Skip to main content

context_key

Function context_key 

Source
pub fn context_key(context: &str) -> [u8; 32]
Expand description

Hash a key-derivation context string and return a ContextKey.

This has the same security requirement as key derivation. The context string should be hardcoded, globally unique, and application-specific.

Its one use is Mode::DeriveKeyWith: a program that derives many keys from one context hashes the context once.

ยงExample

use blake3_servil_core::Mode;

let context_key = blake3_servil_core::throughput::context_key("foo");
let derived = blake3_servil_core::convenience::hash_with(Mode::DeriveKeyWith(&context_key), b"bar");
assert_eq!(derived, blake3_servil_core::convenience::hash_with(Mode::DeriveKey("foo"), b"bar"));