Clearmatics Libff  0.1
C++ library for Finite Fields and Elliptic Curves
fp6_3over2.hpp
Go to the documentation of this file.
1 
10 #ifndef FP6_3OVER2_HPP_
11 #define FP6_3OVER2_HPP_
14 #include <vector>
15 
16 namespace libff
17 {
18 
19 template<mp_size_t n, const bigint<n> &modulus> class Fp6_3over2_model;
20 
21 template<mp_size_t n, const bigint<n> &modulus>
22 std::ostream &operator<<(std::ostream &, const Fp6_3over2_model<n, modulus> &);
23 
24 template<mp_size_t n, const bigint<n> &modulus>
25 std::istream &operator>>(std::istream &, Fp6_3over2_model<n, modulus> &);
26 
33 template<mp_size_t n, const bigint<n> &modulus> class Fp6_3over2_model
34 {
35 public:
38 
39  // (modulus^6-1)/2
41  // modulus^6 = 2^s * t + 1
42  static std::size_t s;
43  // with t odd
44  static bigint<6 * n> t;
45  // (t-1)/2
47  // a quadratic nonresidue in Fp6
49  // nqr^t
51 
57 
58  static const size_t tower_extension_degree = 3;
59 
62  Fp6_3over2_model(const my_Fp2 &c0, const my_Fp2 &c1, const my_Fp2 &c2)
63  {
64  this->coeffs[0] = c0;
65  this->coeffs[1] = c1;
66  this->coeffs[2] = c2;
67  return;
68  };
69 
70  void clear()
71  {
72  coeffs[0].clear();
73  coeffs[1].clear();
74  coeffs[2].clear();
75  }
76  void print() const
77  {
78  printf("c0/c1/c2:\n");
79  coeffs[0].print();
80  coeffs[1].print();
81  coeffs[2].print();
82  }
83 
87 
88  bool is_zero() const
89  {
90  return coeffs[0].is_zero() && coeffs[1].is_zero() &&
91  coeffs[2].is_zero();
92  }
93  bool operator==(const Fp6_3over2_model &other) const;
94  bool operator!=(const Fp6_3over2_model &other) const;
95 
96  Fp6_3over2_model operator+(const Fp6_3over2_model &other) const;
97  Fp6_3over2_model operator-(const Fp6_3over2_model &other) const;
98  Fp6_3over2_model operator*(const Fp6_3over2_model &other) const;
100  Fp6_3over2_model squared() const;
101  Fp6_3over2_model inverse() const;
102  Fp6_3over2_model Frobenius_map(unsigned long power) const;
103 
104  static my_Fp2 mul_by_non_residue(const my_Fp2 &elt);
105 
106  template<mp_size_t m>
107  Fp6_3over2_model operator^(const bigint<m> &other) const;
108 
109  static bigint<n> base_field_char() { return modulus; }
110  static constexpr size_t extension_degree() { return 6; }
111 
112  friend std::ostream &operator<<<n, modulus>(
113  std::ostream &out, const Fp6_3over2_model<n, modulus> &el);
114  friend std::istream &operator>>
115  <n, modulus>(std::istream &in, Fp6_3over2_model<n, modulus> &el);
116 };
117 
118 template<mp_size_t n, const bigint<n> &modulus>
119 std::ostream &operator<<(
120  std::ostream &out, const std::vector<Fp6_3over2_model<n, modulus>> &v);
121 
122 template<mp_size_t n, const bigint<n> &modulus>
123 std::istream &operator>>(
124  std::istream &in, std::vector<Fp6_3over2_model<n, modulus>> &v);
125 
126 template<mp_size_t n, const bigint<n> &modulus>
127 Fp6_3over2_model<n, modulus> operator*(
128  const Fp_model<n, modulus> &lhs, const Fp6_3over2_model<n, modulus> &rhs);
129 
130 template<mp_size_t n, const bigint<n> &modulus>
131 Fp6_3over2_model<n, modulus> operator*(
132  const Fp2_model<n, modulus> &lhs, const Fp6_3over2_model<n, modulus> &rhs);
133 
134 template<mp_size_t n, const bigint<n> &modulus>
136 
137 template<mp_size_t n, const bigint<n> &modulus>
139 
140 template<mp_size_t n, const bigint<n> &modulus>
141 bigint<6 * n> Fp6_3over2_model<n, modulus>::t;
142 
143 template<mp_size_t n, const bigint<n> &modulus>
145 
146 template<mp_size_t n, const bigint<n> &modulus>
147 Fp6_3over2_model<n, modulus> Fp6_3over2_model<n, modulus>::nqr;
148 
149 template<mp_size_t n, const bigint<n> &modulus>
150 Fp6_3over2_model<n, modulus> Fp6_3over2_model<n, modulus>::nqr_to_t;
151 
152 template<mp_size_t n, const bigint<n> &modulus>
153 Fp2_model<n, modulus> Fp6_3over2_model<n, modulus>::non_residue;
154 
155 template<mp_size_t n, const bigint<n> &modulus>
157 
158 template<mp_size_t n, const bigint<n> &modulus>
160 
161 } // namespace libff
162 
164 
165 #endif // FP6_3OVER2_HPP_
libff::Fp6_3over2_model::nqr_to_t
static Fp6_3over2_model< n, modulus > nqr_to_t
Definition: fp6_3over2.hpp:50
libff::Fp6_3over2_model
Definition: fp6_3over2.hpp:19
libff::Fp6_3over2_model::print
void print() const
Definition: fp6_3over2.hpp:76
libff::Fp6_3over2_model::one
static Fp6_3over2_model< n, modulus > one()
libff::Fp6_3over2_model::coeffs
my_Fp2 coeffs[3]
Definition: fp6_3over2.hpp:60
libff::Fp6_3over2_model::zero
static Fp6_3over2_model< n, modulus > zero()
libff
Definition: ffi.cpp:8
libff::Fp6_3over2_model::my_Fp
Fp_model< n, modulus > my_Fp
Definition: fp6_3over2.hpp:36
libff::Fp6_3over2_model::Fp6_3over2_model
Fp6_3over2_model()
Definition: fp6_3over2.hpp:61
libff::Fp6_3over2_model::Fp6_3over2_model
Fp6_3over2_model(const my_Fp2 &c0, const my_Fp2 &c1, const my_Fp2 &c2)
Definition: fp6_3over2.hpp:62
fp.hpp
libff::Fp6_3over2_model::euler
static bigint< 6 *n > euler
Definition: fp6_3over2.hpp:40
libff::Fp6_3over2_model::base_field_char
static bigint< n > base_field_char()
Definition: fp6_3over2.hpp:109
libff::Fp6_3over2_model::random_element
static Fp6_3over2_model< n, modulus > random_element()
libff::operator>>
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
Definition: alt_bn128_g1.cpp:446
libff::Fp6_3over2_model::operator+
Fp6_3over2_model operator+(const Fp6_3over2_model &other) const
libff::Fp6_3over2_model::clear
void clear()
Definition: fp6_3over2.hpp:70
libff::Fp6_3over2_model::nqr
static Fp6_3over2_model< n, modulus > nqr
Definition: fp6_3over2.hpp:48
libff::Fp6_3over2_model::is_zero
bool is_zero() const
Definition: fp6_3over2.hpp:88
libff::Fp6_3over2_model::t_minus_1_over_2
static bigint< 6 *n > t_minus_1_over_2
Definition: fp6_3over2.hpp:46
libff::Fp6_3over2_model::Frobenius_coeffs_c1
static my_Fp2 Frobenius_coeffs_c1[6]
non_residue^((modulus^i-1)/3) for i=0,1,2,3,4,5
Definition: fp6_3over2.hpp:54
libff::Fp6_3over2_model::operator!=
bool operator!=(const Fp6_3over2_model &other) const
libff::Fp6_3over2_model::Frobenius_coeffs_c2
static my_Fp2 Frobenius_coeffs_c2[6]
non_residue^((2*modulus^i-2)/3) for i=0,1,2,3,4,5
Definition: fp6_3over2.hpp:56
libff::Fp2_model::is_zero
bool is_zero() const
Definition: fp2.hpp:89
libff::Fp6_3over2_model::extension_degree
static constexpr size_t extension_degree()
Definition: fp6_3over2.hpp:110
libff::Fp6_3over2_model::inverse
Fp6_3over2_model inverse() const
libff::Fp6_3over2_model::mul_by_non_residue
static my_Fp2 mul_by_non_residue(const my_Fp2 &elt)
fp2.hpp
libff::bigint< 6 *n >
libff::Fp6_3over2_model::Frobenius_map
Fp6_3over2_model Frobenius_map(unsigned long power) const
libff::Fp6_3over2_model::tower_extension_degree
static const size_t tower_extension_degree
Definition: fp6_3over2.hpp:58
libff::Fp6_3over2_model::my_Fp2
Fp2_model< n, modulus > my_Fp2
Definition: fp6_3over2.hpp:37
libff::Fp6_3over2_model::squared
Fp6_3over2_model squared() const
libff::Fp_model
Definition: fp.hpp:20
libff::Fp6_3over2_model::operator^
Fp6_3over2_model operator^(const bigint< m > &other) const
libff::operator<<
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
Definition: alt_bn128_g1.cpp:436
libff::operator*
alt_bn128_G1 operator*(const bigint< m > &lhs, const alt_bn128_G1 &rhs)
Definition: alt_bn128_g1.hpp:99
libff::Fp6_3over2_model::operator==
bool operator==(const Fp6_3over2_model &other) const
fp6_3over2.tcc
libff::Fp2_model
Definition: fp2.hpp:18
libff::Fp2_model::print
void print() const
Definition: fp2.hpp:78
libff::Fp6_3over2_model::operator-
Fp6_3over2_model operator-() const
libff::power
FieldT power(const FieldT &base, const bigint< m > &exponent)
libff::Fp6_3over2_model::non_residue
static my_Fp2 non_residue
Definition: fp6_3over2.hpp:52
libff::Fp6_3over2_model::operator*
Fp6_3over2_model operator*(const Fp6_3over2_model &other) const
libff::Fp6_3over2_model::t
static bigint< 6 *n > t
Definition: fp6_3over2.hpp:44
libff::Fp6_3over2_model::s
static std::size_t s
Definition: fp6_3over2.hpp:42
libff::Fp2_model::clear
void clear()
Definition: fp2.hpp:73