Skip to main content

HashFn

Trait HashFn 

Source
pub trait HashFn<F: Field>: Send + Sync {
    // Required methods
    fn hash_pair(&self, a: &Digest, b: &Digest) -> Box<Digest>;
    fn hash_elem_slice(&self, slice: &[F::Elem]) -> Box<Digest>;
    fn hash_ext_elem_slice(&self, slice: &[F::ExtElem]) -> Box<Digest>;

    // Provided method
    fn is_digest_valid(&self, digest: &Digest) -> bool { ... }
}
Expand description

A trait that sets the hashes and encodings used by the ZKP.

Required Methods§

Source

fn hash_pair(&self, a: &Digest, b: &Digest) -> Box<Digest>

Generate a hash from a pair of Digest.

Source

fn hash_elem_slice(&self, slice: &[F::Elem]) -> Box<Digest>

Generate a hash from a slice of field elements. This may be unpadded so this is only safe to used when the size is known.

Source

fn hash_ext_elem_slice(&self, slice: &[F::ExtElem]) -> Box<Digest>

Generate a hash from a slice of extension field element. This may be unpadded so this is only safe to used when the size is known.

Provided Methods§

Source

fn is_digest_valid(&self, digest: &Digest) -> bool

Checks whether the given Digest is valid for this hash function.

Poseidon2 considers a Digest invalid is any of the words in the digest are not reduced Baby Bear elements.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§