arnaucube
arnaucube/miden-cryptoPublic Self-hosted repository
miden-crypto/src/merkle/mod.rs
src/merkle/mod.rsRaw
 1//! Data structures related to Merkle trees based on RPO256 hash function.
 2
 3use super::{
 4    hash::rpo::{Rpo256, RpoDigest},
 5    utils::collections::{vec, BTreeMap, BTreeSet, KvMap, RecordingMap, Vec},
 6    Felt, StarkField, Word, EMPTY_WORD, ZERO,
 7};
 8
 9// REEXPORTS
10// ================================================================================================
11
12mod empty_roots;
13pub use empty_roots::EmptySubtreeRoots;
14
15mod index;
16pub use index::NodeIndex;
17
18mod merkle_tree;
19pub use merkle_tree::{path_to_text, tree_to_text, MerkleTree};
20
21mod path;
22pub use path::{MerklePath, RootPath, ValuePath};
23
24mod smt;
25pub use smt::{
26    LeafIndex, SimpleSmt, Smt, SmtLeaf, SmtLeafError, SmtProof, SmtProofError, SMT_DEPTH,
27    SMT_MAX_DEPTH, SMT_MIN_DEPTH,
28};
29
30mod tiered_smt;
31pub use tiered_smt::{TieredSmt, TieredSmtProof, TieredSmtProofError};
32
33mod mmr;
34pub use mmr::{InOrderIndex, Mmr, MmrDelta, MmrError, MmrPeaks, MmrProof, PartialMmr};
35
36mod store;
37pub use store::{DefaultMerkleStore, MerkleStore, RecordingMerkleStore, StoreNode};
38
39mod node;
40pub use node::InnerNodeInfo;
41
42mod partial_mt;
43pub use partial_mt::PartialMerkleTree;
44
45mod error;
46pub use error::MerkleError;
47
48// HELPER FUNCTIONS
49// ================================================================================================
50
51#[cfg(test)]
52const fn int_to_node(value: u64) -> RpoDigest {
53    RpoDigest::new([Felt::new(value), ZERO, ZERO, ZERO])
54}
55
56#[cfg(test)]
57const fn int_to_leaf(value: u64) -> Word {
58    [Felt::new(value), ZERO, ZERO, ZERO]
59}
60
61#[cfg(test)]
62fn digests_to_words(digests: &[RpoDigest]) -> Vec<Word> {
63    digests.iter().map(|d| d.into()).collect()
64}