Classical RSA algorithm

Post on 26-Feb-2022

10 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

Classical RSA algorithm

Modulo-𝑁𝑁 arithmetic (modular arithmetic, clock arithmetic)

We need to discuss some mathematics (number theory) first

Usual operations: addition and multiplication (ring), we need only multiplication

2 ≑ 9 (mod 7)4 Γ— 3 ≑ 5 (mod 7)

β€œcongruent” (I will also use β€œ=” instead of β€œβ‰‘β€)

Definition: Order of π‘Žπ‘Ž is the smallest π‘Ÿπ‘Ÿ, for which

π‘Žπ‘Žπ‘Ÿπ‘Ÿ ≑ 1 (mod 𝑁𝑁)

Why important: if 𝑓𝑓 π‘₯π‘₯ = π‘Žπ‘Žπ‘₯π‘₯ (mod 𝑁𝑁), then π‘Ÿπ‘Ÿ is the period of 𝑓𝑓(π‘₯π‘₯).

Check: 𝑓𝑓 π‘₯π‘₯ + π‘Ÿπ‘Ÿ = π‘Žπ‘Žπ‘₯π‘₯+π‘Ÿπ‘Ÿ = π‘Žπ‘Žπ‘₯π‘₯π‘Žπ‘Žπ‘Ÿπ‘Ÿ = π‘Žπ‘Žπ‘₯π‘₯ = 𝑓𝑓(π‘₯π‘₯) mod 𝑁𝑁

Fermat’s little theorem (simple proof, any number theory course)

If 𝑝𝑝 is prime and π‘Žπ‘Ž is not divisible by 𝑝𝑝, then

π‘Žπ‘Žπ‘π‘βˆ’1 ≑ 1 (mod 𝑝𝑝)(e.g., proof via the product π‘Žπ‘Ž 2π‘Žπ‘Ž 3π‘Žπ‘Ž … 𝑝𝑝 βˆ’ 1 π‘Žπ‘Ž = π‘Žπ‘Žπ‘π‘βˆ’1 𝑝𝑝 βˆ’ 1 ! = 𝑝𝑝 βˆ’ 1 ! mod 𝑝𝑝,

since all π‘›π‘›π‘Žπ‘Ž should be different mod 𝑝𝑝)

Fermat 1640 (letter, no proof) Leibniz 1683 (unpublished)Euler 1736 (first published proof)

RSA mathematicsFermat’s little theorem: If 𝑝𝑝 is prime and π‘Žπ‘Ž is not divisible by 𝑝𝑝, then π‘Žπ‘Žπ‘π‘βˆ’1 ≑ 1 (mod 𝑝𝑝)

β‡’ Lemma If 𝑝𝑝 and π‘žπ‘ž are primes and π‘Žπ‘Ž is not divisible by 𝑝𝑝 or π‘žπ‘ž, then

π‘Žπ‘Ž(π‘π‘βˆ’1)(π‘žπ‘žβˆ’1) ≑ 1 (mod π‘π‘π‘žπ‘ž)

Proof π‘Žπ‘Ž(π‘π‘βˆ’1) (π‘žπ‘žβˆ’1) ≑ 1 (mod 𝑝𝑝)π‘Žπ‘Ž(π‘žπ‘žβˆ’1) (π‘π‘βˆ’1) ≑ 1 (mod π‘žπ‘ž)

β‡’ π‘Žπ‘Ž(π‘π‘βˆ’1)(π‘žπ‘žβˆ’1) βˆ’ 1 is a multiple of both 𝑝𝑝 and π‘žπ‘ž, therefore multiple of π‘π‘π‘žπ‘ž.

QED

β‡’ Lemma If 𝑝𝑝 and π‘žπ‘ž are primes and 𝑠𝑠 is an integer, then

π‘Žπ‘Ž1+𝑠𝑠(π‘π‘βˆ’1)(π‘žπ‘žβˆ’1) ≑ π‘Žπ‘Ž (mod π‘π‘π‘žπ‘ž)

Note: works even if π‘Žπ‘Ž is divisible by 𝑝𝑝 or π‘žπ‘ž (trivial if a multiple of π‘π‘π‘žπ‘ž; if only π‘Žπ‘Ž = π‘˜π‘˜π‘žπ‘ž,

then Fermat: π‘Žπ‘Žπ‘ π‘  π‘žπ‘žβˆ’1(π‘π‘βˆ’1)

= 1 + 𝑛𝑛𝑝𝑝, so π‘Žπ‘Žπ‘ π‘  π‘žπ‘žβˆ’1 π‘π‘βˆ’1 +1 = π‘Žπ‘Ž + π‘Žπ‘Žπ‘›π‘›π‘π‘ = π‘Žπ‘Ž + π‘›π‘›π‘˜π‘˜π‘žπ‘žπ‘π‘ )

β‡’ Theorem If 𝑐𝑐𝑐𝑐 ≑ 1 [mod (𝑝𝑝 βˆ’ 1)(π‘žπ‘ž βˆ’ 1)] and 𝑝𝑝 & π‘žπ‘ž are primes, then

π‘Žπ‘Žπ‘π‘π‘π‘ ≑ π‘Žπ‘Ž (mod π‘π‘π‘žπ‘ž)

RSA algorithmRivest, Shamir, Adlerman, 1977, authors from MIT

Alice

Clifford Cocks, 1973, British Intelligence, secret until 1997

Bobpublic key

message(in Mermin’s book roles of Alice and Bob are exchanged)

Alice Pick large primes 𝑝𝑝 and π‘žπ‘ž, calculate 𝑁𝑁 = π‘π‘π‘žπ‘žPick 𝑐𝑐 < 𝑁𝑁 [coprime with (𝑝𝑝 βˆ’ 1)(π‘žπ‘ž βˆ’ 1)]

Find 𝑐𝑐, for which 𝑐𝑐𝑐𝑐 ≑ 1 [mod 𝑝𝑝 βˆ’ 1 π‘žπ‘ž βˆ’ 1 ](easy to find 𝑐𝑐 using Euclidean algorithm for 𝑐𝑐 and 𝑝𝑝 βˆ’ 1 π‘žπ‘ž βˆ’ 1 )

Public key: 𝑁𝑁 and 𝑐𝑐Private key: 𝑁𝑁 and 𝑐𝑐

Bob Wants to send message π‘Žπ‘Ž (π‘Žπ‘Ž < 𝑁𝑁)

Encoding: π‘Žπ‘Ž β†’ οΏ½π‘Žπ‘Ž = π‘Žπ‘Žπ‘π‘ (mod 𝑁𝑁)

Alice Decoding: οΏ½π‘Žπ‘Žπ‘π‘ mod 𝑁𝑁 = π‘Žπ‘Žπ‘π‘π‘π‘ mod 𝑁𝑁 = π‘Žπ‘Ž

RSA algorithm (cont.)Remarks

- Typically 𝑁𝑁 ∼ 2048 βˆ’ 4096 bits long

- Computation of π‘Žπ‘Žπ‘π‘ (mod 𝑁𝑁) and οΏ½π‘Žπ‘Žπ‘π‘ (mod 𝑁𝑁) is fast:π‘Žπ‘Ž β†’ π‘Žπ‘Ž2 β†’ π‘Žπ‘Ž4 β†’ π‘Žπ‘Ž8 β†’. . . , then products (all mod 𝑁𝑁 )

- Eve knows 𝑁𝑁. If she can factor 𝑁𝑁 = π‘π‘π‘žπ‘ž, then she can do the same as Alice, so she can decode. This is why factoring is so important.

- 𝑁𝑁 can be factored via finding the period of the function 𝑓𝑓 π‘₯π‘₯ = π‘Žπ‘Žπ‘₯π‘₯ (mod 𝑁𝑁),where π‘Žπ‘Ž is any number (will discuss in more detail later).

Idea: if π‘Žπ‘Žπ‘Ÿπ‘Ÿ ≑ 1 (mod 𝑁𝑁) and π‘Ÿπ‘Ÿ is even, then π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 βˆ’ 1 π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 + 1 ≑ 0 (mod 𝑁𝑁)

