ark-curves-cherry-picked/mnt4_753/src/fields/fq.rs
mnt4_753/src/fields/fq.rsRaw
1use ark_ff::{
2 biginteger::BigInteger768 as BigInteger,
3 fields::{FftParameters, Fp768, Fp768Parameters, FpParameters},
4};
5
6pub type Fq = Fp768<FqParameters>;
7
8pub struct FqParameters;
9
10impl Fp768Parameters for FqParameters {}
11impl FftParameters for FqParameters {
12 type BigInt = BigInteger;
13
14 const TWO_ADICITY: u32 = 15;
15
16 const TWO_ADIC_ROOT_OF_UNITY: BigInteger = BigInteger([
17 0x3b079c7556ac378,
18 0x2c8c74d04a3f00d4,
19 0xd3b001061b90d4cf,
20 0x946e77514891b0e6,
21 0x79caec8ad6dc9ea1,
22 0xbefd780edc81435d,
23 0xe093d4dca630b154,
24 0x43a0f673199f1c12,
25 0x92276c78436253ff,
26 0xe249d1cf014fcd24,
27 0x96f36471fb7c3ec5,
28 0x1080b8906b7c4,
29 ]);
30
31 const SMALL_SUBGROUP_BASE: Option<u32> = Some(5);
32 const SMALL_SUBGROUP_BASE_ADICITY: Option<u32> = Some(2);
33 /// LARGE_SUBGROUP_ROOT_OF_UNITY =
34 /// 12249458902762217747626832919710926618510011455364963726393752854649914979954138109976331601455448780251166045203053508523342111624583986869301658366625356826888785691823710598470775453742133593634524619429629803955083254436531
35 const LARGE_SUBGROUP_ROOT_OF_UNITY: Option<BigInteger> = Some(BigInteger([
36 8926681816978929800,
37 10873079436792120119,
38 6519893728366769435,
39 7899277225737766970,
40 8416573500933450083,
41 12951641800297678468,
42 7093775028595490583,
43 14327009285082556021,
44 18228411097456927576,
45 2823658094446565457,
46 1708328092507553067,
47 109589007594791,
48 ]));
49}
50impl FpParameters for FqParameters {
51 /// MODULUS = 41898490967918953402344214791240637128170709919953949071783502921025352812571106773058893763790338921418070971888253786114353726529584385201591605722013126468931404347949840543007986327743462853720628051692141265303114721689601
52 const MODULUS: BigInteger = BigInteger([
53 0x5e9063de245e8001,
54 0xe39d54522cdd119f,
55 0x638810719ac425f0,
56 0x685acce9767254a4,
57 0xb80f0da5cb537e38,
58 0xb117e776f218059d,
59 0x99d124d9a15af79d,
60 0x7fdb925e8a0ed8d,
61 0x5eb7e8f96c97d873,
62 0xb7f997505b8fafed,
63 0x10229022eee2cdad,
64 0x1c4c62d92c411,
65 ]);
66
67 const MODULUS_BITS: u32 = 753;
68
69 const CAPACITY: u32 = Self::MODULUS_BITS - 1;
70
71 const REPR_SHAVE_BITS: u32 = 15;
72
73 const R: BigInteger = BigInteger([
74 0x98a8ecabd9dc6f42,
75 0x91cd31c65a034686,
76 0x97c3e4a0cd14572e,
77 0x79589819c788b601,
78 0xed269c942108976f,
79 0x1e0f4d8acf031d68,
80 0x320c3bb713338559,
81 0x598b4302d2f00a62,
82 0x4074c9cbfd8ca621,
83 0xfa47edb3865e88c,
84 0x95455fb31ff9a195,
85 0x7b479ec8e242,
86 ]);
87
88 const R2: BigInteger = BigInteger([
89 0x84717088cfd190c8,
90 0xc7d9ff8e7df03c0a,
91 0xa24bea56242b3507,
92 0xa896a656a0714c7d,
93 0x80a46659ff6f3ddf,
94 0x2f47839ef88d7ce8,
95 0xa8c86d4604a3b597,
96 0xe03c79cac4f7ef07,
97 0x2505daf1f4a81245,
98 0x8e4605754c381723,
99 0xb081f15bcbfdacaf,
100 0x2a33e89cb485,
101 ]);
102
103 const INV: u64 = 0xf2044cfbe45e7fff;
104
105 const GENERATOR: BigInteger = BigInteger([
106 0xa8f627f0e629635e,
107 0x202afce346c36872,
108 0x85e1ece733493254,
109 0x6d76e610664ac389,
110 0xdf542f3f04441585,
111 0x3aa4885bf6d4dd80,
112 0xeb8b63c1c0fffc74,
113 0xd2488e985f6cfa4e,
114 0xcce1c2a623f7a66a,
115 0x2a060f4d5085b19a,
116 0xa9111a596408842f,
117 0x11ca8d50bf627,
118 ]);
119
120 const MODULUS_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
121 0xaf4831ef122f4000,
122 0x71ceaa29166e88cf,
123 0x31c40838cd6212f8,
124 0x342d6674bb392a52,
125 0xdc0786d2e5a9bf1c,
126 0xd88bf3bb790c02ce,
127 0xcce8926cd0ad7bce,
128 0x83fedc92f45076c6,
129 0xaf5bf47cb64bec39,
130 0xdbfccba82dc7d7f6,
131 0x88114811777166d6,
132 0xe26316c96208,
133 ]);
134
135 // T and T_MINUS_ONE_DIV_TWO, where MODULUS - 1 = 2^S * T
136
137 /// T = (MODULUS - 1) / 2^S =
138 /// 1278640471433073529124274133033466709233725278318907137200424283478556909563327233064541435662546964154604216671394463687571830033251476599169665701965732619291119517454523942352538645255842982596454713491581459512424155325
139 const T: BigInteger = BigInteger([
140 0x233ebd20c7bc48bd,
141 0x4be1c73aa8a459ba,
142 0xa948c71020e33588,
143 0xfc70d0b599d2ece4,
144 0xb3b701e1b4b96a6,
145 0xef3b622fceede430,
146 0xdb1b33a249b342b5,
147 0xb0e60ffb724bd141,
148 0x5fdabd6fd1f2d92f,
149 0x9b5b6ff32ea0b71f,
150 0x882220452045ddc5,
151 0x3898c5b25,
152 ]);
153
154 /// (T - 1) / 2 =
155 /// 639320235716536764562137066516733354616862639159453568600212141739278454781663616532270717831273482077302108335697231843785915016625738299584832850982866309645559758727261971176269322627921491298227356745790729756212077662
156 const T_MINUS_ONE_DIV_TWO: BigInteger = BigInteger([
157 0x119f5e9063de245e,
158 0x25f0e39d54522cdd,
159 0x54a4638810719ac4,
160 0x7e38685acce97672,
161 0x59db80f0da5cb53,
162 0xf79db117e776f218,
163 0xed8d99d124d9a15a,
164 0xd87307fdb925e8a0,
165 0xafed5eb7e8f96c97,
166 0xcdadb7f997505b8f,
167 0xc41110229022eee2,
168 0x1c4c62d92,
169 ]);
170}