Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
mnt4_g2.hpp
Go to the documentation of this file.
1
12#ifndef MNT4_G2_HPP_
13#define MNT4_G2_HPP_
14
15#include <vector>
16
19
20namespace libff {
21
22class mnt4_G2;
23std::ostream& operator<<(std::ostream &, const mnt4_G2&);
24std::istream& operator>>(std::istream &, mnt4_G2&);
25
26class mnt4_G2 {
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;
40
44
46
47 // using projective coordinates
48 mnt4_G2();
49 mnt4_G2(const mnt4_Fq2& X, const mnt4_Fq2& Y, const mnt4_Fq2& Z) : X(X), Y(Y), Z(Z) {};
50
51 static mnt4_Fq2 mul_by_a(const mnt4_Fq2 &elt);
52 static mnt4_Fq2 mul_by_b(const mnt4_Fq2 &elt);
53
54 void print() const;
55 void print_coordinates() const;
56
58 void to_special();
59 bool is_special() const;
60
61 bool is_zero() const;
62
63 bool operator==(const mnt4_G2 &other) const;
64 bool operator!=(const mnt4_G2 &other) const;
65
66 mnt4_G2 operator+(const mnt4_G2 &other) const;
67 mnt4_G2 operator-() const;
68 mnt4_G2 operator-(const mnt4_G2 &other) const;
69
70 mnt4_G2 add(const mnt4_G2 &other) const;
71 mnt4_G2 mixed_add(const mnt4_G2 &other) const;
72 mnt4_G2 dbl() const;
73 mnt4_G2 mul_by_q() const;
74
75 bool is_well_formed() const;
76
77 static mnt4_G2 zero();
78 static mnt4_G2 one();
79 static mnt4_G2 random_element();
80
81 static size_t size_in_bits() { return mnt4_Fq2::size_in_bits() + 1; }
84
85 friend std::ostream& operator<<(std::ostream &out, const mnt4_G2 &g);
86 friend std::istream& operator>>(std::istream &in, mnt4_G2 &g);
87
88 static void batch_to_special_all_non_zeros(std::vector<mnt4_G2> &vec);
89};
90
91template<mp_size_t m>
92mnt4_G2 operator*(const bigint<m> &lhs, const mnt4_G2 &rhs)
93{
94 return scalar_mul<mnt4_G2, m>(rhs, lhs);
95}
96
97template<mp_size_t m, const bigint<m>& modulus_p>
99{
100 return scalar_mul<mnt4_G2, m>(rhs, lhs.as_bigint());
101}
102
103} // libff
104
105#endif // MNT4_G2_HPP_
bigint< n > as_bigint() const
static bool initialized
Definition mnt4_g2.hpp:36
static mnt4_G2 random_element()
Definition mnt4_g2.cpp:412
bool operator!=(const mnt4_G2 &other) const
Definition mnt4_g2.cpp:149
mnt4_Fq2 twist_field
Definition mnt4_g2.hpp:42
friend std::istream & operator>>(std::istream &in, mnt4_G2 &g)
Definition mnt4_g2.cpp:433
static std::vector< size_t > fixed_base_exp_window_table
Definition mnt4_g2.hpp:33
friend std::ostream & operator<<(std::ostream &out, const mnt4_G2 &g)
Definition mnt4_g2.cpp:417
mnt4_Fr scalar_field
Definition mnt4_g2.hpp:43
static std::vector< size_t > wnaf_window_table
Definition mnt4_g2.hpp:32
mnt4_Fq base_field
Definition mnt4_g2.hpp:41
static mnt4_Fq2 coeff_b
Definition mnt4_g2.hpp:39
mnt4_G2 mixed_add(const mnt4_G2 &other) const
Definition mnt4_g2.cpp:285
static mnt4_G2 G2_zero
Definition mnt4_g2.hpp:34
mnt4_G2 operator-() const
Definition mnt4_g2.cpp:229
void print_coordinates() const
Definition mnt4_g2.cpp:70
static void batch_to_special_all_non_zeros(std::vector< mnt4_G2 > &vec)
Definition mnt4_g2.cpp:480
static size_t size_in_bits()
Definition mnt4_g2.hpp:81
mnt4_G2(const mnt4_Fq2 &X, const mnt4_Fq2 &Y, const mnt4_Fq2 &Z)
Definition mnt4_g2.hpp:49
bool is_well_formed() const
Definition mnt4_g2.cpp:375
static bigint< mnt4_Fq::num_limbs > base_field_char()
Definition mnt4_g2.hpp:82
static mnt4_G2 zero()
Definition mnt4_g2.cpp:402
void to_special()
Definition mnt4_g2.cpp:105
bool is_special() const
Definition mnt4_g2.cpp:110
mnt4_G2 dbl() const
Definition mnt4_g2.cpp:335
mnt4_G2 operator+(const mnt4_G2 &other) const
Definition mnt4_g2.cpp:154
static bigint< mnt4_Fr::num_limbs > order()
Definition mnt4_g2.hpp:83
static mnt4_G2 G2_one
Definition mnt4_g2.hpp:35
static mnt4_Fq2 coeff_a
Definition mnt4_g2.hpp:38
static mnt4_Fq2 mul_by_b(const mnt4_Fq2 &elt)
Definition mnt4_g2.cpp:37
void to_affine_coordinates()
Definition mnt4_g2.cpp:88
void print() const
Definition mnt4_g2.cpp:52
bool operator==(const mnt4_G2 &other) const
Definition mnt4_g2.cpp:120
mnt4_G2 mul_by_q() const
Definition mnt4_g2.cpp:368
mnt4_G2 add(const mnt4_G2 &other) const
Definition mnt4_g2.cpp:240
mnt4_Fq2 Y
Definition mnt4_g2.hpp:45
mnt4_Fq2 X
Definition mnt4_g2.hpp:45
static mnt4_Fq2 mul_by_a(const mnt4_Fq2 &elt)
Definition mnt4_g2.cpp:32
mnt4_Fq2 Z
Definition mnt4_g2.hpp:45
static mnt4_Fq2 twist
Definition mnt4_g2.hpp:37
static mnt4_G2 one()
Definition mnt4_g2.cpp:407
bool is_zero() const
Definition mnt4_g2.cpp:115
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