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>where
PH::Hash: Clone,
impl<LH: Clone + LeafHash<Hash = PH::Hash>, PH: Clone + PathHash, const DEPTH: u8, const ARITY: u8> Clone for KaryMerkleTree<LH, PH, DEPTH, ARITY>where PH::Hash: Clone,
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> RefUnwindSafe for KaryMerkleTree<LH, PH, DEPTH, ARITY>where LH: RefUnwindSafe, PH: RefUnwindSafe, <PH as PathHash>::Hash: RefUnwindSafe,
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>where LH: Unpin, PH: Unpin, <PH as PathHash>::Hash: Unpin,
impl<LH, PH, const DEPTH: u8, const ARITY: u8> UnwindSafe for KaryMerkleTree<LH, PH, DEPTH, ARITY>where LH: UnwindSafe, PH: UnwindSafe, <PH as PathHash>::Hash: UnwindSafe,
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