Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
libff::mnt4_G2 Class Reference

#include <mnt4_g2.hpp>

Collaboration diagram for libff::mnt4_G2:

Public Types

typedef mnt4_Fq base_field
 
typedef mnt4_Fq2 twist_field
 
typedef mnt4_Fr scalar_field
 

Public Member Functions

 mnt4_G2 ()
 
 mnt4_G2 (const mnt4_Fq2 &X, const mnt4_Fq2 &Y, const mnt4_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 mnt4_G2 &other) const
 
bool operator!= (const mnt4_G2 &other) const
 
mnt4_G2 operator+ (const mnt4_G2 &other) const
 
mnt4_G2 operator- () const
 
mnt4_G2 operator- (const mnt4_G2 &other) const
 
mnt4_G2 add (const mnt4_G2 &other) const
 
mnt4_G2 mixed_add (const mnt4_G2 &other) const
 
mnt4_G2 dbl () const
 
mnt4_G2 mul_by_q () const
 
bool is_well_formed () const
 

Static Public Member Functions

static mnt4_Fq2 mul_by_a (const mnt4_Fq2 &elt)
 
static mnt4_Fq2 mul_by_b (const mnt4_Fq2 &elt)
 
static mnt4_G2 zero ()
 
static mnt4_G2 one ()
 
static mnt4_G2 random_element ()
 
static size_t size_in_bits ()
 
static bigint< mnt4_Fq::num_limbsbase_field_char ()
 
static bigint< mnt4_Fr::num_limbsorder ()
 
static void batch_to_special_all_non_zeros (std::vector< mnt4_G2 > &vec)
 

Public Attributes

mnt4_Fq2 X
 
mnt4_Fq2 Y
 
mnt4_Fq2 Z
 

Static Public Attributes

static std::vector< size_t > wnaf_window_table
 
static std::vector< size_t > fixed_base_exp_window_table
 
static mnt4_G2 G2_zero = {}
 
static mnt4_G2 G2_one = {}
 
static bool initialized
 
static mnt4_Fq2 twist
 
static mnt4_Fq2 coeff_a
 
static mnt4_Fq2 coeff_b
 

Friends

std::ostream & operator<< (std::ostream &out, const mnt4_G2 &g)
 
std::istream & operator>> (std::istream &in, mnt4_G2 &g)
 

Detailed Description

Definition at line 26 of file mnt4_g2.hpp.

Member Typedef Documentation

◆ base_field

Definition at line 41 of file mnt4_g2.hpp.

◆ scalar_field

Definition at line 43 of file mnt4_g2.hpp.

◆ twist_field

Definition at line 42 of file mnt4_g2.hpp.

Constructor & Destructor Documentation

◆ mnt4_G2() [1/2]

libff::mnt4_G2::mnt4_G2 ( )

Definition at line 42 of file mnt4_g2.cpp.

43{
45 {
46 this->X = G2_zero.X;
47 this->Y = G2_zero.Y;
48 this->Z = G2_zero.Z;
49 }
50}
static bool initialized
Definition mnt4_g2.hpp:36
static mnt4_G2 G2_zero
Definition mnt4_g2.hpp:34
mnt4_Fq2 Y
Definition mnt4_g2.hpp:45
mnt4_Fq2 X
Definition mnt4_g2.hpp:45
mnt4_Fq2 Z
Definition mnt4_g2.hpp:45
Definition lib.h:43
Here is the caller graph for this function:

◆ mnt4_G2() [2/2]

libff::mnt4_G2::mnt4_G2 ( const mnt4_Fq2 & X,
const mnt4_Fq2 & Y,
const mnt4_Fq2 & Z )
inline

Definition at line 49 of file mnt4_g2.hpp.

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

Member Function Documentation

◆ add()

mnt4_G2 libff::mnt4_G2::add ( const mnt4_G2 & other) const

Definition at line 240 of file mnt4_g2.cpp.

