Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
edwards_init.cpp
Go to the documentation of this file.
1
11
12namespace libff {
13
16
30
36
38{
39 typedef bigint<edwards_r_limbs> bigint_r;
40 typedef bigint<edwards_q_limbs> bigint_q;
41
42 assert(sizeof(mp_limb_t) == 8 || sizeof(mp_limb_t) == 4); // Montgomery assumes this
43
44 /* parameters for scalar field Fr */
45
46 edwards_modulus_r = bigint_r("1552511030102430251236801561344621993261920897571225601");
48 if (sizeof(mp_limb_t) == 8)
49 {
50 edwards_Fr::Rsquared = bigint_r("621738487827897760168419760282818735947979812540885779");
51 edwards_Fr::Rcubed = bigint_r("899968968216802386013510389846941393831065658679774050");
52 edwards_Fr::inv = 0xdde553277fffffff;
53 }
54 if (sizeof(mp_limb_t) == 4)
55 {
56 edwards_Fr::Rsquared = bigint_r("621738487827897760168419760282818735947979812540885779");
57 edwards_Fr::Rcubed = bigint_r("899968968216802386013510389846941393831065658679774050");
58 edwards_Fr::inv = 0x7fffffff;
59 }
61 edwards_Fr::euler = bigint_r("776255515051215125618400780672310996630960448785612800");
62 edwards_Fr::s = 31;
63 edwards_Fr::t = bigint_r("722944284836962004768104088187507350585386575");
64 edwards_Fr::t_minus_1_over_2 = bigint_r("361472142418481002384052044093753675292693287");
66 edwards_Fr::root_of_unity = edwards_Fr("695314865466598274460565335217615316274564719601897184");
68 edwards_Fr::nqr_to_t = edwards_Fr("1326707053668679463752768729767248251415639579872144553");
69
70 /* parameters for base field Fq */
71
72 edwards_modulus_q = bigint_q("6210044120409721004947206240885978274523751269793792001");
74 if (sizeof(mp_limb_t) == 8)
75 {
76 edwards_Fq::Rsquared = bigint_q("5943559676554581037560514598978484097352477055348195432");
77 edwards_Fq::Rcubed = bigint_q("1081560488703514202058739223469726982199727506489234349");
78 edwards_Fq::inv = 0x76eb690b7fffffff;
79 }
80 if (sizeof(mp_limb_t) == 4)
81 {
82 edwards_Fq::Rsquared = bigint_q("5943559676554581037560514598978484097352477055348195432");
83 edwards_Fq::Rcubed = bigint_q("1081560488703514202058739223469726982199727506489234349");
84 edwards_Fq::inv = 0x7fffffff;
85 }
87 edwards_Fq::euler = bigint_q("3105022060204860502473603120442989137261875634896896000");
88 edwards_Fq::s = 31;
89 edwards_Fq::t = bigint_q("2891777139347848019072416350658041552884388375");
90 edwards_Fq::t_minus_1_over_2 = bigint_q("1445888569673924009536208175329020776442194187");
92 edwards_Fq::root_of_unity = edwards_Fq("4692813029219384139894873043933463717810008194158530536");
94 edwards_Fq::nqr_to_t = edwards_Fq("2626736066325740702418554487368721595489070118548299138");
95
96 /* parameters for twist field Fq3 */
97
98 edwards_Fq3::euler = bigint<3*edwards_q_limbs>("119744082713971502962992613191067836698205043373978948903839934564152994858051284658545502971203325031831647424413111161318314144765646525057914792711854057586688000");
99 edwards_Fq3::s = 31;
100 edwards_Fq3::t = bigint<3*edwards_q_limbs>("111520367408144756185815309352304634357062208814526860512643991563611659089151103662834971185031649686239331424621037357783237607000066456438894190557165125");
101 edwards_Fq3::t_minus_1_over_2 = bigint<3*edwards_q_limbs>("55760183704072378092907654676152317178531104407263430256321995781805829544575551831417485592515824843119665712310518678891618803500033228219447095278582562");
104 edwards_Fq3::nqr_to_t = edwards_Fq3(edwards_Fq("104810943629412208121981114244673004633270996333237516"),edwards_Fq("0"),edwards_Fq("0"));
106 edwards_Fq3::Frobenius_coeffs_c1[1] = edwards_Fq("1073752683758513276629212192812154536507607213288832061");
107 edwards_Fq3::Frobenius_coeffs_c1[2] = edwards_Fq("5136291436651207728317994048073823738016144056504959939");
109 edwards_Fq3::Frobenius_coeffs_c2[1] = edwards_Fq("5136291436651207728317994048073823738016144056504959939");
110 edwards_Fq3::Frobenius_coeffs_c2[2] = edwards_Fq("1073752683758513276629212192812154536507607213288832061");
111
112 /* parameters for Fq6 */
113
116 edwards_Fq6::Frobenius_coeffs_c1[1] = edwards_Fq("1073752683758513276629212192812154536507607213288832062");
117 edwards_Fq6::Frobenius_coeffs_c1[2] = edwards_Fq("1073752683758513276629212192812154536507607213288832061");
118 edwards_Fq6::Frobenius_coeffs_c1[3] = edwards_Fq("6210044120409721004947206240885978274523751269793792000");
119 edwards_Fq6::Frobenius_coeffs_c1[4] = edwards_Fq("5136291436651207728317994048073823738016144056504959939");
120 edwards_Fq6::Frobenius_coeffs_c1[5] = edwards_Fq("5136291436651207728317994048073823738016144056504959940");
122
123 /* choice of Edwards curve and its twist */
124
126 edwards_coeff_d = edwards_Fq("600581931845324488256649384912508268813600056237543024");
136 edwards_twist_mul_by_q_Y = edwards_Fq("1073752683758513276629212192812154536507607213288832062");
137 edwards_twist_mul_by_q_Z = edwards_Fq("1073752683758513276629212192812154536507607213288832062");
138
139 /* choice of group G1 */
142 edwards_G1::G1_one = edwards_G1(edwards_Fq("3713709671941291996998665608188072510389821008693530490"),
143 edwards_Fq("4869953702976555123067178261685365085639705297852816679"));
145
148 edwards_G1::wnaf_window_table.push_back(14);
149 edwards_G1::wnaf_window_table.push_back(24);
150 edwards_G1::wnaf_window_table.push_back(117);
151
153 // window 1 is unbeaten in [-inf, 4.10]
155 // window 2 is unbeaten in [4.10, 9.69]
157 // window 3 is unbeaten in [9.69, 25.21]
159 // window 4 is unbeaten in [25.21, 60.00]
161 // window 5 is unbeaten in [60.00, 149.33]
163 // window 6 is unbeaten in [149.33, 369.61]
165 // window 7 is unbeaten in [369.61, 849.07]
167 // window 8 is unbeaten in [849.07, 1764.94]
169 // window 9 is unbeaten in [1764.94, 4429.59]
171 // window 10 is unbeaten in [4429.59, 13388.78]
173 // window 11 is unbeaten in [13388.78, 15368.00]
175 // window 12 is unbeaten in [15368.00, 74912.07]
177 // window 13 is unbeaten in [74912.07, 438107.20]
179 // window 14 is never the best
181 // window 15 is unbeaten in [438107.20, 1045626.18]
183 // window 16 is never the best
185 // window 17 is unbeaten in [1045626.18, 1577434.48]
187 // window 18 is unbeaten in [1577434.48, 17350594.23]
189 // window 19 is never the best
191 // window 20 is never the best
193 // window 21 is unbeaten in [17350594.23, inf]
194 edwards_G1::fixed_base_exp_window_table.push_back(17350594);
195 // window 22 is never the best
197
198 /* choice of group G2 */
199
202 edwards_G2::G2_one = edwards_G2(edwards_Fq3(edwards_Fq("4531683359223370252210990718516622098304721701253228128"),
203 edwards_Fq("5339624155305731263217400504407647531329993548123477368"),
204 edwards_Fq("3964037981777308726208525982198654699800283729988686552")),
205 edwards_Fq3(edwards_Fq("364634864866983740775341816274081071386963546650700569"),
206 edwards_Fq("3264380230116139014996291397901297105159834497864380415"),
207 edwards_Fq("3504781284999684163274269077749440837914479176282903747")));
209
212 edwards_G2::wnaf_window_table.push_back(12);
213 edwards_G2::wnaf_window_table.push_back(42);
214 edwards_G2::wnaf_window_table.push_back(97);
215
217 // window 1 is unbeaten in [-inf, 4.74]
219 // window 2 is unbeaten in [4.74, 10.67]
221 // window 3 is unbeaten in [10.67, 25.53]
223 // window 4 is unbeaten in [25.53, 60.67]
225 // window 5 is unbeaten in [60.67, 145.77]
227 // window 6 is unbeaten in [145.77, 356.76]
229 // window 7 is unbeaten in [356.76, 823.08]
231 // window 8 is unbeaten in [823.08, 1589.45]
233 // window 9 is unbeaten in [1589.45, 4135.70]
235 // window 10 is unbeaten in [4135.70, 14297.74]
237 // window 11 is unbeaten in [14297.74, 16744.85]
239 // window 12 is unbeaten in [16744.85, 51768.98]
241 // window 13 is unbeaten in [51768.98, 99811.01]
243 // window 14 is unbeaten in [99811.01, 193306.72]
245 // window 15 is unbeaten in [193306.72, 907184.68]
247 // window 16 is never the best
249 // window 17 is unbeaten in [907184.68, 1389682.59]
251 // window 18 is unbeaten in [1389682.59, 6752695.74]
253 // window 19 is never the best
255 // window 20 is unbeaten in [6752695.74, 193642894.51]
257 // window 21 is unbeaten in [193642894.51, 226760202.29]
258 edwards_G2::fixed_base_exp_window_table.push_back(193642895);
259 // window 22 is unbeaten in [226760202.29, inf]
260 edwards_G2::fixed_base_exp_window_table.push_back(226760202);
261
262 /* pairing parameters */
263
264 edwards_ate_loop_count = bigint_q("4492509698523932320491110403");
265 edwards_final_exponent = bigint<6*edwards_q_limbs>("36943107177961694649618797346446870138748651578611748415128207429491593976636391130175425245705674550269561361208979548749447898941828686017765730419416875539615941651269793928962468899856083169227457503942470721108165443528513330156264699608120624990672333642644221591552000");
266 edwards_final_exponent_last_chunk_abs_of_w0 = bigint_q("17970038794095729281964441603");
269
270}
271} // libff
static Fp3_model< n, modulus > nqr_to_t
Definition fp3.hpp:46
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 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
static bool initialized
static edwards_G1 G1_one
static edwards_G1 G1_zero
static std::vector< size_t > wnaf_window_table
static std::vector< size_t > fixed_base_exp_window_table
static bool initialized
static edwards_G2 G2_one
static std::vector< size_t > wnaf_window_table
static edwards_G2 G2_zero
edwards_Fq3 edwards_twist
edwards_Fq edwards_coeff_a
void init_edwards_params()
Fp3_model< edwards_q_limbs, edwards_modulus_q > edwards_Fq3
bigint< edwards_r_limbs > edwards_modulus_r
bigint< 6 *edwards_q_limbs > edwards_final_exponent
Fp_model< edwards_q_limbs, edwards_modulus_q > edwards_Fq
edwards_Fq edwards_twist_mul_by_q_Y
edwards_Fq edwards_twist_mul_by_d_c1
edwards_Fq edwards_twist_mul_by_q_Z
bigint< edwards_q_limbs > edwards_final_exponent_last_chunk_abs_of_w0
bigint< edwards_q_limbs > edwards_modulus_q
edwards_Fq edwards_twist_mul_by_a_c0
edwards_Fq edwards_twist_mul_by_a_c1
edwards_Fq edwards_coeff_d
edwards_Fq3 edwards_twist_coeff_a
bigint< edwards_q_limbs > edwards_final_exponent_last_chunk_w1
bool edwards_final_exponent_last_chunk_is_w0_neg
edwards_Fq edwards_twist_mul_by_d_c2
Fp_model< edwards_r_limbs, edwards_modulus_r > edwards_Fr
edwards_Fq edwards_twist_mul_by_a_c2
edwards_Fq3 edwards_twist_coeff_d
edwards_Fq edwards_twist_mul_by_d_c0
bigint< edwards_q_limbs > edwards_ate_loop_count