- RSA can be also broken directly with a period-finding algorithm.οΏ½π‘Žπ‘Ž, οΏ½π‘Žπ‘Ž2, οΏ½π‘Žπ‘Ž3, . . . οΏ½π‘Žπ‘Žπ‘Ÿπ‘Ÿ = 1, οΏ½π‘Žπ‘Žπ‘Ÿπ‘Ÿ+1 = οΏ½π‘Žπ‘Ž (mod N) (if οΏ½π‘Žπ‘Ž is not coprime with 𝑁𝑁,

then factor immediately). Then π‘Žπ‘Žπ‘Ÿπ‘Ÿ ≑ 1 (mod 𝑁𝑁) also (because subgroups οΏ½π‘Žπ‘Žπ‘˜π‘˜ and π‘Žπ‘Žπ‘˜π‘˜ coincide since π‘Žπ‘Žπ‘π‘ ≑ οΏ½π‘Žπ‘Ž, and οΏ½π‘Žπ‘Žπ‘π‘ ≑ π‘Žπ‘Ž, so the same order.)

Then if we find 𝑐𝑐𝑑 so that 𝑐𝑐𝑐𝑐′ ≑ 1 (mod π‘Ÿπ‘Ÿ), then οΏ½π‘Žπ‘Žπ‘π‘β€² ≑ π‘Žπ‘Žπ‘π‘π‘π‘β€² ≑ π‘Žπ‘Ž1+π‘šπ‘šπ‘Ÿπ‘Ÿ = π‘Žπ‘Ž π‘Žπ‘Žπ‘Ÿπ‘Ÿ π‘šπ‘š = π‘Žπ‘Ž, so direct decoding.

Classical algorithm for factoring via period finding𝑁𝑁 = π‘π‘π‘žπ‘ž can be factored via period of 𝑓𝑓 π‘₯π‘₯ = π‘Žπ‘Žπ‘₯π‘₯ (mod 𝑁𝑁)

1. Pick a random number π‘Žπ‘Ž (π‘Žπ‘Ž < 𝑁𝑁). Check that coprime with 𝑁𝑁 (if not, then great luck!).

2. Find smallest π‘Ÿπ‘Ÿ, for which π‘Žπ‘Žπ‘Ÿπ‘Ÿ ≑ 1 (mod 𝑁𝑁) (i.e., π‘Ÿπ‘Ÿ is the order of π‘Žπ‘Ž).

3. If π‘Ÿπ‘Ÿ is odd, choose another π‘Žπ‘Ž and repeat (go back to Step 1).Probability of going back is ∼50%.

4. If π‘Ÿπ‘Ÿ is even, then π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 βˆ’ 1 π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 + 1 = π‘Žπ‘Žπ‘Ÿπ‘Ÿ βˆ’ 1 ≑ 0 (mod 𝑁𝑁).π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 βˆ’ 1 cannot be 0 (mod 𝑁𝑁), since π‘Ÿπ‘Ÿ is the smallest period. If π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 + 1 ≑ 0 (mod 𝑁𝑁), choose another π‘Žπ‘Ž and repeat (go back to Step 1; this is very rare).

5. Since 𝑁𝑁 = π‘π‘π‘žπ‘ž and 𝑝𝑝 & π‘žπ‘ž are primes, then π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 βˆ’ 1 is a multiple of 𝑝𝑝,and π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 + 1 is a multiple of π‘žπ‘ž (or vice versa).

Find the greatest common divisor (GCD) of 𝑁𝑁 and π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 Β± 1,they will be 𝑝𝑝 and π‘žπ‘ž.

Remarks - If 𝑝𝑝 and π‘žπ‘ž are not prime, then similar algorithm.- If π‘Ÿπ‘Ÿ is not the smallest period, then check that π‘Žπ‘Ž β„π‘Ÿπ‘Ÿ 2 βˆ’ 1 is not 0 (mod N),

otherwise choose another π‘Žπ‘Ž (very rare)

General idea of period finding by a QC (Shor’s algorithm)

After meas. of output register, the input reg. is πœ“πœ“ 𝑛𝑛 = 1π‘šπ‘šβˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 π‘₯π‘₯0 + π‘˜π‘˜π‘Ÿπ‘Ÿ 𝑛𝑛

𝑁𝑁 has 𝑛𝑛0 bits

Key: Quantum Fourier transform (QFT) can be done very efficiently

π‘ˆπ‘ˆπ‘“π‘“π»π»

π‘₯π‘₯ π‘₯π‘₯

𝑦𝑦 𝑦𝑦 βŠ• 𝑓𝑓 π‘₯π‘₯

0 𝑛𝑛

𝑓𝑓 π‘₯π‘₯ = π‘Žπ‘Žπ‘₯π‘₯(mod 𝑁𝑁)

𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻

mea

s.Q

FT

mea

sure

|0⟩

𝑛𝑛qubits

𝑛𝑛0qubits

𝑓𝑓 π‘₯π‘₯ = π‘Žπ‘Žπ‘₯π‘₯ (mod 𝑁𝑁)

Output register has 𝑛𝑛0 qubitsInput register has 𝑛𝑛 β‰₯ 2𝑛𝑛0 qubits

not needed, but easier to think

12π‘›π‘›βˆ‘π‘₯π‘₯=02π‘›π‘›βˆ’1 π‘₯π‘₯ 𝑛𝑛 0 𝑛𝑛0 ⟢

12π‘›π‘›βˆ‘π‘₯π‘₯=02π‘›π‘›βˆ’1 π‘₯π‘₯ 𝑛𝑛 𝑓𝑓(π‘₯π‘₯) 𝑛𝑛0

where π‘Ÿπ‘Ÿ is the period of 𝑓𝑓(π‘₯π‘₯) (i.e., order of π‘Žπ‘Ž), π‘šπ‘š = int[ ⁄2𝑛𝑛 π‘Ÿπ‘Ÿ] or int ⁄2𝑛𝑛 π‘Ÿπ‘Ÿ + 1

Idea: Input register state is periodic (π‘Ÿπ‘Ÿ) β‡’ Fourier transform finds this period

π‘Ÿπ‘Ÿ < 𝑁𝑁 < 2𝑛𝑛0, so π‘šπ‘š > 2𝑛𝑛0 (very many states in superposition)

For 𝑀𝑀 ∼ 2𝑛𝑛, usual Fourier transform needs ∼ 𝑀𝑀2 ∼ 2𝑛𝑛 2 operations, Fast Fourier Transform (FFT) needs ∼ 𝑀𝑀 ∼ 2𝑛𝑛 operations (actually 𝑛𝑛2𝑛𝑛),QFT needs ∼ log𝑀𝑀 2 ∼ 𝑛𝑛2 operations. (Calculation of 𝑓𝑓(π‘₯π‘₯) needs ∼ 𝑛𝑛3 operations.)

Calculation of 𝑓𝑓 π‘₯π‘₯ = π‘Žπ‘Žπ‘₯π‘₯ (mod 𝑁𝑁)

Fast classical algorithm β‡’ quantum algorithm of the same complexity

input register(𝑛𝑛 qubits)

Prepare π‘Žπ‘Ž, π‘Žπ‘Ž2, π‘Žπ‘Ž4, π‘Žπ‘Ž8, . . . (mod 𝑁𝑁), then multiply some of them, depending on the corresponding bits of π‘₯π‘₯ = π‘₯π‘₯π‘›π‘›βˆ’1. . . π‘₯π‘₯1π‘₯π‘₯0

By the way, in this algorithm the work register remains unentangled with input and output registers, so no β€œglobal” garbage collection is needed (garbage collection at each step is still necessary)

Complexity: 𝑛𝑛 steps, each contains multiplication (mod 𝑁𝑁) requiring ∼ 𝑛𝑛2 steps,so overall ∼ 𝑛𝑛3 steps

π‘₯π‘₯

work register(𝑛𝑛0 qubits)

output register(𝑛𝑛0 qubits)

π‘Žπ‘Ž π‘Žπ‘Ž2 π‘Žπ‘Ž4

