Quantum Computing Lecture 10
Quantum Computing Lecture 10
1 / 18
Resources for this lecture
2 / 18
Public-key cryptography
decrypt encrypt
private public
3 / 18
One-way functions
One way function are functions that are easy to perform “forward”,
but hard to invert.
For example, the RSA public-key cryptosystem uses factoring as a
one-way function: multiplying two prime number p and q to give a
composite number N is easy, but the inverse, factoring a composite
number N into factors p and q is mathematically difficult.
In fact, the best known classical algorithm for factoring, the number
field sieve, requires exp(Θ(n1/3 log2/3 n)) operations, where
n = dlog2 N e, i.e., the number of bits required to express N .
For cryptographic applications it is crucial that the mathematical
definition of one-way functions is that they must be hard to invert
on average, not just in the worst case.
4 / 18
Factoring quantum mechanically
www.quora.com/profile/Peter-Shor
Peter Shor
5 / 18
Shor’s factoring algorithm
6 / 18
Order finding
For co-prime positive integers x and N , such that x < N , the order of x
modulo N is defined to be the least positive integer r such that xr = 1
mod N .
7 / 18
Order finding using quantum phase estimation
To find the order of x modulo N quantumly, we simply apply QPE using
the unitary:
U |yi = |(xy) mod N i
where y is an integer such that 0 ≤ y < N .
U is unitary when x and N are co-prime because U is merely a
permutation matrix (i.e., it has exactly one 1 in each column and each
row). To see this, consider the following argument (in which y1 6= y2 ):
8 / 18
Quantum phase estimation with U |yi = |(xy) mod N i
Recall that the QPE circuit is thus:
1 𝑡−1 𝜙)
0 H ( 0 +𝑒 2𝜋𝑖(2 1)
First 2
register 1 1 𝜙)
t qubits 0 H ( 0 +𝑒 2𝜋𝑖(2 1)
2
0 1 0 𝜙)
H ( 0 +𝑒 2𝜋𝑖(2 1)
2
Second 𝑢 0 1 𝑡−1
𝑈2 𝑈2 𝑈2 𝑢
register
j
To perform QPE we need to implement controlled-U 2 gates and prepare
the second register in an eigenstate of U . However, regarding the first of
these, if we were simply to take a naive approach, we would incur an
exponential amount of operations.
9 / 18
j
Implementing the series of controlled-U 2 gates
There are a few variations on the method used to implement the series of
j
controlled-U 2 gates, so here we present one which can be (relatively)
easily understood. We begin by noting:
j j
U 2 |yi = |(x2 y) mod N i
2j
= |((x mod N )y) mod N i
Therefore:
j
1. We first pre-compute x2 mod N for all j, 0 ≤ j ≤ t − 1 (this is
known as modular exponentiation).
2. We then use these pre-computed values to implement the unitary
j
operation |yi → |((x2 mod N )y) mod N i (controlled as
appropriate) for all j, 0 ≤ j ≤ t − 1 in sequence as required.
10 / 18
j
Complexity of implementing the controlled-U 2 gates
Noting that multiplication takes O(m2 ) operations, where m is the
number of bits needed to specify the numbers being multiplied, the
computational complexity of the two steps required to implement the
j
controlled-U 2 gates is therefore as follows:
j
1. Pre-computing x2 mod N for all j, 0 ≤ j ≤ t − 1 can be achieved
by repeated modular squaring of x – i.e., a total of t squaring
j
operations. Note that x2 mod N < N , so a maximum of n bits
are needed to specify the numbers being squared, so the total
number of operations required is O(n2 t).
j
2. With the pre-computed values of x2 mod N we need to implement
j
the multiplication ((x2 mod N )y) mod N for all j,
0 ≤ j ≤ t − 1, i.e., t times in total. y < N , so a total of n bits are
required to express each of the numbers being multiplied, therefore
the complexity of this step is also O(n2 t).
To extract the order from the phase it suffices that t ∈ O(n), so putting
these together we have that the number of operations required to
j
perform the series of controlled-U 2 gates is O(n3 ).
11 / 18
The eigenvalues of U
QPE also requires that we prepare the input to the series of
j
controlled-U 2 gates in an eigenstate of U . States defined by:
r−1
1 X −2πisk/r k
|us i = √ e |x mod N i
r
k=0
for 0 ≤ s ≤ r − 1 are eigenstates of U , because:
r−1
1 X −2πisk/r k+1
U |us i = √ e |x mod N i
r
k=0
r
1 X
=√ e−2πis(k−1)/r |xk mod N i
r
k=1
r
1 X −2πisk/r k
= e2πis/r √ e |x mod N i
r
k=1
r−1
1 X −2πisk/r k
= e2πis/r √ e |x mod N i
r
k=0
= e2πis/r |us i
12 / 18
A superposition of eigenstates of U
To prepare an eigenstate as defined on the previous slide requires
knowledge of r, which we clearly don’t have, so instead we prepare an
equal superposition of eigenstates for 0 ≤ s ≤ r − 1:
r−1 r−1 r−1
1 X 1 X 1 X −2πisk/r k
√ |us i = √ √ e |x mod N i
r s=0 r s=0 r k=0
!
r−1 r−1 X
r−1
1 X 0 0 X
= e |x mod N i + e−2πisk/r |xk mod N i
r s=0
k=1 s=0
| {z }
=0 when k>0
1
= r |1i
r
= |1i
13 / 18
Order finding: quantum circuit
We previously saw that |us i has eigenvalue e2πis/r – i.e., its phase is s/r,
so we now run QPE, with the second register in the state |1i (note this is
|1i such that 1 is an n-bit binary number, rather than simply [0, 1]T ).
0 H⊗𝑡 QFT†
𝑗
1 𝑥 𝑗 mod 𝑁
The measurements will collapse the state into one of the eigenstate
components of |1i because each digital eigenvalue phase estimation in
the first register will be entangled with its corresponding eigenvector in
the second register:
r−1 r−1
1 X ⊗n 1 X g
√ |0i |us i → √ |s/ri |us i
r s=0 r s=0
Thus QPE returns an estimate of the phase s/r g for some (unknown)
integer s, however there is a classical algorithm (the continued fractions
algorithm) that can extract r from s/r
g with high probability.
14 / 18
Reduction of factoring to order-finding
From the order-finding subroutine we have found r such that xr
mod N = 1, i.e.,
(xr − 1) mod N = 0
If r is even this factorises:
15 / 18
Shor’s algorithm: success probability
The probability that r is such that neither of the first two occur is at
least one half. The probability that the order-finding subroutine is such
that the classical post-processing correctly returns the order is at least
1 − for some constant .
Therefore a single run of Shor’s algorithm correctly returns a factor with
probability O(1), which is acceptable, as the expected number of
iterations needed to find a factor does not grow with n.
16 / 18
Shor’s algorithm: computational complexity
Recall that the best classical algorithm for factoring requires
exp(Θ(n1/3 log2/3 n)) operations.
Shor’s algorithm (as we have expressed it here) calls two classical
algorithms as subroutines – the prime power checker, and Euclid’s
algorithm – both of which require a number of operations that is
only polynomial in n.
The quantum circuit used in Shor’s algorithm requires O(n3 ) gates
to perform the modular exponentiation, and O(n2 ) gates to perform
the QFT.
As the success probability of a single run of Shor’s algorithm is
O(1), the number of iterations we expect does not grow with n.
17 / 18
Summary
18 / 18