Invalid ed25519_pk generated by crypto_scalarmult_ed25519_base / crypto_sign_ed25519_sk_to_pk ? #1271
Replies: 3 comments
-
What I am really looking for, in the context of my project, is a way to verify the signatures with the ed25519_pk created by crypto_scalarmult_ed25519_base / crypto_sign_ed25519_sk_to_pk. Essentially, a crypto_sign_verify_detached() that will work with the _pk created by crypto_scalarmult_ed25519_base / crypto_sign_ed25519_sk_to_pk. |
Beta Was this translation helpful? Give feedback.
-
The documentation on signatures say that the secret keys for signatures are That's 64 bytes, not the same as scalars for multiplications over Edwards25519 ( The same documentation page mentions that secret keys contain a seed and a copy of the public key. Looking at the references on EdDSA given below, an EdDSA public key is computed as So, if you really want to use the But, then, you just rewrote the |
Beta Was this translation helpful? Give feedback.
-
Use the provided constants for sizes. In that example, That prevents vulnerabilities, such as here, giving a 32 bytes array to a function that is going to write 64 bytes. |
Beta Was this translation helpful? Give feedback.
-
The issue is that the ed25519_pk generated by crypto_sign_keypair / crypto_sign_ed25519_keypair is valid and can be used for verifying signatures, but a _pk seperately generated from the same _sk with crypto_scalarmult_ed25519_base or crypto_sign_ed25519_sk_to_pk is different and not able to verify signatures created by the secret key that created it.
Basically, it seems like to generate a proper _pk, the following primitives should be used, however they are not available in the library:
ge25519_p3 A;
ge25519_scalarmult_base(&A, sk);
ge25519_p3_tobytes(pk, &A);
The code is self explanatory. Compile and run, you will understand.
`
#include <string.h>
#include <sodium.h>
void test(const unsigned char ed25519_pk[32],const unsigned char ed25519_sk[32])
{
unsigned char message[] = "hello peoples of earth and the sun";
size_t message_len = strlen((char*)message);
}
int main(void)
{
if (sodium_init() < 0)
exit(-1);
}
`
Beta Was this translation helpful? Give feedback.
All reactions