13#ifdef PROFILE_OP_COUNTS
14long long bn128_G1::add_cnt = 0;
15long long bn128_G1::dbl_cnt = 0;
35 for (
size_t i = 0; i < v-1; ++i)
40 assert(check ==
bn::Fp(1));
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);
160 bn::Fp Z1sq, Z2sq, lhs, rhs;
202 if (this->
operator==(other))
208 return this->
add(other);
221 return (*
this) + (-other);
226#ifdef PROFILE_OP_COUNTS
230 bn::Fp 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::Fp this_coord[3], result_coord[3];
362#ifdef NO_PT_COMPRESSION
367 out.write((
char*) &gcopy.
X,
sizeof(gcopy.
X));
368 out.write((
char*) &gcopy.
Y,
sizeof(gcopy.
Y));
376 out.write((
char*) &gcopy.
X,
sizeof(gcopy.
X));
418 in.read((
char*)&is_zero, 1);
422#ifdef NO_PT_COMPRESSION
429 in.read((
char*) &g.
X,
sizeof(g.
X));
430 in.read((
char*) &g.
Y,
sizeof(g.
Y));
439 in.read((
char*)&tX,
sizeof(tX));
443 in.read((
char*)&Y_lsb, 1);
455 g.
Y = bn128_G1::sqrt(tY2);
456 if ((((
unsigned char*)&g.
Y)[0] & 1) != Y_lsb)
476std::ostream&
operator<<(std::ostream& out,
const std::vector<bn128_G1> &v)
478 out << v.size() <<
"\n";
486std::istream&
operator>>(std::istream& in, std::vector<bn128_G1> &v)
495 for (
size_t i = 0; i <
s; ++i)
507 std::vector<bn::Fp> Z_vec;
508 Z_vec.reserve(vec.size());
512 Z_vec.emplace_back(el.Z);
518 for (
size_t i = 0; i < vec.size(); ++i)
static Fp_model< n, modulus > random_element()
bool is_well_formed() const
void print_coordinates() const
static std::vector< size_t > wnaf_window_table
bool operator==(const bn128_G1 &other) const
bn128_G1 add(const bn128_G1 &other) const
bn128_G1 operator-() const
bn128_G1 operator+(const bn128_G1 &other) const
bn128_G1 mixed_add(const bn128_G1 &other) const
void to_affine_coordinates()
static void batch_to_special_all_non_zeros(std::vector< bn128_G1 > &vec)
static std::vector< size_t > fixed_base_exp_window_table
bool operator!=(const bn128_G1 &other) const
static bn128_G1 random_element()
void fill_coord(bn::Fp coord[3]) const
static void(* add)(Fp &out, const Fp &x, const Fp &y)
static void(* mul)(Fp &out, const Fp &x, const Fp &y)
MIE_FORCE_INLINE bool isZero() const
static void(* neg)(Fp &out, const Fp &x)
static void(* sub)(Fp &out, const Fp &x, const Fp &y)
std::string toString(int base=10) const
static void square(Fp &out, const Fp &x)
void ECDouble(FF *out, const FF *in)
void ECAdd(FF *out, const FF *a, const FF *b)
mie::Vuint bn128_Fq_t_minus_1_over_2
void consume_OUTPUT_NEWLINE(std::istream &in)
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)
void consume_newline(std::istream &in)
T power(const T &x, const S &y)