Clearmatics Libff
0.1
C++ library for Finite Fields and Elliptic Curves
|
Go to the documentation of this file.
19 #ifdef PROFILE_OP_COUNTS
20 long long mnt6_G2::add_cnt = 0;
21 long long mnt6_G2::dbl_cnt = 0;
64 "(%Nd*z^2 + %Nd*z + %Nd , %Nd*z^2 + %Nd*z + %Nd)\n",
86 "(%Nd*z^2 + %Nd*z + %Nd : %Nd*z^2 + %Nd*z + %Nd : %Nd*z^2 + %Nd*z "
90 this->X.coeffs[1].as_bigint().data,
92 this->X.coeffs[0].as_bigint().data,
94 this->Y.coeffs[2].as_bigint().data,
96 this->Y.coeffs[1].as_bigint().data,
98 this->Y.coeffs[0].as_bigint().data,
100 this->Z.coeffs[2].as_bigint().data,
102 this->Z.coeffs[1].as_bigint().data,
104 this->Z.coeffs[0].as_bigint().data,
117 this->
X = this->
X * Z_inv;
118 this->
Y = this->
Y * Z_inv;
133 return (this->
X.
is_zero() && this->Z.is_zero());
149 if ((this->
X * other.
Z) != (other.
X * this->Z)) {
154 if ((this->
Y * other.
Z) != (other.
Y * this->Z)) {
205 if (X1Z2 == X2Z1 && Y1Z2 == Y2Z1) {
231 const mnt6_Fq3 Y3 = w * (B -
h) - (RR + RR);
254 const mnt6_Fq3 A = uu * Z1Z2 - (vvv + R + R);
258 const mnt6_Fq3 Y3 = u * (R - A) - vvv * Y1Z2;
272 return (*
this) + (-other);
290 if (this->
operator==(other)) {
294 #ifdef PROFILE_OP_COUNTS
307 const mnt6_Fq3 u = (other.
Y) * (this->
Z) - Y1Z2;
311 const mnt6_Fq3 v = (other.
X) * (this->
Z) - X1Z2;
319 const mnt6_Fq3 A = uu * Z1Z2 - (vvv + R + R);
323 const mnt6_Fq3 Y3 = u * (R - A) - vvv * Y1Z2;
332 #ifdef PROFILE_OP_COUNTS
363 if (X1Z2 == X2Z1 && Y1Z2 == Y2Z1) {
380 const mnt6_Fq3 A = uu * this->
Z - vvv - R - R;
384 const mnt6_Fq3 Y3 = u * (R - A) - vvv * this->Y;
393 #ifdef PROFILE_OP_COUNTS
426 const mnt6_Fq3 Y3 = w * (B -
h) - (RR + RR);
439 (this->
Z).Frobenius_map(1));
533 in.read((
char *)&Y_lsb, 1);
560 std::vector<mnt6_Fq3> Z_vec;
561 Z_vec.reserve(vec.size());
563 for (
auto &el : vec) {
564 Z_vec.emplace_back(el.Z);
566 batch_invert<mnt6_Fq3>(Z_vec);
570 for (
size_t i = 0; i < vec.size(); ++i) {
571 vec[i] =
mnt6_G2(vec[i].
X * Z_vec[i], vec[i].
Y * Z_vec[i],
one);
577 #ifdef NO_PT_COMPRESSION
587 #ifdef NO_PT_COMPRESSION
bool is_in_safe_subgroup() const
mnt6_Fq mnt6_twist_mul_by_a_c0
mnt6_Fq mnt6_twist_mul_by_b_c2
static Fp_model< n, modulus > random_element()
returns random element of Fp_model
static const mnt6_G2 & one()
static Fp3_model< n, modulus > one()
mnt6_Fq mnt6_twist_mul_by_b_c1
mnt6_Fq mnt6_twist_mul_by_q_Y
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
mnt6_Fq mnt6_twist_mul_by_a_c1
mnt6_Fq mnt6_twist_mul_by_q_X
mnt6_G2 operator-() const
mnt6_Fq3 mnt6_twist_coeff_b
void print_coordinates() const
bool operator!=(const mnt6_G2 &other) const
bool is_well_formed() const
mnt6_Fq3 mnt6_twist_coeff_a
bool operator==(const mnt6_G2 &other) const
void consume_OUTPUT_SEPARATOR(std::istream &in)
void write_uncompressed(std::ostream &) const
static const mp_size_t num_limbs
Fp3_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq3
static std::vector< size_t > fixed_base_exp_window_table
static const mnt6_G2 & zero()
mnt6_Fq mnt6_twist_mul_by_a_c2
static std::vector< size_t > wnaf_window_table
bigint< n > as_bigint() const
static void read_uncompressed(std::istream &, mnt6_G2 &)
static mnt6_Fq3 mul_by_a(const mnt6_Fq3 &elt)
void write_compressed(std::ostream &) const
static bigint< h_limbs > h
mnt6_G2 operator+(const mnt6_G2 &other) const
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
Fp3_model inverse() const
Fp3_model sqrt() const
HAS TO BE A SQUARE (else does not terminate)
mnt6_G2 mul_by_cofactor() const
static void batch_to_special_all_non_zeros(std::vector< mnt6_G2 > &vec)
static void read_compressed(std::istream &, mnt6_G2 &)
static const constexpr bigint< n > & mod
mnt6_G2 add(const mnt6_G2 &other) const
static mnt6_G2 random_element()
mnt6_G2 mixed_add(const mnt6_G2 &other) const
Fp3_model squared() const
static mnt6_Fq3 mul_by_b(const mnt6_Fq3 &elt)
void to_affine_coordinates()
static Fp3_model< n, modulus > zero()
mnt6_Fq mnt6_twist_mul_by_b_c0