9
4. Apply the Fourier transform over Z/NZ, giving
r
r
N
∑
y∈Z/NZ
N
r
−1
∑
j=0
ω
(s+ jr)y
N
|yi. (32)
By the identity
M−1
∑
j=0
ω
jy
M
= M δ
j,y mod M
(33)
(applied with M = N/r, so ω
jry
N
= ω
jy
M
), only the values
y ∈{0, N/r,2N/r, ...,(r−1)N/r} experience construc-
tive interference, and Eq. (
32) equals
1
√
r
r−1
∑
k=0
ω
sk
r
|kN/ri. (34)
5. Measure this state in the computational basis, giving
some integer multiple kN/r of N/r. Dividing this inte-
ger by N gives the fraction k/r, which, when reduced to
lowest terms, has r/ gcd(r,k) as its denominator.
6. Repeating the above gives a second denominator
r/ gcd(r,k
′
). If k and k
′
are relatively prime, the
least common multiple of r/ gcd(r,k) and r/ gcd(r, k
′
)
is r. The probability of this happening is at least
∏
p prime
(1−
1
p
2
) = 6/π
2
≈ 0.61, so the algorithm suc-
ceeds with constant probability.
B. Computing discrete logarithms
Let C = hgi be a cyclic group generated by an element g,
with the group operation written multiplicatively. Given an
element x ∈C, the discrete logarithm of x in C with respect to
g, denoted log
g
x, is the smallest non-negative integer ℓ such
that g
ℓ
= x. The discrete logarithm problem is the problem
of calculating log
g
x given g and x. (Notice that for additive
groups such as G = Z/pZ, the discrete log represents division:
log
g
x = x/g mod p.)
1. Discrete logarithms and cryptography
Classically, the discrete logarithm seems like a good candi-
date for a one-way function. We can efficiently compute g
ℓ
,
even if ℓ is exponentially large (in log|C|), by repeated squar-
ing. But given x, it is not immediately clear how to compute
log
g
x without checking exponentially many possibilities.
The apparent hardness of the discrete logarithm problem
is the basis of the Diffie-Hellman key exchange protocol
(
Diffie and Hellman, 1976), the earliest published public-key
cryptographic protocol. The goal of key exchange is for two
distant parties, Alice and Bob, to agree on a secret key using
only an insecure public channel. The Diffie-Hellman protocol
works as follows:
1. Alice and Bob publicly agree on a large prime p and
an integer g of high order. For simplicity, suppose they
choose a g for which hgi = (Z/pZ)
×
(i.e., a primitive
root modulo p). (In general, finding such a g might be
hard, but it can be done efficiently given certain restric-
tions on p.)
2a. Alice chooses some a ∈ Z/(p −1)Z uniformly at ran-
dom. She computes A := g
a
mod p and sends the result
to Bob (keeping a secret).
2b. Bob chooses some b ∈ Z/(p −1)Z uniformly at ran-
dom. He computes B := g
b
mod p and sends the result
to Alice (keeping b secret).
3a. Alice computes K := B
a
= g
ab
mod p.
3b. Bob computes K = A
b
= g
ab
mod p.
At the end of the protocol, Alice and Bob share a key K, and
an eavesdropper Eve has only seen p, g, A, and B.
The security of the Diffie-Hellman protocol relies on the
assumption that discrete log is hard. Clearly, if Eve can
compute discrete logarithms, she can recover a and b, and
hence the key. But it is widely believed that the discrete
logarithm problem is difficult for classical computers. The
best known algorithms for general groups, such as Pollard’s
rho algorithm and the baby-step giant-step algorithm, run in
time O(
p
|C|). For particular groups, it may be possible
to do better: for example, over (Z/pZ)
×
with p prime, the
number field sieve is conjectured to compute discrete loga-
rithms in time 2
O((log p)
1/3
(loglog p)
2/3
)
(
Gordon, 1993) (whereas
the best known rigorously analyzed algorithms run in time
2
O(
√
log ploglog p)
(Pomerance, 1987)); but this is still super-
polynomial in log p. It is suspected that breaking the Diffie-
Hellman protocol is essentially as hard as computing the dis-
crete logarithm.
6
This protocol by itself only provides a means of exchanging
a secret key, not of sending private messages. However, Alice
and Bob can subsequently use their shared key in a symmetric
encryption protocol to communicate securely. The ideas be-
hind the Diffie-Hellman protocol can also be used to directly
create public-key cryptosystems (similar in spirit to the widely
used RSA cryptosystem), such as the ElGamal protocol; see
for example (
Buchmann, 2004; Menezes et al., 1996).
2. Shor’s algorithm for discrete log
Although the problem appears to be difficult for classical
computers, quantum computers can calculate discrete loga-
rithms efficiently. Recall that we are given some element x of
a cyclic group C = hgi and we would like to calculate log
g
x,
the smallest non-negative integer ℓ such that g
ℓ
= x.
6
It is nevertheless an open question whether, given the ability to break the
protocol, Eve can calculate discrete logarithms. Some partial results on this
question are known (
den Boer, 1990; Maurer and Wolf, 1999).