241{
242 // handle special cases having to do with O
243 if (this->is_zero())
244 {
245 return other;
246 }
247
248 if (other.is_zero())
249 {
250 return (*this);
251 }
252
253 // no need to handle points of order 2,4
254 // (they cannot exist in a prime-order subgroup)
255
256 // handle double case
257 if (this->operator==(other))
258 {
259 return this->dbl();
260 }
261
262#ifdef PROFILE_OP_COUNTS
263 this->add_cnt++;
264#endif
265 // NOTE: does not handle O and pts of order 2,4
266 // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-projective.html#addition-add-1998-cmo-2
267
268 const mnt4_Fq2 Y1Z2 = (this->Y) * (other.Z); // Y1Z2 = Y1*Z2
269 const mnt4_Fq2 X1Z2 = (this->X) * (other.Z); // X1Z2 = X1*Z2
270 const mnt4_Fq2 Z1Z2 = (this->Z) * (other.Z); // Z1Z2 = Z1*Z2
271 const mnt4_Fq2 u = (other.Y) * (this->Z) - Y1Z2; // u = Y2*Z1-Y1Z2
272 const mnt4_Fq2 uu = u.squared(); // uu = u^2
273 const mnt4_Fq2 v = (other.X) * (this->Z) - X1Z2; // v = X2*Z1-X1Z2
274 const mnt4_Fq2 vv = v.squared(); // vv = v^2
275 const mnt4_Fq2 vvv = v * vv; // vvv = v*vv
276 const mnt4_Fq2 R = vv * X1Z2; // R = vv*X1Z2
277 const mnt4_Fq2 A = uu * Z1Z2 - (vvv + R + R); // A = uu*Z1Z2 - vvv - 2*R
278 const mnt4_Fq2 X3 = v * A; // X3 = v*A
279 const mnt4_Fq2 Y3 = u * (R-A) - vvv * Y1Z2; // Y3 = u*(R-A) - vvv*Y1Z2
280 const mnt4_Fq2 Z3 = vvv * Z1Z2; // Z3 = vvv*Z1Z2
281
282 return mnt4_G2(X3, Y3, Z3);
283}
Fp2_model squared() const
mnt4_G2 dbl() const
Definition mnt4_g2.cpp:335
bool is_zero() const
Definition mnt4_g2.cpp:115
Fp2_model< mnt4_q_limbs, mnt4_modulus_q > mnt4_Fq2
Definition mnt4_init.hpp:37
#define R
#define A
Here is the call graph for this function:

◆ base_field_char()

static bigint< mnt4_Fq::num_limbs > libff::mnt4_G2::base_field_char ( )
inlinestatic

Definition at line 82 of file mnt4_g2.hpp.

82{ return mnt4_Fq::field_char(); }
Here is the call graph for this function:

◆ batch_to_special_all_non_zeros()

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

Definition at line 480 of file mnt4_g2.cpp.

481{
482 std::vector<mnt4_Fq2> Z_vec;
483 Z_vec.reserve(vec.size());
484
485 for (auto &el: vec)
486 {
487 Z_vec.emplace_back(el.Z);
488 }
490
491 const mnt4_Fq2 one = mnt4_Fq2::one();
492
493 for (size_t i = 0; i < vec.size(); ++i)
494 {
495 vec[i] = mnt4_G2(vec[i].X * Z_vec[i], vec[i].Y * Z_vec[i], one);
496 }
497}
static Fp2_model< n, modulus > one()
static mnt4_G2 one()
Definition mnt4_g2.cpp:407
void batch_invert(std::vector< FieldT > &vec)
Here is the call graph for this function:

◆ dbl()

mnt4_G2 libff::mnt4_G2::dbl ( ) const

Definition at line 335 of file mnt4_g2.cpp.

