| 1 | #cxx . . $ `<file>/ref10/crypto_sign/ge_scalarmult_base.c`/include "ge.h"cxx . . $ `<file>/ref10/crypto_sign/ge.h`/ |
| 2 | #include "crypto_uint32.h"cxx . . $ `<file>/ref10/include/crypto_uint32.h`/ |
| 3 | |
| 4 | static unsigned char equalcxx . . $ equal(b63b4cf3975aab6f).(signed char b,signed char c) |
| 5 | { |
| 6 | unsigned char ub = b; |
| 7 | unsigned char uc = c; |
| 8 | unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */ |
| 9 | crypto_uint32cxx . . $ crypto_uint32# y = x; /* 0: yes; 1..255: no */ |
| 10 | y -= 1; /* 4294967295: yes; 0..254: no */ |
| 11 | y >>= 31; /* 1: yes; 0: no */ |
| 12 | return y; |
| 13 | } |
| 14 | |
| 15 | static unsigned char negativecxx . . $ negative(9f01a6f1cb204fc).(signed char b) |
| 16 | { |
| 17 | unsigned long long x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */ |
| 18 | x >>= 63; /* 1: yes; 0: no */ |
| 19 | return x; |
| 20 | } |
| 21 | |
| 22 | static void cmovcxx . . $ cmov(788d05794913be5d).(ge_precompcxx . . $ ge_precomp# *t,ge_precompcxx . . $ ge_precomp# *u,unsigned char b) |
| 23 | { |
| 24 | fe_cmovcxx . . $ `ref10/crypto_sign/fe.h:25:9`!(t->yplusxcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#yplusx.,u->yplusxcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#yplusx.,b); |
| 25 | fe_cmovcxx . . $ `ref10/crypto_sign/fe.h:25:9`!(t->yminusxcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#yminusx.,u->yminusxcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#yminusx.,b); |
| 26 | fe_cmovcxx . . $ `ref10/crypto_sign/fe.h:25:9`!(t->xy2dcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#xy2d.,u->xy2dcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#xy2d.,b); |
| 27 | } |
| 28 | |
| 29 | /* base[i][j] = (j+1)*256^i*B */ |
| 30 | static ge_precompcxx . . $ ge_precomp# basecxx . . $ base.[32][8] = { |
| 31 | #include "base.h"cxx . . $ `<file>/ref10/crypto_sign/base.h`/ |
| 32 | } ; |
| 33 | |
| 34 | static void selectcxx . . $ select(7f892ef48526790c).(ge_precompcxx . . $ ge_precomp# *t,int pos,signed char b) |
| 35 | { |
| 36 | ge_precompcxx . . $ ge_precomp# minust; |
| 37 | unsigned char bnegative = negativecxx . . $ negative(9f01a6f1cb204fc).(b); |
| 38 | unsigned char babs = b - (((-bnegative) & b) << 1); |
| 39 | |
| 40 | ge_precomp_0cxx . . $ `ref10/crypto_sign/ge.h:61:9`!(t); |
| 41 | cmovcxx . . $ cmov(788d05794913be5d).(t,&basecxx . . $ base.[pos][0],equalcxx . . $ equal(b63b4cf3975aab6f).(babs,1)); |
| 42 | cmovcxx . . $ cmov(788d05794913be5d).(t,&basecxx . . $ base.[pos][1],equalcxx . . $ equal(b63b4cf3975aab6f).(babs,2)); |
| 43 | cmovcxx . . $ cmov(788d05794913be5d).(t,&basecxx . . $ base.[pos][2],equalcxx . . $ equal(b63b4cf3975aab6f).(babs,3)); |
| 44 | cmovcxx . . $ cmov(788d05794913be5d).(t,&basecxx . . $ base.[pos][3],equalcxx . . $ equal(b63b4cf3975aab6f).(babs,4)); |
| 45 | cmovcxx . . $ cmov(788d05794913be5d).(t,&basecxx . . $ base.[pos][4],equalcxx . . $ equal(b63b4cf3975aab6f).(babs,5)); |
| 46 | cmovcxx . . $ cmov(788d05794913be5d).(t,&basecxx . . $ base.[pos][5],equalcxx . . $ equal(b63b4cf3975aab6f).(babs,6)); |
| 47 | cmovcxx . . $ cmov(788d05794913be5d).(t,&basecxx . . $ base.[pos][6],equalcxx . . $ equal(b63b4cf3975aab6f).(babs,7)); |
| 48 | cmovcxx . . $ cmov(788d05794913be5d).(t,&basecxx . . $ base.[pos][7],equalcxx . . $ equal(b63b4cf3975aab6f).(babs,8)); |
| 49 | fe_copycxx . . $ `ref10/crypto_sign/fe.h:20:9`!(minust.yplusxcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#yplusx.,t->yminusxcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#yminusx.); |
| 50 | fe_copycxx . . $ `ref10/crypto_sign/fe.h:20:9`!(minust.yminusxcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#yminusx.,t->yplusxcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#yplusx.); |
| 51 | fe_negcxx . . $ `ref10/crypto_sign/fe.h:28:9`!(minust.xy2dcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#xy2d.,t->xy2dcxx . . $ $anonymous_type_e34c44a02fdbb0a4_3#xy2d.); |
| 52 | cmovcxx . . $ cmov(788d05794913be5d).(t,&minust,bnegative); |
| 53 | } |
| 54 | |
| 55 | /* |
| 56 | h = a * B |
| 57 | where a = a[0]+256*a[1]+...+256^31 a[31] |
| 58 | B is the Ed25519 base point (x,4/5) with x positive. |
| 59 | |
| 60 | Preconditions: |
| 61 | a[31] <= 127 |
| 62 | */ |
| 63 | |
| 64 | void ge_scalarmult_basecxx . . $ `ref10/crypto_sign/ge.h:73:9`!(ge_p3cxx . . $ ge_p3# *h,const unsigned char *a) |
| 65 | { |
| 66 | signed char e[64]; |
| 67 | signed char carry; |
| 68 | ge_p1p1cxx . . $ ge_p1p1# r; |
| 69 | ge_p2cxx . . $ ge_p2# s; |
| 70 | ge_precompcxx . . $ ge_precomp# t; |
| 71 | int i; |
| 72 | |
| 73 | for (i = 0;i < 32;++i) { |
| 74 | e[2 * i + 0] = (a[i] >> 0) & 15; |
| 75 | e[2 * i + 1] = (a[i] >> 4) & 15; |
| 76 | } |
| 77 | /* each e[i] is between 0 and 15 */ |
| 78 | /* e[63] is between 0 and 7 */ |
| 79 | |
| 80 | carry = 0; |
| 81 | for (i = 0;i < 63;++i) { |
| 82 | e[i] += carry; |
| 83 | carry = e[i] + 8; |
| 84 | carry >>= 4; |
| 85 | e[i] -= carry << 4; |
| 86 | } |
| 87 | e[63] += carry; |
| 88 | /* each e[i] is between -8 and 8 */ |
| 89 | |
| 90 | ge_p3_0cxx . . $ `ref10/crypto_sign/ge.h:60:9`!(h); |
| 91 | for (i = 1;i < 64;i += 2) { |
| 92 | selectcxx . . $ select(7f892ef48526790c).(&t,i / 2,e[i]); |
| 93 | ge_maddcxx . . $ `ref10/crypto_sign/ge.h:69:9`!(&r,h,&t); ge_p1p1_to_p3cxx . . $ `ref10/crypto_sign/ge.h:65:9`!(h,&r); |
| 94 | } |
| 95 | |
| 96 | ge_p3_dblcxx . . $ `ref10/crypto_sign/ge.h:67:9`!(&r,h); ge_p1p1_to_p2cxx . . $ `ref10/crypto_sign/ge.h:64:9`!(&s,&r); |
| 97 | ge_p2_dblcxx . . $ `ref10/crypto_sign/ge.h:66:9`!(&r,&s); ge_p1p1_to_p2cxx . . $ `ref10/crypto_sign/ge.h:64:9`!(&s,&r); |
| 98 | ge_p2_dblcxx . . $ `ref10/crypto_sign/ge.h:66:9`!(&r,&s); ge_p1p1_to_p2cxx . . $ `ref10/crypto_sign/ge.h:64:9`!(&s,&r); |
| 99 | ge_p2_dblcxx . . $ `ref10/crypto_sign/ge.h:66:9`!(&r,&s); ge_p1p1_to_p3cxx . . $ `ref10/crypto_sign/ge.h:65:9`!(h,&r); |
| 100 | |
| 101 | for (i = 0;i < 64;i += 2) { |
| 102 | selectcxx . . $ select(7f892ef48526790c).(&t,i / 2,e[i]); |
| 103 | ge_maddcxx . . $ `ref10/crypto_sign/ge.h:69:9`!(&r,h,&t); ge_p1p1_to_p3cxx . . $ `ref10/crypto_sign/ge.h:65:9`!(h,&r); |
| 104 | } |
| 105 | } |