ark-curves-cherry-picked/ed_on_bls12_381/src/fields/fr.rs
ed_on_bls12_381/src/fields/fr.rsRaw
1use ark_ff::{
2 biginteger::{BigInt, BigInteger256 as BigInteger},
3 fields::{FftParameters, Fp256, Fp256Parameters, FpParameters},
4};
5
6pub type Fr = Fp256<FrParameters>;
7
8pub struct FrParameters;
9
10impl Fp256Parameters for FrParameters {}
11impl FftParameters for FrParameters {
12 type BigInt = BigInteger;
13
14 const TWO_ADICITY: u32 = 1;
15
16 #[rustfmt::skip]
17 const TWO_ADIC_ROOT_OF_UNITY: BigInteger = BigInt::new([
18 0xaa9f02ab1d6124de,
19 0xb3524a6466112932,
20 0x7342261215ac260b,
21 0x4d6b87b1da259e2,
22 ]);
23}
24impl FpParameters for FrParameters {
25 /// MODULUS = 6554484396890773809930967563523245729705921265872317281365359162392183254199.
26 #[rustfmt::skip]
27 const MODULUS: BigInteger = BigInt::new([
28 0xd0970e5ed6f72cb7,
29 0xa6682093ccc81082,
30 0x6673b0101343b00,
31 0xe7db4ea6533afa9,
32 ]);
33
34 const MODULUS_BITS: u32 = 252;
35
36 const CAPACITY: u32 = Self::MODULUS_BITS - 1;
37
38 const REPR_SHAVE_BITS: u32 = 4;
39
40 #[rustfmt::skip]
41 const R: BigInteger = BigInt::new([
42 0x25f80bb3b99607d9,
43 0xf315d62f66b6e750,
44 0x932514eeeb8814f4,
45 0x9a6fc6f479155c6,
46 ]);
47
48 #[rustfmt::skip]
49 const R2: BigInteger = BigInt::new([
50 0x67719aa495e57731,
51 0x51b0cef09ce3fc26,
52 0x69dab7fac026e9a5,
53 0x4f6547b8d127688,
54 ]);
55
56 const INV: u64 = 0x1ba3a358ef788ef9;
57
58 #[rustfmt::skip]
59 const GENERATOR: BigInteger = BigInt::new([
60 0x720b1b19d49ea8f1,
61 0xbf4aa36101f13a58,
62 0x5fa8cc968193ccbb,
63 0xe70cbdc7dccf3ac,
64 ]);
65
66 const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInt::new([
67 7515249040934278747,
68 5995434913520945217,
69 9454073218019761536,
70 522094803716528084,
71 ]);
72
73 const T: BigInteger = Self::MODULUS_MINUS_ONE_DIV_TWO;
74
75 const T_MINUS_ONE_DIV_TWO: BigInteger = BigInt::new([
76 12980996557321915181,
77 2997717456760472608,
78 4727036609009880768,
79 261047401858264042,
80 ]);
81}