8 |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
11 |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
15 See fe_mul.c for discussion of implementation strategy.
18 void fe_sq(int32_t h[10], int32_t f[10]) {
29 int32_t f0_2 = 2 * f0;
30 int32_t f1_2 = 2 * f1;
31 int32_t f2_2 = 2 * f2;
32 int32_t f3_2 = 2 * f3;
33 int32_t f4_2 = 2 * f4;
34 int32_t f5_2 = 2 * f5;
35 int32_t f6_2 = 2 * f6;
36 int32_t f7_2 = 2 * f7;
37 int32_t f5_38 = 38 * f5; /* 1.31*2^30 */
38 int32_t f6_19 = 19 * f6; /* 1.31*2^30 */
39 int32_t f7_38 = 38 * f7; /* 1.31*2^30 */
40 int32_t f8_19 = 19 * f8; /* 1.31*2^30 */
41 int32_t f9_38 = 38 * f9; /* 1.31*2^30 */
42 int64_t f0f0 = f0 * (int64_t) f0;
43 int64_t f0f1_2 = f0_2 * (int64_t) f1;
44 int64_t f0f2_2 = f0_2 * (int64_t) f2;
45 int64_t f0f3_2 = f0_2 * (int64_t) f3;
46 int64_t f0f4_2 = f0_2 * (int64_t) f4;
47 int64_t f0f5_2 = f0_2 * (int64_t) f5;
48 int64_t f0f6_2 = f0_2 * (int64_t) f6;
49 int64_t f0f7_2 = f0_2 * (int64_t) f7;
50 int64_t f0f8_2 = f0_2 * (int64_t) f8;
51 int64_t f0f9_2 = f0_2 * (int64_t) f9;
52 int64_t f1f1_2 = f1_2 * (int64_t) f1;
53 int64_t f1f2_2 = f1_2 * (int64_t) f2;
54 int64_t f1f3_4 = f1_2 * (int64_t) f3_2;
55 int64_t f1f4_2 = f1_2 * (int64_t) f4;
56 int64_t f1f5_4 = f1_2 * (int64_t) f5_2;
57 int64_t f1f6_2 = f1_2 * (int64_t) f6;
58 int64_t f1f7_4 = f1_2 * (int64_t) f7_2;
59 int64_t f1f8_2 = f1_2 * (int64_t) f8;
60 int64_t f1f9_76 = f1_2 * (int64_t) f9_38;
61 int64_t f2f2 = f2 * (int64_t) f2;
62 int64_t f2f3_2 = f2_2 * (int64_t) f3;
63 int64_t f2f4_2 = f2_2 * (int64_t) f4;
64 int64_t f2f5_2 = f2_2 * (int64_t) f5;
65 int64_t f2f6_2 = f2_2 * (int64_t) f6;
66 int64_t f2f7_2 = f2_2 * (int64_t) f7;
67 int64_t f2f8_38 = f2_2 * (int64_t) f8_19;
68 int64_t f2f9_38 = f2 * (int64_t) f9_38;
69 int64_t f3f3_2 = f3_2 * (int64_t) f3;
70 int64_t f3f4_2 = f3_2 * (int64_t) f4;
71 int64_t f3f5_4 = f3_2 * (int64_t) f5_2;
72 int64_t f3f6_2 = f3_2 * (int64_t) f6;
73 int64_t f3f7_76 = f3_2 * (int64_t) f7_38;
74 int64_t f3f8_38 = f3_2 * (int64_t) f8_19;
75 int64_t f3f9_76 = f3_2 * (int64_t) f9_38;
76 int64_t f4f4 = f4 * (int64_t) f4;
77 int64_t f4f5_2 = f4_2 * (int64_t) f5;
78 int64_t f4f6_38 = f4_2 * (int64_t) f6_19;
79 int64_t f4f7_38 = f4 * (int64_t) f7_38;
80 int64_t f4f8_38 = f4_2 * (int64_t) f8_19;
81 int64_t f4f9_38 = f4 * (int64_t) f9_38;
82 int64_t f5f5_38 = f5 * (int64_t) f5_38;
83 int64_t f5f6_38 = f5_2 * (int64_t) f6_19;
84 int64_t f5f7_76 = f5_2 * (int64_t) f7_38;
85 int64_t f5f8_38 = f5_2 * (int64_t) f8_19;
86 int64_t f5f9_76 = f5_2 * (int64_t) f9_38;
87 int64_t f6f6_19 = f6 * (int64_t) f6_19;
88 int64_t f6f7_38 = f6 * (int64_t) f7_38;
89 int64_t f6f8_38 = f6_2 * (int64_t) f8_19;
90 int64_t f6f9_38 = f6 * (int64_t) f9_38;
91 int64_t f7f7_38 = f7 * (int64_t) f7_38;
92 int64_t f7f8_38 = f7_2 * (int64_t) f8_19;
93 int64_t f7f9_76 = f7_2 * (int64_t) f9_38;
94 int64_t f8f8_19 = f8 * (int64_t) f8_19;
95 int64_t f8f9_38 = f8 * (int64_t) f9_38;
96 int64_t f9f9_38 = f9 * (int64_t) f9_38;
97 int64_t h0 = f0f0 +f1f9_76+f2f8_38+f3f7_76+f4f6_38+f5f5_38;
98 int64_t h1 = f0f1_2+f2f9_38+f3f8_38+f4f7_38+f5f6_38;
99 int64_t h2 = f0f2_2+f1f1_2 +f3f9_76+f4f8_38+f5f7_76+f6f6_19;
100 int64_t h3 = f0f3_2+f1f2_2 +f4f9_38+f5f8_38+f6f7_38;
101 int64_t h4 = f0f4_2+f1f3_4 +f2f2 +f5f9_76+f6f8_38+f7f7_38;
102 int64_t h5 = f0f5_2+f1f4_2 +f2f3_2 +f6f9_38+f7f8_38;
103 int64_t h6 = f0f6_2+f1f5_4 +f2f4_2 +f3f3_2 +f7f9_76+f8f8_19;
104 int64_t h7 = f0f7_2+f1f6_2 +f2f5_2 +f3f4_2 +f8f9_38;
105 int64_t h8 = f0f8_2+f1f7_4 +f2f6_2 +f3f5_4 +f4f4 +f9f9_38;
106 int64_t h9 = f0f9_2+f1f8_2 +f2f7_2 +f3f6_2 +f4f5_2;
118 carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;
119 carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
121 carry1 = (h1 + (int64_t) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25;
122 carry5 = (h5 + (int64_t) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25;
124 carry2 = (h2 + (int64_t) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26;
125 carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26;
127 carry3 = (h3 + (int64_t) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25;
128 carry7 = (h7 + (int64_t) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25;
130 carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26;
131 carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26;
133 carry9 = (h9 + (int64_t) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25;
135 carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26;