Debian Codegraph @

curve/ed25519/additions/keygen.c

raw
1 #include "ge.h"
2 #include "keygen.h"
3 #include "crypto_additions.h"
4
5 void curve25519_keygen(unsigned char* curve25519_pubkey_out,
6 const unsigned char* curve25519_privkey_in)
7 {
8 /* Perform a fixed-base multiplication of the Edwards base point,
9 (which is efficient due to precalculated tables), then convert
10 to the Curve25519 montgomery-format public key.
11
12 NOTE: y=1 is converted to u=0 since fe_invert is mod-exp
13 */
14
15 ge_p3 ed; /* Ed25519 pubkey point */
16 fe u;
17
18 ge_scalarmult_base(&ed, curve25519_privkey_in);
19 ge_p3_to_montx(u, &ed);
20 fe_tobytes(curve25519_pubkey_out, u);
21 }