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