23 const uint64_t leaf_index,
28 assert(sibling_path.size() <= 64 &&
"Merkle path length must be less than or equal to 64");
30 FF curr_value = leaf_value;
31 uint64_t curr_index = leaf_index;
32 for (
const auto& sibling : sibling_path) {
33 bool index_is_even = (curr_index % 2 == 0);
41 if (curr_index != 0) {
42 throw std::runtime_error(
"Merkle check's final node index must be 0");
44 if (curr_value != root) {
45 throw std::runtime_error(
"Merkle read check failed");
48 std::vector<FF> sibling_vec(sibling_path.begin(), sibling_path.end());
50 .leaf_value = leaf_value,
51 .leaf_index = leaf_index,
75 const uint64_t leaf_index,
77 const FF& current_root)
80 assert(sibling_path.size() <= 64 &&
"Merkle path length must be less than or equal to 64");
82 FF read_value = current_value;
83 FF write_value = new_value;
84 uint64_t curr_index = leaf_index;
86 for (
const auto& sibling : sibling_path) {
87 bool index_is_even = (curr_index % 2 == 0);
97 if (curr_index != 0) {
98 throw std::runtime_error(
"Merkle check's final node index must be 0");
100 if (read_value != current_root) {
101 throw std::runtime_error(
"Merkle read check failed");
104 std::vector<FF> sibling_vec(sibling_path.begin(), sibling_path.end());
106 .leaf_value = current_value,
107 .new_leaf_value = new_value,
108 .leaf_index = leaf_index,
110 .root = current_root,
111 .new_root = write_value,
FF write(const FF ¤t_value, const FF &new_value, const uint64_t leaf_index, std::span< const FF > sibling_path, const FF ¤t_root) override
Assert the membership of the current leaf value (same logic as assert_membership())....
void assert_membership(const FF &leaf_value, const uint64_t leaf_index, std::span< const FF > sibling_path, const FF &root) override
Assert membership of a leaf in a Merkle tree, i.e., verify that the leaf value, leaf index,...