miden_objects/batch/
note_tree.rs1use miden_crypto::{
2 hash::rpo::RpoDigest,
3 merkle::{MerkleError, SimpleSmt},
4};
5
6use crate::{
7 note::{compute_note_hash, NoteId, NoteMetadata},
8 BATCH_NOTE_TREE_DEPTH,
9};
10
11#[derive(Debug, Clone, PartialEq, Eq)]
15pub struct BatchNoteTree(SimpleSmt<BATCH_NOTE_TREE_DEPTH>);
16
17impl BatchNoteTree {
18 pub fn with_contiguous_leaves<'a>(
25 entries: impl IntoIterator<Item = (NoteId, &'a NoteMetadata)>,
26 ) -> Result<Self, MerkleError> {
27 let leaves = entries
28 .into_iter()
29 .map(|(note_id, metadata)| compute_note_hash(note_id, metadata).into());
30
31 SimpleSmt::with_contiguous_leaves(leaves).map(Self)
32 }
33
34 pub fn root(&self) -> RpoDigest {
36 self.0.root()
37 }
38}