#include <bn128_g1.hpp>
Definition at line 23 of file bn128_g1.hpp.
◆ base_field
◆ scalar_field
◆ bn128_G1() [1/2]
libff::bn128_G1::bn128_G1 |
( |
| ) |
|
◆ bn128_G1() [2/2]
libff::bn128_G1::bn128_G1 |
( |
bn::Fp | coord[3] | ) |
|
|
inline |
Definition at line 44 of file bn128_g1.hpp.
44:
X(coord[0]),
Y(coord[1]),
Z(coord[2]) {};
◆ add()
Definition at line 224 of file bn128_g1.cpp.
225{
226#ifdef PROFILE_OP_COUNTS
227 this->add_cnt++;
228#endif
229
230 bn::Fp this_coord[3], other_coord[3], result_coord[3];
232 other.fill_coord(other_coord);
234
236 return result;
237}
void fill_coord(bn::Fp coord[3]) const
void ECAdd(FF *out, const FF *a, const FF *b)
◆ base_field_char()
Definition at line 73 of file bn128_g1.hpp.
static bigint< n > field_char()
◆ batch_to_special_all_non_zeros()
void libff::bn128_G1::batch_to_special_all_non_zeros |
( |
std::vector< bn128_G1 > & | vec | ) |
|
|
static |
Definition at line 505 of file bn128_g1.cpp.
506{
507 std::vector<bn::Fp> Z_vec;
508 Z_vec.reserve(vec.size());
509
510 for (auto &el: vec)
511 {
512 Z_vec.emplace_back(el.Z);
513 }
515
517
518 for (size_t i = 0; i < vec.size(); ++i)
519 {
523
527 }
528}
static void(* mul)(Fp &out, const Fp &x, const Fp &y)
static void square(Fp &out, const Fp &x)
void bn_batch_invert(std::vector< FieldT > &vec)
◆ dbl()
Definition at line 326 of file bn128_g1.cpp.
327{
328#ifdef PROFILE_OP_COUNTS
329 this->dbl_cnt++;
330#endif
331
332 bn::Fp this_coord[3], result_coord[3];
335
337 return result;
338}
void ECDouble(FF *out, const FF *in)
◆ fill_coord()
void libff::bn128_G1::fill_coord |
( |
bn::Fp | coord[3] | ) |
const |
|
inline |
Definition at line 41 of file bn128_g1.hpp.
41{ coord[0] = this->
X; coord[1] = this->
Y; coord[2] = this->
Z;
return; };
◆ is_special()
bool libff::bn128_G1::is_special |
( |
| ) |
const |
◆ is_well_formed()
bool libff::bn128_G1::is_well_formed |
( |
| ) |
const |
Definition at line 384 of file bn128_g1.cpp.
385{
387 {
388 return true;
389 }
390 else
391 {
392
393
394
395
396
397
398
399
400
405
410
412 }
413}
◆ is_zero()
bool libff::bn128_G1::is_zero |
( |
| ) |
const |
Definition at line 141 of file bn128_g1.cpp.
142{
144}
MIE_FORCE_INLINE bool isZero() const
◆ mixed_add()
Definition at line 239 of file bn128_g1.cpp.
240{
242 {
244 }
245
247 {
248 return *this;
249 }
250
251
252
253
254#ifdef DEBUG
255 assert(
other.is_special());
256#endif
257
258
259
260
261
262
263
264
265
266
267
268
276
280
281 if (U1 == U2 && S1 == S2)
282 {
283
285 }
286
287#ifdef PROFILE_OP_COUNTS
288 this->add_cnt++;
289#endif
290
293
295
297
300
302
305
307
312
318
323 return result;
324}
static void(* add)(Fp &out, const Fp &x, const Fp &y)
static void(* sub)(Fp &out, const Fp &x, const Fp &y)
◆ one()
◆ operator!=()
bool libff::bn128_G1::operator!= |
( |
const bn128_G1 & | other | ) |
const |
Definition at line 180 of file bn128_g1.cpp.
181{
183}
bool operator==(const bn128_G1 &other) const
◆ operator+()
Definition at line 185 of file bn128_g1.cpp.
186{
187
189 {
191 }
192
194 {
195 return *this;
196 }
197
198
199
200
201
202 if (this->operator==(other))
203 {
205 }
206 else
207 {
208 return this->
add(other);
209 }
210}
bn128_G1 add(const bn128_G1 &other) const
◆ operator-() [1/2]
bn128_G1 libff::bn128_G1::operator- |
( |
| ) |
const |
Definition at line 212 of file bn128_g1.cpp.
213{
216 return result;
217}
static void(* neg)(Fp &out, const Fp &x)
◆ operator-() [2/2]
◆ operator==()
bool libff::bn128_G1::operator== |
( |
const bn128_G1 & | other | ) |
const |
Definition at line 146 of file bn128_g1.cpp.
147{
149 {
150 return other.is_zero();
151 }
152
154 {
155 return false;
156 }
157
158
159
160 bn::Fp Z1sq, Z2sq, lhs, rhs;
165
166 if (lhs != rhs)
167 {
168 return false;
169 }
170
176
177 return (lhs == rhs);
178}
◆ order()
◆ print()
void libff::bn128_G1::print |
( |
| ) |
const |
Definition at line 84 of file bn128_g1.cpp.
85{
87 {
89 }
90 else
91 {
93 copy.to_affine_coordinates();
94 std::cout <<
"(" <<
copy.X.toString(10) <<
" : " <<
copy.Y.toString(10) <<
" : " <<
copy.Z.toString(10) <<
")\n";
95 }
96}
LOGGING_API void printf(Category category, const char *format,...)
void copy(const path &from, const path &to)
◆ print_coordinates()
void libff::bn128_G1::print_coordinates |
( |
| ) |
const |
Definition at line 98 of file bn128_g1.cpp.
99{
101 {
103 }
104 else
105 {
106 std::cout <<
"(" <<
X.toString(10) <<
" : " <<
Y.
toString(10) <<
" : " <<
Z.
toString(10) <<
")\n";
107 }
108}
std::string toString(int base=10) const
◆ random_element()
bn128_G1 libff::bn128_G1::random_element |
( |
| ) |
|
|
static |
Definition at line 350 of file bn128_g1.cpp.
351{
353}
static Fp_model< n, modulus > random_element()
◆ size_in_bits()
static size_t libff::bn128_G1::size_in_bits |
( |
| ) |
|
|
inlinestatic |
Definition at line 72 of file bn128_g1.hpp.
static size_t size_in_bits()
◆ to_affine_coordinates()
void libff::bn128_G1::to_affine_coordinates |
( |
| ) |
|
Definition at line 110 of file bn128_g1.cpp.
111{
113 {
117 }
118 else
119 {
128 }
129}
◆ to_special()
void libff::bn128_G1::to_special |
( |
| ) |
|
Definition at line 131 of file bn128_g1.cpp.
132{
134}
void to_affine_coordinates()
◆ zero()
◆ operator<<
std::ostream & operator<< |
( |
std::ostream & | out, |
|
|
const bn128_G1 & | g ) |
|
friend |
Definition at line 355 of file bn128_g1.cpp.
356{
358 gcopy.to_affine_coordinates();
359
361
362#ifdef NO_PT_COMPRESSION
363
364#ifndef BINARY_OUTPUT
366#else
367 out.write((char*) &gcopy.X, sizeof(gcopy.X));
368 out.write((char*) &gcopy.Y, sizeof(gcopy.Y));
369#endif
370
371#else
372
373#ifndef BINARY_OUTPUT
374 out << gcopy.X;
375#else
376 out.write((char*) &gcopy.X, sizeof(gcopy.X));
377#endif
379#endif
380
381 return out;
382}
◆ operator>>
std::istream & operator>> |
( |
std::istream & | in, |
|
|
bn128_G1 & | g ) |
|
friend |
Definition at line 415 of file bn128_g1.cpp.
416{
421
422#ifdef NO_PT_COMPRESSION
423
424#ifndef BINARY_OUTPUT
425 in >> g.X;
427 in >> g.Y;
428#else
429 in.read((char*) &g.X, sizeof(g.X));
430 in.read((char*) &g.Y, sizeof(g.Y));
431#endif
432
433#else
434
436#ifndef BINARY_OUTPUT
437 in >> tX;
438#else
439 in.read((char*)&tX, sizeof(tX));
440#endif
442 unsigned char Y_lsb;
443 in.read((char*)&Y_lsb, 1);
444 Y_lsb -= '0';
445
446
448 {
449 g.X = tX;
454
455 g.Y = bn128_G1::sqrt(tY2);
456 if ((((unsigned char*)&g.Y)[0] & 1) != Y_lsb)
457 {
459 }
460 }
461#endif
462
463
465 {
467 }
468 else
469 {
471 }
472
473 return in;
474}
void consume_OUTPUT_SEPARATOR(std::istream &in)
◆ fixed_base_exp_window_table
std::vector< size_t > libff::bn128_G1::fixed_base_exp_window_table |
|
static |
◆ G1_one
◆ G1_zero
◆ initialized
bool libff::bn128_G1::initialized = false |
|
static |
◆ wnaf_window_table
std::vector< size_t > libff::bn128_G1::wnaf_window_table |
|
static |
The documentation for this class was generated from the following files:
- libraries/fc/libraries/ff/libff/algebra/curves/bn128/bn128_g1.hpp
- libraries/fc/libraries/ff/libff/algebra/curves/bn128/bn128_g1.cpp