arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/ed_on_bn254/src/fields/fr.rs
ed_on_bn254/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 = 4;
15
16    #[rustfmt::skip]
17    const TWO_ADIC_ROOT_OF_UNITY: BigInteger = BigInt::new([
18        0x1721ada8d4d27255,
19        0xcda0f5264e0e35bb,
20        0x961a936922086fe6,
21        0x1ab00857387dd52,
22    ]);
23}
24impl FpParameters for FrParameters {
25    /// MODULUS = 2736030358979909402780800718157159386076813972158567259200215660948447373041
26    #[rustfmt::skip]
27    const MODULUS: BigInteger = BigInt::new([
28        0x677297dc392126f1,
29        0xab3eedb83920ee0a,
30        0x370a08b6d0302b0b,
31        0x60c89ce5c263405,
32    ]);
33
34    const MODULUS_BITS: u32 = 251;
35
36    const CAPACITY: u32 = Self::MODULUS_BITS - 1;
37
38    const REPR_SHAVE_BITS: u32 = 5;
39
40    #[rustfmt::skip]
41    const R: BigInteger = BigInt::new([
42        0x073315dea08f9c76,
43        0xe7acffc6a098f24b,
44        0xf85a9201d818f015,
45        0x1f16424e1bb7724,
46    ]);
47
48    #[rustfmt::skip]
49    const R2: BigInteger = BigInt::new([
50        0x35e44abee7ecb21e,
51        0x74646cacf5f84ec4,
52        0xe472df203faa158f,
53        0x445b524f1ba50a8,
54    ]);
55
56    const INV: u64 = 0x532ce5aebc48f5ef;
57
58    #[rustfmt::skip]
59    /// GENERATOR = 31
60    const GENERATOR: BigInteger = BigInt::new([
61        0x3c284f376f3993d1,
62        0x08bc9d93705cf8b8,
63        0x239d5fcbd9538f3e,
64        0x5ca4836185b994b,
65    ]);
66
67    const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInt::new([
68        0x33b94bee1c909378,
69        0xd59f76dc1c907705,
70        0x9b85045b68181585,
71        0x30644e72e131a02,
72    ]);
73
74    const T: BigInteger = BigInt::new([
75        0xa677297dc392126f,
76        0xbab3eedb83920ee0,
77        0x5370a08b6d0302b0,
78        0x60c89ce5c26340,
79    ]);
80
81    const T_MINUS_ONE_DIV_TWO: BigInteger = BigInt::new([
82        0x533b94bee1c90937,
83        0x5d59f76dc1c90770,
84        0x29b85045b6818158,
85        0x30644e72e131a0,
86    ]);
87}