An introduction to HACSpec, its type system, and its application in building transparent, verifiable post-quantum cryptographic standards.
Cryptographic standards written in mathematical pseudocode often contain ambiguities that lead to incompatible or vulnerable software implementations. HACSpec provides a domain-specific language embedded in Rust that reads like algorithmic pseudocode but executes as formal, verifiable code.
HACSpec specifications can be automatically compiled into verification languages such as Coq, F*, and EasyCrypt. This enables cryptographers to verify security proofs directly against the exact code that forms the basis of production libraries.
We review the formal HACSpec implementation of ML-KEM, highlighting how type constraints enforce polynomial degree limits, coefficient modulus ranges, and constant-time execution guarantees across the entire lifecycle.