Replies: 6 comments
-
They aren't supposed to be the same keys, encrypting and signing use different curves. Encryption uses Curve25519, while signing uses Ed25519. This Cryptography StackExchange post might help explain this design choice a bit. You can try using ed2curve.js to convert Ed25519 keys (signing keys) to Curve25519 keys (encryption keys), but there is currently no proof that this is safe to do. It is safer to share both Ed25519 and Curve25519 public keys (their concatenation is 64 bytes long). |
Beta Was this translation helpful? Give feedback.
-
Thank you ! |
Beta Was this translation helpful? Give feedback.
-
From https://cr.yp.to/ecdh.html:
|
Beta Was this translation helpful? Give feedback.
-
If you set up your public key storage system properly, you shouldn't need to check whether a given public key is Ed25519 or Curve25519, you should just simply label each public key appropriately wherever you are storing/transmitting them or come up with a consistent system if you want to store them together (example: you can store the concatenation of the Curve25519 and Ed25519 keys, so you know that bytes 1-32 are the Curve25519 key and bytes 33-64 are the Ed25519 key because that's how you've combined them together). |
Beta Was this translation helpful? Give feedback.
-
If i was able to choose what user use, i certainly choose what you suggest 32bytes curve + 32 bytes ed.
this way, thoses using my lib can use any pubkey and it will do the job. |
Beta Was this translation helpful? Give feedback.
-
My apologies, I missed this comment for some reason! Your plan seems to rely on some assumptions (like hoping that ed2curve will throw an error), which may not always be true in all circumstances. In general (and especially in the field of cryptography), you want to make sure that there are no circumstances where your algorithm can fail or produce unintended results. Perhaps you can add separate functions or a separate parameter to your library to differentiate between what types of keys are being supplied? I don't think it's a good idea to try and guess what type of public key is being supplied to the library, it's far better to include an extra piece of data along with the key to differentiate the two types of keys (you said that Ed25519 is the one already being used so maybe you can have that as the default parameter if no key type details are supplied and have the optional parameter for the key type which should be used always in the future for any new generated keys). |
Beta Was this translation helpful? Give feedback.
-
Here is some pseudo-code (without b64 to Uint8Array conversion) to show an unespected difference.
Why the pubkey isn't the same ?
Have I any way to encrypt a message to a distant user knowing only his signPubKey (and my seed/secretKey and pubkey) ?
Beta Was this translation helpful? Give feedback.
All reactions