Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
mnt6_init.cpp
Go to the documentation of this file.
1
17
18namespace libff {
19
20//bigint<mnt6_r_limbs> mnt6_modulus_r = mnt46_modulus_B;
21//bigint<mnt6_q_limbs> mnt6_modulus_q = mnt46_modulus_A;
22
34
41
43{
44 typedef bigint<mnt6_r_limbs> bigint_r;
45 typedef bigint<mnt6_q_limbs> bigint_q;
46
47 assert(sizeof(mp_limb_t) == 8 || sizeof(mp_limb_t) == 4); // Montgomery assumes this
48
49 /* parameters for scalar field Fr */
50 mnt6_modulus_r = bigint_r("475922286169261325753349249653048451545124879242694725395555128576210262817955800483758081");
52 if (sizeof(mp_limb_t) == 8)
53 {
54 mnt6_Fr::Rsquared = bigint_r("273000478523237720910981655601160860640083126627235719712980612296263966512828033847775776");
55 mnt6_Fr::Rcubed = bigint_r("427298980065529822574935274648041073124704261331681436071990730954930769758106792920349077");
56 mnt6_Fr::inv = 0xb071a1b67165ffff;
57 }
58 if (sizeof(mp_limb_t) == 4)
59 {
60 mnt6_Fr::Rsquared = bigint_r("273000478523237720910981655601160860640083126627235719712980612296263966512828033847775776");
61 mnt6_Fr::Rcubed = bigint_r("427298980065529822574935274648041073124704261331681436071990730954930769758106792920349077");
62 mnt6_Fr::inv = 0x7165ffff;
63 }
65 mnt6_Fr::euler = bigint_r("237961143084630662876674624826524225772562439621347362697777564288105131408977900241879040");
66 mnt6_Fr::s = 17;
67 mnt6_Fr::t = bigint_r("3630998887399759870554727551674258816109656366292531779446068791017229177993437198515");
68 mnt6_Fr::t_minus_1_over_2 = bigint_r("1815499443699879935277363775837129408054828183146265889723034395508614588996718599257");
70 mnt6_Fr::root_of_unity = mnt6_Fr("264706250571800080758069302369654305530125675521263976034054878017580902343339784464690243");
71 mnt6_Fr::nqr = mnt6_Fr("17");
72 mnt6_Fr::nqr_to_t = mnt6_Fr("264706250571800080758069302369654305530125675521263976034054878017580902343339784464690243");
73
74 /* parameters for base field Fq */
75 mnt6_modulus_q = bigint_q("475922286169261325753349249653048451545124878552823515553267735739164647307408490559963137");
77 if (sizeof(mp_limb_t) == 8)
78 {
79 mnt6_Fq::Rsquared = bigint_q("163983144722506446826715124368972380525894397127205577781234305496325861831001705438796139");
80 mnt6_Fq::Rcubed = bigint_q("207236281459091063710247635236340312578688659363066707916716212805695955118593239854980171");
81 mnt6_Fq::inv = 0xbb4334a3ffffffff;
82 }
83 if (sizeof(mp_limb_t) == 4)
84 {
85 mnt6_Fq::Rsquared = bigint_q("163983144722506446826715124368972380525894397127205577781234305496325861831001705438796139");
86 mnt6_Fq::Rcubed = bigint_q("207236281459091063710247635236340312578688659363066707916716212805695955118593239854980171");
87 mnt6_Fq::inv = 0xffffffff;
88 }
90 mnt6_Fq::euler = bigint_q("237961143084630662876674624826524225772562439276411757776633867869582323653704245279981568");
91 mnt6_Fq::s = 34;
92 mnt6_Fq::t = bigint_q("27702323054502562488973446286577291993024111641153199339359284829066871159442729");
93 mnt6_Fq::t_minus_1_over_2 = bigint_q("13851161527251281244486723143288645996512055820576599669679642414533435579721364");
95 mnt6_Fq::root_of_unity = mnt6_Fq("120638817826913173458768829485690099845377008030891618010109772937363554409782252579816313");
96 mnt6_Fq::nqr = mnt6_Fq("5");
97 mnt6_Fq::nqr_to_t = mnt6_Fq("406220604243090401056429458730298145937262552508985450684842547562990900634752279902740880");
98
99 /* parameters for twist field Fq3 */
100 mnt6_Fq3::euler = bigint<3*mnt6_q_limbs>("53898680178554951715397245154796036139463891589001478629193136369124915637741423690184935056189295242736833704290747216410090671804540908400210778934462129625646263095398323485795557551284190224166851571615834194321908328559167529729507439069424158411618728014749106176");
101 mnt6_Fq3::s = 34;
102 mnt6_Fq3::t = bigint<3*mnt6_q_limbs>("6274632199033507112809136178669989590936327770934612330653836993631547740397674926811006741620285348354004521888069251599964996777072188956687550402067383940523288107407084140669968625447269322370045302856694231080113482726640944570478452261237446033817102203");
103 mnt6_Fq3::t_minus_1_over_2 = bigint<3*mnt6_q_limbs>("3137316099516753556404568089334994795468163885467306165326918496815773870198837463405503370810142674177002260944034625799982498388536094478343775201033691970261644053703542070334984312723634661185022651428347115540056741363320472285239226130618723016908551101");
105 mnt6_Fq3::nqr = mnt6_Fq3(mnt6_Fq("5"),mnt6_Fq("0"),mnt6_Fq("0"));
106 mnt6_Fq3::nqr_to_t = mnt6_Fq3(mnt6_Fq("154361449678783505076984156275977937654331103361174469632346230549735979552469642799720052"),mnt6_Fq("0"),mnt6_Fq("0"));
108 mnt6_Fq3::Frobenius_coeffs_c1[1] = mnt6_Fq("471738898967521029133040851318449165997304108729558973770077319830005517129946578866686956");
109 mnt6_Fq3::Frobenius_coeffs_c1[2] = mnt6_Fq("4183387201740296620308398334599285547820769823264541783190415909159130177461911693276180");
111 mnt6_Fq3::Frobenius_coeffs_c2[1] = mnt6_Fq("4183387201740296620308398334599285547820769823264541783190415909159130177461911693276180");
112 mnt6_Fq3::Frobenius_coeffs_c2[2] = mnt6_Fq("471738898967521029133040851318449165997304108729558973770077319830005517129946578866686956");
113
114 /* parameters for Fq6 */
117 mnt6_Fq6::Frobenius_coeffs_c1[1] = mnt6_Fq("471738898967521029133040851318449165997304108729558973770077319830005517129946578866686957");
118 mnt6_Fq6::Frobenius_coeffs_c1[2] = mnt6_Fq("471738898967521029133040851318449165997304108729558973770077319830005517129946578866686956");
119 mnt6_Fq6::Frobenius_coeffs_c1[3] = mnt6_Fq("475922286169261325753349249653048451545124878552823515553267735739164647307408490559963136");
120 mnt6_Fq6::Frobenius_coeffs_c1[4] = mnt6_Fq("4183387201740296620308398334599285547820769823264541783190415909159130177461911693276180");
121 mnt6_Fq6::Frobenius_coeffs_c1[5] = mnt6_Fq("4183387201740296620308398334599285547820769823264541783190415909159130177461911693276181");
123
124 /* choice of short Weierstrass curve and its twist */
126 mnt6_G1::coeff_b = mnt6_Fq("106700080510851735677967319632585352256454251201367587890185989362936000262606668469523074");
141 mnt6_twist_mul_by_q_X = mnt6_Fq("4183387201740296620308398334599285547820769823264541783190415909159130177461911693276180");
142 mnt6_twist_mul_by_q_Y = mnt6_Fq("475922286169261325753349249653048451545124878552823515553267735739164647307408490559963136");
143
144 /* choice of group G1 */
146 mnt6_Fq::one(),
147 mnt6_Fq::zero());
148 mnt6_G1::G1_one = mnt6_G1(mnt6_Fq("336685752883082228109289846353937104185698209371404178342968838739115829740084426881123453"),
149 mnt6_Fq("402596290139780989709332707716568920777622032073762749862342374583908837063963736098549800"),
150 mnt6_Fq::one());
152
154 mnt6_G1::wnaf_window_table.push_back(11);
155 mnt6_G1::wnaf_window_table.push_back(24);
156 mnt6_G1::wnaf_window_table.push_back(60);
157 mnt6_G1::wnaf_window_table.push_back(127);
158
160 // window 1 is unbeaten in [-inf, 3.96]
162 // window 2 is unbeaten in [3.96, 9.67]
164 // window 3 is unbeaten in [9.67, 25.13]
166 // window 4 is unbeaten in [25.13, 60.31]
168 // window 5 is unbeaten in [60.31, 146.07]
170 // window 6 is unbeaten in [146.07, 350.09]
172 // window 7 is unbeaten in [350.09, 844.54]
174 // window 8 is unbeaten in [844.54, 1839.64]
176 // window 9 is unbeaten in [1839.64, 3904.26]
178 // window 10 is unbeaten in [3904.26, 11309.42]
180 // window 11 is unbeaten in [11309.42, 24015.57]
182 // window 12 is unbeaten in [24015.57, 72288.57]
184 // window 13 is unbeaten in [72288.57, 138413.22]
186 // window 14 is unbeaten in [138413.22, 156390.30]
187 mnt6_G1::fixed_base_exp_window_table.push_back(138413);
188 // window 15 is unbeaten in [156390.30, 562560.50]
189 mnt6_G1::fixed_base_exp_window_table.push_back(156390);
190 // window 16 is unbeaten in [562560.50, 1036742.02]
191 mnt6_G1::fixed_base_exp_window_table.push_back(562560);
192 // window 17 is unbeaten in [1036742.02, 2053818.86]
193 mnt6_G1::fixed_base_exp_window_table.push_back(1036742);
194 // window 18 is unbeaten in [2053818.86, 4370223.95]
195 mnt6_G1::fixed_base_exp_window_table.push_back(2053819);
196 // window 19 is unbeaten in [4370223.95, 8215703.81]
197 mnt6_G1::fixed_base_exp_window_table.push_back(4370224);
198 // window 20 is unbeaten in [8215703.81, 42682375.43]
199 mnt6_G1::fixed_base_exp_window_table.push_back(8215704);
200 // window 21 is never the best
202 // window 22 is unbeaten in [42682375.43, inf]
203 mnt6_G1::fixed_base_exp_window_table.push_back(42682375);
204
205 /* choice of group G2 */
209 mnt6_G2::G2_one = mnt6_G2(mnt6_Fq3(mnt6_Fq("421456435772811846256826561593908322288509115489119907560382401870203318738334702321297427"),
210 mnt6_Fq("103072927438548502463527009961344915021167584706439945404959058962657261178393635706405114"),
211 mnt6_Fq("143029172143731852627002926324735183809768363301149009204849580478324784395590388826052558")),
212 mnt6_Fq3(mnt6_Fq("464673596668689463130099227575639512541218133445388869383893594087634649237515554342751377"),
213 mnt6_Fq("100642907501977375184575075967118071807821117960152743335603284583254620685343989304941678"),
214 mnt6_Fq("123019855502969896026940545715841181300275180157288044663051565390506010149881373807142903")),
215 mnt6_Fq3::one());
217
219 mnt6_G2::wnaf_window_table.push_back(5);
220 mnt6_G2::wnaf_window_table.push_back(15);
221 mnt6_G2::wnaf_window_table.push_back(39);
222 mnt6_G2::wnaf_window_table.push_back(109);
223
225 // window 1 is unbeaten in [-inf, 4.25]
227 // window 2 is unbeaten in [4.25, 10.22]
229 // window 3 is unbeaten in [10.22, 24.85]
231 // window 4 is unbeaten in [24.85, 60.06]
233 // window 5 is unbeaten in [60.06, 143.61]
235 // window 6 is unbeaten in [143.61, 345.66]
237 // window 7 is unbeaten in [345.66, 818.56]
239 // window 8 is unbeaten in [818.56, 1782.06]
241 // window 9 is unbeaten in [1782.06, 4002.45]
243 // window 10 is unbeaten in [4002.45, 10870.18]
245 // window 11 is unbeaten in [10870.18, 18022.51]
247 // window 12 is unbeaten in [18022.51, 43160.74]
249 // window 13 is unbeaten in [43160.74, 149743.32]
251 // window 14 is never the best
253 // window 15 is unbeaten in [149743.32, 551844.13]
254 mnt6_G2::fixed_base_exp_window_table.push_back(149743);
255 // window 16 is unbeaten in [551844.13, 1041827.91]
256 mnt6_G2::fixed_base_exp_window_table.push_back(551844);
257 // window 17 is unbeaten in [1041827.91, 1977371.53]
258 mnt6_G2::fixed_base_exp_window_table.push_back(1041828);
259 // window 18 is unbeaten in [1977371.53, 3703619.51]
260 mnt6_G2::fixed_base_exp_window_table.push_back(1977372);
261 // window 19 is unbeaten in [3703619.51, 7057236.87]
262 mnt6_G2::fixed_base_exp_window_table.push_back(3703620);
263 // window 20 is unbeaten in [7057236.87, 38554491.67]
264 mnt6_G2::fixed_base_exp_window_table.push_back(7057237);
265 // window 21 is never the best
267 // window 22 is unbeaten in [38554491.67, inf]
268 mnt6_G2::fixed_base_exp_window_table.push_back(38554492);
269
270 /* pairing parameters */
271 mnt6_ate_loop_count = bigint_q("689871209842287392837045615510547309923794944");
273 mnt6_final_exponent = bigint<6*mnt6_q_limbs>("24416320138090509697890595414313438768353977489862543935904010715439066975957855922532159264213056712140358746422742237328406558352706591021642230618060502855451264045397444793186876199015256781648746888625527075466063075011307800862173764236311342105211681121426931616843635215852236649271569251468773714424208521977615548771268520882870120900360322044218806712027729351845307690474985502587527753847200130592058098363641559341826790559426614919168");
274 mnt6_final_exponent_last_chunk_abs_of_w0 = bigint_q("689871209842287392837045615510547309923794944");
276 mnt6_final_exponent_last_chunk_w1 = bigint_q("1");
277}
278
279} // libff
static Fp3_model< n, modulus > nqr_to_t
Definition fp3.hpp:46
static Fp3_model< n, modulus > one()
static Fp3_model< n, modulus > zero()
static Fp3_model< n, modulus > nqr
Definition fp3.hpp:45
static my_Fp Frobenius_coeffs_c1[6]
static bigint< n > euler
Definition fp.hpp:54
static Fp_model< n, modulus > multiplicative_generator
Definition fp.hpp:60
static Fp_model< n, modulus > zero()
static Fp_model< n, modulus > one()
static size_t s
Definition fp.hpp:55
static bigint< n > t
Definition fp.hpp:56
static bigint< n > t_minus_1_over_2
Definition fp.hpp:57
static Fp_model< n, modulus > root_of_unity
Definition fp.hpp:61
static bigint< n > Rcubed
Definition fp.hpp:64
static bool modulus_is_valid()
Definition fp.hpp:66
static mp_limb_t inv
Definition fp.hpp:62
static Fp_model< n, modulus > nqr_to_t
Definition fp.hpp:59
static Fp_model< n, modulus > nqr
Definition fp.hpp:58
static bigint< n > Rsquared
Definition fp.hpp:63
static size_t num_bits
Definition fp.hpp:53
static std::vector< size_t > fixed_base_exp_window_table
Definition mnt6_g1.hpp:33
static mnt6_Fq coeff_a
Definition mnt6_g1.hpp:37
static mnt6_Fq coeff_b
Definition mnt6_g1.hpp:38
static bool initialized
Definition mnt6_g1.hpp:36
static mnt6_G1 G1_zero
Definition mnt6_g1.hpp:34
static mnt6_G1 G1_one
Definition mnt6_g1.hpp:35
static std::vector< size_t > wnaf_window_table
Definition mnt6_g1.hpp:32
static std::vector< size_t > wnaf_window_table
Definition mnt6_g2.hpp:32
static bool initialized
Definition mnt6_g2.hpp:36
static mnt6_G2 G2_one
Definition mnt6_g2.hpp:35
static mnt6_Fq3 twist
Definition mnt6_g2.hpp:37
static mnt6_G2 G2_zero
Definition mnt6_g2.hpp:34
static mnt6_Fq3 coeff_a
Definition mnt6_g2.hpp:38
static mnt6_Fq3 coeff_b
Definition mnt6_g2.hpp:39
static std::vector< size_t > fixed_base_exp_window_table
Definition mnt6_g2.hpp:33
bigint< mnt6_r_limbs > mnt6_modulus_r
bigint< 6 *mnt6_q_limbs > mnt6_final_exponent
Definition mnt6_init.cpp:37
bigint< mnt6_q_limbs > mnt6_final_exponent_last_chunk_abs_of_w0
Definition mnt6_init.cpp:38
void init_mnt6_params()
Definition mnt6_init.cpp:42
bigint< mnt6_q_limbs > mnt6_modulus_q
bool mnt6_final_exponent_last_chunk_is_w0_neg
Definition mnt6_init.cpp:39
mnt6_Fq mnt6_twist_mul_by_a_c0
Definition mnt6_init.cpp:26
bigint< mnt6_q_limbs > mnt6_final_exponent_last_chunk_w1
Definition mnt6_init.cpp:40
mnt6_Fq mnt6_twist_mul_by_a_c2
Definition mnt6_init.cpp:28
Fp_model< mnt6_r_limbs, mnt6_modulus_r > mnt6_Fr
Definition mnt6_init.hpp:35
mnt6_Fq mnt6_twist_mul_by_b_c2
Definition mnt6_init.cpp:31
Fp_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq
Definition mnt6_init.hpp:36
mnt6_Fq3 mnt6_twist
Definition mnt6_init.cpp:23
mnt6_Fq mnt6_twist_mul_by_b_c1
Definition mnt6_init.cpp:30
bool mnt6_ate_is_loop_count_neg
Definition mnt6_init.cpp:36
mnt6_Fq3 mnt6_twist_coeff_a
Definition mnt6_init.cpp:24
mnt6_Fq mnt6_twist_mul_by_q_Y
Definition mnt6_init.cpp:33
mnt6_Fq mnt6_twist_mul_by_b_c0
Definition mnt6_init.cpp:29
mnt6_Fq mnt6_twist_mul_by_q_X
Definition mnt6_init.cpp:32
Fp3_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq3
Definition mnt6_init.hpp:37
mnt6_Fq3 mnt6_twist_coeff_b
Definition mnt6_init.cpp:25
bigint< mnt6_q_limbs > mnt6_ate_loop_count
Definition mnt6_init.cpp:35
mnt6_Fq mnt6_twist_mul_by_a_c1
Definition mnt6_init.cpp:27