Clearmatics Libff
0.1
C++ library for Finite Fields and Elliptic Curves
|
Go to the documentation of this file.
28 this->
PX == other.
PX && this->PY == other.
PY &&
56 this->
c_H == other.
c_H && this->c_4C == other.
c_4C &&
57 this->c_J == other.
c_J && this->c_L == other.
c_L);
82 return (this->
c_L1 == other.
c_L1 && this->c_RZ == other.
c_RZ);
103 this->
QX == other.
QX && this->QY == other.
QY &&
147 for (
size_t i = 0; i < dbl_s; ++i) {
161 for (
size_t i = 0; i < add_s; ++i) {
176 enter_block(
"Call to mnt6_final_exponentiation_last_chunk");
186 mnt6_Fq6 result = w1_part * w0_part;
187 leave_block(
"Call to mnt6_final_exponentiation_last_chunk");
195 enter_block(
"Call to mnt6_final_exponentiation_first_chunk");
202 const mnt6_Fq6 elt_q3_over_elt = elt_q3 * elt_inv;
206 const mnt6_Fq6 beta = alpha * elt_q3_over_elt;
207 leave_block(
"Call to mnt6_final_exponentiation_first_chunk");
217 const mnt6_Fq6 elt_inv_to_first_chunk =
220 elt_to_first_chunk, elt_inv_to_first_chunk);
231 enter_block(
"Call to mnt6_affine_ate_precompute_G1");
241 leave_block(
"Call to mnt6_affine_ate_precompute_G1");
248 enter_block(
"Call to mnt6_affine_ate_precompute_G2");
261 bool found_nonzero =
false;
263 std::vector<long> NAF =
find_wnaf(1, loop_count);
264 for (
long i = NAF.size() - 1; i >= 0; --i) {
265 if (!found_nonzero) {
267 found_nonzero |= (NAF[i] != 0);
279 result.
coeffs.push_back(c);
297 result.
coeffs.push_back(c);
319 leave_block(
"Call to mnt6_affine_ate_precompute_G2");
327 enter_block(
"Call to mnt6_affine_ate_miller_loop");
332 bool found_nonzero =
false;
335 std::vector<long> NAF =
find_wnaf(1, loop_count);
336 for (
long i = NAF.size() - 1; i >= 0; --i) {
337 if (!found_nonzero) {
339 found_nonzero |= (NAF[i] != 0);
380 leave_block(
"Call to mnt6_affine_ate_miller_loop");
395 printf(
"extended mnt6_G2 projective X/Y/Z/T:\n");
408 const mnt6_Fq3 X = current.
X, Y = current.
Y, Z = current.
Z, T = current.
T;
414 const mnt6_Fq3 E = (X + C).squared() - B - D;
418 current.
X = -(E + E + E + E) + G;
420 -
mnt6_Fq(
"8") * D + F * (E + E - current.
X);
421 current.
Z = (Y + Z).squared() - C - Z.
squared();
424 dc.
c_H = (current.
Z + T).squared() - current.
T - A;
425 dc.
c_4C = C + C + C + C;
426 dc.
c_J = (F + T).squared() - G - A;
427 dc.
c_L = (F + X).squared() - G - B;
441 const mnt6_Fq3 X1 = current.
X, Y1 = current.
Y, Z1 = current.
Z,
443 const mnt6_Fq3 &x2 = base_X, &y2 = base_Y, &y2_squared = base_Y_squared;
446 const mnt6_Fq3 D = ((y2 + Z1).squared() - y2_squared - T1) *
455 current.
X = L1.
squared() - J - (V + V);
457 L1 * (V - current.
X) - (Y1 + Y1) * J;
458 current.
Z = (Z1 + H).squared() - T1 - I;
509 bool found_one =
false;
510 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i) {
511 const bool bit = loop_count.
test_bit(i);
526 result.
QX, result.
QY, result.
QY2, R, ac);
534 mnt6_Fq3 RZ3_inv = RZ2_inv * RZ_inv;
535 mnt6_Fq3 minus_R_affine_X = R.
X * RZ2_inv;
536 mnt6_Fq3 minus_R_affine_Y = -R.
Y * RZ3_inv;
540 minus_R_affine_X, minus_R_affine_Y, minus_R_affine_Y2, R, ac);
558 bool found_one =
false;
564 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i) {
565 const bool bit = loop_count.
test_bit(i);
597 f = (f * g_RnegR_at_P).inverse();
611 enter_block(
"Call to mnt6_ate_double_miller_loop");
622 bool found_one =
false;
628 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i) {
629 const bool bit = loop_count.
test_bit(i);
652 f = f.
squared() * g_RR_at_P1 * g_RR_at_P2;
666 f = f * g_RQ_at_P1 * g_RQ_at_P2;
681 f = (f * g_RnegR_at_P1 * g_RnegR_at_P2).inverse();
684 leave_block(
"Call to mnt6_ate_double_miller_loop");
static Fp6_2over3_model< n, modulus > one()
bigint< mnt6_q_limbs > mnt6_ate_loop_count
mnt6_Fq3 PY_twist_squared
std::vector< mnt6_ate_dbl_coeffs > dbl_coeffs
void enter_block(const std::string &msg, const bool indent)
mnt6_ate_G2_precomp mnt6_ate_precompute_G2(const mnt6_G2 &Q)
static Fp3_model< n, modulus > one()
bigint< mnt6_q_limbs > mnt6_final_exponent_last_chunk_w1
std::vector< mnt6_ate_add_coeffs > add_coeffs
Fp_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq
void doubling_step_for_flipped_miller_loop(const alt_bn128_Fq two_inv, alt_bn128_G2 ¤t, alt_bn128_ate_ell_coeffs &c)
std::vector< mnt6_affine_ate_coeffs > coeffs
static const Fp_model< n, modulus > & zero()
mnt6_Fq6 mnt6_ate_miller_loop(const mnt6_ate_G1_precomp &prec_P, const mnt6_ate_G2_precomp &prec_Q)
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
mnt6_GT mnt6_affine_reduced_pairing(const mnt6_G1 &P, 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)
bool operator==(const mnt6_ate_dbl_coeffs &other) const
bool operator==(const mnt6_ate_G2_precomp &other) const
mnt6_GT mnt6_ate_reduced_pairing(const mnt6_G1 &P, const mnt6_G2 &Q)
mnt6_affine_ate_G2_precomputation mnt6_affine_ate_precompute_G2(const mnt6_G2 &Q)
mnt6_Fq6 mnt6_miller_loop(const mnt6_G1_precomp &prec_P, const mnt6_G2_precomp &prec_Q)
mnt6_Fq6 mnt6_ate_pairing(const mnt6_G1 &P, const mnt6_G2 &Q)
void to_affine_coordinates()
mnt6_GT mnt6_reduced_pairing(const mnt6_G1 &P, const mnt6_G2 &Q)
static constexpr size_t max_bits()
The number of bits representable by this bigint type.
mnt6_Fq6 mnt6_final_exponentiation_last_chunk(const mnt6_Fq6 &elt, const mnt6_Fq6 &elt_inv)
bool operator==(const mnt6_ate_G1_precomp &other) const
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)
mnt6_Fq3 mnt6_twist_coeff_a
mnt6_G1_precomp mnt6_precompute_G1(const mnt6_G1 &P)
mnt6_Fq6 mnt6_final_exponentiation_first_chunk(const mnt6_Fq6 &elt, const mnt6_Fq6 &elt_inv)
void consume_OUTPUT_SEPARATOR(std::istream &in)
Fp6_2over3_model Frobenius_map(unsigned long power) const
void test_invariant() const
Fp3_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq3
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)
Fp6_2over3_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq6
bool operator==(const mnt6_ate_add_coeffs &other) const
mnt6_G2_precomp mnt6_precompute_G2(const mnt6_G2 &Q)
mnt6_Fq6 mnt6_affine_ate_miller_loop(const mnt6_affine_ate_G1_precomputation &prec_P, const mnt6_affine_ate_G2_precomputation &prec_Q)
Fp6_2over3_model mul_by_2345(const Fp6_2over3_model &other) const
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
Fp3_model inverse() const
void consume_OUTPUT_NEWLINE(std::istream &in)
Fp6_2over3_model cyclotomic_exp(const bigint< m > &exponent) const
std::vector< long > find_wnaf(const size_t window_size, const bigint< n > &scalar)
mnt6_Fq6 mnt6_pairing(const mnt6_G1 &P, const mnt6_G2 &Q)
void leave_block(const std::string &msg, const bool indent)
bool mnt6_ate_is_loop_count_neg
bool test_bit(const std::size_t bitno) const
bool mnt6_final_exponent_last_chunk_is_w0_neg
bigint< mnt6_q_limbs > mnt6_final_exponent_last_chunk_abs_of_w0
void consume_newline(std::istream &in)
Fp3_model squared() const
mnt6_affine_ate_G1_precomputation mnt6_affine_ate_precompute_G1(const mnt6_G1 &P)
mnt6_GT mnt6_final_exponentiation(const mnt6_Fq6 &elt)
Fp6_2over3_model inverse() const
Fp6_2over3_model squared() const
void to_affine_coordinates()
mnt6_ate_G1_precomp mnt6_ate_precompute_G1(const mnt6_G1 &P)