HQC
HQC (Hamming Quasi-Cyclic) is a code-based key-encapsulation mechanism that NIST selected on 2025-03-11 as a fourth-round selection — the fifth algorithm chosen for NIST PQC standardization overall — a code-based backup to ML-KEM, and the second KEM selected for standardization (after ML-KEM, and not finalized at the same time). It provides algorithm diversity — a backup whose security rests on coding theory rather than lattices — with moderate, practical key and ciphertext sizes. HQC has been selected for standardization, but no final FIPS standard has been published yet. Its FIPS number has not yet been assigned by NIST. A draft is projected roughly a year after selection and a final standard is expected around 2027; until then it remains a selected candidate, not a published standard.
How it works
HQC is a KEM built on the hardness of decoding in the Hamming metric using quasi-cyclic codes. Encapsulation adds a structured error to a codeword; recovering the message requires decoding that error, which is hard without the secret. HQC pairs an outer error-correcting code (for reliable decoding) with the quasi-cyclic structure (for compact keys), and applies a transform to reach IND-CCA2 security.
A key engineering advantage of HQC over some other code-based schemes is its clean, analyzable decoding-failure rate (DFR): the probability that decapsulation fails can be bounded tightly and made negligibly small, which simplifies security analysis and constant-time implementation.
Parameter sets
Three parameter sets target NIST categories 1, 3, and 5. Approximate sizes in bytes for the category-1 set are shown; higher levels scale up.
| Parameter set | Security level | Public key (approx.) | Ciphertext (approx.) | Shared secret |
|---|---|---|---|---|
| HQC-128 | Category 1 | 2249 | 4433 | 64 |
| HQC-192 | Category 3 | ~4522 | ~8978 | 64 |
| HQC-256 | Category 5 | ~7245 | ~14421 | 64 |
These are larger than ML-KEM but far more practical than Classic McEliece's hundred-kilobyte keys. The 64-byte shared secret in the table is the round-4 specification value; defer to the final NIST standard draft, as the final standard may adjust it slightly.
Strengths & tradeoffs
- Algorithm diversity. Code-based security gives a hedge against any future break of lattice assumptions, making HQC a natural backup or hybrid partner for ML-KEM.
- Clean DFR. The decoding-failure rate is well understood and easy to bound, which aids robust, constant-time implementations.
- Tradeoff: public keys and ciphertexts are noticeably larger than ML-KEM's, and performance is slower. It is a backup, not a wholesale replacement for ML-KEM.
When to use it
Use HQC when you want defense-in-depth against a lattice break: as the second component of a hybrid alongside ML-KEM, or as a primary KEM in environments that mandate non-lattice cryptography. For most performance-sensitive deployments where a single algorithm suffices, ML-KEM remains the default.
Code example
When using HQC as a backup or hybrid component, size your buffers, KDF inputs, and protocol fields according to the lengths exposed by the specific specification or library.
HQC-* was temporarily disabled in some recent builds pending a specification update, and mechanism strings can change between releases. Before running, confirm the exact name with oqs.get_enabled_kem_mechanisms().import oqs
kem = "HQC-128"
with oqs.KeyEncapsulation(kem) as server:
public_key = server.generate_keypair()
print("public key bytes:", len(public_key)) # ~2249
with oqs.KeyEncapsulation(kem) as client:
ciphertext, ss_c = client.encap_secret(public_key)
print("ciphertext bytes:", len(ciphertext)) # ~4433
ss_s = server.decap_secret(ciphertext)
assert ss_c == ss_s
Related
Code-based cryptography →
Quasi-cyclic codes and decoding.
ML-KEM →
The primary lattice KEM standard.
BIKE →
A related QC-MDPC code-based KEM.
Hybrid key exchange →
Combining HQC with ML-KEM.
Standards & references
- HQC project — official specification, reference code, and parameter sets.
- NIST PQC project — HQC selected for standardization as an additional KEM.
- Resources — full standards register
HQC
HQC(Hamming Quasi-Cyclic)是一种基于编码的密钥封装机制。NIST 于 2025-03-11 将其选定,属于第四轮遴选结果——从整体标准化算法数量看是 NIST 选定的第五个后量子算法,作为 ML-KEM 的编码类备份方案,也是继 ML-KEM 之后第二个进入标准化的 KEM(二者并非同时定稿)。它提供算法多样性——一个安全性建立在编码理论而非格上的备份方案——同时密钥与密文尺寸适中、可用性良好。HQC 已被选定用于标准化,尚未发布最终 FIPS 标准。其 FIPS 编号尚未由 NIST 正式公布。草案约在入选后一年发布、终稿约 2027 年;在此之前,它仍是已选定的候选,而非已发布的标准。
工作原理
HQC 是一种 KEM,建立在汉明度量下使用准循环(quasi-cyclic)码的解码困难性之上。封装时向码字叠加一个结构化错误;还原消息需解出该错误,而无私钥时这一过程很难完成。HQC 将一个外层纠错码(保证可靠解码)与准循环结构(保证密钥紧凑)结合,并施加变换以达到 IND-CCA2 安全。
相较某些其他编码方案,HQC 的一大工程优势是解码失败率(DFR)清晰可分析:解封装失败的概率可被严格界定并压到可忽略的水平,这既简化了安全分析,也便于恒定时间实现。
参数集
三组参数对应 NIST 等级 1、3、5。下表给出等级 1 的近似字节尺寸,更高等级按比例增大。
| 参数集 | 安全等级 | 公钥(约) | 密文(约) | 共享密钥 |
|---|---|---|---|---|
| HQC-128 | 等级 1 | 2249 | 4433 | 64 |
| HQC-192 | 等级 3 | 约 4522 | 约 8978 | 64 |
| HQC-256 | 等级 5 | 约 7245 | 约 14421 | 64 |
这些尺寸大于 ML-KEM,但远比 Classic McEliece 的数百 KB 公钥实用。表中 64 字节的共享密钥为第四轮规范取值,以最终 NIST 标准草案为准,最终标准可能微调。
优势与取舍
- 算法多样性。编码类安全性可对冲格假设未来被攻破的风险,使 HQC 成为 ML-KEM 天然的备份或混合搭档。
- DFR 清晰。解码失败率易于理解与界定,有助于实现稳健的恒定时间代码。
- 取舍:公钥与密文明显大于 ML-KEM,性能也更慢。它是备份,而非对 ML-KEM 的全面替代。
适用场景
当你需要针对格被攻破的纵深防御时选用 HQC:作为与 ML-KEM 并行的混合方案第二组件,或在强制使用非格密码的环境中作为主 KEM。对于单一算法即可满足、且性能敏感的多数部署,ML-KEM 仍是默认。
代码示例
把 HQC 作为备份或混合组件时,缓冲区、KDF 输入和协议字段应以具体规范/库暴露的长度为准。
HQC-* 在部分较新构建中因规范更新被暂时下线;运行前请用 oqs.get_enabled_kem_mechanisms() 确认环境中确切的算法名称。import oqs
kem = "HQC-128"
with oqs.KeyEncapsulation(kem) as server:
public_key = server.generate_keypair()
print("公钥字节:", len(public_key)) # 约 2249
with oqs.KeyEncapsulation(kem) as client:
ciphertext, ss_c = client.encap_secret(public_key)
print("密文字节:", len(ciphertext)) # 约 4433
ss_s = server.decap_secret(ciphertext)
assert ss_c == ss_s
相关页面
标准与参考
- HQC 项目 — 官方规范 参考代码与参数集。
- NIST PQC 项目 — HQC 入选为标准化的第二个 KEM。
- 资源链接 — 完整标准登记册