Debian Codegraph @

ref10/crypto_sign/sign.c

raw symbols SCIP
1 #include <string.h>
2 #include "crypto_sign.h"
3 #include "crypto_hash_sha512.h"
4 #include "ge.h"
5 #include "sc.h"
6
7 int crypto_sign(
8 unsigned char *sm,unsigned long long *smlen,
9 const unsigned char *m,unsigned long long mlen,
10 const unsigned char *sk
11 )
12 {
13 unsigned char pk[32];
14 unsigned char az[64];
15 unsigned char nonce[64];
16 unsigned char hram[64];
17 ge_p3 R;
18
19 memmove(pk,sk + 32,32);
20
21 crypto_hash_sha512(az,sk,32);
22 az[0] &= 248;
23 az[31] &= 63;
24 az[31] |= 64;
25
26 *smlen = mlen + 64;
27 memmove(sm + 64,m,mlen);
28 memmove(sm + 32,az + 32,32);
29 crypto_hash_sha512(nonce,sm + 32,mlen + 32);
30 memmove(sm + 32,pk,32);
31
32 sc_reduce(nonce);
33 ge_scalarmult_base(&R,nonce);
34 ge_p3_tobytes(sm,&R);
35
36 crypto_hash_sha512(hram,sm,mlen + 64);
37 sc_reduce(hram);
38 sc_muladd(sm + 32,hram,az,nonce);
39
40 return 0;
41 }