336{
337#ifdef PROFILE_OP_COUNTS
338 this->dbl_cnt++;
339#endif
340 if (this->is_zero())
341 {
342 return (*this);
343 }
344 else
345 {
346 // NOTE: does not handle O and pts of order 2,4
347 // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-projective.html#doubling-dbl-2007-bl
348
349 const mnt4_Fq2 XX = (this->X).squared(); // XX = X1^2
350 const mnt4_Fq2 ZZ = (this->Z).squared(); // ZZ = Z1^2
351 const mnt4_Fq2 w = mnt4_G2::mul_by_a(ZZ) + (XX + XX + XX); // w = a*ZZ + 3*XX
352 const mnt4_Fq2 Y1Z1 = (this->Y) * (this->Z);
353 const mnt4_Fq2 s = Y1Z1 + Y1Z1; // s = 2*Y1*Z1
354 const mnt4_Fq2 ss = s.squared(); // ss = s^2
355 const mnt4_Fq2 sss = s * ss; // sss = s*ss
356 const mnt4_Fq2 R = (this->Y) * s; // R = Y1*s
357 const mnt4_Fq2 RR = R.squared(); // RR = R^2
358 const mnt4_Fq2 B = ((this->X)+R).squared()-XX-RR; // B = (X1+R)^2 - XX - RR
359 const mnt4_Fq2 h = w.squared() - (B+B); // h = w^2-2*B
360 const mnt4_Fq2 X3 = h * s; // X3 = h*s
361 const mnt4_Fq2 Y3 = w * (B-h)-(RR+RR); // Y3 = w*(B-h) - 2*RR
362 const mnt4_Fq2 Z3 = sss; // Z3 = sss
363
364 return mnt4_G2(X3, Y3, Z3);
365 }
366}
static mnt4_Fq2 mul_by_a(const mnt4_Fq2 &elt)
Definition mnt4_g2.cpp:32
static const Segment ss(Segment::ss)
char * s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_special()

bool libff::mnt4_G2::is_special ( ) const

Definition at line 110 of file mnt4_g2.cpp.

111{
112 return (this->is_zero() || this->Z == mnt4_Fq2::one());
113}
Here is the call graph for this function:

◆ is_well_formed()

bool libff::mnt4_G2::is_well_formed ( ) const

Definition at line 375 of file mnt4_g2.cpp.

376{
377 if (this->is_zero())
378 {
379 return true;
380 }
381 else
382 {
383 /*
384 y^2 = x^3 + ax + b
385
386 We are using projective, so equation we need to check is actually
387
388 (y/z)^2 = (x/z)^3 + a (x/z) + b
389 z y^2 = x^3 + a z^2 x + b z^3
390
391 z (y^2 - b z^2) = x ( x^2 + a z^2)
392 */
393 const mnt4_Fq2 X2 = this->X.squared();
394 const mnt4_Fq2 Y2 = this->Y.squared();
395 const mnt4_Fq2 Z2 = this->Z.squared();
396 const mnt4_Fq2 aZ2 = mnt4_twist_coeff_a * Z2;
397
398 return (this->Z * (Y2 - mnt4_twist_coeff_b * Z2) == this->X * (X2 + aZ2));
399 }
400}
mnt4_Fq2 mnt4_twist_coeff_b
Definition mnt4_init.cpp:25
mnt4_Fq2 mnt4_twist_coeff_a
Definition mnt4_init.cpp:24
Here is the call graph for this function:

◆ is_zero()

bool libff::mnt4_G2::is_zero ( ) const

Definition at line 115 of file mnt4_g2.cpp.

116{
117 return (this->X.is_zero() && this->Z.is_zero());
118}
Here is the caller graph for this function:

◆ mixed_add()

mnt4_G2 libff::mnt4_G2::mixed_add ( const mnt4_G2 & other) const

Definition at line 285 of file mnt4_g2.cpp.

