# 哈希链

哈希链是一串通过对初始秘密反复应用密码学哈希函数而构造出的值序列，其中每一个值都承诺了下一个值，因而任何靠后的值都可以对照靠前的值进行验证。这种单向阶梯解决了一个具体问题：一方如何在一段时间内对一连串消息或口令进行认证，同时只存储和揭示那些对于伪造尚未出现的值毫无用处的值。哈希链是一次性口令方案、一次性签名与基于哈希的签名，以及广播消息认证的基础。<sup>[1](https://lamport.azurewebsites.net/pubs/password.pdf)</sup><sup> • </sup><sup>[2](https://www.cryptoplexity.informatik.tu-darmstadt.de/media/crypt/publications_1/fischlinhashchain2004.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 构造 | 对于种子 \( x_{0} \)，由 \( x_{i} = h(x_{i-1}) \) 构成的值链，其中 \( h \) 是抗碰撞的哈希函数或另一种公开可计算的单向函数<sup>[2](https://www.cryptoplexity.informatik.tu-darmstadt.de/media/crypt/publications_1/fischlinhashchain2004.pdf)</sup> |
| 承诺 | 所有者公布末端值 \( x_{n} \) 并逐步释放原像；接收方通过重新计算链条直至 \( x_{n} \) 来验证<sup>[2](https://www.cryptoplexity.informatik.tu-darmstadt.de/media/crypt/publications_1/fischlinhashchain2004.pdf)</sup> |
| 验证成本 | 检查位置 \( i \) 处的值通常需要 \( i \) 次哈希求值<sup>[2](https://www.cryptoplexity.informatik.tu-darmstadt.de/media/crypt/publications_1/fischlinhashchain2004.pdf)</sup> |
| S/KEY 口令长度 | 每个一次性口令 64 位<sup>[3](http://ftp.funet.fi/rfc/rfc1760.txt.pdf)</sup> |
| 存储高效的遍历 | 访问 \( N \) 元链中某个元素需要 \( O(\log N) \) 存储和 \( O(\log N) \) 计算<sup>[4](https://netsec.ethz.ch/publications/papers/ndss03.pdf)</sup> |
| 经典弱点 | 口令在下一轮之前始终有效，且对同一单向函数反复迭代比单次迭代更弱<sup>[5](https://tosc.iacr.org/index.php/ToSC/article/download/11955/11822/13556)</sup> |
| 后量子标准 | FIPS 205 规定了 SLH-DSA，这是一种基于 SPHINCS+ 的无状态基于哈希的签名，其安全性依赖于寻找哈希原像的困难性<sup>[6](https://csrc.nist.gov/pubs/fips/205/final)</sup> |

## 工作原理

哈希链的安全性来自哈希函数的原像抗性（单向性）。<sup>[7](https://www.cise.ufl.edu/~traynor/papers/traynor-atc10.pdf)</sup> 链是一串哈希值，对于种子 \( x_{0} \) 满足 \( x_{i} = h(x_{i-1}) \)。<sup>[2](https://www.cryptoplexity.informatik.tu-darmstadt.de/media/crypt/publications_1/fischlinhashchain2004.pdf)</sup> 种子的所有者公布末端值 \( x_{n} \)，然后按相反顺序释放原像，即 \( x_{n-1}, x_{n-2}, \dots \)。在第 \( i \) 步揭示 \( x_{n-i} \) 并不能帮助对手找到更早的值，因为那将需要求逆哈希函数。<sup>[2](https://www.cryptoplexity.informatik.tu-darmstadt.de/media/crypt/publications_1/fischlinhashchain2004.pdf)</sup>

验证向前运行，生成向后运行。任何人都可以通过取一个较早释放的值 \( v_{i} \) 并检查 \( h^{j-i}(v_{j}) = v_{i} \) 来认证值 \( v_{j} \) 属于该链；给定最新释放的值 \( v_{i} \)，对手无法找到满足该等式的更靠后的值 \( v_{j} \)。<sup>[4](https://netsec.ethz.ch/publications/papers/ndss03.pdf)</sup> 同样的检查通过 \( h^{i}(s_{i}) = s_{0} \) 将链元素 \( s_{i} \) 与承诺 \( s_{0} \) 绑定起来。<sup>[8](https://people.eecs.berkeley.edu/~tygar/papers/TESLA_broadcast_authentication_protocol.pdf)</sup>

## 具体做法

实践者遵循一个简短的步骤序列，经典的口令认证协议及其 S/KEY 标准化可以说明这一点。

1. **选择哈希函数和链长。** 在兰波特（Lamport）方案中，对于固定字 \( x \) 和[单向函数](https://www.edgepedia.org/zh/one-way-function) \( F \)，第 \( i \) 个口令是 \( x_{i} = F^{1000-i}(x) \)，因此链有 1000 个环节；系统最初存储 \( y_{1} = F^{1000}(x) \)。<sup>[1](https://lamport.azurewebsites.net/pubs/password.pdf)</sup>
2. **承诺。** 服务器持有当前链值；在经典的轮次结构中，在认证轮 \( k \)，客户端发送 \( x_{k} = F^{1000-k}(x) \)，这与定义 \( x_{i} = F^{1000-i}(x) \) 一致。<sup>[5](https://tosc.iacr.org/index.php/ToSC/article/download/11955/11822/13556)</sup>
3. **验证并更新。** 服务器通过 \( h \) 检查收到的值是先前存储值的原像，然后存储新值。在 S/KEY 中，主机通过一次安全哈希函数运算并与前一个一次性口令比较来进行验证；每次使用都会将哈希应用次数减少一。<sup>[3](http://ftp.funet.fi/rfc/rfc1760.txt.pdf)</sup> S/KEY 口令长度为 64 位。<sup>[3](http://ftp.funet.fi/rfc/rfc1760.txt.pdf)</sup>
4. **处理失步。** 如果用户发送 \( x_{j} \) 而系统对照不同的索引进行检查，则通过对两个值反复应用 \( F \) 直到找到匹配来检测不一致，这也能应对系统崩溃的情况。<sup>[1](https://lamport.azurewebsites.net/pubs/password.pdf)</sup>

验证成本随位置增长：检查位置 \( i \) 处的值需要 \( i \) 次哈希求值。在存储方面，各种构造以 \( O(\log N) \) 存储和 \( O(\log N) \) 计算来访问 \( N \) 元链中的某个元素。<sup>[4](https://netsec.ethz.ch/publications/papers/ndss03.pdf)</sup>

## 起源

该构造的一次性口令形式由[莱斯利·兰波特](https://www.edgepedia.org/zh/leslie-lamport)（Leslie Lamport）于 1981 年在《ACM 通讯》发表的《不安全通信中的口令认证》一文中提出。<sup>[9](https://doi.org/10.1145/358790.358797)</sup> 在该论文中，每个用户口令都是系统认证下一个口令所需的值，因此记录了过往口令的窃听者若想计算出下一个口令，就会与 \( F \) 的单向性相矛盾。<sup>[9](https://doi.org/10.1145/358790.358797)</sup> S/KEY 一次性认证标准规定于 RFC 1760。<sup>[3](http://ftp.funet.fi/rfc/rfc1760.txt.pdf)</sup>

## 变体

若干有名称的构造将链式思想适配到不同场景。

- **S/KEY。** RFC 1760 的一次性口令系统对秘密多次应用安全哈希函数，每次使用将计数减一。<sup>[3](http://ftp.funet.fi/rfc/rfc1760.txt.pdf)</sup>
- **TESLA。** TESLA 利用松散同步的时间和单向密钥链来认证组播和广播数据包，每个时间区间（比如一秒）使用链中的一个密钥作为该区间内各数据包的 MAC 密钥；发送方仅在区间结束后才披露每个密钥，因此时间提供了不对称性。<sup>[10](https://datatracker.ietf.org/doc/html/rfc4082)</sup> 该协议由阿德里安·佩里格（Adrian Perrig）及其同事于 2001 年报告。<sup>[8](https://people.eecs.berkeley.edu/~tygar/papers/TESLA_broadcast_authentication_protocol.pdf)</sup>
- **哈希树。** 哈希树将长链压缩为树结构，使从任意值到已公布根的路径缩短为对数长度，但验证需要对数数量的内部节点作为证明，牺牲了链的低通信复杂度和结构简单性。<sup>[2](https://www.cryptoplexity.informatik.tu-darmstadt.de/media/crypt/publications_1/fischlinhashchain2004.pdf)</sup>
- **温特尼茨链与 W-OTS+。** 所有 W-OTS 变体都使用若干从随机输入（私钥）开始的函数链，公钥是链的最终输出；签名将消息映射到每条链的一个中间值。W-OTS+ 相对于先前的 W-OTS 变体减小了签名大小，允许在签名大小和运行时间之间进行权衡，并在标准模型下，在给定第二原像抗性、不可检测性和单向性的条件下，被证明在自适应选择消息攻击下具有强不可伪造性。<sup>[11](https://eprint.iacr.org/2017/965.pdf)</sup> RFC 8554《莱顿-米卡利基于哈希的签名》（2019-04-29 发布）规定了莱顿-米卡利签名（LMS）系统——一种建立在兰波特、迪菲、温特尼茨和默克尔之上并由莱顿和米卡利改编的默克尔树变体方案——以及建立在其上的 HSS 分层签名系统。<sup>[12](https://datatracker.ietf.org/doc/html/draft-mcgrew-hash-sigs-02)</sup>
- **T/Key。** T/Key 是一种基于哈希链的基于时间的一次性口令方案，由德米特里·科根（Dmitry Kogan）、内森·马诺哈（Nathan Manohar）和[丹·博内](https://www.edgepedia.org/zh/dan-boneh)（Dan Boneh）于 2017 年报告。<sup>[13](https://doi.org/10.48550/arxiv.1708.08424)</sup> T/Key 在迭代哈希求值中包含时间戳并使用域分离。<sup>[5](https://tosc.iacr.org/index.php/ToSC/article/download/11955/11822/13556)</sup>

## 应用

除了一次性口令，哈希链还作为数字现金、延长数字证书寿命、一次性签名、认证链路状态路由更新以及高效数据包认证的构建模块。<sup>[14](https://netsec.ethz.ch/publications/papers/light4.pdf)</sup> TESLA 式的延迟密钥披露被用于传感器网络广播认证和自组网路由协议，而用延迟披露认证链路状态路由更新的技术也被独立发现。<sup>[8](https://people.eecs.berkeley.edu/~tygar/papers/TESLA_broadcast_authentication_protocol.pdf)</sup>

## 局限与替代方案

经典的兰波特式构造有两个有据可查的弱点：口令无限期有效，至少到下一认证轮之前；且对同一单向函数的反复迭代使其比单次迭代更弱。<sup>[5](https://tosc.iacr.org/index.php/ToSC/article/download/11955/11822/13556)</sup> 链也是有限的，在资源受限的环境（如小型移动设备和传感器网络）中，长单向链的建立、遍历、验证和存储是一项重大挑战。<sup>[14](https://netsec.ethz.ch/publications/papers/light4.pdf)</sup> 为避免链耗尽，人们设计了多级哈希链和自更新哈希链，一旦旧链被消耗就建立新链。<sup>[15](https://onlinelibrary.wiley.com/doi/10.1155/2020/8888679)</sup>

与基于 HMAC 的一次性口令相比，基于 HOTP 的方案需要将共享密钥 \( k \) 存储在服务器上，使其暴露于服务器端攻击，TOTP 继承了这一弱点；TOTP 用基于时间戳的计数器替代 HOTP 的共享计数器，计算 \( T = \lfloor (t - t_{0})/I \rfloor \) 和 \( \mathrm{HMAC}(k, T) \)，典型时间槽大小 \( I \) 为 30 秒。<sup>[16](https://arxiv.org/pdf/1708.08424v1.pdf)</sup> 相比之下，T/Key 不依赖共享密钥。<sup>[17](https://acmccs.github.io/papers/p983-koganA.pdf)</sup>

基于哈希的签名因后量子安全性而重新受到关注，因为一次性签名系统及由其构建的通用签名系统具有小的公钥和私钥以及快速的签名和验证，但签名大且密钥生成慢。<sup>[12](https://datatracker.ietf.org/doc/html/draft-mcgrew-hash-sigs-02)</sup> 实用无状态基于哈希签名的 SPHINCS 框架由丹尼尔·J·伯恩斯坦（Daniel J. Bernstein）及其同事报告，<sup>[18](https://eprint.iacr.org/2025/2236.pdf)</sup> 并演变为 SPHINCS+，其在 [FIPS 205](https://www.edgepedia.org/zh/fips-205) 中规定的实例已被 NIST 采纳为无状态基于哈希的数字签名标准 SLH-DSA。<sup>[18](https://eprint.iacr.org/2025/2236.pdf)</sup> FIPS 205 指出，SLH-DSA 的安全性依赖于寻找哈希函数原像的假定困难性，并且它旨在抵御大规模量子计算机的攻击；它将少数次签名方案（FORS）与多次方案（XMSS）结合，后者建立在温特尼茨一次性签名方案之上。<sup>[6](https://csrc.nist.gov/pubs/fips/205/final)</sup>

## References

1. [Password Authentication with Insecure Communication (Lamport, 1981)](https://lamport.azurewebsites.net/pubs/password.pdf)
2. [Fast Verification of Hash Chains (Fischlin, 2004)](https://www.cryptoplexity.informatik.tu-darmstadt.de/media/crypt/publications_1/fischlinhashchain2004.pdf)
3. [RFC 1760 - The S/KEY One-Time Password System](http://ftp.funet.fi/rfc/rfc1760.txt.pdf)
4. [Efficient Security Mechanisms for Routing Protocols (Hu, Perrig, Johnson, NDSS 2003)](https://netsec.ethz.ch/publications/papers/ndss03.pdf)
5. [ToSC article discussing hash-chain-based one-time passwords and T/Key](https://tosc.iacr.org/index.php/ToSC/article/download/11955/11822/13556)
6. [FIPS 205, Stateless Hash-Based Digital Signature Standard | CSRC](https://csrc.nist.gov/pubs/fips/205/final)
7. [Security analysis of hash-chain one-time authentication (Traynor et al., USENIX ATC 2010)](https://www.cise.ufl.edu/~traynor/papers/traynor-atc10.pdf)
8. [TESLA: Broadcast Authentication Protocol overview (Perrig et al.)](https://people.eecs.berkeley.edu/~tygar/papers/TESLA_broadcast_authentication_protocol.pdf)
9. [Leslie Lamport (1981). Password authentication with insecure communication. Communications of the ACM.](https://doi.org/10.1145/358790.358797)
10. [RFC 4082 - TESLA: Multicast Source Authentication Transform Introduction](https://datatracker.ietf.org/doc/html/rfc4082)
11. [W-OTS+ – Shorter Signatures for Hash-Based Signature Schemes](https://eprint.iacr.org/2017/965.pdf)
12. [draft-mcgrew-hash-sigs-02 (LDWM and Merkle tree signature systems)](https://datatracker.ietf.org/doc/html/draft-mcgrew-hash-sigs-02)
13. [Kogan, Dmitry, Manohar, Nathan, Boneh, Dan (2017). T/Key: Second-Factor Authentication From Secure Hash Chains. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1708.08424)
14. [Efficient Constructions for One-way Hash Chains (Jakobsson et al.)](https://netsec.ethz.ch/publications/papers/light4.pdf)
15. [An Authentication Scheme Based on Novel Construction of Hash Chains for Smart Mobile Devices (Wiley, 2020)](https://onlinelibrary.wiley.com/doi/10.1155/2020/8888679)
16. [T/Key: Second-Factor Authentication From Secure Hash Chains (arXiv preprint; excerpts merged into S10)](https://arxiv.org/pdf/1708.08424v1.pdf)
17. [T/Key: Second-Factor Authentication From Secure Hash Chains (Kogan et al., ACM CCS)](https://acmccs.github.io/papers/p983-koganA.pdf)
18. [Extending the Framework: Varying the ... (IACR ePrint, 2025)](https://eprint.iacr.org/2025/2236.pdf)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Oct 15, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Titles 2 to Ma

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/hash-chain

English original: https://www.edgepedia.org/hash-chain
