Trait winter_crypto::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_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 Types§

source

type Digest: Digest

Specifies a digest type returned by this hasher.

Required Associated Constants§

source

const COLLISION_RESISTANCE: u32

Collision resistance of the hash function measured in bits.

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_with_int(seed: Self::Digest, value: u64) -> Self::Digest

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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Hasher for Rp62_248

§

type Digest = ElementDigest

source§

const COLLISION_RESISTANCE: u32 = 124u32

source§

impl Hasher for Rp64_256

§

type Digest = ElementDigest

source§

const COLLISION_RESISTANCE: u32 = 128u32

source§

impl Hasher for RpJive64_256

§

type Digest = ElementDigest

source§

const COLLISION_RESISTANCE: u32 = 128u32

source§

impl<B: StarkField> Hasher for Blake3_192<B>

§

type Digest = ByteDigest<24>

source§

const COLLISION_RESISTANCE: u32 = 96u32

source§

impl<B: StarkField> Hasher for Blake3_256<B>

§

type Digest = ByteDigest<32>

source§

const COLLISION_RESISTANCE: u32 = 128u32

source§

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

§

type Digest = ByteDigest<32>

source§

const COLLISION_RESISTANCE: u32 = 128u32