mirror of
https://github.com/arnaucube/miden-crypto.git
synced 2026-01-12 09:01:29 +01:00
feat: add merkle node index
This commit introduces a wrapper structure to encapsulate the merkle tree traversal. related issue: #36
This commit is contained in:
@@ -5,6 +5,9 @@ use super::{
|
||||
};
|
||||
use core::fmt;
|
||||
|
||||
mod index;
|
||||
pub use index::NodeIndex;
|
||||
|
||||
mod merkle_tree;
|
||||
pub use merkle_tree::MerkleTree;
|
||||
|
||||
@@ -22,11 +25,11 @@ pub use simple_smt::SimpleSmt;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum MerkleError {
|
||||
DepthTooSmall(u32),
|
||||
DepthTooBig(u32),
|
||||
DepthTooSmall(u8),
|
||||
DepthTooBig(u8),
|
||||
NumLeavesNotPowerOfTwo(usize),
|
||||
InvalidIndex(u32, u64),
|
||||
InvalidDepth(u32, u32),
|
||||
InvalidIndex(NodeIndex),
|
||||
InvalidDepth { expected: u8, provided: u8 },
|
||||
InvalidPath(MerklePath),
|
||||
InvalidEntriesCount(usize, usize),
|
||||
NodeNotInSet(u64),
|
||||
@@ -41,11 +44,11 @@ impl fmt::Display for MerkleError {
|
||||
NumLeavesNotPowerOfTwo(leaves) => {
|
||||
write!(f, "the leaves count {leaves} is not a power of 2")
|
||||
}
|
||||
InvalidIndex(depth, index) => write!(
|
||||
InvalidIndex(index) => write!(
|
||||
f,
|
||||
"the leaf index {index} is not valid for the depth {depth}"
|
||||
"the index value {} is not valid for the depth {}", index.value(), index.depth()
|
||||
),
|
||||
InvalidDepth(expected, provided) => write!(
|
||||
InvalidDepth { expected, provided } => write!(
|
||||
f,
|
||||
"the provided depth {provided} is not valid for {expected}"
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user