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§
Sourcefn hash_pair(&self, a: &Digest, b: &Digest) -> Box<Digest>
fn hash_pair(&self, a: &Digest, b: &Digest) -> Box<Digest>
Generate a hash from a pair of Digest.
Sourcefn hash_elem_slice(&self, slice: &[F::Elem]) -> Box<Digest>
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.
Sourcefn hash_ext_elem_slice(&self, slice: &[F::ExtElem]) -> Box<Digest>
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§
Sourcefn is_digest_valid(&self, digest: &Digest) -> bool
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".