286{
287#ifdef PROFILE_OP_COUNTS
288 this->add_cnt++;
289#endif
290 // NOTE: does not handle O and pts of order 2,4
291 // http://www.hyperelliptic.org/EFD/g1p/auto-shortw-projective.html#addition-add-1998-cmo-2
292 //assert(other.Z == mnt4_Fq2::one());
293
294 if (this->is_zero())
295 {
296 return other;
297 }
298
299 if (other.is_zero())
300 {
301 return (*this);
302 }
303
304#ifdef DEBUG
305 assert(other.is_special());
306#endif
307
308 const mnt4_Fq2 &X1Z2 = (this->X); // X1Z2 = X1*Z2 (but other is special and not zero)
309 const mnt4_Fq2 X2Z1 = (this->Z) * (other.X); // X2Z1 = X2*Z1
310
311 // (used both in add and double checks)
312
313 const mnt4_Fq2 &Y1Z2 = (this->Y); // Y1Z2 = Y1*Z2 (but other is special and not zero)
314 const mnt4_Fq2 Y2Z1 = (this->Z) * (other.Y); // Y2Z1 = Y2*Z1
315
316 if (X1Z2 == X2Z1 && Y1Z2 == Y2Z1)
317 {
318 return this->dbl();
319 }
320
321 const mnt4_Fq2 u = Y2Z1 - this->Y; // u = Y2*Z1-Y1
322 const mnt4_Fq2 uu = u.squared(); // uu = u2
323 const mnt4_Fq2 v = X2Z1 - this->X; // v = X2*Z1-X1
324 const mnt4_Fq2 vv = v.squared(); // vv = v2
325 const mnt4_Fq2 vvv = v*vv; // vvv = v*vv
326 const mnt4_Fq2 R = vv * this->X; // R = vv*X1
327 const mnt4_Fq2 A = uu * this->Z - vvv - R - R; // A = uu*Z1-vvv-2*R
328 const mnt4_Fq2 X3 = v * A; // X3 = v*A
329 const mnt4_Fq2 Y3 = u*(R-A) - vvv * this->Y; // Y3 = u*(R-A)-vvv*Y1
330 const mnt4_Fq2 Z3 = vvv * this->Z; // Z3 = vvv*Z1
331
332 return mnt4_G2(X3, Y3, Z3);
333}
Here is the call graph for this function:

◆ mul_by_a()

mnt4_Fq2 libff::mnt4_G2::mul_by_a ( const mnt4_Fq2 & elt)
static

Definition at line 32 of file mnt4_g2.cpp.

33{
35}
mnt4_Fq mnt4_twist_mul_by_a_c0
Definition mnt4_init.cpp:26
mnt4_Fq mnt4_twist_mul_by_a_c1
Definition mnt4_init.cpp:27
Here is the caller graph for this function:

◆ mul_by_b()

mnt4_Fq2 libff::mnt4_G2::mul_by_b ( const mnt4_Fq2 & elt)
static

Definition at line 37 of file mnt4_g2.cpp.

38{
40}
mnt4_Fq mnt4_twist_mul_by_b_c1
Definition mnt4_init.cpp:29
mnt4_Fq mnt4_twist_mul_by_b_c0
Definition mnt4_init.cpp:28

◆ mul_by_q()

mnt4_G2 libff::mnt4_G2::mul_by_q ( ) const

Definition at line 368 of file mnt4_g2.cpp.

369{
370 return mnt4_G2(mnt4_twist_mul_by_q_X * (this->X).Frobenius_map(1),
371 mnt4_twist_mul_by_q_Y * (this->Y).Frobenius_map(1),
372 (this->Z).Frobenius_map(1));
373}
mnt4_Fq mnt4_twist_mul_by_q_X
Definition mnt4_init.cpp:30
mnt4_Fq mnt4_twist_mul_by_q_Y
Definition mnt4_init.cpp:31
Here is the call graph for this function:

◆ one()

mnt4_G2 libff::mnt4_G2::one ( )
static

Definition at line 407 of file mnt4_g2.cpp.

408{
409 return G2_one;
410}
static mnt4_G2 G2_one
Definition mnt4_g2.hpp:35
Here is the caller graph for this function:

◆ operator!=()

bool libff::mnt4_G2::operator!= ( const mnt4_G2 & other) const

Definition at line 149 of file mnt4_g2.cpp.

150{
151 return !(operator==(other));
152}
bool operator==(const mnt4_G2 &other) const
Definition mnt4_g2.cpp:120
Here is the call graph for this function:

◆ operator+()

mnt4_G2 libff::mnt4_G2::operator+ ( const mnt4_G2 & other) const

Definition at line 154 of file mnt4_g2.cpp.

