|
| 1 | +use crypto_bigint::{Limb, Reciprocal, Word}; |
| 2 | + |
1 | 3 | /// The type that fits any small prime from the table. |
2 | 4 | pub(crate) type SmallPrime = u16; |
3 | 5 |
|
| 6 | +const SMALL_PRIMES_SIZE: usize = 2047; |
| 7 | + |
4 | 8 | /// The list of 2nd to 2048th primes (The 1st one, 2, is not included). |
5 | | -pub(crate) const SMALL_PRIMES: [SmallPrime; 2047] = [ |
| 9 | +pub(crate) const SMALL_PRIMES: [SmallPrime; SMALL_PRIMES_SIZE] = [ |
6 | 10 | 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, |
7 | 11 | 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, |
8 | 12 | 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, |
@@ -142,3 +146,15 @@ pub(crate) const SMALL_PRIMES: [SmallPrime; 2047] = [ |
142 | 146 | 17599, 17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683, 17707, 17713, 17729, 17737, |
143 | 147 | 17747, 17749, 17761, 17783, 17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863, |
144 | 148 | ]; |
| 149 | + |
| 150 | +const fn create_reciprocals() -> [Reciprocal; SMALL_PRIMES_SIZE] { |
| 151 | + let mut arr = [Reciprocal::default(); SMALL_PRIMES_SIZE]; |
| 152 | + let mut i = 0; |
| 153 | + while i < SMALL_PRIMES_SIZE { |
| 154 | + arr[i] = Reciprocal::ct_new(Limb(SMALL_PRIMES[i] as Word)).0; |
| 155 | + i += 1; |
| 156 | + } |
| 157 | + arr |
| 158 | +} |
| 159 | + |
| 160 | +pub(crate) const RECIPROCALS: [Reciprocal; SMALL_PRIMES_SIZE] = create_reciprocals(); |
0 commit comments