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 mnt4_G2::add_cnt = 0;
21 long long mnt4_G2::dbl_cnt = 0;
62 "(%Nd*z + %Nd , %Nd*z + %Nd)\n",
80 "(%Nd*z + %Nd : %Nd*z + %Nd : %Nd*z + %Nd)\n",
83 this->X.coeffs[0].as_bigint().data,
85 this->Y.coeffs[1].as_bigint().data,
87 this->Y.coeffs[0].as_bigint().data,
89 this->Z.coeffs[1].as_bigint().data,
91 this->Z.coeffs[0].as_bigint().data,
119 return (this->
X.
is_zero() && this->Z.is_zero());
135 if ((this->
X * other.
Z) != (other.
X * this->Z)) {
140 if ((this->
Y * other.
Z) != (other.
Y * this->Z)) {
192 if (X1Z2 == X2Z1 && Y1Z2 == Y2Z1) {
218 const mnt4_Fq2 Y3 = w * (B -
h) - (RR + RR);
241 const mnt4_Fq2 A = uu * Z1Z2 - (vvv + R + R);
245 const mnt4_Fq2 Y3 = u * (R - A) - vvv * Y1Z2;
259 return (*
this) + (-other);
277 if (this->
operator==(other)) {
281 #ifdef PROFILE_OP_COUNTS
294 const mnt4_Fq2 u = (other.
Y) * (this->
Z) - Y1Z2;
298 const mnt4_Fq2 v = (other.
X) * (this->
Z) - X1Z2;
306 const mnt4_Fq2 A = uu * Z1Z2 - (vvv + R + R);
310 const mnt4_Fq2 Y3 = u * (R - A) - vvv * Y1Z2;
319 #ifdef PROFILE_OP_COUNTS
350 if (X1Z2 == X2Z1 && Y1Z2 == Y2Z1) {
367 const mnt4_Fq2 A = uu * this->
Z - vvv - R - R;
371 const mnt4_Fq2 Y3 = u * (R - A) - vvv * this->Y;
380 #ifdef PROFILE_OP_COUNTS
413 const mnt4_Fq2 Y3 = w * (B -
h) - (RR + RR);
426 (this->
Z).Frobenius_map(1));
517 in.read((
char *)&Y_lsb, 1);
543 std::vector<mnt4_Fq2> Z_vec;
544 Z_vec.reserve(vec.size());
546 for (
auto &el : vec) {
547 Z_vec.emplace_back(el.Z);
549 batch_invert<mnt4_Fq2>(Z_vec);
553 for (
size_t i = 0; i < vec.size(); ++i) {
554 vec[i] =
mnt4_G2(vec[i].
X * Z_vec[i], vec[i].
Y * Z_vec[i],
one);
560 #ifdef NO_PT_COMPRESSION
570 #ifdef NO_PT_COMPRESSION
mnt4_Fq mnt4_twist_mul_by_b_c1
mnt4_Fq2 mnt4_twist_coeff_b
mnt4_Fq mnt4_twist_mul_by_a_c1
void write_compressed(std::ostream &) const
void print_coordinates() const
static Fp_model< n, modulus > random_element()
returns random element of Fp_model
mnt4_G2 add(const mnt4_G2 &other) const
static const Fp2_model< n, modulus > & one()
static bigint< h_limbs > h
mnt4_Fq2 mnt4_twist_coeff_a
static void read_compressed(std::istream &, mnt4_G2 &)
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
bool operator!=(const mnt4_G2 &other) const
bool is_well_formed() const
mnt4_Fq mnt4_twist_mul_by_q_X
mnt4_G2 operator+(const mnt4_G2 &other) const
void write_uncompressed(std::ostream &) const
Fp2_model inverse() const
void to_affine_coordinates()
static void batch_to_special_all_non_zeros(std::vector< mnt4_G2 > &vec)
static mnt4_G2 random_element()
static std::vector< size_t > fixed_base_exp_window_table
void consume_OUTPUT_SEPARATOR(std::istream &in)
static const mp_size_t num_limbs
Fp2_model< mnt4_q_limbs, mnt4_modulus_q > mnt4_Fq2
bigint< n > as_bigint() const
mnt4_Fq mnt4_twist_mul_by_b_c0
static void read_uncompressed(std::istream &, mnt4_G2 &)
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
static const mnt4_G2 & one()
mnt4_Fq mnt4_twist_mul_by_q_Y
mnt4_G2 mixed_add(const mnt4_G2 &other) const
Fp2_model squared() const
default is squared_complex
static mnt4_Fq2 mul_by_a(const mnt4_Fq2 &elt)
mnt4_G2 operator-() const
static const constexpr bigint< n > & mod
bool operator==(const mnt4_G2 &other) const
static std::vector< size_t > wnaf_window_table
Fp2_model sqrt() const
HAS TO BE A SQUARE (else does not terminate)
mnt4_Fq mnt4_twist_mul_by_a_c0
static const Fp2_model< n, modulus > & zero()
mnt4_G2 mul_by_cofactor() const
bool is_in_safe_subgroup() const
static mnt4_Fq2 mul_by_b(const mnt4_Fq2 &elt)
static const mnt4_G2 & zero()