]> pd.if.org Git - zpackage/blob - crypto/ref10/fe_mul121666.c
remove stray debug fprintf
[zpackage] / crypto / ref10 / fe_mul121666.c
1 #include <stdint.h>
2
3 /*
4 h = f * 121666
5 Can overlap h with f.
6
7 Preconditions:
8    |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
9
10 Postconditions:
11    |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
12 */
13
14 void fe_mul121666(int32_t h[10], int32_t f[10]) {
15         int32_t f0 = f[0];
16         int32_t f1 = f[1];
17         int32_t f2 = f[2];
18         int32_t f3 = f[3];
19         int32_t f4 = f[4];
20         int32_t f5 = f[5];
21         int32_t f6 = f[6];
22         int32_t f7 = f[7];
23         int32_t f8 = f[8];
24         int32_t f9 = f[9];
25         int64_t h0 = f0 * (int64_t) 121666;
26         int64_t h1 = f1 * (int64_t) 121666;
27         int64_t h2 = f2 * (int64_t) 121666;
28         int64_t h3 = f3 * (int64_t) 121666;
29         int64_t h4 = f4 * (int64_t) 121666;
30         int64_t h5 = f5 * (int64_t) 121666;
31         int64_t h6 = f6 * (int64_t) 121666;
32         int64_t h7 = f7 * (int64_t) 121666;
33         int64_t h8 = f8 * (int64_t) 121666;
34         int64_t h9 = f9 * (int64_t) 121666;
35         int64_t carry0;
36         int64_t carry1;
37         int64_t carry2;
38         int64_t carry3;
39         int64_t carry4;
40         int64_t carry5;
41         int64_t carry6;
42         int64_t carry7;
43         int64_t carry8;
44         int64_t carry9;
45
46         carry9 = (h9 + (int64_t) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
47         carry1 = (h1 + (int64_t) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
48         carry3 = (h3 + (int64_t) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
49         carry5 = (h5 + (int64_t) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
50         carry7 = (h7 + (int64_t) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;
51
52         carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
53         carry2 = (h2 + (int64_t) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
54         carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
55         carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
56         carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
57
58         h[0] = h0;
59         h[1] = h1;
60         h[2] = h2;
61         h[3] = h3;
62         h[4] = h4;
63         h[5] = h5;
64         h[6] = h6;
65         h[7] = h7;
66         h[8] = h8;
67         h[9] = h9;
68 }