miden_crypto/merkle/
error.rs

1use thiserror::Error;
2
3use super::{MAX_LEAF_ENTRIES, 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("number of entries in a leaf ({actual}) exceeds the maximum of ({MAX_LEAF_ENTRIES})")]
26    TooManyLeafEntries { actual: usize },
27    #[error("node index `{0}` not found in the tree")]
28    NodeIndexNotFoundInTree(NodeIndex),
29    #[error("node {0:?} with index `{1}` not found in the store")]
30    NodeIndexNotFoundInStore(Word, NodeIndex),
31    #[error("number of provided merkle tree leaves {0} is not a power of two")]
32    NumLeavesNotPowerOfTwo(usize),
33    #[error("root {0:?} is not in the store")]
34    RootNotInStore(Word),
35    #[error(
36        "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"
37    )]
38    UntrackedKey(Word),
39}