Hasher

Trait Hasher 

Source
pub trait Hasher<H: CHasher>: Send + Sync {
    // Required methods
    fn leaf_digest(&mut self, pos: u64, element: &[u8]) -> H::Digest;
    fn node_digest(
        &mut self,
        pos: u64,
        left: &H::Digest,
        right: &H::Digest,
    ) -> H::Digest;
    fn root<'a>(
        &mut self,
        size: u64,
        peak_digests: impl Iterator<Item = &'a H::Digest>,
    ) -> H::Digest;
    fn digest(&mut self, data: &[u8]) -> H::Digest;
    fn inner(&mut self) -> &mut H;
    fn fork(&self) -> impl Hasher<H>;
}
Expand description

A trait for computing the various digests of an MMR.

Required Methods§

Source

fn leaf_digest(&mut self, pos: u64, element: &[u8]) -> H::Digest

Computes the digest for a leaf given its position and the element it represents.

Source

fn node_digest( &mut self, pos: u64, left: &H::Digest, right: &H::Digest, ) -> H::Digest

Computes the digest for a node given its position and the digests of its children.

Source

fn root<'a>( &mut self, size: u64, peak_digests: impl Iterator<Item = &'a H::Digest>, ) -> H::Digest

Computes the root for an MMR given its size and an iterator over the digests of its peaks in decreasing order of height.

Source

fn digest(&mut self, data: &[u8]) -> H::Digest

Compute the digest of a byte slice.

Source

fn inner(&mut self) -> &mut H

Access the inner CHasher hasher.

Source

fn fork(&self) -> impl Hasher<H>

Fork the hasher to provide equivalent functionality in another thread. This is different than Clone::clone because the forked hasher need not be a deep copy, and may share non-mutable state with the hasher from which it was forked.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<H: CHasher> Hasher<H> for Grafting<'_, H>

Source§

impl<H: CHasher> Hasher<H> for GraftingFork<'_, H>

Source§

impl<H: CHasher> Hasher<H> for GraftingVerifier<'_, H>

Source§

impl<H: CHasher> Hasher<H> for Standard<H>