Number Theory for Cryptography

The number theory behind public-key cryptography, and the algorithms that limit it. Divisibility, gcd as the least positive combination (Bézout), modular arithmetic and inverses, groups (Lagrange-style g^{|G|} = 1, exponents mod the group order, e-th powers as permutations), Z*_N and Euler's φ, the Chinese remainder theorem and computing with it. Random primes via the prime number theorem, the Fermat test and Carmichael numbers, Miller–Rabin with strong witnesses (error 2⁻ᵗ). The factoring and RSA assumptions (RSA ≤ factoring; φ(N) or d reveal the factors). Cyclic groups, element orders, generators, discrete log, CDH and DDH, why prime-order groups (Pohlig–Hellman, generators, near-uniform DH values), quadratic-residue subgroups of Z*_p for safe primes, elliptic-curve groups with explicit addition laws. Applications: one-way functions from factoring, RSA one-way permutations, a discrete-log collision-resistant hash. Attacks: Pollard p−1, Pollard rho (N^{1/4}), quadratic sieve (2^{O(√(n log n))}), number field sieve; baby-step/giant-step (√q, generically optimal), Pohlig–Hellman, discrete log in Z_N is easy, index calculus; group-size comparison for Z*_p versus elliptic curves. Worked examples and exercises verified.

· 29 min read · 5,683 words

Corresponds to Katz & Lindell, Introduction to Modern Cryptography, Chapters 7–8.

Motivation: concrete hard problems

IntuitionWhy number theory now

  1. Completing the top-down story. Private-key cryptography came from PRFs and PRPs, which come from one-way functions. Here one-way functions finally get concrete candidates: hard mathematical problems that have been studied for centuries.
  2. Public-key cryptography needs structure. Private-key primitives can be built heuristically with no number theory. Public-key schemes have no unifying primitive and can’t (yet) be built “from scratch”: they rely on specific algebraic hardness, where some trapdoor makes a problem easy and its absence makes it hard.

Efficiency is measured in the bit length ∥N∥=Θ(log⁡N)\lVert N\rVert = \Theta(\log N). An algorithm taking Θ(N)\Theta(N) steps is exponential. Algorithmic number theory cares about both sides: what is efficiently computable (exponentiation, inverses, gcd) and what seems hard (factoring, discrete log).

AssumptionProblemBest known attack (classical)
Factoringgiven N=pqN = pq, find p,qp, qnumber field sieve, 2O(n1/3(log⁡n)2/3)2^{O(n^{1/3}(\log n)^{2/3})}
RSAgiven N,e,yN, e, y, find y1/e mod Ny^{1/e}\bmod Nfactor NN
Discrete log in Zp∗\mathbb Z_p^*given g,hg, h, find log⁡gh\log_ghindex calculus / NFS, subexponential
Discrete log on elliptic curvessame, in E(Zp)E(\mathbb Z_p)generic only, Θ(q)\Theta(\sqrt q)
CDH / DDHcompute / recognise gxyg^{xy}via discrete log

Primes, divisibility and modular arithmetic

DefinitionDivisibility and primes

a∣ba\mid b if ac=bac = b for some integer cc. If a∣ba\mid b and a∣ca\mid c, then a∣Xb+Yca\mid Xb + Yc. A prime p>1p > 1 has only the divisors 1 and pp; 1 is neither prime nor composite. Fundamental theorem of arithmetic: N=∏ipieiN = \prod_ip_i^{e_i} uniquely. Division with remainder: a=qb+ra = qb + r with 0≤r<b0\le r < b, computable in polynomial time.

TheoremProposition 7.2 — Bézout

For positive a,ba, b, there exist integers X,YX, Y with Xa+Yb=gcd⁡(a,b)Xa + Yb = \gcd(a,b), and gcd⁡(a,b)\gcd(a,b) is the smallest positive such combination. Euclid’s algorithm computes gcd⁡\gcd, and extended Euclid computes X,YX, Y, both in polynomial time.

ProofThe smallest positive combination divides everything

Let dd be the least positive element of I={X^a+Y^b}I = \{\hat Xa + \hat Yb\}. Any c∈Ic\in I gives c=qd+rc = qd + r with r=c−qd∈Ir = c - qd\in I and 0≤r<d0\le r < d, so r=0r = 0 and d∣cd\mid c. In particular d∣ad\mid a and d∣bd\mid b. Any common divisor divides Xa+Yb=dXa + Yb = d, so dd is the greatest common divisor.

∎

TheoremConsequences (Propositions 7.3–7.4)

  • If c∣abc\mid ab and gcd⁡(a,c)=1\gcd(a,c) = 1, then c∣bc\mid b. In particular, p∣ab⇒p∣ap\mid ab\Rightarrow p\mid a or p∣bp\mid b. (Multiply 1=Xa+Yc1 = Xa + Yc by bb.)
  • If p∣Np\mid N, q∣Nq\mid N and gcd⁡(p,q)=1\gcd(p,q) = 1, then pq∣Npq\mid N.

DefinitionModular arithmetic

[a mod N]∈{0,…,N−1}[a\bmod N]\in\{0,\ldots,N-1\} is the remainder, and a=b mod Na = b\bmod N iff N∣(a−b)N\mid(a - b). Congruence respects ++, −-, ×\times, so reduce first, then compute: 1093028⋅190301≡28⋅1=28(mod100)1093028\cdot190301\equiv28\cdot1 = 28\pmod{100}. It does not respect division: 3⋅2=15⋅2 mod 243\cdot2 = 15\cdot2\bmod24, yet 3≠15 mod 243\ne15\bmod24.

TheoremProposition 7.7 — Invertibility

aa is invertible modulo NN iff gcd⁡(a,N)=1\gcd(a,N) = 1. The inverse is the XX in Xa+YN=1Xa + YN = 1. Example: (−3)⋅11+2⋅17=1(-3)\cdot11 + 2\cdot17 = 1, so 11−1=[−3 mod 17]=1411^{-1} = [-3\bmod17] = 14. Division by bb means multiplication by b−1b^{-1}, and cancellation then works. Addition, multiplication, inversion and exponentiation (repeated squaring) mod NN are all polynomial time.


Groups

DefinitionGroup (Def. 7.9)

A set with a binary operation satisfying closure, an identity, inverses, and associativity; abelian if also commutative. The order ∣G∣\lvert G\rvert is the number of elements. The identity and inverses are unique (Exercise 7.1). A subgroup is a subset that is a group under the same operation.

Notation: additive (g+hg + h, identity 0, inverse −g-g, repetition mgmg) or multiplicative (ghgh, identity 1, inverse g−1g^{-1}, repetition gmg^m). Results are stated multiplicatively; this is notation only.

