{"id":24712,"date":"2014-04-30T22:03:08","date_gmt":"2014-05-01T03:03:08","guid":{"rendered":"http:\/\/blogs.ams.org\/mathgradblog\/?p=24712"},"modified":"2014-06-17T16:16:47","modified_gmt":"2014-06-17T21:16:47","slug":"shors-algorithm-breaking-rsa-encryption","status":"publish","type":"post","link":"https:\/\/blogs.ams.org\/mathgradblog\/2014\/04\/30\/shors-algorithm-breaking-rsa-encryption\/","title":{"rendered":"Shor&#8217;s Algorithm &#8211; Breaking RSA Encryption"},"content":{"rendered":"<p>In my previous article, I talked about the RSA cryptosystem which is widely used on the Internet for secure data transmission. The power and security of the RSA cryptosystem derives from the fact that the factoring problem is \u201chard.\u201d That is, it is believed that the full decryption of an RSA ciphertext is infeasible because no efficient classical algorithm currently exists for factoring large numbers.\u00a0 However, in 1994 Peter Shor showed that a quantum computer could be used to factor a number <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/> in polynomial time, thus effectively breaking RSA.<\/p>\n<p><!--more--><\/p>\n<p>It may be tempting to use the speed of a quantum computer to simply check all possible divisors in parallel. In this case, we would be performing a classical algorithm on a quantum computer, making use only of the increased speed of the quantum machine. Unfortunately, this is not going to work. In a way, it is possible for a quantum computer to try all possible divisors. However, due to the nature of quantum computing, when measuring the outcome of the computations, you will get a random possible divisor, which is almost certainly not the one you want.<\/p>\n<p>How, then, can we use a quantum computer to solve the factoring problem? The key to a fast and accurate quantum factoring algorithm is to make use of the structure of the factoring problem itself. Instead of looking for factors directly, we must use some mathematical property of factoring. Fortunately, the factoring problem has plenty of special properties from which to choose. For example, given a positive integer, even if we do not know its prime factorization we do know that it has <b>exactly one<\/b> factorization. This fact does not help us solve the factorization problem, but it does give us hope that the problem has other nice mathematical properties that will.<\/p>\n<p>The property we will use is the ability to reduce the prime factorization problem into a problem of order (or period) finding. Let&#8217;s start by looking at an example. Consider the sequence of numbers<\/p>\n<p align=\"CENTER\">2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, \u2026<\/p>\n<p align=\"LEFT\">Now, let&#8217;s look at this same sequence of powers of two, but taken \u201cmod 15.\u201d In other words, we will create a new sequence of numbers consisting of the remainders when each power of two is divided by 15. This gives us the new sequence<\/p>\n<p align=\"CENTER\">2, 4, 8, 1, 2, 4, 8, 1, 2, 4, \u2026<\/p>\n<p align=\"LEFT\">We see that taking the powers of two mod 15 gives us a periodic sequence whose period (or order) is four. For another example, consider the same powers of two, but taken mod 21. In this case, we have the new sequence<\/p>\n<p align=\"CENTER\">2, 4, 8, 16, 11, 1, 2, 4, 8, 16, \u2026<\/p>\n<p align=\"LEFT\">Here, we get a periodic sequence whose period is six.<\/p>\n<p align=\"LEFT\">In the 1760s, Euler discovered a beautiful pattern to this period finding problem. Let <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/> be the product of two prime numbers, <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=p&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"p\" class=\"latex\" \/> and <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=q&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"q\" class=\"latex\" \/>. Consider the sequence<\/p>\n<p align=\"CENTER\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=x+%5Ctext%7B+mod+%7D+n%2C+x%5E2+%5Ctext%7B+mod+%7D+n%2C+x%5E3+%5Ctext%7B+mod+%7D+n%2C+x%5E4+%5Ctext%7B+mod+%7D+n%2C&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"x &#92;text{ mod } n, x^2 &#92;text{ mod } n, x^3 &#92;text{ mod } n, x^4 &#92;text{ mod } n,\" class=\"latex\" \/>&#8230;<\/p>\n<p>If <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=x&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"x\" class=\"latex\" \/> is not divisible by <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=p&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"p\" class=\"latex\" \/> or <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=q&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"q\" class=\"latex\" \/>, then the above sequence will repeat with some period that evenly divides <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28p-1%29%28q-1%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(p-1)(q-1)\" class=\"latex\" \/>.<\/p>\n<p>In our examples above, we have <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=x+%3D+2&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"x = 2\" class=\"latex\" \/>. In the first example, we have <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n+%3D+15&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n = 15\" class=\"latex\" \/> which has the prime factors <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=p+%3D+3&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"p = 3\" class=\"latex\" \/> and <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=q+%3D+5&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"q = 5\" class=\"latex\" \/>. Then, <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28p-1%29%28q-1%29+%3D+8&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(p-1)(q-1) = 8\" class=\"latex\" \/>, which is divisible by the period of 4. In the second example, we have <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n+%3D+21&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n = 21\" class=\"latex\" \/> which has the prime factors <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=p+%3D+3&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"p = 3\" class=\"latex\" \/> and <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=q+%3D+7&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"q = 7\" class=\"latex\" \/>. Then, <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28p-1%29%28q-1%29+%3D+12&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(p-1)(q-1) = 12\" class=\"latex\" \/>, which is divisible by the period of 6.<\/p>\n<p>But how does this help us solve the factorization problem? If we can find the period of the sequence<\/p>\n<p align=\"CENTER\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=x+%5Ctext%7B+mod+%7D+n%2C+x%5E2+%5Ctext%7B+mod+%7D+n%2C+x%5E3+%5Ctext%7B+mod+%7D+n%2C+x%5E4+%5Ctext%7B+mod+%7D+n%2C&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"x &#92;text{ mod } n, x^2 &#92;text{ mod } n, x^3 &#92;text{ mod } n, x^4 &#92;text{ mod } n,\" class=\"latex\" \/>&#8230;<\/p>\n<p align=\"LEFT\">then we learn something about the prime factors of <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/>. In particular, we learn a divisor of <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28p-1%29%28q-1%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(p-1)(q-1)\" class=\"latex\" \/>. Of course, we&#8217;d rather learn the factors <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=p&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"p\" class=\"latex\" \/> and <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=q&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"q\" class=\"latex\" \/> themselves, but this, at least, represents progress. If we determine several random divisors of <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28p-1%29%28q-1%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(p-1)(q-1)\" class=\"latex\" \/> by trying different random values of <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=x&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"x\" class=\"latex\" \/>, then we can multiply those divisors together to obtain <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28p-1%29%28q-1%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(p-1)(q-1)\" class=\"latex\" \/> itself. Once we know <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28p-1%29%28q-1%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(p-1)(q-1)\" class=\"latex\" \/>, we can then determine <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=p&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"p\" class=\"latex\" \/> and <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=q&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"q\" class=\"latex\" \/>.<\/p>\n<p align=\"LEFT\">However, there&#8217;s still a problem with applying our observations to the factorization problem. Even though the sequence<\/p>\n<p align=\"CENTER\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=x+%5Ctext%7B+mod+%7D+n%2C+x%5E2+%5Ctext%7B+mod+%7D+n%2C+x%5E3+%5Ctext%7B+mod+%7D+n%2C+x%5E4+%5Ctext%7B+mod+%7D+n%2C&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"x &#92;text{ mod } n, x^2 &#92;text{ mod } n, x^3 &#92;text{ mod } n, x^4 &#92;text{ mod } n,\" class=\"latex\" \/>&#8230;<\/p>\n<p align=\"LEFT\">will eventually start repeating itself, the number of steps before it repeats could be almost as large as <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/>, which in the RSA cryptosystem is a very large number! This issue is why finding the period of the sequence does not appear to lead to a classical factoring algorithm. However, with the help of quantum mechanics, we can define a quantum algorithm that works in a reasonable amount of time.<\/p>\n<p align=\"LEFT\">Shor&#8217;s algorithm is composed of two parts. The first part turns the factoring problem into the period finding problem, and can be computed on a classical computer. The second part (step 2 below) finds the period using the quantum Fourier transform and is responsible for the quantum speedup of the algorithm. We begin by briefly describing all five steps. After that, we will focus on the quantum part of the algorithm (i.e. step 2). To factor a large integer <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/> (which, without loss of generality, we may assume is odd), we use Shor&#8217;s algorithm:<\/p>\n<p align=\"LEFT\">1. Choose a random positive integer <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=m+%3C+n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"m &lt; n\" class=\"latex\" \/>. Compute gcd<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28m%2C+n%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(m, n)\" class=\"latex\" \/>, which may be done in polynomial time using the Euclidean algorithm. If gcd<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28m%2C+n%29%5Cneq+1&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(m, n)&#92;neq 1\" class=\"latex\" \/>, then we have found a non-trivial factor of <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/>, and we are done. If, on the other hand, gcd<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28m%2C+n%29+%3D+1&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(m, n) = 1\" class=\"latex\" \/>, proceed to step 2.<\/p>\n<p>2. Use a quantum computer to determine the unknown period <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"P\" class=\"latex\" \/> of the sequence<\/p>\n<p align=\"CENTER\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=x+%5Ctext%7B+mod+%7D+n%2C+x%5E2+%5Ctext%7B+mod+%7D+n%2C+x%5E3+%5Ctext%7B+mod+%7D+n%2C+x%5E4+%5Ctext%7B+mod+%7D+n%2C&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"x &#92;text{ mod } n, x^2 &#92;text{ mod } n, x^3 &#92;text{ mod } n, x^4 &#92;text{ mod } n,\" class=\"latex\" \/>&#8230;<\/p>\n<p align=\"LEFT\">3. If <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"P\" class=\"latex\" \/> is an odd integer, then return to step 1. The probability that <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"P\" class=\"latex\" \/> is odd is <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28%5Cfrac%7B1%7D%7B2%7D%29%5Ek&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(&#92;frac{1}{2})^k\" class=\"latex\" \/>, where <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=k&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"k\" class=\"latex\" \/> is the number of distinct prime factors of <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/>. If <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"P\" class=\"latex\" \/> is even, then proceed to step 4.<\/p>\n<p>4. Since <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"P\" class=\"latex\" \/> is even,<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28m%5E%7BP%2F2%7D+-+1%29%28m%5E%7BP%2F2%7D+-+1%29+%3D+m%5E%7BP%7D+-+1+%3D+0+%5Ctext%7B+mod+%7D+n.&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(m^{P\/2} - 1)(m^{P\/2} - 1) = m^{P} - 1 = 0 &#92;text{ mod } n.\" class=\"latex\" \/><\/p>\n<p>If <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=m%5E%7BP%2F2%7D+%2B1+%3D+0+%5Ctext%7B+mod+%7D+n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"m^{P\/2} +1 = 0 &#92;text{ mod } n\" class=\"latex\" \/>, then go to step 1. If <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=m%5E%7BP%2F2%7D+%2B1+%5Cneq+0+%5Ctext%7B+mod+%7D+n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"m^{P\/2} +1 &#92;neq 0 &#92;text{ mod } n\" class=\"latex\" \/>, then proceed to step 5. It can be shown that the probability that <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=m%5E%7BP%2F2%7D+%2B1+%3D+0+%5Ctext%7B+mod+%7D+n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"m^{P\/2} +1 = 0 &#92;text{ mod } n\" class=\"latex\" \/> is less than <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28%5Cfrac%7B1%7D%7B2%7D%29%5E%7Bk-1%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(&#92;frac{1}{2})^{k-1}\" class=\"latex\" \/>, where <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=k&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"k\" class=\"latex\" \/> denotes the number of distinct prime factors of <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/>.<\/p>\n<p>5. Compute <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=d+%3D+&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"d = \" class=\"latex\" \/> gcd<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%28m%5E%7BP%2F2%7D-1%2C+n%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(m^{P\/2}-1, n)\" class=\"latex\" \/> using the Euclidean algorithm. Since <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=m%5E%7BP%2F2%7D+%2B1+%5Cneq+0+%5Ctext%7B+mod+%7D+n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"m^{P\/2} +1 &#92;neq 0 &#92;text{ mod } n\" class=\"latex\" \/>, it can be shown that <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=d&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"d\" class=\"latex\" \/> is a non-trivial factor of <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/>. Exit with the answer <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=d&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"d\" class=\"latex\" \/>.<\/p>\n<p>Thus, the task of factoring an odd positive integer <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n\" class=\"latex\" \/> reduces to the problem of finding the period of a function\/sequence. Shor&#8217;s period-finding algorithm (step 2 above) relies heavily on the ability of a quantum computer to be in many states simultaneously (a superposition of states). To compute the period of a function <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=f&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"f\" class=\"latex\" \/>, we evaluate the function at all points simultaneously.<\/p>\n<p>Unfortunately, quantum mechanics does not allow us to access all of this information directly. Instead, a measurement must be taken which will yield only one of the possible values (destroying all others). Because of this issue, we must transform the superposition to another state that will return the correct period with high probability. This is achieved by using the quantum Fourier transform. The main components of Shor&#8217;s period-finding algorithm are as follows:<\/p>\n<p>1. Create a superposition of states. This can be done by applying Hadamard gates to all qubits in the input register.<\/p>\n<p>2. Implement the function <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=f&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"f\" class=\"latex\" \/> as a quantum transform. To achieve this, Shor used repeated squaring for his modular exponentiation transform.<\/p>\n<p>3. Perform a quantum Fourier transform.<\/p>\n<p>After these transformations, a measurement will yield an approximation to the period <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"P\" class=\"latex\" \/>.<\/p>\n<p>Now let&#8217;s look at an example of how <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n+%3D+91+%28%3D+7%5Ccdot+13%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n = 91 (= 7&#92;cdot 13)\" class=\"latex\" \/> can be factored using Shor&#8217;s algorithm.<\/p>\n<p>Step 1. Choose a random positive integer <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=m&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"m\" class=\"latex\" \/>, say <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=m+%3D+3&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"m = 3\" class=\"latex\" \/>. Since gcd<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%2891%2C3%29+%3D+1&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(91,3) = 1\" class=\"latex\" \/>, proceed to step 2 to find the period of the function <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=f&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"f\" class=\"latex\" \/> given by<\/p>\n<p align=\"CENTER\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=f%28a%29+%3D+3%5Ea+%5Ctext%7B+mod+%7D+91&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"f(a) = 3^a &#92;text{ mod } 91\" class=\"latex\" \/>.<\/p>\n<p align=\"LEFT\">Step 2. Run Shor&#8217;s period-finding algorithm on a quantum computer to find (with high probability) that the period <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P+%3D+6&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"P = 6\" class=\"latex\" \/>.<\/p>\n<p align=\"LEFT\">Step 3. Since <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=P+%3D+6&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"P = 6\" class=\"latex\" \/> is even, we proceed to step 4.<\/p>\n<p align=\"LEFT\">Step 4. Since<\/p>\n<p align=\"CENTER\"><img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=3%5E%7BP%2F2%7D+%2B1+%3D3%5E3+%2B+1+%3D+28+%5Cneq+0+%5Ctext+%7B+mod+%7D+91&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"3^{P\/2} +1 =3^3 + 1 = 28 &#92;neq 0 &#92;text { mod } 91\" class=\"latex\" \/><\/p>\n<p align=\"LEFT\">proceed to step 5.<\/p>\n<p align=\"LEFT\">Step 5. With the Euclidean algorithm, compute<\/p>\n<p align=\"CENTER\">\u00a0<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=d+%3D+&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"d = \" class=\"latex\" \/> gcd<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%283%5E%7BP%2F2%7D-1%2C+91%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(3^{P\/2}-1, 91)\" class=\"latex\" \/>= gcd<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%283%5E%7B3%7D-1%2C+91%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(3^{3}-1, 91)\" class=\"latex\" \/>= gcd<img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=%2826%2C+91%29+%3D+13.&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"(26, 91) = 13.\" class=\"latex\" \/><\/p>\n<p align=\"LEFT\">We have succeeded in using Shor&#8217;s algorithm to find a non-trivial factor of <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=n+%3D+91&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"n = 91\" class=\"latex\" \/>, namely <img decoding=\"async\" src=\"https:\/\/s0.wp.com\/latex.php?latex=d+%3D+13&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002\" alt=\"d = 13\" class=\"latex\" \/>.<\/p>\n<p>&nbsp;<\/p>\n<p>Sources:<\/p>\n<p>Shor, P. W. (1997). Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. <i>SIAM Journal on Computing, 26<\/i>(5), 1484-26. doi:http:\/\/dx.doi.org\/10.1137\/S0097539795293172<\/p>\n<p>Lomonaco, Jr, S. J. (2000) Shor&#8217;s Quantum Factoring Algorithm. <a href=\"http:\/\/arxiv.org\/abs\/quant-ph\/0010034\">arXiv:quant-ph\/0010034<\/a><\/p>\n<div style=\"margin-top: 0px; margin-bottom: 0px;\" class=\"sharethis-inline-share-buttons\" ><\/div>","protected":false},"excerpt":{"rendered":"<p>In my previous article, I talked about the RSA cryptosystem which is widely used on the Internet for secure data transmission. The power and security of the RSA cryptosystem derives from the fact that the factoring problem is \u201chard.\u201d That &hellip; <a href=\"https:\/\/blogs.ams.org\/mathgradblog\/2014\/04\/30\/shors-algorithm-breaking-rsa-encryption\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n<div style=\"margin-top: 0px; margin-bottom: 0px;\" class=\"sharethis-inline-share-buttons\" data-url=https:\/\/blogs.ams.org\/mathgradblog\/2014\/04\/30\/shors-algorithm-breaking-rsa-encryption\/><\/div>\n","protected":false},"author":68,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12,21],"tags":[],"class_list":["post-24712","post","type-post","status-publish","format-standard","hentry","category-math","category-technology-math"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3gbww-6qA","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/posts\/24712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/comments?post=24712"}],"version-history":[{"count":18,"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/posts\/24712\/revisions"}],"predecessor-version":[{"id":24730,"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/posts\/24712\/revisions\/24730"}],"wp:attachment":[{"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/media?parent=24712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/categories?post=24712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ams.org\/mathgradblog\/wp-json\/wp\/v2\/tags?post=24712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}