Debian Codegraph @

fiat-zig/src/poly1305_64.zig

raw
1 // Autogenerated: 'src/ExtractionOCaml/unsaturated_solinas' --lang Zig --internal-static --public-function-case camelCase --private-function-case camelCase --public-type-case UpperCamelCase --private-type-case UpperCamelCase --no-prefix-fiat --package-name poly1305 '' 64 3 '2^130 - 5' carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes relax
2 // curve description (via package name): poly1305
3 // machine_wordsize = 64 (from "64")
4 // requested operations: carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, relax
5 // n = 3 (from "3")
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, 0, 1]
11 // eval z = z[0] + (z[1] << 44) + (z[2] << 87)
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 = [0x1ffffffffff6, 0xffffffffffe, 0xffffffffffe]
14
15 const std = @import("std");
16 const mode = @import("builtin").mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels
17
18 inline fn cast(comptime DestType: type, target: anytype) DestType {
19 @setEvalBranchQuota(10000);
20 if (@typeInfo(@TypeOf(target)) == .int) {
21 const dest = @typeInfo(DestType).int;
22 const source = @typeInfo(@TypeOf(target)).int;
23 if (dest.bits < source.bits) {
24 const T = std.meta.Int(source.signedness, dest.bits);
25 return @bitCast(@as(T, @truncate(target)));
26 }
27 }
28 return target;
29 }
30
31 // The type LooseFieldElement is a field element with loose bounds.
32 // Bounds: [[0x0 ~> 0x300000000000], [0x0 ~> 0x180000000000], [0x0 ~> 0x180000000000]]
33 pub const LooseFieldElement = [3]u64;
34
35 // The type TightFieldElement is a field element with tight bounds.
36 // Bounds: [[0x0 ~> 0x100000000000], [0x0 ~> 0x80000000000], [0x0 ~> 0x80000000000]]
37 pub const TightFieldElement = [3]u64;
38
39 /// The function addcarryxU44 is an addition with carry.
40 ///
41 /// Postconditions:
42 /// out1 = (arg1 + arg2 + arg3) mod 2^44
43 /// out2 = ⌊(arg1 + arg2 + arg3) / 2^44⌋
44 ///
45 /// Input Bounds:
46 /// arg1: [0x0 ~> 0x1]
47 /// arg2: [0x0 ~> 0xfffffffffff]
48 /// arg3: [0x0 ~> 0xfffffffffff]
49 /// Output Bounds:
50 /// out1: [0x0 ~> 0xfffffffffff]
51 /// out2: [0x0 ~> 0x1]
52 inline fn addcarryxU44(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
53 @setRuntimeSafety(mode == .Debug);
54
55 const x1 = ((cast(u64, arg1) + arg2) + arg3);
56 const x2 = (x1 & 0xfffffffffff);
57 const x3 = cast(u1, (x1 >> 44));
58 out1.* = x2;
59 out2.* = x3;
60 }
61
62 /// The function subborrowxU44 is a subtraction with borrow.
63 ///
64 /// Postconditions:
65 /// out1 = (-arg1 + arg2 + -arg3) mod 2^44
66 /// out2 = -⌊(-arg1 + arg2 + -arg3) / 2^44⌋
67 ///
68 /// Input Bounds:
69 /// arg1: [0x0 ~> 0x1]
70 /// arg2: [0x0 ~> 0xfffffffffff]
71 /// arg3: [0x0 ~> 0xfffffffffff]
72 /// Output Bounds:
73 /// out1: [0x0 ~> 0xfffffffffff]
74 /// out2: [0x0 ~> 0x1]
75 inline fn subborrowxU44(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
76 @setRuntimeSafety(mode == .Debug);
77
78 const x1 = cast(i64, (cast(i128, cast(i64, (cast(i128, arg2) - cast(i128, arg1)))) - cast(i128, arg3)));
79 const x2 = cast(i1, (x1 >> 44));
80 const x3 = cast(u64, (cast(i128, x1) & cast(i128, 0xfffffffffff)));
81 out1.* = x3;
82 out2.* = cast(u1, (cast(i2, 0x0) - cast(i2, x2)));
83 }
84
85 /// The function addcarryxU43 is an addition with carry.
86 ///
87 /// Postconditions:
88 /// out1 = (arg1 + arg2 + arg3) mod 2^43
89 /// out2 = ⌊(arg1 + arg2 + arg3) / 2^43⌋
90 ///
91 /// Input Bounds:
92 /// arg1: [0x0 ~> 0x1]
93 /// arg2: [0x0 ~> 0x7ffffffffff]
94 /// arg3: [0x0 ~> 0x7ffffffffff]
95 /// Output Bounds:
96 /// out1: [0x0 ~> 0x7ffffffffff]
97 /// out2: [0x0 ~> 0x1]
98 inline fn addcarryxU43(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
99 @setRuntimeSafety(mode == .Debug);
100
101 const x1 = ((cast(u64, arg1) + arg2) + arg3);
102 const x2 = (x1 & 0x7ffffffffff);
103 const x3 = cast(u1, (x1 >> 43));
104 out1.* = x2;
105 out2.* = x3;
106 }
107
108 /// The function subborrowxU43 is a subtraction with borrow.
109 ///
110 /// Postconditions:
111 /// out1 = (-arg1 + arg2 + -arg3) mod 2^43
112 /// out2 = -⌊(-arg1 + arg2 + -arg3) / 2^43⌋
113 ///
114 /// Input Bounds:
115 /// arg1: [0x0 ~> 0x1]
116 /// arg2: [0x0 ~> 0x7ffffffffff]
117 /// arg3: [0x0 ~> 0x7ffffffffff]
118 /// Output Bounds:
119 /// out1: [0x0 ~> 0x7ffffffffff]
120 /// out2: [0x0 ~> 0x1]
121 inline fn subborrowxU43(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
122 @setRuntimeSafety(mode == .Debug);
123
124 const x1 = cast(i64, (cast(i128, cast(i64, (cast(i128, arg2) - cast(i128, arg1)))) - cast(i128, arg3)));
125 const x2 = cast(i1, (x1 >> 43));
126 const x3 = cast(u64, (cast(i128, x1) & cast(i128, 0x7ffffffffff)));
127 out1.* = x3;
128 out2.* = cast(u1, (cast(i2, 0x0) - cast(i2, x2)));
129 }
130
131 /// The function cmovznzU64 is a single-word conditional move.
132 ///
133 /// Postconditions:
134 /// out1 = (if arg1 = 0 then arg2 else arg3)
135 ///
136 /// Input Bounds:
137 /// arg1: [0x0 ~> 0x1]
138 /// arg2: [0x0 ~> 0xffffffffffffffff]
139 /// arg3: [0x0 ~> 0xffffffffffffffff]
140 /// Output Bounds:
141 /// out1: [0x0 ~> 0xffffffffffffffff]
142 inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
143 @setRuntimeSafety(mode == .Debug);
144
145 const x1 = (~(~arg1));
146 const x2 = cast(u64, (cast(i128, cast(i1, (cast(i2, 0x0) - cast(i2, x1)))) & cast(i128, 0xffffffffffffffff)));
147 const x3 = ((x2 & arg3) | ((~x2) & arg2));
148 out1.* = x3;
149 }
150
151 /// The function carryMul multiplies two field elements and reduces the result.
152 ///
153 /// Postconditions:
154 /// eval out1 mod m = (eval arg1 * eval arg2) mod m
155 ///
156 pub fn carryMul(out1: *TightFieldElement, arg1: LooseFieldElement, arg2: LooseFieldElement) void {
157 @setRuntimeSafety(mode == .Debug);
158
159 const x1 = (cast(u128, (arg1[2])) * cast(u128, ((arg2[2]) * 0x5)));
160 const x2 = (cast(u128, (arg1[2])) * cast(u128, ((arg2[1]) * 0xa)));
161 const x3 = (cast(u128, (arg1[1])) * cast(u128, ((arg2[2]) * 0xa)));
162 const x4 = (cast(u128, (arg1[2])) * cast(u128, (arg2[0])));
163 const x5 = (cast(u128, (arg1[1])) * cast(u128, ((arg2[1]) * 0x2)));
164 const x6 = (cast(u128, (arg1[1])) * cast(u128, (arg2[0])));
165 const x7 = (cast(u128, (arg1[0])) * cast(u128, (arg2[2])));
166 const x8 = (cast(u128, (arg1[0])) * cast(u128, (arg2[1])));
167 const x9 = (cast(u128, (arg1[0])) * cast(u128, (arg2[0])));
168 const x10 = (x9 + (x3 + x2));
169 const x11 = cast(u64, (x10 >> 44));
170 const x12 = cast(u64, (x10 & cast(u128, 0xfffffffffff)));
171 const x13 = (x7 + (x5 + x4));
172 const x14 = (x8 + (x6 + x1));
173 const x15 = (cast(u128, x11) + x14);
174 const x16 = cast(u64, (x15 >> 43));
175 const x17 = cast(u64, (x15 & cast(u128, 0x7ffffffffff)));
176 const x18 = (cast(u128, x16) + x13);
177 const x19 = cast(u64, (x18 >> 43));
178 const x20 = cast(u64, (x18 & cast(u128, 0x7ffffffffff)));
179 const x21 = (x19 * 0x5);
180 const x22 = (x12 + x21);
181 const x23 = (x22 >> 44);
182 const x24 = (x22 & 0xfffffffffff);
183 const x25 = (x23 + x17);
184 const x26 = cast(u1, (x25 >> 43));
185 const x27 = (x25 & 0x7ffffffffff);
186 const x28 = (cast(u64, x26) + x20);
187 out1[0] = x24;
188 out1[1] = x27;
189 out1[2] = x28;
190 }
191
192 /// The function carrySquare squares a field element and reduces the result.
193 ///
194 /// Postconditions:
195 /// eval out1 mod m = (eval arg1 * eval arg1) mod m
196 ///
197 pub fn carrySquare(out1: *TightFieldElement, arg1: LooseFieldElement) void {
198 @setRuntimeSafety(mode == .Debug);
199
200 const x1 = ((arg1[2]) * 0x5);
201 const x2 = (x1 * 0x2);
202 const x3 = ((arg1[2]) * 0x2);
203 const x4 = ((arg1[1]) * 0x2);
204 const x5 = (cast(u128, (arg1[2])) * cast(u128, x1));
205 const x6 = (cast(u128, (arg1[1])) * cast(u128, (x2 * 0x2)));
206 const x7 = (cast(u128, (arg1[1])) * cast(u128, ((arg1[1]) * 0x2)));
207 const x8 = (cast(u128, (arg1[0])) * cast(u128, x3));
208 const x9 = (cast(u128, (arg1[0])) * cast(u128, x4));
209 const x10 = (cast(u128, (arg1[0])) * cast(u128, (arg1[0])));
210 const x11 = (x10 + x6);
211 const x12 = cast(u64, (x11 >> 44));
212 const x13 = cast(u64, (x11 & cast(u128, 0xfffffffffff)));
213 const x14 = (x8 + x7);
214 const x15 = (x9 + x5);
215 const x16 = (cast(u128, x12) + x15);
216 const x17 = cast(u64, (x16 >> 43));
217 const x18 = cast(u64, (x16 & cast(u128, 0x7ffffffffff)));
218 const x19 = (cast(u128, x17) + x14);
219 const x20 = cast(u64, (x19 >> 43));
220 const x21 = cast(u64, (x19 & cast(u128, 0x7ffffffffff)));
221 const x22 = (x20 * 0x5);
222 const x23 = (x13 + x22);
223 const x24 = (x23 >> 44);
224 const x25 = (x23 & 0xfffffffffff);
225 const x26 = (x24 + x18);
226 const x27 = cast(u1, (x26 >> 43));
227 const x28 = (x26 & 0x7ffffffffff);
228 const x29 = (cast(u64, x27) + x21);
229 out1[0] = x25;
230 out1[1] = x28;
231 out1[2] = x29;
232 }
233
234 /// The function carry reduces a field element.
235 ///
236 /// Postconditions:
237 /// eval out1 mod m = eval arg1 mod m
238 ///
239 pub fn carry(out1: *TightFieldElement, arg1: LooseFieldElement) void {
240 @setRuntimeSafety(mode == .Debug);
241
242 const x1 = (arg1[0]);
243 const x2 = ((x1 >> 44) + (arg1[1]));
244 const x3 = ((x2 >> 43) + (arg1[2]));
245 const x4 = ((x1 & 0xfffffffffff) + ((x3 >> 43) * 0x5));
246 const x5 = (cast(u64, cast(u1, (x4 >> 44))) + (x2 & 0x7ffffffffff));
247 const x6 = (x4 & 0xfffffffffff);
248 const x7 = (x5 & 0x7ffffffffff);
249 const x8 = (cast(u64, cast(u1, (x5 >> 43))) + (x3 & 0x7ffffffffff));
250 out1[0] = x6;
251 out1[1] = x7;
252 out1[2] = x8;
253 }
254
255 /// The function add adds two field elements.
256 ///
257 /// Postconditions:
258 /// eval out1 mod m = (eval arg1 + eval arg2) mod m
259 ///
260 pub fn add(out1: *LooseFieldElement, arg1: TightFieldElement, arg2: TightFieldElement) void {
261 @setRuntimeSafety(mode == .Debug);
262
263 const x1 = ((arg1[0]) + (arg2[0]));
264 const x2 = ((arg1[1]) + (arg2[1]));
265 const x3 = ((arg1[2]) + (arg2[2]));
266 out1[0] = x1;
267 out1[1] = x2;
268 out1[2] = x3;
269 }
270
271 /// The function sub subtracts two field elements.
272 ///
273 /// Postconditions:
274 /// eval out1 mod m = (eval arg1 - eval arg2) mod m
275 ///
276 pub fn sub(out1: *LooseFieldElement, arg1: TightFieldElement, arg2: TightFieldElement) void {
277 @setRuntimeSafety(mode == .Debug);
278
279 const x1 = ((0x1ffffffffff6 + (arg1[0])) - (arg2[0]));
280 const x2 = ((0xffffffffffe + (arg1[1])) - (arg2[1]));
281 const x3 = ((0xffffffffffe + (arg1[2])) - (arg2[2]));
282 out1[0] = x1;
283 out1[1] = x2;
284 out1[2] = x3;
285 }
286
287 /// The function opp negates a field element.
288 ///
289 /// Postconditions:
290 /// eval out1 mod m = -eval arg1 mod m
291 ///
292 pub fn opp(out1: *LooseFieldElement, arg1: TightFieldElement) void {
293 @setRuntimeSafety(mode == .Debug);
294
295 const x1 = (0x1ffffffffff6 - (arg1[0]));
296 const x2 = (0xffffffffffe - (arg1[1]));
297 const x3 = (0xffffffffffe - (arg1[2]));
298 out1[0] = x1;
299 out1[1] = x2;
300 out1[2] = x3;
301 }
302
303 /// The function selectznz is a multi-limb conditional select.
304 ///
305 /// Postconditions:
306 /// out1 = (if arg1 = 0 then arg2 else arg3)
307 ///
308 /// Input Bounds:
309 /// arg1: [0x0 ~> 0x1]
310 /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
311 /// arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
312 /// Output Bounds:
313 /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
314 pub fn selectznz(out1: *[3]u64, arg1: u1, arg2: [3]u64, arg3: [3]u64) void {
315 @setRuntimeSafety(mode == .Debug);
316
317 var x1: u64 = undefined;
318 cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0]));
319 var x2: u64 = undefined;
320 cmovznzU64(&x2, arg1, (arg2[1]), (arg3[1]));
321 var x3: u64 = undefined;
322 cmovznzU64(&x3, arg1, (arg2[2]), (arg3[2]));
323 out1[0] = x1;
324 out1[1] = x2;
325 out1[2] = x3;
326 }
327
328 /// The function toBytes serializes a field element to bytes in little-endian order.
329 ///
330 /// Postconditions:
331 /// out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..16]
332 ///
333 /// Output Bounds:
334 /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x3]]
335 pub fn toBytes(out1: *[17]u8, arg1: TightFieldElement) void {
336 @setRuntimeSafety(mode == .Debug);
337
338 var x1: u64 = undefined;
339 var x2: u1 = undefined;
340 subborrowxU44(&x1, &x2, 0x0, (arg1[0]), 0xffffffffffb);
341 var x3: u64 = undefined;
342 var x4: u1 = undefined;
343 subborrowxU43(&x3, &x4, x2, (arg1[1]), 0x7ffffffffff);
344 var x5: u64 = undefined;
345 var x6: u1 = undefined;
346 subborrowxU43(&x5, &x6, x4, (arg1[2]), 0x7ffffffffff);
347 var x7: u64 = undefined;
348 cmovznzU64(&x7, x6, cast(u64, 0x0), 0xffffffffffffffff);
349 var x8: u64 = undefined;
350 var x9: u1 = undefined;
351 addcarryxU44(&x8, &x9, 0x0, x1, (x7 & 0xffffffffffb));
352 var x10: u64 = undefined;
353 var x11: u1 = undefined;
354 addcarryxU43(&x10, &x11, x9, x3, (x7 & 0x7ffffffffff));
355 var x12: u64 = undefined;
356 var x13: u1 = undefined;
357 addcarryxU43(&x12, &x13, x11, x5, (x7 & 0x7ffffffffff));
358 const x14 = (x12 << 7);
359 const x15 = (x10 << 4);
360 const x16 = cast(u8, (x8 & cast(u64, 0xff)));
361 const x17 = (x8 >> 8);
362 const x18 = cast(u8, (x17 & cast(u64, 0xff)));
363 const x19 = (x17 >> 8);
364 const x20 = cast(u8, (x19 & cast(u64, 0xff)));
365 const x21 = (x19 >> 8);
366 const x22 = cast(u8, (x21 & cast(u64, 0xff)));
367 const x23 = (x21 >> 8);
368 const x24 = cast(u8, (x23 & cast(u64, 0xff)));
369 const x25 = cast(u8, (x23 >> 8));
370 const x26 = (x15 + cast(u64, x25));
371 const x27 = cast(u8, (x26 & cast(u64, 0xff)));
372 const x28 = (x26 >> 8);
373 const x29 = cast(u8, (x28 & cast(u64, 0xff)));
374 const x30 = (x28 >> 8);
375 const x31 = cast(u8, (x30 & cast(u64, 0xff)));
376 const x32 = (x30 >> 8);
377 const x33 = cast(u8, (x32 & cast(u64, 0xff)));
378 const x34 = (x32 >> 8);
379 const x35 = cast(u8, (x34 & cast(u64, 0xff)));
380 const x36 = cast(u8, (x34 >> 8));
381 const x37 = (x14 + cast(u64, x36));
382 const x38 = cast(u8, (x37 & cast(u64, 0xff)));
383 const x39 = (x37 >> 8);
384 const x40 = cast(u8, (x39 & cast(u64, 0xff)));
385 const x41 = (x39 >> 8);
386 const x42 = cast(u8, (x41 & cast(u64, 0xff)));
387 const x43 = (x41 >> 8);
388 const x44 = cast(u8, (x43 & cast(u64, 0xff)));
389 const x45 = (x43 >> 8);
390 const x46 = cast(u8, (x45 & cast(u64, 0xff)));
391 const x47 = (x45 >> 8);
392 const x48 = cast(u8, (x47 & cast(u64, 0xff)));
393 const x49 = cast(u8, (x47 >> 8));
394 out1[0] = x16;
395 out1[1] = x18;
396 out1[2] = x20;
397 out1[3] = x22;
398 out1[4] = x24;
399 out1[5] = x27;
400 out1[6] = x29;
401 out1[7] = x31;
402 out1[8] = x33;
403 out1[9] = x35;
404 out1[10] = x38;
405 out1[11] = x40;
406 out1[12] = x42;
407 out1[13] = x44;
408 out1[14] = x46;
409 out1[15] = x48;
410 out1[16] = x49;
411 }
412
413 /// The function fromBytes deserializes a field element from bytes in little-endian order.
414 ///
415 /// Postconditions:
416 /// eval out1 mod m = bytes_eval arg1 mod m
417 ///
418 /// Input Bounds:
419 /// arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x3]]
420 pub fn fromBytes(out1: *TightFieldElement, arg1: [17]u8) void {
421 @setRuntimeSafety(mode == .Debug);
422
423 const x1 = (cast(u64, (arg1[16])) << 41);
424 const x2 = (cast(u64, (arg1[15])) << 33);
425 const x3 = (cast(u64, (arg1[14])) << 25);
426 const x4 = (cast(u64, (arg1[13])) << 17);
427 const x5 = (cast(u64, (arg1[12])) << 9);
428 const x6 = (cast(u64, (arg1[11])) * cast(u64, 0x2));
429 const x7 = (cast(u64, (arg1[10])) << 36);
430 const x8 = (cast(u64, (arg1[9])) << 28);
431 const x9 = (cast(u64, (arg1[8])) << 20);
432 const x10 = (cast(u64, (arg1[7])) << 12);
433 const x11 = (cast(u64, (arg1[6])) << 4);
434 const x12 = (cast(u64, (arg1[5])) << 40);
435 const x13 = (cast(u64, (arg1[4])) << 32);
436 const x14 = (cast(u64, (arg1[3])) << 24);
437 const x15 = (cast(u64, (arg1[2])) << 16);
438 const x16 = (cast(u64, (arg1[1])) << 8);
439 const x17 = (arg1[0]);
440 const x18 = (x16 + cast(u64, x17));
441 const x19 = (x15 + x18);
442 const x20 = (x14 + x19);
443 const x21 = (x13 + x20);
444 const x22 = (x12 + x21);
445 const x23 = (x22 & 0xfffffffffff);
446 const x24 = cast(u8, (x22 >> 44));
447 const x25 = (x11 + cast(u64, x24));
448 const x26 = (x10 + x25);
449 const x27 = (x9 + x26);
450 const x28 = (x8 + x27);
451 const x29 = (x7 + x28);
452 const x30 = (x29 & 0x7ffffffffff);
453 const x31 = cast(u1, (x29 >> 43));
454 const x32 = (x6 + cast(u64, x31));
455 const x33 = (x5 + x32);
456 const x34 = (x4 + x33);
457 const x35 = (x3 + x34);
458 const x36 = (x2 + x35);
459 const x37 = (x1 + x36);
460 out1[0] = x23;
461 out1[1] = x30;
462 out1[2] = x37;
463 }
464
465 /// The function relax is the identity function converting from tight field elements to loose field elements.
466 ///
467 /// Postconditions:
468 /// out1 = arg1
469 ///
470 pub fn relax(out1: *LooseFieldElement, arg1: TightFieldElement) void {
471 @setRuntimeSafety(mode == .Debug);
472
473 const x1 = (arg1[0]);
474 const x2 = (arg1[1]);
475 const x3 = (arg1[2]);
476 out1[0] = x1;
477 out1[1] = x2;
478 out1[2] = x3;
479 }