Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include <nullifier_memory_tree.hpp>
Public Member Functions | |
NullifierMemoryTree (size_t depth, size_t initial_size=2) | |
fr_sibling_path | update_element (fr const &value) |
const std::vector< bb::fr > & | get_hashes () |
const WrappedNullifierLeaf< HashingPolicy > | get_leaf (size_t index) |
const std::vector< WrappedNullifierLeaf< HashingPolicy > > & | get_leaves () |
![]() | |
MemoryTree (size_t depth) | |
fr_hash_path | get_hash_path (size_t index) const |
fr_sibling_path | get_sibling_path (size_t index) const |
fr | update_element (size_t index, fr const &value) |
fr | root () const |
fr | get_node (uint32_t level, size_t index) const |
Protected Attributes | |
std::vector< WrappedNullifierLeaf< HashingPolicy > > | leaves_ |
Additional Inherited Members | |
![]() | |
size_t | depth_ |
size_t | total_size_ |
bb::fr | root_ |
std::vector< bb::fr > | hashes_ |
An NullifierMemoryTree is structured just like a usual merkle tree:
hashes_
+---------------------------------------------------------------------------—+ | 0 -> h_{0,0} h_{0,1} h_{0,2} h_{0,3} h_{0,4} h_{0,5} h_{0,6} h_{0,7} | i | | n | 8 -> h_{1,0} h_{1,1} h_{1,2} h_{1,3} | d | | e | 12 -> h_{2,0} h_{2,1} | x | | | 14 -> h_{3,0} | +---------------------------------------------------------------------------—+
Here, depth_ = 3 and {h_{0,j}}_{i=0..7} are leaf values. Also, root_ = h_{3,0} and total_size_ = (2 * 8 - 2) = 14. Lastly, h_{i,j} = hash( h_{i-1,2j}, h_{i-1,2j+1} ) where i > 1.
Initial state:
# # # # # # # # # # # # # # #
index 0 1 2 3 4 5 6 7
val 0 0 0 0 0 0 0 0 nextIdx 0 0 0 0 0 0 0 0 nextVal 0 0 0 0 0 0 0 0
Add new leaf with value 30
val 0 30 0 0 0 0 0 0 nextIdx 1 0 0 0 0 0 0 0 nextVal 30 0 0 0 0 0 0 0
Add new leaf with value 10
val 0 30 10 0 0 0 0 0 nextIdx 2 0 1 0 0 0 0 0 nextVal 10 0 30 0 0 0 0 0
Add new leaf with value 20
val 0 30 10 20 0 0 0 0 nextIdx 2 0 3 1 0 0 0 0 nextVal 10 0 20 30 0 0 0 0
Add new leaf with value 50
val 0 30 10 20 50 0 0 0 nextIdx 2 4 3 1 0 0 0 0 nextVal 10 50 20 30 0 0 0 0
Definition at line 74 of file nullifier_memory_tree.hpp.
bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy >::NullifierMemoryTree | ( | size_t | depth, |
size_t | initial_size = 2 |
||
) |
Definition at line 103 of file nullifier_memory_tree.hpp.
|
inline |
Definition at line 86 of file nullifier_memory_tree.hpp.
|
inline |
Definition at line 87 of file nullifier_memory_tree.hpp.
|
inline |
Definition at line 92 of file nullifier_memory_tree.hpp.
fr_sibling_path bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy >::update_element | ( | fr const & | value | ) |
Definition at line 138 of file nullifier_memory_tree.hpp.
|
protected |
Definition at line 99 of file nullifier_memory_tree.hpp.