Documentation
¶
Overview ¶
Package hashprf builds keyed pseudo-random functions over six hash-based ITB registry primitives, exposing each as a fixed-output-width PRF.
The six primitives split into two families:
- Areion family ("areion256", "areion512") — keyed via the ITB registry HashFunc factories (hashes.Areion256PairWithKey / hashes.Areion512PairWithKey). The PRF hashes the input under a zero seed and serialises the resulting uint64 words little-endian.
- BLAKE family ("blake2b256", "blake2s", "blake3", "blake2b512") — keyed via the upstream keyed-hash mode. The PRF output is the leading blockSize bytes of the keyed digest over the input.
The Areion family additionally exposes a 4-wide batched PRF via NewBatch: it hashes four inputs in one SIMD batch (bit-exact with the single-input PRF), which the ctr keystream uses to amortise per-block dispatch. The BLAKE family has no batch path, and NewBatch reports none for those names.
The package is a shared dependency of the ctr and kdf packages, which import it for their keyed-PRF and SP 800-108 counter-mode constructions respectively. It imports the BLAKE upstream packages and the ITB hashes package; it does not import ctr or kdf, so no import cycle arises.
Index ¶
Constants ¶
const ( Areion256 = "areion256" Areion512 = "areion512" BLAKE2b256 = "blake2b256" BLAKE2b512 = "blake2b512" BLAKE2s = "blake2s" BLAKE3 = "blake3" )
Registry names accepted by New, NewBatch, KeySize, and BlockSize.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a keyed PRF for one of the six hash-based primitives and its output block size. The key length must equal the primitive's key size; a mismatched length or an unknown name is an error.
The returned prf writes exactly blockSize bytes into dst[:blockSize], so dst must have len(dst) >= blockSize. The returned prf is not safe for concurrent use; it reuses internal hasher state and is intended for serial, single-stream use.
func NewBatch ¶
func NewBatch(name string, key []byte) (batch func(dst, in *[4][]byte), blockSize int, ok bool, err error)
NewBatch returns a 4-wide batched keyed PRF for the primitives that expose a SIMD batch path, together with the per-lane output block size. ok reports whether a batch path exists for name: only the Areion family does (via the registry BatchHashFunc factories, which are bit-exact with the single-input HashFunc), so a batched keystream over those primitives produces output byte-identical to the single-block PRF. ok is false for the BLAKE family, whose registry factories expose no 4-wide batch; callers fall back to New.
The returned batch closure fills dst[0..3] (each at least blockSize bytes) from in[0..3]. It is bound to one keystream / KDF instance and driven sequentially, like the New closures.
Types ¶
This section is empty.