miden_crypto/merkle/smt/full/
error.rs

1use thiserror::Error;
2
3use crate::{
4    hash::rpo::RpoDigest,
5    merkle::{LeafIndex, SMT_DEPTH},
6};
7
8// SMT LEAF ERROR
9// =================================================================================================
10
11#[derive(Debug, Error)]
12pub enum SmtLeafError {
13    #[error(
14        "multiple leaf requires all keys to map to the same leaf index but key1 {key_1} and key2 {key_2} map to different indices"
15    )]
16    InconsistentMultipleLeafKeys { key_1: RpoDigest, key_2: RpoDigest },
17    #[error(
18        "single leaf key {key} maps to {actual_leaf_index:?} but was expected to map to {expected_leaf_index:?}"
19    )]
20    InconsistentSingleLeafIndices {
21        key: RpoDigest,
22        expected_leaf_index: LeafIndex<SMT_DEPTH>,
23        actual_leaf_index: LeafIndex<SMT_DEPTH>,
24    },
25    #[error(
26        "supplied leaf index {leaf_index_supplied:?} does not match {leaf_index_from_keys:?} for multiple leaf"
27    )]
28    InconsistentMultipleLeafIndices {
29        leaf_index_from_keys: LeafIndex<SMT_DEPTH>,
30        leaf_index_supplied: LeafIndex<SMT_DEPTH>,
31    },
32    #[error("multiple leaf requires at least two entries but only {0} were given")]
33    MultipleLeafRequiresTwoEntries(usize),
34}
35
36// SMT PROOF ERROR
37// =================================================================================================
38
39#[derive(Debug, Error)]
40pub enum SmtProofError {
41    #[error("merkle path length {0} does not match SMT depth {SMT_DEPTH}")]
42    InvalidMerklePathLength(usize),
43}