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

XMSS & LMS (stateful hash-based)

XMSS and LMS are stateful hash-based signature schemes standardized by NIST in SP 800-208 (and by the IETF in RFC 8391 and RFC 8554). They offer small signatures, fast verification, and rock-solid hash-only security — but each one-time key may be used at most once, making state management mission-critical.

How it works

Both schemes build a Merkle tree of one-time signature (OTS) key pairs. The tree's root is the long-term public key; each leaf is a one-time key that signs a single message. A signature includes the OTS signature plus the authentication path proving that leaf belongs to the published root.

The decisive property is that they are stateful: every leaf index must be used at most once, and never reused. If the signer ever reuses a leaf — signing two different messages with the same one-time key — the OTS security collapses and an attacker can forge signatures. The signer must therefore reliably track and persist which indices have been consumed.

  • LMS (RFC 8554, Leighton-Micali) and its multi-tree variant HSS (Hierarchical Signature System).
  • XMSS (RFC 8391, eXtended Merkle Signature Scheme) and its multi-tree variant XMSS^MT.

Parameter sets

Parameters are governed by the underlying hash (typically SHA-256), the Winternitz parameter, and the tree height h, which fixes the total number of signatures available as 2^h. Representative figures:

SchemeHashTree height (h)Max signaturesPublic keySignature (approx.)
LMSSHA-256101024~60 B~1.5-2.7 KB
XMSSSHA-256101024~64 B~2.5 KB
XMSS^MT / HSSSHA-25620-60 (multi-tree)2^20 - 2^60~64 Blarger (multi-layer)

Higher trees allow more signatures but increase signature size and key-generation cost.

Strengths & tradeoffs

  • Hash-only security. Like SLH-DSA, security reduces to the underlying hash — extremely conservative, no lattice or coding assumptions.
  • Compact, fast verify. Signatures and keys are small and verification is cheap.
  • Tradeoff — state. The signer must never reuse a leaf. This requires durable, atomic state tracking (ideally in hardware), and limits the total number of signatures to 2^h.

When to use it

XMSS/LMS are ideal for firmware, secure boot, and software signing: a controlled signing environment, a bounded and predictable number of signatures, and hardware that can manage the state safely. NIST SP 800-208 approves them precisely for these long-lived signing roots. If you cannot guarantee single-use state, use the stateless SLH-DSA instead.

Code example

State management with the standard openssl CLI conceptually:

# NOTE: stateful LMS/XMSS are NOT available through the OpenSSL CLI.
# OpenSSL cannot generate or sign with LMS/XMSS keys (no genpkey support;
# it errors with "Error initializing LMS context"). Use a purpose-built
# implementation that safely manages the one-time-key STATE:
#   LMS/HSS : RFC 8554 reference code, Cisco "hash-sigs" library, Bouncy Castle
#   XMSS    : RFC 8391 "xmss-reference", Bouncy Castle
# Some stacks (AWS-LC, Bouncy Castle) can VERIFY LMS signatures even where they
# cannot generate them. The hard part is never the math - it is never reusing a
# one-time leaf index, which is why state management belongs in dedicated tooling/HSMs.
Warning
Reusing a one-time leaf index is catastrophic: signing two different messages with the same XMSS/LMS leaf lets an attacker forge signatures. Never copy, restore from backup, or run two instances of a stateful private key in parallel. Persist the state atomically, prefer hardware key management, and if single-use cannot be guaranteed, use stateless SLH-DSA.

Related

Standards & references

XMSS 与 LMS 有状态哈希签名

XMSS 与 LMS 是 NIST 在 SP 800-208 中标准化的有状态哈希签名方案(IETF 亦以 RFC 8391 与 RFC 8554 定义)。它们签名小巧、验证迅速、仅依赖哈希的安全性极为稳固——但每个一次性密钥最多只能使用一次,使状态管理成为成败关键。

工作原理

两种方案都构建一棵由一次性签名(OTS)密钥对组成的 Merkle 树。树根是长期公钥;每个叶子是只签名一条消息的一次性密钥。一份签名包含 OTS 签名以及证明该叶子属于已发布树根的认证路径。

决定性特性是它们有状态:每个叶子索引最多只能使用一次,且绝不能复用。一旦签名者复用某叶子——用同一一次性密钥签两条不同消息——OTS 安全性即告崩溃,攻击者便能伪造签名。因此签名者必须可靠地跟踪并持久化已消耗的索引。

  • LMS(RFC 8554,Leighton-Micali)及其多树变体 HSS(分层签名系统)。
  • XMSS(RFC 8391,扩展 Merkle 签名方案)及其多树变体 XMSS^MT

参数集

参数由底层哈希(通常 SHA-256)、Winternitz 参数与树高 h 决定,后者将可用签名总数固定为 2^h。代表性数据:

方案哈希树高 h最大签名数公钥签名(约)
LMSSHA-256101024约 60 B约 1.5-2.7 KB
XMSSSHA-256101024约 64 B约 2.5 KB
XMSS^MT / HSSSHA-25620-60(多树)2^20 - 2^60约 64 B更大(多层)

树越高可签名次数越多,但签名尺寸与密钥生成开销也随之增大。

优势与取舍

  • 仅依赖哈希。与 SLH-DSA 一样,安全性归约到底层哈希——极为保守,无格或编码假设。
  • 紧凑且验证快。签名与密钥小巧,验证成本低廉。
  • 取舍——状态。签名者绝不能复用叶子。这要求持久、原子的状态跟踪(最好由硬件完成),并将签名总数限制在 2^h。

适用场景

XMSS/LMS 非常适合固件、安全启动与软件签名:受控的签名环境、有界且可预测的签名数量、以及能安全管理状态的硬件。NIST SP 800-208 正是为这类长寿命签名根而批准它们。若无法保证单次使用,请改用无状态的 SLH-DSA

代码示例

以标准 openssl CLI 在概念上演示状态管理:

# 注意:有状态的 LMS/XMSS 无法通过 OpenSSL 命令行使用。
# OpenSSL 不能生成或用 LMS/XMSS 私钥签名(无 genpkey 支持,
# 会报 "Error initializing LMS context")。请使用能安全管理一次性密钥
# 「状态」的专用实现:
#   LMS/HSS : RFC 8554 参考实现、Cisco "hash-sigs" 库、Bouncy Castle
#   XMSS    : RFC 8391 "xmss-reference"、Bouncy Castle
# 部分实现(AWS-LC、Bouncy Castle)即便不能生成也能「验签」LMS。
# 难点从不在数学,而在于绝不重用一次性叶子索引——因此状态管理应交给专用工具/HSM。
警告
复用一次性叶子索引后果灾难性:用同一 XMSS/LMS 叶子签两条不同消息会让攻击者得以伪造签名。切勿复制、从备份还原、或并行运行两个有状态私钥实例。请原子地持久化状态、优先采用硬件密钥管理;若无法保证单次使用,请改用无状态的 SLH-DSA。

相关页面

标准与参考

⚑ Report an error⚑ 纠错与校正