j4flmao/agent-skills/shors-algorithm
Claude Code and agent skill by j4flmao/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Use this skill when the user says 'Shor's algorithm', 'quantum factoring', 'period finding', 'break RSA with quantum', 'order finding', 'discrete log quantum', 'how many qubits to break RSA-2048', 'Q-Day estimate'. Explains Shor's reduction from factoring to order finding, the quantum period-finding circuit (modular exponentiation + inverse QFT), classical post-processing with continued fractions, a runnable classical simulation of the logic, and realistic resource estimates for RSA/ECC. Do NOT use for: migration planning to PQC (quantum-computing/post-quantum-crypto), Grover search (quantum-computing/grovers-algorithm), or the QFT/phase-estimation survey (quantum-computing/quantum-algorithms).
Install
npx vskill@latest install j4flmao/agent-skills/shors-algorithmSKILL.md
Shor's Algorithm
Purpose
Shor (1994) showed that a quantum computer can factor integers and compute discrete logarithms in polynomial time, which breaks RSA, Diffie-Hellman, and elliptic-curve cryptography. The quantum part finds the period r of f(x) = aˣ mod N; everything else is classical number theory. This skill explains the algorithm precisely, gives runnable code for the classical parts, and states what current resource estimates say about breaking real keys.
Agent Protocol
Trigger
"Shor", "quantum factoring", "order finding", "period finding", "modular exponentiation circuit", "RSA-2048 qubits", "ECC quantum attack", "Q-Day".
Input Context
- Goal: explanation, toy implementation, or resource/threat assessment.
- Key type and size (RSA-2048, P-256) if assessing threat.
Output Artifact
Algorithm walkthrough, code for reduction and post-processing, and a sourced resource estimate with assumptions.
Response Format
Completion Criteria
- [ ] Classical reduction and failure cases (odd r, a^{r/2} ≡ −1) handled.
- [ ] Continued-fraction step explained for measured phases.
- [ ] Resource numbers cited with their assumptions, not invented.
The Reduction (classical)
- Pick random a with 1 < a < N. If g = gcd(a, N) > 1, g is a factor (lucky).
- Find the order r: smallest r > 0 with aʳ ≡ 1 (mod N). This is the only quantum step.
- If r is even and a^{r/2} ≢ −1 (mod N), then gcd(a^{r/2} − 1, N) and gcd(a^{r/2} + 1, N) are non-trivial factors.
- Otherwise pick another a; for N with at least two distinct odd prime factors, a random a succeeds with probability ≥ 1/2.
The Quantum Step: Period Finding
- Two registers: t ≈ 2n qubits (counting) and n qubits (work), n = ⌈log₂ N⌉.
- Hadamards on the counting register → uniform superposition over x.
- Controlled modular exponentiation: |x⟩|1⟩ → |x⟩|aˣ mod N⟩ (implemented as controlled multiplications by a^{2^j} mod N; this dominates circuit cost).
- Inverse QFT on the counting register; measure y. Then y/2ᵗ ≈ s/r for a random integer s.
- Recover r with continued fractions of y/2ᵗ (denominator ≤ N); verify aʳ ≡ 1 mod N; repeat a few times and take lcm of candidates if needed.
Equivalently, this is phase estimation of the unitary U|y⟩ = |a·y mod N⟩, whose eigenphases are s/r.
Runnable Classical Simulation of the Logic
Resource Reality
| Item | Status | |
|---|---|---|
| Largest numbers factored with genuine Shor-style circuits | Tiny (15, 21), using simplified circuits that exploit known answers | |
| RSA-2048 estimate (Gidney & Ekerå, 2019) | ~20 million noisy physical qubits, ~8 hours, assuming 10⁻³ gate errors, surface code, 1 µs cycle | |
| RSA-2048 estimate (Gidney, 2025) | Under 1 million noisy physical qubits, under a week, same style of assumptions with improved arithmetic and magic-state techniques | |
| ECC (e.g. P-256) | Estimates require fewer logical qubits than RSA-2048; elliptic-curve keys are at least as exposed | |
| Current hardware | Hundreds to ~a thousand physical qubits, early below-threshold QEC demonstrations; no logical-qubit machine near these scales |
Interpretation: the algorithmic threat is settled; the hardware timeline is uncertain and estimates keep falling as algorithms improve. Hence harvest-now-decrypt-later risk and PQC migration now.
Claims of breaking RSA with annealers or tiny devices typically rely on classical preprocessing or special-form numbers; they do not scale like Shor's algorithm.
Anti-Patterns
- "Quantum computers try all factors in parallel" (the speedup comes from interference in period finding).
- Quoting qubit counts without error rates, cycle times, and code assumptions.
- Treating demonstrations on 15/21 as evidence of imminent RSA breaks, or dismissing the threat because they are small.
Checklist
- [ ] Reduction steps and retry conditions correct.
- [ ] Continued-fraction recovery demonstrated.
- [ ] Resource numbers cite source and assumptions.
- [ ] Recommendation links to PQC migration where relevant.
References
- Shor, "Algorithms for quantum computation: discrete logarithms and factoring" (FOCS 1994); SIAM J. Comput. 1997.
- Gidney & Ekerå, "How to factor 2048 bit RSA integers in 8 hours using 20 million noisy qubits" (Quantum, 2021).
- Gidney, "How to factor 2048 bit RSA integers with less than a million noisy qubits" (2025).
- Nielsen & Chuang, ch. 5.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/quantum-computing/shors-algorithm/SKILL.md
Popularity
- Repository stars
- 29
- Repository forks
- 1
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/j4flmao/agent-skills/shors-algorithm)