Algorithm Search⌘K

Proofs: Number field sieve for discrete logarithms

These are the human proofs of Number field sieve for discrete logarithms, at full length.

Correctness of the quadratic number field sieve for discrete logarithms full

This proof shows: correctness, termination.

We prove the version of the main pseudocode, with f1=x2+a1x+a0f_1 = x^2 + a_1 x + a_0 such that O=Z[ω]=Z[x]/(f1)\mathcal{O} = \mathbb{Z}[\omega] = \mathbb{Z}[x]/(f_1) is the ring of integers of an imaginary quadratic field of class number 11, and f2=dx−cf_2 = d x - c with d≥1d \ge 1 and c2+a1cd+a0d2=pc^2 + a_1 c d + a_0 d^2 = p. Let p≥3p \ge 3 be prime, G=(Z/pZ)∗G = (\mathbb{Z}/p\mathbb{Z})^*, cyclic of order N=p−1N = p - 1, let g∈Gg \in G have order rr and let h∈Gh \in G. Let γ\gamma be the generator of line L3 and L(z)∈Z/NZL(z) \in \mathbb{Z}/N\mathbb{Z} the logarithm of z∈Gz \in G to base γ\gamma. Let ℓ=∏qe\ell = \prod q^e over the prime powers qe∥Nq^e \parallel N with q∣rq \mid r; then r∣ℓ∣Nr \mid \ell \mid N. The bound BB satisfies 1≤B≤(p−1)/21 \le B \le (p - 1)/2. For n∈Zn \in \mathbb{Z} with p∤np \nmid n we write L(n)L(n) for the logarithm of n mod pn \bmod p. For termination we treat the exponents mm of lines L9 and L13 and the column jj of line L9 as independent and uniform.

Lemma 1 (membership and the trivial target). Line L1 returns NONE exactly when h∉⟨g⟩h \notin \langle g \rangle, and line L2 is correct.

Proof. GG is cyclic, so its only subgroup of order rr is {z:zr=1}\{z : z^r = 1\}, which is ⟨g⟩\langle g \rangle. If h=1h = 1, then x=0x = 0. □\square

From now on h=gx∗h = g^{x^*} with 0≤x∗<r0 \le x^* < r, unique because gg has order rr, and h≠1h \ne 1, so r≥2r \ge 2 and p≥3p \ge 3.

Lemma 2 (the two maps). Let s=cd−1 mod ps = c d^{-1} \bmod p. Then f1(s)≡0(modp)f_1(s) \equiv 0 \pmod p, the map ρ:O→Fp\rho : \mathcal{O} \to \mathbb{F}_p, a+bω↦a+bsa + b\omega \mapsto a + b s, is a ring map, and d ρ(a+bω)≡ad+bc(modp)d \, \rho(a + b\omega) \equiv a d + b c \pmod p for all integers a,ba, b.

Proof. d2f1(c/d)=c2+a1cd+a0d2=pd^2 f_1(c/d) = c^2 + a_1 c d + a_0 d^2 = p, and 0<d<p0 < d < p, so dd is a unit modulo pp and f1(s)≡0f_1(s) \equiv 0. Since O=Z[x]/(f1)\mathcal{O} = \mathbb{Z}[x]/(f_1) and ss is a root of f1f_1 in Fp\mathbb{F}_p, the evaluation x↦sx \mapsto s defines a ring map. Finally d(a+bs)≡ad+b ds≡ad+bcd (a + b s) \equiv a d + b \, d s \equiv a d + b c. □\square

Lemma 3 (the factor bases). Every column has a nonzero image in Fp\mathbb{F}_p, so its logarithm is defined: −1-1, the primes q≤Bq \le B, the unit generator ε\varepsilon, every listed generator π\pi, and dd. Every nonzero z∈Oz \in \mathcal{O} that is a product of prime ideals of norm at most BB is εk∏πeπ\varepsilon^k \prod \pi^{e_\pi} for unique k mod ∣O∗∣k \bmod |\mathcal{O}^*| and exponents eπ≥0e_\pi \ge 0.

