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

BIKE

BIKE (Bit Flipping Key Encapsulation) is a code-based KEM built on quasi-cyclic moderate-density parity-check (QC-MDPC) codes. A NIST Round-4 candidate that was ultimately not selected, it offers small keys but carries decoding-failure and reaction-attack considerations that demand careful, constant-time implementation.

How it works

BIKE is a KEM based on decoding QC-MDPC codes. The private key is a sparse parity-check matrix; the public key is a quasi-cyclic representation derived from it. Encapsulation introduces an error pattern, and decapsulation runs an iterative bit-flipping decoder to recover it. The quasi-cyclic structure keeps keys compact compared with other code-based schemes.

The subtlety is the decoding-failure rate (DFR). Bit-flipping decoders occasionally fail, and an attacker who can observe whether decoding succeeds — and correlate that with chosen ciphertexts — can mount a reaction attack to recover the secret key over many queries. Mitigating this requires a constant-time decoder and a conservatively low, well-analyzed DFR.

Parameter sets

BIKE submitted parameters targeting NIST security categories 1, 3, and 5, but it was not selected by NIST for standardization; its public keys and ciphertexts are small (approximate bytes).

Parameter setSecurity levelPublic key (approx.)Ciphertext (approx.)
BIKE Level 1Category 1~1541~1573
BIKE Level 3Category 3~3083~3115
BIKE Level 5Category 5~5122~5154

Strengths & tradeoffs

  • Small keys. Thanks to the quasi-cyclic structure, keys and ciphertexts are far smaller than Classic McEliece — only a couple of kilobytes.
  • Code-based diversity. Like HQC, it offers an alternative to lattice assumptions.
  • Tradeoff — DFR / reaction attacks. The iterative decoder's failure behavior must be tightly controlled; a non-constant-time decoder or an underestimated DFR opens the door to key-recovery reaction attacks. BIKE was not selected by NIST, with HQC chosen as the code-based standard instead.

When to use it

For new deployments, prefer the standardized code-based KEM HQC over BIKE, since HQC was selected and has a cleaner decoding-failure analysis. BIKE remains of research and historical interest, and may appear in experimental libraries; if you must use it, deploy only an audited constant-time implementation with conservative parameters.

Code example

import oqs

# Availability depends on the liboqs build; BIKE is not a NIST standard.
kem = "BIKE-L1"
if kem in oqs.get_enabled_kem_mechanisms():
    with oqs.KeyEncapsulation(kem) as server:
        public_key = server.generate_keypair()
        with oqs.KeyEncapsulation(kem) as client:
            ct, ss_c = client.encap_secret(public_key)
        ss_s = server.decap_secret(ct)
        assert ss_c == ss_s
else:
    print("BIKE not enabled in this liboqs build")
Warning
BIKE's QC-MDPC bit-flipping decoder must run in constant time with a rigorously bounded decoding-failure rate. A variable-time decoder, or a DFR higher than analyzed, exposes the scheme to reaction attacks that recover the secret key. BIKE was not selected by NIST — prefer HQC for new code-based deployments.

Related

Standards & references

BIKE

BIKE(Bit Flipping Key Encapsulation)是一种基于编码的 KEM,建立在准循环中密度校验(QC-MDPC)码之上。它是 NIST 第四轮候选,最终未获选,密钥小巧,但存在解码失败与反应攻击方面的考量,需谨慎的恒定时间实现。

工作原理

BIKE 是一种基于解码 QC-MDPC 码KEM。私钥是一个稀疏校验矩阵;公钥是由其导出的准循环表示。封装时引入一个错误模式,解封装则运行迭代式比特翻转解码器将其还原。准循环结构使其密钥相比其他编码方案更为紧凑。

微妙之处在于解码失败率(DFR)。比特翻转解码器偶尔会失败,而能观测解码成败、并将其与选择密文关联的攻击者,可通过大量查询发起反应攻击以还原私钥。缓解之道是采用恒定时间解码器,并将 DFR 保守地压低且充分分析。

参数集

BIKE 提交过面向 NIST 安全等级 1、3、5 的参数,但未被 NIST 选中标准化;公钥与密文均小巧(近似字节)。

参数集安全等级公钥(约)密文(约)
BIKE Level 1等级 1约 1541约 1573
BIKE Level 3等级 3约 3083约 3115
BIKE Level 5等级 5约 5122约 5154

优势与取舍

  • 密钥小。得益于准循环结构,密钥与密文远小于 Classic McEliece——仅几千字节。
  • 编码类多样性。与 HQC 一样,提供格假设之外的另一选择。
  • 取舍——DFR/反应攻击。迭代解码器的失败行为必须严格受控;非恒定时间解码器或被低估的 DFR 会为还原私钥的反应攻击敞开大门。BIKE 未被 NIST 选中,编码类标准最终花落 HQC。

适用场景

对于新部署,应优先选用已标准化的编码类 KEM HQC 而非 BIKE,因为 HQC 已获选且解码失败分析更清晰。BIKE 仍具研究与历史价值,可能出现在实验性库中;若必须使用,请仅部署经审计的恒定时间实现并采用保守参数。

代码示例

import oqs

# 是否可用取决于 liboqs 构建;BIKE 并非 NIST 标准。
kem = "BIKE-L1"
if kem in oqs.get_enabled_kem_mechanisms():
    with oqs.KeyEncapsulation(kem) as server:
        public_key = server.generate_keypair()
        with oqs.KeyEncapsulation(kem) as client:
            ct, ss_c = client.encap_secret(public_key)
        ss_s = server.decap_secret(ct)
        assert ss_c == ss_s
else:
    print("当前 liboqs 构建未启用 BIKE")
警告
BIKE 的 QC-MDPC 比特翻转解码器必须恒定时间运行,且解码失败率经严格界定。变时解码器或高于分析值的 DFR 会使方案暴露于还原私钥的反应攻击之下。BIKE 未获 NIST 选中——新编码类部署请优先选用 HQC。

相关页面

标准与参考

⚑ Report an error⚑ 纠错与校正