ExampleGroups and non-groups

  • Z\mathbb Z under ++ is a group; under ×\times it is not (2 has no inverse).
  • R∖{0}\mathbb R\setminus\{0\} under ×\times is a group.
  • ZN={0,…,N−1}\mathbb Z_N = \{0,\ldots,N-1\} under addition mod NN: order NN, inverse [N−a mod N][N - a\bmod N].
  • Cancellation (Lemma 7.13): ac=bc⇒a=bac = bc\Rightarrow a = b.

TheoremTheorem 7.14 — g∣G∣=1g^{\lvert G\rvert} = 1

In a finite group of order mm, gm=1g^m = 1 for every gg.

ProofMultiplying by gg permutes the group (abelian case)

With G={g1,…,gm}G = \{g_1,\ldots,g_m\}, the elements gg1,…,ggmgg_1,\ldots,gg_m are distinct by cancellation, so they are GG again. Then ∏igi=∏i(ggi)=gm∏igi\prod_ig_i = \prod_i(gg_i) = g^m\prod_ig_i, and cancelling gives gm=1g^m = 1.

∎

TheoremCorollaries 7.15 and 7.17 — Exponent arithmetic

  • Work mod ∣G∣\lvert G\rvert in the exponent: gi=g[i mod m]g^i = g^{[i\bmod m]}. Additively, 152⋅11≡2⋅11=7(mod15)152\cdot11\equiv2\cdot11 = 7\pmod{15}.
  • ee-th powers are permutations: if gcd⁡(e,m)=1\gcd(e,m) = 1, then fe(g)=gef_e(g) = g^e is a bijection with inverse fdf_d, d=[e−1 mod m]d = [e^{-1}\bmod m], since (ge)d=g[ed mod m]=g(g^e)^d = g^{[ed\bmod m]} = g. This is RSA’s engine.

The group ZN∗\mathbb Z_N^* and Euler’s φ\varphi

DefinitionZN∗\mathbb Z_N^* (Proposition 7.18)

ZN∗={a∈{1,…,N−1}:gcd⁡(a,N)=1}\mathbb Z_N^* = \{a\in\{1,\ldots,N-1\} : \gcd(a,N) = 1\} is an abelian group under multiplication mod NN. (Closure: a prime dividing NN and abab would divide aa or bb.) Its order is Euler’s phi function φ(N)\varphi(N).

FormulaEuler’s φ\varphi (Theorem 7.19)

φ(p)=p−1,φ(pq)=(p−1)(q−1),φ(∏ipiei)=∏ipiei−1(pi−1)\varphi(p) = p - 1,\qquad\varphi(pq) = (p-1)(q-1),\qquad\varphi\Big(\prod_ip_i^{e_i}\Big) = \prod_ip_i^{e_i-1}(p_i - 1)

For N=pqN = pq: from {1,…,N−1}\{1,\ldots,N-1\}, remove the q−1q - 1 multiples of pp and the p−1p - 1 multiples of qq. Example: Z15∗={1,2,4,7,8,11,13,14}\mathbb Z_{15}^* = \{1,2,4,7,8,11,13,14\} has φ(15)=8\varphi(15) = 8, and 8−1=28^{-1} = 2.

TheoremCorollaries 7.21–7.22 — Euler and Fermat

aφ(N)=1 mod Na^{\varphi(N)} = 1\bmod N for a∈ZN∗a\in\mathbb Z_N^*, and ap−1=1 mod pa^{p-1} = 1\bmod p (Fermat). If gcd⁡(e,φ(N))=1\gcd(e,\varphi(N)) = 1, then x↦xe mod Nx\mapsto x^e\bmod N is a permutation of ZN∗\mathbb Z_N^* with inverse x↦xdx\mapsto x^d, d=e−1 mod φ(N)d = e^{-1}\bmod\varphi(N). This even holds on all of ZN\mathbb Z_N for squarefree N=pqN = pq (Exercise 7.8: apply CRT; modulo pp either p∣xp\mid x, giving 0↦00\mapsto0, or use Fermat with ed≡1 mod (p−1)ed\equiv1\bmod(p-1)).

The Chinese remainder theorem

DefinitionIsomorphisms and direct products

An isomorphism f:G→Hf : G\to H is a bijection with f(g1g2)=f(g1)f(g2)f(g_1g_2) = f(g_1)f(g_2) (G≃HG\simeq H): the same algebraic structure in a different representation. G×HG\times H has the componentwise operation.

TheoremTheorem 7.24 — Chinese remainder theorem

If N=pqN = pq with gcd⁡(p,q)=1\gcd(p,q) = 1, then

ZN≃Zp×Zq,ZN∗≃Zp∗×Zq∗,x↔([x mod p], [x mod q])\mathbb Z_N\simeq\mathbb Z_p\times\mathbb Z_q,\qquad\mathbb Z_N^*\simeq\mathbb Z_p^*\times\mathbb Z_q^*,\qquad x\leftrightarrow([x\bmod p],\ [x\bmod q])

It extends to any pairwise-coprime factorisation.

ProofInjective plus equal sizes

