miden-crypto/src/merkle/tiered_smt/error.rs
src/merkle/tiered_smt/error.rsRaw
1use core::fmt::Display;
2
3#[derive(Debug, PartialEq, Eq)]
4pub enum TieredSmtProofError {
5 EntriesEmpty,
6 PathTooLong,
7 NotATierPath(u8),
8 MultipleEntriesOutsideLastTier,
9 EmptyValueNotAllowed,
10 UnmatchingPrefixes(u64, u64),
11}
12
13impl Display for TieredSmtProofError {
14 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
15 match self {
16 TieredSmtProofError::EntriesEmpty => {
17 write!(f, "Missing entries for tiered sparse merkle tree proof")
18 }
19 TieredSmtProofError::PathTooLong => {
20 write!(
21 f,
22 "Path longer than maximum depth of 64 for tiered sparse merkle tree proof"
23 )
24 }
25 TieredSmtProofError::NotATierPath(got) => {
26 write!(
27 f,
28 "Path length does not correspond to a tier. Got {} Expected one of 16,32,48,64",
29 got
30 )
31 }
32 TieredSmtProofError::MultipleEntriesOutsideLastTier => {
33 write!(f, "Multiple entries are only allowed for the last tier (depth 64)")
34 }
35 TieredSmtProofError::EmptyValueNotAllowed => {
36 write!(
37 f,
38 "The empty value [0,0,0,0] is not allowed inside a tiered sparse merkle tree"
39 )
40 }
41 TieredSmtProofError::UnmatchingPrefixes(first, second) => {
42 write!(f, "Not all leaves have the same prefix. First {} second {}", first, second)
43 }
44 }
45 }
46}
47
48#[cfg(feature = "std")]
49impl std::error::Error for TieredSmtProofError {}