Closed alwitt closed 1 year ago
I'm no cryptographer, but should we not be testing with X25519 key pairs as opposed to Ed25519?
$ openssl genpkey -algorithm X25519 -out prv.pem
$ openssl pkey -in prv.pem -pubout -out pub.pem
Quote: 'The public key representations are related but not the same. They cannot be used interchangeably without additional processing.' Source: https://crypto.stackexchange.com/questions/76156/public-key-generation-for-ed25519-vs-x25519 Author: Frank Denis
Yeah, it seems like the code example in the OP is using ed25519::pkcs8
, which is for the Edwards form of Curve25519.
X25519 uses the Montgomery form. It's possible to convert from the Edwards form to the Montgomery form, but they are distinct.
@tarcieri thank you for clarifying. I am glad to see there are activities in this repo again.
I am testing this crate (
v1.2.0
) using a ED25519 key pair generated byOpenSSL 1.1.1o FIPS 3 May 2022
, and checking for correct DH shared secret generation against ax25519_dalek::EphemeralSecret
based key pair.The issue I am seeing is that starting from the private key generated by OpenSSL, the pubic key generated by
PublicKey::from
for that private key is different from what OpenSSL generated. Am I using the APIs correctly? What is the correct way to use existing key pairs?The complete test code