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.

Object Safety§

This trait is not object safe.

Implementors§