miden_crypto/merkle/
error.rs

1use thiserror::Error;
2
3use super::{NodeIndex, RpoDigest};
4
5#[derive(Debug, Error)]
6pub enum MerkleError {
7    #[error("expected merkle root {expected_root} found {actual_root}")]
8    ConflictingRoots {
9        expected_root: RpoDigest,
10        actual_root: RpoDigest,
11    },
12    #[error("provided merkle tree depth {0} is too small")]
13    DepthTooSmall(u8),
14    #[error("provided merkle tree depth {0} is too big")]
15    DepthTooBig(u64),
16    #[error("multiple values provided for merkle tree index {0}")]
17    DuplicateValuesForIndex(u64),
18    #[error("node index value {value} is not valid for depth {depth}")]
19    InvalidNodeIndex { depth: u8, value: u64 },
20    #[error("provided node index depth {provided} does not match expected depth {expected}")]
21    InvalidNodeIndexDepth { expected: u8, provided: u8 },
22    #[error("merkle subtree depth {subtree_depth} exceeds merkle tree depth {tree_depth}")]
23    SubtreeDepthExceedsDepth { subtree_depth: u8, tree_depth: u8 },
24    #[error("number of entries in the merkle tree exceeds the maximum of {0}")]
25    TooManyEntries(usize),
26    #[error("node index `{0}` not found in the tree")]
27    NodeIndexNotFoundInTree(NodeIndex),
28    #[error("node {0:?} with index `{1}` not found in the store")]
29    NodeIndexNotFoundInStore(RpoDigest, NodeIndex),
30    #[error("number of provided merkle tree leaves {0} is not a power of two")]
31    NumLeavesNotPowerOfTwo(usize),
32    #[error("root {0:?} is not in the store")]
33    RootNotInStore(RpoDigest),
34    #[error(
35        "partial smt does not track the merkle path for key {0} so updating it would produce a different root compared to the same update in the full tree"
36    )]
37    UntrackedKey(RpoDigest),
38}