pub struct MerkleTree { /* private fields */ }
Expand description
Merkle tree implementation for the model, assumes the leaf layer consists of 32 byte blobs. The tree is built in a flattened manner, where the leaves are at the beginning of the vector and layers are placed adjacent to each other.
Implementations§
Source§impl MerkleTree
impl MerkleTree
Sourcepub fn new(leaves: &[[u8; 32]]) -> Self
pub fn new(leaves: &[[u8; 32]]) -> Self
Constructs a Merkle tree from the given leaf nodes that uses the Groestl output transformation (Groestl-P permutation + XOR) as a digest compression function.
Sourcepub fn merkle_path(&self, index: usize) -> Vec<[u8; 32]>
pub fn merkle_path(&self, index: usize) -> Vec<[u8; 32]>
Returns a merkle path for the given index.
Sourcepub fn verify_path(
path: &[[u8; 32]],
root: [u8; 32],
leaf: [u8; 32],
index: usize,
)
pub fn verify_path( path: &[[u8; 32]], root: [u8; 32], leaf: [u8; 32], index: usize, )
Verifies a merkle path for inclusion in the tree.
pub fn root(&self) -> [u8; 32]
Auto Trait Implementations§
impl Freeze for MerkleTree
impl RefUnwindSafe for MerkleTree
impl Send for MerkleTree
impl Sync for MerkleTree
impl Unpin for MerkleTree
impl UnwindSafe for MerkleTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more