Clearmatics Libsnark  0.1
C++ library for zkSNARK proofs
fp6_3over2_gadgets.hpp
Go to the documentation of this file.
1 
9 #ifndef LIBSNARK_GADGETLIB1_GADGETS_FIELDS_FP6_3OVER2_GADGETS_HPP_
10 #define LIBSNARK_GADGETLIB1_GADGETS_FIELDS_FP6_3OVER2_GADGETS_HPP_
11 
14 
15 #include <libff/algebra/curves/public_params.hpp>
16 
17 namespace libsnark
18 {
19 
20 template<typename Fp6T>
21 class Fp6_3over2_variable : public gadget<typename Fp6T::my_Fp>
22 {
23 public:
24  using FieldT = typename Fp6T::my_Fp;
25  using Fp2T = typename Fp6T::my_Fp2;
26 
30 
32  protoboard<FieldT> &pb, const std::string &annotation_prefix);
33 
36  const Fp6_3over2_variable<Fp6T> &el,
37  const std::string &annotation_prefix);
38 
41  const Fp6T &el,
42  const std::string &annotation_prefix);
43 
46  const Fp2_variable<Fp2T> &c0,
47  const Fp2_variable<Fp2T> &c1,
48  const Fp2_variable<Fp2T> &c2,
49  const std::string &annotation_prefix);
50 
51  Fp6_3over2_variable<Fp6T> operator*(const FieldT &scalar) const;
52  Fp6_3over2_variable<Fp6T> operator*(const Fp2T &fp2_constant) const;
53  Fp6_3over2_variable<Fp6T> operator*(const Fp6T &fp6_constant) const;
55  const Fp6_3over2_variable<Fp6T> &other) const;
57  const Fp6_3over2_variable<Fp6T> &other) const;
60 
61  void evaluate() const;
62  void generate_r1cs_witness(const Fp6T &el);
63  Fp6T get_element() const;
64 };
65 
84 template<typename Fp6T>
85 class Fp6_3over2_mul_gadget : public gadget<typename Fp6T::my_Fp>
86 {
87 public:
88  using FieldT = typename Fp6T::my_Fp;
89  using Fp2T = typename Fp6T::my_Fp2;
90 
94 
95  // These conditions follow from the above expressions for c0, c1, c2:
96  // v0 = c0 - non_residue*((a1 + a2)(b1 + b2) - v1 - v2)
97  // (a0 + a1)(b0 + b1) = c1 + v0 + v1 - non_residue * v2
98  // (a0 + a2)(b0 + b2) = c2 + v0 + v2 - v1
99 
106 
109  const Fp6_3over2_variable<Fp6T> &A,
110  const Fp6_3over2_variable<Fp6T> &B,
111  const Fp6_3over2_variable<Fp6T> &result,
112  const std::string &annotation_prefix);
113 
115  void generate_r1cs_witness();
116 };
117 
118 } // namespace libsnark
119 
121 
122 #endif // LIBSNARK_GADGETLIB1_GADGETS_FIELDS_FP6_3OVER2_GADGETS_HPP_
libsnark::Fp6_3over2_mul_gadget
Definition: fp6_3over2_gadgets.hpp:85
libsnark::Fp6_3over2_mul_gadget::_result
Fp6_3over2_variable< Fp6T > _result
Definition: fp6_3over2_gadgets.hpp:93
libsnark::Fp6_3over2_variable::operator*
Fp6_3over2_variable< Fp6T > operator*(const FieldT &scalar) const
libsnark::gadget< Fp6T::my_Fp >::annotation_prefix
const std::string annotation_prefix
Definition: gadget.hpp:20
libsnark::Fp6_3over2_mul_gadget::Fp2T
typename Fp6T::my_Fp2 Fp2T
Definition: fp6_3over2_gadgets.hpp:89
libsnark::Fp6_3over2_mul_gadget::generate_r1cs_constraints
void generate_r1cs_constraints()
fp6_3over2_gadgets.tcc
libsnark::Fp6_3over2_mul_gadget::_compute_a0a2_times_b0b2
Fp2_mul_gadget< Fp2T > _compute_a0a2_times_b0b2
Definition: fp6_3over2_gadgets.hpp:105
libsnark::Fp6_3over2_mul_gadget::_A
Fp6_3over2_variable< Fp6T > _A
Definition: fp6_3over2_gadgets.hpp:91
libsnark
Definition: accumulation_vector.hpp:18
libsnark::Fp6_3over2_mul_gadget::_compute_v2
Fp2_mul_gadget< Fp2T > _compute_v2
Definition: fp6_3over2_gadgets.hpp:101
libsnark::Fp6_3over2_mul_gadget::FieldT
typename Fp6T::my_Fp FieldT
Definition: fp6_3over2_gadgets.hpp:88
libsnark::Fp2_variable
Definition: fp2_gadgets.hpp:27
fp2_gadgets.hpp
libsnark::gadget< Fp6T::my_Fp >::pb
protoboard< Fp6T::my_Fp > & pb
Definition: gadget.hpp:19
libsnark::Fp6_3over2_mul_gadget::_B
Fp6_3over2_variable< Fp6T > _B
Definition: fp6_3over2_gadgets.hpp:92
libsnark::Fp6_3over2_variable::evaluate
void evaluate() const
gadget.hpp
libsnark::Fp6_3over2_mul_gadget::_compute_v0
Fp2_mul_gadget< Fp2T > _compute_v0
Definition: fp6_3over2_gadgets.hpp:103
libsnark::gadget
Definition: gadget.hpp:16
libsnark::Fp6_3over2_variable::_c0
Fp2_variable< Fp2T > _c0
Definition: fp6_3over2_gadgets.hpp:27
libsnark::Fp6_3over2_variable::FieldT
typename Fp6T::my_Fp FieldT
Definition: fp6_3over2_gadgets.hpp:24
libsnark::Fp6_3over2_variable
Definition: fp6_3over2_gadgets.hpp:21
libsnark::Fp6_3over2_variable::generate_r1cs_witness
void generate_r1cs_witness(const Fp6T &el)
libsnark::Fp6_3over2_mul_gadget::_compute_a1a2_times_b1b2
Fp2_mul_gadget< Fp2T > _compute_a1a2_times_b1b2
Definition: fp6_3over2_gadgets.hpp:102
gadgetlib2::power
FElem power(const FElem &base, long exponent)
Definition: variable.cpp:139
libsnark::Fp6_3over2_variable::frobenius_map
Fp6_3over2_variable< Fp6T > frobenius_map(size_t power) const
libsnark::Fp6_3over2_variable::Fp6_3over2_variable
Fp6_3over2_variable(protoboard< FieldT > &pb, const std::string &annotation_prefix)
libsnark::Fp6_3over2_mul_gadget::Fp6_3over2_mul_gadget
Fp6_3over2_mul_gadget(protoboard< FieldT > &pb, const Fp6_3over2_variable< Fp6T > &A, const Fp6_3over2_variable< Fp6T > &B, const Fp6_3over2_variable< Fp6T > &result, const std::string &annotation_prefix)
libsnark::Fp6_3over2_variable::operator-
Fp6_3over2_variable< Fp6T > operator-() const
libsnark::Fp6_3over2_mul_gadget::generate_r1cs_witness
void generate_r1cs_witness()
libsnark::Fp6_3over2_variable::operator+
Fp6_3over2_variable< Fp6T > operator+(const Fp6_3over2_variable< Fp6T > &other) const
libsnark::Fp6_3over2_variable::get_element
Fp6T get_element() const
libsnark::Fp6_3over2_mul_gadget::_compute_a0a1_times_b0b1
Fp2_mul_gadget< Fp2T > _compute_a0a1_times_b0b1
Definition: fp6_3over2_gadgets.hpp:104
libsnark::Fp6_3over2_variable::_c2
Fp2_variable< Fp2T > _c2
Definition: fp6_3over2_gadgets.hpp:29
libsnark::Fp6_3over2_variable::_c1
Fp2_variable< Fp2T > _c1
Definition: fp6_3over2_gadgets.hpp:28
libsnark::Fp6_3over2_variable::Fp2T
typename Fp6T::my_Fp2 Fp2T
Definition: fp6_3over2_gadgets.hpp:25
libsnark::Fp6_3over2_mul_gadget::_compute_v1
Fp2_mul_gadget< Fp2T > _compute_v1
Definition: fp6_3over2_gadgets.hpp:100
libsnark::protoboard
Definition: pb_variable.hpp:22
libsnark::Fp2_mul_gadget
Definition: fp2_gadgets.hpp:76