155{
156 // handle special cases having to do with O
157 if (this->is_zero())
158 {
159 return other;
160 }
161
162 if (other.is_zero())
163 {
164 return *this;
165 }
166
167 // no need to handle points of order 2,4
168 // (they cannot exist in a prime-order subgroup)
169
170 // handle double case, and then all the rest
171 /*
172 The code below is equivalent to (but faster than) the snippet below:
173
174 if (this->operator==(other))
175 {
176 return this->dbl();
177 }
178 else
179 {
180 return this->add(other);
181 }
182 */
183
184 const mnt4_Fq2 X1Z2 = (this->X) * (other.Z); // X1Z2 = X1*Z2
185 const mnt4_Fq2 X2Z1 = (this->Z) * (other.X); // X2Z1 = X2*Z1
186
187 // (used both in add and double checks)
188
189 const mnt4_Fq2 Y1Z2 = (this->Y) * (other.Z); // Y1Z2 = Y1*Z2
190 const mnt4_Fq2 Y2Z1 = (this->Z) * (other.Y); // Y2Z1 = Y2*Z1
191
192 if (X1Z2 == X2Z1 && Y1Z2 == Y2Z1)
193 {
194 // perform dbl case
195 const mnt4_Fq2 XX = (this->X).squared(); // XX = X1^2
196 const mnt4_Fq2 ZZ = (this->Z).squared(); // ZZ = Z1^2
197 const mnt4_Fq2 w = mnt4_G2::mul_by_a(ZZ) + (XX + XX + XX); // w = a*ZZ + 3*XX
198 const mnt4_Fq2 Y1Z1 = (this->Y) * (this->Z);
199 const mnt4_Fq2 s = Y1Z1 + Y1Z1; // s = 2*Y1*Z1
200 const mnt4_Fq2 ss = s.squared(); // ss = s^2
201 const mnt4_Fq2 sss = s * ss; // sss = s*ss
202 const mnt4_Fq2 R = (this->Y) * s; // R = Y1*s
203 const mnt4_Fq2 RR = R.squared(); // RR = R^2
204 const mnt4_Fq2 B = ((this->X)+R).squared()-XX-RR; // B = (X1+R)^2 - XX - RR
205 const mnt4_Fq2 h = w.squared() - (B+B); // h = w^2 - 2*B
206 const mnt4_Fq2 X3 = h * s; // X3 = h*s
207 const mnt4_Fq2 Y3 = w * (B-h)-(RR+RR); // Y3 = w*(B-h) - 2*RR
208 const mnt4_Fq2 Z3 = sss; // Z3 = sss
209
210 return mnt4_G2(X3, Y3, Z3);
211 }
212
213 // if we have arrived here we are in the add case
214 const mnt4_Fq2 Z1Z2 = (this->Z) * (other.Z); // Z1Z2 = Z1*Z2
215 const mnt4_Fq2 u = Y2Z1 - Y1Z2; // u = Y2*Z1-Y1Z2
216 const mnt4_Fq2 uu = u.squared(); // uu = u^2
217 const mnt4_Fq2 v = X2Z1 - X1Z2; // v = X2*Z1-X1Z2
218 const mnt4_Fq2 vv = v.squared(); // vv = v^2
219 const mnt4_Fq2 vvv = v * vv; // vvv = v*vv
220 const mnt4_Fq2 R = vv * X1Z2; // R = vv*X1Z2
221 const mnt4_Fq2 A = uu * Z1Z2 - (vvv + R + R); // A = uu*Z1Z2 - vvv - 2*R
222 const mnt4_Fq2 X3 = v * A; // X3 = v*A
223 const mnt4_Fq2 Y3 = u * (R-A) - vvv * Y1Z2; // Y3 = u*(R-A) - vvv*Y1Z2
224 const mnt4_Fq2 Z3 = vvv * Z1Z2; // Z3 = vvv*Z1Z2
225
226 return mnt4_G2(X3, Y3, Z3);
227}
Here is the call graph for this function:

◆ operator-() [1/2]

mnt4_G2 libff::mnt4_G2::operator- ( ) const

Definition at line 229 of file mnt4_g2.cpp.

230{
231 return mnt4_G2(this->X, -(this->Y), this->Z);
232}
Here is the call graph for this function:

◆ operator-() [2/2]

mnt4_G2 libff::mnt4_G2::operator- ( const mnt4_G2 & other) const

