Skip to main content

MerkleHasher

Trait MerkleHasher 

Source
pub trait MerkleHasher:
    'static
    + Clone
    + Send
    + Sync {
    type F: Field;
    type Digest: 'static + Copy + Send + Sync;

    // Required methods
    fn hash_slice(&self, vals: &[Self::F]) -> Self::Digest;
    fn compress(&self, left: Self::Digest, right: Self::Digest) -> Self::Digest;

    // Provided method
    fn tree_compress(&self, hashes: Vec<Self::Digest>) -> Self::Digest { ... }
}
Expand description

Trait abstracting Merkle tree hash operations. This trait is used as part of the definition of the StarkProtocolConfig.

The MerkleHasher is parameterized over the base field F used as leaves, and provides a Digest type for internal nodes.

Required Associated Types§

Source

type F: Field

Source

type Digest: 'static + Copy + Send + Sync

Required Methods§

Source

fn hash_slice(&self, vals: &[Self::F]) -> Self::Digest

Hash a slice of field elements into a digest (used for leaf hashing).

Source

fn compress(&self, left: Self::Digest, right: Self::Digest) -> Self::Digest

Compress two digests into one (used for internal Merkle tree nodes).

Provided Methods§

Source

fn tree_compress(&self, hashes: Vec<Self::Digest>) -> Self::Digest

Compress a vector of digests (must be power-of-two length) into a single digest by repeated binary compression.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F, Digest, H, C> MerkleHasher for Hasher<F, Digest, H, C>
where F: Field, Digest: 'static + Copy + Send + Sync, H: 'static + Send + Sync + CryptographicHasher<F, Digest>, C: 'static + Send + Sync + PseudoCompressionFunction<Digest, 2>,

Source§

type F = F

Source§

type Digest = Digest