zk/include/nil/crypto3/zk/snark/algorithms/verify.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2020-2021 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
4 // Copyright (c) 2020-2021 Ilias Khairullin <ilias@nil.foundation>
5 //
6 // MIT License
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 //---------------------------------------------------------------------------//
26 
27 #ifndef CRYPTO3_ZK_SNARK_ALGORITHMS_VERIFY_HPP
28 #define CRYPTO3_ZK_SNARK_ALGORITHMS_VERIFY_HPP
29 
30 namespace nil {
31  namespace crypto3 {
32  namespace zk {
33  namespace snark {
34  template<typename ProofSystemType>
35  bool verify(const typename ProofSystemType::verification_key_type &vk,
36  const typename ProofSystemType::primary_input_type &primary_input,
37  const typename ProofSystemType::proof_type &proof) {
38 
39  return ProofSystemType::verify(vk, primary_input, proof);
40  }
41 
42  template<typename ProofSystemType>
43  bool verify(const typename ProofSystemType::processed_verification_key_type &pvk,
44  const typename ProofSystemType::primary_input_type &primary_input,
45  const typename ProofSystemType::proof_type &proof) {
46 
47  return ProofSystemType::verify(pvk, primary_input, proof);
48  }
49 
50  template<typename ProofSystemType, typename DistributionType, typename GeneratorType, typename Hash,
51  typename InputPrimaryInputRange, typename InputIterator>
52  bool verify(const typename ProofSystemType::verification_srs_type &ip_verifier_srs,
53  const typename ProofSystemType::verification_key_type &pvk,
54  const InputPrimaryInputRange &public_inputs,
55  const typename ProofSystemType::proof_type &proof,
56  InputIterator transcript_include_first,
57  InputIterator transcript_include_last) {
58 
59  return ProofSystemType::template verify<DistributionType, GeneratorType, Hash>(
60  ip_verifier_srs, pvk, public_inputs, proof, transcript_include_first, transcript_include_last);
61  }
62 
63  template<typename ProofSystemType, typename CipherTextIterator, typename PublicKey>
64  static inline bool verify(CipherTextIterator first, CipherTextIterator last,
65  const typename ProofSystemType::verification_key_type &vk,
66  const PublicKey &pubkey,
67  const typename ProofSystemType::primary_input_type &unencrypted_primary_input,
68  const typename ProofSystemType::proof_type &proof) {
69  return ProofSystemType::verify(first, last, vk, pubkey, unencrypted_primary_input, proof);
70  }
71  } // namespace snark
72  } // namespace zk
73  } // namespace crypto3
74 } // namespace nil
75 
76 #endif // CRYPTO3_ZK_SNARK_ALGORITHMS_HPP
Definition: snark/proof.hpp:37
boost::mpl::apply< AccumulatorSet, tag::pubkey< ProcessingMode > >::type::result_type pubkey(const AccumulatorSet &acc)
Definition: accumulators/pubkey.hpp:106
bool verify(const typename ProofSystemType::verification_key_type &vk, const typename ProofSystemType::primary_input_type &primary_input, const typename ProofSystemType::proof_type &proof)
Definition: zk/include/nil/crypto3/zk/snark/algorithms/verify.hpp:35
Definition: pair.hpp:31
Definition: proof.hpp:34