1Γ— π‘Žπ‘Ž or Γ— 1, depending on π‘₯π‘₯0

Γ— π‘Žπ‘Ž2 or Γ— 1, depending on π‘₯π‘₯1

(𝑛𝑛0 ∼ 𝑛𝑛)

Quantum Fourier Transform (QFT)Discrete Fourier transform (DFT)

π‘₯π‘₯ = 0, 1, 2, . . .𝑀𝑀 βˆ’ 1 𝑔𝑔 π‘₯π‘₯ β†’ �𝑔𝑔(π‘₯π‘₯)

�𝑔𝑔 π‘₯π‘₯ = 1π‘€π‘€βˆ‘π‘¦π‘¦=0π‘€π‘€βˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ ⁄π‘₯π‘₯𝑦𝑦 𝑀𝑀𝑔𝑔(𝑦𝑦)

Inverse DFT: the same with 𝑖𝑖 β†’ βˆ’π‘–π‘–

In QC, 𝑀𝑀 = 2𝑛𝑛 (𝑛𝑛 qubits), and we do discrete Fourier transform of amplitudes:

βˆ‘π‘₯π‘₯=02π‘›π‘›βˆ’1𝑔𝑔 π‘₯π‘₯ |π‘₯π‘₯⟩ ⟢ βˆ‘π‘₯π‘₯=02π‘›π‘›βˆ’1 �𝑔𝑔 π‘₯π‘₯ |π‘₯π‘₯βŸ©π‘ˆπ‘ˆπ‘„π‘„π‘„π‘„π‘„π‘„

Therefore π‘ˆπ‘ˆπ‘„π‘„π‘„π‘„π‘„π‘„ π‘₯π‘₯ = 12𝑛𝑛

βˆ‘π‘¦π‘¦=02π‘›π‘›βˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ ⁄π‘₯π‘₯𝑦𝑦 2𝑛𝑛|π‘¦π‘¦βŸ©

- Check that unitary. For basis vectors |π‘₯π‘₯π‘™π‘™βŸ© and |π‘₯π‘₯π‘šπ‘šβŸ©, the inner product after QFT isπ‘₯π‘₯π‘™π‘™π‘ˆπ‘ˆπ‘„π‘„π‘„π‘„π‘„π‘„

† |π‘ˆπ‘ˆπ‘„π‘„π‘„π‘„π‘„π‘„π‘₯π‘₯π‘šπ‘š = 12π‘›π‘›βˆ‘π‘¦π‘¦=02π‘›π‘›βˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹(βˆ’π‘₯π‘₯𝑙𝑙+π‘₯π‘₯π‘šπ‘š) ⁄𝑦𝑦 2π‘›π‘›βŸ¨π‘¦π‘¦|π‘¦π‘¦βŸ© = 1

2𝑛𝑛2π‘›π‘›π›Ώπ›Ώπ‘™π‘™π‘šπ‘š = π›Ώπ›Ώπ‘™π‘™π‘šπ‘š.

So, the orthonormal basis is transformed into an orthonormal basis β‡’ unitary.

- Somewhat similar to 𝑛𝑛-fold Hadamard: transforms each basis vector into equal-weight superposition of all basis vectors (but instead of Β±1 for Hadamard, many phases in QFT)

Quantum Fourier Transform (cont.)

π‘ˆπ‘ˆπ‘„π‘„π‘„π‘„π‘„π‘„ π‘₯π‘₯ = 12𝑛𝑛

βˆ‘π‘¦π‘¦=02π‘›π‘›βˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ ⁄π‘₯π‘₯𝑦𝑦 2𝑛𝑛|π‘¦π‘¦βŸ©

A very simple quantum circuit exits for QFT

For π‘₯π‘₯ = π‘₯π‘₯π‘›π‘›βˆ’12π‘›π‘›βˆ’1 + π‘₯π‘₯π‘›π‘›βˆ’22π‘›π‘›βˆ’2+ . . . π‘₯π‘₯020, many digits are not important

π‘ˆπ‘ˆπ‘„π‘„π‘„π‘„π‘„π‘„ π‘₯π‘₯ = 12𝑛𝑛

βˆ‘π‘¦π‘¦π‘›π‘›βˆ’1,…𝑦𝑦0 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ ⁄π‘₯π‘₯(π‘¦π‘¦π‘›π‘›βˆ’12π‘›π‘›βˆ’1+π‘¦π‘¦π‘›π‘›βˆ’22π‘›π‘›βˆ’2+...+𝑦𝑦020) 2𝑛𝑛 π‘¦π‘¦π‘›π‘›βˆ’1 π‘¦π‘¦π‘›π‘›βˆ’2 . . . |𝑦𝑦0⟩

=12𝑛𝑛

0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘₯π‘₯ ⁄2π‘›π‘›βˆ’1 2𝑛𝑛 0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘₯π‘₯ ⁄2π‘›π‘›βˆ’2 2𝑛𝑛 . . . 0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘₯π‘₯ ⁄20 2𝑛𝑛

π‘ˆπ‘ˆπ‘„π‘„π‘„π‘„π‘„π‘„ π‘₯π‘₯ =0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹

π‘₯π‘₯02

20 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹(

π‘₯π‘₯12 +

π‘₯π‘₯022)

2. . .

0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹(π‘₯π‘₯π‘›π‘›βˆ’12 +π‘₯π‘₯π‘›π‘›βˆ’222 +...+π‘₯π‘₯02𝑛𝑛)

212

0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘₯π‘₯02 = 1

2( 0 + 1 βˆ’1 π‘₯π‘₯0) = 𝐻𝐻|π‘₯π‘₯0⟩First (most significant) qubit:

(only in computational basis)So, if we use reverse order (most significant ↔ least significant), then the only necessary operation is 𝐻𝐻 acting on qubit |π‘₯π‘₯0⟩.

Second qubit: needs 𝐻𝐻 acting on |π‘₯π‘₯1⟩ and also 1 00 exp(2πœ‹πœ‹ ⁄𝑖𝑖 22) if π‘₯π‘₯0 = 1.

Quantum Fourier Transform (cont.)

=0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹

π‘₯π‘₯02

20 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹(

π‘₯π‘₯12 +

π‘₯π‘₯022)

2. . .

0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹(π‘₯π‘₯π‘›π‘›βˆ’12 +π‘₯π‘₯π‘›π‘›βˆ’222 +...+π‘₯π‘₯02𝑛𝑛)

2

π‘…π‘…π‘˜π‘˜ ≑1 00 exp(2πœ‹πœ‹ ⁄𝑖𝑖 2π‘˜π‘˜)Let us introduce rotation operator

Two qubits

(Mermin: π‘…π‘…π‘˜π‘˜ = π‘‰π‘‰π‘˜π‘˜βˆ’1)

|π‘₯π‘₯1⟩|π‘₯π‘₯0⟩

𝑅𝑅2𝐻𝐻

|𝑦𝑦0⟩|𝑦𝑦1⟩

(reverse order)𝐻𝐻

Three qubits

|π‘₯π‘₯2⟩|π‘₯π‘₯1⟩

𝑅𝑅2𝐻𝐻

𝑦𝑦0 = οΏ½0 + 1 e2πœ‹πœ‹πœ‹πœ‹π‘₯π‘₯22 +

π‘₯π‘₯122+

π‘₯π‘₯023 2𝐻𝐻

|π‘₯π‘₯0⟩

𝑅𝑅3𝑅𝑅2

𝐻𝐻𝑦𝑦1 = οΏ½0 + 1 e2πœ‹πœ‹πœ‹πœ‹

π‘₯π‘₯12 +

π‘₯π‘₯022 2

𝑦𝑦2 = οΏ½0 + 1 e2πœ‹πœ‹πœ‹πœ‹π‘₯π‘₯02 2

again, output order is reversed

π‘ˆπ‘ˆπ‘„π‘„π‘„π‘„π‘„π‘„ π‘₯π‘₯ = 12𝑛𝑛

