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 #[rustfmt::skip]
38 const R: BigInteger = BigInteger([
39 9015221291577245683u64,
40 8239323489949974514u64,
41 1646089257421115374u64,
42 958099254763297437u64,
43 ]);
44
45 #[rustfmt::skip]
46 const R2: BigInteger = BigInteger([
47 2726216793283724667u64,
48 14712177743343147295u64,
49 12091039717619697043u64,
50 81024008013859129u64,
51 ]);
52
53 const INV: u64 = 725501752471715839u64;
54
55 // GENERATOR = 11
56 #[rustfmt::skip]
57 const GENERATOR: BigInteger = BigInteger([
58 1855201571499933546u64,
59 8511318076631809892u64,
60 6222514765367795509u64,
61 1122129207579058019u64,
62 ]);
63
64 /// (r - 1)/2 =
65 /// 4222230874714185212124412469390773265687949667577031913967616727958704619520
66 #[rustfmt::skip]
67 const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
68 0x8508c00000000000,
69 0xacd53b7f68000000,
70 0x305a268f2e1bd800,
71 0x955b2af4d1652ab,
72 ]);
73
74 // T and T_MINUS_ONE_DIV_TWO, where r - 1 = 2^s * t
75
76 /// t = (r - 1) / 2^s =
77 /// 60001509534603559531609739528203892656505753216962260608619555
78 #[rustfmt::skip]
79 const T: BigInteger = BigInteger([
80 0xedfda00000021423,
81 0x9a3cb86f6002b354,
82 0xcabd34594aacc168,
83 0x2556,
84 ]);
85
86 /// (t - 1) / 2 =
87 /// 30000754767301779765804869764101946328252876608481130304309777
88 #[rustfmt::skip]
89 const T_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
90 0x76fed00000010a11,
91 0x4d1e5c37b00159aa,
92 0x655e9a2ca55660b4,
93 0x12ab,
94 ]);
95}