Coppersmith algorithm

This algorithm solves for small roots of polynomials modulo any integer, meaning given some polynomial f(x)Z[x]f(x)\in\mathbb Z[x]of degree ddand any integer NN, then if f(x0)=0(modN),x0<N1df(x_0)=0\pmod{N},|x_0|<N^{\frac1d}, this algorithm can findx0x_0with time polynomial in logN\log Nand dd. The key idea behind this algorithm is to construct a polynomialg(x)g(x)such that g(x0)=0g(x_0)=0in R\mathbb R. As roots of polynomials over the reals can be found easily, this gives an easy way to find x0x_0. We shall introduce the Coppersmith algorithm in a few iterations, with each iteration approaching the N1dN^{\frac1d}bound.

Polynomials in lattices

We first consider a criteria for a root of a polynomial moduloNNto exists over the reals as well. Supposef(x)=i=0dfixif(x)=\sum_{i=0}^df_ix^iis a polynomial of degreedd. Define the 2\ell_2normf(x)2\left\lVert f(x)\right\rVert_2 of a polynomial to be i=0dfi2\sqrt{\sum_{i=0}^df_i^2}. Given x0<B,f(x0)=0(modN)|x_0|<B,f(x_0)=0\pmod N, if

f(Bx)2=i=0d(fiBi)2Nd+1\left\lVert f(Bx)\right\rVert_2=\sqrt{\sum_{i=0}^d\left(f_iB^i\right)^2}\leq\frac N{\sqrt{d+1}}

then f(x0)=0f(x_0)=0 in R\mathbb R. The proof is a relatively straightforward chain of inequalities:

Nd+1i=0d(fiBi)2i=0d(fix0i)21d+1i=0dfix0i1d+1i=0dfix0i\begin{align*} \frac N{\sqrt{d+1}}&\geq\sqrt{\sum_{i=0}^d\left(f_iB^i\right)^2}\\&\geq\sqrt{\sum_{i=0}^d\left(f_ix_0^i\right)^2}\\ &\geq\frac1{\sqrt{d+1}}\sum_{i=0}^d\left|f_ix_0^i\right|\\ &\geq\frac1{\sqrt{d+1}}\left|\sum_{i=0}^df_ix_0^i\right|\\ \end{align*}

and since f(x0)=0(modN)f(x_0)=0\pmod Nimplies f(x0)=kNf(x_0)=kNfor some kZk\in\mathbb Z, we know that kkmust be00to satisfy the inequality above.

With this, if we can find some polynomials fif_isuch that fi(x0)=0(modN)f_i(x_0)=0\pmod N, then if we can find some cic_isuch that icifi(x)2Nd+1\left\lVert\sum_ic_if_i(x)\right\rVert_2\leq\frac N{\sqrt{d+1}}, then we can find x0x_0easily. This gives a brief idea as to why lattices would be useful in such a problem.