βˆ‘π‘¦π‘¦=02π‘›π‘›βˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ ⁄π‘₯π‘₯𝑦𝑦 2𝑛𝑛|π‘¦π‘¦βŸ©

Quantum Fourier Transform (cont.)

π‘ˆπ‘ˆπ‘„π‘„π‘„π‘„π‘„π‘„ π‘₯π‘₯ =0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹

π‘₯π‘₯02

20 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹(

π‘₯π‘₯12 +

π‘₯π‘₯022)

2. . .

0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹(π‘₯π‘₯π‘›π‘›βˆ’12 +π‘₯π‘₯π‘›π‘›βˆ’222 +...+π‘₯π‘₯02𝑛𝑛)

2

π‘…π‘…π‘˜π‘˜ = 1 00 exp(2πœ‹πœ‹ ⁄𝑖𝑖 2π‘˜π‘˜)

Four qubits

reversed order

|π‘₯π‘₯3⟩|π‘₯π‘₯2⟩

𝑅𝑅2𝐻𝐻

𝑦𝑦0𝐻𝐻

|π‘₯π‘₯1⟩

𝑅𝑅3𝑅𝑅2

𝐻𝐻𝑦𝑦1𝑦𝑦2

|π‘₯π‘₯0⟩

𝑅𝑅4𝑅𝑅3

𝑅𝑅2𝐻𝐻 𝑦𝑦3

Similar for 𝑛𝑛 qubits: need 𝑛𝑛 Hadamard gates and ⁄𝑛𝑛(𝑛𝑛 βˆ’ 1) 2 controlled-R gates. Each c-R gate can be realized with 2 CNOTs, so ∼ 𝑛𝑛2 CNOTs. (With superconducting qubits, c-R gate can be realized directly.)

c-R gates with extreme precision (∼ 2βˆ’π‘›π‘›) are actually not needed. Crude precision is sufficient (will discuss later), so gates c-π‘…π‘…π‘˜π‘˜ with π‘˜π‘˜ > 20 are not needed. Then only ∼ 20𝑛𝑛 c-R gates are needed.

= 12𝑛𝑛

βˆ‘π‘¦π‘¦=02π‘›π‘›βˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ ⁄π‘₯π‘₯𝑦𝑦 2𝑛𝑛|π‘¦π‘¦βŸ©

c-R2 c-R3 c-R4 c-R5 c-R6

Another representation of the same circuit for QFT

𝐻𝐻 𝐻𝐻 𝐻𝐻 𝐻𝐻 𝐻𝐻 𝐻𝐻

|𝑦𝑦0⟩

|𝑦𝑦1⟩

|𝑦𝑦2⟩

|𝑦𝑦3⟩

|𝑦𝑦4⟩

Symmetry of c-R gates and reversed order are naturally represented

|𝑦𝑦5⟩

Inverse QFT: time-reverse the sequence and conjugate gates (𝐻𝐻† = 𝐻𝐻, so only replace c-π‘…π‘…π‘˜π‘˜ β†’ c-π‘…π‘…π‘˜π‘˜

†)

π‘…π‘…π‘˜π‘˜ ≑1 00 exp(2πœ‹πœ‹ ⁄𝑖𝑖 2π‘˜π‘˜)

Inverse QFT in this representationyellow: 𝐻𝐻blue: c-π‘…π‘…π‘˜π‘˜green: c-π‘…π‘…π‘˜π‘˜

†

Inverse QFT using the first circuit|π‘₯π‘₯3⟩|π‘₯π‘₯2⟩

𝑅𝑅2𝐻𝐻

𝑦𝑦0𝐻𝐻

|π‘₯π‘₯1⟩

𝑅𝑅3𝑅𝑅2

𝐻𝐻𝑦𝑦1𝑦𝑦2

|π‘₯π‘₯0⟩

𝑅𝑅4𝑅𝑅3

𝑅𝑅2𝐻𝐻 𝑦𝑦3

Inverse QFT: 𝑖𝑖 β†’ βˆ’π‘–π‘–, so we would expect

|𝑦𝑦3⟩|𝑦𝑦2⟩

𝑅𝑅2†

𝐻𝐻π‘₯π‘₯0𝐻𝐻

|𝑦𝑦1⟩

𝑅𝑅3†

𝑅𝑅2†

𝐻𝐻π‘₯π‘₯1π‘₯π‘₯2

|𝑦𝑦0⟩

𝑅𝑅4†

𝑅𝑅3†

𝑅𝑅2†

𝐻𝐻 π‘₯π‘₯3On the other hand, we know that for inverse, the circuit should be time-reversed and gates should be conjugated.

QFTβˆ’1

QFT

|𝑦𝑦3⟩|𝑦𝑦2⟩ 𝑅𝑅2

† 𝐻𝐻π‘₯π‘₯0𝐻𝐻

|𝑦𝑦1⟩ 𝑅𝑅3† 𝑅𝑅2

† 𝐻𝐻π‘₯π‘₯1π‘₯π‘₯2

|𝑦𝑦0⟩ 𝑅𝑅4† 𝑅𝑅3

† 𝑅𝑅2† 𝐻𝐻 π‘₯π‘₯3

QFTβˆ’1

use symmetry of c-π‘…π‘…π‘˜π‘˜,then shift gates

Does not look the same! But actually is.

Inverse QFT (cont.)

|𝑦𝑦3⟩|𝑦𝑦2⟩

𝑅𝑅2†

𝐻𝐻π‘₯π‘₯0𝐻𝐻

|𝑦𝑦1⟩

𝑅𝑅3†

𝑅𝑅2†

𝐻𝐻π‘₯π‘₯1π‘₯π‘₯2

|𝑦𝑦0⟩

𝑅𝑅4†

𝑅𝑅3†

𝑅𝑅2†

𝐻𝐻 π‘₯π‘₯3

|𝑦𝑦3⟩|𝑦𝑦2⟩ 𝑅𝑅2

† 𝐻𝐻π‘₯π‘₯0𝐻𝐻

|𝑦𝑦1⟩ 𝑅𝑅3† 𝑅𝑅2

† 𝐻𝐻π‘₯π‘₯1π‘₯π‘₯2

|𝑦𝑦0⟩ 𝑅𝑅4† 𝑅𝑅3

† 𝑅𝑅2† 𝐻𝐻 π‘₯π‘₯3

use symmetry of c-π‘…π‘…π‘˜π‘˜

|𝑦𝑦3⟩|𝑦𝑦2⟩

𝑅𝑅2†

𝐻𝐻π‘₯π‘₯0𝐻𝐻

|𝑦𝑦1⟩

𝑅𝑅3†

𝑅𝑅2†

𝐻𝐻π‘₯π‘₯1π‘₯π‘₯2

|𝑦𝑦0⟩

𝑅𝑅4†

𝑅𝑅3†

𝑅𝑅2†

𝐻𝐻 π‘₯π‘₯3

shift some gates to the left

Measurement-based realization of QFTIn Shor’s algorithm, all qubits are measured after QFT. In this case QFT can be realized with classically-controlled π‘…π‘…π‘˜π‘˜ gates.

|π‘₯π‘₯3⟩|π‘₯π‘₯2⟩

𝑅𝑅2𝐻𝐻

𝑦𝑦0𝐻𝐻

|π‘₯π‘₯1⟩

𝑅𝑅3𝑅𝑅2

𝐻𝐻𝑦𝑦1𝑦𝑦2

|π‘₯π‘₯0⟩

𝑅𝑅4𝑅𝑅3

𝑅𝑅2𝐻𝐻 𝑦𝑦3

Usual QFT

Since c-π‘…π‘…π‘˜π‘˜ gates are symmetric, exchange control and target

|π‘₯π‘₯3⟩|π‘₯π‘₯2⟩ 𝑅𝑅2 𝐻𝐻

𝑦𝑦0𝐻𝐻

|π‘₯π‘₯1⟩ 𝑅𝑅3 𝑅𝑅2 𝐻𝐻𝑦𝑦1𝑦𝑦2

|π‘₯π‘₯0⟩ 𝑅𝑅4 𝑅𝑅3 𝑅𝑅2 𝐻𝐻 𝑦𝑦3

