Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
mnt4_g1.hpp
Go to the documentation of this file.
1
12#ifndef MNT4_G1_HPP_
13#define MNT4_G1_HPP_
14
15#include <vector>
16
19
20namespace libff {
21
22class mnt4_G1;
23std::ostream& operator<<(std::ostream &, const mnt4_G1&);
24std::istream& operator>>(std::istream &, mnt4_G1&);
25
26class mnt4_G1 {
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;
39
42
44
45 // using projective coordinates
46 mnt4_G1();
47 mnt4_G1(const mnt4_Fq& X, const mnt4_Fq& Y) : X(X), Y(Y), Z(base_field::one()) {}
48 mnt4_G1(const mnt4_Fq& X, const mnt4_Fq& Y, const mnt4_Fq& Z) : X(X), Y(Y), Z(Z) {}
49
50 void print() const;
51 void print_coordinates() const;
52
54 void to_special();
55 bool is_special() const;
56
57 bool is_zero() const;
58
59 bool operator==(const mnt4_G1 &other) const;
60 bool operator!=(const mnt4_G1 &other) const;
61
62 mnt4_G1 operator+(const mnt4_G1 &other) const;
63 mnt4_G1 operator-() const;
64 mnt4_G1 operator-(const mnt4_G1 &other) const;
65
66 mnt4_G1 add(const mnt4_G1 &other) const;
67 mnt4_G1 mixed_add(const mnt4_G1 &other) const;
68 mnt4_G1 dbl() const;
69
70 bool is_well_formed() const;
71
72 static mnt4_G1 zero();
73 static mnt4_G1 one();
74 static mnt4_G1 random_element();
75
76 static size_t size_in_bits() { return mnt4_Fq::size_in_bits() + 1; }
79
80 friend std::ostream& operator<<(std::ostream &out, const mnt4_G1 &g);
81 friend std::istream& operator>>(std::istream &in, mnt4_G1 &g);
82
83 static void batch_to_special_all_non_zeros(std::vector<mnt4_G1> &vec);
84};
85
86template<mp_size_t m>
87mnt4_G1 operator*(const bigint<m> &lhs, const mnt4_G1 &rhs)
88{
89 return scalar_mul<mnt4_G1, m>(rhs, lhs);
90}
91
92template<mp_size_t m, const bigint<m>& modulus_p>
94{
95 return scalar_mul<mnt4_G1, m>(rhs, lhs.as_bigint());
96}
97
98std::ostream& operator<<(std::ostream& out, const std::vector<mnt4_G1> &v);
99std::istream& operator>>(std::istream& in, std::vector<mnt4_G1> &v);
100
101} // libff
102
103#endif // MNT4_G1_HPP_
bigint< n > as_bigint() const
static bigint< mnt4_Fq::num_limbs > base_field_char()
Definition mnt4_g1.hpp:77
static std::vector< size_t > wnaf_window_table
Definition mnt4_g1.hpp:32
static mnt4_G1 zero()
Definition mnt4_g1.cpp:378
static bool initialized
Definition mnt4_g1.hpp:36
static mnt4_G1 random_element()
Definition mnt4_g1.cpp:388
mnt4_Fr scalar_field
Definition mnt4_g1.hpp:41
friend std::istream & operator>>(std::istream &in, mnt4_G1 &g)
Definition mnt4_g1.cpp:409
mnt4_G1 operator+(const mnt4_G1 &other) const
Definition mnt4_g1.cpp:138
mnt4_G1 operator-() const
Definition mnt4_g1.cpp:213
void print() const
Definition mnt4_g1.cpp:41
mnt4_G1(const mnt4_Fq &X, const mnt4_Fq &Y, const mnt4_Fq &Z)
Definition mnt4_g1.hpp:48
static mnt4_G1 one()
Definition mnt4_g1.cpp:383
static mnt4_G1 G1_one
Definition mnt4_g1.hpp:35
static mnt4_G1 G1_zero
Definition mnt4_g1.hpp:34
void to_affine_coordinates()
Definition mnt4_g1.cpp:72
bool operator!=(const mnt4_G1 &other) const
Definition mnt4_g1.cpp:133
bool is_zero() const
Definition mnt4_g1.cpp:99
void print_coordinates() const
Definition mnt4_g1.cpp:57
static bigint< mnt4_Fr::num_limbs > order()
Definition mnt4_g1.hpp:78
static std::vector< size_t > fixed_base_exp_window_table
Definition mnt4_g1.hpp:33
bool is_well_formed() const
Definition mnt4_g1.cpp:352
mnt4_Fq base_field
Definition mnt4_g1.hpp:40
static size_t size_in_bits()
Definition mnt4_g1.hpp:76
mnt4_G1 add(const mnt4_G1 &other) const
Definition mnt4_g1.cpp:224
bool is_special() const
Definition mnt4_g1.cpp:94
mnt4_G1 mixed_add(const mnt4_G1 &other) const
Definition mnt4_g1.cpp:269
static mnt4_Fq coeff_a
Definition mnt4_g1.hpp:37
friend std::ostream & operator<<(std::ostream &out, const mnt4_G1 &g)
Definition mnt4_g1.cpp:393
static mnt4_Fq coeff_b
Definition mnt4_g1.hpp:38
void to_special()
Definition mnt4_g1.cpp:89
mnt4_G1 dbl() const
Definition mnt4_g1.cpp:319
mnt4_G1(const mnt4_Fq &X, const mnt4_Fq &Y)
Definition mnt4_g1.hpp:47
static void batch_to_special_all_non_zeros(std::vector< mnt4_G1 > &vec)
Definition mnt4_g1.cpp:489
bool operator==(const mnt4_G1 &other) const
Definition mnt4_g1.cpp:104
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