pub trait HashAlgorithm:
Clone
+ Send
+ Sync
+ 'static {
const OUTPUT_SIZE: usize;
const ALGORITHM_NAME: &'static str;
// Required method
fn hash(data: &[u8]) -> Vec<u8> ⓘ;
// Provided methods
fn hash_concat(data1: &[u8], data2: &[u8]) -> Vec<u8> ⓘ { ... }
fn expand_seed(seed: &[u8]) -> (Vec<u8>, Vec<u8>) { ... }
}Available on crate feature
hash only.Expand description
Trait for hash algorithms used in KES schemes
This trait provides a simple interface for hash algorithms used in Key Evolving Signature (KES) constructions, particularly for the binary sum composition where verification keys are hashed.
Required Associated Constants§
Sourceconst OUTPUT_SIZE: usize
const OUTPUT_SIZE: usize
Output size in bytes
Sourceconst ALGORITHM_NAME: &'static str
const ALGORITHM_NAME: &'static str
Algorithm name for debugging
Required Methods§
Provided Methods§
Sourcefn hash_concat(data1: &[u8], data2: &[u8]) -> Vec<u8> ⓘ
fn hash_concat(data1: &[u8], data2: &[u8]) -> Vec<u8> ⓘ
Hash two inputs concatenated together
§Example
use cardano_crypto::hash::{Blake2b256, HashAlgorithm};
let hash = Blake2b256::hash_concat(b"hello", b"world");
assert_eq!(hash.len(), 32);Sourcefn expand_seed(seed: &[u8]) -> (Vec<u8>, Vec<u8>)
fn expand_seed(seed: &[u8]) -> (Vec<u8>, Vec<u8>)
Expand a seed into two new seeds using domain separation
§Example
use cardano_crypto::hash::{Blake2b256, HashAlgorithm};
let seed = b"original seed";
let (seed0, seed1) = Blake2b256::expand_seed(seed);
assert_eq!(seed0.len(), 32);
assert_eq!(seed1.len(), 32);
assert_ne!(seed0, seed1);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.