Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
bn128_g1.hpp
Go to the documentation of this file.
1
8#ifndef BN128_G1_HPP_
9#define BN128_G1_HPP_
10#include <vector>
11
13
16
17namespace libff {
18
19class bn128_G1;
20std::ostream& operator<<(std::ostream &, const bn128_G1&);
21std::istream& operator>>(std::istream &, bn128_G1&);
22
23class bn128_G1 {
24private:
25 static bn::Fp sqrt(const bn::Fp &el);
26public:
27#ifdef PROFILE_OP_COUNTS
28 static long long add_cnt;
29 static long long dbl_cnt;
30#endif
31 static std::vector<size_t> wnaf_window_table;
32 static std::vector<size_t> fixed_base_exp_window_table;
35 static bool initialized;
36
39
41 void fill_coord(bn::Fp coord[3]) const { coord[0] = this->X; coord[1] = this->Y; coord[2] = this->Z; return; };
42
43 bn128_G1();
44 bn128_G1(bn::Fp coord[3]) : X(coord[0]), Y(coord[1]), Z(coord[2]) {};
45
46 void print() const;
47 void print_coordinates() const;
48
50 void to_special();
51 bool is_special() const;
52
53 bool is_zero() const;
54
55 bool operator==(const bn128_G1 &other) const;
56 bool operator!=(const bn128_G1 &other) const;
57
58 bn128_G1 operator+(const bn128_G1 &other) const;
59 bn128_G1 operator-() const;
60 bn128_G1 operator-(const bn128_G1 &other) const;
61
62 bn128_G1 add(const bn128_G1 &other) const;
63 bn128_G1 mixed_add(const bn128_G1 &other) const;
64 bn128_G1 dbl() const;
65
66 bool is_well_formed() const;
67
68 static bn128_G1 zero();
69 static bn128_G1 one();
70 static bn128_G1 random_element();
71
72 static size_t size_in_bits() { return bn128_Fq::size_in_bits() + 1; }
75
76 friend std::ostream& operator<<(std::ostream &out, const bn128_G1 &g);
77 friend std::istream& operator>>(std::istream &in, bn128_G1 &g);
78
79 static void batch_to_special_all_non_zeros(std::vector<bn128_G1> &vec);
80};
81
82template<mp_size_t m>
83bn128_G1 operator*(const bigint<m> &lhs, const bn128_G1 &rhs)
84{
85 return scalar_mul<bn128_G1, m>(rhs, lhs);
86}
87
88template<mp_size_t m, const bigint<m>& modulus_p>
90{
91 return scalar_mul<bn128_G1, m>(rhs, lhs.as_bigint());
92}
93
94std::ostream& operator<<(std::ostream& out, const std::vector<bn128_G1> &v);
95std::istream& operator>>(std::istream& in, std::vector<bn128_G1> &v);
96
97
98} // libff
99#endif // BN128_G1_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
bool is_well_formed() const
Definition bn128_g1.cpp:384
friend std::ostream & operator<<(std::ostream &out, const bn128_G1 &g)
Definition bn128_g1.cpp:355
bn128_Fr scalar_field
Definition bn128_g1.hpp:38
void print() const
Definition bn128_g1.cpp:84
bool is_zero() const
Definition bn128_g1.cpp:141
void print_coordinates() const
Definition bn128_g1.cpp:98
static bn128_G1 G1_zero
Definition bn128_g1.hpp:33
static bn128_G1 zero()
Definition bn128_g1.cpp:340
bn128_G1 dbl() const
Definition bn128_g1.cpp:326
static std::vector< size_t > wnaf_window_table
Definition bn128_g1.hpp:31
bool is_special() const
Definition bn128_g1.cpp:136
bool operator==(const bn128_G1 &other) const
Definition bn128_g1.cpp:146
bn128_G1 add(const bn128_G1 &other) const
Definition bn128_g1.cpp:224
static size_t size_in_bits()
Definition bn128_g1.hpp:72
bn128_G1 operator-() const
Definition bn128_g1.cpp:212
bn128_G1 operator+(const bn128_G1 &other) const
Definition bn128_g1.cpp:185
static bn128_G1 one()
Definition bn128_g1.cpp:345
bn128_G1 mixed_add(const bn128_G1 &other) const
Definition bn128_g1.cpp:239
bn128_Fq base_field
Definition bn128_g1.hpp:37
void to_affine_coordinates()
Definition bn128_g1.cpp:110
static void batch_to_special_all_non_zeros(std::vector< bn128_G1 > &vec)
Definition bn128_g1.cpp:505
static bigint< scalar_field::num_limbs > order()
Definition bn128_g1.hpp:74
bn128_G1(bn::Fp coord[3])
Definition bn128_g1.hpp:44
static std::vector< size_t > fixed_base_exp_window_table
Definition bn128_g1.hpp:32
static bigint< base_field::num_limbs > base_field_char()
Definition bn128_g1.hpp:73
static bool initialized
Definition bn128_g1.hpp:35
static bn128_G1 G1_one
Definition bn128_g1.hpp:34
bool operator!=(const bn128_G1 &other) const
Definition bn128_g1.cpp:180
static bn128_G1 random_element()
Definition bn128_g1.cpp:350
friend std::istream & operator>>(std::istream &in, bn128_G1 &g)
Definition bn128_g1.cpp:415
void fill_coord(bn::Fp coord[3]) const
Definition bn128_g1.hpp:41
Definition zm2.h:18
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