Debian Codegraph @

fiat-rust/src/secp256k1_dettman_64.rs

raw symbols SCIP
1 //! Autogenerated: 'src/ExtractionOCaml/dettman_multiplication' --lang Rust --inline secp256k1_dettman 64 5 48 2 '2^256 - 4294968273' mul square
2 //! curve description: secp256k1_dettman
3 //! machine_wordsize = 64 (from "64")
4 //! requested operations: mul, square
5 //! n = 5 (from "5")
6 //! last_limb_width = 48 (from "48")
7 //! last_reduction = 2 (from "2")
8 //! s-c = 2^256 - [(1, 4294968273)] (from "2^256 - 4294968273")
9 //! inbounds_multiplier: None (from "")
10 //!
11 //! Computed values:
12 //!
13 //!
14
15 #![allow(unused_parens)]
16 #![allow(non_camel_case_types)]
17
18 /// Since `Index` and `IndexMut` aren't callable in `const` contexts yet, this helper type helps unify
19 /// arrays and user-defined array-wrapper types into a single type which can be indexed in `const`
20 /// contexts. Once `const trait`s are stabilized this type can go away
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
40 /// The function fiat_secp256k1_dettman_mul multiplies two field elements.
41 ///
42 /// Postconditions:
43 /// eval out1 mod 115792089237316195423570985008687907853269984665640564039457584007908834671663 = (eval arg1 * eval arg2) mod 115792089237316195423570985008687907853269984665640564039457584007908834671663
44 ///
45 /// Input Bounds:
46 /// arg1: [[0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1fffffffffffe]]
47 /// arg2: [[0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1fffffffffffe]]
48 /// Output Bounds:
49 /// out1: [[0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x17fffffffffff]]
50 #[inline]
51 pub const fn fiat_secp256k1_dettman_mul(mut out1: &mut [u64; 5], arg1: &[u64; 5], arg2: &[u64; 5]) {
52 let x1: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(4)) as u128));
53 let x2: u64 = ((x1 >> 64) as u64);
54 let x3: u64 = ((x1 & (0xffffffffffffffff as u128)) as u64);
55 let x4: u128 = (((((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(3)) as u128)) + ((((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(2)) as u128)) + ((((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(1)) as u128)) + (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(0)) as u128))))) + ((x3 as u128) * (0x1000003d10 as u128)));
56 let x5: u64 = ((x4 >> 52) as u64);
57 let x6: u64 = ((x4 & (0xfffffffffffff as u128)) as u64);
58 let x7: u128 = (((x5 as u128) + ((((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(4)) as u128)) + ((((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(3)) as u128)) + ((((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(2)) as u128)) + ((((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(1)) as u128)) + (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(0)) as u128))))))) + ((x2 as u128) * (0x1000003d10000 as u128)));
59 let x8: u64 = ((x7 >> 52) as u64);
60 let x9: u64 = ((x7 & (0xfffffffffffff as u128)) as u64);
61 let x10: u128 = ((x8 as u128) + ((((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(4)) as u128)) + ((((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(3)) as u128)) + ((((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(2)) as u128)) + (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(1)) as u128))))));
62 let x11: u64 = ((x10 >> 52) as u64);
63 let x12: u64 = ((x10 & (0xfffffffffffff as u128)) as u64);
64 let x13: u64 = (x9 >> 48);
65 let x14: u64 = (x9 & 0xffffffffffff);
66 let x15: u128 = ((((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(0)) as u128)) + (((x13 + (x12 << 4)) as u128) * (0x1000003d1 as u128)));
67 let x16: u64 = ((x15 >> 52) as u64);
68 let x17: u64 = ((x15 & (0xfffffffffffff as u128)) as u64);
69 let x18: u128 = ((x11 as u128) + ((((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(4)) as u128)) + ((((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(3)) as u128)) + (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(2)) as u128)))));
70 let x19: u64 = ((x18 >> 52) as u64);
71 let x20: u64 = ((x18 & (0xfffffffffffff as u128)) as u64);
72 let x21: u128 = (((x16 as u128) + ((((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(1)) as u128)) + (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(0)) as u128)))) + ((x20 as u128) * (0x1000003d10 as u128)));
73 let x22: u64 = ((x21 >> 52) as u64);
74 let x23: u64 = ((x21 & (0xfffffffffffff as u128)) as u64);
75 let x24: u128 = ((x19 as u128) + ((((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg2).index(4)) as u128)) + (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg2).index(3)) as u128))));
76 let x25: u64 = ((x24 >> 64) as u64);
77 let x26: u64 = ((x24 & (0xffffffffffffffff as u128)) as u64);
78 let x27: u128 = (((x22 as u128) + ((((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg2).index(2)) as u128)) + ((((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg2).index(1)) as u128)) + (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg2).index(0)) as u128))))) + ((x26 as u128) * (0x1000003d10 as u128)));
79 let x28: u64 = ((x27 >> 52) as u64);
80 let x29: u64 = ((x27 & (0xfffffffffffff as u128)) as u64);
81 let x30: u128 = (((x28 + x6) as u128) + ((x25 as u128) * (0x1000003d10000 as u128)));
82 let x31: u64 = ((x30 >> 52) as u64);
83 let x32: u64 = ((x30 & (0xfffffffffffff as u128)) as u64);
84 let x33: u64 = (x31 + x14);
85 *IndexConst(&mut out1).index_mut(0) = x17;
86 *IndexConst(&mut out1).index_mut(1) = x23;
87 *IndexConst(&mut out1).index_mut(2) = x29;
88 *IndexConst(&mut out1).index_mut(3) = x32;
89 *IndexConst(&mut out1).index_mut(4) = x33;
90 }
91
92 /// The function fiat_secp256k1_dettman_square squares a field element.
93 ///
94 /// Postconditions:
95 /// eval out1 mod 115792089237316195423570985008687907853269984665640564039457584007908834671663 = (eval arg1 * eval arg1) mod 115792089237316195423570985008687907853269984665640564039457584007908834671663
96 ///
97 /// Input Bounds:
98 /// arg1: [[0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1fffffffffffe]]
99 /// Output Bounds:
100 /// out1: [[0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x1ffffffffffffe], [0x0 ~> 0x17fffffffffff]]
101 #[inline]
102 pub const fn fiat_secp256k1_dettman_square(mut out1: &mut [u64; 5], arg1: &[u64; 5]) {
103 let x1: u64 = ((*IndexConst(arg1).index(3)) * 0x2);
104 let x2: u64 = ((*IndexConst(arg1).index(2)) * 0x2);
105 let x3: u64 = ((*IndexConst(arg1).index(1)) * 0x2);
106 let x4: u64 = ((*IndexConst(arg1).index(0)) * 0x2);
107 let x5: u128 = (((*IndexConst(arg1).index(4)) as u128) * ((*IndexConst(arg1).index(4)) as u128));
108 let x6: u64 = ((x5 >> 64) as u64);
109 let x7: u64 = ((x5 & (0xffffffffffffffff as u128)) as u64);
110 let x8: u128 = ((((x4 as u128) * ((*IndexConst(arg1).index(3)) as u128)) + ((x3 as u128) * ((*IndexConst(arg1).index(2)) as u128))) + ((x7 as u128) * (0x1000003d10 as u128)));
111 let x9: u64 = ((x8 >> 52) as u64);
112 let x10: u64 = ((x8 & (0xfffffffffffff as u128)) as u64);
113 let x11: u128 = (((x9 as u128) + (((x4 as u128) * ((*IndexConst(arg1).index(4)) as u128)) + (((x3 as u128) * ((*IndexConst(arg1).index(3)) as u128)) + (((*IndexConst(arg1).index(2)) as u128) * ((*IndexConst(arg1).index(2)) as u128))))) + ((x6 as u128) * (0x1000003d10000 as u128)));
114 let x12: u64 = ((x11 >> 52) as u64);
115 let x13: u64 = ((x11 & (0xfffffffffffff as u128)) as u64);
116 let x14: u128 = ((x12 as u128) + (((x3 as u128) * ((*IndexConst(arg1).index(4)) as u128)) + ((x2 as u128) * ((*IndexConst(arg1).index(3)) as u128))));
117 let x15: u64 = ((x14 >> 52) as u64);
118 let x16: u64 = ((x14 & (0xfffffffffffff as u128)) as u64);
119 let x17: u64 = (x13 >> 48);
120 let x18: u64 = (x13 & 0xffffffffffff);
121 let x19: u128 = ((((*IndexConst(arg1).index(0)) as u128) * ((*IndexConst(arg1).index(0)) as u128)) + (((x17 + (x16 << 4)) as u128) * (0x1000003d1 as u128)));
122 let x20: u64 = ((x19 >> 52) as u64);
123 let x21: u64 = ((x19 & (0xfffffffffffff as u128)) as u64);
124 let x22: u128 = ((x15 as u128) + (((x2 as u128) * ((*IndexConst(arg1).index(4)) as u128)) + (((*IndexConst(arg1).index(3)) as u128) * ((*IndexConst(arg1).index(3)) as u128))));
125 let x23: u64 = ((x22 >> 52) as u64);
126 let x24: u64 = ((x22 & (0xfffffffffffff as u128)) as u64);
127 let x25: u128 = (((x20 as u128) + ((x4 as u128) * ((*IndexConst(arg1).index(1)) as u128))) + ((x24 as u128) * (0x1000003d10 as u128)));
128 let x26: u64 = ((x25 >> 52) as u64);
129 let x27: u64 = ((x25 & (0xfffffffffffff as u128)) as u64);
130 let x28: u128 = ((x23 as u128) + ((x1 as u128) * ((*IndexConst(arg1).index(4)) as u128)));
131 let x29: u64 = ((x28 >> 64) as u64);
132 let x30: u64 = ((x28 & (0xffffffffffffffff as u128)) as u64);
133 let x31: u128 = (((x26 as u128) + (((x4 as u128) * ((*IndexConst(arg1).index(2)) as u128)) + (((*IndexConst(arg1).index(1)) as u128) * ((*IndexConst(arg1).index(1)) as u128)))) + ((x30 as u128) * (0x1000003d10 as u128)));
134 let x32: u64 = ((x31 >> 52) as u64);
135 let x33: u64 = ((x31 & (0xfffffffffffff as u128)) as u64);
136 let x34: u128 = (((x32 + x10) as u128) + ((x29 as u128) * (0x1000003d10000 as u128)));
137 let x35: u64 = ((x34 >> 52) as u64);
138 let x36: u64 = ((x34 & (0xfffffffffffff as u128)) as u64);
139 let x37: u64 = (x35 + x18);
140 *IndexConst(&mut out1).index_mut(0) = x21;
141 *IndexConst(&mut out1).index_mut(1) = x27;
142 *IndexConst(&mut out1).index_mut(2) = x33;
143 *IndexConst(&mut out1).index_mut(3) = x36;
144 *IndexConst(&mut out1).index_mut(4) = x37;
145 }