STHash
STHash is a fast, keyed, cryptographic hash function designed to process large, possibly untrusted data.
The flipside is that using a secret key (or, in this implementation, a secret seed) is mandatory.
A typical use of STHash is to compute keys for locally cached objects.
The construction relies on:
- a composition of two ϵ-almost-∆-universal functions, NH and Poly1305. See the Adiantum paper for a justification of this composition.
- The KMAC keyed hash function, both to produce the final tag and as a XOF to derive the NH, Poly1305 and finalization keys.
The current code is portable, written in safe Rust, and has a lot of room for optimization.
However, even without vectorization, it is already consistently faster than optimized BLAKE2bp implementations (using the blake2b-simd
crate) on all platforms.
You can expect a 2x to 4x speed increase in future versions.
Usage
use *;
// This must be a random, secret seed.
let seed: = ;
// The key constructor accepts an optional application name
// Different personalization strings produce different keys
// from the same `seed`.
let key = from_seed;
// Another personalization string, such as the purpose of the
// `Hasher`, can be provided here as well.
let hasher = new;
// Returns a 256-bit hash.
let h1 = hasher.hash;
// `Hasher` structures can safely be reused to hash more data.
let h2 = hasher.hash;