Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
bn128_g2.hpp
Go to the documentation of this file.
1
8#ifndef BN128_G2_HPP_
9#define BN128_G2_HPP_
10#include <iostream>
11#include <vector>
12
14
17
18namespace libff {
19
20class bn128_G2;
21std::ostream& operator<<(std::ostream &, const bn128_G2&);
22std::istream& operator>>(std::istream &, bn128_G2&);
23
24class bn128_G2 {
25private:
26 static bn::Fp2 sqrt(const bn::Fp2 &el);
27public:
28#ifdef PROFILE_OP_COUNTS
29 static long long add_cnt;
30 static long long dbl_cnt;
31#endif
32 static std::vector<size_t> wnaf_window_table;
33 static std::vector<size_t> fixed_base_exp_window_table;
36 static bool initialized;
37
40
42 void fill_coord(bn::Fp2 coord[3]) const { coord[0] = this->X; coord[1] = this->Y; coord[2] = this->Z; };
43
44 bn128_G2();
45 bn128_G2(bn::Fp2 coord[3]) : X(coord[0]), Y(coord[1]), Z(coord[2]) {};
46
47 void print() const;
48 void print_coordinates() const;
49
51 void to_special();
52 bool is_special() const;
53
54 bool is_zero() const;
55
56 bool operator==(const bn128_G2 &other) const;
57 bool operator!=(const bn128_G2 &other) const;
58
59 bn128_G2 operator+(const bn128_G2 &other) const;
60 bn128_G2 operator-() const;
61 bn128_G2 operator-(const bn128_G2 &other) const;
62
63 bn128_G2 add(const bn128_G2 &other) const;
64 bn128_G2 mixed_add(const bn128_G2 &other) const;
65 bn128_G2 dbl() const;
66
67 bool is_well_formed() const;
68
69 static bn128_G2 zero();
70 static bn128_G2 one();
71 static bn128_G2 random_element();
72
73 static size_t size_in_bits() { return 2*base_field::size_in_bits() + 1; }
76
77 friend std::ostream& operator<<(std::ostream &out, const bn128_G2 &g);
78 friend std::istream& operator>>(std::istream &in, bn128_G2 &g);
79
80 static void batch_to_special_all_non_zeros(std::vector<bn128_G2> &vec);
81};
82
83template<mp_size_t m>
84bn128_G2 operator*(const bigint<m> &lhs, const bn128_G2 &rhs)
85{
86 return scalar_mul<bn128_G2, m>(rhs, lhs);
87}
88
89template<mp_size_t m, const bigint<m>& modulus_p>
91{
92 return scalar_mul<bn128_G2, m>(rhs, lhs.as_bigint());
93}
94
95} // libff
96#endif // BN128_G2_HPP_
BN parameter.
static bigint< n > field_char()
Definition fp.hpp:116
static size_t size_in_bits()
Definition fp.hpp:114
bigint< n > as_bigint() const
static bigint< base_field::num_limbs > base_field_char()
Definition bn128_g2.hpp:74
bn128_G2 mixed_add(const bn128_G2 &other) const
Definition bn128_g2.cpp:239
static bn128_G2 random_element()
Definition bn128_g2.cpp:381
static bn128_G2 G2_zero
Definition bn128_g2.hpp:34
bool is_well_formed() const
Definition bn128_g2.cpp:340
static void batch_to_special_all_non_zeros(std::vector< bn128_G2 > &vec)
Definition bn128_g2.cpp:489
bool is_zero() const
Definition bn128_g2.cpp:141
static std::vector< size_t > fixed_base_exp_window_table
Definition bn128_g2.hpp:33
bn128_G2 dbl() const
Definition bn128_g2.cpp:326
void print_coordinates() const
Definition bn128_g2.cpp:98
bn128_G2(bn::Fp2 coord[3])
Definition bn128_g2.hpp:45
bool operator==(const bn128_G2 &other) const
Definition bn128_g2.cpp:146
static bn128_G2 zero()
Definition bn128_g2.cpp:371
bn128_G2 operator-() const
Definition bn128_g2.cpp:212
static bn128_G2 G2_one
Definition bn128_g2.hpp:35
bool is_special() const
Definition bn128_g2.cpp:136
bn128_Fq base_field
Definition bn128_g2.hpp:38
bn128_G2 operator+(const bn128_G2 &other) const
Definition bn128_g2.cpp:185
bool operator!=(const bn128_G2 &other) const
Definition bn128_g2.cpp:180
static std::vector< size_t > wnaf_window_table
Definition bn128_g2.hpp:32
static bool initialized
Definition bn128_g2.hpp:36
static size_t size_in_bits()
Definition bn128_g2.hpp:73
friend std::istream & operator>>(std::istream &in, bn128_G2 &g)
Definition bn128_g2.cpp:419
void to_affine_coordinates()
Definition bn128_g2.cpp:110
friend std::ostream & operator<<(std::ostream &out, const bn128_G2 &g)
Definition bn128_g2.cpp:386
bn128_G2 add(const bn128_G2 &other) const
Definition bn128_g2.cpp:224
void fill_coord(bn::Fp2 coord[3]) const
Definition bn128_g2.hpp:42
static bn128_G2 one()
Definition bn128_g2.cpp:376
bn128_Fr scalar_field
Definition bn128_g2.hpp:39
void print() const
Definition bn128_g2.cpp:84
static bigint< scalar_field::num_limbs > order()
Definition bn128_g2.hpp:75
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
GroupT scalar_mul(const GroupT &base, const bigint< m > &scalar)
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
alt_bn128_G1 operator*(const bigint< m > &lhs, const alt_bn128_G1 &rhs)
Definition lib.h:43
Definition bn.h:348