Units map to units: gcd⁡(x,N)=1⇒gcd⁡(x mod p,p)=1\gcd(x,N) = 1\Rightarrow\gcd(x\bmod p,p) = 1. Injective: f(x)=f(x′)f(x) = f(x') means p,q∣x−x′p, q\mid x - x', so pq∣x−x′pq\mid x - x' (Proposition 7.4), and x=x′x = x'. Same size: N=pqN = pq, so ff is a bijection. Homomorphism: (a+Nb) mod p=(a+pb) mod p(a +_N b)\bmod p = (a +_p b)\bmod p (Exercise 7.6, since p∣Np\mid N), and likewise for ×\times.

∎

ExampleZ15∗≃Z5∗×Z3∗\mathbb Z_{15}^*\simeq\mathbb Z_5^*\times\mathbb Z_3^* (Example 7.25)

1↔(1,1)1\leftrightarrow(1,1), 2↔(2,2)2\leftrightarrow(2,2), 4↔(4,1)4\leftrightarrow(4,1), 7↔(2,1)7\leftrightarrow(2,1), 8↔(3,2)8\leftrightarrow(3,2), 11↔(1,2)11\leftrightarrow(1,2), 13↔(3,1)13\leftrightarrow(3,1), 14↔(4,2)14\leftrightarrow(4,2): every pair appears exactly once. Then 14⋅13↔(4⋅3, 2⋅1)=(2,2)↔214\cdot13\leftrightarrow(4\cdot3,\ 2\cdot1) = (2,2)\leftrightarrow2, and indeed 182≡2(mod15)182\equiv2\pmod{15}.

AlgorithmConverting back from (xp,xq)(x_p,x_q) (when p,qp, q are known)

  1. Extended Euclid: Xp+Yq=1Xp + Yq = 1.
  2. 1p=[Yq mod N]↔(1,0)1_p = [Yq\bmod N]\leftrightarrow(1,0) and 1q=[Xp mod N]↔(0,1)1_q = [Xp\bmod N]\leftrightarrow(0,1) (precompute these once).
  3. x=[xp1p+xq1q mod N]x = [x_p1_p + x_q1_q\bmod N].

Example (N=35N = 35): 3⋅5−2⋅7=13\cdot5 - 2\cdot7 = 1 gives 1p=211_p = 21 and 1q=151_q = 15, so (4,3)↔[84+45 mod 35]=24(4,3)\leftrightarrow[84 + 45\bmod35] = 24. Check: 24≡4(mod5)24\equiv4\pmod5 and 24≡3(mod7)24\equiv3\pmod7.

ExampleExponentiation through CRT (Examples 7.29–7.30)

  • 29100 mod 3529^{100}\bmod35: 29↔(−1,1)29\leftrightarrow(-1,1), so (−1,1)100=(1,1)↔1(-1,1)^{100} = (1,1)\leftrightarrow1.
  • 1825 mod 3518^{25}\bmod35: 18↔(3,4)18\leftrightarrow(3,4). Reduce exponents mod the group orders, 25 mod 4=125\bmod4 = 1 and 25 mod 6=125\bmod6 = 1, giving (3,4)↔18(3,4)\leftrightarrow18.

Splitting into small moduli and reducing exponents mod p−1p - 1 and q−1q - 1 makes RSA decryption about 4× faster (RSA-CRT). It needs the factorisation, which only the key owner has.


Primes, factoring and RSA

Generating random primes

WarningRandom products are easy to factor

In “weak factoring” (multiply two random nn-bit integers), NN is even with probability 3/43/4, and small prime factors are common. The hardest numbers to factor have only large prime factors, so the factoring assumption uses random nn-bit primes, which must be efficiently generatable.

AlgorithmRandom nn-bit prime (Algorithm 7.34)

Repeat up to n2/cn^2/c times: p:=1∥p′p := 1\Vert p' with p′←{0,1}n−1p'\leftarrow\{0,1\}^{n-1} (so the length is exactly nn); return pp if Miller–Rabin with parameter nn says “prime”.

  • Density (prime number theorem, weak form): at least c⋅2n−1/nc\cdot2^{n-1}/n of the nn-bit numbers are prime, so each try succeeds with probability at least c/nc/n. After n2/cn^2/c tries, failure is at most (1−c/n)n2/c≤e−n(1 - c/n)^{n^2/c}\le e^{-n}.
  • Testing: one-sided randomised tests (a prime is always called prime). A deterministic polynomial test exists (AKS, 2002) but is slower, so randomised tests are used in practice.
  • Special forms (p≡3 mod 4p\equiv3\bmod4, safe primes p=2q+1p = 2q + 1): modified generators work in practice, though their analyses rely on density conjectures.

Primality testing: Miller–Rabin

AlgorithmFermat test (first attempt, Algorithm 7.35)

Pick a←{1,…,N−1}a\leftarrow\{1,\ldots,N-1\}. Output “composite” if gcd⁡(a,N)≠1\gcd(a,N)\ne1 or aN−1≠1 mod Na^{N-1}\ne1\bmod N (a witness), and repeat tt times.

LemmaLemmas 7.36–7.37 — subgroups are small

In a finite group, a nonempty subset containing 1 and closed under the operation is a subgroup (inverses come from am−1a^{m-1}). A strict subgroup has at most half the elements: a coset hˉH\bar hH is disjoint from HH and the same size.

TheoremTheorem 7.38 — one witness means many

If any witness exists, the non-witnesses form a strict subgroup of ZN∗\mathbb Z_N^*, so at least half of ZN∗\mathbb Z_N^* are witnesses. Each round then catches NN with probability at least 12\frac12, giving error at most 2−t2^{-t}.

WarningCarmichael numbers

Infinitely many composites (for example 561) have no Fermat witnesses at all. The Fermat test is not enough.

DefinitionStrong witnesses

Write N−1=2ruN - 1 = 2^ru with uu odd and look at au,a2u,…,a2rua^u, a^{2u},\ldots,a^{2^ru} (each the square of the previous). aa is a strong witness if au≠±1a^u\ne\pm1 and a2iu≠−1a^{2^iu}\ne-1 for 1≤i<r1\le i < r. A non-strong-witness’s sequence looks like (±1,1,…,1)(\pm1,1,\ldots,1) or (∗,…,∗,−1,1,…,1)(\ast,\ldots,\ast,-1,1,\ldots,1). Every Fermat witness is a strong witness.

TheoremPrimes have no strong witnesses (Lemma 7.39)

Modulo an odd prime, the only square roots of 1 are ±1\pm1: (x−1)(x+1)≡0(x-1)(x+1)\equiv0 forces p∣x∓1p\mid x\mp1. In the sequence ending at aN−1=1a^{N-1} = 1, the term just before the first 1 is a square root of 1 other than 1, hence −1-1.

TheoremTheorem 7.40 — Many strong witnesses for odd composites that are not prime powers

Let ii be the largest index for which some non-strong-witness has a2iu=−1a^{2^iu} = -1 (ii exists since (−1)u=−1(-1)^u = -1). Define Bad‾={a:a2iu=±1}\overline{\mathrm{Bad}} = \{a : a^{2^iu} = \pm1\}.

  • It contains all non-strong-witnesses.
  • It is a subgroup (closed under products).
  • It is strict: write N=N1N2N = N_1N_2 with coprime factors. Take aa with a2iu=−1↔(−1,−1)a^{2^iu} = -1\leftrightarrow(-1,-1) and set b↔(a1,1)b\leftrightarrow(a_1,1). Then b2iu↔(−1,1)b^{2^iu}\leftrightarrow(-1,1), which is neither 11 nor −1-1.

So at least half of ZN∗\mathbb Z_N^* are strong witnesses.

AlgorithmMiller–Rabin (Algorithm 7.44; Theorem 7.33)

Even NN: composite. Perfect power: composite (check N^e=N\hat N^e = N for e≤∥N∥+1e\le\lVert N\rVert + 1 by binary search; Exercise 7.9). Otherwise write N−1=2ruN - 1 = 2^ru and repeat tt times: random aa; “composite” if gcd⁡(a,N)≠1\gcd(a,N)\ne1 or aa is a strong witness. A prime always passes; a composite passes with probability at most 2−t2^{-t}.

The factoring and RSA assumptions

DefinitionFactoring assumption (Def. 7.45)

GenModulus(1n)\mathrm{GenModulus}(1^n) outputs (N,p,q)(N,p,q) with N=pqN = pq and p,qp, q nn-bit primes. Factoring is hard relative to it if every ppt A\mathcal A, given NN, outputs p′,q′>1p', q' > 1 with p′q′=Np'q' = N only with negligible probability.

DefinitionRSA assumption (Def. 7.46)

GenRSA(1n)\mathrm{GenRSA}(1^n) outputs (N,e,d)(N,e,d) with gcd⁡(e,φ(N))=1\gcd(e,\varphi(N)) = 1 and ed≡1 mod φ(N)ed\equiv1\bmod\varphi(N) (Algorithm 7.47: generate a modulus, choose ee, set d=e−1 mod φ(N)d = e^{-1}\bmod\varphi(N)). RSA is hard if, given N,eN, e and uniform y∈ZN∗y\in\mathbb Z_N^*, every ppt A\mathcal A finds xx with xe=y mod Nx^e = y\bmod N only with negligible probability.

ImportantRSA is no harder than factoring, and maybe easier

  • Trapdoor: knowing p,qp, q gives φ(N)\varphi(N), then dd, then ydy^d. So hard RSA implies hard factoring.
  • Equivalences: computing φ(N)\varphi(N) is as hard as factoring (Exercise 7.11: p+q=N−φ(N)+1p + q = N - \varphi(N) + 1 and pq=Npq = N, so p,qp, q are roots of z2−(N−φ+1)z+Nz^2 - (N - \varphi + 1)z + N). Knowing dd also reveals the factorisation (Exercise 7.12 for e=3e = 3: 3d−1=kφ(N)3d - 1 = k\varphi(N) with k∈{1,2}k\in\{1,2\}, so try both).
  • Gap: RSA might be solvable without computing φ\varphi or dd, so “RSA ⟺ factoring” is unproven.

Pure factoring lacks a convenient trapdoor structure for building schemes; RSA’s asymmetry (easy with the trapdoor φ(N)\varphi(N), hard without) is what public-key schemes need.


Cyclic groups and discrete-log assumptions

DefinitionOrder, generators, cyclic groups

⟨g⟩={g0,g1,…}\langle g\rangle = \{g^0, g^1,\ldots\} is the subgroup generated by gg. The order of gg is the least i>0i > 0 with gi=1g^i = 1, and ∣⟨g⟩∣=i\lvert\langle g\rangle\rvert = i. GG is cyclic if some gg (a generator) has order ∣G∣\lvert G\rvert. Cyclic groups usually have several generators.

TheoremPropositions 7.49–7.52 and Theorem 7.53 — Orders

  • gx=gy  ⟺  x≡y mod ord(g)g^x = g^y\iff x\equiv y\bmod\mathrm{ord}(g).
  • ord(g)\mathrm{ord}(g) divides ∣G∣\lvert G\rvert (Lagrange for cyclic subgroups).
  • Prime order ⇒ cyclic, and every non-identity element is a generator.
  • Zp∗\mathbb Z_p^* is cyclic for prime pp (but has non-prime order p−1p - 1).

ExampleOrders in practice

  • Z15\mathbb Z_{15} (additive): 1 and 2 generate; 3 has order 5 ({0,3,6,9,12}\{0,3,6,9,12\}); 10 has order 3. Both orders divide 15.
  • Z15∗\mathbb Z_{15}^*: ⟨2⟩={1,2,4,8}\langle2\rangle = \{1,2,4,8\}, order 4, which divides 8.
  • Z7∗\mathbb Z_7^*: ⟨2⟩={1,2,4}\langle2\rangle = \{1,2,4\}, but ⟨3⟩={1,3,2,6,4,5}\langle3\rangle = \{1,3,2,6,4,5\}, so 3 is a generator.

WarningIsomorphic is not computationally equivalent

Every cyclic group of order nn is isomorphic to Zn\mathbb Z_n via a↦gaa\mapsto g^a. But evaluating that isomorphism backwards is the discrete-log problem. Discrete log is trivial in (Zn,+)(\mathbb Z_n,+) and believed hard in Zp∗\mathbb Z_p^* or on elliptic curves: hardness depends on the representation.

Discrete log, CDH and DDH

DefinitionDiscrete logarithm (Def. 7.59)

G(1n)\mathcal G(1^n) outputs a cyclic group G\mathbb G of order qq (∥q∥=n\lVert q\rVert = n) with generator gg and efficient operations. log⁡gh\log_gh is the unique x∈Zqx\in\mathbb Z_q with gx=hg^x = h; it satisfies log⁡g(h1h2)=log⁡gh1+log⁡gh2 mod q\log_g(h_1h_2) = \log_gh_1 + \log_gh_2\bmod q. Hard if, given (G,q,g,h)(\mathbb G,q,g,h) for uniform hh, every ppt algorithm finds log⁡gh\log_gh only with negligible probability.

DefinitionDiffie–Hellman problems

DHg(gx1,gx2)=gx1x2\mathrm{DH}_g(g^{x_1},g^{x_2}) = g^{x_1x_2}.

  • CDH: compute gxyg^{xy} from gx,gyg^x, g^y.
  • DDH (Def. 7.60): distinguish (gx,gy,gxy)(g^x,g^y,g^{xy}) from (gx,gy,gz)(g^x,g^y,g^z): ∣Pr⁡[A(…,gz)=1]−Pr⁡[A(…,gxy)=1]∣≤negl(n)\lvert\Pr[\mathcal A(\ldots,g^z) = 1] - \Pr[\mathcal A(\ldots,g^{xy}) = 1]\rvert\le\mathrm{negl}(n).

Hierarchy: DL easy ⇒ CDH easy ⇒ DDH easy, so hard DDH ⇒ hard CDH ⇒ hard DL (Exercises 7.13–7.14). The converses are believed false: some groups have hard DL and CDH but easy DDH (for example Zp∗\mathbb Z_p^* itself, via quadratic residuosity).

ImportantWhy prime-order groups

  1. Discrete log is hardest there. Pohlig–Hellman reduces order q1q2q_1q_2 to orders q1q_1 and q2q_2.
  2. Generators are free. Every non-identity element generates.
  3. DH values are almost uniform (Proposition 7.61). For random x1,x2x_1, x_2, Pr⁡[DH=1]=2q−1q2\Pr[\mathrm{DH} = 1] = \frac2q - \frac1{q^2} (since x1x2≡0x_1x_2\equiv0 iff a factor is 0, as qq is prime), and Pr⁡[DH=y]=1q−1q2\Pr[\mathrm{DH} = y] = \frac1q - \frac1{q^2} for y≠1y\ne1 (unique x2=x⋅x1−1x_2 = x\cdot x_1^{-1}). That is within negligible distance of uniform.

This is heuristic support only: prime order is neither necessary nor sufficient for DDH hardness.

AlgorithmQuadratic residues modulo a safe prime (Algorithm 7.62)

Squaring mod pp is 2-to-1, so the quadratic residues QRp\mathcal{QR}_p are half of Zp∗\mathbb Z_p^* and form a subgroup. For a safe prime p=2q+1p = 2q + 1 with qq prime, QRp\mathcal{QR}_p has prime order qq, so DDH is believed hard there. Generate (p,q)(p,q), pick x≠±1x\ne\pm1, and output g=x2 mod pg = x^2\bmod p, a non-identity residue and hence a generator.

Elliptic-curve groups

DefinitionElliptic curve over Zp\mathbb Z_p (p≥5p\ge5)

E:y2=x3+Ax+B mod pE : y^2 = x^3 + Ax + B\bmod p with 4A3+27B2≠04A^3 + 27B^2\ne0 (no repeated roots). E(Zp)E(\mathbb Z_p) is the set of solutions together with the point at infinity OO. Picture the real curve, with OO at the top of every vertical line. A line meets the curve in exactly 3 points (counting tangency twice and OO for vertical lines).

ExamplePoints on y2=x3+3x+3 mod 7y^2 = x^3 + 3x + 3\bmod7 (Example 7.63)

f(x)=x3+3x+3f(x) = x^3 + 3x + 3 takes the values f(0..6)=3,0,3,4,2,3,6f(0..6) = 3, 0, 3, 4, 2, 3, 6. The quadratic residues mod 7 are {1,2,4}\{1,2,4\}.

  • f(1)=0f(1) = 0 gives the single point (1,0)(1,0);
  • f(3)=4f(3) = 4 gives (3,2)(3,2) and (3,5)(3,5);
  • f(4)=2f(4) = 2 gives (4,3)(4,3) and (4,4)(4,4).

With OO, that is 6 points.

FormulaGroup law (Claims 7.64–7.65)

Rule: P1+P2+P3=OP_1 + P_2 + P_3 = O for collinear points, OO is the identity, and −(x,y)=(x,−y)-(x,y) = (x,-y) (reflect). For P1=(x1,y1)P_1 = (x_1,y_1) and P2=(x2,y2)P_2 = (x_2,y_2), neither OO:

  • x1≠x2x_1\ne x_2: m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1};
  • doubling, P1=P2P_1 = P_2 with y1≠0y_1\ne0: m=3x12+A2y1m = \frac{3x_1^2 + A}{2y_1};

