Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
edwards_g2.hpp
Go to the documentation of this file.
1
8#ifndef EDWARDS_G2_HPP_
9#define EDWARDS_G2_HPP_
10#include <iostream>
11#include <vector>
12
15
16namespace libff {
17
18class edwards_G2;
19std::ostream& operator<<(std::ostream &, const edwards_G2&);
20std::istream& operator>>(std::istream &, edwards_G2&);
21
23public:
24#ifdef PROFILE_OP_COUNTS
25 static long long add_cnt;
26 static long long dbl_cnt;
27#endif
28 static std::vector<size_t> wnaf_window_table;
29 static std::vector<size_t> fixed_base_exp_window_table;
30
33 static bool initialized;
34
36 edwards_G2();
37private:
38 edwards_G2(const edwards_Fq3& X, const edwards_Fq3& Y, const edwards_Fq3& Z) : X(X), Y(Y), Z(Z) {};
39public:
40 static edwards_Fq3 mul_by_a(const edwards_Fq3 &elt);
41 static edwards_Fq3 mul_by_d(const edwards_Fq3 &elt);
45
46 // using inverted coordinates
47 edwards_G2(const edwards_Fq3& X, const edwards_Fq3& Y) : X(Y), Y(X), Z(X*Y) {};
48
49 void print() const;
50 void print_coordinates() const;
51
53 void to_special();
54 bool is_special() const;
55
56 bool is_zero() const;
57
58 bool operator==(const edwards_G2 &other) const;
59 bool operator!=(const edwards_G2 &other) const;
60
61 edwards_G2 operator+(const edwards_G2 &other) const;
62 edwards_G2 operator-() const;
63 edwards_G2 operator-(const edwards_G2 &other) const;
64
65 edwards_G2 add(const edwards_G2 &other) const;
66 edwards_G2 mixed_add(const edwards_G2 &other) const;
67 edwards_G2 dbl() const;
68 edwards_G2 mul_by_q() const;
69
70 bool is_well_formed() const;
71
72 static edwards_G2 zero();
73 static edwards_G2 one();
75
76 static size_t size_in_bits() { return twist_field::size_in_bits() + 1; }
79
80 friend std::ostream& operator<<(std::ostream &out, const edwards_G2 &g);
81 friend std::istream& operator>>(std::istream &in, edwards_G2 &g);
82
83 static void batch_to_special_all_non_zeros(std::vector<edwards_G2> &vec);
84};
85
86template<mp_size_t m>
88{
89 return scalar_mul<edwards_G2, m>(rhs, lhs);
90}
91
92template<mp_size_t m, const bigint<m>& modulus_p>
94{
95 return scalar_mul<edwards_G2, m>(rhs, lhs.as_bigint());
96}
97
98} // libff
99#endif // EDWARDS_G2_HPP_
bigint< n > as_bigint() const
edwards_G2 dbl() const
static edwards_G2 random_element()
edwards_Fq base_field
bool is_well_formed() const
static edwards_G2 zero()
bool operator!=(const edwards_G2 &other) const
bool operator==(const edwards_G2 &other) const
static void batch_to_special_all_non_zeros(std::vector< edwards_G2 > &vec)
edwards_G2 add(const edwards_G2 &other) const
edwards_G2(const edwards_Fq3 &X, const edwards_Fq3 &Y)
friend std::ostream & operator<<(std::ostream &out, const edwards_G2 &g)
static size_t size_in_bits()
edwards_G2 operator-() const
edwards_Fr scalar_field
friend std::istream & operator>>(std::istream &in, edwards_G2 &g)
void print() const
static std::vector< size_t > fixed_base_exp_window_table
static bool initialized
static bigint< scalar_field::num_limbs > order()
edwards_G2 mixed_add(const edwards_G2 &other) const
static edwards_G2 one()
static edwards_Fq3 mul_by_a(const edwards_Fq3 &elt)
void to_affine_coordinates()
void print_coordinates() const
static edwards_Fq3 mul_by_d(const edwards_Fq3 &elt)
edwards_G2 operator+(const edwards_G2 &other) const
static edwards_G2 G2_one
static std::vector< size_t > wnaf_window_table
static bigint< base_field::num_limbs > base_field_char()
static edwards_G2 G2_zero
edwards_Fq3 twist_field
edwards_G2 mul_by_q() const
bool is_zero() const
bool is_special() const
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