Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy > Class Template Reference

#include <nullifier_memory_tree.hpp>

Inheritance diagram for bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy >:
bb::crypto::merkle_tree::MemoryTree< HashingPolicy >

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 ()
 
- Public Member Functions inherited from bb::crypto::merkle_tree::MemoryTree< HashingPolicy >
 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

- Public Attributes inherited from bb::crypto::merkle_tree::MemoryTree< HashingPolicy >
size_t depth_
 
size_t total_size_
 
bb::fr root_
 
std::vector< bb::frhashes_
 

Detailed Description

template<typename HashingPolicy>
class bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy >

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.

  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

  2. 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

  3. 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

  4. 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

  5. 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.

Constructor & Destructor Documentation

◆ NullifierMemoryTree()

template<typename HashingPolicy >
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.

Member Function Documentation

◆ get_hashes()

template<typename HashingPolicy >
const std::vector< bb::fr > & bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy >::get_hashes ( )
inline

Definition at line 86 of file nullifier_memory_tree.hpp.

◆ get_leaf()

template<typename HashingPolicy >
const WrappedNullifierLeaf< HashingPolicy > bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy >::get_leaf ( size_t  index)
inline

Definition at line 87 of file nullifier_memory_tree.hpp.

◆ get_leaves()

template<typename HashingPolicy >
const std::vector< WrappedNullifierLeaf< HashingPolicy > > & bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy >::get_leaves ( )
inline

Definition at line 92 of file nullifier_memory_tree.hpp.

◆ update_element()

template<typename HashingPolicy >
fr_sibling_path bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy >::update_element ( fr const &  value)

Definition at line 138 of file nullifier_memory_tree.hpp.

Member Data Documentation

◆ leaves_

template<typename HashingPolicy >
std::vector<WrappedNullifierLeaf<HashingPolicy> > bb::crypto::merkle_tree::NullifierMemoryTree< HashingPolicy >::leaves_
protected

Definition at line 99 of file nullifier_memory_tree.hpp.


The documentation for this class was generated from the following file: