SLH-DSA message hash and pseudorandom function calls #
This module implements the two FIPS 205 hash calls that process an arbitrary-length message:
PRF_msg and H_msg. The inputs retain the exact n-byte seed, root, randomizer, and optional
randomness boundaries. The output of H_msg uses the six Table 2 digest lengths derived in
ParameterShape.digestBytes.
The SHAKE parameter sets use the specified direct SHAKE256 packages. The SHA2 category 1 sets
use HMAC-SHA-256 and SHA-256 followed by MGF1-SHA-256; categories 3 and 5 use the corresponding
SHA-512 functions. prfMessage and hMessage are total functions. FIPS 180-4 defines SHA-2 only
below a message-length limit, and the docstring of each call states the resulting bound on M.
These two calls do not choose the optional randomness and cannot abort.
This module is definitions only: its theorems are the length equations of the byte packages. It
supplies no counts of hash, compression or permutation calls and no machine, program-size, gate,
qubit or query costs (#4987). It does not prove PRF or ITSR security, correctness of digest
slicing, signing or verification, constant-time behavior, FIPS validation, or an EUF-CMA/QROM
reduction. The test module CslibFrontierTests.Crypto.SLHDSAMessageCalls evaluates both calls
against values computed outside Lean.
Main definitions #
Cslib.Crypto.SLHDSA.prfMessage,hMessage: the exact FIPS 205 calls.
References #
- NIST, Stateless Hash-Based Digital Signature Standard, Section 4.1, Section 9, Table 2, Algorithm 19, and Sections 11.1--11.2.2
- A. Hülsing and M. Kudinov, Recovering the Tight Security Proof of SPHINCS+, Theorem 3 and Equations (5)--(6), cited for the security properties the SPHINCS+ proof requires of these two calls; no declaration here states or proves them.
One standardized m-byte message digest.
The HMAC text opt_rand || M used by the SHA2 PRF_msg calls.
The SHAKE input SK.prf || opt_rand || M used by PRF_msg.
The common H_msg digest input R || PK.seed || PK.root || M.
The SHA2 MGF1 seed R || PK.seed || D, where D is the inner SHA-2 digest.
FIPS 205 PRF_msg(SK.prf, opt_rand, M) from Sections 11.1--11.2.2.
The SHAKE branch is the FIPS 205 value for every message. In the SHA2 branch the inner HMAC hash
reads one padded key block followed by opt_rand ‖ M, and FIPS 180-4 defines SHA-256 only below
2 ^ 61 input bytes and SHA-512 only below 2 ^ 125. The SHA2 branch is therefore the FIPS 205
value when 64 + n + |M| < 2 ^ 61 at n = 16 and when 128 + n + |M| < 2 ^ 125 at
n = 24, 32. For a longer message the standards define no value, and this function returns what
the total evaluators HMAC.hmacSHA256 and HMAC.hmacSHA512 return.
FIPS 205 H_msg(R, PK.seed, PK.root, M) from Sections 11.1--11.2.2.
The SHAKE branch is the FIPS 205 value for every message. In the SHA2 branch the inner digest
hashes R ‖ PK.seed ‖ PK.root ‖ M, and FIPS 180-4 defines SHA-256 only below 2 ^ 61 input bytes
and SHA-512 only below 2 ^ 125. The SHA2 branch is therefore the FIPS 205 value when
3 * n + |M| < 2 ^ 61 at n = 16 and when 3 * n + |M| < 2 ^ 125 at n = 24, 32. For a longer
message the standards define no value, and this function returns what the total evaluators
SHA2.sha256 and SHA2.sha512 return. The MGF1 step adds no condition: its seed has the fixed
length 2 * n + 32 or 2 * n + 64 and its output has at most 49 bytes.