HQC, short for Hamming Quasi-Cyclic, is a code-based key encapsulation mechanism (KEM) whose security rests on the difficulty of decoding random quasi-cyclic codes in the Hamming metric. In quantum security, it matters because NIST selected it in March 2025 as the backup KEM to ML-KEM, giving post-quantum key establishment a second foundation that does not depend on lattice mathematics.
The scheme lets two parties agree on a shared secret key over an untrusted network, which they then use for symmetric encryption. It resists every known attack by a cryptographically relevant quantum computer, because Shor’s algorithm does not apply to decoding problems and Grover’s algorithm offers only a modest square-root speedup against them.
How HQC hides a key inside a noisy codeword
HQC encrypts a random message by encoding it with a public error-correcting code and then masking the codeword with structured noise that only the key holder can remove. All arithmetic happens in the polynomial ring of binary vectors of length n, where multiplication is a cyclic convolution, which is what makes the code quasi-cyclic.
During key generation, the owner picks two secret vectors x and y with low Hamming weight, a public random vector h, and publishes s = x + h·y. Recovering x and y from h and s is an instance of the quasi-cyclic syndrome decoding problem, the core hardness assumption of HQC.
To encapsulate, the sender draws sparse vectors r1, r2 and e, computes u = r1 + h·r2 and v = mG + s·r2 + e, where mG is the encoded message. The receiver computes v − u·y, which equals mG plus a combined error x·r2 − r1·y + e. Because all these vectors are sparse, that error stays small enough for the decoder to correct it and recover m.
The steps below summarize the three algorithms of the KEM and what each one produces.
| Algorithm | Main inputs | Output |
|---|---|---|
| Key generation | Random seed, sparse x and y | Public key (h, s) and secret key |
| Encapsulation | Public key, random message m | Ciphertext (u, v) and shared secret |
| Decapsulation | Secret key, ciphertext | Shared secret or implicit rejection |
The basic public-key encryption scheme is only secure against passive attackers, so HQC wraps it in a Fujisaki-Okamoto style transform. Decapsulation re-encrypts the recovered message and compares the result with the received ciphertext, which yields IND-CCA2 security against active attackers who submit manipulated ciphertexts.
Concatenated codes and decryption failures
The public code in HQC is a concatenation of a Reed-Solomon code and a duplicated Reed-Muller code. The inner Reed-Muller code absorbs dense local errors, and the outer Reed-Solomon code corrects the symbols the inner decoder still gets wrong. The code needs no secret structure, which is a key difference from McEliece-type designs.
Decoding is probabilistic, so a ciphertext can occasionally fail to decrypt. The designers choose parameters so that the decryption failure rate (DFR) stays below roughly 2^-128 for the first level and lower at higher levels. A low, well-analyzed DFR matters because attackers can exploit observable decryption failures to learn bits of the secret key.
HQC parameter sets and key sizes
HQC is specified in three security levels that map to NIST categories 1, 3 and 5, roughly comparable to AES-128, AES-192 and AES-256. The figures below come from the round 4 submission and may change slightly in the final standard.
| Parameter set | NIST category | Public key | Ciphertext |
|---|---|---|---|
| HQC-128 | 1 | About 2,250 bytes | About 4,480 bytes |
| HQC-192 | 3 | About 4,520 bytes | About 9,030 bytes |
| HQC-256 | 5 | About 7,250 bytes | About 14,470 bytes |
The vector length grows from about 17,700 bits at level 1 to about 57,600 bits at level 5, while the secret vectors keep only a few dozen to about 130 nonzero positions. The secret key is small because it can be regenerated from a short seed.
How HQC compares with other post-quantum KEMs
HQC trades larger ciphertexts and slower operations for a security argument that is independent of lattice assumptions. The comparison below places it next to the other KEMs that practitioners usually consider.
| Scheme | Hard problem | Public key at level 1 | Status |
|---|---|---|---|
| HQC | Quasi-cyclic syndrome decoding | About 2.2 KB | Selected in 2025 as backup KEM |
| ML-KEM | Module learning with errors | 800 bytes | Primary standard, FIPS 203 |
| Classic McEliece | Decoding hidden Goppa codes | About 261 KB | Not selected by NIST, ISO track |
| BIKE | Quasi-cyclic moderate density codes | About 1.5 KB | Not selected by NIST |
Against BIKE, its closest code-based rival, HQC won largely because its decryption failure analysis is better understood and its performance is more predictable. Against Classic McEliece, HQC has far smaller public keys but rests on a younger, structured code assumption with less cryptanalytic history.
Why NIST wanted a code-based backup
NIST chose HQC as insurance against a future break of lattice cryptography. ML-KEM, ML-DSA and FN-DSA all rely on structured lattices, so a single mathematical advance could weaken all three at once; HQC gives agencies a standardized fallback built on a different problem.
NIST did not present HQC as a replacement for ML-KEM. The agency signaled that ML-KEM remains the default choice for general use, with HQC intended for systems that want algorithm diversity. A draft standard was expected about a year after selection and a final standard around 2027.
Deployment trade-offs and implementation risks
The main practical cost of HQC is bandwidth: a level 1 ciphertext of about 4.5 KB does not fit in a single packet and can enlarge TLS handshakes noticeably. Polynomial multiplication over long vectors also makes encapsulation several times slower than ML-KEM on common processors.
Real implementations have shown that side-channel resistance is the hardest part. The table lists the issues that practitioners most often review before deployment.
| Risk | Cause | Mitigation |
|---|---|---|
| Timing leakage | Variable-time decoding or sampling | Strictly constant-time code |
| Failure oracles | Observable decryption failures | Implicit rejection, analyzed DFR |
| Power analysis | Secret-dependent multiplication patterns | Masking and shuffling on embedded devices |
| Version mismatch | Pre-standard parameters in libraries | Pin versions until the final standard |
- Prefer hybrid key exchange that combines HQC or ML-KEM with X25519 during the transition.
- Treat HQC as part of crypto-agility planning, so that the KEM can be swapped through configuration.
- Record its use in the cryptographic inventory with the exact parameter set and library version.
In everyday language
HQC is a way for two computers to agree on a secret password that a future quantum computer still could not steal. One side hides the secret inside a message and sprinkles in a carefully measured amount of random noise. Only the receiver knows the trick to clean up that noise and read the secret.
Most new quantum-safe tools rely on one family of math puzzles. HQC uses a different puzzle, so it acts as a spare tire: slower and bulkier, but ready if the main tire ever fails.
Seen in the real world
A national agency that protects classified archives for decades follows a harvest now, decrypt later threat model. Its security team already runs a hybrid of X25519 and ML-KEM-768 for internal TLS traffic, but its policy requires that long-term data links do not depend on a single mathematical assumption.
For the link between two data centers, the team adds HQC-192 as a second post-quantum component and derives the session key from all three shared secrets. Handshakes grow by roughly 13 KB of extra key material, which is negligible on a dedicated fiber link. The outcome is a channel that stays confidential even if lattice cryptography is broken, with the switch managed through configuration rather than new hardware.