Clearmatics Libsnark  0.1
C++ library for zkSNARK proofs
merkle_tree_check_update_gadget.hpp
Go to the documentation of this file.
1 
19 #ifndef MERKLE_TREE_CHECK_UPDATE_GADGET_HPP_
20 #define MERKLE_TREE_CHECK_UPDATE_GADGET_HPP_
21 
28 
29 namespace libsnark
30 {
31 
32 template<typename FieldT, typename HashT>
34 {
35 private:
36  std::vector<HashT> prev_hashers;
37  std::vector<block_variable<FieldT>> prev_hasher_inputs;
38  std::vector<digest_selector_gadget<FieldT>> prev_propagators;
39  std::vector<digest_variable<FieldT>> prev_internal_output;
40 
41  std::vector<HashT> next_hashers;
42  std::vector<block_variable<FieldT>> next_hasher_inputs;
43  std::vector<digest_selector_gadget<FieldT>> next_propagators;
44  std::vector<digest_variable<FieldT>> next_internal_output;
45 
46  std::shared_ptr<digest_variable<FieldT>> computed_next_root;
47  std::shared_ptr<bit_vector_copy_gadget<FieldT>> check_next_root;
48 
49 public:
50  const size_t digest_size;
51  const size_t tree_depth;
52 
61 
62  /* Note that while it is necessary to generate R1CS constraints
63  for prev_path, it is not necessary to do so for next_path. See
64  comment in the implementation of generate_r1cs_constraints() */
65 
68  const size_t tree_depth,
77  const std::string &annotation_prefix);
78 
80  void generate_r1cs_witness();
81 
82  static size_t root_size_in_bits();
83  /* for debugging purposes */
84  static size_t expected_constraints(const size_t tree_depth);
85 };
86 
87 template<typename FieldT, typename HashT>
89 
90 } // namespace libsnark
91 
93 
94 #endif // MERKLE_TREE_CHECK_UPDATE_GADGET_HPP_
libsnark::test_merkle_tree_check_update_gadget
void test_merkle_tree_check_update_gadget()
libsnark::gadget::annotation_prefix
const std::string annotation_prefix
Definition: gadget.hpp:20
libsnark
Definition: accumulation_vector.hpp:18
libsnark::gadget::pb
protoboard< FieldT > & pb
Definition: gadget.hpp:19
libsnark::merkle_tree_check_update_gadget::prev_leaf_digest
digest_variable< FieldT > prev_leaf_digest
Definition: merkle_tree_check_update_gadget.hpp:54
libsnark::merkle_tree_check_update_gadget::digest_size
const size_t digest_size
Definition: merkle_tree_check_update_gadget.hpp:50
crh_gadget.hpp
gadget.hpp
libsnark::merkle_tree_check_update_gadget::next_root_digest
digest_variable< FieldT > next_root_digest
Definition: merkle_tree_check_update_gadget.hpp:58
libsnark::gadget
Definition: gadget.hpp:16
hash_io.hpp
merkle_tree.hpp
libsnark::merkle_tree_check_update_gadget::generate_r1cs_witness
void generate_r1cs_witness()
libsnark::merkle_tree_check_update_gadget::expected_constraints
static size_t expected_constraints(const size_t tree_depth)
libsnark::merkle_tree_check_update_gadget::update_successful
pb_linear_combination< FieldT > update_successful
Definition: merkle_tree_check_update_gadget.hpp:60
libsnark::merkle_tree_check_update_gadget::generate_r1cs_constraints
void generate_r1cs_constraints()
libsnark::digest_variable
Definition: hash_io.hpp:16
libsnark::pb_linear_combination
Definition: pb_variable.hpp:101
libsnark::merkle_tree_check_update_gadget::root_size_in_bits
static size_t root_size_in_bits()
digest_selector_gadget.hpp
libsnark::merkle_tree_check_update_gadget::tree_depth
const size_t tree_depth
Definition: merkle_tree_check_update_gadget.hpp:51
merkle_authentication_path_variable.hpp
libsnark::merkle_tree_check_update_gadget::address_bits
pb_variable_array< FieldT > address_bits
Definition: merkle_tree_check_update_gadget.hpp:53
libsnark::pb_variable_array
Definition: pb_variable.hpp:44
libsnark::merkle_tree_check_update_gadget::next_path
merkle_authentication_path_variable< FieldT, HashT > next_path
Definition: merkle_tree_check_update_gadget.hpp:59
merkle_tree_check_update_gadget.tcc
libsnark::merkle_authentication_path_variable
Definition: merkle_authentication_path_variable.hpp:19
libsnark::merkle_tree_check_update_gadget::merkle_tree_check_update_gadget
merkle_tree_check_update_gadget(protoboard< FieldT > &pb, const size_t tree_depth, const pb_variable_array< FieldT > &address_bits, const digest_variable< FieldT > &prev_leaf_digest, const digest_variable< FieldT > &prev_root_digest, const merkle_authentication_path_variable< FieldT, HashT > &prev_path, const digest_variable< FieldT > &next_leaf_digest, const digest_variable< FieldT > &next_root_digest, const merkle_authentication_path_variable< FieldT, HashT > &next_path, const pb_linear_combination< FieldT > &update_successful, const std::string &annotation_prefix)
libsnark::merkle_tree_check_update_gadget
Definition: merkle_tree_check_update_gadget.hpp:33
libsnark::merkle_tree_check_update_gadget::prev_root_digest
digest_variable< FieldT > prev_root_digest
Definition: merkle_tree_check_update_gadget.hpp:55
libsnark::merkle_tree_check_update_gadget::prev_path
merkle_authentication_path_variable< FieldT, HashT > prev_path
Definition: merkle_tree_check_update_gadget.hpp:56
libsnark::protoboard
Definition: pb_variable.hpp:22
libsnark::merkle_tree_check_update_gadget::next_leaf_digest
digest_variable< FieldT > next_leaf_digest
Definition: merkle_tree_check_update_gadget.hpp:57