Debian Codegraph @

fiat-java/src/FiatPoly1305.java

raw symbols SCIP
1 /* Autogenerated: 'src/ExtractionOCaml/unsaturated_solinas' --lang Java --cmovznz-by-mul --widen-carry --widen-bytes --internal-static --package-name fiat_crypto --class-case UpperCamelCase --no-field-element-typedefs Poly1305 32 '(auto)' '2^130 - 5' carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes relax */
2 /* curve description: Poly1305 */
3 /* machine_wordsize = 32 (from "32") */
4 /* requested operations: carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, relax */
5 /* n = 5 (from "(auto)") */
6 /* s-c = 2^130 - [(1, 5)] (from "2^130 - 5") */
7 /* tight_bounds_multiplier = 1 (from "") */
8 /* */
9 /* Computed values: */
10 /* carry_chain = [0, 1, 2, 3, 4, 0, 1] */
11 /* eval z = z[0] + (z[1] << 26) + (z[2] << 52) + (z[3] << 78) + (z[4] << 104) */
12 /* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) */
13 /* balance = [0x7fffff6, 0x7fffffe, 0x7fffffe, 0x7fffffe, 0x7fffffe] */
14
15 package fiat_crypto;
16
17 public final class FiatPoly1305 {
18
19 static class Box<T> {
20 private T value;
21 public Box(T value) { this.value = value; }
22 public void set(T value) { this.value = value; }
23 public T get() { return this.value; }
24 }
25
26
27
28 /**
29 * The function fiat_Poly1305_addcarryx_u26 is an addition with carry. <p>
30 * <p>
31 * Postconditions: <p>
32 * out1 = (arg1 + arg2 + arg3) mod 2^26 <p>
33 * out2 = ⌊(arg1 + arg2 + arg3) / 2^26⌋ <p>
34 * <p>
35 * Input Bounds: <p>
36 * arg1: [0x0 ~&gt; 0x1] <p>
37 * arg2: [0x0 ~&gt; 0x3ffffff] <p>
38 * arg3: [0x0 ~&gt; 0x3ffffff] <p>
39 * Output Bounds: <p>
40 * out1: [0x0 ~&gt; 0x3ffffff] <p>
41 * out2: [0x0 ~&gt; 0x1] <p>
42 */
43 static void fiat_Poly1305_addcarryx_u26(Box<Integer> out1, Box<Integer> out2, int arg1, int arg2, int arg3) {
44 int x1 = ((arg1 + arg2) + arg3);
45 int x2 = (x1 & 0x3ffffff);
46 int x3 = (x1 >>> 26);
47 out1.set(x2);
48 out2.set(x3);
49 }
50
51 /**
52 * The function fiat_Poly1305_subborrowx_u26 is a subtraction with borrow. <p>
53 * <p>
54 * Postconditions: <p>
55 * out1 = (-arg1 + arg2 + -arg3) mod 2^26 <p>
56 * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^26⌋ <p>
57 * <p>
58 * Input Bounds: <p>
59 * arg1: [0x0 ~&gt; 0x1] <p>
60 * arg2: [0x0 ~&gt; 0x3ffffff] <p>
61 * arg3: [0x0 ~&gt; 0x3ffffff] <p>
62 * Output Bounds: <p>
63 * out1: [0x0 ~&gt; 0x3ffffff] <p>
64 * out2: [0x0 ~&gt; 0x1] <p>
65 */
66 static void fiat_Poly1305_subborrowx_u26(Box<Integer> out1, Box<Integer> out2, int arg1, int arg2, int arg3) {
67 int x1 = (((int) Integer.toUnsignedLong(((Number) (arg2)).intValue()) - (int) Integer.toUnsignedLong(((Number) (arg1)).intValue())) - (int) Integer.toUnsignedLong(((Number) (arg3)).intValue()));
68 int x2 = (x1 >>> 26);
69 int x3 = ((int) Integer.toUnsignedLong(((Number) (x1)).intValue()) & 0x3ffffff);
70 out1.set(x3);
71 out2.set(((int) Integer.toUnsignedLong(((Number) (0x0)).intValue()) - (int) Integer.toUnsignedLong(((Number) (x2)).intValue())));
72 }
73
74 /**
75 * The function fiat_Poly1305_cmovznz_u32 is a single-word conditional move. <p>
76 * <p>
77 * Postconditions: <p>
78 * out1 = (if arg1 = 0 then arg2 else arg3) <p>
79 * <p>
80 * Input Bounds: <p>
81 * arg1: [0x0 ~&gt; 0x1] <p>
82 * arg2: [0x0 ~&gt; 0xffffffff] <p>
83 * arg3: [0x0 ~&gt; 0xffffffff] <p>
84 * Output Bounds: <p>
85 * out1: [0x0 ~&gt; 0xffffffff] <p>
86 */
87 static void fiat_Poly1305_cmovznz_u32(Box<Integer> out1, int arg1, int arg2, int arg3) {
88 int x1 = (arg1 * 0xffffffff);
89 int x2 = ((x1 & arg3) | ((~x1) & arg2));
90 out1.set(x2);
91 }
92
93 /**
94 * The function fiat_Poly1305_carry_mul multiplies two field elements and reduces the result. <p>
95 * <p>
96 * Postconditions: <p>
97 * eval out1 mod m = (eval arg1 * eval arg2) mod m <p>
98 * <p>
99 * Input Bounds: <p>
100 * arg1: [[0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000]] <p>
101 * arg2: [[0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000]] <p>
102 * Output Bounds: <p>
103 * out1: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
104 */
105 public static void fiat_Poly1305_carry_mul(int[] out1, final int[] arg1, final int[] arg2) {
106 long x1 = ((long) Integer.toUnsignedLong(((Number) ((arg1[4]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[4]) * 0x5))).intValue()));
107 long x2 = ((long) Integer.toUnsignedLong(((Number) ((arg1[4]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[3]) * 0x5))).intValue()));
108 long x3 = ((long) Integer.toUnsignedLong(((Number) ((arg1[4]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[2]) * 0x5))).intValue()));
109 long x4 = ((long) Integer.toUnsignedLong(((Number) ((arg1[4]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[1]) * 0x5))).intValue()));
110 long x5 = ((long) Integer.toUnsignedLong(((Number) ((arg1[3]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[4]) * 0x5))).intValue()));
111 long x6 = ((long) Integer.toUnsignedLong(((Number) ((arg1[3]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[3]) * 0x5))).intValue()));
112 long x7 = ((long) Integer.toUnsignedLong(((Number) ((arg1[3]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[2]) * 0x5))).intValue()));
113 long x8 = ((long) Integer.toUnsignedLong(((Number) ((arg1[2]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[4]) * 0x5))).intValue()));
114 long x9 = ((long) Integer.toUnsignedLong(((Number) ((arg1[2]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[3]) * 0x5))).intValue()));
115 long x10 = ((long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (((arg2[4]) * 0x5))).intValue()));
116 long x11 = ((long) Integer.toUnsignedLong(((Number) ((arg1[4]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[0]))).intValue()));
117 long x12 = ((long) Integer.toUnsignedLong(((Number) ((arg1[3]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[1]))).intValue()));
118 long x13 = ((long) Integer.toUnsignedLong(((Number) ((arg1[3]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[0]))).intValue()));
119 long x14 = ((long) Integer.toUnsignedLong(((Number) ((arg1[2]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[2]))).intValue()));
120 long x15 = ((long) Integer.toUnsignedLong(((Number) ((arg1[2]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[1]))).intValue()));
121 long x16 = ((long) Integer.toUnsignedLong(((Number) ((arg1[2]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[0]))).intValue()));
122 long x17 = ((long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[3]))).intValue()));
123 long x18 = ((long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[2]))).intValue()));
124 long x19 = ((long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[1]))).intValue()));
125 long x20 = ((long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[0]))).intValue()));
126 long x21 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[4]))).intValue()));
127 long x22 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[3]))).intValue()));
128 long x23 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[2]))).intValue()));
129 long x24 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[1]))).intValue()));
130 long x25 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg2[0]))).intValue()));
131 long x26 = (x25 + (x10 + (x9 + (x7 + x4))));
132 long x27 = (x26 >>> 26);
133 int x28 = ((int) Integer.toUnsignedLong(((Number) (x26)).intValue()) & 0x3ffffff);
134 long x29 = (x21 + (x17 + (x14 + (x12 + x11))));
135 long x30 = (x22 + (x18 + (x15 + (x13 + x1))));
136 long x31 = (x23 + (x19 + (x16 + (x5 + x2))));
137 long x32 = (x24 + (x20 + (x8 + (x6 + x3))));
138 long x33 = (x27 + x32);
139 long x34 = (x33 >>> 26);
140 int x35 = ((int) Integer.toUnsignedLong(((Number) (x33)).intValue()) & 0x3ffffff);
141 long x36 = (x34 + x31);
142 long x37 = (x36 >>> 26);
143 int x38 = ((int) Integer.toUnsignedLong(((Number) (x36)).intValue()) & 0x3ffffff);
144 long x39 = (x37 + x30);
145 long x40 = (x39 >>> 26);
146 int x41 = ((int) Integer.toUnsignedLong(((Number) (x39)).intValue()) & 0x3ffffff);
147 long x42 = (x40 + x29);
148 int x43 = (int) Integer.toUnsignedLong(((Number) ((x42 >>> 26))).intValue());
149 int x44 = ((int) Integer.toUnsignedLong(((Number) (x42)).intValue()) & 0x3ffffff);
150 long x45 = ((long) Integer.toUnsignedLong(((Number) (x43)).intValue()) * (long) Integer.toUnsignedLong(((Number) (0x5)).intValue()));
151 long x46 = ((long) Integer.toUnsignedLong(((Number) (x28)).intValue()) + x45);
152 int x47 = (int) Integer.toUnsignedLong(((Number) ((x46 >>> 26))).intValue());
153 int x48 = ((int) Integer.toUnsignedLong(((Number) (x46)).intValue()) & 0x3ffffff);
154 int x49 = (x47 + x35);
155 int x50 = (x49 >>> 26);
156 int x51 = (x49 & 0x3ffffff);
157 int x52 = (x50 + x38);
158 out1[0] = x48;
159 out1[1] = x51;
160 out1[2] = x52;
161 out1[3] = x41;
162 out1[4] = x44;
163 }
164
165 /**
166 * The function fiat_Poly1305_carry_square squares a field element and reduces the result. <p>
167 * <p>
168 * Postconditions: <p>
169 * eval out1 mod m = (eval arg1 * eval arg1) mod m <p>
170 * <p>
171 * Input Bounds: <p>
172 * arg1: [[0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000]] <p>
173 * Output Bounds: <p>
174 * out1: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
175 */
176 public static void fiat_Poly1305_carry_square(int[] out1, final int[] arg1) {
177 int x1 = ((arg1[4]) * 0x5);
178 int x2 = (x1 * 0x2);
179 int x3 = ((arg1[4]) * 0x2);
180 int x4 = ((arg1[3]) * 0x5);
181 int x5 = (x4 * 0x2);
182 int x6 = ((arg1[3]) * 0x2);
183 int x7 = ((arg1[2]) * 0x2);
184 int x8 = ((arg1[1]) * 0x2);
185 long x9 = ((long) Integer.toUnsignedLong(((Number) ((arg1[4]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x1)).intValue()));
186 long x10 = ((long) Integer.toUnsignedLong(((Number) ((arg1[3]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x2)).intValue()));
187 long x11 = ((long) Integer.toUnsignedLong(((Number) ((arg1[3]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x4)).intValue()));
188 long x12 = ((long) Integer.toUnsignedLong(((Number) ((arg1[2]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x2)).intValue()));
189 long x13 = ((long) Integer.toUnsignedLong(((Number) ((arg1[2]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x5)).intValue()));
190 long x14 = ((long) Integer.toUnsignedLong(((Number) ((arg1[2]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg1[2]))).intValue()));
191 long x15 = ((long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x2)).intValue()));
192 long x16 = ((long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x6)).intValue()));
193 long x17 = ((long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x7)).intValue()));
194 long x18 = ((long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg1[1]))).intValue()));
195 long x19 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x3)).intValue()));
196 long x20 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x6)).intValue()));
197 long x21 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x7)).intValue()));
198 long x22 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) (x8)).intValue()));
199 long x23 = ((long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()) * (long) Integer.toUnsignedLong(((Number) ((arg1[0]))).intValue()));
200 long x24 = (x23 + (x15 + x13));
201 long x25 = (x24 >>> 26);
202 int x26 = ((int) Integer.toUnsignedLong(((Number) (x24)).intValue()) & 0x3ffffff);
203 long x27 = (x19 + (x16 + x14));
204 long x28 = (x20 + (x17 + x9));
205 long x29 = (x21 + (x18 + x10));
206 long x30 = (x22 + (x12 + x11));
207 long x31 = (x25 + x30);
208 long x32 = (x31 >>> 26);
209 int x33 = ((int) Integer.toUnsignedLong(((Number) (x31)).intValue()) & 0x3ffffff);
210 long x34 = (x32 + x29);
211 long x35 = (x34 >>> 26);
212 int x36 = ((int) Integer.toUnsignedLong(((Number) (x34)).intValue()) & 0x3ffffff);
213 long x37 = (x35 + x28);
214 long x38 = (x37 >>> 26);
215 int x39 = ((int) Integer.toUnsignedLong(((Number) (x37)).intValue()) & 0x3ffffff);
216 long x40 = (x38 + x27);
217 int x41 = (int) Integer.toUnsignedLong(((Number) ((x40 >>> 26))).intValue());
218 int x42 = ((int) Integer.toUnsignedLong(((Number) (x40)).intValue()) & 0x3ffffff);
219 long x43 = ((long) Integer.toUnsignedLong(((Number) (x41)).intValue()) * (long) Integer.toUnsignedLong(((Number) (0x5)).intValue()));
220 long x44 = ((long) Integer.toUnsignedLong(((Number) (x26)).intValue()) + x43);
221 int x45 = (int) Integer.toUnsignedLong(((Number) ((x44 >>> 26))).intValue());
222 int x46 = ((int) Integer.toUnsignedLong(((Number) (x44)).intValue()) & 0x3ffffff);
223 int x47 = (x45 + x33);
224 int x48 = (x47 >>> 26);
225 int x49 = (x47 & 0x3ffffff);
226 int x50 = (x48 + x36);
227 out1[0] = x46;
228 out1[1] = x49;
229 out1[2] = x50;
230 out1[3] = x39;
231 out1[4] = x42;
232 }
233
234 /**
235 * The function fiat_Poly1305_carry reduces a field element. <p>
236 * <p>
237 * Postconditions: <p>
238 * eval out1 mod m = eval arg1 mod m <p>
239 * <p>
240 * Input Bounds: <p>
241 * arg1: [[0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000]] <p>
242 * Output Bounds: <p>
243 * out1: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
244 */
245 public static void fiat_Poly1305_carry(int[] out1, final int[] arg1) {
246 int x1 = (arg1[0]);
247 int x2 = ((x1 >>> 26) + (arg1[1]));
248 int x3 = ((x2 >>> 26) + (arg1[2]));
249 int x4 = ((x3 >>> 26) + (arg1[3]));
250 int x5 = ((x4 >>> 26) + (arg1[4]));
251 int x6 = ((x1 & 0x3ffffff) + ((x5 >>> 26) * 0x5));
252 int x7 = ((x6 >>> 26) + (x2 & 0x3ffffff));
253 int x8 = (x6 & 0x3ffffff);
254 int x9 = (x7 & 0x3ffffff);
255 int x10 = ((x7 >>> 26) + (x3 & 0x3ffffff));
256 int x11 = (x4 & 0x3ffffff);
257 int x12 = (x5 & 0x3ffffff);
258 out1[0] = x8;
259 out1[1] = x9;
260 out1[2] = x10;
261 out1[3] = x11;
262 out1[4] = x12;
263 }
264
265 /**
266 * The function fiat_Poly1305_add adds two field elements. <p>
267 * <p>
268 * Postconditions: <p>
269 * eval out1 mod m = (eval arg1 + eval arg2) mod m <p>
270 * <p>
271 * Input Bounds: <p>
272 * arg1: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
273 * arg2: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
274 * Output Bounds: <p>
275 * out1: [[0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000]] <p>
276 */
277 public static void fiat_Poly1305_add(int[] out1, final int[] arg1, final int[] arg2) {
278 int x1 = ((arg1[0]) + (arg2[0]));
279 int x2 = ((arg1[1]) + (arg2[1]));
280 int x3 = ((arg1[2]) + (arg2[2]));
281 int x4 = ((arg1[3]) + (arg2[3]));
282 int x5 = ((arg1[4]) + (arg2[4]));
283 out1[0] = x1;
284 out1[1] = x2;
285 out1[2] = x3;
286 out1[3] = x4;
287 out1[4] = x5;
288 }
289
290 /**
291 * The function fiat_Poly1305_sub subtracts two field elements. <p>
292 * <p>
293 * Postconditions: <p>
294 * eval out1 mod m = (eval arg1 - eval arg2) mod m <p>
295 * <p>
296 * Input Bounds: <p>
297 * arg1: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
298 * arg2: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
299 * Output Bounds: <p>
300 * out1: [[0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000]] <p>
301 */
302 public static void fiat_Poly1305_sub(int[] out1, final int[] arg1, final int[] arg2) {
303 int x1 = ((0x7fffff6 + (arg1[0])) - (arg2[0]));
304 int x2 = ((0x7fffffe + (arg1[1])) - (arg2[1]));
305 int x3 = ((0x7fffffe + (arg1[2])) - (arg2[2]));
306 int x4 = ((0x7fffffe + (arg1[3])) - (arg2[3]));
307 int x5 = ((0x7fffffe + (arg1[4])) - (arg2[4]));
308 out1[0] = x1;
309 out1[1] = x2;
310 out1[2] = x3;
311 out1[3] = x4;
312 out1[4] = x5;
313 }
314
315 /**
316 * The function fiat_Poly1305_opp negates a field element. <p>
317 * <p>
318 * Postconditions: <p>
319 * eval out1 mod m = -eval arg1 mod m <p>
320 * <p>
321 * Input Bounds: <p>
322 * arg1: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
323 * Output Bounds: <p>
324 * out1: [[0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000]] <p>
325 */
326 public static void fiat_Poly1305_opp(int[] out1, final int[] arg1) {
327 int x1 = (0x7fffff6 - (arg1[0]));
328 int x2 = (0x7fffffe - (arg1[1]));
329 int x3 = (0x7fffffe - (arg1[2]));
330 int x4 = (0x7fffffe - (arg1[3]));
331 int x5 = (0x7fffffe - (arg1[4]));
332 out1[0] = x1;
333 out1[1] = x2;
334 out1[2] = x3;
335 out1[3] = x4;
336 out1[4] = x5;
337 }
338
339 /**
340 * The function fiat_Poly1305_selectznz is a multi-limb conditional select. <p>
341 * <p>
342 * Postconditions: <p>
343 * out1 = (if arg1 = 0 then arg2 else arg3) <p>
344 * <p>
345 * Input Bounds: <p>
346 * arg1: [0x0 ~&gt; 0x1] <p>
347 * arg2: [[0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff]] <p>
348 * arg3: [[0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff]] <p>
349 * Output Bounds: <p>
350 * out1: [[0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff], [0x0 ~&gt; 0xffffffff]] <p>
351 */
352 public static void fiat_Poly1305_selectznz(int[] out1, int arg1, final int[] arg2, final int[] arg3) {
353 Box<Integer> x1 = new Box<Integer>((int)0);
354 fiat_Poly1305_cmovznz_u32(x1, arg1, (arg2[0]), (arg3[0]));
355 Box<Integer> x2 = new Box<Integer>((int)0);
356 fiat_Poly1305_cmovznz_u32(x2, arg1, (arg2[1]), (arg3[1]));
357 Box<Integer> x3 = new Box<Integer>((int)0);
358 fiat_Poly1305_cmovznz_u32(x3, arg1, (arg2[2]), (arg3[2]));
359 Box<Integer> x4 = new Box<Integer>((int)0);
360 fiat_Poly1305_cmovznz_u32(x4, arg1, (arg2[3]), (arg3[3]));
361 Box<Integer> x5 = new Box<Integer>((int)0);
362 fiat_Poly1305_cmovznz_u32(x5, arg1, (arg2[4]), (arg3[4]));
363 out1[0] = (x1).get();
364 out1[1] = (x2).get();
365 out1[2] = (x3).get();
366 out1[3] = (x4).get();
367 out1[4] = (x5).get();
368 }
369
370 /**
371 * The function fiat_Poly1305_to_bytes serializes a field element to bytes in little-endian order. <p>
372 * <p>
373 * Postconditions: <p>
374 * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..16] <p>
375 * <p>
376 * Input Bounds: <p>
377 * arg1: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
378 * Output Bounds: <p>
379 * out1: [[0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0x3]] <p>
380 */
381 public static void fiat_Poly1305_to_bytes(int[] out1, final int[] arg1) {
382 Box<Integer> x1 = new Box<Integer>((int)0);
383 Box<Integer> x2 = new Box<Integer>((int)0);
384 fiat_Poly1305_subborrowx_u26(x1, x2, (int) Integer.toUnsignedLong(((Number) (0x0)).intValue()), (arg1[0]), 0x3fffffb);
385 Box<Integer> x3 = new Box<Integer>((int)0);
386 Box<Integer> x4 = new Box<Integer>((int)0);
387 fiat_Poly1305_subborrowx_u26(x3, x4, (x2).get(), (arg1[1]), 0x3ffffff);
388 Box<Integer> x5 = new Box<Integer>((int)0);
389 Box<Integer> x6 = new Box<Integer>((int)0);
390 fiat_Poly1305_subborrowx_u26(x5, x6, (x4).get(), (arg1[2]), 0x3ffffff);
391 Box<Integer> x7 = new Box<Integer>((int)0);
392 Box<Integer> x8 = new Box<Integer>((int)0);
393 fiat_Poly1305_subborrowx_u26(x7, x8, (x6).get(), (arg1[3]), 0x3ffffff);
394 Box<Integer> x9 = new Box<Integer>((int)0);
395 Box<Integer> x10 = new Box<Integer>((int)0);
396 fiat_Poly1305_subborrowx_u26(x9, x10, (x8).get(), (arg1[4]), 0x3ffffff);
397 Box<Integer> x11 = new Box<Integer>((int)0);
398 fiat_Poly1305_cmovznz_u32(x11, (x10).get(), (int) Integer.toUnsignedLong(((Number) (0x0)).intValue()), 0xffffffff);
399 Box<Integer> x12 = new Box<Integer>((int)0);
400 Box<Integer> x13 = new Box<Integer>((int)0);
401 fiat_Poly1305_addcarryx_u26(x12, x13, 0x0, (x1).get(), ((x11).get() & 0x3fffffb));
402 Box<Integer> x14 = new Box<Integer>((int)0);
403 Box<Integer> x15 = new Box<Integer>((int)0);
404 fiat_Poly1305_addcarryx_u26(x14, x15, (x13).get(), (x3).get(), ((x11).get() & 0x3ffffff));
405 Box<Integer> x16 = new Box<Integer>((int)0);
406 Box<Integer> x17 = new Box<Integer>((int)0);
407 fiat_Poly1305_addcarryx_u26(x16, x17, (x15).get(), (x5).get(), ((x11).get() & 0x3ffffff));
408 Box<Integer> x18 = new Box<Integer>((int)0);
409 Box<Integer> x19 = new Box<Integer>((int)0);
410 fiat_Poly1305_addcarryx_u26(x18, x19, (x17).get(), (x7).get(), ((x11).get() & 0x3ffffff));
411 Box<Integer> x20 = new Box<Integer>((int)0);
412 Box<Integer> x21 = new Box<Integer>((int)0);
413 fiat_Poly1305_addcarryx_u26(x20, x21, (x19).get(), (x9).get(), ((x11).get() & 0x3ffffff));
414 int x22 = ((x18).get() << 6);
415 int x23 = ((x16).get() << 4);
416 int x24 = ((x14).get() << 2);
417 int x25 = ((x12).get() & 0xff);
418 int x26 = ((x12).get() >>> 8);
419 int x27 = (x26 & 0xff);
420 int x28 = (x26 >>> 8);
421 int x29 = (x28 & 0xff);
422 int x30 = (x28 >>> 8);
423 int x31 = (x24 + x30);
424 int x32 = (x31 & 0xff);
425 int x33 = (x31 >>> 8);
426 int x34 = (x33 & 0xff);
427 int x35 = (x33 >>> 8);
428 int x36 = (x35 & 0xff);
429 int x37 = (x35 >>> 8);
430 int x38 = (x23 + x37);
431 int x39 = (x38 & 0xff);
432 int x40 = (x38 >>> 8);
433 int x41 = (x40 & 0xff);
434 int x42 = (x40 >>> 8);
435 int x43 = (x42 & 0xff);
436 int x44 = (x42 >>> 8);
437 int x45 = (x22 + x44);
438 int x46 = (x45 & 0xff);
439 int x47 = (x45 >>> 8);
440 int x48 = (x47 & 0xff);
441 int x49 = (x47 >>> 8);
442 int x50 = (x49 & 0xff);
443 int x51 = (x49 >>> 8);
444 int x52 = ((x20).get() & 0xff);
445 int x53 = ((x20).get() >>> 8);
446 int x54 = (x53 & 0xff);
447 int x55 = (x53 >>> 8);
448 int x56 = (x55 & 0xff);
449 int x57 = (x55 >>> 8);
450 out1[0] = x25;
451 out1[1] = x27;
452 out1[2] = x29;
453 out1[3] = x32;
454 out1[4] = x34;
455 out1[5] = x36;
456 out1[6] = x39;
457 out1[7] = x41;
458 out1[8] = x43;
459 out1[9] = x46;
460 out1[10] = x48;
461 out1[11] = x50;
462 out1[12] = x51;
463 out1[13] = x52;
464 out1[14] = x54;
465 out1[15] = x56;
466 out1[16] = x57;
467 }
468
469 /**
470 * The function fiat_Poly1305_from_bytes deserializes a field element from bytes in little-endian order. <p>
471 * <p>
472 * Postconditions: <p>
473 * eval out1 mod m = bytes_eval arg1 mod m <p>
474 * <p>
475 * Input Bounds: <p>
476 * arg1: [[0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0xff], [0x0 ~&gt; 0x3]] <p>
477 * Output Bounds: <p>
478 * out1: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
479 */
480 public static void fiat_Poly1305_from_bytes(int[] out1, final int[] arg1) {
481 int x1 = ((arg1[16]) << 24);
482 int x2 = ((arg1[15]) << 16);
483 int x3 = ((arg1[14]) << 8);
484 int x4 = (arg1[13]);
485 int x5 = ((arg1[12]) << 18);
486 int x6 = ((arg1[11]) << 10);
487 int x7 = ((arg1[10]) << 2);
488 int x8 = ((arg1[9]) << 20);
489 int x9 = ((arg1[8]) << 12);
490 int x10 = ((arg1[7]) << 4);
491 int x11 = ((arg1[6]) << 22);
492 int x12 = ((arg1[5]) << 14);
493 int x13 = ((arg1[4]) << 6);
494 int x14 = ((arg1[3]) << 24);
495 int x15 = ((arg1[2]) << 16);
496 int x16 = ((arg1[1]) << 8);
497 int x17 = (arg1[0]);
498 int x18 = (x16 + x17);
499 int x19 = (x15 + x18);
500 int x20 = (x14 + x19);
501 int x21 = (x20 & 0x3ffffff);
502 int x22 = (x20 >>> 26);
503 int x23 = (x13 + x22);
504 int x24 = (x12 + x23);
505 int x25 = (x11 + x24);
506 int x26 = (x25 & 0x3ffffff);
507 int x27 = (x25 >>> 26);
508 int x28 = (x10 + x27);
509 int x29 = (x9 + x28);
510 int x30 = (x8 + x29);
511 int x31 = (x30 & 0x3ffffff);
512 int x32 = (x30 >>> 26);
513 int x33 = (x7 + x32);
514 int x34 = (x6 + x33);
515 int x35 = (x5 + x34);
516 int x36 = (x3 + x4);
517 int x37 = (x2 + x36);
518 int x38 = (x1 + x37);
519 out1[0] = x21;
520 out1[1] = x26;
521 out1[2] = x31;
522 out1[3] = x35;
523 out1[4] = x38;
524 }
525
526 /**
527 * The function fiat_Poly1305_relax is the identity function converting from tight field elements to loose field elements. <p>
528 * <p>
529 * Postconditions: <p>
530 * out1 = arg1 <p>
531 * <p>
532 * Input Bounds: <p>
533 * arg1: [[0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000], [0x0 ~&gt; 0x4000000]] <p>
534 * Output Bounds: <p>
535 * out1: [[0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000], [0x0 ~&gt; 0xc000000]] <p>
536 */
537 public static void fiat_Poly1305_relax(int[] out1, final int[] arg1) {
538 int x1 = (arg1[0]);
539 int x2 = (arg1[1]);
540 int x3 = (arg1[2]);
541 int x4 = (arg1[3]);
542 int x5 = (arg1[4]);
543 out1[0] = x1;
544 out1[1] = x2;
545 out1[2] = x3;
546 out1[3] = x4;
547 out1[4] = x5;
548 }
549
550 }