QianHeng乾珩 PQC Docs Hub量子文档 ✦ Ask AI✦ 问问文档 ⚐ Scan⚐ 扫一扫

Code-Based Cryptography

Code-based cryptography is the oldest post-quantum family, dating to McEliece in 1978. Its security rests on the difficulty of decoding random linear error-correcting codes — an NP-hard problem with no known quantum shortcut. The classic scheme has survived 45+ years of attack, making it a trusted, conservative KEM choice despite very large public keys.

The Hard Problem: Syndrome Decoding

An error-correcting code adds redundancy so that a few flipped bits can be corrected. For a structured code with a known decoder this is easy; for a random-looking linear code it is hard. The underlying problem is syndrome decoding: given a parity-check matrix and a syndrome, find a low-weight error vector that produces it. The general syndrome-decoding problem is NP-hard. To date, no known classical or quantum algorithm efficiently breaks these code-based constructions at the relevant parameters.

The trick of code-based encryption is to disguise a code that the owner can decode efficiently as one that looks random to everyone else. The public key is the scrambled code; the private key is the structure that enables fast decoding.

McEliece and Goppa Codes

The original McEliece cryptosystem (1978) uses binary Goppa codes. Remarkably, it has never been broken in over four decades of cryptanalysis — an exceptional track record. The cost is size:

SchemeCode typePublic key sizeNote
Classic McElieceBinary Goppa~261 KB to ~1 MBUnbroken 45+ years; huge keys
BIKEQC-MDPCFew KBSmaller; some decoding-failure / reaction-attack concerns
HQCStructured (quasi-cyclic)Few KBClean decoding-failure analysis; selected for standardization in 2025; final FIPS standard expected ~2027 (not yet standardized)

McEliece's giant public keys make it impractical for many handshake protocols, but its conservatism makes it attractive where keys can be provisioned once and stored — and where confidence against future cryptanalysis matters most.

Structured Codes: Smaller Keys, New Risks

To make code-based KEMs practical, newer schemes use structured codes (quasi-cyclic, QC-MDPC) that compress the key dramatically:

  • BIKE — uses QC-MDPC codes for keys of just a few kilobytes. However, some QC-MDPC constructions face decoding failures that can enable reaction attacks, where an adversary learns secret information from whether decapsulation succeeds. This requires careful analysis and constant-time decoding.
  • HQC — uses structured codes but is engineered with a clean, well-quantified decoding-failure analysis, giving stronger assurance. NIST selected HQC for standardization in 2025 as a code-based KEM to diversify away from lattice-based ML-KEM.
Note
HQC's value is strategic: it provides KEM diversity. If a future advance weakened lattice schemes, a standardized code-based KEM resting on an entirely different hard problem would remain available.

Tradeoffs

  • Pro — Decades of cryptanalysis (McEliece); a hard problem unrelated to lattices.
  • Con — Very large keys (McEliece) or, for structured variants, decoding-failure risk that must be carefully bounded.
  • Use — KEMs only; no practical signatures from this family in the standards.

Standards & references

编码基密码

编码基密码是最古老的后量子家族,可追溯至 1978 年的 McEliece。其安全性建立在随机线性纠错码译码的困难性之上——这是一个 NP 难问题,且无已知量子捷径。经典方案历经四十五年以上的攻击考验,尽管公钥极大,仍是可信而保守的 KEM 选择。

困难问题 伴随式译码

纠错码加入冗余,使少量翻转的比特可被纠正。对于带已知译码器的结构化码,这很容易;对于看似随机的线性码,则很难。底层问题是伴随式译码:给定校验矩阵与伴随式,求出产生该伴随式的低重量错误向量。一般伴随式译码问题是 NP 难的。到目前为止,尚无已知经典或量子算法能够在相关参数下有效攻破这些编码基构造。

编码基加密的诀窍在于,将所有者能高效译码的码伪装成对其他所有人看似随机的码。公钥是被扰乱的码,私钥是支持快速译码的结构。

McEliece 与 Goppa 码

最初的 McEliece 密码体制(1978 年)使用二元 Goppa 码。值得注意的是,在四十余年的密码分析中它从未被攻破——堪称卓越战绩。代价在于体积:

方案码类型公钥体积说明
Classic McEliece二元 Goppa约 261 KB 至约 1 MB四十五年以上未破,密钥极大
BIKEQC-MDPC几 KB较小,存在译码失败与反应攻击隐忧
HQC结构化准循环几 KB译码失败分析清晰,2025 年入选标准化;最终 FIPS 标准预计约 2027 年(尚未标准化)

McEliece 巨大的公钥使其在许多握手协议中不实用,但在密钥可一次性配发并存储、且最看重抵御未来密码分析的场合,其保守性极具吸引力。

结构化码 更小密钥 新的风险

为使编码基 KEM 实用,较新的方案采用结构化码(如准循环 QC-MDPC)大幅压缩密钥:

  • BIKE——使用 QC-MDPC 码,密钥仅几千字节。然而某些 QC-MDPC 构造面临译码失败,可能引发反应攻击:攻击者从解封装是否成功中获取秘密信息。这需要谨慎分析与常量时间译码。
  • HQC——同样使用结构化码,但其设计带有清晰且量化良好的译码失败分析,提供更强保证。NIST 于 2025 年选定 HQC 标准化,作为编码基 KEM 以分散对格基 ML-KEM 的依赖。
注意
HQC 的价值在于战略层面——它提供 KEM 多样性。若未来进展削弱了格基方案,一个建立在完全不同困难问题上的已标准化编码基 KEM 仍可备用。

权衡

  • 优势——历经数十年密码分析,McEliece 的困难问题与格无关。
  • 劣势——McEliece 密钥极大;对结构化变体而言,须谨慎界定译码失败风险。
  • 用途——仅用于 KEM,该家族在标准中无实用签名方案。

标准与参考

⚑ Report an error⚑ 纠错与校正