zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.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_ZK_TBCS_PPZKSNARK_BASIC_VERIFIER_HPP
27 #define CRYPTO3_ZK_TBCS_PPZKSNARK_BASIC_VERIFIER_HPP
28 
31 #include <nil/crypto3/zk/snark/schemes/ppzksnark/uscs_ppzksnark.hpp>
32 #include <nil/crypto3/zk/snark/schemes/ppzksnark/tbcs_ppzksnark/detail/basic_policy.hpp>
34 
35 namespace nil {
36  namespace crypto3 {
37  namespace zk {
38  namespace snark {
39 
40  /*
41  Below are four variants of verifier algorithm for the TBCS ppzkSNARK.
42 
43  These are the four cases that arise from the following two choices:
44 
45  (1) The verifier accepts a (non-processed) verification key or, instead, a processed
46  verification key. In the latter case, we call the algorithm an "online verifier".
47 
48  (2) The verifier checks for "weak" input consistency or, instead, "strong" input consistency.
49  Strong input consistency requires that |primary_input| = C.num_inputs, whereas
50  weak input consistency requires that |primary_input| <= C.num_inputs (and
51  the primary input is implicitly padded with zeros up to length C.num_inputs).
52  */
53 
57  template<typename CurveType>
60 
61  public:
64 
67  }
68  };
69 
70  template<typename CurveType>
73 
78 
79  public:
84 
90  static inline bool process(const verification_key_type &vk,
91  const primary_input_type &primary_input,
92  const proof_type &proof) {
93  typedef typename CurveType::scalar_field_type field_type;
94  const uscs_primary_input<field_type> uscs_input =
95  algebra::convert_bit_vector_to_field_element_vector<field_type>(primary_input);
96  return verify<uscs_ppzksnark_weak_proof_system>(
98  }
99 
105  static inline bool process(const processed_verification_key_type &pvk,
106  const primary_input_type &primary_input,
107  const proof_type &proof) {
108 
109  typedef typename CurveType::scalar_field_type field_type;
110  const uscs_primary_input<field_type> uscs_input =
111  algebra::convert_bit_vector_to_field_element_vector<field_type>(primary_input);
112 
113  return verify<uscs_ppzksnark_weak_proof_system>(pvk, uscs_input, proof);
114  }
115  };
116 
117  template<typename CurveType>
120 
122  public:
127 
133  static inline bool process(const verification_key_type &vk,
134  const primary_input_type &primary_input,
135  const proof_type &proof) {
136  typedef typename CurveType::scalar_field_type field_type;
137  const uscs_primary_input<field_type> uscs_input =
138  algebra::convert_bit_vector_to_field_element_vector<field_type>(primary_input);
139 
140  return verify<uscs_ppzksnark_proof_system>(
142  }
143 
149  static inline bool process(const processed_verification_key_type &pvk,
150  const primary_input_type &primary_input,
151  const proof_type &proof) {
152  typedef typename CurveType::scalar_field_type field_type;
153  const uscs_primary_input<field_type> uscs_input =
154  algebra::convert_bit_vector_to_field_element_vector<field_type>(primary_input);
155 
156  return verify<uscs_ppzksnark_proof_system>(pvk, uscs_input, proof);
157  }
158  };
159  } // namespace snark
160  } // namespace zk
161  } // namespace crypto3
162 } // namespace nil
163 
164 #endif // CRYPTO3_ZK_TBCS_PPZKSNARK_BASIC_VERIFIER_HPP
Definition: snark/proof.hpp:37
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:58
static processed_verification_key_type process(const verification_key_type &vk)
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:65
policy_type::processed_verification_key_type processed_verification_key_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:63
policy_type::verification_key_type verification_key_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:62
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:118
policy_type::verification_key_type verification_key_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:124
policy_type::proof_type proof_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:126
policy_type::primary_input_type primary_input_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:123
policy_type::processed_verification_key_type processed_verification_key_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:125
static bool process(const verification_key_type &vk, const primary_input_type &primary_input, const proof_type &proof)
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:133
static bool process(const processed_verification_key_type &pvk, const primary_input_type &primary_input, const proof_type &proof)
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:149
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:71
policy_type::proof_type proof_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:83
policy_type::primary_input_type primary_input_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:80
static bool process(const processed_verification_key_type &pvk, const primary_input_type &primary_input, const proof_type &proof)
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:105
policy_type::verification_key_type verification_key_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:81
static bool process(const verification_key_type &vk, const primary_input_type &primary_input, const proof_type &proof)
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:90
policy_type::processed_verification_key_type processed_verification_key_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/verifier.hpp:82
Definition: uscs_ppzksnark/generator.hpp:49
static processed_verification_key_type process(const verification_key_type &vk)
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verifier.hpp:72
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:87
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:41
Definition: uscs_ppzksnark/prover.hpp:56
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verification_key.hpp:42
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/uscs_ppzksnark/verifier.hpp:94
ppzkSNARK for USCS
Definition: uscs_ppzksnark.hpp:71
std::vector< typename FieldType::value_type > uscs_primary_input
Definition: uscs.hpp:67
Definition: pair.hpp:31
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/detail/basic_policy.hpp:66
tbcs_primary_input primary_input_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/tbcs_ppzksnark/detail/basic_policy.hpp:76