Definition at line 235 of file mnt4_g2.cpp.

236{
237 return (*this) + (-other);
238}

◆ operator==()

bool libff::mnt4_G2::operator== ( const mnt4_G2 & other) const

Definition at line 120 of file mnt4_g2.cpp.

121{
122 if (this->is_zero())
123 {
124 return other.is_zero();
125 }
126
127 if (other.is_zero())
128 {
129 return false;
130 }
131
132 /* now neither is O */
133
134 // X1/Z1 = X2/Z2 <=> X1*Z2 = X2*Z1
135 if ((this->X * other.Z) != (other.X * this->Z))
136 {
137 return false;
138 }
139
140 // Y1/Z1 = Y2/Z2 <=> Y1*Z2 = Y2*Z1
141 if ((this->Y * other.Z) != (other.Y * this->Z))
142 {
143 return false;
144 }
145
146 return true;
147}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ order()

static bigint< mnt4_Fr::num_limbs > libff::mnt4_G2::order ( )
inlinestatic

Definition at line 83 of file mnt4_g2.hpp.

83{ return mnt4_Fr::field_char(); }
Here is the call graph for this function:

◆ print()

void libff::mnt4_G2::print ( ) const

Definition at line 52 of file mnt4_g2.cpp.

53{
54 if (this->is_zero())
55 {
56 printf("O\n");
57 }
58 else
59 {
60 mnt4_G2 copy(*this);
61 copy.to_affine_coordinates();
62 gmp_printf("(%Nd*z + %Nd , %Nd*z + %Nd)\n",
63 copy.X.c1.as_bigint().data, mnt4_Fq::num_limbs,
64 copy.X.c0.as_bigint().data, mnt4_Fq::num_limbs,
65 copy.Y.c1.as_bigint().data, mnt4_Fq::num_limbs,
66 copy.Y.c0.as_bigint().data, mnt4_Fq::num_limbs);
67 }
68}
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
void copy(const path &from, const path &to)
Here is the call graph for this function:

◆ print_coordinates()

void libff::mnt4_G2::print_coordinates ( ) const

Definition at line 70 of file mnt4_g2.cpp.

71{
72 if (this->is_zero())
73 {
74 printf("O\n");
75 }
76 else
77 {
78 gmp_printf("(%Nd*z + %Nd : %Nd*z + %Nd : %Nd*z + %Nd)\n",
79 this->X.c1.as_bigint().data, mnt4_Fq::num_limbs,
80 this->X.c0.as_bigint().data, mnt4_Fq::num_limbs,
81 this->Y.c1.as_bigint().data, mnt4_Fq::num_limbs,
82 this->Y.c0.as_bigint().data, mnt4_Fq::num_limbs,
83 this->Z.c1.as_bigint().data, mnt4_Fq::num_limbs,
84 this->Z.c0.as_bigint().data, mnt4_Fq::num_limbs);
85 }
86}
Here is the call graph for this function:

◆ random_element()

mnt4_G2 libff::mnt4_G2::random_element ( )
static

Definition at line 412 of file mnt4_g2.cpp.

413{
414 return (mnt4_Fr::random_element().as_bigint()) * G2_one;
415}
static Fp_model< n, modulus > random_element()
Here is the call graph for this function:

◆ size_in_bits()

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

Definition at line 81 of file mnt4_g2.hpp.

Here is the call graph for this function:

◆ to_affine_coordinates()

void libff::mnt4_G2::to_affine_coordinates ( )

Definition at line 88 of file mnt4_g2.cpp.

89{
90 if (this->is_zero())
91 {
92 this->X = mnt4_Fq2::zero();
93 this->Y = mnt4_Fq2::one();
94 this->Z = mnt4_Fq2::zero();
95 }
96 else
97 {
98 const mnt4_Fq2 Z_inv = Z.inverse();
99 X = X * Z_inv;
100 Y = Y * Z_inv;
101 Z = mnt4_Fq2::one();
102 }
103}
static Fp2_model< n, modulus > zero()
Fp2_model inverse() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_special()

void libff::mnt4_G2::to_special ( )

Definition at line 105 of file mnt4_g2.cpp.

