13#ifdef PROFILE_OP_COUNTS
14long long bn128_G2::add_cnt = 0;
15long long bn128_G2::dbl_cnt = 0;
35 for (
size_t i = 0; i < v-1; ++i)
93 copy.to_affine_coordinates();
94 std::cout <<
"(" << copy.X.toString(10) <<
" : " << copy.Y.toString(10) <<
" : " << copy.Z.toString(10) <<
")\n";
106 std::cout <<
"(" <<
X.toString(10) <<
" : " <<
Y.
toString(10) <<
" : " <<
Z.
toString(10) <<
")\n";
138 return (this->
is_zero() || this->
Z == 1);
202 if (this->
operator==(other))
208 return this->
add(other);
221 return (*
this) + (-other);
226#ifdef PROFILE_OP_COUNTS
230 bn::Fp2 this_coord[3], other_coord[3], result_coord[3];
232 other.fill_coord(other_coord);
255 assert(other.is_special());
281 if (U1 == U2 && S1 == S2)
287#ifdef PROFILE_OP_COUNTS
328#ifdef PROFILE_OP_COUNTS
332 bn::Fp2 this_coord[3], result_coord[3];
393#ifdef NO_PT_COMPRESSION
399 out.write((
char*) &gcopy.
X.
a_,
sizeof(gcopy.
X.
a_));
400 out.write((
char*) &gcopy.
X.
b_,
sizeof(gcopy.
X.
b_));
401 out.write((
char*) &gcopy.
Y.
a_,
sizeof(gcopy.
Y.
a_));
402 out.write((
char*) &gcopy.
Y.
b_,
sizeof(gcopy.
Y.
b_));
410 out.write((
char*) &gcopy.
X.
a_,
sizeof(gcopy.
X.
a_));
411 out.write((
char*) &gcopy.
X.
b_,
sizeof(gcopy.
X.
b_));
422 in.read((
char*)&is_zero, 1);
426#ifdef NO_PT_COMPRESSION
437 in.read((
char*) &g.
X.
a_,
sizeof(g.
X.
a_));
438 in.read((
char*) &g.
X.
b_,
sizeof(g.
X.
b_));
439 in.read((
char*) &g.
Y.
a_,
sizeof(g.
Y.
a_));
440 in.read((
char*) &g.
Y.
b_,
sizeof(g.
Y.
b_));
451 in.read((
char*)&tX.
a_,
sizeof(tX.
a_));
452 in.read((
char*)&tX.
b_,
sizeof(tX.
b_));
456 in.read((
char*)&Y_lsb, 1);
468 g.
Y = bn128_G2::sqrt(tY2);
469 if ((((
unsigned char*)&g.
Y.
a_)[0] & 1) != Y_lsb)
491 std::vector<bn::Fp2> Z_vec;
492 Z_vec.reserve(vec.size());
496 Z_vec.emplace_back(el.Z);
502 for (
size_t i = 0; i < vec.size(); ++i)
static Fp_model< n, modulus > random_element()
bn128_G2 mixed_add(const bn128_G2 &other) const
static bn128_G2 random_element()
bool is_well_formed() const
static void batch_to_special_all_non_zeros(std::vector< bn128_G2 > &vec)
static std::vector< size_t > fixed_base_exp_window_table
void print_coordinates() const
bool operator==(const bn128_G2 &other) const
bn128_G2 operator-() const
bn128_G2 operator+(const bn128_G2 &other) const
bool operator!=(const bn128_G2 &other) const
static std::vector< size_t > wnaf_window_table
void to_affine_coordinates()
bn128_G2 add(const bn128_G2 &other) const
void fill_coord(bn::Fp2 coord[3]) const
void ECDouble(FF *out, const FF *in)
void ECAdd(FF *out, const FF *a, const FF *b)
bn::Fp2 bn128_twist_coeff_b
void bn_batch_invert(std::vector< FieldT > &vec)
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
void consume_OUTPUT_SEPARATOR(std::istream &in)
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
bn::Fp2 bn128_Fq2_nqr_to_t
mie::Vuint bn128_Fq2_t_minus_1_over_2
T power(const T &x, const S &y)
std::string toString(int base=10) const
static void neg(Fp2T &z, const Fp2T &x)
static void(* square)(Fp2T &z, const Fp2T &x)
static void(* sub)(Fp2T &z, const Fp2T &x, const Fp2T &y)
static void(* add)(Fp2T &z, const Fp2T &x, const Fp2T &y)
static void(* mul)(Fp2T &z, const Fp2T &x, const Fp2T &y)