r1cs_ppzksnark.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2020 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_R1CS_PPZKSNARK_HPP
27 #define CRYPTO3_ZK_R1CS_PPZKSNARK_HPP
28 
29 #include <nil/crypto3/zk/snark/schemes/ppzksnark/r1cs_ppzksnark/detail/basic_policy.hpp>
30 
31 #include <nil/crypto3/zk/snark/schemes/ppzksnark/r1cs_ppzksnark/generator.hpp>
32 #include <nil/crypto3/zk/snark/schemes/ppzksnark/r1cs_ppzksnark/prover.hpp>
33 #include <nil/crypto3/zk/snark/schemes/ppzksnark/r1cs_ppzksnark/verifier.hpp>
34 
35 namespace nil {
36  namespace crypto3 {
37  namespace zk {
38  namespace snark {
66  template<typename CurveType,
67  typename Generator = r1cs_ppzksnark_generator<CurveType>,
68  typename Prover = r1cs_ppzksnark_prover<CurveType>,
69  typename Verifier = r1cs_ppzksnark_verifier_strong_input_consistency<CurveType>>
72 
73  public:
74  typedef Generator generator_type;
75  typedef Prover prover_type;
76  typedef Verifier verifier_type;
77 
81 
85 
88 
89  static inline keypair_type generate(const constraint_system_type &constraint_system) {
90  return Generator::process(constraint_system);
91  }
92 
93  static inline proof_type prove(const proving_key_type &pk,
94  const primary_input_type &primary_input,
95  const auxiliary_input_type &auxiliary_input) {
96 
97  return Prover::process(pk, primary_input, auxiliary_input);
98  }
99 
100  static inline bool verify(const typename Verifier::verification_key_type &vk,
101  const primary_input_type &primary_input,
102  const proof_type &proof) {
103  return Verifier::process(vk, primary_input, proof);
104  }
105 
106  static inline bool verify(const typename Verifier::processed_verification_key_type &pvk,
107  const primary_input_type &primary_input,
108  const proof_type &proof) {
109  return Verifier::process(pvk, primary_input, proof);
110  }
111  };
112  } // namespace snark
113  } // namespace zk
114  } // namespace crypto3
115 } // namespace nil
116 
117 #endif // CRYPTO3_ZK_R1CS_PPZKSNARK_HPP
Definition: snark/proof.hpp:37
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/r1cs_ppzksnark/verification_key.hpp:102
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:43
Definition: systems/ppzksnark/r1cs_ppzksnark/proving_key.hpp:47
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/r1cs_ppzksnark/verification_key.hpp:42
ppzkSNARK for R1CS
Definition: r1cs_ppzksnark.hpp:70
static keypair_type generate(const constraint_system_type &constraint_system)
Definition: r1cs_ppzksnark.hpp:89
policy_type::proving_key_type proving_key_type
Definition: r1cs_ppzksnark.hpp:82
policy_type::proof_type proof_type
Definition: r1cs_ppzksnark.hpp:87
policy_type::primary_input_type primary_input_type
Definition: r1cs_ppzksnark.hpp:79
policy_type::constraint_system_type constraint_system_type
Definition: r1cs_ppzksnark.hpp:78
policy_type::auxiliary_input_type auxiliary_input_type
Definition: r1cs_ppzksnark.hpp:80
policy_type::processed_verification_key_type processed_verification_key_type
Definition: r1cs_ppzksnark.hpp:84
policy_type::keypair_type keypair_type
Definition: r1cs_ppzksnark.hpp:86
policy_type::verification_key_type verification_key_type
Definition: r1cs_ppzksnark.hpp:83
Generator generator_type
Definition: r1cs_ppzksnark.hpp:74
static bool verify(const typename Verifier::processed_verification_key_type &pvk, const primary_input_type &primary_input, const proof_type &proof)
Definition: r1cs_ppzksnark.hpp:106
static proof_type prove(const proving_key_type &pk, const primary_input_type &primary_input, const auxiliary_input_type &auxiliary_input)
Definition: r1cs_ppzksnark.hpp:93
static bool verify(const typename Verifier::verification_key_type &vk, const primary_input_type &primary_input, const proof_type &proof)
Definition: r1cs_ppzksnark.hpp:100
Prover prover_type
Definition: r1cs_ppzksnark.hpp:75
Verifier verifier_type
Definition: r1cs_ppzksnark.hpp:76
Definition: pair.hpp:31
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/r1cs_ppzksnark/detail/basic_policy.hpp:78
r1cs_primary_input< typename CurveType::scalar_field_type > primary_input_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/r1cs_ppzksnark/detail/basic_policy.hpp:89
r1cs_ppzksnark_keypair< proving_key_type, verification_key_type > keypair_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/r1cs_ppzksnark/detail/basic_policy.hpp:123
r1cs_auxiliary_input< typename CurveType::scalar_field_type > auxiliary_input_type
Definition: zk/include/nil/crypto3/zk/snark/systems/ppzksnark/r1cs_ppzksnark/detail/basic_policy.hpp:91