crypto_sign_seed_keypair + crypto_scalarmult_ed25519 #1326
-
How would one get the ed25519 public key from the key returned by crypto_sign_seed_keypair ? If I you generate a "normal" ed25519 key without signing..., And then to derive a shared secret Those keys are "clamped" So the guide here shows you how to convert an ED25519 signing key to X25519 It also shows how to grab the ed25519 secret key from the key from the sign key gen function How do you convert a public key from crypto_sign_seed_keypair into something that would work with crypto_scalarmult_ed25519 on a remote machine for DH, or would it already work as is? I know the ED signing keys do a bunch of bit twiddling to make signing work right, includes an SHA512 key for deterministic signatures, ie no need to generate nonce The example at https://libsodium.gitbook.io/doc/advanced/ed25519-curve25519 shows only the way to get the SK for use in crypto_scalarmult_ed25519, but not the PK. The use case is offline, stateless encryption + signing, similar to PGP, with no forward secrecy. Is the best way to do it to convert keys from ED25519 to X25519? Or can the public signing key be properly used with crypto_scalarmult_ed25519 with no changes? I hear that some ed25519 edwards keys cannot be converted to montgomery x25519. Internally
If there's anything funny or questionable about the different codepaths and incompatible behavior, I am inclined to generate a long term signing key and long term encryption key that are separate. Or is converting the signing keys to X25519 for libsodium well understood and supported, and the best way, vs trying to use with crypto_scalarmult_ed25519, if I want a single keyset? Nothing says I can't use both a long term ED25519 pub key and X25519 pub key as an identity though for my purpose. 64 bytes won't kill anyone. I think I understand the basics here, but definitely not the math. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
The But The FAQ has an entire section on signing and encrypting with a single key pair. |
Beta Was this translation helpful? Give feedback.
-
Yea, I linked to that faq a few times. If you only have the PK from crypto_sign_seed_keypair - say someone generated a key and shared their PK - can that be used with crypto_scalarmult_ed25519 directly? The FAQ and notes show how to convert the SK\seed for the local end, but not the shared PK for the remote end. It doesn't say anything about the PK from what I can see. Do any conversions need to happen on the PK shared out from crypto_sign_seed_keypair before passing to crypto_scalarmult_ed25519 for DH? Or said another way, does verify_detached work with the PK from crypto_sign_ed25519_sk_to_pk()? Is it the same PK that crypto_sign_ed25519_seed_keypair returns? It's not clear to me if the PK is in the right format for both verifying sigs and for scalermult_ed25519. A bunch of folks on reddit go back and forth - saying converting keys is unnecessary and everyone jumps to it, just do DH over ED curve. Others say you need to convert. ChatGPT 4 seems to know how to use libsodium well enough, it thinks converting is the way. |
Beta Was this translation helpful? Give feedback.
Once you have computed the edwards25519 scalar from the ed25519 seed, the output of
crypto_scalarmult_ed25519_base()
should be the same as the ed25519 public key.But wouldn't it be easier just to use 64 byte public keys?