Step 1

Measurement-based realization of QFT (cont.)

|π‘₯π‘₯3⟩|π‘₯π‘₯2⟩ 𝑅𝑅2 𝐻𝐻

𝑦𝑦0𝐻𝐻

|π‘₯π‘₯1⟩ 𝑅𝑅3 𝑅𝑅2 𝐻𝐻

𝑦𝑦1𝑦𝑦2

|π‘₯π‘₯0⟩ 𝑅𝑅4 𝑅𝑅3 𝑅𝑅2 𝐻𝐻 𝑦𝑦3

Step 1

Step 2Measure and control classically

|π‘₯π‘₯3⟩|π‘₯π‘₯2⟩ 𝐻𝐻

𝐻𝐻

|π‘₯π‘₯1⟩ 𝐻𝐻|π‘₯π‘₯0⟩ 𝑅𝑅4

𝑦𝑦0 𝐻𝐻

meas.result 𝑦𝑦0

𝑅𝑅3𝑦𝑦0

𝑅𝑅2𝑦𝑦0 meas.

result 𝑦𝑦1

𝑅𝑅3𝑦𝑦1

𝑅𝑅2𝑦𝑦1 meas.

result 𝑦𝑦2

𝑅𝑅2𝑦𝑦2 meas.

result 𝑦𝑦3

meas. result 𝑦𝑦0meas. result 𝑦𝑦1meas. result 𝑦𝑦2meas. result 𝑦𝑦3

Because of β€œspooky action”, measurement acts back in time, so we can exchange in time measurement and control

So far we assume that gates are perfect (it is not possible experimentally for π‘…π‘…π‘˜π‘˜ with exponentially small angles). We will discuss later that precision is not a problem.

π‘…π‘…π‘˜π‘˜ ≑1 00 exp(2πœ‹πœ‹ ⁄𝑖𝑖 2π‘˜π‘˜)

Back to Shor’s algorithm (period finding)

Measure first register, probability of result 𝑦𝑦 is

π‘ˆπ‘ˆπ‘“π‘“π»π»

π‘₯π‘₯ π‘₯π‘₯

𝑦𝑦 𝑦𝑦 βŠ• 𝑓𝑓 π‘₯π‘₯

0 𝑛𝑛

𝑓𝑓 π‘₯π‘₯ = π‘Žπ‘Žπ‘₯π‘₯(mod 𝑁𝑁)

𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻

mea

s.Q

FT

mea

sure

|0⟩

𝑛𝑛qubits

𝑛𝑛0qubits

12π‘›π‘›βˆ‘π‘₯π‘₯=02π‘›π‘›βˆ’1 π‘₯π‘₯ 𝑛𝑛 0 𝑛𝑛0 ⟢

12π‘›π‘›βˆ‘π‘₯π‘₯=02π‘›π‘›βˆ’1 π‘₯π‘₯ 𝑛𝑛 𝑓𝑓(π‘₯π‘₯) 𝑛𝑛0 ⟢

1π‘šπ‘šβˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 π‘₯π‘₯0 + π‘˜π‘˜π‘Ÿπ‘Ÿ 𝑛𝑛 ⟢

π‘ˆπ‘ˆπ‘“π‘“

measure second register, result 𝑓𝑓(π‘₯π‘₯0)

period we want to find

⟢ 12π‘›π‘›βˆ‘π‘¦π‘¦=02π‘›π‘›βˆ’1 1

π‘šπ‘šβˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ π‘₯π‘₯0+π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝑦𝑦 2𝑛𝑛 𝑦𝑦 𝑛𝑛

π‘ˆπ‘ˆQFT π‘šπ‘š = int[ ⁄2𝑛𝑛 π‘Ÿπ‘Ÿ]

= 12𝑛𝑛

1π‘šπ‘šβˆ‘π‘¦π‘¦=02π‘›π‘›βˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘₯π‘₯0 ⁄𝑦𝑦 2𝑛𝑛 βˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝑦𝑦 2𝑛𝑛 𝑦𝑦 𝑛𝑛

π‘₯π‘₯0 is not important, just a phase factor

𝑝𝑝 𝑦𝑦 = πœ“πœ“ 𝑦𝑦 2 =1

2π‘›π‘›π‘šπ‘š οΏ½π‘˜π‘˜=0

π‘šπ‘šβˆ’1𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝑦𝑦 2𝑛𝑛

2

No more QM, let us see how result is related to π‘Ÿπ‘Ÿ

Shor’s algorithm (cont.)

integer𝑝𝑝 𝑦𝑦 = πœ“πœ“ 𝑦𝑦 2 =1

2π‘›π‘›π‘šπ‘š οΏ½π‘˜π‘˜=0

π‘šπ‘šβˆ’1𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝑦𝑦 2𝑛𝑛

2

Significant 𝑝𝑝(𝑦𝑦) only if all terms are in phase: 𝑦𝑦 β‰ˆ2𝑛𝑛

π‘Ÿπ‘Ÿ 𝑗𝑗Understanding via Fourier transform

|πœ“πœ“βŸ© = 1π‘šπ‘šβˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 π‘₯π‘₯0 + π‘˜π‘˜π‘Ÿπ‘Ÿ 𝑛𝑛

0 2𝑛𝑛 βˆ’ 1π‘₯π‘₯0

π‘Ÿπ‘Ÿ QFT

0 2𝑛𝑛 βˆ’ 1

2𝑛𝑛

π‘Ÿπ‘Ÿπœ“πœ“ 𝑦𝑦 2

2𝑛𝑛

π‘Ÿπ‘Ÿπ‘—π‘—

comb with period π‘Ÿπ‘Ÿ # of peaks: π‘Ÿπ‘Ÿ, height:

∼ π‘šπ‘š2

π‘šπ‘š 2𝑛𝑛= π‘šπ‘š

2𝑛𝑛= 1

π‘Ÿπ‘Ÿ

Peaks should be at integers, while ⁄2π‘Ÿπ‘Ÿ π‘Ÿπ‘Ÿ is not an integer

Measurement randomly picks one of the peaks of 𝑝𝑝 𝑦𝑦 , while we need π‘Ÿπ‘Ÿ.

Two steps next:1) Show that with a significant probability (>40%) the measured number

is the closest (<1/2) to one of multiples of ⁄2𝑛𝑛 π‘Ÿπ‘Ÿ.2) Show that in this case, from the measured number we can obtain π‘Ÿπ‘Ÿ.

Shor’s algorithm (cont.)

𝑝𝑝 𝑦𝑦 =1

2π‘›π‘›π‘šπ‘š οΏ½π‘˜π‘˜=0

π‘šπ‘šβˆ’1𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝑦𝑦 2𝑛𝑛

2

0 2𝑛𝑛 βˆ’ 1

2𝑛𝑛

π‘Ÿπ‘Ÿπ‘π‘(𝑦𝑦)

2𝑛𝑛

π‘Ÿπ‘Ÿπ‘—π‘—

1) Show that with a significant probability (>40%) the measured number is the closest (<1/2) to one of multiples of ⁄2𝑛𝑛 π‘Ÿπ‘Ÿ.

Denote the closest integer as 𝑦𝑦𝑗𝑗 = 𝑗𝑗 ⁄2𝑛𝑛 π‘Ÿπ‘Ÿ + 𝛿𝛿𝑗𝑗 , 𝛿𝛿𝑗𝑗 ≀ ⁄1 2Sum geometric series for 𝑝𝑝(𝑦𝑦𝑗𝑗)

𝑝𝑝 𝑦𝑦𝑗𝑗 =1

2π‘›π‘›π‘šπ‘šοΏ½

π‘˜π‘˜=0

π‘šπ‘šβˆ’1𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛

2

=1

2π‘›π‘›π‘šπ‘šπ‘’π‘’2πœ‹πœ‹πœ‹πœ‹π‘šπ‘šπ‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛 βˆ’ 1𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛 βˆ’ 1

2

=1

2π‘›π‘›π‘šπ‘šsin2(πœ‹πœ‹π‘šπ‘šπ‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛)sin2(πœ‹πœ‹π‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛)

