mirror of
https://github.com/arnaucube/miden-crypto.git
synced 2026-01-12 00:51:29 +01:00
mmr: added partial mmr
This commit is contained in:
@@ -28,6 +28,11 @@ impl MerklePath {
|
||||
self.nodes.len() as u8
|
||||
}
|
||||
|
||||
/// Returns a reference to the [MerklePath]'s nodes.
|
||||
pub fn nodes(&self) -> &[RpoDigest] {
|
||||
&self.nodes
|
||||
}
|
||||
|
||||
/// Computes the merkle root for this opening.
|
||||
pub fn compute_root(&self, index: u64, node: RpoDigest) -> Result<RpoDigest, MerkleError> {
|
||||
let mut index = NodeIndex::new(self.depth(), index)?;
|
||||
@@ -69,6 +74,9 @@ impl MerklePath {
|
||||
}
|
||||
}
|
||||
|
||||
// CONVERSIONS
|
||||
// ================================================================================================
|
||||
|
||||
impl From<MerklePath> for Vec<RpoDigest> {
|
||||
fn from(path: MerklePath) -> Self {
|
||||
path.nodes
|
||||
@@ -81,6 +89,12 @@ impl From<Vec<RpoDigest>> for MerklePath {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&[RpoDigest]> for MerklePath {
|
||||
fn from(path: &[RpoDigest]) -> Self {
|
||||
Self::new(path.to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for MerklePath {
|
||||
// we use `Vec` here instead of slice so we can call vector mutation methods directly from the
|
||||
// merkle path (example: `Vec::remove`).
|
||||
|
||||
Reference in New Issue
Block a user