Trait CryptoDigest

Source
pub trait CryptoDigest: Serialize {
    const PREFIX: &'static [u8; 15];

    // Provided method
    fn digest(&self) -> [u8; 32] { ... }
}
Expand description

This trait can be implemented on any type that implements serde::Serialize, in order to provide a digest() function that returns a unique hash.

Required Associated Constants§

Source

const PREFIX: &'static [u8; 15]

The domain separation string to use in the hash. This is to distinguish hashes for different use-cases. With this approach, a type is linked to a single usecase.

Warning: careful not to use the same separation string with two different types.

Provided Methods§

Source

fn digest(&self) -> [u8; 32]

Returns the digest of self. Note: this is implemented as the SHA-256 of a prefix (“kimchi-circuit”), followed by the serialized gates. The gates are serialized using BCS.

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.

Implementors§