Skip to Content
oxcrypto

HQC

Code-based KEM selected by NIST in 2025.

from oxcrypto.kem.hqc_kem import HQC

private_key = HQC.HQC_128.generate()
ciphertext, shared_secret = private_key.public_key().encapsulate()
assert private_key.decapsulate(ciphertext) == shared_secret
VariantPrivate keyPublic keyCiphertextShared secret
HQC_12832 bytes2241 bytes4433 bytes32 bytes
HQC_19232 bytes4514 bytes8978 bytes32 bytes
HQC_25632 bytes7237 bytes14421 bytes32 bytes

Private keys serialize as the 32-byte seed_kem, which is the last 32 bytes of the reference implementation's secret key.

Warning

Experimental. NIST selected HQC for standardization in March 2025; the FIPS draft is not yet published, and the parameters may change.

  • Crate: RustCrypto hqc-kem 0.1.0-rc.0, pre-release, no published audit. Builds with Rust 1.88.
  • Vectors: HQC reference implementation KATs hqc-1.rsp, hqc-3.rsp and hqc-5.rsp (count 0), from RustCrypto/KEMs hqc-kem/kat.

Zeroization

Retained state: the full secret key (PKE secret, sigma, seed_kem). The upstream DecapsulationKey wipes it on drop and the upstream key generation wipes its seed intermediates.

Short-lived copies not wiped by the upstream crate: the 32-byte private seed copies the kem trait adapter makes in generate and load_private_key, decapsulation intermediates, and the shared-secret array the adapter returns before oxcrypto copies it into a wiped buffer.

oxcrypto enables the zeroize features of sha3 and shake, so the upstream SHA-3 and SHAKE states are wiped on drop.

On this page