| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 | \chapter{Williams' $p+1$ factorization method \label{chap:william+1}}Analogously to Pollard's $p-1$ factorization described in chapter~\ref{chap:pollard-1}, this method will allow the determination of the divisor$p$ of a number $N$, if $p$ is such that $p+1$ has only small prime divisors.This method was presented in ~\cite{Williams:p+1} together with the results ofthe application of this method to a large number of composite numbers.\section{Background on Lucas Sequences}Let us call \emph{Lucas Sequence} the recurrence relation with parameters $\tau,\upsilon$\begin{align*}  \begin{cases}    U_0 = 0 \\    U_1 = 1 \\    U_n = \tau U_{n-1} - \upsilon U_{n-2}  \end{cases}  \quad  \begin{cases}    V_0 = 2 \\    V_1 = \tau \\    V_n = \tau V_{n-1} - \upsilon V_{n-2}  \end{cases}\end{align*}%% <https://en.wikipedia.org/wiki/Lucas_sequence> thanks wikipediaFor respectively different values of $\tau, \upsilon$, Lucas Sequences havespecific names:\begin{tabular}{c l@{\hskip 0pt} l@{\hskip 1pt} l l l}  $\bullet$ & $U($ & $\tau=1,$ & $\upsilon=-1)$ & \emph{Fibonacci numbers}; \\  $\bullet$ & $V($ & $\tau=1,$ & $\upsilon=-1)$ & \emph{Lucas numbers}; \\  $\bullet$ & $U($ & $\tau=3,$ & $\upsilon=2)$ & \emph{Mersenne numbers}.\\\end{tabular}\\\\For our purposes, $U_n$ is not necessary, and $\upsilon=1$\footnote{  Williams justifies this choice stating that choosing to compute a $U_n$ sequence  is far more computationally expensive than involving $V_n$; for what  concerns $\upsilon$, that simplifies Lehmer's theorem with no loss of  generality. For further references,  see \cite{Williams:p+1} \S 3.}.In order to simplify any later theorem, we just omit it. Therefore, the latterexpression becomes:\begin{equation}  \label{eq:williams:ls}  \begin{cases}    V_0 = 2 \\    V_1 = \tau \\    V_n = \tau V_{n-1} - V_{n-2} \\  \end{cases}\end{equation}Three foundamental properties interpolate terms of Lucas Sequences:\begin{align}  & V_{2n+1} = \tau V_n - V_{n-1} \label{eq:ls:2n+1}\\  & V_{2n} = V_n^2 - 2 \label{eq:ls:2n}\\  & V_{2n-1} = V_nV_{n-1} - \tau \label{eq:ls:2n-1}\end{align}All these identities can be verified by direct substitution with\ref{eq:williams:ls}. What's interesting about the ones of above, is that we canexploit those to efficiently compute the product $V_{hk}$ if we are provided with$\angular{V_k, V_{k-1}}$ by considering the binary representation of the number$h$. In other words, we can consider each bit of $h$, starting from the leastsignificant one: if it is zero, we use the multiplication formula\ref{eq:ls:2n}; otherwise the two addition formulas \ref{eq:ls:2n+1} and\ref{eq:ls:2n-1}.\begin{algorithm}[H]  \caption{Lucas Sequence Multiplier}  \begin{algorithmic}[1]    \Function{Lucas}{$V, V', a, \tau$}      \While{$a > 0$}        \If{$a$ is even }          \State $V'' \gets V^2 -2$          \Comment by equation \ref{eq:ls:2n}          \State $V' \gets VV' - \tau$          \Comment by equation \ref{eq:ls:2n-1}          \State $v \gets V''$        \ElsIf{$a$ is odd}          \State $V'' \gets \tau V^2 - VV' - \tau$          \Comment by equation \ref{eq:ls:2n+1}          \State $V' \gets V^2 -2$          \Comment by equation \ref{eq:ls:2n}          \State $V \gets V''$        \EndIf        \State $a \gets a \gg 1$      \EndWhile      \State \Return $V, V'$    \EndFunction  \end{algorithmic}\end{algorithm}Finally, we need the following (\cite{Williams:p+1} \S 2):\begin{theorem*}[Lehmer]  If $p$ is an odd prime and the Legendre symbol  $\legendre{\Delta}{p} = \varepsilon$, then:  \begin{align*}%%  &  U_{(p - \varepsilon)m} \equiv 0 \pmod{p} \\  &  V_{(p - \varepsilon)m} \equiv 2 \pmod{p}  \end{align*}\end{theorem*}\begin{remark}  From number theory we know that the probability that  $\mathbb{P}\{\epsilon = -1\} = \rfrac{1}{2}$.  But, there is reason to restrict ourselves for $\legendre{\Delta}{p} = -1$.  What's woth noring, though, is that a $p-1$ factorization attempt would be  quite slow with respect to Pollard's $p-1$ method. As a consequence of this,  we and \cite{Williams:p+1} proceeded running pollard first????\end{remark}\section{Dressing Up}At this point the factorization proceeds just by substituting theexponentiation and Fermat's theorem with lucas sequences and Lehmer's theoremintroduced in the preceeding section. If we find a $Q$ satisfying $p+1 \mid Q\text{ or } p-1 \mid Q$ then, due to Lehmer's theorem $p \mid V_Q -2$ and thus$\gcd(V_Q -2, N)$ is a non-trial divisor of $N$.\begin{enumerate}[(i)]\item take a random, initial $\tau = V_1$; now let the \emph{base} be  $\angular{V_0, V_1}$.\item take the $i$-th prime in $\mathcal{P}$, starting from $0$, and call it be  $p_i$;\item assuming the current state is $\angular{V_k, V_{k-1}}$, compute the  successive terms of the sequence using additions and multiplications formula,  until you have $\angular{V_{p_ik}, V_{p_ik - 1}}$.\item just like with the Pollard $p-1$ method, repeat step (iii) for $e =  \ceil{\frac{\log N}{\log p_i}}$ times;\item select $Q = V_k - 2 \pmod{N}$ and check the $gcd$ with $N$, hoping this  leads to one of the two prime factors:\begin{align}  g = gcd(Q, N), \quad 1 < g < N \,.\end{align}If so, than we have finished, since $g$ itself and $\frac{N}{g}$are the two primes factorizing the public  modulus.Otherwise, if $g = 1$ we go back to to (ii), since $p-1 \nmid Q$ yet;if $g = N$ start back from scratch, as $pq \mid g_i$.%% riesel actually does not examine this case, strangely. However, it seems to%% be fairly probable that.\end{enumerate}\begin{algorithm}  \caption{Williams $p+1$ factorization}  \begin{algorithmic}[1]    \Require $\mathcal{P}$, the prime pool    \Function{Factorize}{$N, \tau$}      \State $V \gets 2$      \State $V' \gets \tau$      \For{$p_i \strong{ in } \mathcal{P}$}      \Comment step (i)        \State $e \gets \log \sqrt{N} // \log p_i$        \For{$e \strong{ times }$}          \State $V, V' \gets \textsc{lucas}(V, V', p_i, \tau)$          \Comment step (ii)          \State $Q \gets V -2$          \State $g \gets \gcd(Q, N)$          \Comment step (iii)          \If{$g = 1$} \Return \strong{nil}          \ElsIf{$g > 1$} \Return g          \EndIf        \EndFor      \EndFor    \EndFunction  \end{algorithmic}\end{algorithm}%%% Local Variables:%%% mode: latex%%% TeX-master: "question_authority"%%% End:
 |