From e2acaf89e6b831a7730ebda20224ad82ff32503e Mon Sep 17 00:00:00 2001 From: Qyriad Date: Fri, 21 Mar 2025 18:41:04 +0100 Subject: [PATCH] SparseMerklePath: impl From/Into conversions --- miden-crypto/src/merkle/sparse_path.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/miden-crypto/src/merkle/sparse_path.rs b/miden-crypto/src/merkle/sparse_path.rs index 0e277b7..3eca5f0 100644 --- a/miden-crypto/src/merkle/sparse_path.rs +++ b/miden-crypto/src/merkle/sparse_path.rs @@ -125,6 +125,30 @@ impl SparseMerklePath { } } +// CONVERSIONS +// ================================================================================================ + +impl From for MerklePath { + fn from(sparse_path: SparseMerklePath) -> Self { + sparse_path.into_path() + } +} + +/// # Panics +/// +/// This conversion fails and panics if the path length is greater than [`SMT_MAX_DEPTH`]. +impl From for SparseMerklePath { + fn from(path: MerklePath) -> Self { + SparseMerklePath::from_path(path).unwrap() + } +} + +impl From for Vec { + fn from(path: SparseMerklePath) -> Self { + path.into_path().into() + } +} + // ITERATORS // ================================================================================================