then

x3=m2−x1−x2,y3=m(x1−x3)−y1(modp)x_3 = m^2 - x_1 - x_2,\qquad y_3 = m(x_1 - x_3) - y_1\pmod p

(with x2=x1x_2 = x_1 in the doubling case). If x1=x2x_1 = x_2 with y1≠y2y_1\ne y_2, or P1=P2P_1 = P_2 with y1=0y_1 = 0, the sum is OO. This is an abelian group; associativity is tedious to verify directly and follows naturally from algebraic geometry.

NoteWhy elliptic curves

No subexponential discrete-log algorithm is known for well-chosen curves, only generic q\sqrt q ones. In practice, parameters are chosen so that E(Zp)E(\mathbb Z_p) (or a subgroup) has prime order. Schemes in this book treat the group generically (“any cyclic group where DDH is hard”), so the curve only matters at implementation time.


Applications

TheoremTheorem 7.68 — Factoring ⇒ one-way function

Let Gen use p(n)p(n) random bits. fGen(x)f_{\mathrm{Gen}}(x) runs Gen(1n;x)\mathrm{Gen}(1^n;x), using xx as the random tape with nn such that p(n)≤∣x∣<p(n+1)p(n)\le\lvert x\rvert < p(n+1), and outputs NN. A uniform xx gives exactly Gen’s distribution of moduli, and any preimage x′x' reveals the factors (rerun Gen on x′x'). Hence hard factoring ⇒ one-way ff, and hard RSA ⇒ one-way ff too.

