# 肖尔算法

**肖尔算法**是一种量子算法，由彼得·W·肖尔（Peter W. Shor）于1994年发表，能在输入规模（如待分解整数的位数）的多项式步数内完成整数分解和离散对数计算。<sup>[1](https://arxiv.org/abs/quant-ph/9508027)</sup> 这些问题所有已知的经典算法都需要超多项式时间；最好的经典分解方法——通用数域筛法——所需时间随整数位长呈亚指数增长。<sup>[2](https://archive.dimacs.rutgers.edu/TechnicalReports/abstracts/1994.sav/94-37.html)</sup><sup> • </sup><sup>[3](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=934896)</sup> 由于广泛使用的RSA密码系统正是建立在“分解整数难以做到”这一假设之上，该算法几乎在一夜之间使量子计算成为国家安全关切。<sup>[3](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=934896)</sup><sup> • </sup><sup>[4](https://www.nist.gov/quantum-information-science/quantum-computing-explained)</sup>

| 关键事实 | 详情 |
|---|---|
| 来源 | 彼得·W·肖尔（AT&T研究公司）；初版于1994年11月20日至22日在新墨西哥州圣菲举行的第35届计算机科学基础年会上报告，第124–134页<sup>[1](https://arxiv.org/abs/quant-ph/9508027)</sup> |
| 解决的问题 | 在量子计算机上以多项式时间完成整数分解和离散对数计算<sup>[1](https://arxiv.org/abs/quant-ph/9508027)</sup><sup> • </sup><sup>[5](https://nvlpubs.nist.gov/nistpubs/ir/2012/nist.ir.7856.pdf)</sup> |
| 期刊版本 | SIAM J. Sci. Statist. Comput. 26 (1997) 1484<sup>[1](https://arxiv.org/abs/quant-ph/9508027)</sup> |
| 量子核心 | 求阶问题，通过使用逆量子傅里叶变换的量子相位估计来求解；最后的分解步骤完全是经典的<sup>[6](https://qiskit.qotlabs.org/learning/courses/fundamentals-of-quantum-algorithms/phase-estimation-and-factoring/shor-algorithm)</sup> |
| 密码学目标 | 在足够大且容错的量子计算机上，肖尔算法将攻破RSA、ECDSA、(EC)DH和DSA<sup>[7](https://csrc.nist.gov/CSRC/media/Presentations/quantum-computing-current-state-and-cryptography/images-media/Quantum%20Computin_%20Current%20State%20and%20Crytography.pdf)</sup> |
| 硬件规模 | 运行肖尔破译算法的量子计算机可能需要数百万个能无限期无差错运行的量子比特；2025年的一项资源研究认为，具有密码学相关规模的实例或许只需一万个可重构原子量子比特即可运行<sup>[4](https://www.nist.gov/quantum-information-science/quantum-computing-explained)</sup><sup> • </sup><sup>[8](https://arxiv.org/abs/2603.28627)</sup> |
| 应对措施 | NIST于2024年发布了首批三项最终确定的后量子密码学标准，基于结构化格和哈希函数<sup>[9](https://www.nist.gov/cybersecurity-and-privacy/what-post-quantum-cryptography)</sup> |

## 算法原理

该算法将分解问题归约为一个称为“求阶”的数论问题。对于正整数N，与N互素的元素a有一个阶r，即满足a<sup>r</sup> ≡ 1 (mod N)的最小正整数。求出这个阶便可以对N进行分解。<sup>[10](https://quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)</sup> 量子计算机只在求阶这一步需要用到；算法的其余步骤完全是经典的。<sup>[6](https://qiskit.qotlabs.org/learning/courses/fundamentals-of-quantum-algorithms/phase-estimation-and-factoring/shor-algorithm)</sup>

**量子相位估计。** 求阶被转化为一个相位估计问题。乘法算子M<sub>a</sub>定义为M<sub>a</sub>|x⟩ = |ax (mod N)⟩，它是一个酉算子，其特征值编码了a的阶r。<sup>[10](https://quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)</sup> 受控酉算子向其控制量子比特执行相位回踢，将特征值的相位信息传播到一个由m个估计量子比特组成的寄存器上。此操作之后，估计寄存器的可能状态是正交归一的，可以旋转回计算基进行测量；旋转矩阵对应于2<sup>m</sup>维希尔伯特空间中的逆量子傅里叶变换（QFT）。<sup>[10](https://quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)</sup> 其背后的思想是：模幂算子具有周期性结构，这种周期性被存储在量子态中，而QFT将这种周期性转化为频域中可测量的峰值。<sup>[10](https://quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)</sup> 因此，求解求阶问题的主要工具是量子傅里叶变换，它在肖尔算法中的作用类似于西蒙算法中的哈达玛变换。<sup>[11](https://theory.cs.princeton.edu/complexity/quantumchap.pdf)</sup>

**模幂运算。** 相位估计电路需要k = 1, 2, 4, …, 2<sup>m−1</sup>时的幂M<sub>a</sub><sup>k</sup>。这些幂不是通过迭代M<sub>a</sub>的电路来构建的；算法改为经典地通过反复平方计算出b = a<sup>k</sup> mod N，然后使用M<sub>b</sub>的电路。<sup>[10](https://quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)</sup>

**经典收尾。** 一旦从量子计算机获得相位测量结果，算法剩余的部分——将求阶与整数分解联系起来——就在经典计算机上运行。<sup>[12](https://eu-de.quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)</sup> 求阶过程在单次运行中可能失败，因此量子部分可能需要重复；在IBM的一次演示中，取a = 2对N = 15进行分解，测得的特征值中有两个给出了正确结果r = 4。<sup>[12](https://eu-de.quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)</sup>

## 起源与发表

肖尔于1994年在AT&T研究公司任职期间发表了这项工作。初版收录于1994年11月在新墨西哥州圣菲举行的第35届计算机科学基础年会论文集；扩展后的论文于1995年8月提交至arXiv，1996年1月修订，给出了在假想量子计算机上分解整数和计算离散对数的高效随机算法，所需步数随输入规模呈多项式增长。<sup>[1](https://arxiv.org/abs/quant-ph/9508027)</sup> NIST的一份报告将这一发现描述为用于整数分解和离散对数计算的多项式时间量子算法，并指出NIST一直在监测实验量子计算，以预测量子计算机何时——或者是否——会对RSA及其他在用的密码系统构成重大威胁。<sup>[5](https://nvlpubs.nist.gov/nistpubs/ir/2012/nist.ir.7856.pdf)</sup> DIMACS技术报告版本则直截了当地陈述了结论：量子计算机可以在多项式时间内分解整数和求离散对数，而这些问题所有已知的经典算法都需要超多项式时间。<sup>[2](https://archive.dimacs.rutgers.edu/TechnicalReports/abstracts/1994.sav/94-37.html)</sup>

## 密码学影响

RSA选取两个非常大的素数，将它们相乘得到一个更大的数作为公钥。将素数相乘既容易又快速；而逆向还原出素因子，正是经典计算机破解加密所必须做的事，对于足够大的数，据估计这需要数十亿年。<sup>[9](https://www.nist.gov/cybersecurity-and-privacy/what-post-quantum-cryptography)</sup> 肖尔算法原则上消除了这一障碍：一台能力足够的量子计算机可以在数天甚至数小时内解决这个分解难题，而不是数十亿年，从而使国家机密和银行账户信息面临风险。<sup>[9](https://www.nist.gov/cybersecurity-and-privacy/what-post-quantum-cryptography)</sup> NIST的一份演示文稿列出的受影响方案包括RSA、ECDSA、(EC)DH和DSA。<sup>[7](https://csrc.nist.gov/CSRC/media/Presentations/quantum-computing-current-state-and-cryptography/images-media/Quantum%20Computin_%20Current%20State%20and%20Crytography.pdf)</sup> 威胁还延伸到建立在这些方案之上的协议，包括用于HTTPS和文件传输的TLS与SSL、IPSEC、SSH以及PGP电子邮件加密。<sup>[13](https://www.oezratty.net/wordpress/wp-content/themes/Ezratty5/forcedownload.php?file=%2FFiles%2FPublications%2FUQT2025-Part4-A4.pdf)</sup>

应对之策是全球向后量子密码学迁移。NIST于2015年启动了遴选与标准化工作，2016年正式征集候选算法，收到69份达到其门槛的提交；首批三项最终确定的后量子标准于2024年发布，基于结构化格和哈希函数——这两类数学问题被认为对量子计算机和传统计算机同样难以求解。<sup>[9](https://www.nist.gov/cybersecurity-and-privacy/what-post-quantum-cryptography)</sup> 即便尚无任何具有密码学相关能力的量子计算机存在，今天截获的加密数据仍会因“先存储、后解密”攻击而面临风险——攻击者存储密文，期望有朝一日造出这样的机器后再行解密。<sup>[9](https://www.nist.gov/cybersecurity-and-privacy/what-post-quantum-cryptography)</sup> NIST对量子计算利弊的评估得出结论：容错算法构成主要的密码学威胁，这暗示量子计算机可能在威胁密码学之前先带来经济效益。<sup>[14](https://www.nist.gov/publications/assessing-benefits-and-risks-quantum-computers)</sup>

## 资源需求

演示与威胁之间的差距很大。IBM的教程通过在真实量子硬件上分解15来演示该算法，使用的是由相位估计构建的求阶电路。<sup>[10](https://quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)</sup> 相比之下，大规模运行肖尔的破译算法可能需要数百万个像经典计算机的比特那样无限期无差错运行的量子比特；这样的机器可能还非常遥远。<sup>[4](https://www.nist.gov/quantum-information-science/quantum-computing-explained)</sup> NIST的通俗指南指出，需要动用成千上万个量子比特的量子计算机才能破解当今的加密；而量子比特很脆弱，最轻微的扰动就可能在破解密码等操作完成之前将其破坏。<sup>[9](https://www.nist.gov/cybersecurity-and-privacy/what-post-quantum-cryptography)</sup>

近期的资源研究降低了这些估计。2025年的一项分析利用高码率量子纠错码、高效逻辑指令集和电路设计，认为肖尔算法可以在具有密码学相关规模的情况下，仅用一万个可重构原子量子比特即可执行；在合理假设下，对于拥有26,000个物理量子比特的系统，P-256椭圆曲线上的离散对数运行时间可能只需几天，而分解RSA-2048整数则要长一到两个数量级。<sup>[8](https://arxiv.org/abs/2603.28627)</sup> 据《生活科学》报道的一项相关研究，缺乏纠错的最先进量子机器需要100万个量子比特才能在一周内破解RSA，而采用约102,000个量子比特的并行化设计可以在97天内破解RSA-2048。<sup>[15](https://www.livescience.com/technology/quantum/quantum-computers-need-just-10-000-qubits-not-the-millions-we-assumed-to-break-the-worlds-most-secure-encryption-algorithms)</sup> 对于椭圆曲线离散对数，早期工作表明，攻击一个n比特素数域曲线最多需要9n + 2⌈log₂(n)⌉ + 10个量子比特和最多448n³ log₂(n) + 4090n³个托福利门。<sup>[16](https://arxiv.org/abs/1706.06752)</sup>

## 加速何以可能

该算法展示了量子计算如何从叠加态中提取全局信息。正如谷歌量子计算研究员、曾长期任职于NIST的斯蒂芬·乔丹（Stephen Jordan）所解释的，在叠加态中进行的计算实现了某种并行计算，但这并不能对全部潜在解进行高效的暴力搜索，因为最终的测量只能提取关于所有计算结果的一小部分信息；关键在于设计测量方式，使其能提取关于整个结果集合的有用信息。<sup>[4](https://www.nist.gov/quantum-information-science/quantum-computing-explained)</sup> 在肖尔算法中，这一测量就是对某个状态的量子傅里叶变换，该状态的周期性编码了阶r，从而将一个经典方法难以攻克的问题转化为量子计算机通过重复运行即可回答的问题。<sup>[10](https://quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)</sup><sup> • </sup><sup>[11](https://theory.cs.princeton.edu/complexity/quantumchap.pdf)</sup>

## References

1. [Peter W. Shor (1995, revised 1996). Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer. arXiv:quant-ph/9508027.](https://arxiv.org/abs/quant-ph/9508027)
2. [DIMACS Technical Report 94-37: Algorithms for Quantum Computation: Discrete Log and Factoring.](https://archive.dimacs.rutgers.edu/TechnicalReports/abstracts/1994.sav/94-37.html)
3. [Dustin Moody and Angela Robinson (2022). Cryptographic Standards in a Post-Quantum Era. NIST.](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=934896)
4. [Quantum Computing Explained. NIST.](https://www.nist.gov/quantum-information-science/quantum-computing-explained)
5. [NISTIR 7856 (2012). NIST.](https://nvlpubs.nist.gov/nistpubs/ir/2012/nist.ir.7856.pdf)
6. [Shor's algorithm, Fundamentals of Quantum Algorithms course. IBM Quantum Learning.](https://qiskit.qotlabs.org/learning/courses/fundamentals-of-quantum-algorithms/phase-estimation-and-factoring/shor-algorithm)
7. [The Quantum Threat: Quantum Computing, Current State and Cryptography. NIST CSRC presentation.](https://csrc.nist.gov/CSRC/media/Presentations/quantum-computing-current-state-and-cryptography/images-media/Quantum%20Computin_%20Current%20State%20and%20Crytography.pdf)
8. [Shor's algorithm is possible with as few as 10,000 reconfigurable atomic qubits. arXiv:2603.28627.](https://arxiv.org/abs/2603.28627)
9. [What Is Post-Quantum Cryptography? NIST.](https://www.nist.gov/cybersecurity-and-privacy/what-post-quantum-cryptography)
10. [Shor's algorithm tutorial. IBM Quantum Documentation.](https://quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)
11. [Shor's Algorithm: Integer Factorization Using Quantum Computers, chapter 20, Princeton complexity theory text.](https://theory.cs.princeton.edu/complexity/quantumchap.pdf)
12. [Shor's algorithm tutorial (EU mirror). IBM Quantum Documentation.](https://eu-de.quantum.cloud.ibm.com/docs/en/tutorials/shors-algorithm)
13. [Understanding Quantum Technologies 2025, Part 4. Olivier Ezratty.](https://www.oezratty.net/wordpress/wp-content/themes/Ezratty5/forcedownload.php?file=%2FFiles%2FPublications%2FUQT2025-Part4-A4.pdf)
14. [Assessing the Benefits and Risks of Quantum Computers. NIST.](https://www.nist.gov/publications/assessing-benefits-and-risks-quantum-computers)
15. [Quantum computers need just 10,000 qubits, not the millions we assumed. Live Science.](https://www.livescience.com/technology/quantum/quantum-computers-need-just-10-000-qubits-not-the-millions-we-assumed-to-break-the-worlds-most-secure-encryption-algorithms)
16. [Quantum resource estimates for computing elliptic curve discrete logarithms. arXiv:1706.06752.](https://arxiv.org/abs/1706.06752)

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

Topic: 物质世界与数学 › 物理学 › 量子物理学 › Quantum information science › Quantum computing and algorithms › Quantum algorithms › Factoring, discrete logarithms, and hidden-subgroup algorithms › Shor's factoring algorithm

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/shors-algorithm

English original: https://www.edgepedia.org/shors-algorithm
