Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::avm2::simulation::MerkleCheck Class Reference

#include <merkle_check.hpp>

Inheritance diagram for bb::avm2::simulation::MerkleCheck:
bb::avm2::simulation::MerkleCheckInterface

Public Member Functions

 MerkleCheck (Poseidon2Interface &poseidon2, EventEmitterInterface< MerkleCheckEvent > &event_emitter)
 
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, and the sibling path lead to the given root. Size of the tree is implicitly given by the sibling path length.
 
FF write (const FF &current_value, const FF &new_value, const uint64_t leaf_index, std::span< const FF > sibling_path, const FF &current_root) override
 Assert the membership of the current leaf value (same logic as assert_membership()). Write the new leaf value in the tree, i.e., compute the new root of the tree after the insertion of the new leaf value. Size of the tree is implicitly given by the sibling path length.
 
- Public Member Functions inherited from bb::avm2::simulation::MerkleCheckInterface
virtual ~MerkleCheckInterface ()=default
 

Private Attributes

EventEmitterInterface< MerkleCheckEvent > & events
 
Poseidon2Interfaceposeidon2
 

Detailed Description

Definition at line 14 of file merkle_check.hpp.

Constructor & Destructor Documentation

◆ MerkleCheck()

bb::avm2::simulation::MerkleCheck::MerkleCheck ( Poseidon2Interface poseidon2,
EventEmitterInterface< MerkleCheckEvent > &  event_emitter 
)
inline

Definition at line 16 of file merkle_check.hpp.

Member Function Documentation

◆ assert_membership()

void bb::avm2::simulation::MerkleCheck::assert_membership ( const FF leaf_value,
const uint64_t  leaf_index,
std::span< const FF sibling_path,
const FF root 
)
overridevirtual

Assert membership of a leaf in a Merkle tree, i.e., verify that the leaf value, leaf index, and the sibling path lead to the given root. Size of the tree is implicitly given by the sibling path length.

Note
A precondition is that sibling_path.size() <= 64
Exceptions
std::runtime_errorif the membership check fails.
Parameters
leaf_valueThe value of the leaf to check.
leaf_indexThe index of the leaf to check.
sibling_pathThe sibling path to the leaf to check.
rootThe root of the Merkle tree.

Implements bb::avm2::simulation::MerkleCheckInterface.

Definition at line 22 of file merkle_check.cpp.

◆ write()

FF bb::avm2::simulation::MerkleCheck::write ( const FF current_value,
const FF new_value,
const uint64_t  leaf_index,
std::span< const FF sibling_path,
const FF current_root 
)
overridevirtual

Assert the membership of the current leaf value (same logic as assert_membership()). Write the new leaf value in the tree, i.e., compute the new root of the tree after the insertion of the new leaf value. Size of the tree is implicitly given by the sibling path length.

Note
A precondition is that sibling_path.size() <= 64
Exceptions
std::runtime_errorif the membership check fails.
Parameters
current_valueThe value of the current leaf.
new_valueThe value of the new leaf.
leaf_indexThe index of the leaf to write.
sibling_pathThe sibling path to the leaf to write.
current_rootThe root of the Merkle tree before the write.
Returns
The new root of the Merkle tree after the write.

Implements bb::avm2::simulation::MerkleCheckInterface.

Definition at line 73 of file merkle_check.cpp.

Member Data Documentation

◆ events

EventEmitterInterface<MerkleCheckEvent>& bb::avm2::simulation::MerkleCheck::events
private

Definition at line 33 of file merkle_check.hpp.

◆ poseidon2

Poseidon2Interface& bb::avm2::simulation::MerkleCheck::poseidon2
private

Definition at line 34 of file merkle_check.hpp.


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