TheoremConstruction 7.71 — The RSA one-way permutation family

Gen\mathrm{Gen}: I=⟨N,e⟩I = \langle N,e\rangle from GenRSA; DI=ZN∗D_I = \mathbb Z_N^*; Samp is uniform on ZN∗\mathbb Z_N^*; fI(x)=xe mod Nf_I(x) = x^e\bmod N. One-way iff RSA is hard, and a trapdoor permutation given dd. Discrete log also gives a one-way permutation family: x↦gx mod px\mapsto g^x\bmod p maps {1,…,p−1}\{1,\ldots,p-1\} bijectively onto Zp∗\mathbb Z_p^* (Exercise 7.17).

TheoremTheorem 7.73 — A discrete-log collision-resistant hash

With prime-order (G,q,g)(\mathbb G,q,g) and random hh as the public key,

Hs(x1,x2)=gx1hx2,x1,x2∈ZqH_s(x_1,x_2) = g^{x_1}h^{x_2},\qquad x_1,x_2\in\mathbb Z_q

is collision-resistant if discrete log is hard. (Evidence suggests collision resistance can’t be built from arbitrary OWFs or OWPs, so number theory is needed for provable CRHFs.)

ProofA collision reveals log⁡gh\log_gh

gx1hx2=gx1′hx2′g^{x_1}h^{x_2} = g^{x_1'}h^{x_2'} gives gx1−x1′=hx2′−x2g^{x_1-x_1'} = h^{x_2'-x_2}. Here Δ=x2′−x2≢0\Delta = x_2' - x_2\not\equiv0, otherwise x1=x1′x_1 = x_1' too and the inputs would be equal. Since qq is prime, Δ\Delta is invertible, so log⁡gh=(x1−x1′)Δ−1 mod q\log_gh = (x_1 - x_1')\Delta^{-1}\bmod q. (If h=1h = 1, output 0.) The reduction’s view is exactly the real key distribution, so its success equals the collision probability.

∎

ExampleToy instance and compression (Example 7.74, Exercise 7.16)

p=47p = 47, QR47\mathcal{QR}_{47} has order q=23q = 23, g=4g = 4, h=21h = 21. An 8-bit input splits into two 4-bit numbers: 11111101↦(15,13)11111101\mapsto(15,13). Then 415⋅2113≡34⋅7=238≡3(mod47)4^{15}\cdot21^{13}\equiv34\cdot7 = 238\equiv3\pmod{47}, so Hs(11111101)=000011H_s(11111101) = 000011. (Checked by hand.) Inputs are 2(n−1)2(n-1) bits and outputs n+1n + 1 bits (elements of Zp∗\mathbb Z_p^* with ∥p∥=n+1\lVert p\rVert = n + 1), so the hash compresses once n>3n > 3. Merkle–Damgård then extends it to arbitrary length (Theorem 4.12).

ExampleAn RSA-based CRHF (Exercise 7.18, Construction 7.75)

Key (N,e,y)(N,e,y); for X∈{0,1}3nX\in\{0,1\}^{3n}, H(X)=fX1(fX2(⋯fX3n(1)))H(X) = f^{X_1}(f^{X_2}(\cdots f^{X_{3n}}(1))) with f0(x)=xef^0(x) = x^e and f1(x)=yxef^1(x) = yx^e. Strip equal outer layers until the first differing bit, where ae=y bea^e = y\,b^e. Then y=(a/b)ey = (a/b)^e, so a/ba/b is the ee-th root of yy: a collision solves RSA. (Sketch.)


Algorithms for factoring (Chapter 8)

NoteWhy attacks matter

Parameter sizes come from the best known algorithms: a scheme meant to last 5 years needs NN large enough that the best factoring algorithm takes longer than that. Trial division takes O(N)O(\sqrt N), so anything interesting must beat that.

Pollard’s p−1p - 1 method

AlgorithmPollard p−1p - 1 (Algorithm 8.1)

Find y↔(1,yq)y\leftrightarrow(1,y_q) with yq≠1y_q\ne1. Then p∣y−1p\mid y - 1 but q∤y−1q\nmid y - 1, so gcd⁡(y−1,N)=p\gcd(y - 1,N) = p.

  • Choose BB with (p−1)∣B(p-1)\mid B but (q−1)∤B(q-1)\nmid B, for example B=∏i≤kpi⌊n/log⁡pi⌋B = \prod_{i\le k}p_i^{\lfloor n/\log p_i\rfloor} over small primes.
  • Set y=xB mod Ny = x^B\bmod N. Modulo pp: xB=1x^B = 1 (Fermat). Modulo qq: xB≠1x^B\ne1 whenever xqx_q has order not dividing BB, for example when it is a generator, which happens with probability φ(q−1)/(q−1)\varphi(q-1)/(q-1).

It works exactly when p−1p - 1 is smooth (all prime factors small) and q−1q - 1 is not. Defence: strong primes ((p−1)/2(p-1)/2 prime). Today’s consensus is that the cost isn’t worth it, since general-purpose algorithms are better anyway, though some schemes need strong primes for structural reasons.

Pollard’s rho method

AlgorithmPollard rho (Algorithm 8.3)

Look for a good pair: x≡x′ mod px\equiv x'\bmod p but x≢x′ mod Nx\not\equiv x'\bmod N. Then gcd⁡(x−x′,N)=p\gcd(x - x',N) = p.

  • Birthday: k≈2n/2=O(p)k\approx2^{n/2} = O(\sqrt p) random elements contain a collision mod pp with constant probability (about 1/4), but almost surely none mod NN. Testing all (k2)\binom k2 pairs would cost O(N)O(\sqrt N), no better than trial division.
  • Iterate xm=F(xm−1)x_m = F(x_{m-1}), for example F(x)=x2+bF(x) = x^2 + b with b≠0,−2b\ne0,-2. The sequence mod pp is eventually periodic (a “ρ” shape). Claim 8.2: if xi≡xj(modp)x_i\equiv x_j\pmod p with i<ji < j, then some i′<ji' < j has xi′≡x2i′x_{i'}\equiv x_{2i'}, namely the first multiple of the period at least ii. So test only gcd⁡(x2i−xi,N)\gcd(x_{2i} - x_i,N) (Floyd cycle-finding, as in the low-memory birthday attack).

Heuristically O(N1/4polylogN)O(N^{1/4}\mathrm{polylog}N), about 2∥N∥/42^{\lVert N\rVert/4}: general-purpose but still exponential. The sequence isn’t random, so a rigorous analysis is open.

The quadratic sieve

IntuitionCongruence of squares

If x2≡y2 mod Nx^2\equiv y^2\bmod N with x≢±yx\not\equiv\pm y, then N∣(x−y)(x+y)N\mid(x-y)(x+y) but divides neither factor, so gcd⁡(x−y,N)\gcd(x - y,N) is a prime factor. For N=pqN = pq, each square has four square roots, so a random “equal squares” pair is nontrivial with probability about 12\frac12.

AlgorithmQuadratic sieve (high level)

  1. Collect relations. Fix a factor base B={p1,…,pk}\mathcal B = \{p_1,\ldots,p_k\} of small primes. Find ℓ>k\ell > k values xi>Nx_i > \sqrt N with qi=xi2 mod Nq_i = x_i^2\bmod N B\mathcal B-smooth: xi2≡∏jpjei,jx_i^2\equiv\prod_jp_j^{e_{i,j}}. (The sieving that finds them is omitted.)
  2. Linear algebra mod 2. The exponent-parity matrix Γ\Gamma (ℓ×k\ell\times k, ℓ>k\ell > k) has a subset of rows summing to 0 over GF(2)\mathrm{GF}(2). The product of those relations is then (∏xi)2≡(∏jpj(∑e)/2)2\big(\prod x_i\big)^2\equiv\big(\prod_jp_j^{(\sum e)/2}\big)^2.

Running time 2O(nlog⁡n)2^{O(\sqrt{n\log n})}: subexponential. Fastest until the early 1990s, still best up to about 300-bit NN. The general number field sieve is fastest today: heuristically 2O(n1/3(log⁡n)2/3)2^{O(n^{1/3}(\log n)^{2/3})}.

ExampleFactoring N=377753N = 377753 (Example 8.4)

xxx2 mod Nx^2\bmod Nfactorisation
6206647172⋅2317^2\cdot23
621788824⋅17⋅292^4\cdot17\cdot29
6453827227⋅13⋅232^7\cdot13\cdot23
6555127223⋅13⋅17⋅292^3\cdot13\cdot17\cdot29

The product is 214⋅132⋅174⋅232⋅2922^{14}\cdot13^2\cdot17^4\cdot23^2\cdot29^2, all exponents even. So (620⋅621⋅645⋅655)2≡(27⋅13⋅172⋅23⋅29)2(620\cdot621\cdot645\cdot655)^2\equiv(2^7\cdot13\cdot17^2\cdot23\cdot29)^2, i.e. 1271942≡453352127194^2\equiv45335^2 with 127194≠±45335127194\ne\pm45335. Then gcd⁡(127194−45335, N)=751\gcd(127194 - 45335,\ N) = 751, and N=751×503N = 751\times503. (Squares and factorisation checked by hand.)


Algorithms for discrete log (Chapter 8)

NoteGeneric versus specific

Generic algorithms use only group operations (and the order qq). Specific ones exploit the representation. Brute force is O(q)O(q). Generic algorithms provably need Ω(q)\Omega(\sqrt q) (Nechaev; Shoup), and baby-step/giant-step meets this, but the bound says nothing about particular groups.

Baby-step/giant-step

AlgorithmShanks’ baby-step/giant-step (Algorithm 8.5)

With t=⌊q⌋t = \lfloor\sqrt q\rfloor:

  1. Giant steps: compute and sort g0,gt,g2t,…,g⌊q/t⌋tg^0, g^t, g^{2t},\ldots,g^{\lfloor q/t\rfloor t}, which mark the “circle” ⟨g⟩\langle g\rangle at spacing tt.
  2. Baby steps: for i=0..ti = 0..t, compute ygiyg^i and look it up. Since y=gxy = g^x lies in some gap, ygi=gktyg^i = g^{kt} for some i≤ti\le t, giving log⁡gy=kt−i mod q\log_gy = kt - i\bmod q.

Time O(q polylog q)O(\sqrt q\,\mathrm{polylog}\,q) and memory O(q)O(\sqrt q). Pollard’s rho for discrete log achieves the same time with constant memory.

Examplelog⁡217\log_217 in Z29∗\mathbb Z_{29}^* (Example 8.6)

q=28q = 28, t=5t = 5. Giant steps: 20,25,…,225=1,3,9,27,23,112^0, 2^5,\ldots,2^{25} = 1, 3, 9, 27, 23, 11. Baby steps: 17⋅2i17\cdot2^i for i=0..5i = 0..5 gives 17,5,10,20,11,2217, 5, 10, 20, 11, 22. The match 17⋅24=11=22517\cdot2^4 = 11 = 2^{25} gives log⁡217=25−4=21\log_217 = 25 - 4 = 21. Check: 221=220⋅2=46≡172^{21} = 2^{20}\cdot2 = 46\equiv17.

Pohlig–Hellman

AlgorithmPohlig–Hellman

With q=∏iqiq = \prod_iq_i pairwise coprime and ord(g)=q\mathrm{ord}(g) = q: since ord(gq/qi)=qi\mathrm{ord}(g^{q/q_i}) = q_i (Lemma 8.7),

(gq/qi)x=yq/qi⇒xi=x mod qi(g^{q/q_i})^x = y^{q/q_i}\quad\Rightarrow\quad x_i = x\bmod q_i

in a group of order qiq_i. Solve each subproblem (for example with baby-step/giant-step) and combine by CRT. Time O(polylog(q)⋅max⁡iqi)O(\mathrm{polylog}(q)\cdot\max_i\sqrt{q_i}). Prime powers reduce further, digit by digit in base pp (Exercises 8.1–8.2), to O(polylog(q)⋅max⁡pi)O(\mathrm{polylog}(q)\cdot\max\sqrt{p_i}), where the pip_i are the primes dividing qq. Smooth group order ⇒ easy discrete log, hence prime-order groups.

Examplelog⁡326\log_326 in Z31∗\mathbb Z_{31}^* (Example 8.8)

q=30=5⋅3⋅2q = 30 = 5\cdot3\cdot2.

  • (36)x=16x=266=1(3^6)^x = 16^x = 26^6 = 1, so x≡0(mod5)x\equiv0\pmod5 (16 has order 5);
  • (310)x=25x=2610=5=252(3^{10})^x = 25^x = 26^{10} = 5 = 25^2, so x≡2(mod3)x\equiv2\pmod3;
  • (315)x=30x=2615=30(3^{15})^x = 30^x = 26^{15} = 30, so xx is odd.

CRT gives x≡5(mod30)x\equiv5\pmod{30}, and indeed 35=243≡263^5 = 243\equiv26.

Discrete log in (ZN,+)(\mathbb Z_N,+) is easy

ExampleRepresentation matters

In additive ZN\mathbb Z_N, "log⁡gy\log_gy" means solving x⋅g≡yx\cdot g\equiv y. With g=1g = 1, x=yx = y. With any generator gg, gcd⁡(g,N)=1\gcd(g,N) = 1, so x=y⋅g−1 mod Nx = y\cdot g^{-1}\bmod N. This uses multiplication, a second operation beyond the group law. For non-generators, divide by d=gcd⁡(g,N)d = \gcd(g,N), solve mod N/dN/d, and lift to dd solutions (Exercise 8.3).

Index calculus

AlgorithmIndex calculus in Zp∗\mathbb Z_p^*

  1. Precompute (needs only p,gp, g; reusable): pick a factor base {p1,…,pk}\{p_1,\ldots,p_k\} and find exponents xix_i with gxi mod pg^{x_i}\bmod p smooth. Each gives a linear relation xi≡∑jei,jlog⁡gpj(modp−1)x_i\equiv\sum_je_{i,j}\log_gp_j\pmod{p-1}.
  2. Per target yy: find x∗x^* with gx∗yg^{x^*}y smooth, giving x∗+log⁡gy≡∑jej∗log⁡gpjx^* + \log_gy\equiv\sum_je^*_j\log_gp_j. Solve the linear system (care is needed because p−1p - 1 is composite).

Time 2O(nlog⁡n)2^{O(\sqrt{n\log n})}, the same as the quadratic sieve; the NFS variant reaches 2O(n1/3(log⁡n)2/3)2^{O(n^{1/3}(\log n)^{2/3})}. Specific to Zp∗\mathbb Z_p^* (smoothness of integer representatives). There is no analogue for good elliptic curves.

Examplelog⁡387\log_387 in Z101∗\mathbb Z_{101}^* (Example 8.9)

310=65=5⋅133^{10} = 65 = 5\cdot13, 312=80=24⋅53^{12} = 80 = 2^4\cdot5, 314=133^{14} = 13, and 35⋅87=32=253^5\cdot87 = 32 = 2^5. So log⁡13=14\log13 = 14, log⁡5=10−14=96\log5 = 10 - 14 = 96, and 4log⁡2=12−96≡16(mod100)4\log2 = 12 - 96\equiv16\pmod{100}. That gives log⁡2∈{4,29,54,79}\log2\in\{4,29,54,79\}; checking gives 29. Then log⁡87=5⋅29−5=140≡40(mod100)\log87 = 5\cdot29 - 5 = 140\equiv40\pmod{100}. (Relations checked by hand.)

ImportantWhy elliptic curves are smaller

A 512-bit pp: NFS costs about 25121/3⋅92/3≈28⋅4.32^{512^{1/3}\cdot9^{2/3}}\approx2^{8\cdot4.3}, roughly 2322^{32}–2352^{35}. A prime-order elliptic curve with q≈264q\approx2^{64} costs about q=232\sqrt q = 2^{32} by the best (generic) attack. Comparable security with far smaller groups, hence faster honest operations. (Modern guidance: about 3072-bit RSA or Zp∗\mathbb Z_p^* versus about 256-bit curves for 128-bit security. 512-bit Diffie–Hellman was actually broken in practice by the 2015 Logjam attack. And all of factoring, discrete log and EC discrete log fall to Shor’s quantum algorithm.)


Exercises (selected)

ExampleShort answers

  • 7.2: {1}∪{2,4,6,…}⊂R×\{1\}\cup\{2,4,6,\ldots\}\subset\mathbb R^\times is closed, contains 1, but has no inverses. Proposition 7.36 needs finiteness.
  • 7.3: ⟨g⟩\langle g\rangle is a subgroup in finite groups (inverses gi−1g^{i-1}). In infinite groups {g0,g1,…}\{g^0,g^1,\ldots\} needn’t be: {2k:k≥0}⊂Q×\{2^k : k\ge0\}\subset\mathbb Q^\times lacks 12\frac12.
  • 7.6: p∣N⇒[[X mod N] mod p]=[X mod p]p\mid N\Rightarrow[[X\bmod N]\bmod p] = [X\bmod p], but [[X mod p] mod N][[X\bmod p]\bmod N] needn’t equal [X mod N][X\bmod N]: take X=NX = N and p∤Np\nmid N-free cases, e.g. p=3p = 3, N=6N = 6, X=4X = 4 gives 11 versus 44.
  • 7.9: if N=N^eN = \hat N^e with N^≥2\hat N\ge2, then e≤log⁡2N≤∥N∥e\le\log_2N\le\lVert N\rVert. For each ee, binary-search N^\hat N, giving polynomial time overall.
  • 7.11–7.12: see the RSA box above.
  • 8.3: ab≡c mod Nab\equiv c\bmod N with gcd⁡(b,N)=d\gcd(b,N) = d forces d∣cd\mid c and a(b/d)≡c/d mod N/da(b/d)\equiv c/d\bmod N/d with gcd⁡(b/d,N/d)=1\gcd(b/d,N/d) = 1. Invert, then the dd lifts a+k(N/d)a + k(N/d) are all solutions.

(Answers worked here.)


Quick reference

ObjectStatementNote
BézoutXa+Yb=gcd⁡(a,b)Xa + Yb = \gcd(a,b)extended Euclid, polynomial time
Inverse mod NNexists iff gcd⁡(a,N)=1\gcd(a,N) = 111−1≡14(mod17)11^{-1}\equiv14\pmod{17}
g∣G∣=1g^{\lvert G\rvert} = 1exponents mod ∣G∣\lvert G\rvertee-th power permutes if gcd⁡(e,∣G∣)=1\gcd(e,\lvert G\rvert) = 1
φ\varphiφ(pq)=(p−1)(q−1)\varphi(pq) = (p-1)(q-1); ∏pe−1(p−1)\prod p^{e-1}(p-1)Euler/Fermat
CRTZN∗≃Zp∗×Zq∗\mathbb Z_N^*\simeq\mathbb Z_p^*\times\mathbb Z_q^*x=xp1p+xq1qx = x_p1_p + x_q1_q
Prime generationrandom nn-bit + Miller–Rabin, O(n2)O(n^2) triesdensity ≥c/n\ge c/n
Miller–Rabinstrong witnesses ≥ half for non-prime-power compositeserror 2−t2^{-t}
Factoring / RSAfind p,qp, q / find y1/ey^{1/e}RSA ≤ factoring; φ\varphi or dd ⇒ factors
Ordersdivide ∣G∣\lvert G\rvert; prime order ⇒ every non-identity element generates
DL, CDH, DDHDDH hard ⇒ CDH hard ⇒ DL hardprime-order groups preferred
Safe-prime subgroupQRp\mathcal{QR}_p, p=2q+1p = 2q + 1, order qqg=x2g = x^2
Elliptic curveschord-and-tangent law, OO identityonly generic attacks
Applicationsfactoring ⇒ OWF; RSA ⇒ OWP family; DL ⇒ CRHF gx1hx2g^{x_1}h^{x_2}
Pollard p−1p - 1gcd⁡(xB−1,N)\gcd(x^B - 1,N)smooth p−1p - 1
Pollard rhogcd⁡(x2i−xi,N)\gcd(x_{2i} - x_i,N)O(N1/4)O(N^{1/4})
Quadratic sievesmooth relations + GF(2) linear algebra2O(nlog⁡n)2^{O(\sqrt{n\log n})}
NFSfactoring and DL in Zp∗\mathbb Z_p^*2O(n1/3(log⁡n)2/3)2^{O(n^{1/3}(\log n)^{2/3})}
BSGSgiant steps gktg^{kt}, baby steps ygiyg^iO(q)O(\sqrt q), generically optimal
Pohlig–HellmanCRT over the factors of the orderO(max⁡pi)O(\max\sqrt{p_i})
Index calculussmooth relations for log⁡\log of the factor basesubexponential, Zp∗\mathbb Z_p^* only

Facts to keep to hand

  • Modular arithmetic is efficient; structure gives trapdoors. gcd, inverses and exponentiation are polynomial time. Exponents live modulo the group order, so knowing φ(N)\varphi(N) (equivalently the factorisation) inverts x↦xex\mapsto x^e. RSA’s trapdoor is exactly that asymmetry, and CRT makes computing with known factors fast.
  • Primes are plentiful and testable. About 1/n1/n of nn-bit numbers are prime, and Miller–Rabin’s strong witnesses defeat Carmichael numbers, giving error 2−t2^{-t}. So random moduli and safe-prime groups are easy to generate.
  • Cyclic groups host discrete log, CDH and DDH. Prefer prime order (Pohlig–Hellman, easy generators, near-uniform DH values): safe-prime residue subgroups of Zp∗\mathbb Z_p^*, or elliptic curves where only generic q\sqrt q attacks are known. Hardness depends on representation, not abstract structure.
  • Known attacks set the key sizes. Factoring and discrete log in Zp∗\mathbb Z_p^* fall to subexponential sieves (smooth relations plus linear algebra), while elliptic-curve discrete log resists all but generic attacks. That is why curves achieve the same security with much smaller parameters.

References

  • Katz & Lindell, Introduction to Modern Cryptography — Chapters 7–8
  • Shoup, A Computational Introduction to Number Theory and Algebra (2005)
  • Crandall & Pomerance, Prime Numbers: A Computational Perspective (2005)
  • Washington, Elliptic Curves: Number Theory and Cryptography (2008)

← All notes