Hasher

Trait Hasher 

Source
pub trait Hasher {
    type Digest: Digest;

    const COLLISION_RESISTANCE: u32;

    // Required methods
    fn hash(bytes: &[u8]) -> Self::Digest;
    fn merge(values: &[Self::Digest; 2]) -> Self::Digest;
    fn merge_many(values: &[Self::Digest]) -> Self::Digest;
    fn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest;
}
Expand description

Defines a cryptographic hash function.

This trait defines hash procedures for the following inputs:

  • A sequence of bytes.
  • Two digests - this is intended for use in Merkle tree constructions.
  • A digests and a u64 value - this intended for use in PRNG or PoW contexts.

Required Associated Constants§

Source

const COLLISION_RESISTANCE: u32

Collision resistance of the hash function measured in bits.

Required Associated Types§

Source

type Digest: Digest

Specifies a digest type returned by this hasher.

Required Methods§

Source

fn hash(bytes: &[u8]) -> Self::Digest

Returns a hash of the provided sequence of bytes.

Source

fn merge(values: &[Self::Digest; 2]) -> Self::Digest

Returns a hash of two digests. This method is intended for use in construction of Merkle trees.

Source

fn merge_many(values: &[Self::Digest]) -> Self::Digest

Returns a hash of many digests.

Source

fn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest

Returns hash(seed || value). This method is intended for use in PRNG and PoW contexts.

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.

Implementations on Foreign Types§

Source§

impl Hasher for Blake3_160

Source§

const COLLISION_RESISTANCE: u32 = 80u32

Blake3 collision resistance is 80-bits for 20-bytes output.

Source§

type Digest = Blake3Digest<20>

Source§

fn hash(bytes: &[u8]) -> <Blake3_160 as Hasher>::Digest

Source§

fn merge( values: &[<Blake3_160 as Hasher>::Digest; 2], ) -> <Blake3_160 as Hasher>::Digest

Source§

fn merge_many( values: &[<Blake3_160 as Hasher>::Digest], ) -> <Blake3_160 as Hasher>::Digest

Source§

fn merge_with_int( seed: <Blake3_160 as Hasher>::Digest, value: u64, ) -> <Blake3_160 as Hasher>::Digest

Source§

impl Hasher for Keccak256

Source§

const COLLISION_RESISTANCE: u32 = 128u32

Keccak256 collision resistance is 128-bits for 32-bytes output.

Source§

type Digest = Keccak256Digest

Source§

fn hash(bytes: &[u8]) -> <Keccak256 as Hasher>::Digest

Source§

fn merge( values: &[<Keccak256 as Hasher>::Digest; 2], ) -> <Keccak256 as Hasher>::Digest

Source§

fn merge_many( values: &[<Keccak256 as Hasher>::Digest], ) -> <Keccak256 as Hasher>::Digest

Source§

fn merge_with_int( seed: <Keccak256 as Hasher>::Digest, value: u64, ) -> <Keccak256 as Hasher>::Digest

Implementors§

Source§

impl Hasher for miden_processor::utils::Blake3_256

Source§

impl Hasher for Rp62_248

Source§

const COLLISION_RESISTANCE: u32 = 124u32

Source§

type Digest = ElementDigest

Source§

impl Hasher for Rp64_256

Source§

const COLLISION_RESISTANCE: u32 = 128u32

Source§

type Digest = ElementDigest

Source§

impl Hasher for RpJive64_256

Source§

const COLLISION_RESISTANCE: u32 = 128u32

Source§

type Digest = ElementDigest

Source§

impl Hasher for miden_processor::crypto::Blake3_192

Source§

impl Hasher for Poseidon2

Source§

impl Hasher for Rpo256

Source§

impl Hasher for Rpx256

Source§

impl<B> Hasher for winter_crypto::hash::blake::Blake3_192<B>
where B: StarkField,

Source§

const COLLISION_RESISTANCE: u32 = 96u32

Source§

type Digest = ByteDigest<24>

Source§

impl<B> Hasher for winter_crypto::hash::blake::Blake3_256<B>
where B: StarkField,

Source§

const COLLISION_RESISTANCE: u32 = 128u32

Source§

type Digest = ByteDigest<32>

Source§

impl<B> Hasher for Sha3_256<B>
where B: StarkField,

Source§

const COLLISION_RESISTANCE: u32 = 128u32

Source§

type Digest = ByteDigest<32>