|
Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include <note_hash_tree_check.hpp>
Public Member Functions | |
| NoteHashTreeCheck (const FF &first_nullifier, Poseidon2Interface &poseidon2, MerkleCheckInterface &merkle_check, EventEmitterInterface< NoteHashTreeCheckEvent > &event_emitter) | |
| FF | get_first_nullifier () const override |
| bool | note_hash_exists (const FF &unique_note_hash, const FF &leaf_value, uint64_t leaf_index, std::span< const FF > sibling_path, const AppendOnlyTreeSnapshot &snapshot) override |
| Checks whether a note hash exists in the note hash tree via Merkle membership proof. | |
| AppendOnlyTreeSnapshot | append_note_hash (const FF ¬e_hash, AztecAddress contract_address, uint64_t note_hash_counter, std::span< const FF > sibling_path, const AppendOnlyTreeSnapshot &prev_snapshot) override |
| Appends a raw (inner) note hash to the tree after siloing and making it unique. | |
| AppendOnlyTreeSnapshot | append_siloed_note_hash (const FF &siloed_note_hash, uint64_t note_hash_counter, std::span< const FF > sibling_path, const AppendOnlyTreeSnapshot &prev_snapshot) override |
| Appends a pre-siloed note hash to the tree after making it unique. | |
| AppendOnlyTreeSnapshot | append_unique_note_hash (const FF &unique_note_hash, uint64_t note_hash_counter, std::span< const FF > sibling_path, const AppendOnlyTreeSnapshot &prev_snapshot) override |
| Appends a pre-computed unique note hash directly to the tree. | |
| void | on_checkpoint_created () override |
| Emits a checkpoint creation event for the note hash tree. | |
| void | on_checkpoint_committed () override |
| Emits a checkpoint commit event, finalizing pending note hash tree changes. | |
| void | on_checkpoint_reverted () override |
| Emits a checkpoint revert event, rolling back pending note hash tree changes. | |
Public Member Functions inherited from bb::avm2::simulation::NoteHashTreeCheckInterface | |
| virtual | ~NoteHashTreeCheckInterface ()=default |
Public Member Functions inherited from bb::avm2::simulation::CheckpointNotifiable | |
| virtual | ~CheckpointNotifiable ()=default |
Private Member Functions | |
| FF | make_siloed (AztecAddress contract_address, const FF ¬e_hash) const |
| Computes the siloed note hash by hashing the contract address with the note hash. | |
| FF | make_nonce (uint64_t note_hash_counter) const |
| Derives a nonce for a note hash from the transaction's first nullifier and the note hash counter. | |
| FF | make_unique (const FF &siloed_note_hash, const FF &nonce) const |
| Computes a unique note hash by combining a siloed note hash with its nonce. | |
| AppendOnlyTreeSnapshot | append_note_hash_internal (FF note_hash, std::optional< AztecAddress > contract_address, bool should_make_unique, uint64_t note_hash_counter, std::span< const FF > sibling_path, const AppendOnlyTreeSnapshot &prev_snapshot) |
| Internal implementation for all note hash append variants. | |
Private Attributes | |
| FF | first_nullifier |
| EventEmitterInterface< NoteHashTreeCheckEvent > & | events |
| Poseidon2Interface & | poseidon2 |
| MerkleCheckInterface & | merkle_check |
Definition at line 18 of file note_hash_tree_check.hpp.
|
inline |
Definition at line 20 of file note_hash_tree_check.hpp.
|
overridevirtual |
Appends a raw (inner) note hash to the tree after siloing and making it unique.
This is the standard entry point for user-space note hash insertion. The note hash is first siloed with the contract address, then made unique using a nonce derived from the first nullifier and the note hash counter, before being inserted into the tree.
| note_hash | The raw (inner) note hash to append. |
| contract_address | The address of the contract that created the note. |
| note_hash_counter | A counter distinguishing this note hash within the transaction. |
| sibling_path | The Merkle sibling path for the append operation. |
| prev_snapshot | The tree snapshot before the append. |
Implements bb::avm2::simulation::NoteHashTreeCheckInterface.
Definition at line 91 of file note_hash_tree_check.cpp.
|
private |
Internal implementation for all note hash append variants.
Optionally silos and/or makes the note hash unique before inserting it as a new leaf at the next available index. Performs a Merkle write (replacing a zero leaf) and emits a read/write event capturing all intermediate data for constraint generation.
| note_hash | The note hash to insert (may be raw, siloed, or unique depending on caller). |
| contract_address | If present, the note hash is siloed with this address before insertion. |
| should_make_unique | If true, a nonce is derived and the note hash is made unique. |
| note_hash_counter | A counter distinguishing this note hash within the transaction. |
| sibling_path | The Merkle sibling path for the append operation. |
| prev_snapshot | The tree snapshot before the append. |
Definition at line 166 of file note_hash_tree_check.cpp.
|
overridevirtual |
Appends a pre-siloed note hash to the tree after making it unique.
Skips the siloing step (the note hash is already bound to a contract) but still derives a nonce and computes the unique note hash before insertion.
| siloed_note_hash | The already-siloed note hash to append. |
| note_hash_counter | A counter distinguishing this note hash within the transaction. |
| sibling_path | The Merkle sibling path for the append operation. |
| prev_snapshot | The tree snapshot before the append. |
Implements bb::avm2::simulation::NoteHashTreeCheckInterface.
Definition at line 113 of file note_hash_tree_check.cpp.
|
overridevirtual |
Appends a pre-computed unique note hash directly to the tree.
Skips both siloing and uniqueness derivation – the note hash is inserted as-is. This is used when the caller has already performed all transformations externally.
| unique_note_hash | The fully-unique note hash to append. |
| note_hash_counter | A counter distinguishing this note hash within the transaction. |
| sibling_path | The Merkle sibling path for the append operation. |
| prev_snapshot | The tree snapshot before the append. |
Implements bb::avm2::simulation::NoteHashTreeCheckInterface.
Definition at line 138 of file note_hash_tree_check.cpp.
|
inlineoverridevirtual |
Implements bb::avm2::simulation::NoteHashTreeCheckInterface.
Definition at line 30 of file note_hash_tree_check.hpp.
|
private |
Derives a nonce for a note hash from the transaction's first nullifier and the note hash counter.
The nonce ensures uniqueness of note hashes within and across transactions.
| note_hash_counter | The index of the note hash in the transaction. |
Definition at line 58 of file note_hash_tree_check.cpp.
|
private |
Computes the siloed note hash by hashing the contract address with the note hash.
Siloing binds a note hash to its originating contract, preventing cross-contract collisions. Uses Poseidon2 with a domain separator for siloed note hashes.
| contract_address | The address of the contract that created the note. |
| note_hash | The original (inner) note hash. |
Definition at line 45 of file note_hash_tree_check.cpp.
|
private |
Computes a unique note hash by combining a siloed note hash with its nonce.
This final transformation guarantees global uniqueness of the note hash.
| siloed_note_hash | The siloed note hash (already bound to a contract). |
| nonce | The nonce derived from the first nullifier and note hash counter. |
Definition at line 72 of file note_hash_tree_check.cpp.
|
overridevirtual |
Checks whether a note hash exists in the note hash tree via Merkle membership proof.
Verifies that leaf_value is present at leaf_index in the tree whose root is given by snapshot, then compares it against the claimed unique_note_hash.
leaf_index is within the bounds of the tree nor that it is less than the next available leaf index.| unique_note_hash | The unique note hash the caller claims to exist. |
| leaf_value | The actual leaf value retrieved from the tree. |
| leaf_index | The index of the leaf in the tree. |
| sibling_path | The Merkle sibling path used for the membership proof. |
| snapshot | The tree snapshot (root + size) to verify against. |
unique_note_hash equals leaf_value, false otherwise. Implements bb::avm2::simulation::NoteHashTreeCheckInterface.
Definition at line 21 of file note_hash_tree_check.cpp.
|
overridevirtual |
Emits a checkpoint commit event, finalizing pending note hash tree changes.
Implements bb::avm2::simulation::CheckpointNotifiable.
Definition at line 214 of file note_hash_tree_check.cpp.
|
overridevirtual |
Emits a checkpoint creation event for the note hash tree.
Implements bb::avm2::simulation::CheckpointNotifiable.
Definition at line 208 of file note_hash_tree_check.cpp.
|
overridevirtual |
Emits a checkpoint revert event, rolling back pending note hash tree changes.
Implements bb::avm2::simulation::CheckpointNotifiable.
Definition at line 220 of file note_hash_tree_check.cpp.
|
private |
Definition at line 67 of file note_hash_tree_check.hpp.
|
private |
Definition at line 66 of file note_hash_tree_check.hpp.
|
private |
Definition at line 69 of file note_hash_tree_check.hpp.
|
private |
Definition at line 68 of file note_hash_tree_check.hpp.