β‰ˆ 2𝑛𝑛

β‰ˆ1

2π‘›π‘›π‘šπ‘šsin2(πœ‹πœ‹π›Ώπ›Ώπ‘—π‘—)

sin2(πœ‹πœ‹π‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛) β‰ˆ1π‘Ÿπ‘Ÿ

sin πœ‹πœ‹π›Ώπ›Ώπ‘—π‘—πœ‹πœ‹ 𝛿𝛿𝑗𝑗

2

β‰₯1π‘Ÿπ‘Ÿ

4πœ‹πœ‹2

very small, π‘Ÿπ‘Ÿ < 2𝑛𝑛0 β‰ͺ 2π‘›π‘›β‰ˆ ⁄4𝑛𝑛 π‘Ÿπ‘Ÿ at 𝛿𝛿𝑗𝑗 = Β± ⁄1 2

β‰ˆ π‘Ÿπ‘Ÿ peaks (𝑗𝑗2𝑛𝑛/π‘Ÿπ‘Ÿ, 𝑗𝑗 = 1, 2, . . . π‘Ÿπ‘Ÿ βˆ’ 1), so total probability that measured result is within ⁄1 2 from 𝑗𝑗2𝑛𝑛/π‘Ÿπ‘Ÿ is β‰₯ ⁄4 πœ‹πœ‹2 > 40%. Not always but quite likely.

Actually, if try both neighbors, then probability to be within ⁄1 2 from 𝑗𝑗2𝑛𝑛/π‘Ÿπ‘Ÿis > 80%, if try 4 closest neighbors, then > 90%.

Shor’s algorithm (cont.)2) How to find period π‘Ÿπ‘Ÿ from 𝑦𝑦 = 𝑗𝑗 ⁄2𝑛𝑛 π‘Ÿπ‘Ÿ + 𝛿𝛿 , where 𝛿𝛿 ≀ ⁄1 2

𝑛𝑛 is a parameter we can choose. For large enough 𝑛𝑛, the result ⁄𝑦𝑦 2𝑛𝑛 will be very close to the rational number ⁄𝑗𝑗 π‘Ÿπ‘Ÿ.

Rewrite 𝑦𝑦2𝑛𝑛

βˆ’π‘—π‘—π‘Ÿπ‘Ÿ

≀1

2𝑛𝑛+1

So, if

want to findwe know

Remember π‘Ÿπ‘Ÿ < 𝑁𝑁 < 2𝑛𝑛0

integer to factor # of bits in 𝑁𝑁

Rational numbers with denominators < 𝑁𝑁 are not closer to each other than ⁄1 𝑁𝑁2

(because β„π‘Žπ‘Ž 𝑏𝑏 βˆ’ ⁄𝑐𝑐 𝑐𝑐 β‰₯ ⁄1 𝑏𝑏𝑐𝑐)1

2𝑛𝑛+1≀

12𝑁𝑁2 , then the closest to ⁄𝑦𝑦 2𝑛𝑛 rational number

with denominator ≀ 𝑁𝑁 is ⁄𝑗𝑗 π‘Ÿπ‘Ÿ. This is why we need 𝑛𝑛 β‰₯ 2𝑛𝑛0.

How to find ⁄𝑗𝑗 π‘Ÿπ‘Ÿ: continued fractions

𝑦𝑦2𝑛𝑛

=1

𝑧𝑧0 + 1𝑧𝑧1 + 1

𝑧𝑧2+. . .

,This expansion will go through ⁄𝑗𝑗 π‘Ÿπ‘Ÿ

Theorem: If π‘₯π‘₯ is an estimate of ⁄𝑗𝑗 π‘Ÿπ‘Ÿ, π‘₯π‘₯ βˆ’ ⁄𝑗𝑗 π‘Ÿπ‘Ÿ ≀ 1/(2π‘Ÿπ‘Ÿ2), then continued fractionsgo through ⁄𝑗𝑗 π‘Ÿπ‘Ÿ (proven in N-C book, not a very short proof)

Continued fractions is a fast classical algorithm, 𝑂𝑂(𝑛𝑛03) operations

Shor’s algorithm (cont.)

So, we will find 𝑗𝑗/π‘Ÿπ‘Ÿ with a significant probability (> 40%). It is still possible that we will not find correct π‘Ÿπ‘Ÿ if 𝑗𝑗 and π‘Ÿπ‘Ÿ have common divisors.

Then we will find a divisor of π‘Ÿπ‘Ÿ instead of π‘Ÿπ‘Ÿ itself. However, the probability of finding π‘Ÿπ‘Ÿ (not its divisor) is β‰₯ 50%, and if it is not π‘Ÿπ‘Ÿ,

then it is most likely β„π‘Ÿπ‘Ÿ 2 or β„π‘Ÿπ‘Ÿ 3 (not large denominator). So, after finding π‘Ÿπ‘Ÿ0, we can try π‘Ÿπ‘Ÿ0, 2π‘Ÿπ‘Ÿ0, 3π‘Ÿπ‘Ÿ0, etc.It is important that it is easy to check classically if π‘˜π‘˜π‘Ÿπ‘Ÿ0 is a period of 𝑓𝑓(π‘₯π‘₯) or not.

Finding period π‘Ÿπ‘Ÿ

If the procedure is unsuccessful, we can run the algorithm again (with the same π‘Žπ‘Ž). If find another divider of π‘Ÿπ‘Ÿ, we can calculate Least Common Multiple (LCM); most likely if will be π‘Ÿπ‘Ÿ.

Still possible that 𝑦𝑦/2𝑛𝑛 was not the closest ⁄𝑗𝑗 π‘Ÿπ‘Ÿ, so need several trials.

So, ∼ 3 βˆ’ 10 runs of the quantum algorithm will give us the period π‘Ÿπ‘Ÿ.

Required precision of gates c-π‘…π‘…π‘˜π‘˜ in QFT

If a gate is imprecise, then πœ“πœ“ β†’ |πœ“πœ“β€²βŸ©. But if the imprecision is not too big, then the states |πœ“πœ“βŸ© and |πœ“πœ“β€²βŸ© are still close, πœ“πœ“ πœ“πœ“β€² 2 = 1 βˆ’ πœ€πœ€ with πœ€πœ€ β‰ͺ 1. Then they are not well-distinguishable (independently of what we measure). So, probability of measuring what we want does not change much.

General idea

In some sense, the operation is digital, and therefore insensitive to small analog errors.

π‘…π‘…π‘˜π‘˜ = 1 00 exp(2πœ‹πœ‹ ⁄𝑖𝑖 2π‘˜π‘˜)

For π‘˜π‘˜ > 10 it is very difficult to realize c-π‘…π‘…π‘˜π‘˜ accurately, for π‘˜π‘˜ > 20 practically impossible.Is this precision (very small angles) really necessary? No!

Required precision of gates c-π‘…π‘…π‘˜π‘˜ in QFT (cont.)Estimate of phase accuracy needed for QFT

Ideally, 𝑝𝑝 𝑦𝑦 = 12π‘›π‘›π‘šπ‘š

βˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝑦𝑦 2𝑛𝑛 2

Suppose there are phase errorsπ‘π‘πœ‘πœ‘ 𝑦𝑦 =

12π‘›π‘›π‘šπ‘š

οΏ½π‘˜π‘˜=0

π‘šπ‘šβˆ’1𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝑦𝑦 2𝑛𝑛 π‘’π‘’πœ‹πœ‹πœ‘πœ‘π‘˜π‘˜(𝑦𝑦)

2

β‰ˆ 1 + π‘–π‘–πœ‘πœ‘π‘˜π‘˜(𝑦𝑦)

can depend on both π‘˜π‘˜ and 𝑦𝑦

Assume πœ‘πœ‘π‘˜π‘˜(𝑦𝑦) ≀ πœ‘πœ‘ β‰ͺ 1As before, 𝑦𝑦𝑗𝑗 = 𝑗𝑗 ⁄2𝑛𝑛 π‘Ÿπ‘Ÿ + 𝛿𝛿𝑗𝑗 with 𝛿𝛿𝑗𝑗 ≀ ⁄1 2

