Clearmatics Libff  0.1
C++ library for Finite Fields and Elliptic Curves
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
libff::alt_bn128_G2 Class Reference

#include <alt_bn128_g2.hpp>

Collaboration diagram for libff::alt_bn128_G2:
Collaboration graph
[legend]

Public Types

typedef alt_bn128_Fq base_field
 
typedef alt_bn128_Fq2 twist_field
 
typedef alt_bn128_Fr scalar_field
 

Public Member Functions

 alt_bn128_G2 ()
 
 alt_bn128_G2 (const alt_bn128_Fq2 &X, const alt_bn128_Fq2 &Y, const alt_bn128_Fq2 &Z)
 
void print () const
 
void print_coordinates () const
 
void to_affine_coordinates ()
 
void to_special ()
 
bool is_special () const
 
bool is_zero () const
 
bool operator== (const alt_bn128_G2 &other) const
 
bool operator!= (const alt_bn128_G2 &other) const
 
alt_bn128_G2 operator+ (const alt_bn128_G2 &other) const
 
alt_bn128_G2 operator- () const
 
alt_bn128_G2 operator- (const alt_bn128_G2 &other) const
 
alt_bn128_G2 add (const alt_bn128_G2 &other) const
 
alt_bn128_G2 mixed_add (const alt_bn128_G2 &other) const
 
alt_bn128_G2 dbl () const
 
alt_bn128_G2 mul_by_q () const
 
alt_bn128_G2 mul_by_cofactor () const
 
bool is_well_formed () const
 
bool is_in_safe_subgroup () const
 
void write_uncompressed (std::ostream &) const
 
void write_compressed (std::ostream &) const
 

Static Public Member Functions

static alt_bn128_Fq2 mul_by_b (const alt_bn128_Fq2 &elt)
 
static const alt_bn128_G2zero ()
 
static const alt_bn128_G2one ()
 
static alt_bn128_G2 random_element ()
 
static size_t size_in_bits ()
 
static bigint< base_field::num_limbsbase_field_char ()
 
static bigint< scalar_field::num_limbsorder ()
 
static void read_uncompressed (std::istream &, alt_bn128_G2 &)
 
static void read_compressed (std::istream &, alt_bn128_G2 &)
 
static void batch_to_special_all_non_zeros (std::vector< alt_bn128_G2 > &vec)
 

Public Attributes

alt_bn128_Fq2 X
 
alt_bn128_Fq2 Y
 
alt_bn128_Fq2 Z
 

Static Public Attributes

static std::vector< size_t > wnaf_window_table
 
static std::vector< size_t > fixed_base_exp_window_table
 
static alt_bn128_G2 G2_zero
 
static alt_bn128_G2 G2_one
 
static alt_bn128_Fq2 coeff_a
 
static alt_bn128_Fq2 coeff_b
 
static const mp_size_t h_bitcount = 256
 
static const mp_size_t h_limbs
 
static bigint< h_limbsh
 

Detailed Description

Definition at line 21 of file alt_bn128_g2.hpp.

Member Typedef Documentation

◆ base_field

Definition at line 35 of file alt_bn128_g2.hpp.

◆ scalar_field

Definition at line 37 of file alt_bn128_g2.hpp.

◆ twist_field

Definition at line 36 of file alt_bn128_g2.hpp.

Constructor & Destructor Documentation

◆ alt_bn128_G2() [1/2]

libff::alt_bn128_G2::alt_bn128_G2 ( )

Definition at line 29 of file alt_bn128_g2.cpp.

30 {
31  this->X = G2_zero.X;
32  this->Y = G2_zero.Y;
33  this->Z = G2_zero.Z;
34 }
Here is the caller graph for this function:

◆ alt_bn128_G2() [2/2]

libff::alt_bn128_G2::alt_bn128_G2 ( const alt_bn128_Fq2 X,
const alt_bn128_Fq2 Y,
const alt_bn128_Fq2 Z 
)
inline

Definition at line 49 of file alt_bn128_g2.hpp.

51  : X(X), Y(Y), Z(Z){};

