From c45d9682eb4789778d65311095debc9728bbbe45 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 dc52b33..eb9fd31 100644 --- a/miden-crypto/src/merkle/sparse_path.rs +++ b/miden-crypto/src/merkle/sparse_path.rs @@ -137,6 +137,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 // ================================================================================================