| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#![allow(unused_parens)] |
| 16 |
#![allow(non_camel_case_types)] |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
struct IndexConst<T: ?Sized>(T); |
| 22 |
|
| 23 |
impl<'a, T, const N: usize> IndexConst<&'a [T; N]> { |
| 24 |
#[inline(always)] |
| 25 |
#[allow(unused)] |
| 26 |
const fn index(self, i: usize) -> &'a T { |
| 27 |
&self.0[i] |
| 28 |
} |
| 29 |
} |
| 30 |
impl<'a, 'b, T, const N: usize> IndexConst<&'a mut &'b mut [T; N]> { |
| 31 |
#[inline(always)] |
| 32 |
#[allow(unused)] |
| 33 |
const fn index_mut(self, i: usize) -> &'a mut T { |
| 34 |
&mut self.0[i] |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
pub type fiat_25519_u1 = u8; |
| 40 |
|
| 41 |
pub type fiat_25519_i1 = i8; |
| 42 |
|
| 43 |
pub type fiat_25519_u2 = u8; |
| 44 |
|
| 45 |
pub type fiat_25519_i2 = i8; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
#[derive(Clone, Copy)] |
| 50 |
pub struct fiat_25519_loose_field_element(pub [u64; 5]); |
| 51 |
|
| 52 |
impl core::ops::Index<usize> for fiat_25519_loose_field_element { |
| 53 |
type Output = u64; |
| 54 |
#[inline] |
| 55 |
fn index(&self, index: usize) -> &Self::Output { |
| 56 |
&self.0[index] |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
impl core::ops::IndexMut<usize> for fiat_25519_loose_field_element { |
| 61 |
#[inline] |
| 62 |
fn index_mut(&mut self, index: usize) -> &mut Self::Output { |
| 63 |
&mut self.0[index] |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
impl<'a> IndexConst<&'a fiat_25519_loose_field_element> { |
| 68 |
#[allow(unused)] |
| 69 |
#[inline(always)] |
| 70 |
const fn index(self, i: usize) -> &'a u64 { |
| 71 |
&self.0.0[i] |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
impl<'a, 'b> IndexConst<&'a mut &'b mut fiat_25519_loose_field_element> { |
| 76 |
#[allow(unused)] |
| 77 |
#[inline(always)] |
| 78 |
const fn index_mut(self, i: usize) -> &'a mut u64 { |
| 79 |
&mut self.0.0[i] |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
#[derive(Clone, Copy)] |
| 86 |
pub struct fiat_25519_tight_field_element(pub [u64; 5]); |
| 87 |
|
| 88 |
impl core::ops::Index<usize> for fiat_25519_tight_field_element { |
| 89 |
type Output = u64; |
| 90 |
#[inline] |
| 91 |
fn index(&self, index: usize) -> &Self::Output { |
| 92 |
&self.0[index] |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
impl core::ops::IndexMut<usize> for fiat_25519_tight_field_element { |
| 97 |
#[inline] |
| 98 |
fn index_mut(&mut self, index: usize) -> &mut Self::Output { |
| 99 |
&mut self.0[index] |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
impl<'a> IndexConst<&'a fiat_25519_tight_field_element> { |
| 104 |
#[allow(unused)] |
| 105 |
#[inline(always)] |
| 106 |
const fn index(self, i: usize) -> &'a u64 { |
| 107 |
&self.0.0[i] |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
impl<'a, 'b> IndexConst<&'a mut &'b mut fiat_25519_tight_field_element> { |
| 112 |
#[allow(unused)] |
| 113 |
#[inline(always)] |
| 114 |
const fn index_mut(self, i: usize) -> &'a mut u64 { |
| 115 |
&mut self.0.0[i] |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
1⌋ |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
#[inline] |
| 134 |
pub const fn fiat_25519_addcarryx_u51(out1: &mut u64, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u64, arg3: u64) { |
| 135 |
let x1: u64 = (((arg1 as u64) + arg2) + arg3); |
| 136 |
let x2: u64 = (x1 & 0x7ffffffffffff); |
| 137 |
let x3: fiat_25519_u1 = ((x1 >> 51) as fiat_25519_u1); |
| 138 |
*out1 = x2; |
| 139 |
*out2 = x3; |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
1⌋ |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
#[inline] |
| 156 |
pub const fn fiat_25519_subborrowx_u51(out1: &mut u64, out2: &mut fiat_25519_u1, arg1: fiat_25519_u1, arg2: u64, arg3: u64) { |
| 157 |
let x1: i64 = ((((((arg2 as i128) - (arg1 as i128)) as i64) as i128) - (arg3 as i128)) as i64); |
| 158 |
let x2: fiat_25519_i1 = ((x1 >> 51) as fiat_25519_i1); |
| 159 |
let x3: u64 = (((x1 as i128) & (0x7ffffffffffff as i128)) as u64); |
| 160 |
*out1 = x3; |
| 161 |
*out2 = (((0x0 as fiat_25519_i2) - (x2 as fiat_25519_i2)) as fiat_25519_u1); |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
#[inline] |
| 176 |
pub const fn fiat_25519_cmovznz_u64(out1: &mut u64, arg1: fiat_25519_u1, arg2: u64, arg3: u64) { |
| 177 |
let x1: fiat_25519_u1 = (!(!arg1)); |
| 178 |
let x2: u64 = ((((((0x0 as fiat_25519_i2) - (x1 as fiat_25519_i2)) as fiat_25519_i1) as i128) & (0xffffffffffffffff as i128)) as u64); |
| 179 |
let x3: u64 = ((x2 & arg3) | ((!x2) & arg2)); |
| 180 |
*out1 = x3; |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
#[inline] |
| 189 |
pub const fn fiat_25519_carry_mul(mut out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element, arg2: &fiat_25519_loose_field_element) { |
| 190 |
let x1: u128 = (((*IndexConst(arg1).index(4)) as u128) * (((*IndexConst(arg2).index(4)) * 0x13) as u128)); |
| 191 |
let x2: u128 = (((*IndexConst(arg1).index(4)) as u128) * (((*IndexConst(arg2).index(3)) * 0x13) as u128)); |
| 192 |
let x3: u128 = (((*IndexConst(arg1).index(4)) as u128) * (((*IndexConst(arg2).index(2)) * 0x13) as u128)); |
| 193 |
let x4: u128 = (((*IndexConst(arg1).index(4)) as u128) * (((*IndexConst(arg2).index(1)) * 0x13) as u128)); |
| 194 |
let x5: u128 = (((*IndexConst(arg1).index(3)) as u128) * (((*IndexConst(arg2).index(4)) * 0x13) as u128)); |
| 195 |
let x6: u128 = (((*IndexConst(arg1).index(3)) as u128) * (((*IndexConst(arg2).index(3)) * 0x13) as u128)); |
| 196 |
let x7: u128 = (((*IndexConst(arg1).index(3)) as u128) * (((*IndexConst(arg2).index(2)) * 0x13) as u128)); |
| 197 |
let x8: u128 = (((*IndexConst(arg1).index(2)) as u128) * (((*IndexConst(arg2).index(4)) * 0x13) as u128)); |
| 198 |
let x9: u128 = (((*IndexConst(arg1).index(2)) as u128) * (((*IndexConst(arg2).index(3)) * 0x13) as u128)); |
| 199 |
let x10: u128 = (((*IndexConst(arg1).index(1)) as u128) * (((*IndexConst(arg2).index(4)) * 0x13) as u128)); |
| 200 |
let x11: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(0)) as u128)); |
| 201 |
let x12: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(1)) as u128)); |
| 202 |
let x13: u128 = (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(0)) as u128)); |
| 203 |
let x14: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(2)) as u128)); |
| 204 |
let x15: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(1)) as u128)); |
| 205 |
let x16: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(0)) as u128)); |
| 206 |
let x17: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(3)) as u128)); |
| 207 |
let x18: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(2)) as u128)); |
| 208 |
let x19: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(1)) as u128)); |
| 209 |
let x20: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(0)) as u128)); |
| 210 |
let x21: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(4)) as u128)); |
| 211 |
let x22: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(3)) as u128)); |
| 212 |
let x23: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(2)) as u128)); |
| 213 |
let x24: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(1)) as u128)); |
| 214 |
let x25: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(0)) as u128)); |
| 215 |
let x26: u128 = (x25 + (x10 + (x9 + (x7 + x4)))); |
| 216 |
let x27: u64 = ((x26 >> 51) as u64); |
| 217 |
let x28: u64 = ((x26 & (0x7ffffffffffff as u128)) as u64); |
| 218 |
let x29: u128 = (x21 + (x17 + (x14 + (x12 + x11)))); |
| 219 |
let x30: u128 = (x22 + (x18 + (x15 + (x13 + x1)))); |
| 220 |
let x31: u128 = (x23 + (x19 + (x16 + (x5 + x2)))); |
| 221 |
let x32: u128 = (x24 + (x20 + (x8 + (x6 + x3)))); |
| 222 |
let x33: u128 = ((x27 as u128) + x32); |
| 223 |
let x34: u64 = ((x33 >> 51) as u64); |
| 224 |
let x35: u64 = ((x33 & (0x7ffffffffffff as u128)) as u64); |
| 225 |
let x36: u128 = ((x34 as u128) + x31); |
| 226 |
let x37: u64 = ((x36 >> 51) as u64); |
| 227 |
let x38: u64 = ((x36 & (0x7ffffffffffff as u128)) as u64); |
| 228 |
let x39: u128 = ((x37 as u128) + x30); |
| 229 |
let x40: u64 = ((x39 >> 51) as u64); |
| 230 |
let x41: u64 = ((x39 & (0x7ffffffffffff as u128)) as u64); |
| 231 |
let x42: u128 = ((x40 as u128) + x29); |
| 232 |
let x43: u64 = ((x42 >> 51) as u64); |
| 233 |
let x44: u64 = ((x42 & (0x7ffffffffffff as u128)) as u64); |
| 234 |
let x45: u64 = (x43 * 0x13); |
| 235 |
let x46: u64 = (x28 + x45); |
| 236 |
let x47: u64 = (x46 >> 51); |
| 237 |
let x48: u64 = (x46 & 0x7ffffffffffff); |
| 238 |
let x49: u64 = (x47 + x35); |
| 239 |
let x50: fiat_25519_u1 = ((x49 >> 51) as fiat_25519_u1); |
| 240 |
let x51: u64 = (x49 & 0x7ffffffffffff); |
| 241 |
let x52: u64 = ((x50 as u64) + x38); |
| 242 |
*IndexConst(&mut out1).index_mut(0) = x48; |
| 243 |
*IndexConst(&mut out1).index_mut(1) = x51; |
| 244 |
*IndexConst(&mut out1).index_mut(2) = x52; |
| 245 |
*IndexConst(&mut out1).index_mut(3) = x41; |
| 246 |
*IndexConst(&mut out1).index_mut(4) = x44; |
| 247 |
} |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
#[inline] |
| 255 |
pub const fn fiat_25519_carry_square(mut out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element) { |
| 256 |
let x1: u64 = ((*IndexConst(arg1).index(4)) * 0x13); |
| 257 |
let x2: u64 = (x1 * 0x2); |
| 258 |
let x3: u64 = ((*IndexConst(arg1).index(4)) * 0x2); |
| 259 |
let x4: u64 = ((*IndexConst(arg1).index(3)) * 0x13); |
| 260 |
let x5: u64 = (x4 * 0x2); |
| 261 |
let x6: u64 = ((*IndexConst(arg1).index(3)) * 0x2); |
| 262 |
let x7: u64 = ((*IndexConst(arg1).index(2)) * 0x2); |
| 263 |
let x8: u64 = ((*IndexConst(arg1).index(1)) * 0x2); |
| 264 |
let x9: u128 = (((*IndexConst(arg1).index(4)) as u128) * (x1 as u128)); |
| 265 |
let x10: u128 = (((*IndexConst(arg1).index(3)) as u128) * (x2 as u128)); |
| 266 |
let x11: u128 = (((*IndexConst(arg1).index(3)) as u128) * (x4 as u128)); |
| 267 |
let x12: u128 = (((*IndexConst(arg1).index(2)) as u128) * (x2 as u128)); |
| 268 |
let x13: u128 = (((*IndexConst(arg1).index(2)) as u128) * (x5 as u128)); |
| 269 |
let x14: u128 = (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg1).index(2)) as u128)); |
| 270 |
let x15: u128 = (((*IndexConst(arg1).index(1)) as u128) * (x2 as u128)); |
| 271 |
let x16: u128 = (((*IndexConst(arg1).index(1)) as u128) * (x6 as u128)); |
| 272 |
let x17: u128 = (((*IndexConst(arg1).index(1)) as u128) * (x7 as u128)); |
| 273 |
let x18: u128 = (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg1).index(1)) as u128)); |
| 274 |
let x19: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x3 as u128)); |
| 275 |
let x20: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x6 as u128)); |
| 276 |
let x21: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x7 as u128)); |
| 277 |
let x22: u128 = (((*IndexConst(arg1).index(0)) as u128) * (x8 as u128)); |
| 278 |
let x23: u128 = (((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg1).index(0)) as u128)); |
| 279 |
let x24: u128 = (x23 + (x15 + x13)); |
| 280 |
let x25: u64 = ((x24 >> 51) as u64); |
| 281 |
let x26: u64 = ((x24 & (0x7ffffffffffff as u128)) as u64); |
| 282 |
let x27: u128 = (x19 + (x16 + x14)); |
| 283 |
let x28: u128 = (x20 + (x17 + x9)); |
| 284 |
let x29: u128 = (x21 + (x18 + x10)); |
| 285 |
let x30: u128 = (x22 + (x12 + x11)); |
| 286 |
let x31: u128 = ((x25 as u128) + x30); |
| 287 |
let x32: u64 = ((x31 >> 51) as u64); |
| 288 |
let x33: u64 = ((x31 & (0x7ffffffffffff as u128)) as u64); |
| 289 |
let x34: u128 = ((x32 as u128) + x29); |
| 290 |
let x35: u64 = ((x34 >> 51) as u64); |
| 291 |
let x36: u64 = ((x34 & (0x7ffffffffffff as u128)) as u64); |
| 292 |
let x37: u128 = ((x35 as u128) + x28); |
| 293 |
let x38: u64 = ((x37 >> 51) as u64); |
| 294 |
let x39: u64 = ((x37 & (0x7ffffffffffff as u128)) as u64); |
| 295 |
let x40: u128 = ((x38 as u128) + x27); |
| 296 |
let x41: u64 = ((x40 >> 51) as u64); |
| 297 |
let x42: u64 = ((x40 & (0x7ffffffffffff as u128)) as u64); |
| 298 |
let x43: u64 = (x41 * 0x13); |
| 299 |
let x44: u64 = (x26 + x43); |
| 300 |
let x45: u64 = (x44 >> 51); |
| 301 |
let x46: u64 = (x44 & 0x7ffffffffffff); |
| 302 |
let x47: u64 = (x45 + x33); |
| 303 |
let x48: fiat_25519_u1 = ((x47 >> 51) as fiat_25519_u1); |
| 304 |
let x49: u64 = (x47 & 0x7ffffffffffff); |
| 305 |
let x50: u64 = ((x48 as u64) + x36); |
| 306 |
*IndexConst(&mut out1).index_mut(0) = x46; |
| 307 |
*IndexConst(&mut out1).index_mut(1) = x49; |
| 308 |
*IndexConst(&mut out1).index_mut(2) = x50; |
| 309 |
*IndexConst(&mut out1).index_mut(3) = x39; |
| 310 |
*IndexConst(&mut out1).index_mut(4) = x42; |
| 311 |
} |
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
#[inline] |
| 319 |
pub const fn fiat_25519_carry(mut out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element) { |
| 320 |
let x1: u64 = (*IndexConst(arg1).index(0)); |
| 321 |
let x2: u64 = ((x1 >> 51) + (*IndexConst(arg1).index(1))); |
| 322 |
let x3: u64 = ((x2 >> 51) + (*IndexConst(arg1).index(2))); |
| 323 |
let x4: u64 = ((x3 >> 51) + (*IndexConst(arg1).index(3))); |
| 324 |
let x5: u64 = ((x4 >> 51) + (*IndexConst(arg1).index(4))); |
| 325 |
let x6: u64 = ((x1 & 0x7ffffffffffff) + ((x5 >> 51) * 0x13)); |
| 326 |
let x7: u64 = ((((x6 >> 51) as fiat_25519_u1) as u64) + (x2 & 0x7ffffffffffff)); |
| 327 |
let x8: u64 = (x6 & 0x7ffffffffffff); |
| 328 |
let x9: u64 = (x7 & 0x7ffffffffffff); |
| 329 |
let x10: u64 = ((((x7 >> 51) as fiat_25519_u1) as u64) + (x3 & 0x7ffffffffffff)); |
| 330 |
let x11: u64 = (x4 & 0x7ffffffffffff); |
| 331 |
let x12: u64 = (x5 & 0x7ffffffffffff); |
| 332 |
*IndexConst(&mut out1).index_mut(0) = x8; |
| 333 |
*IndexConst(&mut out1).index_mut(1) = x9; |
| 334 |
*IndexConst(&mut out1).index_mut(2) = x10; |
| 335 |
*IndexConst(&mut out1).index_mut(3) = x11; |
| 336 |
*IndexConst(&mut out1).index_mut(4) = x12; |
| 337 |
} |
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
#[inline] |
| 345 |
pub const fn fiat_25519_add(mut out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element, arg2: &fiat_25519_tight_field_element) { |
| 346 |
let x1: u64 = ((*IndexConst(arg1).index(0)) + (*IndexConst(arg2).index(0))); |
| 347 |
let x2: u64 = ((*IndexConst(arg1).index(1)) + (*IndexConst(arg2).index(1))); |
| 348 |
let x3: u64 = ((*IndexConst(arg1).index(2)) + (*IndexConst(arg2).index(2))); |
| 349 |
let x4: u64 = ((*IndexConst(arg1).index(3)) + (*IndexConst(arg2).index(3))); |
| 350 |
let x5: u64 = ((*IndexConst(arg1).index(4)) + (*IndexConst(arg2).index(4))); |
| 351 |
*IndexConst(&mut out1).index_mut(0) = x1; |
| 352 |
*IndexConst(&mut out1).index_mut(1) = x2; |
| 353 |
*IndexConst(&mut out1).index_mut(2) = x3; |
| 354 |
*IndexConst(&mut out1).index_mut(3) = x4; |
| 355 |
*IndexConst(&mut out1).index_mut(4) = x5; |
| 356 |
} |
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
#[inline] |
| 364 |
pub const fn fiat_25519_sub(mut out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element, arg2: &fiat_25519_tight_field_element) { |
| 365 |
let x1: u64 = ((0xfffffffffffda + (*IndexConst(arg1).index(0))) - (*IndexConst(arg2).index(0))); |
| 366 |
let x2: u64 = ((0xffffffffffffe + (*IndexConst(arg1).index(1))) - (*IndexConst(arg2).index(1))); |
| 367 |
let x3: u64 = ((0xffffffffffffe + (*IndexConst(arg1).index(2))) - (*IndexConst(arg2).index(2))); |
| 368 |
let x4: u64 = ((0xffffffffffffe + (*IndexConst(arg1).index(3))) - (*IndexConst(arg2).index(3))); |
| 369 |
let x5: u64 = ((0xffffffffffffe + (*IndexConst(arg1).index(4))) - (*IndexConst(arg2).index(4))); |
| 370 |
*IndexConst(&mut out1).index_mut(0) = x1; |
| 371 |
*IndexConst(&mut out1).index_mut(1) = x2; |
| 372 |
*IndexConst(&mut out1).index_mut(2) = x3; |
| 373 |
*IndexConst(&mut out1).index_mut(3) = x4; |
| 374 |
*IndexConst(&mut out1).index_mut(4) = x5; |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
#[inline] |
| 383 |
pub const fn fiat_25519_opp(mut out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element) { |
| 384 |
let x1: u64 = (0xfffffffffffda - (*IndexConst(arg1).index(0))); |
| 385 |
let x2: u64 = (0xffffffffffffe - (*IndexConst(arg1).index(1))); |
| 386 |
let x3: u64 = (0xffffffffffffe - (*IndexConst(arg1).index(2))); |
| 387 |
let x4: u64 = (0xffffffffffffe - (*IndexConst(arg1).index(3))); |
| 388 |
let x5: u64 = (0xffffffffffffe - (*IndexConst(arg1).index(4))); |
| 389 |
*IndexConst(&mut out1).index_mut(0) = x1; |
| 390 |
*IndexConst(&mut out1).index_mut(1) = x2; |
| 391 |
*IndexConst(&mut out1).index_mut(2) = x3; |
| 392 |
*IndexConst(&mut out1).index_mut(3) = x4; |
| 393 |
*IndexConst(&mut out1).index_mut(4) = x5; |
| 394 |
} |
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
#[inline] |
| 408 |
pub const fn fiat_25519_selectznz(mut out1: &mut [u64; 5], arg1: fiat_25519_u1, arg2: &[u64; 5], arg3: &[u64; 5]) { |
| 409 |
let mut x1: u64 = 0; |
| 410 |
fiat_25519_cmovznz_u64(&mut x1, arg1, (*IndexConst(arg2).index(0)), (*IndexConst(arg3).index(0))); |
| 411 |
let mut x2: u64 = 0; |
| 412 |
fiat_25519_cmovznz_u64(&mut x2, arg1, (*IndexConst(arg2).index(1)), (*IndexConst(arg3).index(1))); |
| 413 |
let mut x3: u64 = 0; |
| 414 |
fiat_25519_cmovznz_u64(&mut x3, arg1, (*IndexConst(arg2).index(2)), (*IndexConst(arg3).index(2))); |
| 415 |
let mut x4: u64 = 0; |
| 416 |
fiat_25519_cmovznz_u64(&mut x4, arg1, (*IndexConst(arg2).index(3)), (*IndexConst(arg3).index(3))); |
| 417 |
let mut x5: u64 = 0; |
| 418 |
fiat_25519_cmovznz_u64(&mut x5, arg1, (*IndexConst(arg2).index(4)), (*IndexConst(arg3).index(4))); |
| 419 |
*IndexConst(&mut out1).index_mut(0) = x1; |
| 420 |
*IndexConst(&mut out1).index_mut(1) = x2; |
| 421 |
*IndexConst(&mut out1).index_mut(2) = x3; |
| 422 |
*IndexConst(&mut out1).index_mut(3) = x4; |
| 423 |
*IndexConst(&mut out1).index_mut(4) = x5; |
| 424 |
} |
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
..31] |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
#[inline] |
| 434 |
pub const fn fiat_25519_to_bytes(mut out1: &mut [u8; 32], arg1: &fiat_25519_tight_field_element) { |
| 435 |
let mut x1: u64 = 0; |
| 436 |
let mut x2: fiat_25519_u1 = 0; |
| 437 |
fiat_25519_subborrowx_u51(&mut x1, &mut x2, 0x0, (*IndexConst(arg1).index(0)), 0x7ffffffffffed); |
| 438 |
let mut x3: u64 = 0; |
| 439 |
let mut x4: fiat_25519_u1 = 0; |
| 440 |
fiat_25519_subborrowx_u51(&mut x3, &mut x4, x2, (*IndexConst(arg1).index(1)), 0x7ffffffffffff); |
| 441 |
let mut x5: u64 = 0; |
| 442 |
let mut x6: fiat_25519_u1 = 0; |
| 443 |
fiat_25519_subborrowx_u51(&mut x5, &mut x6, x4, (*IndexConst(arg1).index(2)), 0x7ffffffffffff); |
| 444 |
let mut x7: u64 = 0; |
| 445 |
let mut x8: fiat_25519_u1 = 0; |
| 446 |
fiat_25519_subborrowx_u51(&mut x7, &mut x8, x6, (*IndexConst(arg1).index(3)), 0x7ffffffffffff); |
| 447 |
let mut x9: u64 = 0; |
| 448 |
let mut x10: fiat_25519_u1 = 0; |
| 449 |
fiat_25519_subborrowx_u51(&mut x9, &mut x10, x8, (*IndexConst(arg1).index(4)), 0x7ffffffffffff); |
| 450 |
let mut x11: u64 = 0; |
| 451 |
fiat_25519_cmovznz_u64(&mut x11, x10, (0x0 as u64), 0xffffffffffffffff); |
| 452 |
let mut x12: u64 = 0; |
| 453 |
let mut x13: fiat_25519_u1 = 0; |
| 454 |
fiat_25519_addcarryx_u51(&mut x12, &mut x13, 0x0, x1, (x11 & 0x7ffffffffffed)); |
| 455 |
let mut x14: u64 = 0; |
| 456 |
let mut x15: fiat_25519_u1 = 0; |
| 457 |
fiat_25519_addcarryx_u51(&mut x14, &mut x15, x13, x3, (x11 & 0x7ffffffffffff)); |
| 458 |
let mut x16: u64 = 0; |
| 459 |
let mut x17: fiat_25519_u1 = 0; |
| 460 |
fiat_25519_addcarryx_u51(&mut x16, &mut x17, x15, x5, (x11 & 0x7ffffffffffff)); |
| 461 |
let mut x18: u64 = 0; |
| 462 |
let mut x19: fiat_25519_u1 = 0; |
| 463 |
fiat_25519_addcarryx_u51(&mut x18, &mut x19, x17, x7, (x11 & 0x7ffffffffffff)); |
| 464 |
let mut x20: u64 = 0; |
| 465 |
let mut x21: fiat_25519_u1 = 0; |
| 466 |
fiat_25519_addcarryx_u51(&mut x20, &mut x21, x19, x9, (x11 & 0x7ffffffffffff)); |
| 467 |
let x22: u64 = (x20 << 4); |
| 468 |
let x23: u64 = (x18 * (0x2 as u64)); |
| 469 |
let x24: u64 = (x16 << 6); |
| 470 |
let x25: u64 = (x14 << 3); |
| 471 |
let x26: u8 = ((x12 & (0xff as u64)) as u8); |
| 472 |
let x27: u64 = (x12 >> 8); |
| 473 |
let x28: u8 = ((x27 & (0xff as u64)) as u8); |
| 474 |
let x29: u64 = (x27 >> 8); |
| 475 |
let x30: u8 = ((x29 & (0xff as u64)) as u8); |
| 476 |
let x31: u64 = (x29 >> 8); |
| 477 |
let x32: u8 = ((x31 & (0xff as u64)) as u8); |
| 478 |
let x33: u64 = (x31 >> 8); |
| 479 |
let x34: u8 = ((x33 & (0xff as u64)) as u8); |
| 480 |
let x35: u64 = (x33 >> 8); |
| 481 |
let x36: u8 = ((x35 & (0xff as u64)) as u8); |
| 482 |
let x37: u8 = ((x35 >> 8) as u8); |
| 483 |
let x38: u64 = (x25 + (x37 as u64)); |
| 484 |
let x39: u8 = ((x38 & (0xff as u64)) as u8); |
| 485 |
let x40: u64 = (x38 >> 8); |
| 486 |
let x41: u8 = ((x40 & (0xff as u64)) as u8); |
| 487 |
let x42: u64 = (x40 >> 8); |
| 488 |
let x43: u8 = ((x42 & (0xff as u64)) as u8); |
| 489 |
let x44: u64 = (x42 >> 8); |
| 490 |
let x45: u8 = ((x44 & (0xff as u64)) as u8); |
| 491 |
let x46: u64 = (x44 >> 8); |
| 492 |
let x47: u8 = ((x46 & (0xff as u64)) as u8); |
| 493 |
let x48: u64 = (x46 >> 8); |
| 494 |
let x49: u8 = ((x48 & (0xff as u64)) as u8); |
| 495 |
let x50: u8 = ((x48 >> 8) as u8); |
| 496 |
let x51: u64 = (x24 + (x50 as u64)); |
| 497 |
let x52: u8 = ((x51 & (0xff as u64)) as u8); |
| 498 |
let x53: u64 = (x51 >> 8); |
| 499 |
let x54: u8 = ((x53 & (0xff as u64)) as u8); |
| 500 |
let x55: u64 = (x53 >> 8); |
| 501 |
let x56: u8 = ((x55 & (0xff as u64)) as u8); |
| 502 |
let x57: u64 = (x55 >> 8); |
| 503 |
let x58: u8 = ((x57 & (0xff as u64)) as u8); |
| 504 |
let x59: u64 = (x57 >> 8); |
| 505 |
let x60: u8 = ((x59 & (0xff as u64)) as u8); |
| 506 |
let x61: u64 = (x59 >> 8); |
| 507 |
let x62: u8 = ((x61 & (0xff as u64)) as u8); |
| 508 |
let x63: u64 = (x61 >> 8); |
| 509 |
let x64: u8 = ((x63 & (0xff as u64)) as u8); |
| 510 |
let x65: fiat_25519_u1 = ((x63 >> 8) as fiat_25519_u1); |
| 511 |
let x66: u64 = (x23 + (x65 as u64)); |
| 512 |
let x67: u8 = ((x66 & (0xff as u64)) as u8); |
| 513 |
let x68: u64 = (x66 >> 8); |
| 514 |
let x69: u8 = ((x68 & (0xff as u64)) as u8); |
| 515 |
let x70: u64 = (x68 >> 8); |
| 516 |
let x71: u8 = ((x70 & (0xff as u64)) as u8); |
| 517 |
let x72: u64 = (x70 >> 8); |
| 518 |
let x73: u8 = ((x72 & (0xff as u64)) as u8); |
| 519 |
let x74: u64 = (x72 >> 8); |
| 520 |
let x75: u8 = ((x74 & (0xff as u64)) as u8); |
| 521 |
let x76: u64 = (x74 >> 8); |
| 522 |
let x77: u8 = ((x76 & (0xff as u64)) as u8); |
| 523 |
let x78: u8 = ((x76 >> 8) as u8); |
| 524 |
let x79: u64 = (x22 + (x78 as u64)); |
| 525 |
let x80: u8 = ((x79 & (0xff as u64)) as u8); |
| 526 |
let x81: u64 = (x79 >> 8); |
| 527 |
let x82: u8 = ((x81 & (0xff as u64)) as u8); |
| 528 |
let x83: u64 = (x81 >> 8); |
| 529 |
let x84: u8 = ((x83 & (0xff as u64)) as u8); |
| 530 |
let x85: u64 = (x83 >> 8); |
| 531 |
let x86: u8 = ((x85 & (0xff as u64)) as u8); |
| 532 |
let x87: u64 = (x85 >> 8); |
| 533 |
let x88: u8 = ((x87 & (0xff as u64)) as u8); |
| 534 |
let x89: u64 = (x87 >> 8); |
| 535 |
let x90: u8 = ((x89 & (0xff as u64)) as u8); |
| 536 |
let x91: u8 = ((x89 >> 8) as u8); |
| 537 |
*IndexConst(&mut out1).index_mut(0) = x26; |
| 538 |
*IndexConst(&mut out1).index_mut(1) = x28; |
| 539 |
*IndexConst(&mut out1).index_mut(2) = x30; |
| 540 |
*IndexConst(&mut out1).index_mut(3) = x32; |
| 541 |
*IndexConst(&mut out1).index_mut(4) = x34; |
| 542 |
*IndexConst(&mut out1).index_mut(5) = x36; |
| 543 |
*IndexConst(&mut out1).index_mut(6) = x39; |
| 544 |
*IndexConst(&mut out1).index_mut(7) = x41; |
| 545 |
*IndexConst(&mut out1).index_mut(8) = x43; |
| 546 |
*IndexConst(&mut out1).index_mut(9) = x45; |
| 547 |
*IndexConst(&mut out1).index_mut(10) = x47; |
| 548 |
*IndexConst(&mut out1).index_mut(11) = x49; |
| 549 |
*IndexConst(&mut out1).index_mut(12) = x52; |
| 550 |
*IndexConst(&mut out1).index_mut(13) = x54; |
| 551 |
*IndexConst(&mut out1).index_mut(14) = x56; |
| 552 |
*IndexConst(&mut out1).index_mut(15) = x58; |
| 553 |
*IndexConst(&mut out1).index_mut(16) = x60; |
| 554 |
*IndexConst(&mut out1).index_mut(17) = x62; |
| 555 |
*IndexConst(&mut out1).index_mut(18) = x64; |
| 556 |
*IndexConst(&mut out1).index_mut(19) = x67; |
| 557 |
*IndexConst(&mut out1).index_mut(20) = x69; |
| 558 |
*IndexConst(&mut out1).index_mut(21) = x71; |
| 559 |
*IndexConst(&mut out1).index_mut(22) = x73; |
| 560 |
*IndexConst(&mut out1).index_mut(23) = x75; |
| 561 |
*IndexConst(&mut out1).index_mut(24) = x77; |
| 562 |
*IndexConst(&mut out1).index_mut(25) = x80; |
| 563 |
*IndexConst(&mut out1).index_mut(26) = x82; |
| 564 |
*IndexConst(&mut out1).index_mut(27) = x84; |
| 565 |
*IndexConst(&mut out1).index_mut(28) = x86; |
| 566 |
*IndexConst(&mut out1).index_mut(29) = x88; |
| 567 |
*IndexConst(&mut out1).index_mut(30) = x90; |
| 568 |
*IndexConst(&mut out1).index_mut(31) = x91; |
| 569 |
} |
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
#[inline] |
| 579 |
pub const fn fiat_25519_from_bytes(mut out1: &mut fiat_25519_tight_field_element, arg1: &[u8; 32]) { |
| 580 |
let x1: u64 = (((*IndexConst(arg1).index(31)) as u64) << 44); |
| 581 |
let x2: u64 = (((*IndexConst(arg1).index(30)) as u64) << 36); |
| 582 |
let x3: u64 = (((*IndexConst(arg1).index(29)) as u64) << 28); |
| 583 |
let x4: u64 = (((*IndexConst(arg1).index(28)) as u64) << 20); |
| 584 |
let x5: u64 = (((*IndexConst(arg1).index(27)) as u64) << 12); |
| 585 |
let x6: u64 = (((*IndexConst(arg1).index(26)) as u64) << 4); |
| 586 |
let x7: u64 = (((*IndexConst(arg1).index(25)) as u64) << 47); |
| 587 |
let x8: u64 = (((*IndexConst(arg1).index(24)) as u64) << 39); |
| 588 |
let x9: u64 = (((*IndexConst(arg1).index(23)) as u64) << 31); |
| 589 |
let x10: u64 = (((*IndexConst(arg1).index(22)) as u64) << 23); |
| 590 |
let x11: u64 = (((*IndexConst(arg1).index(21)) as u64) << 15); |
| 591 |
let x12: u64 = (((*IndexConst(arg1).index(20)) as u64) << 7); |
| 592 |
let x13: u64 = (((*IndexConst(arg1).index(19)) as u64) << 50); |
| 593 |
let x14: u64 = (((*IndexConst(arg1).index(18)) as u64) << 42); |
| 594 |
let x15: u64 = (((*IndexConst(arg1).index(17)) as u64) << 34); |
| 595 |
let x16: u64 = (((*IndexConst(arg1).index(16)) as u64) << 26); |
| 596 |
let x17: u64 = (((*IndexConst(arg1).index(15)) as u64) << 18); |
| 597 |
let x18: u64 = (((*IndexConst(arg1).index(14)) as u64) << 10); |
| 598 |
let x19: u64 = (((*IndexConst(arg1).index(13)) as u64) << 2); |
| 599 |
let x20: u64 = (((*IndexConst(arg1).index(12)) as u64) << 45); |
| 600 |
let x21: u64 = (((*IndexConst(arg1).index(11)) as u64) << 37); |
| 601 |
let x22: u64 = (((*IndexConst(arg1).index(10)) as u64) << 29); |
| 602 |
let x23: u64 = (((*IndexConst(arg1).index(9)) as u64) << 21); |
| 603 |
let x24: u64 = (((*IndexConst(arg1).index(8)) as u64) << 13); |
| 604 |
let x25: u64 = (((*IndexConst(arg1).index(7)) as u64) << 5); |
| 605 |
let x26: u64 = (((*IndexConst(arg1).index(6)) as u64) << 48); |
| 606 |
let x27: u64 = (((*IndexConst(arg1).index(5)) as u64) << 40); |
| 607 |
let x28: u64 = (((*IndexConst(arg1).index(4)) as u64) << 32); |
| 608 |
let x29: u64 = (((*IndexConst(arg1).index(3)) as u64) << 24); |
| 609 |
let x30: u64 = (((*IndexConst(arg1).index(2)) as u64) << 16); |
| 610 |
let x31: u64 = (((*IndexConst(arg1).index(1)) as u64) << 8); |
| 611 |
let x32: u8 = (*IndexConst(arg1).index(0)); |
| 612 |
let x33: u64 = (x31 + (x32 as u64)); |
| 613 |
let x34: u64 = (x30 + x33); |
| 614 |
let x35: u64 = (x29 + x34); |
| 615 |
let x36: u64 = (x28 + x35); |
| 616 |
let x37: u64 = (x27 + x36); |
| 617 |
let x38: u64 = (x26 + x37); |
| 618 |
let x39: u64 = (x38 & 0x7ffffffffffff); |
| 619 |
let x40: u8 = ((x38 >> 51) as u8); |
| 620 |
let x41: u64 = (x25 + (x40 as u64)); |
| 621 |
let x42: u64 = (x24 + x41); |
| 622 |
let x43: u64 = (x23 + x42); |
| 623 |
let x44: u64 = (x22 + x43); |
| 624 |
let x45: u64 = (x21 + x44); |
| 625 |
let x46: u64 = (x20 + x45); |
| 626 |
let x47: u64 = (x46 & 0x7ffffffffffff); |
| 627 |
let x48: u8 = ((x46 >> 51) as u8); |
| 628 |
let x49: u64 = (x19 + (x48 as u64)); |
| 629 |
let x50: u64 = (x18 + x49); |
| 630 |
let x51: u64 = (x17 + x50); |
| 631 |
let x52: u64 = (x16 + x51); |
| 632 |
let x53: u64 = (x15 + x52); |
| 633 |
let x54: u64 = (x14 + x53); |
| 634 |
let x55: u64 = (x13 + x54); |
| 635 |
let x56: u64 = (x55 & 0x7ffffffffffff); |
| 636 |
let x57: u8 = ((x55 >> 51) as u8); |
| 637 |
let x58: u64 = (x12 + (x57 as u64)); |
| 638 |
let x59: u64 = (x11 + x58); |
| 639 |
let x60: u64 = (x10 + x59); |
| 640 |
let x61: u64 = (x9 + x60); |
| 641 |
let x62: u64 = (x8 + x61); |
| 642 |
let x63: u64 = (x7 + x62); |
| 643 |
let x64: u64 = (x63 & 0x7ffffffffffff); |
| 644 |
let x65: u8 = ((x63 >> 51) as u8); |
| 645 |
let x66: u64 = (x6 + (x65 as u64)); |
| 646 |
let x67: u64 = (x5 + x66); |
| 647 |
let x68: u64 = (x4 + x67); |
| 648 |
let x69: u64 = (x3 + x68); |
| 649 |
let x70: u64 = (x2 + x69); |
| 650 |
let x71: u64 = (x1 + x70); |
| 651 |
*IndexConst(&mut out1).index_mut(0) = x39; |
| 652 |
*IndexConst(&mut out1).index_mut(1) = x47; |
| 653 |
*IndexConst(&mut out1).index_mut(2) = x56; |
| 654 |
*IndexConst(&mut out1).index_mut(3) = x64; |
| 655 |
*IndexConst(&mut out1).index_mut(4) = x71; |
| 656 |
} |
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
#[inline] |
| 664 |
pub const fn fiat_25519_relax(mut out1: &mut fiat_25519_loose_field_element, arg1: &fiat_25519_tight_field_element) { |
| 665 |
let x1: u64 = (*IndexConst(arg1).index(0)); |
| 666 |
let x2: u64 = (*IndexConst(arg1).index(1)); |
| 667 |
let x3: u64 = (*IndexConst(arg1).index(2)); |
| 668 |
let x4: u64 = (*IndexConst(arg1).index(3)); |
| 669 |
let x5: u64 = (*IndexConst(arg1).index(4)); |
| 670 |
*IndexConst(&mut out1).index_mut(0) = x1; |
| 671 |
*IndexConst(&mut out1).index_mut(1) = x2; |
| 672 |
*IndexConst(&mut out1).index_mut(2) = x3; |
| 673 |
*IndexConst(&mut out1).index_mut(3) = x4; |
| 674 |
*IndexConst(&mut out1).index_mut(4) = x5; |
| 675 |
} |
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
#[inline] |
| 683 |
pub const fn fiat_25519_carry_scmul_121666(mut out1: &mut fiat_25519_tight_field_element, arg1: &fiat_25519_loose_field_element) { |
| 684 |
let x1: u128 = ((0x1db42 as u128) * ((*IndexConst(arg1).index(4)) as u128)); |
| 685 |
let x2: u128 = ((0x1db42 as u128) * ((*IndexConst(arg1).index(3)) as u128)); |
| 686 |
let x3: u128 = ((0x1db42 as u128) * ((*IndexConst(arg1).index(2)) as u128)); |
| 687 |
let x4: u128 = ((0x1db42 as u128) * ((*IndexConst(arg1).index(1)) as u128)); |
| 688 |
let x5: u128 = ((0x1db42 as u128) * ((*IndexConst(arg1).index(0)) as u128)); |
| 689 |
let x6: u64 = ((x5 >> 51) as u64); |
| 690 |
let x7: u64 = ((x5 & (0x7ffffffffffff as u128)) as u64); |
| 691 |
let x8: u128 = ((x6 as u128) + x4); |
| 692 |
let x9: u64 = ((x8 >> 51) as u64); |
| 693 |
let x10: u64 = ((x8 & (0x7ffffffffffff as u128)) as u64); |
| 694 |
let x11: u128 = ((x9 as u128) + x3); |
| 695 |
let x12: u64 = ((x11 >> 51) as u64); |
| 696 |
let x13: u64 = ((x11 & (0x7ffffffffffff as u128)) as u64); |
| 697 |
let x14: u128 = ((x12 as u128) + x2); |
| 698 |
let x15: u64 = ((x14 >> 51) as u64); |
| 699 |
let x16: u64 = ((x14 & (0x7ffffffffffff as u128)) as u64); |
| 700 |
let x17: u128 = ((x15 as u128) + x1); |
| 701 |
let x18: u64 = ((x17 >> 51) as u64); |
| 702 |
let x19: u64 = ((x17 & (0x7ffffffffffff as u128)) as u64); |
| 703 |
let x20: u64 = (x18 * 0x13); |
| 704 |
let x21: u64 = (x7 + x20); |
| 705 |
let x22: fiat_25519_u1 = ((x21 >> 51) as fiat_25519_u1); |
| 706 |
let x23: u64 = (x21 & 0x7ffffffffffff); |
| 707 |
let x24: u64 = ((x22 as u64) + x10); |
| 708 |
let x25: fiat_25519_u1 = ((x24 >> 51) as fiat_25519_u1); |
| 709 |
let x26: u64 = (x24 & 0x7ffffffffffff); |
| 710 |
let x27: u64 = ((x25 as u64) + x13); |
| 711 |
*IndexConst(&mut out1).index_mut(0) = x23; |
| 712 |
*IndexConst(&mut out1).index_mut(1) = x26; |
| 713 |
*IndexConst(&mut out1).index_mut(2) = x27; |
| 714 |
*IndexConst(&mut out1).index_mut(3) = x16; |
| 715 |
*IndexConst(&mut out1).index_mut(4) = x19; |
| 716 |
} |