π‘π‘πœ‘πœ‘ 𝑦𝑦𝑗𝑗 β‰ˆ 12π‘›π‘›π‘šπ‘š

βˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛 1 + π‘–π‘–πœ‘πœ‘π‘˜π‘˜,𝑗𝑗2β‰ˆ

for 𝑦𝑦 = 𝑦𝑦𝑗𝑗

β‰ˆ 𝑝𝑝 𝑦𝑦𝑗𝑗 + 22π‘›π‘›π‘šπ‘š

Re (βˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛 π‘–π‘–πœ‘πœ‘π‘˜π‘˜,𝑗𝑗)(βˆ‘π‘˜π‘˜β€²=0π‘šπ‘šβˆ’1 π‘’π‘’βˆ’2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜

β€²π‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛)ideal

in linear order

Even in the worst case: βˆ‘π‘˜π‘˜β€²=0

π‘šπ‘šβˆ’1 π‘’π‘’βˆ’2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜β€²π‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛 ≀ π‘šπ‘šβˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝛿𝛿𝑗𝑗 2𝑛𝑛 π‘–π‘–πœ‘πœ‘π‘˜π‘˜,𝑗𝑗 ≀ π‘šπ‘šπœ‘πœ‘ ,

So differenceis limited: π‘π‘πœ‘πœ‘ 𝑦𝑦𝑗𝑗 βˆ’ 𝑝𝑝(𝑦𝑦𝑗𝑗) ≀

22π‘›π‘›π‘šπ‘š

π‘šπ‘šπœ‘πœ‘ π‘šπ‘š =2π‘šπ‘š2𝑛𝑛

πœ‘πœ‘ β‰ˆ2π‘Ÿπ‘Ÿπœ‘πœ‘

Total difference ≀ π‘Ÿπ‘Ÿ π‘π‘πœ‘πœ‘ 𝑦𝑦𝑗𝑗 βˆ’ 𝑝𝑝 𝑦𝑦𝑗𝑗 ≀ 2πœ‘πœ‘ β‰ͺ 1 Small!

Required precision of gates c-π‘…π‘…π‘˜π‘˜ in QFT (cont.)

𝑝𝑝 𝑦𝑦 = 12π‘›π‘›π‘šπ‘š

βˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝑦𝑦 2𝑛𝑛 2

Therefore, the probability of success (i.e. the measured 𝑦𝑦 is the closest integerto 𝑗𝑗 2𝑛𝑛/π‘Ÿπ‘Ÿ) is not β‰₯ 40%, but β‰₯ 40% βˆ’ 2πœ‘πœ‘.

π‘π‘πœ‘πœ‘ 𝑦𝑦 = 12π‘›π‘›π‘šπ‘š

βˆ‘π‘˜π‘˜=0π‘šπ‘šβˆ’1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹π‘˜π‘˜π‘Ÿπ‘Ÿ ⁄𝑦𝑦 2𝑛𝑛 π‘’π‘’πœ‹πœ‹πœ‘πœ‘π‘˜π‘˜(𝑦𝑦) 2

πœ‘πœ‘π‘˜π‘˜(𝑦𝑦) ≀ πœ‘πœ‘ β‰ͺ 1ideally

Therefore the precision πœ‘πœ‘ ∼ 10% is sufficient! (digital computation)

Total probability difference ≀ π‘Ÿπ‘Ÿ π‘π‘πœ‘πœ‘ 𝑦𝑦𝑗𝑗 βˆ’ 𝑝𝑝 𝑦𝑦𝑗𝑗 ≀ 2πœ‘πœ‘with phase errors

We still cannot say that all gates with 3% accuracy is OK, because many gates for each β€œwire”

Inaccuracy scales (at most) linearly with the number of gates.

In QFT, there are ∼ 𝑛𝑛 gates π‘…π‘…π‘˜π‘˜. The gates π‘…π‘…π‘˜π‘˜ can be completely neglected if 𝑛𝑛 2πœ‹πœ‹ 2βˆ’π‘˜π‘˜ < 0.1Therefore π‘˜π‘˜π‘šπ‘šπ‘šπ‘šπ‘₯π‘₯ ∼ log2 𝑛𝑛 + 6 ∼ 20 is sufficient

Then the number of gates in QFT is not ~ 𝑛𝑛2 but only ∼ 𝑛𝑛 log(𝑛𝑛)

Precision of gates (more general discussion)

�𝑂𝑂 = supπœ“πœ“ β‰ 0

�𝑂𝑂|πœ“πœ“βŸ©|πœ“πœ“βŸ©

= supπœ“πœ“ β‰ 0

βŸ¨πœ“πœ“ �𝑂𝑂† �𝑂𝑂 πœ“πœ“βŸ©βŸ¨πœ“πœ“|πœ“πœ“βŸ©

maxIntroduce operator norm

Suppose a unitary π‘ˆπ‘ˆ is replaced with a slightly imprecise unitary π‘ˆπ‘ˆπ‘‘. The imprecision can be characterized by the norm of the difference: Ξ” = π‘ˆπ‘ˆ βˆ’ π‘ˆπ‘ˆπ‘‘ .

It is really a norm (satisfies triangle inequality)

Imprecision of a gate

Then for an imprecise sequence of gates (composition of operations), π‘ˆπ‘ˆπ‘˜π‘˜ . . .π‘ˆπ‘ˆ2π‘ˆπ‘ˆ1 ⟢ π‘ˆπ‘ˆπ‘˜π‘˜β€² . . .π‘ˆπ‘ˆ2β€²π‘ˆπ‘ˆ1β€² , we can show Ξ” ≀ βˆ‘πœ‹πœ‹ Ξ”πœ‹πœ‹The proof is step-by-step, using triangle inequality and norm-preservation by a unitary

π‘ˆπ‘ˆ2π‘ˆπ‘ˆ1 πœ“πœ“ βˆ’ π‘ˆπ‘ˆ2β€²π‘ˆπ‘ˆ1β€² πœ“πœ“ = π‘ˆπ‘ˆ2π‘ˆπ‘ˆ1 πœ“πœ“ βˆ’ π‘ˆπ‘ˆ2β€²π‘ˆπ‘ˆ1|πœ“πœ“βŸ©) + π‘ˆπ‘ˆ2β€²π‘ˆπ‘ˆ1 πœ“πœ“ βˆ’ π‘ˆπ‘ˆ2β€²π‘ˆπ‘ˆ1β€² |πœ“πœ“βŸ©) =

= (π‘ˆπ‘ˆ2βˆ’π‘ˆπ‘ˆ2β€²)π‘ˆπ‘ˆ1 πœ“πœ“ βˆ’ π‘ˆπ‘ˆ2β€²(π‘ˆπ‘ˆ1 βˆ’ π‘ˆπ‘ˆ1β€²) πœ“πœ“

π‘ˆπ‘ˆ2π‘ˆπ‘ˆ1 βˆ’ π‘ˆπ‘ˆ2β€²π‘ˆπ‘ˆ1β€² ≀ π‘ˆπ‘ˆ2 βˆ’ π‘ˆπ‘ˆ2β€² + π‘ˆπ‘ˆ1 βˆ’ π‘ˆπ‘ˆ1β€²Therefore

So, we proved that the imprecision Ξ” accumulates at most linearly with the number of gates

Precision of gates (cont.)We proved that the imprecision Ξ” accumulates at most linearly with the number of gates.

For an overall imprecision Ξ”, the difference in the probability of obtaining a certain result for a measurement is less than 2Ξ” (simple proof in N-C book, Sec. 4.5.3).

Two more important properties:

If a 1-qubit or 2-qubit gate π‘ˆπ‘ˆ has imprecision Ξ”, then the same imprecision for this gate acting on many-qubit state (i.e., gate π‘ˆπ‘ˆβŠ— οΏ½1).

Proof (for a 2-qubit gate) A multi-qubit entangled state can always be represented as

