Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
merkle_path_authenticator.hpp
Go to the documentation of this file.
1 // DISCLAIMER:
2 // Content taken and adapted from:
3 // https://github.com/HarryR/ethsnarks/blob/master/src/gadgets/merkle_tree.hpp
4 // https://github.com/HarryR/ethsnarks/blob/master/src/gadgets/merkle_tree.cpp
5 
6 #ifndef __ZETH_CIRCUITS_MERKLE_PATH_AUTHENTICATOR_HPP__
7 #define __ZETH_CIRCUITS_MERKLE_PATH_AUTHENTICATOR_HPP__
8 
10 
11 namespace libzeth
12 {
13 
15 template<typename FieldT, typename HashTreeT>
16 class merkle_path_authenticator : public merkle_path_compute<FieldT, HashTreeT>
17 {
18 public:
19  // Expected value of the Merkle Tree root
20  const libsnark::pb_variable<FieldT> m_expected_root;
21 
22  // Boolean enforcing the comparison between the expected and
23  // computed value of the Merkle Tree root
24  const libsnark::pb_variable<FieldT> value_enforce;
25 
27  libsnark::protoboard<FieldT> &pb,
28  // The depth of the tree
29  const size_t depth,
30  // Address of the leaf to authenticate
31  const libsnark::pb_variable_array<FieldT> &address_bits,
32  // Leaf to authenticate
33  const libsnark::pb_variable<FieldT> leaf,
34  // Expected root
35  const libsnark::pb_variable<FieldT> expected_root,
36  // Merkle Authentication path
37  const libsnark::pb_variable_array<FieldT> &path,
38  // Boolean enforcing the comparison between the expected and
39  // computed value of the Merkle Tree root
40  const libsnark::pb_variable<FieldT> &bool_enforce,
41  const std::string &annotation_prefix);
42 
44  void generate_r1cs_witness();
45 
46  // Returns boolean saying whether the expected and computed MT roots are
47  // equal
48  bool is_valid();
49 };
50 
51 } // namespace libzeth
52 
54 
55 #endif // __ZETH_CIRCUITS_MERKLE_PATH_AUTHENTICATOR_HPP__
libzeth::merkle_path_compute::path
const libsnark::pb_variable_array< FieldT > path
Definition: merkle_path_compute.hpp:24
libzeth::merkle_path_compute::leaf
const libsnark::pb_variable< FieldT > leaf
Definition: merkle_path_compute.hpp:22
libzeth::merkle_path_authenticator::merkle_path_authenticator
merkle_path_authenticator(libsnark::protoboard< FieldT > &pb, const size_t depth, const libsnark::pb_variable_array< FieldT > &address_bits, const libsnark::pb_variable< FieldT > leaf, const libsnark::pb_variable< FieldT > expected_root, const libsnark::pb_variable_array< FieldT > &path, const libsnark::pb_variable< FieldT > &bool_enforce, const std::string &annotation_prefix)
merkle_path_compute.hpp
libzeth
Definition: binary_operation.hpp:15
libzeth::merkle_path_authenticator
Merkle path authenticator, verifies computed root matches expected result.
Definition: merkle_path_authenticator.hpp:16
merkle_path_authenticator.tcc
libzeth::merkle_path_compute
Definition: merkle_path_compute.hpp:15
libzeth::merkle_path_authenticator::generate_r1cs_witness
void generate_r1cs_witness()
libzeth::merkle_path_authenticator::generate_r1cs_constraints
void generate_r1cs_constraints()
libzeth::merkle_path_authenticator::is_valid
bool is_valid()
libzeth::merkle_path_authenticator::m_expected_root
const libsnark::pb_variable< FieldT > m_expected_root
Definition: merkle_path_authenticator.hpp:20
libzeth::merkle_path_authenticator::value_enforce
const libsnark::pb_variable< FieldT > value_enforce
Definition: merkle_path_authenticator.hpp:24
libzeth::merkle_path_compute::address_bits
const libsnark::pb_variable_array< FieldT > address_bits
Definition: merkle_path_compute.hpp:20
libzeth::merkle_path_compute::depth
const size_t depth
Definition: merkle_path_compute.hpp:18