diff --git a/miden-crypto/src/merkle/sparse_path.rs b/miden-crypto/src/merkle/sparse_path.rs index eb9fd31..af836c9 100644 --- a/miden-crypto/src/merkle/sparse_path.rs +++ b/miden-crypto/src/merkle/sparse_path.rs @@ -254,6 +254,33 @@ impl DoubleEndedIterator for SparseMerkleIter { } } +// SPARSE MERKLE PATH CONTAINERS +// ================================================================================================ +/// A container for a [crate::Word] value and its [SparseMerklePath] opening. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct SparseValuePath { + /// The node value opening for `path`. + pub value: RpoDigest, + /// The path from `value` to `root` (exclusive), using an efficient memory representation for + /// empty nodes. + pub path: SparseMerklePath, +} + +impl SparseValuePath { + /// Convenience function to construct a [SparseValuePath]. + /// + /// `value` is the value `path` leads to, in the tree. + pub fn new(value: RpoDigest, path: SparseMerklePath) -> Self { + Self { value, path } + } +} + +impl From<(SparseMerklePath, Word)> for SparseValuePath { + fn from((path, value): (SparseMerklePath, Word)) -> Self { + SparseValuePath::new(value.into(), path) + } +} + // SERIALIZATION // ================================================================================================