arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/bls12_377/src/fields/fr.rs
bls12_377/src/fields/fr.rsRaw
 1use ark_ff::{biginteger::BigInteger256 as BigInteger, fields::*};
 2
 3pub type Fr = Fp256<FrParameters>;
 4
 5pub struct FrParameters;
 6
 7impl Fp256Parameters for FrParameters {}
 8impl FftParameters for FrParameters {
 9    type BigInt = BigInteger;
10
11    const TWO_ADICITY: u32 = 47;
12
13    #[rustfmt::skip]
14    const TWO_ADIC_ROOT_OF_UNITY: BigInteger = BigInteger([
15        0x3c3d3ca739381fb2,
16        0x9a14cda3ec99772b,
17        0xd7aacc7c59724826,
18        0xd1ba211c5cc349c,
19    ]);
20}
21impl FpParameters for FrParameters {
22    /// MODULUS = 8444461749428370424248824938781546531375899335154063827935233455917409239041
23    #[rustfmt::skip]
24    const MODULUS: BigInteger = BigInteger([
25        725501752471715841u64,
26        6461107452199829505u64,
27        6968279316240510977u64,
28        1345280370688173398u64,
29    ]);
30
31    const MODULUS_BITS: u32 = 253;
32
33    const CAPACITY: u32 = Self::MODULUS_BITS - 1;
34
35    const REPR_SHAVE_BITS: u32 = 3;
36
37    /// R = 6014086494747379908336260804527802945383293308637734276299549080986809532403
38    #[rustfmt::skip]
39    const R: BigInteger = BigInteger([
40        9015221291577245683u64,
41        8239323489949974514u64,
42        1646089257421115374u64,
43        958099254763297437u64,
44    ]);
45
46    #[rustfmt::skip]
47    const R2: BigInteger = BigInteger([
48        2726216793283724667u64,
49        14712177743343147295u64,
50        12091039717619697043u64,
51        81024008013859129u64,
52    ]);
53
54    const INV: u64 = 725501752471715839u64;
55
56    /// GENERATOR = 11
57    /// Encoded in Montgomery form, so the value is
58    /// (11 * R) % q = 7043719196222586021957094278335006679584931048936630243748405699433040183146
59    #[rustfmt::skip]
60    const GENERATOR: BigInteger = BigInteger([
61        1855201571499933546u64,
62        8511318076631809892u64,
63        6222514765367795509u64,
64        1122129207579058019u64,
65    ]);
66
67    /// (r - 1)/2 =
68    /// 4222230874714185212124412469390773265687949667577031913967616727958704619520
69    #[rustfmt::skip]
70    const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
71        0x8508c00000000000,
72        0xacd53b7f68000000,
73        0x305a268f2e1bd800,
74        0x955b2af4d1652ab,
75    ]);
76
77    // T and T_MINUS_ONE_DIV_TWO, where r - 1 = 2^s * t
78    // For T coprime to 2
79
80    /// t = (r - 1) / 2^s =
81    /// 60001509534603559531609739528203892656505753216962260608619555
82    #[rustfmt::skip]
83    const T: BigInteger = BigInteger([
84        0xedfda00000021423,
85        0x9a3cb86f6002b354,
86        0xcabd34594aacc168,
87        0x2556,
88    ]);
89
90    /// (t - 1) / 2 =
91    /// 30000754767301779765804869764101946328252876608481130304309777
92    #[rustfmt::skip]
93    const T_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
94        0x76fed00000010a11,
95        0x4d1e5c37b00159aa,
96        0x655e9a2ca55660b4,
97        0x12ab,
98    ]);
99}