Is the quadratic sieve algorithm on Wikipedia wrong/inefficient?

79 Views Asked by At

I'm confused by a few aspects of the algorithm.

https://en.wikipedia.org/wiki/Quadratic_sieve

First, I'm confused by the choice of $a_i$'s.

For each iteration:

  1. Choose $x \in \{ 0, \pm 1, \pm 2, \cdots \}$.
  2. Let $a_i = x + \lfloor\sqrt{n}\rfloor$.
  3. Let $b_i = a_i^2 - n$.

I think $x$ needs to be positive.

  • If $x$ is negative, $b_i$ is negative. We would want $a_i^2 - n$ to be in $\{ 0, 1, \cdots, n - 1 \}$.
  • If $x$ is 0 and $n$ is a perfect square, $b_i$ is 0. (e.g., If $n = 100$ and $x = 0$, then $a_i = 10$ and $b_i = 0$.)

Second, I'm confused by the inner while loop.

The article includes a while loop:

while (check-p_t-smooth(b_i) = false) do

I don't think this while loop ever terminates if $b_i$ isn't $p_t$-smooth? In addition, this while loop checks the existence of a subset $T \subset \{ 1, 2, \cdots, t + 1 \}$ such that $\prod_{i \in T} b_i$ becomes a perfect square.

I'm not sure if this is the right place to do that. We should do so after finding $t + 1$ $b_i$'s as that is how we guarantee that such a $T$ exists.