Debian Codegraph @

crypto_sign/ed25519/ref10/sign.c

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