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 mnt6_G1::add_cnt = 0;
21 long long mnt6_G1::dbl_cnt = 0;
61 "(%Nd : %Nd : %Nd)\n",
64 this->Y.as_bigint().data,
66 this->Z.as_bigint().data,
79 this->
X = this->
X * Z_inv;
80 this->
Y = this->
Y * Z_inv;
94 return (this->
X.
is_zero() && this->Z.is_zero());
110 if ((this->
X * other.
Z) != (other.
X * this->Z)) {
115 if ((this->
Y * other.
Z) != (other.
Y * this->Z)) {
155 const mnt6_Fq X1Z2 = (this->
X) * (other.
Z);
157 const mnt6_Fq X2Z1 = (this->
Z) * (other.
X);
162 const mnt6_Fq Y1Z2 = (this->
Y) * (other.
Z);
164 const mnt6_Fq Y2Z1 = (this->
Z) * (other.
Y);
166 if (X1Z2 == X2Z1 && Y1Z2 == Y2Z1) {
169 const mnt6_Fq XX = (this->
X).squared();
171 const mnt6_Fq ZZ = (this->
Z).squared();
174 const mnt6_Fq Y1Z1 = (this->
Y) * (this->
Z);
192 const mnt6_Fq Y3 = w * (B -
h) - (RR + RR);
201 const mnt6_Fq Z1Z2 = (this->
Z) * (other.
Z);
215 const mnt6_Fq A = uu * Z1Z2 - (vvv + R + R);
219 const mnt6_Fq Y3 = u * (R - A) - vvv * Y1Z2;
233 return (*
this) + (-other);
251 if (this->
operator==(other)) {
255 #ifdef PROFILE_OP_COUNTS
262 const mnt6_Fq Y1Z2 = (this->
Y) * (other.
Z);
264 const mnt6_Fq X1Z2 = (this->
X) * (other.
Z);
266 const mnt6_Fq Z1Z2 = (this->
Z) * (other.
Z);
268 const mnt6_Fq u = (other.
Y) * (this->
Z) - Y1Z2;
272 const mnt6_Fq v = (other.
X) * (this->
Z) - X1Z2;
280 const mnt6_Fq A = uu * Z1Z2 - (vvv + R + R);
284 const mnt6_Fq Y3 = u * (R - A) - vvv * Y1Z2;
293 #ifdef PROFILE_OP_COUNTS
315 const mnt6_Fq X2Z1 = (this->
Z) * (other.
X);
322 const mnt6_Fq Y2Z1 = (this->
Z) * (other.
Y);
324 if (X1Z2 == X2Z1 && Y1Z2 == Y2Z1) {
341 mnt6_Fq A = uu * this->
Z - vvv - R - R;
345 mnt6_Fq Y3 = u * (R - A) - vvv * this->Y;
354 #ifdef PROFILE_OP_COUNTS
364 const mnt6_Fq XX = (this->
X).squared();
366 const mnt6_Fq ZZ = (this->
Z).squared();
369 const mnt6_Fq Y1Z1 = (this->
Y) * (this->
Z);
387 const mnt6_Fq Y3 = w * (B -
h) - (RR + RR);
483 in.read((
char *)&Y_lsb, 1);
492 if ((tY.
as_bigint().data[0] & 1) != Y_lsb) {
509 std::vector<mnt6_Fq> Z_vec;
510 Z_vec.reserve(vec.size());
512 for (
auto &el : vec) {
513 Z_vec.emplace_back(el.Z);
515 batch_invert<mnt6_Fq>(Z_vec);
519 for (
size_t i = 0; i < vec.size(); ++i) {
520 vec[i] =
mnt6_G1(vec[i].
X * Z_vec[i], vec[i].
Y * Z_vec[i],
one);
526 #ifdef NO_PT_COMPRESSION
536 #ifdef NO_PT_COMPRESSION
mnt6_G1 mixed_add(const mnt6_G1 &other) const
mnt6_G1 operator+(const mnt6_G1 &other) const
static Fp_model< n, modulus > random_element()
returns random element of Fp_model
mnt6_G1 mul_by_cofactor() const
static void read_uncompressed(std::istream &, mnt6_G1 &)
Fp_model< mnt6_q_limbs, mnt6_modulus_q > mnt6_Fq
static const Fp_model< n, modulus > & zero()
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
mnt6_G1 operator-() const
void to_affine_coordinates()
bool operator==(const mnt6_G1 &other) const
Fp_model sqrt() const
HAS TO BE A SQUARE (else does not terminate)
static const Fp_model< n, modulus > & one()
mnt6_G1 add(const mnt6_G1 &other) const
bool is_in_safe_subgroup() const
bool operator!=(const mnt6_G1 &other) const
static std::vector< size_t > wnaf_window_table
void print_coordinates() const
static bigint< h_limbs > h
static std::vector< size_t > fixed_base_exp_window_table
void consume_OUTPUT_SEPARATOR(std::istream &in)
static const mp_size_t num_limbs
static void read_compressed(std::istream &, mnt6_G1 &)
static const mnt6_G1 & zero()
bigint< n > as_bigint() const
static const mnt6_G1 & one()
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
static mnt6_G1 random_element()
void write_compressed(std::ostream &) const
bool is_well_formed() const
void write_uncompressed(std::ostream &) const
static void batch_to_special_all_non_zeros(std::vector< mnt6_G1 > &vec)