williams+1.tex 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. \chapter{Williams' $p+1$ factorization method \label{chap:william+1}}
  2. Analogously to Pollard's $p-1$ factorization described in chapter
  3. ~\ref{chap:pollard-1}, this method will allow the determination of the divisor
  4. $p$ of a number $N$, if $p$ is such that $p+1$ has only small prime divisors.
  5. This method was presented in ~\cite{Williams:p+1} together with the results of
  6. the application of this method to a large number of composite numbers.
  7. \section{Background on Lucas Sequences}
  8. Let us call \emph{Lucas Sequence} the recurrence relation with parameters $\tau,
  9. \upsilon$
  10. \begin{align*}
  11. \begin{cases}
  12. U_0 = 0 \\
  13. U_1 = 1 \\
  14. U_n = \tau U_{n-1} - \upsilon U_{n-2}
  15. \end{cases}
  16. \quad
  17. \begin{cases}
  18. V_0 = 2 \\
  19. V_1 = \tau \\
  20. V_n = \tau V_{n-1} - \upsilon V_{n-2}
  21. \end{cases}
  22. \end{align*}
  23. %% <https://en.wikipedia.org/wiki/Lucas_sequence> thanks wikipedia
  24. For respectively different values of $\tau, \upsilon$, Lucas Sequences have
  25. specific names:
  26. \begin{tabular}{c l@{\hskip 0pt} l@{\hskip 1pt} l l l}
  27. $\bullet$ & $U($ & $\tau=1,$ & $\upsilon=-1)$ & \emph{Fibonacci numbers}; \\
  28. $\bullet$ & $V($ & $\tau=1,$ & $\upsilon=-1)$ & \emph{Lucas numbers}; \\
  29. $\bullet$ & $U($ & $\tau=3,$ & $\upsilon=2)$ & \emph{Mersenne numbers}.\\
  30. \end{tabular}
  31. \\
  32. \\
  33. For our purposes, $U_n$ is not necessary, and $\upsilon=1$.\footnote{
  34. Williams justifies this choice stating that choosing to compute a $U_n$ sequence
  35. is far more computationally expensive than involving $V_n$; for what
  36. concerns $\upsilon$, that simplifies Lehmer's theorem with no loss of
  37. generality. For further references,
  38. see \cite{Williams:p+1} \S 3.}
  39. In order to simplify any later theorem, we just omit $U_n$, and assume $\upsilon
  40. = 1$.
  41. Therefore, the latter expression becomes:
  42. \begin{equation}
  43. \label{eq:williams:ls}
  44. \begin{cases}
  45. V_0 = 2 \\
  46. V_1 = \tau \\
  47. V_n = \tau V_{n-1} - V_{n-2} \\
  48. \end{cases}
  49. \end{equation}
  50. Two foundamental properties interpolate terms of Lucas Sequences, namely
  51. \emph{addition} and \emph{duplication} formulas:
  52. \begin{align}
  53. & V_{n+m} = V_nV_m - V_{m-n} \label{eq:ls:addition} \\
  54. & V_{2n} = V_n^2 - 2 \label{eq:ls:duplication}
  55. \end{align}
  56. All these identities can be verified by direct substitution with
  57. \ref{eq:williams:ls}. What's interesting about the ones of above, is that we can
  58. exploit them to efficiently compute the product $V_{hk}$ if we are provided with
  59. `$V_k$ by considering the binary representation of the number
  60. $h$. In other words, we can consider each bit of $h$, starting from second most
  61. significant one: if it is zero, we compute $\angular{V_{2k}, V_{(2+1)k}}$ using
  62. \ref{eq:ls:duplication} and \ref{eq:ls:addition} respectively; otherwise we
  63. compute $\angular{V_{(2+1)k}, V_{2(k+1)}}$ using \ref{eq:ls:addition} and
  64. \ref{eq:ls:duplication}.
  65. \begin{algorithm}[H]
  66. \caption{Lucas Sequence Multiplier}
  67. \begin{algorithmic}[1]
  68. \Function{Lucas}{$V, a, N$}
  69. \State $V_1 \gets V$
  70. \State $V_2 \gets V^2 - 2 \pmod{N}$
  71. \For{each bit $b$ in $a$ to right of the MSB}
  72. \If{$b$ is $0$ }
  73. \State $V_2 \gets V_1V_2 - V \pmod{N}$
  74. \Comment by addition %% \ref{eq:ls:addition}
  75. \State $V_1 \gets V_1^2 -2 \pmod{N}$
  76. \Comment by duplication %% \ref{eq:ls:duplication}
  77. \ElsIf{$b$ is $1$}
  78. \State $V_1 \gets V_1V_2 - V \pmod{N}$
  79. \Comment by addition %% \ref{eq:ls:addition}
  80. \State $V_2 \gets V_2^2 -2 \pmod{N}$
  81. \Comment by duplication %% \ref{eq:ls:duplication}
  82. \EndIf
  83. \EndFor
  84. \State \Return $V_1$
  85. \EndFunction
  86. \end{algorithmic}
  87. \end{algorithm}
  88. Finally, we need the following (\cite{Williams:p+1} \S 2):
  89. \begin{theorem*}[Lehmer]
  90. Let $\Delta$ be $\tau^2-4$;
  91. if $p$ is an odd prime and the Legendre symbol
  92. $\varepsilon = \legendre{\Delta}{p}$, then:
  93. \begin{align*}
  94. %% & U_{(p - \varepsilon)m} \equiv 0 \pmod{p} \\
  95. & V_{(p - \varepsilon)m} \equiv 2 \pmod{p}
  96. \end{align*}
  97. \end{theorem*}
  98. \begin{remark}
  99. From number theory we know that the probability that
  100. $P(\varepsilon = -1) = \rfrac{1}{2}$.
  101. There is no reason to restrict ourselves to
  102. $\legendre{\Delta}{p} = -1$.
  103. In the alternative case of $\varepsilon = 1$, the factorization yields the
  104. same factors as Pollard's $p-1$ method, but slowerly.
  105. For this reason it is advisable to first attempt the attack presented in the
  106. previous chapter \cite{Williams:p+1}whenever we look up for a $p-1$
  107. factorization.
  108. \end{remark}
  109. \section{Dressing up}
  110. At this point the factorization proceeds just by substituting the
  111. exponentiation and Fermat's theorem with Lucas sequences and Lehmer's theorem
  112. introduced in the preceeding section. If we find a $Q$ satisfying $p+1 \mid Q
  113. \text{ or } p-1 \mid Q$ then, due to Lehmer's theorem $p \mid V_Q -2$ and thus
  114. $\gcd(V_Q -2, N)$ is a non-trial divisor of $N$.
  115. \begin{enumerate}[(i)]
  116. \item take a random, initial $\tau = V_1$; now let the \emph{base} be
  117. $\angular{V_1}$.
  118. \item take the $i$-th prime in $\mathcal{P}$, starting from $0$, and call it
  119. $p_i$;
  120. \item assuming the current state is $\angular{V_k}$, compute the
  121. successive terms of the sequence using additions and multiplications formula,
  122. until you have $\angular{V_{p_ik}}$.
  123. \item just like with the Pollard $p-1$ method, repeat step (iii) for $e =
  124. \ceil{\frac{\log N}{\log p_i}}$ times;
  125. \item select $Q = V_k - 2 \pmod{N}$ and check the $gcd$ with $N$, hoping this
  126. leads to one of the two prime factors:
  127. \begin{align}
  128. g = gcd(Q, N), \quad 1 < g < N \,.
  129. \end{align}
  130. If so, than we have finished, since $g$ itself and $\frac{N}{g}$
  131. are the two primes factorizing the public modulus.
  132. Otherwise, if $g = 1$ we go back to to (ii), since $p-1 \nmid Q$ yet;
  133. if $g = N$ start back from scratch, as $pq \mid g$.
  134. %% riesel actually does not examine this case, strangely. However, it seems to
  135. %% be fairly probable that.
  136. \end{enumerate}
  137. \begin{algorithm}
  138. \caption{Williams $p+1$ factorization}
  139. \begin{algorithmic}[1]
  140. \Require $\mathcal{P}$, the prime pool
  141. \Function{Factorize}{$N, \tau$}
  142. \State $V \gets \tau$
  143. \For{$p_i \strong{ in } \mathcal{P}$}
  144. \Comment step (i)
  145. \State $e \gets \log \sqrt{N} // \log p_i$
  146. \For{$e \strong{ times }$}
  147. \State $V \gets \textsc{lucas}(V, p_i, N)$
  148. \Comment step (ii)
  149. \State $Q \gets V -2$
  150. \State $g \gets \gcd(Q, N)$
  151. \Comment step (iii)
  152. \If{$g = 1$} \Return \strong{nil}
  153. \ElsIf{$g > 1$} \Return $g, N//g$
  154. \EndIf
  155. \EndFor
  156. \EndFor
  157. \EndFunction
  158. \end{algorithmic}
  159. \end{algorithm}
  160. %%% Local Variables:
  161. %%% mode: latex
  162. %%% TeX-master: "question_authority"
  163. %%% End: