miden_crypto/merkle/smt/full/
error.rs1use thiserror::Error;
2
3use crate::{
4 Word,
5 merkle::{LeafIndex, MAX_LEAF_ENTRIES, SMT_DEPTH},
6};
7
8#[derive(Debug, Error)]
13pub enum SmtLeafError {
14 #[error(
16 "multiple leaf requires all keys to map to the same leaf index but key1 {key_1} and key2 {key_2} map to different indices"
17 )]
18 InconsistentMultipleLeafKeys { key_1: Word, key_2: Word },
20 #[error(
21 "single leaf key {key} maps to leaf {actual_leaf_index} but was expected to map to leaf {expected_leaf_index}"
22 )]
23 InconsistentSingleLeafIndices {
24 key: Word,
25 expected_leaf_index: LeafIndex<SMT_DEPTH>,
26 actual_leaf_index: LeafIndex<SMT_DEPTH>,
27 },
28
29 #[error(
31 "supplied leaf index {leaf_index_supplied:?} does not match {leaf_index_from_keys:?} for multiple leaf"
32 )]
33 InconsistentMultipleLeafIndices {
34 leaf_index_from_keys: LeafIndex<SMT_DEPTH>,
35 leaf_index_supplied: LeafIndex<SMT_DEPTH>,
36 },
37
38 #[error("multiple leaf requires at least two entries but only {0} were given")]
40 MultipleLeafRequiresTwoEntries(usize),
41
42 #[error(
44 "multiple leaf contains {actual} entries but the maximum allowed is {MAX_LEAF_ENTRIES}"
45 )]
46 TooManyLeafEntries { actual: usize },
47}
48
49#[derive(Debug, Error)]
54pub enum SmtProofError {
55 #[error("merkle path length {0} does not match SMT depth {SMT_DEPTH}")]
57 InvalidMerklePathLength(usize),
58}