Documentation

CslibFrontier.Crypto.Primitives.SLHDSA.HashCalls

Addressed SLH-DSA hash calls #

This module implements the four FIPS 205 hash calls whose inputs are separated by an address: PRF, F, H, and T_l. The SHAKE parameter sets use the canonical 32-byte address and SHAKE256. The SHA2 parameter sets use the compressed 22-byte address and the precise SHA-256 or SHA-512 branch prescribed for each call and security-element length.

The low-level calls accept every typed Address, as the signatures in Section 4.1 do. SHA2 applies the standard's total compressed-address projection; protocol call sites are responsible for setting the address type and keeping the retained layer and tree fields in their standardized ranges.

Inputs encode the source arities in their types: F and PRF consume one n-byte payload, H consumes two consecutive n-byte blocks, and T_l consumes exactly l * n bytes. All outputs are exactly n bytes. The hash calls use the total SHA2 functions, while ValidTInput separately records the standard's SHA-2 input domain; validTInput_of_blocks_le_67 proves that fact for every standardized WOTS+ or FORS call.

This is executable hash plumbing, not a constant-time or machine-costed implementation, a NIST validation, a security proof, or an asymptotic parameter family. It does not define H_msg, PRF_msg, WOTS+, XMSS, FORS, the hypertree, signing, or verification.

Main definitions #

Main results #

References #

The two concrete hash families used by the FIPS 205 parameter sets.

Instances For
    @[reducible, inline]

    One n-byte SLH-DSA security element.

    @[reducible, inline]

    Two consecutive n-byte blocks, the input shape of H.

    @[reducible, inline]

    Exactly l consecutive n-byte blocks, the input shape of T_l.

    def Cslib.Crypto.SLHDSA.shakeInput {p : SecurityBytes} {m : ℕ} (publicSeed : NBytes p) (address : Address) (message : FixedBytes m) :

    The exact SHAKE input PK.seed || ADRS || X, using the canonical 32-byte address.

    @[simp]
    theorem Cslib.Crypto.SLHDSA.length_shakeInput {p : SecurityBytes} {m : ℕ} (publicSeed : NBytes p) (address : Address) (message : FixedBytes m) :
    (shakeInput publicSeed address message).length = p.count + 32 + m

    SHAKE call packaging has n + 32 + m bytes.

    def Cslib.Crypto.SLHDSA.sha256Input {p : SecurityBytes} {m : ℕ} (publicSeed : NBytes p) (address : Address) (message : FixedBytes m) :

    The exact SHA-256 input PK.seed || toByte(0, 64 - n) || ADRS^c || X.

    @[simp]
    theorem Cslib.Crypto.SLHDSA.length_sha256Input {p : SecurityBytes} {m : ℕ} (publicSeed : NBytes p) (address : Address) (message : FixedBytes m) :
    (sha256Input publicSeed address message).length = 64 + 22 + m

    SHA-256 call packaging has 64 + 22 + m bytes.

    def Cslib.Crypto.SLHDSA.sha512Input {p : SecurityBytes} {m : ℕ} (publicSeed : NBytes p) (address : Address) (message : FixedBytes m) :

    The exact SHA-512 input PK.seed || toByte(0, 128 - n) || ADRS^c || X.

    @[simp]
    theorem Cslib.Crypto.SLHDSA.length_sha512Input {p : SecurityBytes} {m : ℕ} (publicSeed : NBytes p) (address : Address) (message : FixedBytes m) :
    (sha512Input publicSeed address message).length = 128 + 22 + m

    SHA-512 call packaging has 128 + 22 + m bytes.

    def Cslib.Crypto.SLHDSA.prf (family : HashFamily) {p : SecurityBytes} (publicSeed secretSeed : NBytes p) (address : Address) :

    FIPS 205 PRF(PK.seed, SK.seed, ADRS) from Sections 11.1--11.2.2.

    def Cslib.Crypto.SLHDSA.f (family : HashFamily) {p : SecurityBytes} (publicSeed : NBytes p) (address : Address) (message : NBytes p) :

    FIPS 205 F(PK.seed, ADRS, M_1) from Sections 11.1--11.2.2.

    def Cslib.Crypto.SLHDSA.ValidTInput (family : HashFamily) {p : SecurityBytes} {l : ℕ} (publicSeed : NBytes p) (address : Address) (message : LBlocksBytes p l) :

    The standard's source-domain predicate for an arbitrary T_l call.

    SHAKE256 accepts every finite byte string. For SHA2, this is exactly the input predicate of the SHA-256 or SHA-512 branch selected by FIPS 205. The executable hash functions are total outside this domain; this predicate records that a call is within the source domain rather than imposing a runtime precondition.

    Instances For
      @[instance_reducible]
      instance Cslib.Crypto.SLHDSA.instDecidableValidTInput (family : HashFamily) {p : SecurityBytes} {l : ℕ} (publicSeed : NBytes p) (address : Address) (message : LBlocksBytes p l) :
      Decidable (ValidTInput family publicSeed address message)
      theorem Cslib.Crypto.SLHDSA.validTInput_of_blocks_le_67 (family : HashFamily) {p : SecurityBytes} {l : ℕ} (publicSeed : NBytes p) (address : Address) (message : LBlocksBytes p l) (hl : l ≤ 67) :
      ValidTInput family publicSeed address message

      Every block count used by a standardized WOTS+ or FORS call is inside the SHA2 source domain.

      The largest WOTS+ value is len = 67, while every standardized FORS value has k ≤ 35.

      def Cslib.Crypto.SLHDSA.tL (family : HashFamily) {p : SecurityBytes} (l : ℕ) (publicSeed : NBytes p) (address : Address) (message : LBlocksBytes p l) :

      FIPS 205 T_l(PK.seed, ADRS, M_l) from Sections 11.1--11.2.2, extended totally through the total SHA2 functions. ValidTInput separately records the standard's source domain.

      def Cslib.Crypto.SLHDSA.h (family : HashFamily) {p : SecurityBytes} (publicSeed : NBytes p) (address : Address) (message : TwoNBytes p) :

      FIPS 205 H(PK.seed, ADRS, M_2) from Sections 11.1--11.2.2.