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