williams+1.tex 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. Three foundamental properties interpolate terms of Lucas Sequences:
  51. \begin{align}
  52. & V_{2n+1} = \tau V_n^2 - V_n V_{n-1} - \tau \label{eq:ls:2n+1} \\
  53. & V_{2n} = V_n^2 - 2 \label{eq:ls:2n} \\
  54. & V_{2n-1} = V_nV_{n-1} - \tau \label{eq:ls:2n-1}
  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. $\angular{V_k, V_{k-1}}$ by considering the binary representation of the number
  60. $h$. In other words, we can consider each bit of $h$, starting from the least
  61. significant one: if it is zero, we use the multiplication formula
  62. \ref{eq:ls:2n}; otherwise the two addition formulas \ref{eq:ls:2n+1} and
  63. \ref{eq:ls:2n-1}.
  64. \begin{algorithm}[H]
  65. \caption{Lucas Sequence Multiplier}
  66. \begin{algorithmic}[1]
  67. \Function{Lucas}{$V, V', a, \tau$}
  68. \While{$a > 0$}
  69. \If{$a$ is even }
  70. \State $V'' \gets V^2 -2$
  71. \Comment by equation \ref{eq:ls:2n}
  72. \State $V' \gets VV' - \tau$
  73. \Comment by equation \ref{eq:ls:2n-1}
  74. \State $V \gets V''$
  75. \ElsIf{$a$ is odd}
  76. \State $V'' \gets \tau V^2 - VV' - \tau$
  77. \Comment by equation \ref{eq:ls:2n+1}
  78. \State $V' \gets V^2 -2$
  79. \Comment by equation \ref{eq:ls:2n}
  80. \State $V \gets V''$
  81. \EndIf
  82. \State $a \gets a \gg 1$
  83. \EndWhile
  84. \State \Return $V, V'$
  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. If $p$ is an odd prime and the Legendre symbol
  91. $\varepsilon = \legendre{\Delta}{p}$, then:
  92. \begin{align*}
  93. %% & U_{(p - \varepsilon)m} \equiv 0 \pmod{p} \\
  94. & V_{(p - \varepsilon)m} \equiv 2 \pmod{p}
  95. \end{align*}
  96. \end{theorem*}
  97. \begin{remark}
  98. From number theory we know that the probability that
  99. $\mathbb{P}\{\varepsilon = -1\} = \rfrac{1}{2}$.
  100. There is no reason to restrict ourselves to
  101. $\legendre{\Delta}{p} = -1$.
  102. In the alternative case of $\varepsilon = 1$, the factorization yields the
  103. same factors as Pollard's $p-1$ method, but slowerly.
  104. For this reason, when we look up for a $p-1$ factorization, it is advisable
  105. to attempt the attack presented in the previous chapter \cite{Williams:p+1}.
  106. \end{remark}
  107. \section{Dressing up}
  108. At this point the factorization proceeds just by substituting the
  109. exponentiation and Fermat's theorem with Lucas sequences and Lehmer's theorem
  110. introduced in the preceeding section. If we find a $Q$ satisfying $p+1 \mid Q
  111. \text{ or } p-1 \mid Q$ then, due to Lehmer's theorem $p \mid V_Q -2$ and thus
  112. $\gcd(V_Q -2, N)$ is a non-trial divisor of $N$.
  113. \begin{enumerate}[(i)]
  114. \item take a random, initial $\tau = V_1$; now let the \emph{base} be
  115. $\angular{V_0, V_1}$.
  116. \item take the $i$-th prime in $\mathcal{P}$, starting from $0$, and call it
  117. $p_i$;
  118. \item assuming the current state is $\angular{V_k, V_{k-1}}$, compute the
  119. successive terms of the sequence using additions and multiplications formula,
  120. until you have $\angular{V_{p_ik}, V_{p_ik - 1}}$.
  121. \item just like with the Pollard $p-1$ method, repeat step (iii) for $e =
  122. \ceil{\frac{\log N}{\log p_i}}$ times;
  123. \item select $Q = V_k - 2 \pmod{N}$ and check the $gcd$ with $N$, hoping this
  124. leads to one of the two prime factors:
  125. \begin{align}
  126. g = gcd(Q, N), \quad 1 < g < N \,.
  127. \end{align}
  128. If so, than we have finished, since $g$ itself and $\frac{N}{g}$
  129. are the two primes factorizing the public modulus.
  130. Otherwise, if $g = 1$ we go back to to (ii), since $p-1 \nmid Q$ yet;
  131. if $g = N$ start back from scratch, as $pq \mid g$.
  132. %% riesel actually does not examine this case, strangely. However, it seems to
  133. %% be fairly probable that.
  134. \end{enumerate}
  135. \begin{algorithm}
  136. \caption{Williams $p+1$ factorization}
  137. \begin{algorithmic}[1]
  138. \Require $\mathcal{P}$, the prime pool
  139. \Function{Factorize}{$N, \tau$}
  140. \State $V \gets \tau$
  141. \State $V' \gets 2$
  142. \For{$p_i \strong{ in } \mathcal{P}$}
  143. \Comment step (i)
  144. \State $e \gets \log \sqrt{N} // \log p_i$
  145. \For{$e \strong{ times }$}
  146. \State $V, V' \gets \textsc{lucas}(V, V', p_i, \tau)$
  147. \Comment step (ii)
  148. \State $Q \gets V -2$
  149. \State $g \gets \gcd(Q, N)$
  150. \Comment step (iii)
  151. \If{$g = 1$} \Return \strong{nil}
  152. \ElsIf{$g > 1$} \Return $g, N//g$
  153. \EndIf
  154. \EndFor
  155. \EndFor
  156. \EndFunction
  157. \end{algorithmic}
  158. \end{algorithm}
  159. %%% Local Variables:
  160. %%% mode: latex
  161. %%% TeX-master: "question_authority"
  162. %%% End: