27 return (this->
PX == other.
PX &&
28 this->PY == other.PY &&
29 this->PX_twist == other.PX_twist &&
30 this->PY_twist == other.PY_twist);
55 return (this->
c_H == other.
c_H &&
56 this->c_4C == other.c_4C &&
57 this->c_J == other.c_J &&
58 this->c_L == other.c_L);
83 this->c_RZ == other.c_RZ);
104 return (this->
QX == other.
QX &&
105 this->QY == other.QY &&
106 this->QY2 == other.QY2 &&
107 this->QX_over_twist == other.QX_over_twist &&
108 this->QY_over_twist == other.QY_over_twist &&
109 this->dbl_coeffs == other.dbl_coeffs &&
110 this->add_coeffs == other.add_coeffs);
154 for (
size_t i = 0; i < dbl_s; ++i)
169 for (
size_t i = 0; i < add_s; ++i)
184 enter_block(
"Call to mnt6_final_exponentiation_last_chunk");
194 mnt6_Fq6 result = w1_part * w0_part;
195 leave_block(
"Call to mnt6_final_exponentiation_last_chunk");
202 enter_block(
"Call to mnt6_final_exponentiation_first_chunk");
209 const mnt6_Fq6 elt_q3_over_elt = elt_q3 * elt_inv;
213 const mnt6_Fq6 beta = alpha * elt_q3_over_elt;
214 leave_block(
"Call to mnt6_final_exponentiation_first_chunk");
234 enter_block(
"Call to mnt6_affine_ate_precompute_G1");
244 leave_block(
"Call to mnt6_affine_ate_precompute_G1");
250 enter_block(
"Call to mnt6_affine_ate_precompute_G2");
263 bool found_nonzero =
false;
265 std::vector<long> NAF =
find_wnaf(1, loop_count);
266 for (
long i = NAF.size() - 1; i >= 0; --i)
271 found_nonzero |= (NAF[i] != 0);
282 result.coeffs.push_back(c);
302 result.coeffs.push_back(c);
324 leave_block(
"Call to mnt6_affine_ate_precompute_G2");
331 enter_block(
"Call to mnt6_affine_ate_miller_loop");
336 bool found_nonzero =
false;
339 std::vector<long> NAF =
find_wnaf(1, loop_count);
340 for (
long i = NAF.size() - 1; i >= 0; --i)
345 found_nonzero |= (NAF[i] != 0);
356 f =
f.squared().mul_by_2345(g_RR_at_P);
372 f =
f.mul_by_2345(g_RQ_at_P);
388 leave_block(
"Call to mnt6_affine_ate_miller_loop");
403 printf(
"extended mnt6_G2 projective X/Y/Z/T:\n");
419 const mnt6_Fq3 X = current.X, Y = current.Y, Z = current.Z,
T = current.T;
429 current.X = -(E+E+E+E) + G;
430 current.Y = -
mnt6_Fq(
"8")*
D + F*(E+E-current.X);
431 current.Z = (Y+Z).squared() - C - Z.
squared();
432 current.T = current.Z.
squared();
434 dc.
c_H = (current.Z +
T).squared() - current.T -
A;
436 dc.
c_J = (F+
T).squared() - G -
A;
437 dc.
c_L = (F+
X).squared() - G -
B;
440 current.test_invariant();
448 const mnt6_Fq3 X1 = current.X, Y1 = current.Y, Z1 = current.Z, T1 = current.T;
449 const mnt6_Fq3 &x2 = base_X, &y2 = base_Y, &y2_squared = base_Y_squared;
452 const mnt6_Fq3 D = ((y2 + Z1).squared() - y2_squared - T1) * T1;
461 current.Y = L1 * (
V-current.X) - (Y1+Y1) * J;
462 current.Z = (Z1+H).squared() - T1 - I;
463 current.T = current.Z.
squared();
468 current.test_invariant();
502 result.QX_over_twist = Qcopy.
X * mnt6_twist_inv;
503 result.QY_over_twist = Qcopy.
Y * mnt6_twist_inv;
512 bool found_one =
false;
513 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i)
526 result.dbl_coeffs.push_back(dc);
532 result.add_coeffs.push_back(ac);
540 mnt6_Fq3 RZ3_inv = RZ2_inv * RZ_inv;
541 mnt6_Fq3 minus_R_affine_X =
R.X * RZ2_inv;
542 mnt6_Fq3 minus_R_affine_Y = -
R.Y * RZ3_inv;
546 result.add_coeffs.push_back(ac);
562 bool found_one =
false;
568 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i)
586 f =
f.squared() * g_RR_at_P;
603 f = (
f * g_RnegR_at_P).inverse();
616 enter_block(
"Call to mnt6_ate_double_miller_loop");
623 bool found_one =
false;
629 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i)
653 f =
f.squared() * g_RR_at_P1 * g_RR_at_P2;
666 f =
f * g_RQ_at_P1 * g_RQ_at_P2;
680 f = (
f * g_RnegR_at_P1 * g_RnegR_at_P2).inverse();
683 leave_block(
"Call to mnt6_ate_double_miller_loop");
Fp3_model inverse() const
Fp3_model squared() const
static Fp3_model< n, modulus > one()
Fp6_2over3_model inverse() const
Fp6_2over3_model cyclotomic_exp(const bigint< m > &exponent) const
static Fp6_2over3_model< n, modulus > one()
Fp6_2over3_model Frobenius_map(unsigned long power) const
static Fp_model< n, modulus > zero()
bool test_bit(const std::size_t bitno) const
void to_affine_coordinates()
void to_affine_coordinates()
#define D(var, file, col, who, lev,...)
Fp6_2over3_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq6
mnt6_GT mnt6_final_exponentiation(const mnt6_Fq6 &elt)
mnt6_Fq6 mnt6_ate_miller_loop(const mnt6_ate_G1_precomp &prec_P, const mnt6_ate_G2_precomp &prec_Q)
void consume_OUTPUT_NEWLINE(std::istream &in)
bigint< mnt6_q_limbs > mnt6_final_exponent_last_chunk_abs_of_w0
mnt6_Fq6 mnt6_final_exponentiation_last_chunk(const mnt6_Fq6 &elt, const mnt6_Fq6 &elt_inv)
mnt6_ate_G1_precomp mnt6_ate_precompute_G1(const mnt6_G1 &P)
mnt6_GT mnt6_ate_reduced_pairing(const mnt6_G1 &P, const mnt6_G2 &Q)
mnt6_ate_G2_precomp mnt6_ate_precompute_G2(const mnt6_G2 &Q)
mnt6_GT mnt6_reduced_pairing(const mnt6_G1 &P, const mnt6_G2 &Q)
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
mnt6_Fq6 mnt6_miller_loop(const mnt6_G1_precomp &prec_P, const mnt6_G2_precomp &prec_Q)
void consume_OUTPUT_SEPARATOR(std::istream &in)
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
bool mnt6_final_exponent_last_chunk_is_w0_neg
void enter_block(const std::string &msg, const bool indent)
mnt6_Fq6 mnt6_double_miller_loop(const mnt6_G1_precomp &prec_P1, const mnt6_G2_precomp &prec_Q1, const mnt6_G1_precomp &prec_P2, const mnt6_G2_precomp &prec_Q2)
void doubling_step_for_flipped_miller_loop(const alt_bn128_Fq two_inv, alt_bn128_G2 ¤t, alt_bn128_ate_ell_coeffs &c)
mnt6_Fq6 mnt6_ate_pairing(const mnt6_G1 &P, const mnt6_G2 &Q)
bigint< mnt6_q_limbs > mnt6_final_exponent_last_chunk_w1
mnt6_Fq6 mnt6_pairing(const mnt6_G1 &P, const mnt6_G2 &Q)
Fp_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq
mnt6_Fq6 mnt6_final_exponentiation_first_chunk(const mnt6_Fq6 &elt, const mnt6_Fq6 &elt_inv)
std::vector< long > find_wnaf(const size_t window_size, const bigint< n > &scalar)
mnt6_Fq6 mnt6_ate_double_miller_loop(const mnt6_ate_G1_precomp &prec_P1, const mnt6_ate_G2_precomp &prec_Q1, const mnt6_ate_G1_precomp &prec_P2, const mnt6_ate_G2_precomp &prec_Q2)
bool mnt6_ate_is_loop_count_neg
mnt6_affine_ate_G1_precomputation mnt6_affine_ate_precompute_G1(const mnt6_G1 &P)
mnt6_Fq3 mnt6_twist_coeff_a
void leave_block(const std::string &msg, const bool indent)
Fp3_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq3
mnt6_GT mnt6_affine_reduced_pairing(const mnt6_G1 &P, const mnt6_G2 &Q)
mnt6_G1_precomp mnt6_precompute_G1(const mnt6_G1 &P)
void consume_newline(std::istream &in)
mnt6_Fq6 mnt6_affine_ate_miller_loop(const mnt6_affine_ate_G1_precomputation &prec_P, const mnt6_affine_ate_G2_precomputation &prec_Q)
mnt6_affine_ate_G2_precomputation mnt6_affine_ate_precompute_G2(const mnt6_G2 &Q)
bigint< mnt6_q_limbs > mnt6_ate_loop_count
mnt6_G2_precomp mnt6_precompute_G2(const mnt6_G2 &Q)
void mixed_addition_step_for_flipped_miller_loop(const alt_bn128_G2 base, alt_bn128_G2 ¤t, alt_bn128_ate_ell_coeffs &c)
#define T(meth, val, expected)
void test_invariant() const
mnt6_Fq3 PY_twist_squared
std::vector< mnt6_affine_ate_coeffs > coeffs
bool operator==(const mnt6_ate_G1_precomp &other) const
std::vector< mnt6_ate_add_coeffs > add_coeffs
bool operator==(const mnt6_ate_G2_precomp &other) const
std::vector< mnt6_ate_dbl_coeffs > dbl_coeffs
bool operator==(const mnt6_ate_add_coeffs &other) const
bool operator==(const mnt6_ate_dbl_coeffs &other) const