Debian Codegraph @

crypto_nG/merged25519/arm64-neonplusuma10l-opt/nG.c

raw symbols SCIP
1 // 20240926 djb: use cryptoint
2 #include <string.h>
3 #include "crypto_nG.h"
4 #include "crypto_hash_sha512.h"
5 #include "randombytes.h"
6 #include "fe25519.h"
7 #include "sc25519.h"
8 #include "ge25519.h"
9 #include "crypto_uint8.h"
10
11 void crypto_nG(unsigned char *pk,const unsigned char *sk)
12 {
13 unsigned char e[32];
14 sc25519 scsk;
15 ge25519_p2_10l_dense gepk;
16 fe25519_10l_dense recip;
17 fe25519_10l_dense r,s;
18 fe25519 x,y;
19 int wantmont;
20
21 for (int i = 0;i < 32;++i) e[i] = sk[i];
22 wantmont = crypto_uint8_topbit_01(e[31]);
23 e[31] &= 127;
24
25 sc25519_from32bytes(&scsk,e);
26
27 ge25519_scalarmult_base(&gepk, &scsk, wantmont);
28
29 fe25519_10l_dense_to_4l(&x,&gepk.z);
30 fe25519_invert(&y,&x);
31 fe25519_4l_to_10l_dense(&recip,&y);
32 fe25519_mul(&s,&gepk.y,&recip);
33 fe25519_mul(&r,&gepk.x,&recip);
34
35 fe25519_10l_dense_to_4l(&y,&s);
36 fe25519_10l_dense_to_4l(&x,&r);
37
38 fe25519_pack(pk,&y);
39 pk[31] ^= crypto_uint8_shlmod((1-wantmont) & fe25519_getparity(&x),7);
40 }