pub struct KaryMerkleTree<LH: LeafHash<Hash = PH::Hash>, PH: PathHash, const DEPTH: u8, const ARITY: u8> { /* private fields */ }
Implementations§
Source§impl<LH: LeafHash<Hash = PH::Hash>, PH: PathHash, const DEPTH: u8, const ARITY: u8> KaryMerkleTree<LH, PH, DEPTH, ARITY>
impl<LH: LeafHash<Hash = PH::Hash>, PH: PathHash, const DEPTH: u8, const ARITY: u8> KaryMerkleTree<LH, PH, DEPTH, ARITY>
Sourcepub fn new(
leaf_hasher: &LH,
path_hasher: &PH,
leaves: &[LH::Leaf],
) -> Result<Self>
pub fn new( leaf_hasher: &LH, path_hasher: &PH, leaves: &[LH::Leaf], ) -> Result<Self>
Initializes a new Merkle tree with the given leaves.
Sourcepub fn prove(
&self,
leaf_index: usize,
leaf: &LH::Leaf,
) -> Result<KaryMerklePath<PH, DEPTH, ARITY>>
pub fn prove( &self, leaf_index: usize, leaf: &LH::Leaf, ) -> Result<KaryMerklePath<PH, DEPTH, ARITY>>
Returns the Merkle path for the given leaf index and leaf.
Sourcepub fn verify(
&self,
path: &KaryMerklePath<PH, DEPTH, ARITY>,
root: &PH::Hash,
leaf: &LH::Leaf,
) -> bool
pub fn verify( &self, path: &KaryMerklePath<PH, DEPTH, ARITY>, root: &PH::Hash, leaf: &LH::Leaf, ) -> bool
Returns true
if the given Merkle path is valid for the given root and leaf.
Sourcepub fn tree(&self) -> &[PH::Hash]
pub fn tree(&self) -> &[PH::Hash]
Returns the Merkle tree (excluding the hashes of the leaves).
Sourcepub const fn empty_hash(&self) -> &PH::Hash
pub const fn empty_hash(&self) -> &PH::Hash
Returns the empty hash.
Sourcepub const fn number_of_leaves(&self) -> usize
pub const fn number_of_leaves(&self) -> usize
Returns the number of leaves in the Merkle tree.
Trait Implementations§
Source§impl<LH: Clone + LeafHash<Hash = PH::Hash>, PH: Clone + PathHash, const DEPTH: u8, const ARITY: u8> Clone for KaryMerkleTree<LH, PH, DEPTH, ARITY>
impl<LH: Clone + LeafHash<Hash = PH::Hash>, PH: Clone + PathHash, const DEPTH: u8, const ARITY: u8> Clone for KaryMerkleTree<LH, PH, DEPTH, ARITY>
Source§fn clone(&self) -> KaryMerkleTree<LH, PH, DEPTH, ARITY>
fn clone(&self) -> KaryMerkleTree<LH, PH, DEPTH, ARITY>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<LH, PH, const DEPTH: u8, const ARITY: u8> Freeze for KaryMerkleTree<LH, PH, DEPTH, ARITY>
impl<LH, PH, const DEPTH: u8, const ARITY: u8> RefUnwindSafe for KaryMerkleTree<LH, PH, DEPTH, ARITY>
impl<LH, PH, const DEPTH: u8, const ARITY: u8> Send for KaryMerkleTree<LH, PH, DEPTH, ARITY>
impl<LH, PH, const DEPTH: u8, const ARITY: u8> Sync for KaryMerkleTree<LH, PH, DEPTH, ARITY>
impl<LH, PH, const DEPTH: u8, const ARITY: u8> Unpin for KaryMerkleTree<LH, PH, DEPTH, ARITY>
impl<LH, PH, const DEPTH: u8, const ARITY: u8> UnwindSafe for KaryMerkleTree<LH, PH, DEPTH, ARITY>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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