Member Function Documentation

◆ add()

alt_bn128_G2 libff::alt_bn128_G2::add ( const alt_bn128_G2 other) const

Definition at line 166 of file alt_bn128_g2.cpp.

167 {
168  // handle special cases having to do with O
169  if (this->is_zero()) {
170  return other;
171  }
172 
173  if (other.is_zero()) {
174  return *this;
175  }
176 
177  // no need to handle points of order 2,4
178  // (they cannot exist in a prime-order subgroup)
179 
180  // check for doubling case
181 
182  // using Jacobian coordinates so:
183  // (X1:Y1:Z1) = (X2:Y2:Z2)
184  // iff
185  // X1/Z1^2 == X2/Z2^2 and Y1/Z1^3 == Y2/Z2^3
186  // iff
187  // X1 * Z2^2 == X2 * Z1^2 and Y1 * Z2^3 == Y2 * Z1^3
188 
189  const alt_bn128_Fq2 Z1Z1 = (this->Z).squared();
190  const alt_bn128_Fq2 Z2Z2 = (other.Z).squared();
191 
192  const alt_bn128_Fq2 U1 = this->X * Z2Z2;
193  const alt_bn128_Fq2 U2 = other.X * Z1Z1;
194 
195  const alt_bn128_Fq2 Z1_cubed = (this->Z) * Z1Z1;
196  const alt_bn128_Fq2 Z2_cubed = (other.Z) * Z2Z2;
197 
198  // S1 = Y1 * Z2 * Z2Z2
199  const alt_bn128_Fq2 S1 = (this->Y) * Z2_cubed;
200  // S2 = Y2 * Z1 * Z1Z1
201  const alt_bn128_Fq2 S2 = (other.Y) * Z1_cubed;
202 
203  if (U1 == U2 && S1 == S2) {
204  // dbl case; nothing of above can be reused
205  return this->dbl();
206  }
207 
208 #ifdef PROFILE_OP_COUNTS
209  this->add_cnt++;
210 #endif
211 
212  // rest of add case
213  const alt_bn128_Fq2 H = U2 - U1; // H = U2-U1
214  const alt_bn128_Fq2 S2_minus_S1 = S2 - S1;
215  // I = (2 * H)^2
216  const alt_bn128_Fq2 I = (H + H).squared();
217  // J = H * I
218  const alt_bn128_Fq2 J = H * I;
219  // r = 2 * (S2-S1)
220  const alt_bn128_Fq2 r = S2_minus_S1 + S2_minus_S1;
221  // V = U1 * I
222  const alt_bn128_Fq2 V = U1 * I;
223  // X3 = r^2 - J - 2 * V
224  const alt_bn128_Fq2 X3 = r.squared() - J - (V + V);
225  const alt_bn128_Fq2 S1_J = S1 * J;
226  // Y3 = r * (V-X3)-2 S1 J
227  const alt_bn128_Fq2 Y3 = r * (V - X3) - (S1_J + S1_J);
228  // Z3 = ((Z1+Z2)^2-Z1Z1-Z2Z2) * H
229  const alt_bn128_Fq2 Z3 = ((this->Z + other.Z).squared() - Z1Z1 - Z2Z2) * H;
230 
231  return alt_bn128_G2(X3, Y3, Z3);
232 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ base_field_char()

static bigint<base_field::num_limbs> libff::alt_bn128_G2::base_field_char ( )
inlinestatic

Definition at line 85 of file alt_bn128_g2.hpp.

86  {
87  return base_field::field_char();
88  }
Here is the call graph for this function:

◆ batch_to_special_all_non_zeros()

void libff::alt_bn128_G2::batch_to_special_all_non_zeros ( std::vector< alt_bn128_G2 > &  vec)
static

Definition at line 486 of file alt_bn128_g2.cpp.

488 {
489  std::vector<alt_bn128_Fq2> Z_vec;
490  Z_vec.reserve(vec.size());
491 
492  for (auto &el : vec) {
493  Z_vec.emplace_back(el.Z);
494  }
495  batch_invert<alt_bn128_Fq2>(Z_vec);
496 
498 
499  for (size_t i = 0; i < vec.size(); ++i) {
500  const alt_bn128_Fq2 Z2 = Z_vec[i].squared();
501  const alt_bn128_Fq2 Z3 = Z_vec[i] * Z2;
502 
503  vec[i].X = vec[i].X * Z2;
504  vec[i].Y = vec[i].Y * Z3;
505  vec[i].Z = one;
506  }
507 }
Here is the call graph for this function:

◆ dbl()

alt_bn128_G2 libff::alt_bn128_G2::dbl ( ) const

Definition at line 311 of file alt_bn128_g2.cpp.

312 {
313 #ifdef PROFILE_OP_COUNTS
314  this->dbl_cnt++;
315 #endif
316  // handle point at infinity
317  if (this->is_zero()) {
318  return (*this);
319  }
320 
321  // NOTE: does not handle O and pts of order 2,4
322  // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-projective.html#doubling-dbl-2007-bl
323 
324  // A = X1^2
325  const alt_bn128_Fq2 A = (this->X).squared();
326  // B = Y1^2
327  const alt_bn128_Fq2 B = (this->Y).squared();
328  // C = B^2
329  const alt_bn128_Fq2 C = B.squared();
330  alt_bn128_Fq2 D = (this->X + B).squared() - A - C;
331  // D = 2 * ((X1 + B)^2 - A - C)
332  D = D + D;
333  // E = 3 * A
334  const alt_bn128_Fq2 E = A + A + A;
335  // F = E^2
336  const alt_bn128_Fq2 F = E.squared();
337  // X3 = F - 2 D
338  const alt_bn128_Fq2 X3 = F - (D + D);
339  alt_bn128_Fq2 eightC = C + C;
340  eightC = eightC + eightC;
341  eightC = eightC + eightC;
342  // Y3 = E * (D - X3) - 8 * C
343  const alt_bn128_Fq2 Y3 = E * (D - X3) - eightC;
344  const alt_bn128_Fq2 Y1Z1 = (this->Y) * (this->Z);
345  // Z3 = 2 * Y1 * Z1
346  const alt_bn128_Fq2 Z3 = Y1Z1 + Y1Z1;
347 
348  return alt_bn128_G2(X3, Y3, Z3);
349 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_in_safe_subgroup()

bool libff::alt_bn128_G2::is_in_safe_subgroup ( ) const

Definition at line 389 of file alt_bn128_g2.cpp.

390 {
391  return zero() == scalar_field::mod * (*this);
392 }
Here is the call graph for this function:

◆ is_special()

bool libff::alt_bn128_G2::is_special ( ) const

Definition at line 103 of file alt_bn128_g2.cpp.

104 {
105  return (this->is_zero() || this->Z == alt_bn128_Fq2::one());
106 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_well_formed()

bool libff::alt_bn128_G2::is_well_formed ( ) const

Definition at line 364 of file alt_bn128_g2.cpp.

365 {
366  if (this->is_zero()) {
367  return true;
368  } else {
369  // y^2 = x^3 + b
370  //
371  // We are using Jacobian coordinates, so equation we need to check is
372  // actually
373  //
374  // (y/z^3)^2 = (x/z^2)^3 + b
375  // y^2 / z^6 = x^3 / z^6 + b
376  // y^2 = x^3 + b z^6
377  const alt_bn128_Fq2 X2 = this->X.squared();
378  const alt_bn128_Fq2 Y2 = this->Y.squared();
379  const alt_bn128_Fq2 Z2 = this->Z.squared();
380 
381  const alt_bn128_Fq2 X3 = this->X * X2;
382  const alt_bn128_Fq2 Z3 = this->Z * Z2;
383  const alt_bn128_Fq2 Z6 = Z3.squared();
384 
385  return (Y2 == X3 + alt_bn128_twist_coeff_b * Z6);
386  }
387 }
Here is the call graph for this function:

◆ is_zero()

bool libff::alt_bn128_G2::is_zero ( ) const

Definition at line 108 of file alt_bn128_g2.cpp.

108 { return (this->Z.is_zero()); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mixed_add()

alt_bn128_G2 libff::alt_bn128_G2::mixed_add ( const alt_bn128_G2 other) const

Definition at line 234 of file alt_bn128_g2.cpp.

235 {
236 #ifdef DEBUG
237  assert(other.is_special());
238 #endif
239 
240  // handle special cases having to do with O
241  if (this->is_zero()) {
242  return other;
243  }
244 
245  if (other.is_zero()) {
246  return *this;
247  }
248 
249  // no need to handle points of order 2,4
250  // (they cannot exist in a prime-order subgroup)
251 
252  // check for doubling case
253 
254  // using Jacobian coordinates so:
255  // (X1:Y1:Z1) = (X2:Y2:Z2)
256  // iff
257  // X1/Z1^2 == X2/Z2^2 and Y1/Z1^3 == Y2/Z2^3
258  // iff
259  // X1 * Z2^2 == X2 * Z1^2 and Y1 * Z2^3 == Y2 * Z1^3
260 
261  // we know that Z2 = 1
262 
263  const alt_bn128_Fq2 Z1Z1 = (this->Z).squared();
264 
265  const alt_bn128_Fq2 &U1 = this->X;
266  const alt_bn128_Fq2 U2 = other.X * Z1Z1;
267 
268  const alt_bn128_Fq2 Z1_cubed = (this->Z) * Z1Z1;
269 
270  // S1 = Y1 * Z2 * Z2Z2
271  const alt_bn128_Fq2 &S1 = (this->Y);
272  // S2 = Y2 * Z1 * Z1Z1
273  const alt_bn128_Fq2 S2 = (other.Y) * Z1_cubed;
274 
275  if (U1 == U2 && S1 == S2) {
276  // dbl case; nothing of above can be reused
277  return this->dbl();
278  }
279 
280 #ifdef PROFILE_OP_COUNTS
281  this->add_cnt++;
282 #endif
283 
284  // NOTE: does not handle O and pts of order 2,4
285  // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-madd-2007-bl
286  // H = U2-X1
287  const alt_bn128_Fq2 H = U2 - (this->X);
288  // HH = H&2
289  const alt_bn128_Fq2 HH = H.squared();
290  // I = 4*HH
291  alt_bn128_Fq2 I = HH + HH;
292  I = I + I;
293  // J = H*I
294  const alt_bn128_Fq2 J = H * I;
295  // r = 2*(S2-Y1)
296  alt_bn128_Fq2 r = S2 - (this->Y);
297  r = r + r;
298  // V = X1*I
299  const alt_bn128_Fq2 V = (this->X) * I;
300  // X3 = r^2-J-2*V
301  const alt_bn128_Fq2 X3 = r.squared() - J - V - V;
302  // Y3 = r*(V-X3)-2*Y1*J
303  alt_bn128_Fq2 Y3 = (this->Y) * J;
304  Y3 = r * (V - X3) - Y3 - Y3;
305  // Z3 = (Z1+H)^2-Z1Z1-HH
306  const alt_bn128_Fq2 Z3 = ((this->Z) + H).squared() - Z1Z1 - HH;
307 
308  return alt_bn128_G2(X3, Y3, Z3);
309 }
Here is the call graph for this function:

◆ mul_by_b()

alt_bn128_Fq2 libff::alt_bn128_G2::mul_by_b ( const alt_bn128_Fq2 elt)
static

Definition at line 36 of file alt_bn128_g2.cpp.

37 {
38  return alt_bn128_Fq2(
39  alt_bn128_twist_mul_by_b_c0 * elt.coeffs[0],
40  alt_bn128_twist_mul_by_b_c1 * elt.coeffs[1]);
41 }

◆ mul_by_cofactor()

alt_bn128_G2 libff::alt_bn128_G2::mul_by_cofactor ( ) const

Definition at line 359 of file alt_bn128_g2.cpp.

360 {
361  return alt_bn128_G2::h * (*this);
362 }

◆ mul_by_q()

alt_bn128_G2 libff::alt_bn128_G2::mul_by_q ( ) const

Definition at line 351 of file alt_bn128_g2.cpp.

352 {
353  return alt_bn128_G2(
354  alt_bn128_twist_mul_by_q_X * (this->X).Frobenius_map(1),
355  alt_bn128_twist_mul_by_q_Y * (this->Y).Frobenius_map(1),
356  (this->Z).Frobenius_map(1));
357 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ one()

const alt_bn128_G2 & libff::alt_bn128_G2::one ( )
static

Definition at line 396 of file alt_bn128_g2.cpp.

396 { return G2_one; }
Here is the caller graph for this function:

◆ operator!=()

bool libff::alt_bn128_G2::operator!= ( const alt_bn128_G2 other) const

Definition at line 146 of file alt_bn128_g2.cpp.

147 {
148  return !(operator==(other));
149 }
Here is the call graph for this function:

◆ operator+()

alt_bn128_G2 libff::alt_bn128_G2::operator+ ( const alt_bn128_G2 other) const

Definition at line 151 of file alt_bn128_g2.cpp.

152 {
153  return add(other);
154 }
Here is the call graph for this function:

◆ operator-() [1/2]

alt_bn128_G2 libff::alt_bn128_G2::operator- ( ) const

Definition at line 156 of file alt_bn128_g2.cpp.

157 {
158  return alt_bn128_G2(this->X, -(this->Y), this->Z);
159 }
Here is the call graph for this function:

◆ operator-() [2/2]

alt_bn128_G2 libff::alt_bn128_G2::operator- ( const alt_bn128_G2 other) const

Definition at line 161 of file alt_bn128_g2.cpp.

162 {
163  return (*this) + (-other);
164 }

◆ operator==()

bool libff::alt_bn128_G2::operator== ( const alt_bn128_G2 other) const

Definition at line 110 of file alt_bn128_g2.cpp.

111 {
112  if (this->is_zero()) {
113  return other.is_zero();
114  }
115 
116  if (other.is_zero()) {
117  return false;
118  }
119 
120  /* now neither is O */
121 
122  // using Jacobian coordinates so:
123  // (X1:Y1:Z1) = (X2:Y2:Z2)
124  // iff
125  // X1/Z1^2 == X2/Z2^2 and Y1/Z1^3 == Y2/Z2^3
126  // iff
127  // X1 * Z2^2 == X2 * Z1^2 and Y1 * Z2^3 == Y2 * Z1^3
128 
129  const alt_bn128_Fq2 Z1_squared = (this->Z).squared();
130  const alt_bn128_Fq2 Z2_squared = (other.Z).squared();
131 
132  if ((this->X * Z2_squared) != (other.X * Z1_squared)) {
133  return false;
134  }
135 
136  const alt_bn128_Fq2 Z1_cubed = (this->Z) * Z1_squared;
137  const alt_bn128_Fq2 Z2_cubed = (other.Z) * Z2_squared;
138 
139  if ((this->Y * Z2_cubed) != (other.Y * Z1_cubed)) {
140  return false;
141  }
142 
143  return true;
144 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ order()

static bigint<scalar_field::num_limbs> libff::alt_bn128_G2::order ( )
inlinestatic

Definition at line 89 of file alt_bn128_g2.hpp.

90  {
91  return scalar_field::field_char();
92  }
Here is the call graph for this function:

◆ print()

void libff::alt_bn128_G2::print ( ) const

Definition at line 43 of file alt_bn128_g2.cpp.

44 {
45  if (this->is_zero()) {
46  printf("O\n");
47  } else {
48  alt_bn128_G2 copy(*this);
49  copy.to_affine_coordinates();
50  gmp_printf(
51  "(%Nd*z + %Nd , %Nd*z + %Nd)\n",
52  copy.X.coeffs[1].as_bigint().data,
54  copy.X.coeffs[0].as_bigint().data,
56  copy.Y.coeffs[1].as_bigint().data,
58  copy.Y.coeffs[0].as_bigint().data,
60  }
61 }
Here is the call graph for this function:

◆ print_coordinates()

void libff::alt_bn128_G2::print_coordinates ( ) const

Definition at line 63 of file alt_bn128_g2.cpp.

64 {
65  if (this->is_zero()) {
66  printf("O\n");
67  } else {
68  gmp_printf(
69  "(%Nd*z + %Nd : %Nd*z + %Nd : %Nd*z + %Nd)\n",
70  this->X.coeffs[1].as_bigint().data,
72  this->X.coeffs[0].as_bigint().data,
74  this->Y.coeffs[1].as_bigint().data,
76  this->Y.coeffs[0].as_bigint().data,
78  this->Z.coeffs[1].as_bigint().data,
80  this->Z.coeffs[0].as_bigint().data,
82  }
83 }
Here is the call graph for this function:

◆ random_element()

alt_bn128_G2 libff::alt_bn128_G2::random_element ( )
static

Definition at line 398 of file alt_bn128_g2.cpp.

399 {
400  return (alt_bn128_Fr::random_element().as_bigint()) * G2_one;
401 }
Here is the call graph for this function:

◆ read_compressed()

void libff::alt_bn128_G2::read_compressed ( std::istream &  in,
alt_bn128_G2 g 
)
static

Definition at line 440 of file alt_bn128_g2.cpp.

441 {
442  // <flags> | <x-coord>
443  char flags_char;
444  in.read(&flags_char, 1) >> g.X;
445  const uint8_t flags = flags_char - '0';
446 
447  // alt_bn128_Fq2 tX;
448 
449  // y = +/- sqrt(x^3 + b)
450  if (0 == (flags & G2_ZERO_FLAG)) {
451  const uint8_t Y_lsb = (flags & G2_Y_LSB_FLAG) ? 1 : 0;
452  const alt_bn128_Fq2 tX2 = g.X.squared();
453  const alt_bn128_Fq2 tY2 = tX2 * g.X + alt_bn128_twist_coeff_b;
454  g.Y = tY2.sqrt();
455 
456  if ((uint8_t)(g.Y.coeffs[0].as_bigint().data[0] & 1) != Y_lsb) {
457  g.Y = -g.Y;
458  }
459 
460  g.Z = alt_bn128_Fq2::one();
461  } else {
462  g = alt_bn128_G2::zero();
463  }
464 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_uncompressed()

void libff::alt_bn128_G2::read_uncompressed ( std::istream &  in,
alt_bn128_G2 g 
)
static

Definition at line 425 of file alt_bn128_g2.cpp.

426 {
427  // <is_zero> | <x-coord> | <y-coord>
428  char is_zero;
429  in.read(&is_zero, 1) >> g.X >> g.Y;
430  ;
431  is_zero -= '0';
432 
433  if (!is_zero) {
434  g.Z = alt_bn128_Fq2::one();
435  } else {
436  g = alt_bn128_G2::zero();
437  }
438 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ size_in_bits()

static size_t libff::alt_bn128_G2::size_in_bits ( )
inlinestatic

Definition at line 84 of file alt_bn128_g2.hpp.

84 { return twist_field::size_in_bits() + 1; }
Here is the call graph for this function:

◆ to_affine_coordinates()

void libff::alt_bn128_G2::to_affine_coordinates ( )

Definition at line 85 of file alt_bn128_g2.cpp.

86 {
87  if (this->is_zero()) {
88  this->X = alt_bn128_Fq2::zero();
89  this->Y = alt_bn128_Fq2::one();
90  this->Z = alt_bn128_Fq2::zero();
91  } else {
92  const alt_bn128_Fq2 Z_inv = Z.inverse();
93  const alt_bn128_Fq2 Z2_inv = Z_inv.squared();
94  const alt_bn128_Fq2 Z3_inv = Z2_inv * Z_inv;
95  this->X = this->X * Z2_inv;
96  this->Y = this->Y * Z3_inv;
97  this->Z = alt_bn128_Fq2::one();
98  }
99 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_special()

void libff::alt_bn128_G2::to_special ( )

Definition at line 101 of file alt_bn128_g2.cpp.

101 { this->to_affine_coordinates(); }
Here is the call graph for this function:

◆ write_compressed()

void libff::alt_bn128_G2::write_compressed ( std::ostream &  out) const

Definition at line 412 of file alt_bn128_g2.cpp.

413 {
414  // <flags> | <x-coord>
415  alt_bn128_G2 copy(*this);
416  copy.to_affine_coordinates();
417 
418  const uint8_t flags =
419  (copy.is_zero() ? G2_ZERO_FLAG : 0) |
420  ((copy.Y.coeffs[0].as_bigint().data[0] & 1) ? G2_Y_LSB_FLAG : 0);
421  const char flags_char = '0' + flags;
422  out.write(&flags_char, 1) << copy.X;
423 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_uncompressed()

void libff::alt_bn128_G2::write_uncompressed ( std::ostream &  out) const

Definition at line 403 of file alt_bn128_g2.cpp.

404 {
405  // <is_zero> | <x-coord> | <y-coord>
406  alt_bn128_G2 copy(*this);
407  copy.to_affine_coordinates();
408  const char is_zero = copy.is_zero() ? '1' : '0';
409  out.write(&is_zero, 1) << copy.X << copy.Y;
410 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zero()

const alt_bn128_G2 & libff::alt_bn128_G2::zero ( )
static

Definition at line 394 of file alt_bn128_g2.cpp.

394 { return G2_zero; }
Here is the caller graph for this function:

Member Data Documentation

◆ coeff_a

alt_bn128_Fq2 libff::alt_bn128_G2::coeff_a
static

Definition at line 32 of file alt_bn128_g2.hpp.

◆ coeff_b

alt_bn128_Fq2 libff::alt_bn128_G2::coeff_b
static

Definition at line 33 of file alt_bn128_g2.hpp.

◆ fixed_base_exp_window_table

std::vector< size_t > libff::alt_bn128_G2::fixed_base_exp_window_table
static

Definition at line 29 of file alt_bn128_g2.hpp.

◆ G2_one

alt_bn128_G2 libff::alt_bn128_G2::G2_one
static

Definition at line 31 of file alt_bn128_g2.hpp.

◆ G2_zero

alt_bn128_G2 libff::alt_bn128_G2::G2_zero
static

Definition at line 30 of file alt_bn128_g2.hpp.

◆ h

bigint< alt_bn128_G2::h_limbs > libff::alt_bn128_G2::h
static

Definition at line 43 of file alt_bn128_g2.hpp.

◆ h_bitcount

const mp_size_t libff::alt_bn128_G2::h_bitcount = 256
static

Definition at line 40 of file alt_bn128_g2.hpp.

◆ h_limbs

const mp_size_t libff::alt_bn128_G2::h_limbs
static
Initial value:
=
(h_bitcount + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS

Definition at line 41 of file alt_bn128_g2.hpp.

◆ wnaf_window_table

std::vector< size_t > libff::alt_bn128_G2::wnaf_window_table
static

Definition at line 28 of file alt_bn128_g2.hpp.

◆ X

alt_bn128_Fq2 libff::alt_bn128_G2::X

Definition at line 45 of file alt_bn128_g2.hpp.

◆ Y

alt_bn128_Fq2 libff::alt_bn128_G2::Y

Definition at line 45 of file alt_bn128_g2.hpp.

◆ Z

alt_bn128_Fq2 libff::alt_bn128_G2::Z

Definition at line 45 of file alt_bn128_g2.hpp.


The documentation for this class was generated from the following files:
libff::Fp2_model::coeffs
my_Fp coeffs[2]
Definition: fp2.hpp:63
libff::alt_bn128_twist_mul_by_q_Y
alt_bn128_Fq2 alt_bn128_twist_mul_by_q_Y
Definition: alt_bn128_init.cpp:24
libff::alt_bn128_G2::one
static const alt_bn128_G2 & one()
Definition: alt_bn128_g2.cpp:396
libff::Fp_model::random_element
static Fp_model< n, modulus > random_element()
returns random element of Fp_model
libff::alt_bn128_G2::operator==
bool operator==(const alt_bn128_G2 &other) const
Definition: alt_bn128_g2.cpp:110
libff::Fp2_model< alt_bn128_q_limbs, alt_bn128_modulus_q >::one
static const Fp2_model< n, modulus > & one()
libff::Fp2_model< alt_bn128_q_limbs, alt_bn128_modulus_q >::size_in_bits
static size_t size_in_bits()
Definition: fp2.hpp:108
libff::alt_bn128_G2::h
static bigint< h_limbs > h
Definition: alt_bn128_g2.hpp:43
libff::alt_bn128_G2::Y
alt_bn128_Fq2 Y
Definition: alt_bn128_g2.hpp:45
libff::alt_bn128_twist_coeff_b
alt_bn128_Fq2 alt_bn128_twist_coeff_b
Definition: alt_bn128_init.cpp:20
libff::alt_bn128_G2::Z
alt_bn128_Fq2 Z
Definition: alt_bn128_g2.hpp:45
libff::alt_bn128_G2::X
alt_bn128_Fq2 X
Definition: alt_bn128_g2.hpp:45
libff::alt_bn128_twist_mul_by_q_X
alt_bn128_Fq2 alt_bn128_twist_mul_by_q_X
Definition: alt_bn128_init.cpp:23
libff::Fp2_model::inverse
Fp2_model inverse() const
libff::alt_bn128_G2::G2_zero
static alt_bn128_G2 G2_zero
Definition: alt_bn128_g2.hpp:30
libff::Fp2_model::is_zero
bool is_zero() const
Definition: fp2.hpp:89
libff::alt_bn128_G2::h_bitcount
static const mp_size_t h_bitcount
Definition: alt_bn128_g2.hpp:40
libff::alt_bn128_twist_mul_by_b_c1
alt_bn128_Fq alt_bn128_twist_mul_by_b_c1
Definition: alt_bn128_init.cpp:22
libff::alt_bn128_Fq2
Fp2_model< alt_bn128_q_limbs, alt_bn128_modulus_q > alt_bn128_Fq2
Definition: alt_bn128_init.hpp:32
libff::alt_bn128_G2::add
alt_bn128_G2 add(const alt_bn128_G2 &other) const
Definition: alt_bn128_g2.cpp:166
libff::Fp_model< alt_bn128_q_limbs, alt_bn128_modulus_q >::num_limbs
static const mp_size_t num_limbs
Definition: fp.hpp:47
libff::Fp_model< alt_bn128_q_limbs, alt_bn128_modulus_q >::field_char
static const bigint< n > & field_char()
Definition: fp.hpp:136
libff::Fp_model::as_bigint
bigint< n > as_bigint() const
libff::alt_bn128_G2::alt_bn128_G2
alt_bn128_G2()
Definition: alt_bn128_g2.cpp:29
libff::alt_bn128_G2::to_affine_coordinates
void to_affine_coordinates()
Definition: alt_bn128_g2.cpp:85
libff::alt_bn128_G2::zero
static const alt_bn128_G2 & zero()
Definition: alt_bn128_g2.cpp:394
libff::Fp2_model::squared
Fp2_model squared() const
default is squared_complex
libff::alt_bn128_twist_mul_by_b_c0
alt_bn128_Fq alt_bn128_twist_mul_by_b_c0
Definition: alt_bn128_init.cpp:21
libff::Fp_model::mod
static const constexpr bigint< n > & mod
Definition: fp.hpp:48
libff::Fp2_model::sqrt
Fp2_model sqrt() const
HAS TO BE A SQUARE (else does not terminate)
libff::alt_bn128_G2::G2_one
static alt_bn128_G2 G2_one
Definition: alt_bn128_g2.hpp:31
libff::Fp2_model< alt_bn128_q_limbs, alt_bn128_modulus_q >::zero
static const Fp2_model< n, modulus > & zero()
libff::alt_bn128_G2::is_zero
bool is_zero() const
Definition: alt_bn128_g2.cpp:108
libff::alt_bn128_G2::dbl
alt_bn128_G2 dbl() const
Definition: alt_bn128_g2.cpp:311