snark/systems/ppzksnark/uscs_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_USCS_PPZKSNARK_PROOF_HPP
27 #define CRYPTO3_USCS_PPZKSNARK_PROOF_HPP
28 
29 namespace nil {
30  namespace crypto3 {
31  namespace zk {
32  namespace snark {
40  template<typename CurveType>
42  using g1_type = typename CurveType::template g1_type<>;
43  using g2_type = typename CurveType::template g2_type<>;
44 
45  public:
46 
47  typename g1_type::value_type V_g1;
48  typename g1_type::value_type alpha_V_g1;
49  typename g1_type::value_type H_g1;
50  typename g2_type::value_type V_g2;
51 
53  V_g1(g1_type::value_type::one()), alpha_V_g1(g1_type::value_type::one()),
54  H_g1(g1_type::value_type::one()), V_g2(g2_type::value_type::one()) {
55  // invalid proof with valid curve points
56  }
57  uscs_ppzksnark_proof(typename g1_type::value_type &&V_g1,
58  typename g1_type::value_type &&alpha_V_g1,
59  typename g1_type::value_type &&H_g1,
60  typename g2_type::value_type &&V_g2) :
61  V_g1(std::move(V_g1)),
62  alpha_V_g1(std::move(alpha_V_g1)), H_g1(std::move(H_g1)), V_g2(std::move(V_g2)) {};
63 
64  std::size_t G1_size() const {
65  return 3;
66  }
67 
68  std::size_t G2_size() const {
69  return 1;
70  }
71 
72  std::size_t size_in_bits() const {
73  return G1_size() * g1_type::value_bits + G2_size() * g2_type::value_bits;
74  }
75 
76  bool is_well_formed() const {
77  return (V_g1.is_well_formed() && alpha_V_g1.is_well_formed() && H_g1.is_well_formed() &&
78  V_g2.is_well_formed());
79  }
80 
81  bool operator==(const uscs_ppzksnark_proof &other) const {
82  return (this->V_g1 == other.V_g1 && this->alpha_V_g1 == other.alpha_V_g1 &&
83  this->H_g1 == other.H_g1 && this->V_g2 == other.V_g2);
84  }
85  };
86  } // namespace snark
87  } // namespace zk
88  } // namespace crypto3
89 } // namespace nil
90 
91 #endif // CRYPTO3_R1CS_PPZKSNARK_BASIC_PROVER_HPP
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:41
std::size_t size_in_bits() const
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:72
bool operator==(const uscs_ppzksnark_proof &other) const
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:81
g1_type::value_type V_g1
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:47
g2_type::value_type V_g2
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:50
uscs_ppzksnark_proof(typename g1_type::value_type &&V_g1, typename g1_type::value_type &&alpha_V_g1, typename g1_type::value_type &&H_g1, typename g2_type::value_type &&V_g2)
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:57
g1_type::value_type alpha_V_g1
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:48
g1_type::value_type H_g1
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:49
bool is_well_formed() const
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:76
uscs_ppzksnark_proof()
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:52
std::size_t G1_size() const
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:64
std::size_t G2_size() const
Definition: snark/systems/ppzksnark/uscs_ppzksnark/proof.hpp:68
OutputIterator move(const SinglePassRange &rng, OutputIterator result)
Definition: move.hpp:45
Definition: pair.hpp:31