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

#include <memory_tree.hpp>

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

Public Member Functions

 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
 

Public Attributes

size_t depth_
 
size_t total_size_
 
bb::fr root_
 
std::vector< bb::frhashes_
 

Detailed Description

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

A MemoryTree is structured as follows: 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.

Definition at line 30 of file memory_tree.hpp.

Constructor & Destructor Documentation

◆ MemoryTree()

template<typename HashingPolicy >
bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::MemoryTree ( size_t  depth)

Definition at line 52 of file memory_tree.hpp.

Member Function Documentation

◆ get_hash_path()

template<typename HashingPolicy >
fr_hash_path bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::get_hash_path ( size_t  index) const

Definition at line 83 of file memory_tree.hpp.

◆ get_node()

template<typename HashingPolicy >
fr bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::get_node ( uint32_t  level,
size_t  index 
) const

Definition at line 74 of file memory_tree.hpp.

◆ get_sibling_path()

template<typename HashingPolicy >
fr_sibling_path bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::get_sibling_path ( size_t  index) const

Definition at line 98 of file memory_tree.hpp.

◆ root()

template<typename HashingPolicy >
fr bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::root ( ) const
inline

Definition at line 40 of file memory_tree.hpp.

◆ update_element()

template<typename HashingPolicy >
fr bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::update_element ( size_t  index,
fr const &  value 
)

Definition at line 116 of file memory_tree.hpp.

Member Data Documentation

◆ depth_

template<typename HashingPolicy >
size_t bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::depth_

Definition at line 45 of file memory_tree.hpp.

◆ hashes_

template<typename HashingPolicy >
std::vector<bb::fr> bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::hashes_

Definition at line 48 of file memory_tree.hpp.

◆ root_

template<typename HashingPolicy >
bb::fr bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::root_

Definition at line 47 of file memory_tree.hpp.

◆ total_size_

template<typename HashingPolicy >
size_t bb::crypto::merkle_tree::MemoryTree< HashingPolicy >::total_size_

Definition at line 46 of file memory_tree.hpp.


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