106{
107 this->to_affine_coordinates();
108}
void to_affine_coordinates()
Definition mnt4_g2.cpp:88
Here is the call graph for this function:

◆ zero()

mnt4_G2 libff::mnt4_G2::zero ( )
static

Definition at line 402 of file mnt4_g2.cpp.

403{
404 return G2_zero;
405}

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const mnt4_G2 & g )
friend

Definition at line 417 of file mnt4_g2.cpp.

418{
419 mnt4_G2 copy(g);
420 copy.to_affine_coordinates();
421
422 out << (copy.is_zero() ? 1 : 0) << OUTPUT_SEPARATOR;
423#ifdef NO_PT_COMPRESSION
424 out << copy.X << OUTPUT_SEPARATOR << copy.Y;
425#else
426 /* storing LSB of Y */
427 out << copy.X << OUTPUT_SEPARATOR << (copy.Y.c0.as_bigint().data[0] & 1);
428#endif
429
430 return out;
431}
#define OUTPUT_SEPARATOR

◆ operator>>

std::istream & operator>> ( std::istream & in,
mnt4_G2 & g )
friend

Definition at line 433 of file mnt4_g2.cpp.

434{
435 char is_zero;
436 mnt4_Fq2 tX, tY;
437
438#ifdef NO_PT_COMPRESSION
439 in >> is_zero >> tX >> tY;
440 is_zero -= '0';
441#else
442 in.read((char*)&is_zero, 1); // this reads is_zero;
443 is_zero -= '0';
445
446 unsigned char Y_lsb;
447 in >> tX;
449 in.read((char*)&Y_lsb, 1);
450 Y_lsb -= '0';
451
452 // y = +/- sqrt(x^3 + a*x + b)
453 if (!is_zero)
454 {
455 mnt4_Fq2 tX2 = tX.squared();
456 mnt4_Fq2 tY2 = (tX2 + mnt4_twist_coeff_a ) * tX + mnt4_twist_coeff_b;
457 tY = tY2.sqrt();
458
459 if ((tY.c0.as_bigint().data[0] & 1) != Y_lsb)
460 {
461 tY = -tY;
462 }
463 }
464#endif
465 // using projective coordinates
466 if (!is_zero)
467 {
468 g.X = tX;
469 g.Y = tY;
470 g.Z = mnt4_Fq2::one();
471 }
472 else
473 {
474 g = mnt4_G2::zero();
475 }
476
477 return in;
478}
Fp2_model sqrt() const
static mnt4_G2 zero()
Definition mnt4_g2.cpp:402
void consume_OUTPUT_SEPARATOR(std::istream &in)

Member Data Documentation

◆ coeff_a

mnt4_Fq2 libff::mnt4_G2::coeff_a
static

Definition at line 38 of file mnt4_g2.hpp.

◆ coeff_b

mnt4_Fq2 libff::mnt4_G2::coeff_b
static

Definition at line 39 of file mnt4_g2.hpp.

◆ fixed_base_exp_window_table

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

Definition at line 33 of file mnt4_g2.hpp.

◆ G2_one

mnt4_G2 libff::mnt4_G2::G2_one = {}
static

Definition at line 35 of file mnt4_g2.hpp.

◆ G2_zero

mnt4_G2 libff::mnt4_G2::G2_zero = {}
static

Definition at line 34 of file mnt4_g2.hpp.

◆ initialized

bool libff::mnt4_G2::initialized
static

Definition at line 36 of file mnt4_g2.hpp.

◆ twist

mnt4_Fq2 libff::mnt4_G2::twist
static

Definition at line 37 of file mnt4_g2.hpp.

◆ wnaf_window_table

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

Definition at line 32 of file mnt4_g2.hpp.

◆ X

mnt4_Fq2 libff::mnt4_G2::X

Definition at line 45 of file mnt4_g2.hpp.

◆ Y

mnt4_Fq2 libff::mnt4_G2::Y

Definition at line 45 of file mnt4_g2.hpp.

◆ Z

mnt4_Fq2 libff::mnt4_G2::Z

Definition at line 45 of file mnt4_g2.hpp.


The documentation for this class was generated from the following files: