zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2018-2021 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
4 //
5 // MIT License
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //---------------------------------------------------------------------------//
25 
26 #ifndef CRYPTO3_USCS_PPZKSNARK_VERIFICATION_KEY_HPP
27 #define CRYPTO3_USCS_PPZKSNARK_VERIFICATION_KEY_HPP
28 
30 
31 namespace nil {
32  namespace crypto3 {
33  namespace zk {
34  namespace snark {
35 
36  using namespace algebra;
37 
41  template<typename CurveType>
43  using g1_type = typename CurveType::template g1_type<>;
44  using g2_type = typename CurveType::template g2_type<>;
45  public:
46 
47  typename g2_type::value_type tilde_g2;
48  typename g2_type::value_type alpha_tilde_g2;
49  typename g2_type::value_type Z_g2;
50 
52 
54  uscs_ppzksnark_verification_key(const typename g2_type::value_type &tilde_g2,
55  const typename g2_type::value_type &alpha_tilde_g2,
56  const typename g2_type::value_type &Z_g2,
57  const accumulation_vector<g1_type> &eIC) :
58  tilde_g2(tilde_g2),
59  alpha_tilde_g2(alpha_tilde_g2), Z_g2(Z_g2), encoded_IC_query(eIC) {};
60 
61  std::size_t G1_size() const {
62  return encoded_IC_query.size();
63  }
64 
65  std::size_t G2_size() const {
66  return 3;
67  }
68 
69  std::size_t size_in_bits() const {
70  return encoded_IC_query.size_in_bits() + 3 * g2_type::value_bits;
71  }
72 
73  bool operator==(const uscs_ppzksnark_verification_key &other) const {
74  return (this->tilde_g2 == other.tilde_g2 && this->alpha_tilde_g2 == other.alpha_tilde_g2 &&
75  this->Z_g2 == other.Z_g2 && this->encoded_IC_query == other.encoded_IC_query);
76  }
77  };
78 
86  template<typename CurveType>
89 
90  public:
91  typedef CurveType curve_type;
92 
93  typename pairing_policy::g1_precomputed_type pp_G1_one_precomp;
94  typename pairing_policy::g2_precomputed_type pp_G2_one_precomp;
95  typename pairing_policy::g2_precomputed_type vk_tilde_g2_precomp;
96  typename pairing_policy::g2_precomputed_type vk_alpha_tilde_g2_precomp;
97  typename pairing_policy::g2_precomputed_type vk_Z_g2_precomp;
98  typename CurveType::gt_type::value_type pairing_of_g1_and_g2;
99 
101 
103  return (this->pp_G1_one_precomp == other.pp_G1_one_precomp &&
104  this->pp_G2_one_precomp == other.pp_G2_one_precomp &&
105  this->vk_tilde_g2_precomp == other.vk_tilde_g2_precomp &&
106  this->vk_alpha_tilde_g2_precomp == other.vk_alpha_tilde_g2_precomp &&
107  this->vk_Z_g2_precomp == other.vk_Z_g2_precomp &&
108  this->pairing_of_g1_and_g2 == other.pairing_of_g1_and_g2 &&
109  this->encoded_IC_query == other.encoded_IC_query);
110  }
111  };
112  } // namespace snark
113  } // namespace zk
114  } // namespace crypto3
115 } // namespace nil
116 
117 #endif // CRYPTO3_R1CS_PPZKSNARK_BASIC_PROVER_HPP
118 
std::size_t size() const
Definition: accumulation_vector.hpp:83
std::size_t size_in_bits() const
Definition: accumulation_vector.hpp:87
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:87
accumulation_vector< typename CurveType::template g1_type<> > encoded_IC_query
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:100
CurveType curve_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:91
CurveType::gt_type::value_type pairing_of_g1_and_g2
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:98
pairing_policy::g2_precomputed_type vk_alpha_tilde_g2_precomp
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:96
pairing_policy::g2_precomputed_type vk_Z_g2_precomp
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:97
pairing_policy::g2_precomputed_type vk_tilde_g2_precomp
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:95
pairing_policy::g1_precomputed_type pp_G1_one_precomp
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:93
bool operator==(const uscs_ppzksnark_processed_verification_key &other) const
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:102
pairing_policy::g2_precomputed_type pp_G2_one_precomp
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:94
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:42
std::size_t G2_size() const
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:65
g2_type::value_type tilde_g2
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:47
g2_type::value_type Z_g2
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:49
bool operator==(const uscs_ppzksnark_verification_key &other) const
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:73
std::size_t size_in_bits() const
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:69
g2_type::value_type alpha_tilde_g2
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:48
accumulation_vector< g1_type > encoded_IC_query
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:51
uscs_ppzksnark_verification_key(const typename g2_type::value_type &tilde_g2, const typename g2_type::value_type &alpha_tilde_g2, const typename g2_type::value_type &Z_g2, const accumulation_vector< g1_type > &eIC)
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:54
std::size_t G1_size() const
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:61
Definition: pair.hpp:31