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);
102 this->
QX == other.
QX && this->QY == other.
QY &&
146 for (
size_t i = 0; i < dbl_s; ++i) {
160 for (
size_t i = 0; i < add_s; ++i) {
175 enter_block(
"Call to mnt4_final_exponentiation_last_chunk");
185 mnt4_Fq4 result = w1_part * w0_part;
186 leave_block(
"Call to mnt4_final_exponentiation_last_chunk");
194 enter_block(
"Call to mnt4_final_exponentiation_first_chunk");
201 const mnt4_Fq4 elt_q2_over_elt = elt_q2 * elt_inv;
203 leave_block(
"Call to mnt4_final_exponentiation_first_chunk");
204 return elt_q2_over_elt;
213 const mnt4_Fq4 elt_inv_to_first_chunk =
216 elt_to_first_chunk, elt_inv_to_first_chunk);
227 enter_block(
"Call to mnt4_affine_ate_precompute_G1");
237 leave_block(
"Call to mnt4_affine_ate_precompute_G1");
244 enter_block(
"Call to mnt4_affine_ate_precompute_G2");
257 bool found_nonzero =
false;
259 std::vector<long> NAF =
find_wnaf(1, loop_count);
260 for (
long i = NAF.size() - 1; i >= 0; --i) {
261 if (!found_nonzero) {
263 found_nonzero |= (NAF[i] != 0);
275 result.
coeffs.push_back(c);
293 result.
coeffs.push_back(c);
314 leave_block(
"Call to mnt4_affine_ate_precompute_G2");
322 enter_block(
"Call to mnt4_affine_ate_miller_loop");
326 bool found_nonzero =
false;
330 std::vector<long> NAF =
find_wnaf(1, loop_count);
331 for (
long i = NAF.size() - 1; i >= 0; --i) {
332 if (!found_nonzero) {
334 found_nonzero |= (NAF[i] != 0);
375 leave_block(
"Call to mnt4_affine_ate_miller_loop");
390 printf(
"extended mnt4_G2 projective X/Y/Z/T:\n");
403 const mnt4_Fq2 X = current.
X, Y = current.
Y, Z = current.
Z, T = current.
T;
409 const mnt4_Fq2 E = (X + C).squared() - B - D;
413 current.
X = -(E + E + E + E) + G;
415 -
mnt4_Fq(
"8") * D + F * (E + E - current.
X);
416 current.
Z = (Y + Z).squared() - C - Z.
squared();
419 dc.
c_H = (current.
Z + T).squared() - current.
T - A;
420 dc.
c_4C = C + C + C + C;
421 dc.
c_J = (F + T).squared() - G - A;
422 dc.
c_L = (F + X).squared() - G - B;
436 const mnt4_Fq2 X1 = current.
X, Y1 = current.
Y, Z1 = current.
Z,
438 const mnt4_Fq2 &x2 = base_X, &y2 = base_Y, &y2_squared = base_Y_squared;
441 const mnt4_Fq2 D = ((y2 + Z1).squared() - y2_squared - T1) *
450 current.
X = L1.
squared() - J - (V + V);
452 L1 * (V - current.
X) - (Y1 + Y1) * J;
453 current.
Z = (Z1 + H).squared() - T1 - I;
501 bool found_one =
false;
503 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i) {
504 const bool bit = loop_count.
test_bit(i);
517 result.
QX, result.
QY, result.
QY2, R, ac);
525 mnt4_Fq2 RZ3_inv = RZ2_inv * RZ_inv;
526 mnt4_Fq2 minus_R_affine_X = R.
X * RZ2_inv;
527 mnt4_Fq2 minus_R_affine_Y = -R.
Y * RZ3_inv;
531 minus_R_affine_X, minus_R_affine_Y, minus_R_affine_Y2, R, ac);
549 bool found_one =
false;
554 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i) {
555 const bool bit = loop_count.
test_bit(i);
587 f = (f * g_RnegR_at_P).inverse();
601 enter_block(
"Call to mnt4_ate_double_miller_loop");
610 bool found_one =
false;
615 for (
long i = loop_count.
max_bits() - 1; i >= 0; --i) {
616 const bool bit = loop_count.
test_bit(i);
639 f = f.
squared() * g_RR_at_P1 * g_RR_at_P2;
653 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");
void test_invariant() const
Fp4_model Frobenius_map(unsigned long power) const
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_Fq4 mnt4_miller_loop(const mnt4_G1_precomp &prec_P, const mnt4_G2_precomp &prec_Q)
void enter_block(const std::string &msg, const bool indent)
bool operator==(const mnt4_ate_G1_precomp &other) const
static const Fp2_model< n, modulus > & one()
mnt4_affine_ate_G1_precomputation mnt4_affine_ate_precompute_G1(const mnt4_G1 &P)
void doubling_step_for_flipped_miller_loop(const alt_bn128_Fq two_inv, alt_bn128_G2 ¤t, alt_bn128_ate_ell_coeffs &c)
mnt4_Fq2 mnt4_twist_coeff_a
mnt4_Fq4 mnt4_final_exponentiation_last_chunk(const mnt4_Fq4 &elt, const mnt4_Fq4 &elt_inv)
static const Fp_model< n, modulus > & zero()
mnt4_GT mnt4_ate_reduced_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)
mnt4_ate_G2_precomp mnt4_ate_precompute_G2(const mnt4_G2 &Q)
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
Fp4_model cyclotomic_exp(const bigint< m > &exponent) const
void mixed_addition_step_for_flipped_miller_loop(const alt_bn128_G2 base, alt_bn128_G2 ¤t, alt_bn128_ate_ell_coeffs &c)
Fp4_model inverse() const
bigint< mnt4_q_limbs > mnt4_final_exponent_last_chunk_abs_of_w0
Fp2_model inverse() const
mnt4_GT mnt4_reduced_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)
Fp_model< mnt4_q_limbs, mnt4_modulus_q > mnt4_Fq
static constexpr size_t max_bits()
The number of bits representable by this bigint type.
mnt4_G1_precomp mnt4_precompute_G1(const mnt4_G1 &P)
bool operator==(const mnt4_ate_G2_precomp &other) const
void to_affine_coordinates()
mnt4_Fq4 mnt4_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)
void consume_OUTPUT_SEPARATOR(std::istream &in)
mnt4_affine_ate_G2_precomputation mnt4_affine_ate_precompute_G2(const mnt4_G2 &Q)
mnt4_Fq4 mnt4_ate_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)
Fp2_model< mnt4_q_limbs, mnt4_modulus_q > mnt4_Fq2
mnt4_Fq4 mnt4_final_exponentiation_first_chunk(const mnt4_Fq4 &elt, const mnt4_Fq4 &elt_inv)
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)
bool operator==(const mnt4_ate_dbl_coeffs &other) const
Fp4_model mul_by_023(const Fp4_model &other) const
std::vector< mnt4_ate_add_coeffs > add_coeffs
mnt4_G2_precomp mnt4_precompute_G2(const mnt4_G2 &Q)
bigint< mnt4_q_limbs > mnt4_ate_loop_count
bool mnt4_ate_is_loop_count_neg
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
void consume_OUTPUT_NEWLINE(std::istream &in)
std::vector< long > find_wnaf(const size_t window_size, const bigint< n > &scalar)
Fp4_model< mnt4_q_limbs, mnt4_modulus_q > mnt4_Fq4
bool mnt4_final_exponent_last_chunk_is_w0_neg
Fp2_model squared() const
default is squared_complex
bigint< mnt4_q_limbs > mnt4_final_exponent_last_chunk_w1
void leave_block(const std::string &msg, const bool indent)
Fp4_model squared() const
void to_affine_coordinates()
bool test_bit(const std::size_t bitno) const
mnt4_GT mnt4_final_exponentiation(const mnt4_Fq4 &elt)
mnt4_Fq4 mnt4_affine_ate_miller_loop(const mnt4_affine_ate_G1_precomputation &prec_P, const mnt4_affine_ate_G2_precomputation &prec_Q)
std::vector< mnt4_affine_ate_coeffs > coeffs
void consume_newline(std::istream &in)
bool operator==(const mnt4_ate_add_coeffs &other) const
std::vector< mnt4_ate_dbl_coeffs > dbl_coeffs
static Fp4_model< n, modulus > one()
mnt4_Fq4 mnt4_ate_miller_loop(const mnt4_ate_G1_precomp &prec_P, const mnt4_ate_G2_precomp &prec_Q)
mnt4_ate_G1_precomp mnt4_ate_precompute_G1(const mnt4_G1 &P)
mnt4_Fq2 PY_twist_squared
mnt4_GT mnt4_affine_reduced_pairing(const mnt4_G1 &P, const mnt4_G2 &Q)