Proof. A prime q≤B<pq \le B < p and −1-1 are not divisible by pp, and 0<d<p0 < d < p. Units map to units. For a generator π\pi with norm ππˉ=n(π)≤B<p\pi \bar\pi = n(\pi) \le B < p, we have ρ(π)ρ(πˉ)=ρ(n(π))≠0\rho(\pi) \rho(\bar\pi) = \rho(n(\pi)) \ne 0, so ρ(π)≠0\rho(\pi) \ne 0. The ring O\mathcal{O} is a principal ideal domain, hence has unique factorization into primes up to units. The list holds exactly one generator for each prime ideal of norm at most BB: the implementation enumerates all elements of norm at most BB, keeps those of prime norm and the inert rational primes qq with q2≤Bq^2 \le B, which are all the prime elements of norm at most BB, and keeps one canonical associate of each. The unit group is finite and cyclic, generated by ε\varepsilon, so the unit factor is εk\varepsilon^k. □\square

Lemma 4 (relations). Every row (σ,eq;κ,eπ,δ;k′)(\sigma, e_q ; \kappa, e_\pi, \delta ; k') of RR satisfies σL(−1)+∑qeqL(q)+κL(ε)+∑πeπL(π)+δL(d)≡k′(modN)\sigma L(-1) + \sum_q e_q L(q) + \kappa L(\varepsilon) + \sum_\pi e_\pi L(\pi) + \delta L(d) \equiv k' \pmod N, where L(π)L(\pi) and L(ε)L(\varepsilon) are the logarithms of the images under ρ\rho.

Proof. A row from line L7 has p∤Nab=ad+bcp \nmid N_{ab} = a d + b c, Nab=(−1)σ∏qeqN_{ab} = (-1)^\sigma \prod q^{e_q}, and a+bω=εk∏πeπa + b\omega = \varepsilon^k \prod \pi^{e_\pi}. By Lemma 2, Nab≡d ρ(a+bω)N_{ab} \equiv d \, \rho(a + b\omega), which is nonzero modulo pp. Applying ρ\rho and LL to both factorizations gives σL(−1)+∑eqL(q)=L(d)+kL(ε)+∑eπL(π)\sigma L(-1) + \sum e_q L(q) = L(d) + k L(\varepsilon) + \sum e_\pi L(\pi), which is the row with κ=−k\kappa = -k, the negated eπe_\pi, δ=−1\delta = -1 and right side 00. A row from line L10 has γmwj≡(−1)σ∏qeq\gamma^m w_j \equiv (-1)^\sigma \prod q^{e_q}, where wjw_j is the image of column jj and is absent if jj is none; the balanced residue is congruent to γmwj\gamma^m w_j. Applying LL gives m+L(wj)=σL(−1)+∑eqL(q)m + L(w_j) = \sigma L(-1) + \sum e_q L(q), which is the row with −1-1 in column jj and right side mm. □\square

Lemma 5 (SOLVE). Let M=qeM = q^e with qq prime and M∣NM \mid N. If SOLVE(R,q,M)(R, q, M) returns a vector λ\lambda, then λ\lambda equals the vector of true logarithms of the columns modulo MM.

Proof. By Lemma 4, the true vector XX modulo MM satisfies every row modulo MM, because M∣NM \mid N. Lines L19 and L20 swap two rows, multiply a row by a unit modulo MM (an entry not divisible by qq is coprime to MM), or subtract a multiple of one row from another. Each operation is invertible, so the set of solutions modulo MM is unchanged, and XX is still a solution afterwards. After column jj has been processed, row jj has a 11 in column jj and every other row has 00 there, and later steps keep this. When all columns are processed, row jj reads Xj≡X_j \equiv (right side of row jj), so the returned λj\lambda_j equals XjX_j. □\square

Lemma 6 (scale). After line L11, λ\lambda is the vector of true logarithms of the columns modulo ℓ\ell.

Proof. Line L11 is passed only when every SOLVE succeeded, so Lemma 5 applies to each qe∥ℓq^e \parallel \ell. The moduli are pairwise coprime, and the Chinese remainder theorem gives a unique residue modulo ℓ\ell with these reductions. □\square

Lemma 7 (medium primes). If line L14 assigns a value to L(Qi)L(Q_i), the value is the true L(Qi) mod ℓL(Q_i) \bmod \ell.

Proof. Qi≤B2Q_i \le B^2 is a prime factor of a nonzero residue zz with ∣z∣<p/2|z| < p/2, so Qi<pQ_i < p and L(Qi)L(Q_i) is defined. Line L14 accepts (a,b)(a, b) only if p∤Nabp \nmid N_{ab}, Nab=Qik⋅(−1)σ∏qeqN_{ab} = Q_i^k \cdot (-1)^\sigma \prod q^{e_q} with gcd⁡(k,ℓ)=1\gcd(k, \ell) = 1, and a+bω=εk′∏πeπa + b\omega = \varepsilon^{k'} \prod \pi^{e_\pi}. As in Lemma 4, kL(Qi)+σL(−1)+∑eqL(q)≡L(d)+k′L(ε)+∑eπL(π)(modN)k L(Q_i) + \sigma L(-1) + \sum e_q L(q) \equiv L(d) + k' L(\varepsilon) + \sum e_\pi L(\pi) \pmod N, and so modulo ℓ\ell. Since kk is a unit modulo ℓ\ell, solving for L(Qi)L(Q_i) and replacing the column logarithms by λ\lambda, by Lemma 6, gives the value of line L14. □\square

Lemma 8 (individual logarithms). For y∈{g,h}y \in \{g, h\}, the value of line L16 is the true L(y) mod ℓL(y) \bmod \ell.

Proof. Line L15 is passed only when the balanced residue of yγmy \gamma^m equals (−1)σ∏qdq∏Qiui(-1)^\sigma \prod q^{d_q} \prod Q_i^{u_i} and every QiQ_i got a value. Then L(y)+m≡σL(−1)+∑dqL(q)+∑uiL(Qi)(modN)L(y) + m \equiv \sigma L(-1) + \sum d_q L(q) + \sum u_i L(Q_i) \pmod N, where the sign is the first entry of the rational exponent vector. Reducing modulo ℓ\ell and using Lemmas 6 and 7 gives line L16. □\square

Lemma 9 (conversion). With c=ℓ/rc = \ell / r, the residue L(g) mod ℓL(g) \bmod \ell is cuc u for an integer uu coprime to rr, the residue L(h) mod ℓL(h) \bmod \ell is divisible by cc, and (L(h)/c) u−1≡x∗(modr)(L(h)/c) \, u^{-1} \equiv x^* \pmod r.

Proof. Since gg has order rr and γ\gamma has order NN, gcd⁡(L(g),N)=N/r\gcd(L(g), N) = N / r. For each prime q∣rq \mid r with qa∥rq^a \parallel r and qe∥Nq^e \parallel N, the qq-adic valuation of L(g)L(g), taken in [0,N−1][0, N - 1], is exactly e−ae - a, which is the valuation of cc at qq, and cc has no other prime factors. Reducing modulo ℓ\ell does not change a valuation below ee, so L(g) mod ℓ=cuL(g) \bmod \ell = c u with uu coprime to rr. Next, h=gx∗h = g^{x^*} gives L(h)≡x∗cu(modℓ)L(h) \equiv x^* c u \pmod \ell, so L(h)/c≡x∗u(modr)L(h)/c \equiv x^* u \pmod r, and multiplying by u−1u^{-1} gives x∗x^*. □\square

Correctness. By Lemmas 8 and 9, line L18 returns x∗x^*. With Lemma 1, the algorithm returns x∗x^* if h∈⟨g⟩h \in \langle g \rangle and NONE otherwise.

Termination. The loop of lines L5 to L7 runs over a finite set of pairs. For the loop of lines L8 to L11, we exhibit for each column a row whose only nonzero entry is ±1\pm 1 in that column, and which line L10 appends with positive probability in each trial. For a prime q≤Bq \le B, take jj = none and γm=q\gamma^m = q: since q≤B<p/2q \le B < p/2, the balanced residue is qq itself, and the row is eq=1e_q = 1. For −1-1, take jj = none and γm=p−1\gamma^m = p - 1: the balanced residue is −1-1, and the row has σ=1\sigma = 1 and nothing else. For an algebraic column jj, take γm=wj−1\gamma^m = w_j^{-1}: then z=1z = 1, and the row has −1-1 in column jj only. With probability 11, every column eventually gets such a row, and RR eventually has at least t+10t + 10 rows. Once these rows are present, every SOLVE succeeds: the row with its only nonzero entry in column jj has entry 00 in every earlier column, so it is never a pivot for an earlier column and is never changed by the clearing steps, which subtract multiples of a pivot row only from rows with a nonzero entry in the pivot column; swaps at a column j′<jj' < j move it only among positions at least j′j', so it is still available when column jj is processed, and its entry ±1\pm 1 is a unit pivot. The implementation retries SOLVE after each new row of line L10. For the loop of lines L13 to L15, each trial has yγm=1y \gamma^m = 1 with probability 1/N1/N; then there are no QiQ_i, and line L15 is passed. Each search of line L14 is over a finite set. Hence the algorithm stops with probability 11. ■\blacksquare

Back to Number field sieve for discrete logarithms