systems/ppzksnark/uscs_ppzksnark/proving_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_PROVING_KEY_HPP
27 #define CRYPTO3_USCS_PPZKSNARK_PROVING_KEY_HPP
28 
29 #include <vector>
30 
31 namespace nil {
32  namespace crypto3 {
33  namespace zk {
34  namespace snark {
38  template<typename CurveType, typename ConstraintSystem>
40  using g1_type = typename CurveType::template g1_type<>;
41  using g2_type = typename CurveType::template g2_type<>;
42  public:
43 
44  typedef ConstraintSystem constraint_system_type;
45 
46  std::vector<typename g1_type::value_type> V_g1_query;
47  std::vector<typename g1_type::value_type> alpha_V_g1_query;
48  std::vector<typename g1_type::value_type> H_g1_query;
49  std::vector<typename g2_type::value_type> V_g2_query;
50 
52 
57  uscs_ppzksnark_proving_key(std::vector<typename g1_type::value_type> &&V_g1_query,
58  std::vector<typename g1_type::value_type> &&alpha_V_g1_query,
59  std::vector<typename g1_type::value_type> &&H_g1_query,
60  std::vector<typename g2_type::value_type> &&V_g2_query,
62  V_g1_query(std::move(V_g1_query)),
65 
66  std::size_t G1_size() const {
67  return V_g1_query.size() + alpha_V_g1_query.size() + H_g1_query.size();
68  }
69 
70  std::size_t G2_size() const {
71  return V_g2_query.size();
72  }
73 
74  std::size_t G1_sparse_size() const {
75  return G1_size();
76  }
77 
78  std::size_t G2_sparse_size() const {
79  return G2_size();
80  }
81 
82  std::size_t size_in_bits() const {
83  return g1_type::value_bits * G1_size() + g2_type::value_bits * G2_size();
84  }
85 
86  bool operator==(const uscs_ppzksnark_proving_key &other) const {
87  return (this->V_g1_query == other.V_g1_query &&
88  this->alpha_V_g1_query == other.alpha_V_g1_query &&
89  this->H_g1_query == other.H_g1_query && this->V_g2_query == other.V_g2_query &&
90  this->constraint_system == other.constraint_system);
91  }
92  };
93  } // namespace snark
94  } // namespace zk
95  } // namespace crypto3
96 } // namespace nil
97 
98 #endif // CRYPTO3_R1CS_PPZKSNARK_BASIC_PROVER_HPP
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:39
std::size_t G1_size() const
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:66
std::size_t G2_sparse_size() const
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:78
uscs_ppzksnark_proving_key(uscs_ppzksnark_proving_key &&other)=default
bool operator==(const uscs_ppzksnark_proving_key &other) const
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:86
std::vector< typename g1_type::value_type > V_g1_query
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:46
constraint_system_type constraint_system
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:51
std::size_t size_in_bits() const
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:82
std::size_t G1_sparse_size() const
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:74
std::vector< typename g1_type::value_type > H_g1_query
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:48
std::vector< typename g1_type::value_type > alpha_V_g1_query
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:47
uscs_ppzksnark_proving_key & operator=(const uscs_ppzksnark_proving_key &other)=default
uscs_ppzksnark_proving_key(const uscs_ppzksnark_proving_key &other)=default
ConstraintSystem constraint_system_type
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:44
uscs_ppzksnark_proving_key()
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:53
uscs_ppzksnark_proving_key(std::vector< typename g1_type::value_type > &&V_g1_query, std::vector< typename g1_type::value_type > &&alpha_V_g1_query, std::vector< typename g1_type::value_type > &&H_g1_query, std::vector< typename g2_type::value_type > &&V_g2_query, constraint_system_type &&constraint_system)
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:57
std::size_t G2_size() const
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:70
std::vector< typename g2_type::value_type > V_g2_query
Definition: systems/ppzksnark/uscs_ppzksnark/proving_key.hpp:49
OutputIterator move(const SinglePassRange &rng, OutputIterator result)
Definition: move.hpp:45
Definition: pair.hpp:31