Ξ¨ = 𝛼𝛼00 00 Ξ¦00 + 𝛼𝛼01 01 Ξ¦01 + 𝛼𝛼10 10 Ξ¦10 + 𝛼𝛼11 11 Ξ¦11 ,where |Ξ¦πœ‹πœ‹π‘—π‘—βŸ© are normalized states of other qubits, 𝛼𝛼00 2 + 𝛼𝛼01 2 + 𝛼𝛼10 2 + 𝛼𝛼11 2 = 1.

A gate π‘ˆπ‘ˆ acts only on π›Όπ›Όπœ‹πœ‹π‘—π‘—, an imprecise π‘ˆπ‘ˆπ‘‘ produces π›Όπ›Όπœ‹πœ‹π‘—π‘—,in β†’ π›Όπ›Όπœ‹πœ‹π‘—π‘—β€² instead of π›Όπ›Όπœ‹πœ‹π‘—π‘—,in β†’ π›Όπ›Όπœ‹πœ‹π‘—π‘—.

+ 𝛼𝛼01β€² βˆ’ 𝛼𝛼01 01 Ξ¦01 + 𝛼𝛼10β€² βˆ’ 𝛼𝛼10 10 Ξ¦10 + 𝛼𝛼11β€² βˆ’ 𝛼𝛼11 11 Ξ¦11 || =Then π‘ˆπ‘ˆ βˆ’ π‘ˆπ‘ˆπ‘‘ = max Ξ¨β€² βˆ’ Ξ¨ = max || 𝛼𝛼00β€² βˆ’ 𝛼𝛼00 00 Ξ¦00 +

= max 𝛼𝛼00β€² βˆ’ 𝛼𝛼00 2 + 𝛼𝛼01β€² βˆ’ 𝛼𝛼01 2 + 𝛼𝛼10β€² βˆ’ 𝛼𝛼10 2 + 𝛼𝛼11β€² βˆ’ 𝛼𝛼11 2,

which is the same as when this gate acts only on two qubits. QED

Phase estimation algorithm (Kitaev)Consider a toy problem, which can be used in serious problems (period finding, etc.)

π‘ˆπ‘ˆSuppose we know an eigenstate |π‘’π‘’βŸ©, but do not know the corresponding eigenvalue 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹πœ‘πœ‘(since π‘ˆπ‘ˆ is unitary, absolute value of eigenvalue is 1)

Goal: find πœ‘πœ‘

First idea: 𝐻𝐻 𝐻𝐻 meas.

π‘ˆπ‘ˆ|π‘’π‘’βŸ© |π‘’π‘’βŸ© |π‘’π‘’βŸ© does not change, since eigenstate

0 + 12

𝑒𝑒 ⟢0 + 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹πœ‘πœ‘

2𝑒𝑒 ⟢

0 + 1 + 0 βˆ’ 1 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹πœ‘πœ‘

2𝑒𝑒 =

c-π‘ˆπ‘ˆ 𝐻𝐻

= 01 + 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹πœ‘πœ‘

2+ 1

1 βˆ’ 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹πœ‘πœ‘

2𝑒𝑒

Measure many times, find probabilities 𝑝𝑝(0) and 𝑝𝑝(1)

𝑝𝑝 0 βˆ’ 𝑝𝑝 1 = cos(2πœ‹πœ‹πœ‘πœ‘)

Phase estimation algorithm (cont.)

Now add S-gate

𝐻𝐻 𝐻𝐻 meas.

π‘ˆπ‘ˆ|π‘’π‘’βŸ© |π‘’π‘’βŸ©π‘π‘ 0 βˆ’ 𝑝𝑝 1 = cos(2πœ‹πœ‹πœ‘πœ‘)

𝑆𝑆 = 1 00 𝑖𝑖

𝐻𝐻 𝐻𝐻 meas.

π‘ˆπ‘ˆ|π‘’π‘’βŸ© |π‘’π‘’βŸ©

𝑆𝑆

𝑝𝑝 0 βˆ’ 𝑝𝑝 1 = βˆ’sin(2πœ‹πœ‹πœ‘πœ‘)

Measuring many times, we can find πœ‘πœ‘ accurately, but this is not fast (to find 𝑛𝑛 bits of πœ‘πœ‘, we need ∼ 22𝑛𝑛 measurements)

Main idea: use c-π‘ˆπ‘ˆ2, c-π‘ˆπ‘ˆ4, c-π‘ˆπ‘ˆ8, etc. to find πœ‘πœ‘ bit-by-bit (Kitaev)

Even better to use (inverse) QFT after that

Phase estimation algorithm (cont.)

𝐻𝐻

π‘ˆπ‘ˆ|π‘’π‘’βŸ© |π‘’π‘’βŸ©

State of the input register after c-π‘ˆπ‘ˆπ‘˜π‘˜ gates:

Exact result if πœ‘πœ‘ has 𝑛𝑛-bit representation 0.πœ‘πœ‘π‘›π‘›βˆ’1πœ‘πœ‘π‘›π‘›βˆ’2 . . .πœ‘πœ‘0

This is just Fourier transform of 2π‘›π‘›πœ‘πœ‘

𝐻𝐻𝐻𝐻

. . . |0⟩

|0⟩|0⟩

𝑛𝑛bits

π‘ˆπ‘ˆ2 . . . π‘ˆπ‘ˆ2π‘›π‘›βˆ’1

QFQFTβˆ’1

= QFT†

mea

sure

men

t

12𝑛𝑛

( 0 + 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹2π‘›π‘›βˆ’1πœ‘πœ‘|1⟩)( 0 + 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹2π‘›π‘›βˆ’2πœ‘πœ‘|1⟩) . . . ( 0 + 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹πœ‘πœ‘|1⟩) =

=12𝑛𝑛�

𝑦𝑦=0

2π‘›π‘›βˆ’1𝑒𝑒2πœ‹πœ‹πœ‹πœ‹πœ‘πœ‘π‘¦π‘¦ |π‘¦π‘¦βŸ©

So, apply inverse QFT to get 2π‘›π‘›πœ‘πœ‘

lower upperIf 2π‘›π‘›πœ‘πœ‘ is not integer, then some errors.Result: to find π‘šπ‘š bits of πœ‘πœ‘ with probability 1 βˆ’ πœ€πœ€, we need 𝑛𝑛 = π‘šπ‘š + log(2 + 1

2πœ€πœ€) qubits

Phase estimation algorithm (cont.)

Relation to period finding 𝑓𝑓 π‘₯π‘₯ = π‘Žπ‘Žπ‘₯π‘₯ (mod 𝑁𝑁)Define π‘ˆπ‘ˆ as multiplication by π‘Žπ‘Ž (mod N): π‘ˆπ‘ˆ 𝑦𝑦 = |π‘Žπ‘Žπ‘¦π‘¦ mod 𝑁𝑁 ⟩.

Then π‘ˆπ‘ˆπ‘Ÿπ‘Ÿ = οΏ½1 for the period π‘Ÿπ‘Ÿ, which we want to find.

Therefore eigenvalues of π‘ˆπ‘ˆ are 𝑒𝑒2πœ‹πœ‹πœ‹πœ‹ ⁄𝑗𝑗 π‘Ÿπ‘Ÿ for integer 𝑗𝑗.So, finding the phase, we learn ⁄𝑗𝑗 π‘Ÿπ‘Ÿ (as in Shor’s algorithm)Therefore, phase estimation algorithms can be used for factoring integers.

It seems that for this algorithm we need to prepare an eigenstate |π‘’π‘’βŸ©. However, any state is a linear combination of eigenstates, so it does not matter (the algorithm will randomly find one of eigenstates of π‘ˆπ‘ˆ). Natural to start with 1 (we need to avoid |0⟩).

If output register starts with |00. . 01⟩, then after c-π‘ˆπ‘ˆπ‘˜π‘˜ gates: 12π‘›π‘›βˆ‘π‘₯π‘₯=02π‘›π‘›βˆ’1 π‘₯π‘₯ |𝑓𝑓 π‘₯π‘₯ ⟩

(unitary because π‘Žπ‘Ž is coprime with 𝑁𝑁)

top related