Breaking RSA Using Shor's Algorithm
Cryptographic implications of our construction
Implications for finite field discrete logarithms
Given a generator g of an order r subgroup to , where the modulus
is prime, and an element
, the finite field discrete logarithm problem is to compute
. In what follows, we
assume r to be prime. If r is composite, the discrete logarithm problem may be decomposed into
problems in subgroups of orders dividing
, as shown by Pohlig and Hellman. For this reason,
prime order subgroups are used in cryptographic applications.
As has order
, it must be that
divides
, so
for some integer
.
The asymptotically best currently known classical algorithms for computing discrete logarithms in
subgroups of this form are generic cycle-finding algorithms, such as Pollard's ρ- and λ-algorithms, that run in time
and
, respectively, and the general number field sieve (GNFS),
that runs in subexponential time in the bit length
of
.
The idea of factoring via algebraic number fields was originally introduced by Pollard for integers on special forms. It was over time generalized, by amongst others Buhler et al., Lenstra et al. and Pollard, to factor general integers, and modified by amongst others Gordon and Schirokauer to compute discrete logarithms in finite fields. Much research effort has since been devoted to optimizing the GNFS in various respects. For an in-depth historical account of the development of the GNFS. For the best academic record.
Let z be the number of bits of security provided by the modulus with respect to classical attacks
using the GNFS. Let and
be the lengths in bits of
and
, respectively. It then suffices to
pick
to achieve
bits of classical security, as the generic cycle-finding algorithms are
then not more efficient than the GNFS.
When instantiating schemes based on the intractability of the finite field discrete logarithm
problem, one may hence choose between using a Schnorr group, for which , or a
safe-prime group, for which
. In the latter case, one may in turn choose between using
a short exponent, such that
, or a full length exponent, such that
. All
three parameterization options provide
bits of classical security.
What finite field groups are used in practice?
In practice, Schnorr groups or safe-prime groups with short exponents are often preferred over safe- prime groups with full length exponents, as the comparatively short exponents yield considerable performance improvements.
The discrete logarithm problem in Schnorr groups is of standard form, unlike the short discrete
logarithm problem in safe-prime groups, and Schnorr groups are faster to generate than safe-prime
groups. A downside to using Schnorr groups is that group elements received from untrusted parties
must be tested for membership of the order subgroup. This typically involves exponentiating
the element to the power of
, which is computationally expensive. Safe-prime groups are more
flexible than Schnorr groups, in that the exponent length may be adaptively selected depending
on the performance requirements. In more recent years, the use of safe-prime groups would appear
to have become increasingly prevalent. Some cryptographic schemes, such as the Diffie-Hellman
key agreement protocol, are agnostic to the choice of group, whereas other schemes, such as DSA,
use Schnorr groups for efficiency reasons.
The National Institute of Standards and Technology (NIST) in the United States standardizes
the use of cryptography in unclassified applications within the federal government. Up until April
of 2018, NIST recommended the use of randomly selected Schnorr groups with moduli of length
2048 bits for Diffie-Hellman key agreement. NIST changed this recommendation in the 3rd revision
of SP800-56A, and are now advocating using a fixed set of safe-prime groups with moduli of
length up to 8192 bits, with short or full length exponents. These groups were originally developed
for TLS and IKE where, again, they are used either with short of full length exponents.
Complexity estimates
To estimates the resource and time requirements for computing discrete logarithms in finite fields
for various modulus lengths , and for the aforementioned parameterization options, we need to
decide on what model to use for estimating
as a function of
. Various models have been proposed
over the years. For simplicity, we use the same model that NIST uses
in SP 800-56A. Note that NIST rounds z to
the closest multiple of eight bits.
To compute short logarithms in safe-prime groups, the best option is to use Ekerå -Håstad's algorithm that is specialized for this purpose. To compute general discrete logarithms in safe-prime or Schnorr groups, one option is to use Ekerå 's algorithm. A single correct run of these quantum algorithms suffices for the logarithm to be recovered with ≥ 99% success probability in the classical post-processing. These algorithms do not require the order of the group to be known. See Table 4 and Figure 1 for complexity estimates.
If the group order is known, a better option for computing general discrete logarithms in safe-
prime groups and Schnorr groups when not making tradeoffs is to use Shor's original algorithm,
modified to work in the order subgroup rather than in the whole multiplicative group
, and
to start with a uniform superposition of all exponent values, as opposed to superpositions of
values. Note that the latter modification is necessary to enable the use of the semi-classical Fourier
transform, qubit recycling and the windowing technique.
When using this modified version of Shor's algorithm to compute discrete logarithms, the
heuristic analysis shows that a single correct run suffices to compute the logarithm with ≥ 99%
success probability, assuming that each of the two exponent registers is padded with 5 bits, and
that a small search is performed in the classical post-processing. This implies that Shor's algo-
rithm outperforms Ekerå 's algorithm, as Shor's algorithm performs only approximately group
operations per run, compared to
operations in Ekerå 's algorithm, see Table 5 for complexity estimates. This is because Ekerå 's algorithm does not require r to be known. In fact, it computes
both
and
.
Parameters | Volume (megaqubitdays) | Qubits (megaqubitdays) | Runtime (hours) | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
n | ne | nd | nr | z | d1 | d2 | δoff | cmul | cexp | csep | Retry Risk | per run | expected | per run | per run | ||
Schnorr | 1024 | 3nr = 6z | 2z | 2z | 80 | 15 | 25 | 4 | 5 | 5 | 1024 | 10% | 0.2 | 0.2 | 9.2 | 0.4 | |
2048 | 112 | 15 | 27 | 3 | 5 | 5 | 1024 | 9% | 0.9 | 1 | 20 | 1.2 | |||||
3072 | 128 | 15 | 27 | 9 | 5 | 5 | 1024 | 18% | 2.4 | 2.9 | 29 | 2 | |||||
4096 | 152 | 17 | 29 | 7 | 4 | 5 | 1024 | 4% | 6.5 | 6.8 | 51 | 3.1 | |||||
8192 | 200 | 17 | 31 | 3 | 4 | 5 | 1024 | 5% | 38 | 40 | 110 | 8.3 | |||||
12288 | 240 | 17 | 31 | 9 | 4 | 5 | 1024 | 9% | 110 | 120 | 170 | 15 | |||||
16384 | 272 | 17 | 31 | 5 | 4 | 5 | 1024 | 17% | 210 | 250 | 220 | 23 | |||||
Safe-prime | Short | 1024 | 3nd = 6z | 2z | n-1 | 80 | 15 | 25 | 4 | 5 | 5 | 1024 | 10% | 0.2 | 0.2 | 9.2 | 0.4 |
2048 | 112 | 15 | 27 | 3 | 5 | 5 | 1024 | 9% | 0.9 | 1 | 20 | 1.2 | |||||
3072 | 128 | 15 | 27 | 9 | 5 | 5 | 1024 | 18% | 2.4 | 2.9 | 29 | 2 | |||||
4096 | 152 | 17 | 29 | 7 | 4 | 5 | 1024 | 4% | 6.5 | 6.8 | 51 | 3.1 | |||||
8192 | 200 | 17 | 31 | 3 | 4 | 5 | 1024 | 5% | 38 | 40 | 110 | 8.3 | |||||
12288 | 240 | 17 | 31 | 9 | 4 | 5 | 1024 | 9% | 110 | 120 | 170 | 15 | |||||
16384 | 272 | 17 | 31 | 5 | 4 | 5 | 1024 | 17% | 210 | 250 | 220 | 23 | |||||
Full length | 1024 | 3nr = 3(n-1) | n-1 | n-1 | 80 | 15 | 27 | 9 | 5 | 5 | 1024 | 10% | 1.1 | 1.2 | 9.7 | 2.7 | |
2048 | 112 | 17 | 29 | 6 | 4 | 5 | 1024 | 6% | 12 | 12 | 26 | 11 | |||||
3072 | 128 | 17 | 31 | 5 | 4 | 5 | 1024 | 5% | 41 | 43 | 41 | 24 | |||||
4096 | 152 | 19 | 31 | 7 | 4 | 5 | 1024 | 9% | 97 | 110 | 55 | 43 | |||||
8192 | 200 | 19 | 33 | 4 | 4 | 5 | 1024 | 8% | 960 | 1100 | 140 | 180 | |||||
12288 | 240 | 19 | 33 | 3 | 4 | 5 | 1024 | 21% | 3300 | 4100 | 200 | 390 | |||||
16384 | 272 | 21 | 35 | 4 | 4 | 5 | 1024 | 16% | 9100 | 11000 | 320 | 700 |
Table 4: Computing discrete logarithms using Ekerå -Håstad's and Ekerå 's algorithms. This table was produced by the script in the ancillary file "estimate costs.py".
Parameters | Volume (megaqubitdays) | Qubits (megaqubitdays) | Runtime (hours) | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
n | ne | nd | nr | z | d1 | d2 | δoff | cmul | cexp | csep | Retry Risk | per run | expected | per run | per run | |
Schnorr | 1024 | 2(nr+5) | 2z | 2z | 80 | 15 | 25 | 6 | 5 | 5 | 1024 | 8% | 0.1 | 0.1 | 9.2 | 0.3 |
2048 | 112 | 15 | 27 | 8 | 5 | 5 | 1024 | 6% | 0.6 | 0.7 | 20 | 0.8 | ||||
3072 | 128 | 15 | 27 | 6 | 5 | 5 | 1024 | 13% | 1.6 | 1.8 | 29 | 1.3 | ||||
4096 | 152 | 17 | 27 | 3 | 5 | 5 | 1024 | 25% | 3.3 | 4.4 | 39 | 2.1 | ||||
8192 | 200 | 17 | 29 | 5 | 4 | 5 | 1024 | 11% | 23 | 26 | 110 | 5.5 | ||||
12288 | 240 | 17 | 31 | 4 | 4 | 5 | 1024 | 8% | 68 | 74 | 170 | 10 | ||||
16384 | 272 | 17 | 31 | 5 | 4 | 5 | 1024 | 12% | 140 | 160 | 220 | 16 | ||||
Safe-prime | 1024 | 2(nr+5) | n-1 | n-1 | 80 | 15 | 27 | 3 | 5 | 5 | 1024 | 8% | 0.7 | 0.8 | 9.7 | 1.8 |
2048 | 112 | 17 | 29 | 3 | 4 | 5 | 1024 | 5% | 7.4 | 7.8 | 26 | 7 | ||||
3072 | 128 | 17 | 29 | 4 | 4 | 5 | 1024 | 12% | 25 | 29 | 38 | 16 | ||||
4096 | 152 | 17 | 31 | 4 | 4 | 5 | 1024 | 8% | 65 | 70 | 55 | 29 | ||||
8192 | 200 | 19 | 33 | 3 | 4 | 5 | 1024 | 6% | 640 | 680 | 140 | 120 | ||||
12288 | 240 | 19 | 33 | 4 | 4 | 5 | 1024 | 15% | 2200 | 2600 | 200 | 260 | ||||
16384 | 272 | 21 | 35 | 2 | 4 | 5 | 1024 | 12% | 6100 | 6900 | 320 | 470 |
Table 5: Computing discrete logarithms using Shor's algorithm modified. This
table was produced by the script in the ancillary file "estimate costs.py".
Note that for safe-prime groups, , so when
is known to the adversary then so
is
. For Schnorr groups, it may be that
is unknown to the adversary, especially if the group is
randomly selected. It may be hard to compute
classically, as it amounts to finding a
bit
prime factor of
.