snark/systems/ppzksnark/r1cs_ppzksnark/proof.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_R1CS_PPZKSNARK_PROOF_HPP
27 #define CRYPTO3_R1CS_PPZKSNARK_PROOF_HPP
28 
30 
31 namespace nil {
32  namespace crypto3 {
33  namespace zk {
34  namespace snark {
42  template<typename CurveType>
44  typedef CurveType curve_type;
45  using g1_type = typename CurveType::template g1_type<>;
46  using g2_type = typename CurveType::template g2_type<>;
47  using g1_value_type = typename g1_type::value_type;
48  using g2_value_type = typename g2_type::value_type;
49 
50  public:
54  g1_value_type g_H;
55  g1_value_type g_K;
56 
58  // invalid proof with valid curve points
59  this->g_A.g = g1_value_type::one();
60  this->g_A.h = g1_value_type::one();
61  this->g_B.g = g2_value_type::one();
62  this->g_B.h = g1_value_type::one();
63  this->g_C.g = g1_value_type::one();
64  this->g_C.h = g1_value_type::one();
65  this->g_H = g1_value_type::one();
66  this->g_K = g1_value_type::one();
67  }
71  g1_value_type &&g_H,
72  g1_value_type &&g_K) :
73  g_A(std::move(g_A)),
74  g_B(std::move(g_B)), g_C(std::move(g_C)), g_H(std::move(g_H)), g_K(std::move(g_K)) {};
75 
76  std::size_t G1_size() const {
77  return 7;
78  }
79 
80  std::size_t G2_size() const {
81  return 1;
82  }
83 
84  std::size_t size_in_bits() const {
85  return G1_size() * CurveType::g1_type::value_bits + G2_size() * CurveType::g2_type::value_bits;
86  }
87 
88  bool is_well_formed() const {
89  return (g_A.g.is_well_formed() && g_A.h.is_well_formed() && g_B.g.is_well_formed() &&
90  g_B.h.is_well_formed() && g_C.g.is_well_formed() && g_C.h.is_well_formed() &&
91  g_H.is_well_formed() && g_K.is_well_formed());
92  }
93 
94  bool operator==(const r1cs_ppzksnark_proof &other) const {
95  return (this->g_A == other.g_A && this->g_B == other.g_B && this->g_C == other.g_C &&
96  this->g_H == other.g_H && this->g_K == other.g_K);
97  }
98  };
99  } // namespace snark
100  } // namespace zk
101  } // namespace crypto3
102 } // namespace nil
103 
104 #endif // CRYPTO3_R1CS_PPZKSNARK_BASIC_PROVER_HPP
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:43
knowledge_commitment< g1_type, g1_type >::value_type g_C
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:53
r1cs_ppzksnark_proof(typename knowledge_commitment< g1_type, g1_type >::value_type &&g_A, typename knowledge_commitment< g2_type, g1_type >::value_type &&g_B, typename knowledge_commitment< g1_type, g1_type >::value_type &&g_C, g1_value_type &&g_H, g1_value_type &&g_K)
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:68
knowledge_commitment< g1_type, g1_type >::value_type g_A
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:51
r1cs_ppzksnark_proof()
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:57
knowledge_commitment< g2_type, g1_type >::value_type g_B
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:52
g1_value_type g_H
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:54
std::size_t G1_size() const
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:76
bool operator==(const r1cs_ppzksnark_proof &other) const
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:94
std::size_t size_in_bits() const
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:84
bool is_well_formed() const
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:88
g1_value_type g_K
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:55
std::size_t G2_size() const
Definition: snark/systems/ppzksnark/r1cs_ppzksnark/proof.hpp:80
OutputIterator move(const SinglePassRange &rng, OutputIterator result)
Definition: move.hpp:45
Definition: pair.hpp:31
Definition: knowledge_commitment.hpp:49