Debian Codegraph @

fiat-zig/src/p448_solinas_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 p448 '' 64 8 '2^448 - 2^224 - 1' carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes relax
2 // curve description (via package name): p448
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 = 8 (from "8")
6 // s-c = 2^448 - [(2^224, 1), (1, 1)] (from "2^448 - 2^224 - 1")
7 // tight_bounds_multiplier = 1 (from "")
8 //
9 // Computed values:
10 // carry_chain = [3, 7, 4, 0, 5, 1, 6, 2, 7, 3, 4, 0]
11 // eval z = z[0] + (z[1] << 56) + (z[2] << 112) + (z[3] << 168) + (z[4] << 224) + (z[5] << 0x118) + (z[6] << 0x150) + (z[7] << 0x188)
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) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) + (z[32] << 256) + (z[33] << 0x108) + (z[34] << 0x110) + (z[35] << 0x118) + (z[36] << 0x120) + (z[37] << 0x128) + (z[38] << 0x130) + (z[39] << 0x138) + (z[40] << 0x140) + (z[41] << 0x148) + (z[42] << 0x150) + (z[43] << 0x158) + (z[44] << 0x160) + (z[45] << 0x168) + (z[46] << 0x170) + (z[47] << 0x178) + (z[48] << 0x180) + (z[49] << 0x188) + (z[50] << 0x190) + (z[51] << 0x198) + (z[52] << 0x1a0) + (z[53] << 0x1a8) + (z[54] << 0x1b0) + (z[55] << 0x1b8)
13 // balance = [0x1fffffffffffffe, 0x1fffffffffffffe, 0x1fffffffffffffe, 0x1fffffffffffffe, 0x1fffffffffffffc, 0x1fffffffffffffe, 0x1fffffffffffffe, 0x1fffffffffffffe]
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 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000], [0x0 ~> 0x300000000000000]]
33 pub const LooseFieldElement = [8]u64;
34
35 // The type TightFieldElement is a field element with tight bounds.
36 // Bounds: [[0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000], [0x0 ~> 0x100000000000000]]
37 pub const TightFieldElement = [8]u64;
38
39 /// The function addcarryxU56 is an addition with carry.
40 ///
41 /// Postconditions:
42 /// out1 = (arg1 + arg2 + arg3) mod 2^56
43 /// out2 = ⌊(arg1 + arg2 + arg3) / 2^56⌋
44 ///
45 /// Input Bounds:
46 /// arg1: [0x0 ~> 0x1]
47 /// arg2: [0x0 ~> 0xffffffffffffff]
48 /// arg3: [0x0 ~> 0xffffffffffffff]
49 /// Output Bounds:
50 /// out1: [0x0 ~> 0xffffffffffffff]
51 /// out2: [0x0 ~> 0x1]
52 inline fn addcarryxU56(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 & 0xffffffffffffff);
57 const x3 = cast(u1, (x1 >> 56));
58 out1.* = x2;
59 out2.* = x3;
60 }
61
62 /// The function subborrowxU56 is a subtraction with borrow.
63 ///
64 /// Postconditions:
65 /// out1 = (-arg1 + arg2 + -arg3) mod 2^56
66 /// out2 = -⌊(-arg1 + arg2 + -arg3) / 2^56⌋
67 ///
68 /// Input Bounds:
69 /// arg1: [0x0 ~> 0x1]
70 /// arg2: [0x0 ~> 0xffffffffffffff]
71 /// arg3: [0x0 ~> 0xffffffffffffff]
72 /// Output Bounds:
73 /// out1: [0x0 ~> 0xffffffffffffff]
74 /// out2: [0x0 ~> 0x1]
75 inline fn subborrowxU56(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 >> 56));
80 const x3 = cast(u64, (cast(i128, x1) & cast(i128, 0xffffffffffffff)));
81 out1.* = x3;
82 out2.* = cast(u1, (cast(i2, 0x0) - cast(i2, x2)));
83 }
84
85 /// The function cmovznzU64 is a single-word conditional move.
86 ///
87 /// Postconditions:
88 /// out1 = (if arg1 = 0 then arg2 else arg3)
89 ///
90 /// Input Bounds:
91 /// arg1: [0x0 ~> 0x1]
92 /// arg2: [0x0 ~> 0xffffffffffffffff]
93 /// arg3: [0x0 ~> 0xffffffffffffffff]
94 /// Output Bounds:
95 /// out1: [0x0 ~> 0xffffffffffffffff]
96 inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
97 @setRuntimeSafety(mode == .Debug);
98
99 const x1 = (~(~arg1));
100 const x2 = cast(u64, (cast(i128, cast(i1, (cast(i2, 0x0) - cast(i2, x1)))) & cast(i128, 0xffffffffffffffff)));
101 const x3 = ((x2 & arg3) | ((~x2) & arg2));
102 out1.* = x3;
103 }
104
105 /// The function carryMul multiplies two field elements and reduces the result.
106 ///
107 /// Postconditions:
108 /// eval out1 mod m = (eval arg1 * eval arg2) mod m
109 ///
110 pub fn carryMul(out1: *TightFieldElement, arg1: LooseFieldElement, arg2: LooseFieldElement) void {
111 @setRuntimeSafety(mode == .Debug);
112
113 const x1 = (cast(u128, (arg1[7])) * cast(u128, (arg2[7])));
114 const x2 = (cast(u128, (arg1[7])) * cast(u128, (arg2[6])));
115 const x3 = (cast(u128, (arg1[7])) * cast(u128, (arg2[5])));
116 const x4 = (cast(u128, (arg1[6])) * cast(u128, (arg2[7])));
117 const x5 = (cast(u128, (arg1[6])) * cast(u128, (arg2[6])));
118 const x6 = (cast(u128, (arg1[5])) * cast(u128, (arg2[7])));
119 const x7 = (cast(u128, (arg1[7])) * cast(u128, (arg2[7])));
120 const x8 = (cast(u128, (arg1[7])) * cast(u128, (arg2[6])));
121 const x9 = (cast(u128, (arg1[7])) * cast(u128, (arg2[5])));
122 const x10 = (cast(u128, (arg1[6])) * cast(u128, (arg2[7])));
123 const x11 = (cast(u128, (arg1[6])) * cast(u128, (arg2[6])));
124 const x12 = (cast(u128, (arg1[5])) * cast(u128, (arg2[7])));
125 const x13 = (cast(u128, (arg1[7])) * cast(u128, (arg2[7])));
126 const x14 = (cast(u128, (arg1[7])) * cast(u128, (arg2[6])));
127 const x15 = (cast(u128, (arg1[7])) * cast(u128, (arg2[5])));
128 const x16 = (cast(u128, (arg1[7])) * cast(u128, (arg2[4])));
129 const x17 = (cast(u128, (arg1[7])) * cast(u128, (arg2[3])));
130 const x18 = (cast(u128, (arg1[7])) * cast(u128, (arg2[2])));
131 const x19 = (cast(u128, (arg1[7])) * cast(u128, (arg2[1])));
132 const x20 = (cast(u128, (arg1[6])) * cast(u128, (arg2[7])));
133 const x21 = (cast(u128, (arg1[6])) * cast(u128, (arg2[6])));
134 const x22 = (cast(u128, (arg1[6])) * cast(u128, (arg2[5])));
135 const x23 = (cast(u128, (arg1[6])) * cast(u128, (arg2[4])));
136 const x24 = (cast(u128, (arg1[6])) * cast(u128, (arg2[3])));
137 const x25 = (cast(u128, (arg1[6])) * cast(u128, (arg2[2])));
138 const x26 = (cast(u128, (arg1[5])) * cast(u128, (arg2[7])));
139 const x27 = (cast(u128, (arg1[5])) * cast(u128, (arg2[6])));
140 const x28 = (cast(u128, (arg1[5])) * cast(u128, (arg2[5])));
141 const x29 = (cast(u128, (arg1[5])) * cast(u128, (arg2[4])));
142 const x30 = (cast(u128, (arg1[5])) * cast(u128, (arg2[3])));
143 const x31 = (cast(u128, (arg1[4])) * cast(u128, (arg2[7])));
144 const x32 = (cast(u128, (arg1[4])) * cast(u128, (arg2[6])));
145 const x33 = (cast(u128, (arg1[4])) * cast(u128, (arg2[5])));
146 const x34 = (cast(u128, (arg1[4])) * cast(u128, (arg2[4])));
147 const x35 = (cast(u128, (arg1[3])) * cast(u128, (arg2[7])));
148 const x36 = (cast(u128, (arg1[3])) * cast(u128, (arg2[6])));
149 const x37 = (cast(u128, (arg1[3])) * cast(u128, (arg2[5])));
150 const x38 = (cast(u128, (arg1[2])) * cast(u128, (arg2[7])));
151 const x39 = (cast(u128, (arg1[2])) * cast(u128, (arg2[6])));
152 const x40 = (cast(u128, (arg1[1])) * cast(u128, (arg2[7])));
153 const x41 = (cast(u128, (arg1[7])) * cast(u128, (arg2[4])));
154 const x42 = (cast(u128, (arg1[7])) * cast(u128, (arg2[3])));
155 const x43 = (cast(u128, (arg1[7])) * cast(u128, (arg2[2])));
156 const x44 = (cast(u128, (arg1[7])) * cast(u128, (arg2[1])));
157 const x45 = (cast(u128, (arg1[6])) * cast(u128, (arg2[5])));
158 const x46 = (cast(u128, (arg1[6])) * cast(u128, (arg2[4])));
159 const x47 = (cast(u128, (arg1[6])) * cast(u128, (arg2[3])));
160 const x48 = (cast(u128, (arg1[6])) * cast(u128, (arg2[2])));
161 const x49 = (cast(u128, (arg1[5])) * cast(u128, (arg2[6])));
162 const x50 = (cast(u128, (arg1[5])) * cast(u128, (arg2[5])));
163 const x51 = (cast(u128, (arg1[5])) * cast(u128, (arg2[4])));
164 const x52 = (cast(u128, (arg1[5])) * cast(u128, (arg2[3])));
165 const x53 = (cast(u128, (arg1[4])) * cast(u128, (arg2[7])));
166 const x54 = (cast(u128, (arg1[4])) * cast(u128, (arg2[6])));
167 const x55 = (cast(u128, (arg1[4])) * cast(u128, (arg2[5])));
168 const x56 = (cast(u128, (arg1[4])) * cast(u128, (arg2[4])));
169 const x57 = (cast(u128, (arg1[3])) * cast(u128, (arg2[7])));
170 const x58 = (cast(u128, (arg1[3])) * cast(u128, (arg2[6])));
171 const x59 = (cast(u128, (arg1[3])) * cast(u128, (arg2[5])));
172 const x60 = (cast(u128, (arg1[2])) * cast(u128, (arg2[7])));
173 const x61 = (cast(u128, (arg1[2])) * cast(u128, (arg2[6])));
174 const x62 = (cast(u128, (arg1[1])) * cast(u128, (arg2[7])));
175 const x63 = (cast(u128, (arg1[7])) * cast(u128, (arg2[0])));
176 const x64 = (cast(u128, (arg1[6])) * cast(u128, (arg2[1])));
177 const x65 = (cast(u128, (arg1[6])) * cast(u128, (arg2[0])));
178 const x66 = (cast(u128, (arg1[5])) * cast(u128, (arg2[2])));
179 const x67 = (cast(u128, (arg1[5])) * cast(u128, (arg2[1])));
180 const x68 = (cast(u128, (arg1[5])) * cast(u128, (arg2[0])));
181 const x69 = (cast(u128, (arg1[4])) * cast(u128, (arg2[3])));
182 const x70 = (cast(u128, (arg1[4])) * cast(u128, (arg2[2])));
183 const x71 = (cast(u128, (arg1[4])) * cast(u128, (arg2[1])));
184 const x72 = (cast(u128, (arg1[4])) * cast(u128, (arg2[0])));
185 const x73 = (cast(u128, (arg1[3])) * cast(u128, (arg2[4])));
186 const x74 = (cast(u128, (arg1[3])) * cast(u128, (arg2[3])));
187 const x75 = (cast(u128, (arg1[3])) * cast(u128, (arg2[2])));
188 const x76 = (cast(u128, (arg1[3])) * cast(u128, (arg2[1])));
189 const x77 = (cast(u128, (arg1[3])) * cast(u128, (arg2[0])));
190 const x78 = (cast(u128, (arg1[2])) * cast(u128, (arg2[5])));
191 const x79 = (cast(u128, (arg1[2])) * cast(u128, (arg2[4])));
192 const x80 = (cast(u128, (arg1[2])) * cast(u128, (arg2[3])));
193 const x81 = (cast(u128, (arg1[2])) * cast(u128, (arg2[2])));
194 const x82 = (cast(u128, (arg1[2])) * cast(u128, (arg2[1])));
195 const x83 = (cast(u128, (arg1[2])) * cast(u128, (arg2[0])));
196 const x84 = (cast(u128, (arg1[1])) * cast(u128, (arg2[6])));
197 const x85 = (cast(u128, (arg1[1])) * cast(u128, (arg2[5])));
198 const x86 = (cast(u128, (arg1[1])) * cast(u128, (arg2[4])));
199 const x87 = (cast(u128, (arg1[1])) * cast(u128, (arg2[3])));
200 const x88 = (cast(u128, (arg1[1])) * cast(u128, (arg2[2])));
201 const x89 = (cast(u128, (arg1[1])) * cast(u128, (arg2[1])));
202 const x90 = (cast(u128, (arg1[1])) * cast(u128, (arg2[0])));
203 const x91 = (cast(u128, (arg1[0])) * cast(u128, (arg2[7])));
204 const x92 = (cast(u128, (arg1[0])) * cast(u128, (arg2[6])));
205 const x93 = (cast(u128, (arg1[0])) * cast(u128, (arg2[5])));
206 const x94 = (cast(u128, (arg1[0])) * cast(u128, (arg2[4])));
207 const x95 = (cast(u128, (arg1[0])) * cast(u128, (arg2[3])));
208 const x96 = (cast(u128, (arg1[0])) * cast(u128, (arg2[2])));
209 const x97 = (cast(u128, (arg1[0])) * cast(u128, (arg2[1])));
210 const x98 = (cast(u128, (arg1[0])) * cast(u128, (arg2[0])));
211 const x99 = (x95 + (x88 + (x82 + (x77 + (x31 + (x27 + (x22 + x16)))))));
212 const x100 = cast(u64, (x99 >> 56));
213 const x101 = cast(u64, (x99 & cast(u128, 0xffffffffffffff)));
214 const x102 = (x91 + (x84 + (x78 + (x73 + (x69 + (x66 + (x64 + (x63 + (x53 + (x49 + (x45 + x41)))))))))));
215 const x103 = (x92 + (x85 + (x79 + (x74 + (x70 + (x67 + (x65 + (x57 + (x54 + (x50 + (x46 + (x42 + (x13 + x7)))))))))))));
216 const x104 = (x93 + (x86 + (x80 + (x75 + (x71 + (x68 + (x60 + (x58 + (x55 + (x51 + (x47 + (x43 + (x20 + (x14 + (x10 + x8)))))))))))))));
217 const x105 = (x94 + (x87 + (x81 + (x76 + (x72 + (x62 + (x61 + (x59 + (x56 + (x52 + (x48 + (x44 + (x26 + (x21 + (x15 + (x12 + (x11 + x9)))))))))))))))));
218 const x106 = (x96 + (x89 + (x83 + (x35 + (x32 + (x28 + (x23 + (x17 + x1))))))));
219 const x107 = (x97 + (x90 + (x38 + (x36 + (x33 + (x29 + (x24 + (x18 + (x4 + x2)))))))));
220 const x108 = (x98 + (x40 + (x39 + (x37 + (x34 + (x30 + (x25 + (x19 + (x6 + (x5 + x3))))))))));
221 const x109 = (cast(u128, x100) + x105);
222 const x110 = cast(u64, (x102 >> 56));
223 const x111 = cast(u64, (x102 & cast(u128, 0xffffffffffffff)));
224 const x112 = (x109 + cast(u128, x110));
225 const x113 = cast(u64, (x112 >> 56));
226 const x114 = cast(u64, (x112 & cast(u128, 0xffffffffffffff)));
227 const x115 = (x108 + cast(u128, x110));
228 const x116 = (cast(u128, x113) + x104);
229 const x117 = cast(u64, (x115 >> 56));
230 const x118 = cast(u64, (x115 & cast(u128, 0xffffffffffffff)));
231 const x119 = (cast(u128, x117) + x107);
232 const x120 = cast(u64, (x116 >> 56));
233 const x121 = cast(u64, (x116 & cast(u128, 0xffffffffffffff)));
234 const x122 = (cast(u128, x120) + x103);
235 const x123 = cast(u64, (x119 >> 56));
236 const x124 = cast(u64, (x119 & cast(u128, 0xffffffffffffff)));
237 const x125 = (cast(u128, x123) + x106);
238 const x126 = cast(u64, (x122 >> 56));
239 const x127 = cast(u64, (x122 & cast(u128, 0xffffffffffffff)));
240 const x128 = (x126 + x111);
241 const x129 = cast(u64, (x125 >> 56));
242 const x130 = cast(u64, (x125 & cast(u128, 0xffffffffffffff)));
243 const x131 = (x129 + x101);
244 const x132 = (x128 >> 56);
245 const x133 = (x128 & 0xffffffffffffff);
246 const x134 = (x131 >> 56);
247 const x135 = (x131 & 0xffffffffffffff);
248 const x136 = (x114 + x132);
249 const x137 = (x118 + x132);
250 const x138 = (x134 + x136);
251 const x139 = cast(u1, (x138 >> 56));
252 const x140 = (x138 & 0xffffffffffffff);
253 const x141 = (cast(u64, x139) + x121);
254 const x142 = cast(u1, (x137 >> 56));
255 const x143 = (x137 & 0xffffffffffffff);
256 const x144 = (cast(u64, x142) + x124);
257 out1[0] = x143;
258 out1[1] = x144;
259 out1[2] = x130;
260 out1[3] = x135;
261 out1[4] = x140;
262 out1[5] = x141;
263 out1[6] = x127;
264 out1[7] = x133;
265 }
266
267 /// The function carrySquare squares a field element and reduces the result.
268 ///
269 /// Postconditions:
270 /// eval out1 mod m = (eval arg1 * eval arg1) mod m
271 ///
272 pub fn carrySquare(out1: *TightFieldElement, arg1: LooseFieldElement) void {
273 @setRuntimeSafety(mode == .Debug);
274
275 const x1 = (arg1[7]);
276 const x2 = (arg1[7]);
277 const x3 = (x1 * 0x2);
278 const x4 = (x2 * 0x2);
279 const x5 = ((arg1[7]) * 0x2);
280 const x6 = (arg1[6]);
281 const x7 = (arg1[6]);
282 const x8 = (x6 * 0x2);
283 const x9 = (x7 * 0x2);
284 const x10 = ((arg1[6]) * 0x2);
285 const x11 = (arg1[5]);
286 const x12 = (arg1[5]);
287 const x13 = (x11 * 0x2);
288 const x14 = (x12 * 0x2);
289 const x15 = ((arg1[5]) * 0x2);
290 const x16 = (arg1[4]);
291 const x17 = (arg1[4]);
292 const x18 = ((arg1[4]) * 0x2);
293 const x19 = ((arg1[3]) * 0x2);
294 const x20 = ((arg1[2]) * 0x2);
295 const x21 = ((arg1[1]) * 0x2);
296 const x22 = (cast(u128, (arg1[7])) * cast(u128, x1));
297 const x23 = (cast(u128, (arg1[6])) * cast(u128, x3));
298 const x24 = (cast(u128, (arg1[6])) * cast(u128, x6));
299 const x25 = (cast(u128, (arg1[5])) * cast(u128, x3));
300 const x26 = (cast(u128, (arg1[7])) * cast(u128, x1));
301 const x27 = (cast(u128, (arg1[6])) * cast(u128, x3));
302 const x28 = (cast(u128, (arg1[6])) * cast(u128, x6));
303 const x29 = (cast(u128, (arg1[5])) * cast(u128, x3));
304 const x30 = (cast(u128, (arg1[7])) * cast(u128, x2));
305 const x31 = (cast(u128, (arg1[6])) * cast(u128, x4));
306 const x32 = (cast(u128, (arg1[6])) * cast(u128, x7));
307 const x33 = (cast(u128, (arg1[5])) * cast(u128, x4));
308 const x34 = (cast(u128, (arg1[5])) * cast(u128, x9));
309 const x35 = (cast(u128, (arg1[5])) * cast(u128, x8));
310 const x36 = (cast(u128, (arg1[5])) * cast(u128, x12));
311 const x37 = (cast(u128, (arg1[5])) * cast(u128, x11));
312 const x38 = (cast(u128, (arg1[4])) * cast(u128, x4));
313 const x39 = (cast(u128, (arg1[4])) * cast(u128, x3));
314 const x40 = (cast(u128, (arg1[4])) * cast(u128, x9));
315 const x41 = (cast(u128, (arg1[4])) * cast(u128, x8));
316 const x42 = (cast(u128, (arg1[4])) * cast(u128, x14));
317 const x43 = (cast(u128, (arg1[4])) * cast(u128, x13));
318 const x44 = (cast(u128, (arg1[4])) * cast(u128, x17));
319 const x45 = (cast(u128, (arg1[4])) * cast(u128, x16));
320 const x46 = (cast(u128, (arg1[3])) * cast(u128, x4));
321 const x47 = (cast(u128, (arg1[3])) * cast(u128, x3));
322 const x48 = (cast(u128, (arg1[3])) * cast(u128, x9));
323 const x49 = (cast(u128, (arg1[3])) * cast(u128, x8));
324 const x50 = (cast(u128, (arg1[3])) * cast(u128, x14));
325 const x51 = (cast(u128, (arg1[3])) * cast(u128, x13));
326 const x52 = (cast(u128, (arg1[3])) * cast(u128, x18));
327 const x53 = (cast(u128, (arg1[3])) * cast(u128, (arg1[3])));
328 const x54 = (cast(u128, (arg1[2])) * cast(u128, x4));
329 const x55 = (cast(u128, (arg1[2])) * cast(u128, x3));
330 const x56 = (cast(u128, (arg1[2])) * cast(u128, x9));
331 const x57 = (cast(u128, (arg1[2])) * cast(u128, x8));
332 const x58 = (cast(u128, (arg1[2])) * cast(u128, x15));
333 const x59 = (cast(u128, (arg1[2])) * cast(u128, x18));
334 const x60 = (cast(u128, (arg1[2])) * cast(u128, x19));
335 const x61 = (cast(u128, (arg1[2])) * cast(u128, (arg1[2])));
336 const x62 = (cast(u128, (arg1[1])) * cast(u128, x4));
337 const x63 = (cast(u128, (arg1[1])) * cast(u128, x3));
338 const x64 = (cast(u128, (arg1[1])) * cast(u128, x10));
339 const x65 = (cast(u128, (arg1[1])) * cast(u128, x15));
340 const x66 = (cast(u128, (arg1[1])) * cast(u128, x18));
341 const x67 = (cast(u128, (arg1[1])) * cast(u128, x19));
342 const x68 = (cast(u128, (arg1[1])) * cast(u128, x20));
343 const x69 = (cast(u128, (arg1[1])) * cast(u128, (arg1[1])));
344 const x70 = (cast(u128, (arg1[0])) * cast(u128, x5));
345 const x71 = (cast(u128, (arg1[0])) * cast(u128, x10));
346 const x72 = (cast(u128, (arg1[0])) * cast(u128, x15));
347 const x73 = (cast(u128, (arg1[0])) * cast(u128, x18));
348 const x74 = (cast(u128, (arg1[0])) * cast(u128, x19));
349 const x75 = (cast(u128, (arg1[0])) * cast(u128, x20));
350 const x76 = (cast(u128, (arg1[0])) * cast(u128, x21));
351 const x77 = (cast(u128, (arg1[0])) * cast(u128, (arg1[0])));
352 const x78 = (x74 + (x68 + (x38 + x34)));
353 const x79 = cast(u64, (x78 >> 56));
354 const x80 = cast(u64, (x78 & cast(u128, 0xffffffffffffff)));
355 const x81 = (x70 + (x64 + (x58 + (x52 + (x39 + x35)))));
356 const x82 = (x71 + (x65 + (x59 + (x53 + (x47 + (x41 + (x37 + (x30 + x26))))))));
357 const x83 = (x72 + (x66 + (x60 + (x55 + (x49 + (x43 + (x31 + x27)))))));
358 const x84 = (x73 + (x67 + (x63 + (x61 + (x57 + (x51 + (x45 + (x33 + (x32 + (x29 + x28))))))))));
359 const x85 = (x75 + (x69 + (x46 + (x40 + (x36 + x22)))));
360 const x86 = (x76 + (x54 + (x48 + (x42 + x23))));
361 const x87 = (x77 + (x62 + (x56 + (x50 + (x44 + (x25 + x24))))));
362 const x88 = (cast(u128, x79) + x84);
363 const x89 = cast(u64, (x81 >> 56));
364 const x90 = cast(u64, (x81 & cast(u128, 0xffffffffffffff)));
365 const x91 = (x88 + cast(u128, x89));
366 const x92 = cast(u64, (x91 >> 56));
367 const x93 = cast(u64, (x91 & cast(u128, 0xffffffffffffff)));
368 const x94 = (x87 + cast(u128, x89));
369 const x95 = (cast(u128, x92) + x83);
370 const x96 = cast(u64, (x94 >> 56));
371 const x97 = cast(u64, (x94 & cast(u128, 0xffffffffffffff)));
372 const x98 = (cast(u128, x96) + x86);
373 const x99 = cast(u64, (x95 >> 56));
374 const x100 = cast(u64, (x95 & cast(u128, 0xffffffffffffff)));
375 const x101 = (cast(u128, x99) + x82);
376 const x102 = cast(u64, (x98 >> 56));
377 const x103 = cast(u64, (x98 & cast(u128, 0xffffffffffffff)));
378 const x104 = (cast(u128, x102) + x85);
379 const x105 = cast(u64, (x101 >> 56));
380 const x106 = cast(u64, (x101 & cast(u128, 0xffffffffffffff)));
381 const x107 = (x105 + x90);
382 const x108 = cast(u64, (x104 >> 56));
383 const x109 = cast(u64, (x104 & cast(u128, 0xffffffffffffff)));
384 const x110 = (x108 + x80);
385 const x111 = (x107 >> 56);
386 const x112 = (x107 & 0xffffffffffffff);
387 const x113 = (x110 >> 56);
388 const x114 = (x110 & 0xffffffffffffff);
389 const x115 = (x93 + x111);
390 const x116 = (x97 + x111);
391 const x117 = (x113 + x115);
392 const x118 = cast(u1, (x117 >> 56));
393 const x119 = (x117 & 0xffffffffffffff);
394 const x120 = (cast(u64, x118) + x100);
395 const x121 = cast(u1, (x116 >> 56));
396 const x122 = (x116 & 0xffffffffffffff);
397 const x123 = (cast(u64, x121) + x103);
398 out1[0] = x122;
399 out1[1] = x123;
400 out1[2] = x109;
401 out1[3] = x114;
402 out1[4] = x119;
403 out1[5] = x120;
404 out1[6] = x106;
405 out1[7] = x112;
406 }
407
408 /// The function carry reduces a field element.
409 ///
410 /// Postconditions:
411 /// eval out1 mod m = eval arg1 mod m
412 ///
413 pub fn carry(out1: *TightFieldElement, arg1: LooseFieldElement) void {
414 @setRuntimeSafety(mode == .Debug);
415
416 const x1 = (arg1[3]);
417 const x2 = (arg1[7]);
418 const x3 = (x2 >> 56);
419 const x4 = (((x1 >> 56) + (arg1[4])) + x3);
420 const x5 = ((arg1[0]) + x3);
421 const x6 = ((x4 >> 56) + (arg1[5]));
422 const x7 = ((x5 >> 56) + (arg1[1]));
423 const x8 = ((x6 >> 56) + (arg1[6]));
424 const x9 = ((x7 >> 56) + (arg1[2]));
425 const x10 = ((x8 >> 56) + (x2 & 0xffffffffffffff));
426 const x11 = ((x9 >> 56) + (x1 & 0xffffffffffffff));
427 const x12 = cast(u1, (x10 >> 56));
428 const x13 = ((x5 & 0xffffffffffffff) + cast(u64, x12));
429 const x14 = (cast(u64, cast(u1, (x11 >> 56))) + ((x4 & 0xffffffffffffff) + cast(u64, x12)));
430 const x15 = (x13 & 0xffffffffffffff);
431 const x16 = (cast(u64, cast(u1, (x13 >> 56))) + (x7 & 0xffffffffffffff));
432 const x17 = (x9 & 0xffffffffffffff);
433 const x18 = (x11 & 0xffffffffffffff);
434 const x19 = (x14 & 0xffffffffffffff);
435 const x20 = (cast(u64, cast(u1, (x14 >> 56))) + (x6 & 0xffffffffffffff));
436 const x21 = (x8 & 0xffffffffffffff);
437 const x22 = (x10 & 0xffffffffffffff);
438 out1[0] = x15;
439 out1[1] = x16;
440 out1[2] = x17;
441 out1[3] = x18;
442 out1[4] = x19;
443 out1[5] = x20;
444 out1[6] = x21;
445 out1[7] = x22;
446 }
447
448 /// The function add adds two field elements.
449 ///
450 /// Postconditions:
451 /// eval out1 mod m = (eval arg1 + eval arg2) mod m
452 ///
453 pub fn add(out1: *LooseFieldElement, arg1: TightFieldElement, arg2: TightFieldElement) void {
454 @setRuntimeSafety(mode == .Debug);
455
456 const x1 = ((arg1[0]) + (arg2[0]));
457 const x2 = ((arg1[1]) + (arg2[1]));
458 const x3 = ((arg1[2]) + (arg2[2]));
459 const x4 = ((arg1[3]) + (arg2[3]));
460 const x5 = ((arg1[4]) + (arg2[4]));
461 const x6 = ((arg1[5]) + (arg2[5]));
462 const x7 = ((arg1[6]) + (arg2[6]));
463 const x8 = ((arg1[7]) + (arg2[7]));
464 out1[0] = x1;
465 out1[1] = x2;
466 out1[2] = x3;
467 out1[3] = x4;
468 out1[4] = x5;
469 out1[5] = x6;
470 out1[6] = x7;
471 out1[7] = x8;
472 }
473
474 /// The function sub subtracts two field elements.
475 ///
476 /// Postconditions:
477 /// eval out1 mod m = (eval arg1 - eval arg2) mod m
478 ///
479 pub fn sub(out1: *LooseFieldElement, arg1: TightFieldElement, arg2: TightFieldElement) void {
480 @setRuntimeSafety(mode == .Debug);
481
482 const x1 = ((0x1fffffffffffffe + (arg1[0])) - (arg2[0]));
483 const x2 = ((0x1fffffffffffffe + (arg1[1])) - (arg2[1]));
484 const x3 = ((0x1fffffffffffffe + (arg1[2])) - (arg2[2]));
485 const x4 = ((0x1fffffffffffffe + (arg1[3])) - (arg2[3]));
486 const x5 = ((0x1fffffffffffffc + (arg1[4])) - (arg2[4]));
487 const x6 = ((0x1fffffffffffffe + (arg1[5])) - (arg2[5]));
488 const x7 = ((0x1fffffffffffffe + (arg1[6])) - (arg2[6]));
489 const x8 = ((0x1fffffffffffffe + (arg1[7])) - (arg2[7]));
490 out1[0] = x1;
491 out1[1] = x2;
492 out1[2] = x3;
493 out1[3] = x4;
494 out1[4] = x5;
495 out1[5] = x6;
496 out1[6] = x7;
497 out1[7] = x8;
498 }
499
500 /// The function opp negates a field element.
501 ///
502 /// Postconditions:
503 /// eval out1 mod m = -eval arg1 mod m
504 ///
505 pub fn opp(out1: *LooseFieldElement, arg1: TightFieldElement) void {
506 @setRuntimeSafety(mode == .Debug);
507
508 const x1 = (0x1fffffffffffffe - (arg1[0]));
509 const x2 = (0x1fffffffffffffe - (arg1[1]));
510 const x3 = (0x1fffffffffffffe - (arg1[2]));
511 const x4 = (0x1fffffffffffffe - (arg1[3]));
512 const x5 = (0x1fffffffffffffc - (arg1[4]));
513 const x6 = (0x1fffffffffffffe - (arg1[5]));
514 const x7 = (0x1fffffffffffffe - (arg1[6]));
515 const x8 = (0x1fffffffffffffe - (arg1[7]));
516 out1[0] = x1;
517 out1[1] = x2;
518 out1[2] = x3;
519 out1[3] = x4;
520 out1[4] = x5;
521 out1[5] = x6;
522 out1[6] = x7;
523 out1[7] = x8;
524 }
525
526 /// The function selectznz is a multi-limb conditional select.
527 ///
528 /// Postconditions:
529 /// out1 = (if arg1 = 0 then arg2 else arg3)
530 ///
531 /// Input Bounds:
532 /// arg1: [0x0 ~> 0x1]
533 /// arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
534 /// arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
535 /// Output Bounds:
536 /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]]
537 pub fn selectznz(out1: *[8]u64, arg1: u1, arg2: [8]u64, arg3: [8]u64) void {
538 @setRuntimeSafety(mode == .Debug);
539
540 var x1: u64 = undefined;
541 cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0]));
542 var x2: u64 = undefined;
543 cmovznzU64(&x2, arg1, (arg2[1]), (arg3[1]));
544 var x3: u64 = undefined;
545 cmovznzU64(&x3, arg1, (arg2[2]), (arg3[2]));
546 var x4: u64 = undefined;
547 cmovznzU64(&x4, arg1, (arg2[3]), (arg3[3]));
548 var x5: u64 = undefined;
549 cmovznzU64(&x5, arg1, (arg2[4]), (arg3[4]));
550 var x6: u64 = undefined;
551 cmovznzU64(&x6, arg1, (arg2[5]), (arg3[5]));
552 var x7: u64 = undefined;
553 cmovznzU64(&x7, arg1, (arg2[6]), (arg3[6]));
554 var x8: u64 = undefined;
555 cmovznzU64(&x8, arg1, (arg2[7]), (arg3[7]));
556 out1[0] = x1;
557 out1[1] = x2;
558 out1[2] = x3;
559 out1[3] = x4;
560 out1[4] = x5;
561 out1[5] = x6;
562 out1[6] = x7;
563 out1[7] = x8;
564 }
565
566 /// The function toBytes serializes a field element to bytes in little-endian order.
567 ///
568 /// Postconditions:
569 /// out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..55]
570 ///
571 /// Output Bounds:
572 /// 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 ~> 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 ~> 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 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]]
573 pub fn toBytes(out1: *[56]u8, arg1: TightFieldElement) void {
574 @setRuntimeSafety(mode == .Debug);
575
576 var x1: u64 = undefined;
577 var x2: u1 = undefined;
578 subborrowxU56(&x1, &x2, 0x0, (arg1[0]), 0xffffffffffffff);
579 var x3: u64 = undefined;
580 var x4: u1 = undefined;
581 subborrowxU56(&x3, &x4, x2, (arg1[1]), 0xffffffffffffff);
582 var x5: u64 = undefined;
583 var x6: u1 = undefined;
584 subborrowxU56(&x5, &x6, x4, (arg1[2]), 0xffffffffffffff);
585 var x7: u64 = undefined;
586 var x8: u1 = undefined;
587 subborrowxU56(&x7, &x8, x6, (arg1[3]), 0xffffffffffffff);
588 var x9: u64 = undefined;
589 var x10: u1 = undefined;
590 subborrowxU56(&x9, &x10, x8, (arg1[4]), 0xfffffffffffffe);
591 var x11: u64 = undefined;
592 var x12: u1 = undefined;
593 subborrowxU56(&x11, &x12, x10, (arg1[5]), 0xffffffffffffff);
594 var x13: u64 = undefined;
595 var x14: u1 = undefined;
596 subborrowxU56(&x13, &x14, x12, (arg1[6]), 0xffffffffffffff);
597 var x15: u64 = undefined;
598 var x16: u1 = undefined;
599 subborrowxU56(&x15, &x16, x14, (arg1[7]), 0xffffffffffffff);
600 var x17: u64 = undefined;
601 cmovznzU64(&x17, x16, cast(u64, 0x0), 0xffffffffffffffff);
602 var x18: u64 = undefined;
603 var x19: u1 = undefined;
604 addcarryxU56(&x18, &x19, 0x0, x1, (x17 & 0xffffffffffffff));
605 var x20: u64 = undefined;
606 var x21: u1 = undefined;
607 addcarryxU56(&x20, &x21, x19, x3, (x17 & 0xffffffffffffff));
608 var x22: u64 = undefined;
609 var x23: u1 = undefined;
610 addcarryxU56(&x22, &x23, x21, x5, (x17 & 0xffffffffffffff));
611 var x24: u64 = undefined;
612 var x25: u1 = undefined;
613 addcarryxU56(&x24, &x25, x23, x7, (x17 & 0xffffffffffffff));
614 var x26: u64 = undefined;
615 var x27: u1 = undefined;
616 addcarryxU56(&x26, &x27, x25, x9, (x17 & 0xfffffffffffffe));
617 var x28: u64 = undefined;
618 var x29: u1 = undefined;
619 addcarryxU56(&x28, &x29, x27, x11, (x17 & 0xffffffffffffff));
620 var x30: u64 = undefined;
621 var x31: u1 = undefined;
622 addcarryxU56(&x30, &x31, x29, x13, (x17 & 0xffffffffffffff));
623 var x32: u64 = undefined;
624 var x33: u1 = undefined;
625 addcarryxU56(&x32, &x33, x31, x15, (x17 & 0xffffffffffffff));
626 const x34 = cast(u8, (x18 & cast(u64, 0xff)));
627 const x35 = (x18 >> 8);
628 const x36 = cast(u8, (x35 & cast(u64, 0xff)));
629 const x37 = (x35 >> 8);
630 const x38 = cast(u8, (x37 & cast(u64, 0xff)));
631 const x39 = (x37 >> 8);
632 const x40 = cast(u8, (x39 & cast(u64, 0xff)));
633 const x41 = (x39 >> 8);
634 const x42 = cast(u8, (x41 & cast(u64, 0xff)));
635 const x43 = (x41 >> 8);
636 const x44 = cast(u8, (x43 & cast(u64, 0xff)));
637 const x45 = cast(u8, (x43 >> 8));
638 const x46 = cast(u8, (x20 & cast(u64, 0xff)));
639 const x47 = (x20 >> 8);
640 const x48 = cast(u8, (x47 & cast(u64, 0xff)));
641 const x49 = (x47 >> 8);
642 const x50 = cast(u8, (x49 & cast(u64, 0xff)));
643 const x51 = (x49 >> 8);
644 const x52 = cast(u8, (x51 & cast(u64, 0xff)));
645 const x53 = (x51 >> 8);
646 const x54 = cast(u8, (x53 & cast(u64, 0xff)));
647 const x55 = (x53 >> 8);
648 const x56 = cast(u8, (x55 & cast(u64, 0xff)));
649 const x57 = cast(u8, (x55 >> 8));
650 const x58 = cast(u8, (x22 & cast(u64, 0xff)));
651 const x59 = (x22 >> 8);
652 const x60 = cast(u8, (x59 & cast(u64, 0xff)));
653 const x61 = (x59 >> 8);
654 const x62 = cast(u8, (x61 & cast(u64, 0xff)));
655 const x63 = (x61 >> 8);
656 const x64 = cast(u8, (x63 & cast(u64, 0xff)));
657 const x65 = (x63 >> 8);
658 const x66 = cast(u8, (x65 & cast(u64, 0xff)));
659 const x67 = (x65 >> 8);
660 const x68 = cast(u8, (x67 & cast(u64, 0xff)));
661 const x69 = cast(u8, (x67 >> 8));
662 const x70 = cast(u8, (x24 & cast(u64, 0xff)));
663 const x71 = (x24 >> 8);
664 const x72 = cast(u8, (x71 & cast(u64, 0xff)));
665 const x73 = (x71 >> 8);
666 const x74 = cast(u8, (x73 & cast(u64, 0xff)));
667 const x75 = (x73 >> 8);
668 const x76 = cast(u8, (x75 & cast(u64, 0xff)));
669 const x77 = (x75 >> 8);
670 const x78 = cast(u8, (x77 & cast(u64, 0xff)));
671 const x79 = (x77 >> 8);
672 const x80 = cast(u8, (x79 & cast(u64, 0xff)));
673 const x81 = cast(u8, (x79 >> 8));
674 const x82 = cast(u8, (x26 & cast(u64, 0xff)));
675 const x83 = (x26 >> 8);
676 const x84 = cast(u8, (x83 & cast(u64, 0xff)));
677 const x85 = (x83 >> 8);
678 const x86 = cast(u8, (x85 & cast(u64, 0xff)));
679 const x87 = (x85 >> 8);
680 const x88 = cast(u8, (x87 & cast(u64, 0xff)));
681 const x89 = (x87 >> 8);
682 const x90 = cast(u8, (x89 & cast(u64, 0xff)));
683 const x91 = (x89 >> 8);
684 const x92 = cast(u8, (x91 & cast(u64, 0xff)));
685 const x93 = cast(u8, (x91 >> 8));
686 const x94 = cast(u8, (x28 & cast(u64, 0xff)));
687 const x95 = (x28 >> 8);
688 const x96 = cast(u8, (x95 & cast(u64, 0xff)));
689 const x97 = (x95 >> 8);
690 const x98 = cast(u8, (x97 & cast(u64, 0xff)));
691 const x99 = (x97 >> 8);
692 const x100 = cast(u8, (x99 & cast(u64, 0xff)));
693 const x101 = (x99 >> 8);
694 const x102 = cast(u8, (x101 & cast(u64, 0xff)));
695 const x103 = (x101 >> 8);
696 const x104 = cast(u8, (x103 & cast(u64, 0xff)));
697 const x105 = cast(u8, (x103 >> 8));
698 const x106 = cast(u8, (x30 & cast(u64, 0xff)));
699 const x107 = (x30 >> 8);
700 const x108 = cast(u8, (x107 & cast(u64, 0xff)));
701 const x109 = (x107 >> 8);
702 const x110 = cast(u8, (x109 & cast(u64, 0xff)));
703 const x111 = (x109 >> 8);
704 const x112 = cast(u8, (x111 & cast(u64, 0xff)));
705 const x113 = (x111 >> 8);
706 const x114 = cast(u8, (x113 & cast(u64, 0xff)));
707 const x115 = (x113 >> 8);
708 const x116 = cast(u8, (x115 & cast(u64, 0xff)));
709 const x117 = cast(u8, (x115 >> 8));
710 const x118 = cast(u8, (x32 & cast(u64, 0xff)));
711 const x119 = (x32 >> 8);
712 const x120 = cast(u8, (x119 & cast(u64, 0xff)));
713 const x121 = (x119 >> 8);
714 const x122 = cast(u8, (x121 & cast(u64, 0xff)));
715 const x123 = (x121 >> 8);
716 const x124 = cast(u8, (x123 & cast(u64, 0xff)));
717 const x125 = (x123 >> 8);
718 const x126 = cast(u8, (x125 & cast(u64, 0xff)));
719 const x127 = (x125 >> 8);
720 const x128 = cast(u8, (x127 & cast(u64, 0xff)));
721 const x129 = cast(u8, (x127 >> 8));
722 out1[0] = x34;
723 out1[1] = x36;
724 out1[2] = x38;
725 out1[3] = x40;
726 out1[4] = x42;
727 out1[5] = x44;
728 out1[6] = x45;
729 out1[7] = x46;
730 out1[8] = x48;
731 out1[9] = x50;
732 out1[10] = x52;
733 out1[11] = x54;
734 out1[12] = x56;
735 out1[13] = x57;
736 out1[14] = x58;
737 out1[15] = x60;
738 out1[16] = x62;
739 out1[17] = x64;
740 out1[18] = x66;
741 out1[19] = x68;
742 out1[20] = x69;
743 out1[21] = x70;
744 out1[22] = x72;
745 out1[23] = x74;
746 out1[24] = x76;
747 out1[25] = x78;
748 out1[26] = x80;
749 out1[27] = x81;
750 out1[28] = x82;
751 out1[29] = x84;
752 out1[30] = x86;
753 out1[31] = x88;
754 out1[32] = x90;
755 out1[33] = x92;
756 out1[34] = x93;
757 out1[35] = x94;
758 out1[36] = x96;
759 out1[37] = x98;
760 out1[38] = x100;
761 out1[39] = x102;
762 out1[40] = x104;
763 out1[41] = x105;
764 out1[42] = x106;
765 out1[43] = x108;
766 out1[44] = x110;
767 out1[45] = x112;
768 out1[46] = x114;
769 out1[47] = x116;
770 out1[48] = x117;
771 out1[49] = x118;
772 out1[50] = x120;
773 out1[51] = x122;
774 out1[52] = x124;
775 out1[53] = x126;
776 out1[54] = x128;
777 out1[55] = x129;
778 }
779
780 /// The function fromBytes deserializes a field element from bytes in little-endian order.
781 ///
782 /// Postconditions:
783 /// eval out1 mod m = bytes_eval arg1 mod m
784 ///
785 /// Input Bounds:
786 /// 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 ~> 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 ~> 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 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]]
787 pub fn fromBytes(out1: *TightFieldElement, arg1: [56]u8) void {
788 @setRuntimeSafety(mode == .Debug);
789
790 const x1 = (cast(u64, (arg1[55])) << 48);
791 const x2 = (cast(u64, (arg1[54])) << 40);
792 const x3 = (cast(u64, (arg1[53])) << 32);
793 const x4 = (cast(u64, (arg1[52])) << 24);
794 const x5 = (cast(u64, (arg1[51])) << 16);
795 const x6 = (cast(u64, (arg1[50])) << 8);
796 const x7 = (arg1[49]);
797 const x8 = (cast(u64, (arg1[48])) << 48);
798 const x9 = (cast(u64, (arg1[47])) << 40);
799 const x10 = (cast(u64, (arg1[46])) << 32);
800 const x11 = (cast(u64, (arg1[45])) << 24);
801 const x12 = (cast(u64, (arg1[44])) << 16);
802 const x13 = (cast(u64, (arg1[43])) << 8);
803 const x14 = (arg1[42]);
804 const x15 = (cast(u64, (arg1[41])) << 48);
805 const x16 = (cast(u64, (arg1[40])) << 40);
806 const x17 = (cast(u64, (arg1[39])) << 32);
807 const x18 = (cast(u64, (arg1[38])) << 24);
808 const x19 = (cast(u64, (arg1[37])) << 16);
809 const x20 = (cast(u64, (arg1[36])) << 8);
810 const x21 = (arg1[35]);
811 const x22 = (cast(u64, (arg1[34])) << 48);
812 const x23 = (cast(u64, (arg1[33])) << 40);
813 const x24 = (cast(u64, (arg1[32])) << 32);
814 const x25 = (cast(u64, (arg1[31])) << 24);
815 const x26 = (cast(u64, (arg1[30])) << 16);
816 const x27 = (cast(u64, (arg1[29])) << 8);
817 const x28 = (arg1[28]);
818 const x29 = (cast(u64, (arg1[27])) << 48);
819 const x30 = (cast(u64, (arg1[26])) << 40);
820 const x31 = (cast(u64, (arg1[25])) << 32);
821 const x32 = (cast(u64, (arg1[24])) << 24);
822 const x33 = (cast(u64, (arg1[23])) << 16);
823 const x34 = (cast(u64, (arg1[22])) << 8);
824 const x35 = (arg1[21]);
825 const x36 = (cast(u64, (arg1[20])) << 48);
826 const x37 = (cast(u64, (arg1[19])) << 40);
827 const x38 = (cast(u64, (arg1[18])) << 32);
828 const x39 = (cast(u64, (arg1[17])) << 24);
829 const x40 = (cast(u64, (arg1[16])) << 16);
830 const x41 = (cast(u64, (arg1[15])) << 8);
831 const x42 = (arg1[14]);
832 const x43 = (cast(u64, (arg1[13])) << 48);
833 const x44 = (cast(u64, (arg1[12])) << 40);
834 const x45 = (cast(u64, (arg1[11])) << 32);
835 const x46 = (cast(u64, (arg1[10])) << 24);
836 const x47 = (cast(u64, (arg1[9])) << 16);
837 const x48 = (cast(u64, (arg1[8])) << 8);
838 const x49 = (arg1[7]);
839 const x50 = (cast(u64, (arg1[6])) << 48);
840 const x51 = (cast(u64, (arg1[5])) << 40);
841 const x52 = (cast(u64, (arg1[4])) << 32);
842 const x53 = (cast(u64, (arg1[3])) << 24);
843 const x54 = (cast(u64, (arg1[2])) << 16);
844 const x55 = (cast(u64, (arg1[1])) << 8);
845 const x56 = (arg1[0]);
846 const x57 = (x55 + cast(u64, x56));
847 const x58 = (x54 + x57);
848 const x59 = (x53 + x58);
849 const x60 = (x52 + x59);
850 const x61 = (x51 + x60);
851 const x62 = (x50 + x61);
852 const x63 = (x48 + cast(u64, x49));
853 const x64 = (x47 + x63);
854 const x65 = (x46 + x64);
855 const x66 = (x45 + x65);
856 const x67 = (x44 + x66);
857 const x68 = (x43 + x67);
858 const x69 = (x41 + cast(u64, x42));
859 const x70 = (x40 + x69);
860 const x71 = (x39 + x70);
861 const x72 = (x38 + x71);
862 const x73 = (x37 + x72);
863 const x74 = (x36 + x73);
864 const x75 = (x34 + cast(u64, x35));
865 const x76 = (x33 + x75);
866 const x77 = (x32 + x76);
867 const x78 = (x31 + x77);
868 const x79 = (x30 + x78);
869 const x80 = (x29 + x79);
870 const x81 = (x27 + cast(u64, x28));
871 const x82 = (x26 + x81);
872 const x83 = (x25 + x82);
873 const x84 = (x24 + x83);
874 const x85 = (x23 + x84);
875 const x86 = (x22 + x85);
876 const x87 = (x20 + cast(u64, x21));
877 const x88 = (x19 + x87);
878 const x89 = (x18 + x88);
879 const x90 = (x17 + x89);
880 const x91 = (x16 + x90);
881 const x92 = (x15 + x91);
882 const x93 = (x13 + cast(u64, x14));
883 const x94 = (x12 + x93);
884 const x95 = (x11 + x94);
885 const x96 = (x10 + x95);
886 const x97 = (x9 + x96);
887 const x98 = (x8 + x97);
888 const x99 = (x6 + cast(u64, x7));
889 const x100 = (x5 + x99);
890 const x101 = (x4 + x100);
891 const x102 = (x3 + x101);
892 const x103 = (x2 + x102);
893 const x104 = (x1 + x103);
894 out1[0] = x62;
895 out1[1] = x68;
896 out1[2] = x74;
897 out1[3] = x80;
898 out1[4] = x86;
899 out1[5] = x92;
900 out1[6] = x98;
901 out1[7] = x104;
902 }
903
904 /// The function relax is the identity function converting from tight field elements to loose field elements.
905 ///
906 /// Postconditions:
907 /// out1 = arg1
908 ///
909 pub fn relax(out1: *LooseFieldElement, arg1: TightFieldElement) void {
910 @setRuntimeSafety(mode == .Debug);
911
912 const x1 = (arg1[0]);
913 const x2 = (arg1[1]);
914 const x3 = (arg1[2]);
915 const x4 = (arg1[3]);
916 const x5 = (arg1[4]);
917 const x6 = (arg1[5]);
918 const x7 = (arg1[6]);
919 const x8 = (arg1[7]);
920 out1[0] = x1;
921 out1[1] = x2;
922 out1[2] = x3;
923 out1[3] = x4;
924 out1[4] = x5;
925 out1[5] = x6;
926 out1[6] = x7;
927 out1[7] = x8;
928 }