SparseMerklePath: impl From/Into conversions

This commit is contained in:
Qyriad 2025-03-21 18:41:04 +01:00
parent 9b65debf2c
commit 1bb1a45bd0

View file

@ -137,6 +137,30 @@ impl SparseMerklePath {
}
}
// CONVERSIONS
// ================================================================================================
impl From<SparseMerklePath> 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<MerklePath> for SparseMerklePath {
fn from(path: MerklePath) -> Self {
SparseMerklePath::from_path(path).unwrap()
}
}
impl From<SparseMerklePath> for Vec<RpoDigest> {
fn from(path: SparseMerklePath) -> Self {
path.into_path().into()
}
}
// ITERATORS
// ================================================================================================