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);
102 return (this->
QX == other.
QX &&
103 this->QY == other.QY &&
104 this->QY2 == other.QY2 &&
105 this->QX_over_twist == other.QX_over_twist &&
106 this->QY_over_twist == other.QY_over_twist &&
107 this->dbl_coeffs == other.dbl_coeffs &&
108 this->add_coeffs == other.add_coeffs);
152 for (
size_t i = 0; i < dbl_s; ++i)
167 for (
size_t i = 0; i < add_s; ++i)
182 enter_block(
"Call to mnt4_final_exponentiation_last_chunk");
192 mnt4_Fq4 result = w1_part * w0_part;
193 leave_block(
"Call to mnt4_final_exponentiation_last_chunk");
200 enter_block(
"Call to mnt4_final_exponentiation_first_chunk");
207 const mnt4_Fq4 elt_q2_over_elt = elt_q2 * elt_inv;
209 leave_block(
"Call to mnt4_final_exponentiation_first_chunk");
210 return elt_q2_over_elt;
229 enter_block(
"Call to mnt4_affine_ate_precompute_G1");
239 leave_block(
"Call to mnt4_affine_ate_precompute_G1");
245 enter_block(
"Call to mnt4_affine_ate_precompute_G2");
258 bool found_nonzero =
false;
260 std::vector<long> NAF =
find_wnaf(1, loop_count);
261 for (
long i = NAF.size() - 1; i >= 0; --i)
266 found_nonzero |= (NAF[i] != 0);
277 result.coeffs.push_back(c);
297 result.coeffs.push_back(c);
319 leave_block(
"Call to mnt4_affine_ate_precompute_G2");
326 enter_block(
"Call to mnt4_affine_ate_miller_loop");
330 bool found_nonzero =
false;
334 std::vector<long> NAF =
find_wnaf(1, loop_count);
335 for (
long i = NAF.size() - 1; i >= 0; --i)
340 found_nonzero |= (NAF[i] != 0);
351 f =
f.squared().mul_by_023(g_RR_at_P);
367 f =
f.mul_by_023(g_RQ_at_P);
382 leave_block(
"Call to mnt4_affine_ate_miller_loop");
397 printf(
"extended mnt4_G2 projective X/Y/Z/T:\n");
413 const mnt4_Fq2 X = current.X, Y = current.Y, Z = current.Z,
T = current.T;
423 current.X = -(E+E+E+E) + G;
424 current.Y = -
mnt4_Fq(
"8")*
D + F*(E+E-current.X);
425 current.Z = (Y+Z).squared() - C - Z.
squared();
426 current.T = current.Z.
squared();
428 dc.
c_H = (current.Z +
T).squared() - current.T -
A;
430 dc.
c_J = (F+
T).squared() - G -
A;
431 dc.
c_L = (F+
X).squared() - G -
B;
434 current.test_invariant();
442 const mnt4_Fq2 X1 = current.X, Y1 = current.Y, Z1 = current.Z, T1 = current.T;
443 const mnt4_Fq2 &x2 = base_X, &y2 = base_Y, &y2_squared = base_Y_squared;
446 const mnt4_Fq2 D = ((y2 + Z1).squared() - y2_squared - T1) * T1;
455 current.Y = L1 * (
V-current.X) - (Y1+Y1) * J;
456 current.Z = (Z1+H).squared() - T1 - I;
457 current.T = current.Z.
squared();
462 current.test_invariant();
504 bool found_one =
false;
506 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i)
518 result.dbl_coeffs.push_back(dc);
523 result.add_coeffs.push_back(ac);
531 mnt4_Fq2 RZ3_inv = RZ2_inv * RZ_inv;
532 mnt4_Fq2 minus_R_affine_X =
R.X * RZ2_inv;
533 mnt4_Fq2 minus_R_affine_Y = -
R.Y * RZ3_inv;
537 result.add_coeffs.push_back(ac);
553 bool found_one =
false;
558 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i)
576 f =
f.squared() * g_RR_at_P;
592 f = (
f * g_RnegR_at_P).inverse();
605 enter_block(
"Call to mnt4_ate_double_miller_loop");
612 bool found_one =
false;
617 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i)
641 f =
f.squared() * g_RR_at_P1 * g_RR_at_P2;
654 f =
f * g_RQ_at_P1 * g_RQ_at_P2;
668 f = (
f * g_RnegR_at_P1 * g_RnegR_at_P2).inverse();
671 leave_block(
"Call to mnt4_ate_double_miller_loop");
Fp2_model inverse() const
static Fp2_model< n, modulus > one()
Fp2_model squared() const
Fp4_model inverse() const
Fp4_model cyclotomic_exp(const bigint< m > &exponent) const
Fp4_model Frobenius_map(unsigned long power) const
static Fp4_model< n, modulus > one()
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,...)
mnt4_Fq4 mnt4_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)
bool mnt4_final_exponent_last_chunk_is_w0_neg
Fp_model< mnt4_q_limbs, mnt4_modulus_q > mnt4_Fq
mnt4_GT mnt4_reduced_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)
void consume_OUTPUT_NEWLINE(std::istream &in)
mnt4_G1_precomp mnt4_precompute_G1(const mnt4_G1 &P)
mnt4_Fq4 mnt4_double_miller_loop(const mnt4_G1_precomp &prec_P1, const mnt4_G2_precomp &prec_Q1, const mnt4_G1_precomp &prec_P2, const mnt4_G2_precomp &prec_Q2)
mnt4_affine_ate_G1_precomputation mnt4_affine_ate_precompute_G1(const mnt4_G1 &P)
mnt4_Fq4 mnt4_ate_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
Fp4_model< mnt4_q_limbs, mnt4_modulus_q > mnt4_Fq4
void consume_OUTPUT_SEPARATOR(std::istream &in)
mnt4_Fq4 mnt4_final_exponentiation_last_chunk(const mnt4_Fq4 &elt, const mnt4_Fq4 &elt_inv)
mnt4_G2_precomp mnt4_precompute_G2(const mnt4_G2 &Q)
mnt4_Fq4 mnt4_ate_miller_loop(const mnt4_ate_G1_precomp &prec_P, const mnt4_ate_G2_precomp &prec_Q)
bool mnt4_ate_is_loop_count_neg
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
bigint< mnt4_q_limbs > mnt4_final_exponent_last_chunk_abs_of_w0
void enter_block(const std::string &msg, const bool indent)
mnt4_Fq4 mnt4_miller_loop(const mnt4_G1_precomp &prec_P, const mnt4_G2_precomp &prec_Q)
bigint< mnt4_q_limbs > mnt4_final_exponent_last_chunk_w1
mnt4_Fq4 mnt4_ate_double_miller_loop(const mnt4_ate_G1_precomp &prec_P1, const mnt4_ate_G2_precomp &prec_Q1, const mnt4_ate_G1_precomp &prec_P2, const mnt4_ate_G2_precomp &prec_Q2)
mnt4_ate_G2_precomp mnt4_ate_precompute_G2(const mnt4_G2 &Q)
void doubling_step_for_flipped_miller_loop(const alt_bn128_Fq two_inv, alt_bn128_G2 ¤t, alt_bn128_ate_ell_coeffs &c)
bigint< mnt4_q_limbs > mnt4_ate_loop_count
mnt4_Fq4 mnt4_affine_ate_miller_loop(const mnt4_affine_ate_G1_precomputation &prec_P, const mnt4_affine_ate_G2_precomputation &prec_Q)
mnt4_GT mnt4_affine_reduced_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)
std::vector< long > find_wnaf(const size_t window_size, const bigint< n > &scalar)
mnt4_GT mnt4_final_exponentiation(const mnt4_Fq4 &elt)
void leave_block(const std::string &msg, const bool indent)
mnt4_Fq4 mnt4_final_exponentiation_first_chunk(const mnt4_Fq4 &elt, const mnt4_Fq4 &elt_inv)
mnt4_affine_ate_G2_precomputation mnt4_affine_ate_precompute_G2(const mnt4_G2 &Q)
mnt4_Fq2 mnt4_twist_coeff_a
Fp2_model< mnt4_q_limbs, mnt4_modulus_q > mnt4_Fq2
mnt4_ate_G1_precomp mnt4_ate_precompute_G1(const mnt4_G1 &P)
void consume_newline(std::istream &in)
void mixed_addition_step_for_flipped_miller_loop(const alt_bn128_G2 base, alt_bn128_G2 ¤t, alt_bn128_ate_ell_coeffs &c)
mnt4_GT mnt4_ate_reduced_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)
#define T(meth, val, expected)
void test_invariant() const
mnt4_Fq2 PY_twist_squared
std::vector< mnt4_affine_ate_coeffs > coeffs
bool operator==(const mnt4_ate_G1_precomp &other) const
std::vector< mnt4_ate_add_coeffs > add_coeffs
std::vector< mnt4_ate_dbl_coeffs > dbl_coeffs
bool operator==(const mnt4_ate_G2_precomp &other) const
bool operator==(const mnt4_ate_add_coeffs &other) const
bool operator==(const mnt4_ate_dbl_coeffs &other) const