| 1 | #include <string.h> | ||
| 2 | #include "ed25519.h" | ||
| 3 | #include "sha512.h" | ||
| 4 | #include "ge.h" | ||
| 5 | |||
| 6 | |||
| 7 | 0 | void ed25519_create_keypair(unsigned char *public_key, unsigned char *private_key, const unsigned char *seed) { | |
| 8 | ge_p3 A; | ||
| 9 | |||
| 10 | 0 | sha512(seed, 32, private_key); | |
| 11 | 0 | private_key[0] &= 248; | |
| 12 | 0 | private_key[31] &= 63; | |
| 13 | 0 | private_key[31] |= 64; | |
| 14 | |||
| 15 | 0 | ge_scalarmult_base(&A, private_key); | |
| 16 | 0 | ge_p3_tobytes(public_key, &A); | |
| 17 | |||
| 18 | 0 | memmove(private_key, seed, 32); | |
| 19 | 0 | memmove(private_key + 32, public_key, 32); | |
| 20 | 0 | } |