Introduce SparseMerkleTree trait (#245)

This commit is contained in:
Philippe Laferrière
2024-01-18 16:02:02 -05:00
committed by Bobbin Threadbare
parent 1004246bfe
commit 8ea37904e3
13 changed files with 826 additions and 684 deletions

View File

@@ -1,3 +1,5 @@
use crate::Word;
use super::{vec, InnerNodeInfo, MerkleError, NodeIndex, Rpo256, RpoDigest, Vec};
use core::ops::{Deref, DerefMut};
use winter_utils::{ByteReader, Deserializable, DeserializationError, Serializable};
@@ -174,8 +176,14 @@ pub struct ValuePath {
impl ValuePath {
/// Returns a new [ValuePath] instantiated from the specified value and path.
pub fn new(value: RpoDigest, path: Vec<RpoDigest>) -> Self {
Self { value, path: MerklePath::new(path) }
pub fn new(value: RpoDigest, path: MerklePath) -> Self {
Self { value, path }
}
}
impl From<(MerklePath, Word)> for ValuePath {
fn from((path, value): (MerklePath, Word)) -> Self {
ValuePath::new(value.into(), path)
}
}