Clearmatics Libff
0.1
C++ library for Finite Fields and Elliptic Curves
|
Go to the documentation of this file.
13 #ifdef PROFILE_OP_COUNTS
14 long long edwards_G2::add_cnt = 0;
15 long long edwards_G2::dbl_cnt = 0;
62 "(%Nd*z^2 + %Nd*z + %Nd , %Nd*z^2 + %Nd*z + %Nd)\n",
84 "(%Nd*z^2 + %Nd*z + %Nd : %Nd*z^2 + %Nd*z + %Nd : %Nd*z^2 + %Nd*z "
88 this->X.coeffs[1].as_bigint().data,
90 this->X.coeffs[0].as_bigint().data,
92 this->Y.coeffs[2].as_bigint().data,
94 this->Y.coeffs[1].as_bigint().data,
96 this->Y.coeffs[0].as_bigint().data,
98 this->Z.coeffs[2].as_bigint().data,
100 this->Z.coeffs[1].as_bigint().data,
102 this->Z.coeffs[0].as_bigint().data,
120 this->
X = tX * tZ_inv;
121 this->Y = tY * tZ_inv;
132 #if defined(DEBUG) && !defined(NDEBUG)
137 this->
X = this->
X * Z_inv;
138 this->
Y = this->
Y * Z_inv;
142 assert((*
this) == copy);
153 return (this->
Y.
is_zero() && this->Z.is_zero());
169 if ((this->
X * other.
Z) != (other.
X * this->Z)) {
174 if ((this->
Y * other.
Z) != (other.
Y * this->Z)) {
197 return this->
add(other);
207 return (*
this) + (-other);
212 #ifdef PROFILE_OP_COUNTS
231 const edwards_Fq3 I = (this->
X + this->
Y) * (other.
X + other.
Y) - C - D;
244 #ifdef PROFILE_OP_COUNTS
276 const edwards_Fq3 I = (this->
X + this->
Y) * (other.
X + other.
Y) - C - D;
289 #ifdef PROFILE_OP_COUNTS
325 (this->
X).Frobenius_map(1),
348 return (Z2 * (aY2 + X2 - dZ2) == X2 * Y2);
389 #ifdef USE_MIXED_ADDITION
403 in.read((
char *)&Y_lsb, 1);
421 #ifdef USE_MIXED_ADDITION
428 #ifdef NO_PT_COMPRESSION
438 #ifdef NO_PT_COMPRESSION
448 std::vector<edwards_Fq3> Z_vec;
449 Z_vec.reserve(vec.size());
451 for (
auto &el : vec) {
452 Z_vec.emplace_back(el.Z);
454 batch_invert<edwards_Fq3>(Z_vec);
458 for (
size_t i = 0; i < vec.size(); ++i) {
459 vec[i].X = vec[i].X * Z_vec[i];
460 vec[i].Y = vec[i].Y * Z_vec[i];
edwards_Fq edwards_twist_mul_by_d_c0
edwards_G2 mixed_add(const edwards_G2 &other) const
static Fp_model< n, modulus > random_element()
returns random element of Fp_model
static const edwards_G2 & one()
static void batch_to_special_all_non_zeros(std::vector< edwards_G2 > &vec)
static Fp3_model< n, modulus > one()
static edwards_G2 G2_zero
bool operator==(const edwards_G2 &other) const
edwards_G2 mul_by_q() const
edwards_G2 operator+(const edwards_G2 &other) const
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
static edwards_Fq3 mul_by_a(const edwards_Fq3 &elt)
edwards_G2 operator-() const
edwards_Fq edwards_twist_mul_by_q_Z
static const edwards_G2 & zero()
void to_affine_coordinates()
bool operator!=(const edwards_G2 &other) const
static std::vector< size_t > wnaf_window_table
static edwards_Fq3 mul_by_d(const edwards_Fq3 &elt)
void consume_OUTPUT_SEPARATOR(std::istream &in)
static const mp_size_t num_limbs
bool is_well_formed() const
void print_coordinates() const
edwards_Fq edwards_twist_mul_by_a_c0
Fp3_model< edwards_q_limbs, edwards_modulus_q > edwards_Fq3
edwards_Fq edwards_twist_mul_by_q_Y
bigint< n > as_bigint() const
void write_uncompressed(std::ostream &) const
edwards_G2 add(const edwards_G2 &other) const
edwards_Fq edwards_twist_mul_by_d_c1
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)
static void read_compressed(std::istream &, edwards_G2 &)
static edwards_G2 random_element()
void write_compressed(std::ostream &) const
edwards_Fq edwards_twist_mul_by_d_c2
static std::vector< size_t > fixed_base_exp_window_table
Fp3_model squared() const
static void read_uncompressed(std::istream &, edwards_G2 &)
static Fp3_model< n, modulus > zero()