Shor Algorithm by the Numbers
Numeric Example of the Shor Algorithm
See Chapter 10 of the book: Algorithms for greater detail.
LibreOffice SpreadSheet with these same calculations: Shor-Algorithm-By-The-Numbers-Amarketplaceofideas-com.ods
|
The RSA setup You start by picking two large secret primes p and q, then compute:
The keys
It works because of Euler's theorem: m^(ed) ≡ m^(1 + kφ(N)) ≡ m (mod N). p and q are the secret primes you use to derive d. If an attacker learns p and q, they can compute φ(N) and then d, so factoring N breaks RSA. That's exactly why Shor's algorithm matters: it factors N efficiently on a quantum computer, which hands the attacker φ(N), then d, then the private key. |
Factoring the product is a difficult computation task in the case of large prime numbers. In this case it is obvious for the example's purposes
Factor 77 using Shor's algorithm
Pick a number that is relative prime to both 7 and 11. Here we choose 5 for the example.
will be periodic in r. The following would be set up in a quantum register to have all the values in the register simultaneously and calculate the function results simultaneously.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Starts repeating here
-
Calculate one more to check up above to convince yourself the exponential function is indeed periodic
Here we see the form of even power of the variable with 1 left over after the mod. That allows transforming the equation to the easily factored form of an even power minus one that can be factored. The even power is not guaranteed to you keep trying solutions till you get an even periodicity.
After the above results are piled simultaneously in the quantum register a quantum FFT is performed and the period r found to be 30 with high probability. All the above mod result values are in the register at the same time and not indexed per time or pure number index as far as I know. A quantum FFT does not yield a spectrum. It yields a frequency estimate of highest probability of the input waveform. Frequency as in probability frequency. However the above mod result values are KNOWN to be in regular spacing so a frequency that we are accustomed to can be calculated.
Thus using
have common factors with 77.
Calculators
Each of 77's 2 coprime factors have a common factor with only one of the 2 terms above. *(Not sure yet how to prove that) Use Euclid's rule to find the greatest common divisor
Perplexity: Since N | (a^r – 1) = (a^(r/2) – 1)(a^(r/2) + 1) and N ? either factor alone (because r is the smallest period), each prime factor of N must divide one of the two terms. It is also possible for both primes to divide the same term (in which case the algorithm fails and you retry with a new a); the guarantee is only probabilistic. The page's phrasing that each factor hits only one of the two terms is not generally true it happens to be true here.
Greatest Common Divisor. See chapter 1.2.3 of Algorithms.\
-
-
-
30517578124 = 22 × 11 × 31 × 71 × 181 × 1741
-
30517578126 = 2 × 32 × 7 × 61 × 521 × 7621
With this being the Kpub and Kpriv ( public and private key )
and the problem is solved. I need to add a section here that uses real RSA examples albeit smaller sized to allow reasonable computations.
Research Links
- CSE 599d – Quantum Computing Shor’s Algorithm
- CSE 599d
- Quantum Algorithms
- Chapter 10 of the book: Algorithms
- Book: Algorithms
Simulating the quantum factoring process in Open Office Calc
- Shor Algorithm in Open Office Calc
- Shor Algorithm by the Numbers ODS File
- How to calculate greatest common factor in open office calc
- Open Office Calc: Conditional formating
- DFT on OpenOffice Calc
- Gnumeric – a spreadsheet that has high accuracy and built in FFT
- An Overview of an OpenOffice.org Basic Program
- Tutorial covering using basic in open office
- Fourier analysis tool in Microsoft Excel
- List of prime numbers
Umesh V. Vazirani
More Links
DiqLullh6CBE
RSA Public Key Private Key Encryption – Table of Contents TOC