To use lattices, notice that we can encode the polynomial f(x)=i=0dfixif(x)=\sum_{i=0}^df_ix^ias the vector with components fif_i. In this way, adding polynomials and multiplying polynomials by numbers still makes sense. Lets suppose that f(x0)=0(modN),x0<Bf(x_0)=0\pmod N,x_0<Band fd=1f_d=1(otherwise multiplyffby fd1(modN)f_d^{-1}\pmod N. Consider the polynomials gi(x)=Nxig_i(x)=Nx^iand consider the latticeLLgenerated by f(Bx)f(Bx)and gi(Bx)g_i(Bx), 0id10\leq i\leq d-1. As a matrix, the basis vectors are

B=(N00000NB00000NB200000NBd10f0f1Bf2B2fd1Bd1Bd)\mathcal B=\begin{pmatrix} N&0&0&\dots&0&0\\ 0&NB&0&\dots&0&0\\ 0&0&NB^2&\dots&0&0\\ \vdots&\vdots&\vdots&\ddots&\vdots&\vdots\\ 0&0&0&\dots&NB^{d-1}&0\\ f_0&f_1B&f_2B^2&\dots&f_{d-1}B^{d-1}&B^d\\ \end{pmatrix}

As every element in this lattice is some polynomial g(Bx)g(Bx), if f(x0)=0(modN)f(x_0)=0\pmod N, theng(x0)=0(modN)g(x_0)=0\pmod N. Furthermore, if x0<B|x_0|<Band a short vectorv(Bx)v(Bx)has length less than Nd+1\frac N{\sqrt{d+1}}, then we have v(x0)=0v(x_0)=0in R\mathbb R.

The volume of this lattice is NdBd(d+1)2N^dB^{\frac{d(d+1)}2}and the lattice has dimension d+1d+1. By using the LLL algorithm, we can find a vector v(Bx)v(Bx) with length at most

v(Bx)2=(44δ1)d4cδ,dvol(L)1d+1=cδ,dNdd+1Bd2\left\lVert v(Bx)\right\rVert_2=\underbrace{\left(\frac4{4\delta-1}\right)^{\frac d4}}_{c_{\delta,d}}\text{vol}(L)^\frac1{d+1}=c_{\delta,d}N^{\frac d{d+1}}B^{\frac d2}

As long as cδ,dNdd+1Bd2<Nd+1c_{\delta,d}N^{\frac d{d+1}}B^{\frac d2}<\frac N{\sqrt{d+1}}, then by the above criteria we know that this vector has x0x_0has a root over R\mathbb R. This tells us that

B<N2d(d+1)(cδ,dd+1)2dB<N^{\frac2{d(d+1)}}\left(c_{\delta,d}\sqrt{d+1}\right)^{-\frac 2d}

While this isn't the N1dN^{\frac1d}bound that we want, this gives us an idea of what we can do to achieve this bound, i.e. add more vectors such that the length of the shortest vector decreases.

Achieving the N1dN^{\frac1d}bound

One important observation to make is that any coefficients in front ofNxN^xdoes not matter as we can simply brute force the top bits of our small root in O(1)O(1)time. Hence we only need to getB=kN1dB=kN^{\frac1d}for some fixed constantkk.

In order to achieve this, notice that if f(x0)=0(modN)f(x_0)=0\pmod N, then f(x0)h=0(modNh)f(x_0)^h=0\pmod{N^h}. This loosens the inequality required for a polynomial to have x0x_0as a small root as our modulus is now larger. With this in mind, consider the polynomials

gi,j(x)=Nhjf(x)jxi0i<d,0j<hg_{i,j}(x)=N^{h-j}f(x)^jx^i\quad0\leq i<d,0\leq j<h

where we will determinehhlater. Here gi,j(x0)=0(modNh)g_{i,j}(x_0)=0\pmod{N^h}, hence we shall consider the lattice LL generated by gi,j(Bx)g_{i,j}(Bx). As an example, if we have

f(x)=x3+2x2+3x+4h=3f(x)=x^3+2x^2+3x+4\quad h=3

the basis vectors of our lattice would look like

(N3000000000BN3000000000B2N30000004N23BN22B2N2B3N20000004BN23B2N22B3N2B4N20000004B2N23B3N22B4N2B5N200016N24BN25B2N20B3N10B4N4B5NB6N00016BN24B2N25B3N20B4N10B5N4B6NB7N00016B2N24B3N25B4N20B5N10B6N4B7NB8N)\footnotesize{\left(\begin{array}{rrrrrrrrr} N^{3} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & B N^{3} & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & B^{2} N^{3} & 0 & 0 & 0 & 0 & 0 & 0 \\ 4 \, N^{2} & 3 \, B N^{2} & 2 \, B^{2} N^{2} & B^{3} N^{2} & 0 & 0 & 0 & 0 & 0 \\ 0 & 4 \, B N^{2} & 3 \, B^{2} N^{2} & 2 \, B^{3} N^{2} & B^{4} N^{2} & 0 & 0 & 0 & 0 \\ 0 & 0 & 4 \, B^{2} N^{2} & 3 \, B^{3} N^{2} & 2 \, B^{4} N^{2} & B^{5} N^{2} & 0 & 0 & 0 \\ 16 \, N & 24 \, B N & 25 \, B^{2} N & 20 \, B^{3} N & 10 \, B^{4} N & 4 \, B^{5} N & B^{6} N & 0 & 0 \\ 0 & 16 \, B N & 24 \, B^{2} N & 25 \, B^{3} N & 20 \, B^{4} N & 10 \, B^{5} N & 4 \, B^{6} N & B^{7} N & 0 \\ 0 & 0 & 16 \, B^{2} N & 24 \, B^{3} N & 25 \, B^{4} N & 20 \, B^{5} N & 10 \, B^{6} N & 4 \, B^{7} N & B^{8} N \end{array}\right)}

We have the following immediate computations of LL:

dim(L)=dhvol(L)=Ndh(h+1)2B(dh1)dh2\dim(L)=dh\quad\text{vol}(L)=N^{\frac{dh(h+1)}2}B^{\frac{(dh-1)dh}2}

hence when using the LLL algorithm, the shortest LLL basis vectorv(Bx)v(Bx)has length

v(Bx)2=(44δ1)dim(L)14vol(L)1dim(L)=(44δ1)dh14Nh+12Bdh12\begin{align*} \left\lVert v(Bx)\right\rVert_2&=\left(\frac4{4\delta-1}\right)^{\frac{\dim(L)-1}4}\text{vol}(L)^{\frac1{\dim(L)}}\\ &=\left(\frac4{4\delta-1}\right)^{\frac{dh-1}4}N^{\frac{h+1}2}B^{\frac{dh-1}2}\\ \end{align*}

and we need v(Bx)2<Nhdh\left\lVert v(Bx)\right\rVert_2<\frac{N^h}{\sqrt{dh}}for v(x0)=0v(x_0)=0. Hence we have

B<4δ14(1dh)1dh1Nh1dh1B<\sqrt{\frac{4\delta-1}4}\left(\frac1{dh}\right)^{\frac1{dh-1}}N^{\frac{h-1}{dh-1}}

Since limhh1dh1=1d\lim_{h\to\infty}\frac{h-1}{dh-1}=\frac1d, this will achieve the N1dN^{\frac1d}bound that we want. However as for big hh, the LLL algorithm would take a very long time, we typically choose a suitably largehhsuch that the algorithm is still polynomial in logN,d\log N,dand brute force the remaining bits.

Exercises

1) We often see h=max(d+dε1d2ϵ,7d)h=\left\lceil\max\left(\frac{d+d\varepsilon-1}{d^2\epsilon},\frac7d\right)\right\rceilin literature. We shall now show where this mysterious7d\frac7dcomes from. The other term will appear in the next exercise. Typically, one sets δ=34\delta=\frac34to simplify calculations involving the LLL algorithm as 44δ1=2\frac4{4\delta-1}=2. Suppose we want B>12Nh1dh1B>\frac12N^{\frac{h-1}{dh-1}}, show that this gives us dh7dh\geq7.

