Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
note_hash_tree_check.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <optional>
5#include <span>
6
15
16namespace bb::avm2::simulation {
17
19 public:
29
30 FF get_first_nullifier() const override { return first_nullifier; }
31
32 bool note_hash_exists(const FF& unique_note_hash,
33 const FF& leaf_value,
34 uint64_t leaf_index,
35 std::span<const FF> sibling_path,
36 const AppendOnlyTreeSnapshot& snapshot) override;
38 AztecAddress contract_address,
39 uint64_t note_hash_counter,
40 std::span<const FF> sibling_path,
41 const AppendOnlyTreeSnapshot& prev_snapshot) override;
43 uint64_t note_hash_counter,
44 std::span<const FF> sibling_path,
45 const AppendOnlyTreeSnapshot& prev_snapshot) override;
47 uint64_t note_hash_counter,
48 std::span<const FF> sibling_path,
49 const AppendOnlyTreeSnapshot& prev_snapshot) override;
50
51 void on_checkpoint_created() override;
52 void on_checkpoint_committed() override;
53 void on_checkpoint_reverted() override;
54
55 private:
56 FF make_siloed(AztecAddress contract_address, const FF& note_hash) const;
57 FF make_nonce(uint64_t note_hash_counter) const;
58 FF make_unique(const FF& siloed_note_hash, const FF& nonce) const;
60 std::optional<AztecAddress> contract_address,
61 bool should_make_unique,
62 uint64_t note_hash_counter,
63 std::span<const FF> sibling_path,
64 const AppendOnlyTreeSnapshot& prev_snapshot);
65
70};
71
72} // namespace bb::avm2::simulation
Interface for a checkpoint notifiable.
Definition db.hpp:124
void on_checkpoint_created() override
Emits a checkpoint creation event for the note hash tree.
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.
EventEmitterInterface< NoteHashTreeCheckEvent > & events
AppendOnlyTreeSnapshot append_note_hash(const FF &note_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.
NoteHashTreeCheck(const FF &first_nullifier, Poseidon2Interface &poseidon2, MerkleCheckInterface &merkle_check, EventEmitterInterface< NoteHashTreeCheckEvent > &event_emitter)
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.
FF make_siloed(AztecAddress contract_address, const FF &note_hash) const
Computes the siloed note hash by hashing the contract address with the note hash.
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.
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.
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_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.
EventEmitter< DataCopyEvent > event_emitter
AVM range check gadget for witness generation.
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13