Clearmatics Libff  0.1
C++ library for Finite Fields and Elliptic Curves
fp6_2over3.hpp
Go to the documentation of this file.
1 
10 #ifndef FP6_2OVER3_HPP_
11 #define FP6_2OVER3_HPP_
15 
16 namespace libff
17 {
18 
26 template<mp_size_t n, const bigint<n> &modulus> class Fp6_2over3_model;
27 
28 template<mp_size_t n, const bigint<n> &modulus>
29 std::ostream &operator<<(std::ostream &, const Fp6_2over3_model<n, modulus> &);
30 
31 template<mp_size_t n, const bigint<n> &modulus>
32 std::istream &operator>>(std::istream &, Fp6_2over3_model<n, modulus> &);
33 
34 template<mp_size_t n, const bigint<n> &modulus> class Fp6_2over3_model
35 {
36 public:
40  typedef my_Fp3 my_Fpe;
41 
45 
46  static const size_t tower_extension_degree = 2;
47 
50  Fp6_2over3_model(const my_Fp3 &c0, const my_Fp3 &c1)
51  {
52  this->coeffs[0] = c0;
53  this->coeffs[1] = c1;
54  return;
55  };
56 
57  void print() const
58  {
59  printf("c0/c1:\n");
60  coeffs[0].print();
61  coeffs[1].print();
62  }
63  void clear()
64  {
65  coeffs[0].clear();
66  coeffs[1].clear();
67  }
68 
72 
73  bool is_zero() const { return coeffs[0].is_zero() && coeffs[1].is_zero(); }
74  bool operator==(const Fp6_2over3_model &other) const;
75  bool operator!=(const Fp6_2over3_model &other) const;
76 
77  Fp6_2over3_model operator+(const Fp6_2over3_model &other) const;
78  Fp6_2over3_model operator-(const Fp6_2over3_model &other) const;
79  Fp6_2over3_model operator*(const Fp6_2over3_model &other) const;
81  const my_Fp &ell_0, const my_Fp &ell_VW, const my_Fp &ell_VV) const;
82  Fp6_2over3_model mul_by_2345(const Fp6_2over3_model &other) const;
84  Fp6_2over3_model squared() const;
85  Fp6_2over3_model inverse() const;
86  Fp6_2over3_model Frobenius_map(unsigned long power) const;
89 
90  static my_Fp3 mul_by_non_residue(const my_Fp3 &elem);
91 
92  template<mp_size_t m>
93  Fp6_2over3_model cyclotomic_exp(const bigint<m> &exponent) const;
94 
95  static bigint<n> base_field_char() { return modulus; }
96  static constexpr size_t extension_degree() { return 6; }
97 
98  friend std::ostream &operator<<<n, modulus>(
99  std::ostream &out, const Fp6_2over3_model<n, modulus> &el);
100  friend std::istream &operator>>
101  <n, modulus>(std::istream &in, Fp6_2over3_model<n, modulus> &el);
102 };
103 
104 template<mp_size_t n, const bigint<n> &modulus>
105 std::ostream &operator<<(
106  std::ostream &out, const std::vector<Fp6_2over3_model<n, modulus>> &v);
107 
108 template<mp_size_t n, const bigint<n> &modulus>
109 std::istream &operator>>(
110  std::istream &in, std::vector<Fp6_2over3_model<n, modulus>> &v);
111 
112 template<mp_size_t n, const bigint<n> &modulus>
113 Fp6_2over3_model<n, modulus> operator*(
114  const Fp_model<n, modulus> &lhs, const Fp6_2over3_model<n, modulus> &rhs);
115 
116 template<mp_size_t n, const bigint<n> &modulus, mp_size_t m>
117 Fp6_2over3_model<n, modulus> operator^(
118  const Fp6_2over3_model<n, modulus> &self, const bigint<m> &exponent);
119 
120 template<
121  mp_size_t n,
122  const bigint<n> &modulus,
123  mp_size_t m,
124  const bigint<m> &exp_modulus>
125 Fp6_2over3_model<n, modulus> operator^(
126  const Fp6_2over3_model<n, modulus> &self,
127  const Fp_model<m, exp_modulus> &exponent);
128 
129 template<mp_size_t n, const bigint<n> &modulus>
130 Fp_model<n, modulus> Fp6_2over3_model<n, modulus>::non_residue;
131 
132 template<mp_size_t n, const bigint<n> &modulus>
134 
135 } // namespace libff
136 
138 
139 #endif // FP6_2OVER3_HPP_
libff::Fp6_2over3_model::one
static Fp6_2over3_model< n, modulus > one()
libff::Fp6_2over3_model::extension_degree
static constexpr size_t extension_degree()
Definition: fp6_2over3.hpp:96
libff::Fp3_model::print
void print() const
Definition: fp3.hpp:77
libff::Fp6_2over3_model::clear
void clear()
Definition: fp6_2over3.hpp:63
libff::Fp6_2over3_model::mul_by_045
Fp6_2over3_model mul_by_045(const my_Fp &ell_0, const my_Fp &ell_VW, const my_Fp &ell_VV) const
libff
Definition: ffi.cpp:8
fp.hpp
libff::Fp6_2over3_model::mul_by_non_residue
static my_Fp3 mul_by_non_residue(const my_Fp3 &elem)
libff::operator>>
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
Definition: alt_bn128_g1.cpp:446
libff::Fp6_2over3_model::coeffs
my_Fp3 coeffs[2]
Definition: fp6_2over3.hpp:48
libff::Fp6_2over3_model::is_zero
bool is_zero() const
Definition: fp6_2over3.hpp:73
libff::Fp6_2over3_model::operator!=
bool operator!=(const Fp6_2over3_model &other) const
libff::Fp6_2over3_model::unitary_inverse
Fp6_2over3_model unitary_inverse() const
libff::Fp6_2over3_model::zero
static Fp6_2over3_model< n, modulus > zero()
libff::Fp6_2over3_model::operator*
Fp6_2over3_model operator*(const Fp6_2over3_model &other) const
libff::Fp6_2over3_model::operator+
Fp6_2over3_model operator+(const Fp6_2over3_model &other) const
libff::Fp6_2over3_model::tower_extension_degree
static const size_t tower_extension_degree
Definition: fp6_2over3.hpp:46
libff::Fp6_2over3_model::Fp6_2over3_model
Fp6_2over3_model()
Definition: fp6_2over3.hpp:49
libff::Fp6_2over3_model::cyclotomic_squared
Fp6_2over3_model cyclotomic_squared() const
libff::Fp6_2over3_model::my_Fp
Fp_model< n, modulus > my_Fp
Definition: fp6_2over3.hpp:37
libff::Fp6_2over3_model::my_Fpe
my_Fp3 my_Fpe
Definition: fp6_2over3.hpp:40
fp2.hpp
libff::bigint
Definition: bigint.hpp:20
libff::operator^
bn128_GT operator^(const bn128_GT &rhs, const bigint< m > &lhs)
Definition: bn128_gt.hpp:45
libff::Fp6_2over3_model::Frobenius_map
Fp6_2over3_model Frobenius_map(unsigned long power) const
libff::Fp6_2over3_model::non_residue
static my_Fp non_residue
Definition: fp6_2over3.hpp:42
libff::Fp3_model
Definition: fp3.hpp:18
libff::Fp6_2over3_model::Frobenius_coeffs_c1
static my_Fp Frobenius_coeffs_c1[6]
non_residue^((modulus^i-1)/6) for i=0,1,2,3,4,5
Definition: fp6_2over3.hpp:44
libff::Fp6_2over3_model::operator-
Fp6_2over3_model operator-() const
libff::Fp6_2over3_model::Fp6_2over3_model
Fp6_2over3_model(const my_Fp3 &c0, const my_Fp3 &c1)
Definition: fp6_2over3.hpp:50
libff::Fp6_2over3_model::my_Fp3
Fp3_model< n, modulus > my_Fp3
Definition: fp6_2over3.hpp:39
libff::Fp_model
Definition: fp.hpp:20
libff::Fp6_2over3_model::mul_by_2345
Fp6_2over3_model mul_by_2345(const Fp6_2over3_model &other) const
libff::operator<<
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
Definition: alt_bn128_g1.cpp:436
libff::Fp6_2over3_model::print
void print() const
Definition: fp6_2over3.hpp:57
libff::Fp6_2over3_model::operator==
bool operator==(const Fp6_2over3_model &other) const
libff::Fp6_2over3_model::cyclotomic_exp
Fp6_2over3_model cyclotomic_exp(const bigint< m > &exponent) const
libff::operator*
alt_bn128_G1 operator*(const bigint< m > &lhs, const alt_bn128_G1 &rhs)
Definition: alt_bn128_g1.hpp:99
libff::Fp3_model::is_zero
bool is_zero() const
Definition: fp3.hpp:89
fp6_2over3.tcc
libff::Fp6_2over3_model::random_element
static Fp6_2over3_model< n, modulus > random_element()
libff::Fp2_model
Definition: fp2.hpp:18
libff::Fp6_2over3_model::my_Fp2
Fp2_model< n, modulus > my_Fp2
Definition: fp6_2over3.hpp:38
libff::Fp6_2over3_model::base_field_char
static bigint< n > base_field_char()
Definition: fp6_2over3.hpp:95
libff::Fp3_model::clear
void clear()
Definition: fp3.hpp:71
libff::power
FieldT power(const FieldT &base, const bigint< m > &exponent)
libff::Fp6_2over3_model
Definition: fp6_2over3.hpp:26
libff::Fp6_2over3_model::inverse
Fp6_2over3_model inverse() const
libff::Fp6_2over3_model::squared
Fp6_2over3_model squared() const
fp3.hpp