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    Felt, Word, EMPTY_WORD, ZERO,
 6};
 7
 8// REEXPORTS
 9// ================================================================================================
10
11mod empty_roots;
12pub use empty_roots::EmptySubtreeRoots;
13
14mod index;
15pub use index::NodeIndex;
16
17mod merkle_tree;
18pub use merkle_tree::{path_to_text, tree_to_text, MerkleTree};
19
20mod path;
21pub use path::{MerklePath, RootPath, ValuePath};
22
23mod smt;
24#[cfg(feature = "internal")]
25pub use smt::build_subtree_for_bench;
26pub use smt::{
27    LeafIndex, MutationSet, SimpleSmt, Smt, SmtLeaf, SmtLeafError, SmtProof, SmtProofError,
28    SubtreeLeaf, SMT_DEPTH, SMT_MAX_DEPTH, SMT_MIN_DEPTH,
29};
30
31mod mmr;
32pub use mmr::{InOrderIndex, Mmr, MmrDelta, MmrError, MmrPeaks, MmrProof, PartialMmr};
33
34mod store;
35pub use store::{DefaultMerkleStore, MerkleStore, RecordingMerkleStore, StoreNode};
36
37mod node;
38pub use node::InnerNodeInfo;
39
40mod partial_mt;
41pub use partial_mt::PartialMerkleTree;
42
43mod error;
44pub use error::MerkleError;
45
46// HELPER FUNCTIONS
47// ================================================================================================
48
49#[cfg(test)]
50const fn int_to_node(value: u64) -> RpoDigest {
51    RpoDigest::new([Felt::new(value), ZERO, ZERO, ZERO])
52}
53
54#[cfg(test)]
55const fn int_to_leaf(value: u64) -> Word {
56    [Felt::new(value), ZERO, ZERO, ZERO]
57}
58
59#[cfg(test)]
60fn digests_to_words(digests: &[RpoDigest]) -> alloc::vec::Vec<Word> {
61    digests.iter().map(|d| d.into()).collect()
62}