Clearmatics Libsnark  0.1
C++ library for zkSNARK proofs
set_commitment.hpp
Go to the documentation of this file.
1 
12 #ifndef SET_COMMITMENT_HPP_
13 #define SET_COMMITMENT_HPP_
14 
15 #include <libff/common/utils.hpp>
17 #include <libsnark/gadgetlib1/gadgets/hashes/hash_io.hpp> // TODO: the current structure is suboptimal
18 
19 namespace libsnark
20 {
21 
22 typedef libff::bit_vector set_commitment;
23 
25  size_t address;
27 
28  bool operator==(const set_membership_proof &other) const;
29  size_t size_in_bits() const;
30  friend std::ostream &operator<<(
31  std::ostream &out, const set_membership_proof &other);
32  friend std::istream &operator>>(
33  std::istream &in, set_membership_proof &other);
34 };
35 
36 template<typename HashT> class set_commitment_accumulator
37 {
38 private:
39  std::shared_ptr<merkle_tree<HashT>> tree;
40  std::map<libff::bit_vector, size_t> hash_to_pos;
41 
42 public:
43  size_t depth;
44  size_t digest_size;
45  size_t value_size;
46 
48  const size_t max_entries, const size_t value_size = 0);
49 
50  void add(const libff::bit_vector &value);
51  bool is_in_set(const libff::bit_vector &value) const;
53 
55  const libff::bit_vector &value) const;
56 };
57 
58 } // namespace libsnark
59 
60 /* note that set_commitment has both .cpp, for implementation of
61  non-templatized code (methods of set_membership_proof) and .tcc
62  (implementation of set_commitment_accumulator<HashT> */
64 
65 #endif // SET_COMMITMENT_HPP_
libsnark::set_commitment_accumulator::add
void add(const libff::bit_vector &value)
libsnark
Definition: accumulation_vector.hpp:18
libsnark::set_commitment_accumulator
Definition: set_commitment.hpp:36
libsnark::set_membership_proof::address
size_t address
Definition: set_commitment.hpp:25
libsnark::set_membership_proof::operator<<
friend std::ostream & operator<<(std::ostream &out, const set_membership_proof &other)
Definition: set_commitment.cpp:31
libsnark::set_commitment
libff::bit_vector set_commitment
Definition: set_commitment.hpp:22
libsnark::set_commitment_accumulator::digest_size
size_t digest_size
Definition: set_commitment.hpp:44
hash_io.hpp
merkle_tree.hpp
set_commitment.tcc
libsnark::set_commitment_accumulator::set_commitment_accumulator
set_commitment_accumulator(const size_t max_entries, const size_t value_size=0)
libsnark::set_commitment_accumulator::get_commitment
set_commitment get_commitment() const
libsnark::set_commitment_accumulator::get_membership_proof
set_membership_proof get_membership_proof(const libff::bit_vector &value) const
libsnark::set_membership_proof::size_in_bits
size_t size_in_bits() const
Definition: set_commitment.cpp:21
libsnark::set_commitment_accumulator::depth
size_t depth
Definition: set_commitment.hpp:43
libsnark::set_membership_proof::merkle_path
merkle_authentication_path merkle_path
Definition: set_commitment.hpp:26
libsnark::set_membership_proof
Definition: set_commitment.hpp:24
libsnark::set_commitment_accumulator::is_in_set
bool is_in_set(const libff::bit_vector &value) const
libsnark::set_membership_proof::operator==
bool operator==(const set_membership_proof &other) const
Definition: set_commitment.cpp:14
libsnark::set_commitment_accumulator::value_size
size_t value_size
Definition: set_commitment.hpp:45
libsnark::set_membership_proof::operator>>
friend std::istream & operator>>(std::istream &in, set_membership_proof &other)
Definition: set_commitment.cpp:42
libsnark::merkle_authentication_path
std::vector< merkle_authentication_node > merkle_authentication_path
Definition: merkle_tree.hpp:36