miden_crypto/merkle/
error.rs

1use thiserror::Error;
2
3use super::{NodeIndex, Word};
4
5#[derive(Debug, Error)]
6pub enum MerkleError {
7    #[error("expected merkle root {expected_root} found {actual_root}")]
8    ConflictingRoots { expected_root: Word, actual_root: Word },
9    #[error("provided merkle tree depth {0} is too small")]
10    DepthTooSmall(u8),
11    #[error("provided merkle tree depth {0} is too big")]
12    DepthTooBig(u64),
13    #[error("multiple values provided for merkle tree index {0}")]
14    DuplicateValuesForIndex(u64),
15    #[error("node index value {value} is not valid for depth {depth}")]
16    InvalidNodeIndex { depth: u8, value: u64 },
17    #[error("provided node index depth {provided} does not match expected depth {expected}")]
18    InvalidNodeIndexDepth { expected: u8, provided: u8 },
19    #[error("provided node list should have a minimum length of {0}")]
20    InvalidPathLength(usize),
21    #[error("merkle subtree depth {subtree_depth} exceeds merkle tree depth {tree_depth}")]
22    SubtreeDepthExceedsDepth { subtree_depth: u8, tree_depth: u8 },
23    #[error("number of entries in the merkle tree exceeds the maximum of {0}")]
24    TooManyEntries(usize),
25    #[error("node index `{0}` not found in the tree")]
26    NodeIndexNotFoundInTree(NodeIndex),
27    #[error("node {0:?} with index `{1}` not found in the store")]
28    NodeIndexNotFoundInStore(Word, NodeIndex),
29    #[error("number of provided merkle tree leaves {0} is not a power of two")]
30    NumLeavesNotPowerOfTwo(usize),
31    #[error("root {0:?} is not in the store")]
32    RootNotInStore(Word),
33    #[error(
34        "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"
35    )]
36    UntrackedKey(Word),
37}