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::{LeafIndex, SimpleSmt, SMT_MAX_DEPTH, SMT_MIN_DEPTH};
26
27mod tiered_smt;
28pub use tiered_smt::{TieredSmt, TieredSmtProof, TieredSmtProofError};
29
30mod mmr;
31pub use mmr::{InOrderIndex, Mmr, MmrDelta, MmrError, MmrPeaks, MmrProof, PartialMmr};
32
33mod store;
34pub use store::{DefaultMerkleStore, MerkleStore, RecordingMerkleStore, StoreNode};
35
36mod node;
37pub use node::InnerNodeInfo;
38
39mod partial_mt;
40pub use partial_mt::PartialMerkleTree;
41
42mod error;
43pub use error::MerkleError;
44
45// HELPER FUNCTIONS
46// ================================================================================================
47
48#[cfg(test)]
49const fn int_to_node(value: u64) -> RpoDigest {
50    RpoDigest::new([Felt::new(value), ZERO, ZERO, ZERO])
51}
52
53#[cfg(test)]
54const fn int_to_leaf(value: u64) -> Word {
55    [Felt::new(value), ZERO, ZERO, ZERO]
56}
57
58#[cfg(test)]
59fn digests_to_words(digests: &[RpoDigest]) -> Vec<Word> {
60    digests.iter().map(|d| d.into()).collect()
61}