2) We show that we can indeed find small roots less thanN1dN^{\frac1d}in polynomial time. In the worse case, the longest basis vector cannot exceed O(Bdh1Nh)O\left(B^{dh-1}N^h\right). Hence the LLL algorithm will run in at mostO(d6h6(d+h)2log2N)O(d^6h^6(d+h)^2\log^2N)time.

Let

ε=1dh1dh1h=d+dε1d2ϵ1dε\varepsilon=\frac1d-\frac{h-1}{dh-1}\quad h=\frac{d+d\varepsilon-1}{d^2\epsilon}\approx\frac1{d\varepsilon}

and choose ε=1logN\varepsilon=\frac1{\log N}, then NεN^\varepsilonis a constant hence the number of bits needed to be brute forced is a constant. This gives us the approximate run time of O((d+1dlogN)2log8N)O((d+\frac1d\log N)^2\log^8N).

3) We shall show that this is the best bound we can hope for using lattice methods. Suppose there exists some algorithm that finds roots less than O(N1d+ϵ)O\left(N^{\frac1d+\epsilon}\right)in polynomial time. Then consider the case whenN=p2N=p^2and f(x)=x2+pxf(x)=x^2+px. Show that this forces the lattice to have a size too big for the algorithm to run in polynomial time, assuming the algorithm finds all small roots.

Last updated