Clearmatics Libff
0.1
C++ library for Finite Fields and Elliptic Curves
|
Go to the documentation of this file.
6 #ifdef PROFILE_OP_COUNTS
7 long long bls12_381_G2::add_cnt = 0;
8 long long bls12_381_G2::dbl_cnt = 0;
41 "(%Nd*z + %Nd , %Nd*z + %Nd)\n",
59 "(%Nd*z + %Nd : %Nd*z + %Nd : %Nd*z + %Nd)\n",
62 this->X.coeffs[0].as_bigint().data,
64 this->Y.coeffs[1].as_bigint().data,
66 this->Y.coeffs[0].as_bigint().data,
68 this->Z.coeffs[1].as_bigint().data,
70 this->Z.coeffs[0].as_bigint().data,
85 this->
X = this->
X * Z2_inv;
86 this->
Y = this->
Y * Z3_inv;
123 if (((this->
X * Z2_squared) != (other.
X * Z1_squared)) ||
124 ((this->
Y * Z2_cubed) != (other.
Y * Z1_cubed))) {
171 if (U1 == U2 && S1 == S2) {
206 return (*
this) + (-other);
211 return (*
this) + other;
247 if (this->
X == U2 && this->
Y == S2) {
252 #ifdef PROFILE_OP_COUNTS
276 Y3 = r * (V - X3) - Y3 - Y3;
285 #ifdef PROFILE_OP_COUNTS
312 eightC = eightC + eightC;
313 eightC = eightC + eightC;
328 (this->
Z).Frobenius_map(1));
422 in.read((
char *)&Y_lsb, 1);
445 #ifdef NO_PT_COMPRESSION
455 #ifdef NO_PT_COMPRESSION
464 std::vector<bls12_381_G2> &vec)
466 std::vector<bls12_381_Fq2> Z_vec;
467 Z_vec.reserve(vec.size());
469 for (
auto &el : vec) {
470 Z_vec.emplace_back(el.Z);
472 batch_invert<bls12_381_Fq2>(Z_vec);
476 for (
size_t i = 0; i < vec.size(); ++i) {
480 vec[i].X = vec[i].X * Z2;
481 vec[i].Y = vec[i].Y * Z3;
static const bls12_381_G2 & one()
bls12_381_Fq bls12_381_twist_mul_by_b_c1
bool operator!=(const bls12_381_G2 &other) const
static Fp_model< n, modulus > random_element()
returns random element of Fp_model
void write_uncompressed(std::ostream &) const
static const Fp2_model< n, modulus > & one()
bls12_381_Fq2 bls12_381_twist_coeff_b
bool is_in_safe_subgroup() const
Fp2_model< bls12_381_q_limbs, bls12_381_modulus_q > bls12_381_Fq2
static bigint< h_limbs > h
bls12_381_Fq2 bls12_381_twist_mul_by_q_X
static std::vector< std::size_t > wnaf_window_table
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
bls12_381_G2 mul_by_cofactor() const
bls12_381_Fq2 bls12_381_twist_mul_by_q_Y
static bls12_381_G2 G2_one
static bls12_381_Fq2 coeff_a
static void batch_to_special_all_non_zeros(std::vector< bls12_381_G2 > &vec)
Fp2_model inverse() const
void print_coordinates() const
bool is_well_formed() const
bls12_381_Fq bls12_381_twist_mul_by_b_c0
static const bls12_381_G2 & zero()
void consume_OUTPUT_SEPARATOR(std::istream &in)
static void read_compressed(std::istream &, bls12_381_G2 &)
static bls12_381_G2 random_element()
static const mp_size_t num_limbs
bls12_381_G2 mul_by_q() const
bool operator==(const bls12_381_G2 &other) const
static bls12_381_G2 G2_zero
bigint< n > as_bigint() const
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
Fp2_model squared() const
default is squared_complex
bls12_381_G2 add(const bls12_381_G2 &other) const
static void read_uncompressed(std::istream &, bls12_381_G2 &)
static const constexpr bigint< n > & mod
Fp2_model sqrt() const
HAS TO BE A SQUARE (else does not terminate)
static const Fp2_model< n, modulus > & zero()
static std::vector< std::size_t > fixed_base_exp_window_table
bls12_381_G2 operator+(const bls12_381_G2 &other) const
void write_compressed(std::ostream &) const
static bls12_381_Fq2 coeff_b
bls12_381_G2 operator-() const
static bls12_381_Fq2 mul_by_b(const bls12_381_Fq2 &elt)
void to_affine_coordinates()
bls12_381_G2 mixed_add(const bls12_381_G2 &other) const