Skip to main content

Crate hash_fast

Crate hash_fast 

Source
Expand description

Fast non-cryptographic hashing: the estate’s canonical map hash.

FxHash-family multiply-xor accumulation over 8-byte chunks, with two correctness features the family usually skips (both found by this crate’s own property suite, see git history):

  • Streaming-correct: values are buffered through an 8-byte tail and flushed on chunk boundaries, so write(a); write(b) produces exactly the same state as one write(a ++ b) - for every split. Hashing a struct’s fields piecewise (the Hasher contract) is therefore equivalent to hashing the serialized whole.
  • Finalized: finish applies a splitmix-style mix so the avalanche ratio lands near 50% (the raw recurrence measured 0.387 - below the kit’s [0.40, 0.60] window).

Two surfaces:

  • FastHasher: a core::hash::Hasher implementation, drop-in for HashMap<K, V, FastHashBuilder>.
  • hash64: the one-shot byte-slice hash, for non-Hash inputs and for cross-referencing stored hashes. Stable across versions and processes (documented contract; FastHasher’s raw state is NOT stability-claimed).

Non-cryptographic by design: no collision-resistance claims; security-adjacent uses belong to the keyed-crypto domain.

Hot path contract: no panics, no allocation, no syscalls, no_std.

Modules§

oracle
The forever-oracle: an independent byte-assembly formulation of the hash, differential-tested against the optimized forms. Never optimized, never deleted (kit AGENTS.md). Naive reference forms: the forever-oracle. An independent byte-assembly formulation of the same recurrence (bytes assembled into a chunk through a shift-or loop instead of from_le_bytes), plus the streaming-equivalence reference. Do not optimize this module; do not delete it.

Structs§

FastHashBuilder
The builder for HashMap<K, V, FastHashBuilder> (the BuildHasher contract).
FastHasher
The FxHash-family hasher: a core::hash::Hasher for HashMap<K, V, FastHashBuilder> and direct byte hashing.

Functions§

hash64
The standalone byte-slice hash: one-shot, stable across versions and processes. This is the contract that differs from FastHasher’s raw state, whose finalization constants may change on a version bump (map ordering is not a persisted contract).