Algorithm Search⌘K

Proofs: Pollard-Strassen algorithm

These are the human proofs of Pollard-Strassen algorithm, at full length.

Correctness of the Pollard-Strassen algorithm full

This proof shows: correctness, termination.

Let N≥2N \ge 2, let BB be the least integer with B4≥NB^4 \ge N, and write R=Z/NZR = \mathbb{Z}/N\mathbb{Z}. For j=0,1,…,B−1j = 0, 1, \dots, B - 1 let Ij={jB+1,…,jB+B}I_j = \{jB + 1, \dots, jB + B\}. The blocks are disjoint and their union is {1,2,…,B2}\{1, 2, \dots, B^2\}. Let pp be the least prime factor of NN.

Termination. Lines L2 and L3 run a fixed number of polynomial operations, each a finite loop. Lines L4 to L6 are loops over at most BB blocks of BB elements. So the algorithm stops.

Lemma 1 (division by a monic polynomial). Let g∈R[x]g \in R[x] be monic of degree d≥1d \ge 1. For every a∈R[x]a \in R[x] there are unique q,r∈R[x]q, r \in R[x] with a=qg+ra = qg + r and deg⁡r<d\deg r < d.

Proof. Existence, by induction on deg⁡a\deg a. If deg⁡a<d\deg a < d, take q=0q = 0, r=ar = a. Otherwise let cc be the leading coefficient of aa and e=deg⁡ae = \deg a. Then a−cxe−dga - c x^{e - d} g has degree less than ee, because gg is monic, and the induction hypothesis applies to it. Uniqueness: if qg+r=q′g+r′qg + r = q'g + r', then (q−q′)g=r′−r(q - q')g = r' - r. If q≠q′q \ne q', the left side has degree deg⁡(q−q′)+d≥d\deg(q - q') + d \ge d, because the leading coefficient of gg is 11 and so the leading coefficient of (q−q′)g(q - q')g is that of q−q′q - q', which is not zero. The right side has degree less than dd. So q=q′q = q' and r=r′r = r'. □\square

Write a mod ga \bmod g for this rr. The map a↦a mod ga \mapsto a \bmod g is RR-linear, and a mod g=0a \bmod g = 0 exactly when g∣ag \mid a.

Lemma 2 (remainders and evaluation). (a) For a∈Ra \in R, f mod (x−a)=f(a)f \bmod (x - a) = f(a). (b) If gg and hh are monic and h∣gh \mid g, then (f mod g) mod h=f mod h(f \bmod g) \bmod h = f \bmod h.

Proof. (a) Write f=q(x−a)+rf = q(x - a) + r with rr a constant, by Lemma 1. Substitute x=ax = a: f(a)=rf(a) = r. (b) Write f=qg+rf = qg + r with r=f mod gr = f \bmod g, and g=shg = sh. Then f=(qs)h+rf = (qs)h + r, so f mod h=(qsh) mod h+r mod h=r mod hf \bmod h = (qs h) \bmod h + r \bmod h = r \bmod h, by linearity. □\square

Lemma 3 (the remainder tree). Let TT be the subproduct tree of the monic polynomials x−a0,…,x−ak−1x - a_0, \dots, x - a_{k-1}: each inner node is the product of its children, and each node is monic and divides its parent. Put f mod (root)f \bmod (\text{root}) at the root, and at each child the remainder of its parent's value modulo the child. Then the value at the leaf x−ajx - a_j is f(aj)f(a_j).

Proof. By induction down the tree, the value at each node gg is f mod gf \bmod g. This holds at the root. If it holds at a parent PP with a child QQ, then Q∣PQ \mid P, and the value at QQ is (f mod P) mod Q=f mod Q(f \bmod P) \bmod Q = f \bmod Q, by Lemma 2(b). At a leaf x−ajx - a_j, Lemma 2(a) gives f(aj)f(a_j). A node that is copied to the next level because it has no partner has itself as its only child, and (f mod Q) mod Q=f mod Q(f \bmod Q) \bmod Q = f \bmod Q. □\square

Lemma 4 (the implementation of division). For monic gg of degree dd and aa of formal degree m≥dm \ge d, the implementation computes a mod ga \bmod g correctly.

Proof. Write u~(x)=xeu(1/x)\tilde u(x) = x^{e} u(1/x) for the reversal of a polynomial uu of formal degree ee. From a=qg+ra = qg + r with deg⁡q≤m−d\deg q \le m - d and deg⁡r<d\deg r < d, reversal gives a~=q~g~+xm−d+1r~′\tilde a = \tilde q \tilde g + x^{m - d + 1} \tilde r' for some polynomial r~′\tilde r'. The constant term of g~\tilde g is 11, because gg is monic, so g~\tilde g is invertible modulo xm−d+1x^{m - d + 1} and q~≡a~g~−1(modxm−d+1)\tilde q \equiv \tilde a \tilde g^{-1} \pmod{x^{m - d + 1}}. Since deg⁡q~≤m−d\deg \tilde q \le m - d, this congruence determines q~\tilde q, hence qq, and r=a−qgr = a - qg.

The inverse comes from Newton's iteration: if gh≡1(modxt)g h \equiv 1 \pmod{x^t} and h′=h(2−gh)h' = h(2 - gh), then 1−gh′=(1−gh)2≡0(modx2t)1 - gh' = (1 - gh)^2 \equiv 0 \pmod{x^{2t}}. Starting from h=1h = 1, which is correct modulo xx, the iteration doubles the precision until it reaches m−d+1m - d + 1. The schoolbook branch is the existence step of Lemma 1 applied coefficient by coefficient from the top.

Polynomial products use either the schoolbook sum or Kronecker substitution. In the latter, the coefficients ai,bj∈[0,N)a_i, b_j \in [0, N) are written as digits in base 28w2^{8w}, where 28w>min⁡(ℓa,ℓb)N22^{8w} > \min(\ell_a, \ell_b) N^2 for the lengths ℓa,ℓb\ell_a, \ell_b. Each coefficient ck=∑i+j=kaibjc_k = \sum_{i + j = k} a_i b_j of the integer product of the polynomials is a sum of at most min⁡(ℓa,ℓb)\min(\ell_a, \ell_b) terms below N2N^2, so 0≤ck<28w0 \le c_k < 2^{8w}. Hence the product of the packed integers has the digits ckc_k with no carries, and unpacking and reducing modulo NN gives the product in R[x]R[x]. □\square

Lemma 5 (the block values). For each jj, vj≡∏k∈Ijk(modN)v_j \equiv \prod_{k \in I_j} k \pmod N.

Proof. In Z[x]\mathbb{Z}[x], (x+1)(x+2)⋯(x+B)(x + 1)(x + 2) \cdots (x + B) evaluated at x=jBx = jB is ∏i=1B(jB+i)=∏k∈Ijk\prod_{i = 1}^{B} (jB + i) = \prod_{k \in I_j} k. Reduction modulo NN is a ring homomorphism Z[x]→R[x]\mathbb{Z}[x] \to R[x] that commutes with evaluation, so the polynomial ff of line L2 satisfies f(jB)=∏k∈Ijk mod Nf(jB) = \prod_{k \in I_j} k \bmod N. Line L3 computes f(jB)f(jB) by Lemmas 3 and 4. □\square

Lemma 6 (a gcd above 1). gcd⁡(vj,N)>1\gcd(v_j, N) > 1 if and only if some k∈Ijk \in I_j has gcd⁡(k,N)>1\gcd(k, N) > 1.

Proof. By Lemma 5, gcd⁡(vj,N)=gcd⁡(∏k∈Ijk,N)\gcd(v_j, N) = \gcd(\prod_{k \in I_j} k, N), since vjv_j and the product differ by a multiple of NN. If a prime ℓ\ell divides NN and the product, then ℓ\ell divides some factor kk, so gcd⁡(k,N)>1\gcd(k, N) > 1. Conversely, if ℓ\ell divides NN and some k∈Ijk \in I_j, it divides the product. □\square

Lemma 7 (nothing below pp). Every integer kk with 1≤k<p1 \le k < p has gcd⁡(k,N)=1\gcd(k, N) = 1.

Proof. If gcd⁡(k,N)>1\gcd(k, N) > 1, then some prime ℓ\ell divides both, so ℓ≤k<p\ell \le k < p and ℓ∣N\ell \mid N, against the choice of pp as the least prime factor. For k=1k = 1 the gcd is 11. □\square

Theorem. The algorithm returns pp.

Proof. Case 1: p≤B2p \le B^2. Let JJ be the index with p∈IJp \in I_J. Then gcd⁡(p,N)=p>1\gcd(p, N) = p > 1, so gcd⁡(vJ,N)>1\gcd(v_J, N) > 1 by Lemma 6. For j<Jj < J, every k∈Ijk \in I_j satisfies k≤jB+B≤JB<pk \le jB + B \le JB < p, so gcd⁡(k,N)=1\gcd(k, N) = 1 by Lemma 7, and gcd⁡(vj,N)=1\gcd(v_j, N) = 1 by Lemma 6. So the loop of line L4 reaches line L6 first at j=Jj = J. There, every d∈IJd \in I_J with 2≤d<p2 \le d < p is not a divisor of NN: a divisor d≥2d \ge 2 of NN has a prime factor that divides NN and is at most dd, so d≥pd \ge p. And p∈IJp \in I_J divides NN. So line L6 returns pp.

Case 2: p>B2p > B^2. Then p>B2≥Np > B^2 \ge \sqrt N. If NN were composite, then N=p⋅(N/p)N = p \cdot (N/p) with N/p≥pN/p \ge p, so p≤Np \le \sqrt N, a contradiction. So NN is prime and p=Np = N. Every k≤B2k \le B^2 satisfies k<pk < p, so by Lemmas 6 and 7 no block has a gcd above 11, and line L7 returns N=pN = p.

In both cases the output is the least prime factor of NN.

For the full factorization, each pass of the driver divides out every power of the least prime factor pp of what is left. All prime factors of the cofactor mm are then larger than pp. If 1<m<p21 < m < p^2, then mm cannot have two prime factors, each above pp, so mm is prime. The cofactor decreases at every pass, so the driver stops, and the primes collected multiply to the input. ■\blacksquare

Back to Pollard-Strassen algorithm