Documentation

CslibFrontier.Crypto.Primitives.HQC.SeedExpansion

HQC PKE seed expansion #

HQC version 5.1 instantiates I(str) as SHA3-512(str || 0x02) in Table 3 (p. 15). HQC-PKE.Keygen, line 1 (p. 38), splits the 64-byte result into the 32-byte decryption-key and encryption-key seeds. The two seeds initialize separate SHAKE256 contexts in lines 2--9.

pkeSeedPrefixes gives a one-shot view of requested prefixes of those two SHAKE256 streams. It does not claim an incremental-context cost, does not formalize SampleFixedWeightVect$, and does not claim that rejection sampling terminates. Both requested prefix lengths are unary, so the uniform efficiency theorem charges every output byte and required permutation block.

Main definitions #

Main results #

References #

def Cslib.Crypto.HQC.pkeSeedDigest (seed : List (Fin 256)) :
List (Fin 256)

HQC-PKE's domain-separated hash I, before its two 32-byte halves are assigned to the decryption-key and encryption-key seed streams.

The input is a 32-byte seed in the standardized parameter sets; the executable function remains total on every byte string, which is useful for its uniform machine certificate.

HQC-PKE's I expansion always emits 64 bytes.

def Cslib.Crypto.HQC.pkeSeeds (seed : List (Fin 256)) :
List (Fin 256) × List (Fin 256)

Split HQC-PKE's hash I into its 32-byte decryption-key and encryption-key seeds.

theorem Cslib.Crypto.HQC.lengths_pkeSeeds (seed : List (Fin 256)) :
(pkeSeeds seed).1.length = 32 ∧ (pkeSeeds seed).2.length = 32

Both outputs of HQC's I expansion are exactly 32 bytes.

@[reducible, inline]

The input to pkeSeedPrefixes: seed bytes, then unary decryption- and encryption-seed prefix lengths, in that order.

Requested one-shot prefixes of the SHAKE256 streams initialized from HQC-PKE's two seeds.

The first requested length belongs to the decryption-key stream and the second to the encryption-key stream. This function recomputes each requested prefix from its seed.

The two one-shot seed streams return exactly their requested numbers of bytes.

The two requested one-shot SHAKE256 seed prefixes are uniformly polynomial-time in the framed seed and the two unary output lengths.