-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Hi, I'm trying to convert my ed25519 keypair to x25519 keypair, which can be achieved by provided functions
- sodium.crypto_sign_ed25519_pk_to_curve25519(x25519_public, ed25519_public)
- sodium.crypto_sign_ed25519_sk_to_curve25519(x25519_secret, ed25519_secret)
Currently I'm generating x25519 keypair buffer with the following functions
{
publicKey: sodium.sodium_malloc(sodium.crypto_box_PUBLICKEYBYTES),
secretKey: sodium.sodium_malloc(sodium.crypto_box_SECRETKEYBYTES)
}
I was able to convert public key, but it looks like converting secret key raises the following assertion error.
edSk must be 'crypto_sign_ed25519_SECRETKEYBYTES' long
My ed25519 secret key is 32 bytes, and it looks like crypto_sign_ed25519_SECRETKEYBYTES is 64 bytes. Now what I'm curious is even though it's checking for 64 bytes, it looks like a subsequent call is only using 32 bytes of the buffer
crypto_hash(h, edSk, 32)
- Is there a reason the assertion is looking for 64 bytes when only 32 bytes are being used?
- Is it safe if I just pad additional 32 bytes to my private key and pass this assertion?
Metadata
Metadata
Assignees
Labels
No labels