Algorithm Search⌘K

Proofs: Coppersmith's algorithm for discrete logarithms in GF(2^n)

These are the human proofs of Coppersmith's algorithm for discrete logarithms in GF(2^n), at full length.

Correctness of Coppersmith's algorithm full

This proof shows: correctness, termination.

Let f=xn+f1f = x^n + f_1 be irreducible over F2\mathbb{F}_2, so K=F2[x]/(f)K = \mathbb{F}_2[x]/(f) is the field with 2n2^n elements and K∗K^* is cyclic of order N=2n−1N = 2^n - 1. Let g∈K∗g \in K^* have order rr and let h∈K∗h \in K^*. Let γ\gamma be the generator of line L3 and L(y)∈Z/NZL(y) \in \mathbb{Z}/N\mathbb{Z} the logarithm of y∈K∗y \in K^* to base γ\gamma, so L(y1y2)=L(y1)+L(y2)L(y_1 y_2) = L(y_1) + L(y_2). A polynomial a∈F2[x]a \in \mathbb{F}_2[x] with f∤af \nmid a has a nonzero image in KK, and we write L(a)L(a) for the logarithm of that image. 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, and ℓ\ell is odd since NN is odd. For termination we treat the exponents mm of lines L9 and L13 as independent and uniform on {0,…,N−1}\{0, \dots, N - 1\}.

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. K∗K^* is cyclic, so its only subgroup of order rr is {y:yr=1}\{y : y^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.

Lemma 2 (the Frobenius identity). For all A,B∈F2[x]A, B \in \mathbb{F}_2[x] and C=Axl+BC = A x^l + B, with 2kl≥n2^k l \ge n, the polynomial D=A(x2k) x2kl−nf1+B(x2k)D = A(x^{2^k}) \, x^{2^k l - n} f_1 + B(x^{2^k}) satisfies C2k≡D(modf)C^{2^k} \equiv D \pmod f.

Proof. In a commutative ring of characteristic 22, (u+v)2=u2+v2(u + v)^2 = u^2 + v^2, and by induction (u+v)2k=u2k+v2k(u + v)^{2^k} = u^{2^k} + v^{2^k} and (uv)2k=u2kv2k(uv)^{2^k} = u^{2^k} v^{2^k}. For a=∑aixia = \sum a_i x^i with ai∈{0,1}a_i \in \{0, 1\}, this gives a2k=∑aix2ki=a(x2k)a^{2^k} = \sum a_i x^{2^k i} = a(x^{2^k}). So C2k=A(x2k) x2kl+B(x2k)C^{2^k} = A(x^{2^k}) \, x^{2^k l} + B(x^{2^k}). Since f=xn+f1f = x^n + f_1, we have xn≡f1(modf)x^n \equiv f_1 \pmod f, and x2kl=x2kl−nxn≡x2kl−nf1x^{2^k l} = x^{2^k l - n} x^n \equiv x^{2^k l - n} f_1. □\square

Lemma 3 (relations). Every pair (e,k′)(e, k') in RR satisfies ∑s∈SesL(s)≡k′(modN)\sum_{s \in S} e_s L(s) \equiv k' \pmod N.

Proof. Every s∈Ss \in S has degree at most b≤n−1b \le n - 1, so f∤sf \nmid s and L(s)L(s) is defined. A row from line L7 comes from a pair with f∤Cf \nmid C, C=∏scsC = \prod s^{c_s} and D=∏sdsD = \prod s^{d_s} in F2[x]\mathbb{F}_2[x]. By Lemma 2, D≡C2k(modf)D \equiv C^{2^k} \pmod f, which is nonzero in KK since CC is. Applying LL gives ∑sdsL(s)=2k∑scsL(s)\sum_s d_s L(s) = 2^k \sum_s c_s L(s), that is, ∑s(2kcs−ds)L(s)≡0\sum_s (2^k c_s - d_s) L(s) \equiv 0, which is the row (2kc−d,0)(2^k c - d, 0). Line L4 takes l=⌈n/2k⌉l = \lceil n / 2^k \rceil, so 2kl≥n2^k l \ge n and Lemma 2 applies. A row from line L9 has γm≡∏ses\gamma^m \equiv \prod s^{e_s}, and applying LL gives m≡∑sesL(s)m \equiv \sum_s e_s L(s). □\square

Lemma 4 (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 λs≡L(s)(modM)\lambda_s \equiv L(s) \pmod M for every s∈Ss \in S.

Proof. By Lemma 3, the vector X=(L(s) mod M)sX = (L(s) \bmod M)_s 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, since they add multiples of rows whose entry in column jj is 00. When all columns are processed, row jj reads Xj≡X_j \equiv (right side of row jj) (modM)\pmod M, so the returned λj\lambda_j equals XjX_j. □\square

Lemma 5 (scale). After line L11, λs≡L(s)(modℓ)\lambda_s \equiv L(s) \pmod \ell for every s∈Ss \in S.

Proof. Line L11 is passed only when every SOLVE succeeded, so by Lemma 4, λs(q)≡L(s)(modqe)\lambda^{(q)}_s \equiv L(s) \pmod{q^e} for each qe∥ℓq^e \parallel \ell. These moduli are pairwise coprime, and the Chinese remainder theorem gives a unique residue modulo ℓ\ell with these reductions, which is L(s) mod ℓL(s) \bmod \ell. □\square

Lemma 6 (medium polynomials). If line L14 assigns a value to L(Gi)L(G_i), the value is the true L(Gi) mod ℓL(G_i) \bmod \ell.

Proof. Every GiG_i has degree at most min⁡(n−1,2b)<n\min(n - 1, 2b) < n, so f∤Gif \nmid G_i and L(Gi)L(G_i) is defined. Line L14 accepts (A,B)(A, B) only if f∤Cf \nmid C, C=Gia∏scsC = G_i^a \prod s^{c_s} with gcd⁡(a,ℓ)=1\gcd(a, \ell) = 1, and D=∏sds′D = \prod s^{d'_s}. By Lemma 2 and the argument of Lemma 3, 2k(aL(Gi)+∑scsL(s))≡∑sds′L(s)(modN)2^k (a L(G_i) + \sum_s c_s L(s)) \equiv \sum_s d'_s L(s) \pmod N, and so modulo ℓ\ell. Since ℓ\ell is odd, 2k2^k is a unit modulo ℓ\ell, and aa is a unit by the test. Solving, L(Gi)≡(2−k∑sds′L(s)−∑scsL(s)) a−1(modℓ)L(G_i) \equiv (2^{-k} \sum_s d'_s L(s) - \sum_s c_s L(s)) \, a^{-1} \pmod \ell, and by Lemma 5 the λs\lambda_s may replace the L(s)L(s). □\square

Lemma 7 (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 z=yγm mod fz = y \gamma^m \bmod f equals ∏sds∏Giai\prod s^{d_s} \prod G_i^{a_i} in F2[x]\mathbb{F}_2[x] and every GiG_i got a value. Then L(y)+m≡∑sdsL(s)+∑iaiL(Gi)(modN)L(y) + m \equiv \sum_s d_s L(s) + \sum_i a_i L(G_i) \pmod N. Reducing modulo ℓ\ell and using Lemmas 5 and 6 gives line L16. □\square

Lemma 8 (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 as an integer in [0,N−1][0, N - 1], is exactly e−ae - a, which is also the valuation of cc at qq; and cc has no other prime factors, since ℓ\ell has only primes dividing rr. Reducing modulo ℓ\ell does not change the valuation at qq when it is below ee, so L(g) mod ℓ=cuL(g) \bmod \ell = c u with uu prime to every q∣rq \mid r, that is, coprime to rr. Next, h=gx∗h = g^{x^*} gives L(h)≡x∗cu(modℓ)L(h) \equiv x^* c u \pmod \ell, which is divisible by cc, and dividing by cc gives L(h)/c≡x∗u(modℓ/c)L(h) / c \equiv x^* u \pmod{\ell / c}, that is, modulo rr. Multiplying by u−1u^{-1} modulo rr gives x∗x^*. □\square

Correctness. By Lemmas 7 and 8, line L18 returns x∗ mod r=x∗x^* \bmod r = 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, fix s∈Ss \in S. Each trial has γm=s\gamma^m = s with probability 1/N1/N, and then line L9 appends the row with es=1e_s = 1, all other entries 00, and right side L(s)L(s). With probability 11, every s∈Ss \in S eventually contributes such a row, and RR eventually has at least ∣S∣+10|S| + 10 rows. Once the rows include the unit vectors for all ss, every SOLVE succeeds. Indeed, the row that started as the unit vector for column jj has entry 00 in every earlier column, so it is never chosen as a pivot for an earlier column and is never changed by the clearing steps, which subtract a multiple of a pivot row only from rows with a nonzero entry in the pivot column. A swap at column j′<jj' < j moves only rows at positions at least j′j', so this row stays at a position at least jj until column jj is processed, and then its entry 11 is a unit pivot. The implementation retries SOLVE after each new row of line L9, so a successful attempt occurs. For the loop of lines L13 to L15, each trial has z=1z = 1 with probability 1/N1/N; then zz is the empty product, there are no GiG_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 Coppersmith's algorithm for discrete logarithms in GF(2^n)