mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-05-18 07:53:08 +00:00
init
This commit is contained in:
commit
9b80e8676c
95 changed files with 6502 additions and 0 deletions
46
ed25519/ref10/keypair.c
Normal file
46
ed25519/ref10/keypair.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
#include <string.h>
|
||||
#include "randombytes.h"
|
||||
#include "crypto_sign.h"
|
||||
#include "crypto_hash_sha512.h"
|
||||
#include "ge.h"
|
||||
|
||||
int crypto_sign_seckey_expand(unsigned char *sk,const unsigned char *seed)
|
||||
{
|
||||
crypto_hash_sha512(sk,seed,32);
|
||||
sk[0] &= 248;
|
||||
sk[31] &= 63;
|
||||
sk[31] |= 64;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int crypto_sign_seckey(unsigned char *sk)
|
||||
{
|
||||
unsigned char seed[32];
|
||||
|
||||
if (randombytes(seed,32) < 0)
|
||||
return -1;
|
||||
|
||||
crypto_sign_seckey_expand(sk,seed);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int crypto_sign_pubkey(unsigned char *pk,const unsigned char *sk)
|
||||
{
|
||||
ge_p3 A;
|
||||
|
||||
ge_scalarmult_base(&A,sk);
|
||||
ge_p3_tobytes(pk,&A);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int crypto_sign_keypair(unsigned char *pk,unsigned char *sk)
|
||||
{
|
||||
crypto_sign_seckey(sk);
|
||||
crypto_sign_pubkey(pk,sk);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue