The SNFS is based on an idea similar to the much simpler rational sieve; in particular, readers may find it helpful to read about the rational sieve first, before tackling the SNFS. The SNFS works as follows. Let n be the integer we want to factor. As in the rational sieve, the SNFS can be broken into two steps:
First, find a large number of multiplicative relations among a factor base of elements of Z/nZ, such that the number of multiplicative relations is larger than the number of elements in the factor base.
Second, multiply together subsets of these relations in such a way that all the exponents are even, resulting in congruences of the form a2≡b2. These in turn immediately lead to factorizations of n: n=gcd×gcd. If done right, it is almost certain that at least one such factorization will be nontrivial.
The second step is identical to the case of the rational sieve, and is a straightforward linear algebra problem. The first step, however, is done in a different, more efficient way than the rational sieve, by utilizing number fields.
Details of method
Let n be the integer we want to factor. We pick an irreducible polynomialf with integer coefficients, and an integer m such that f≡0 . Let α be a root of f; we can then form the ringZ. There is a uniquering homomorphism φ from Z to Z/nZ that maps α to m. For simplicity, we'll assume that Z is a unique factorization domain; the algorithm can be modified to work when it isn't, but then there are some additional complications. Next, we set up two parallel factor bases, one in Z and one in Z. The one in Z consists of all the prime ideals in Z whose norm is bounded by a chosen value. The factor base in Z, as in the rational sieve case, consists of all prime integers up to some other bound. We then search for relatively prime pairs of integers such that:
a+bα is smooth with respect to the factor base in Z; given how we chose the factor base, this is equivalent to the norm of a+bα being divisible only by primes less than.
These pairs are found through a sieving process, analogous to the Sieve of Eratosthenes; this motivates the name "Number Field Sieve". For each such pair, we can apply the ring homomorphism φ to the factorization of a+bα, and we can apply the canonical ring homomorphism from Z to Z/nZ to the factorization of a+bm. Setting these equal gives a multiplicative relation among elements of a bigger factor base in Z/nZ, and if we find enough pairs we can proceed to combine the relations and factor n, as described above.
Choice of parameters
Not every number is an appropriate choice for the SNFS: you need to know in advance a polynomial f of appropriate degree with small coefficients, and a value x such that where N is the number to factorise. There is an extra condition: x must satisfy for a and b no bigger than. One set of numbers for which such polynomials exist are the numbers from the Cunningham tables; for example, when NFSNET factored 3^479+1, they used the polynomial x^6+3 with x=3^80, since ^6+3 = 3^480+3, and. Numbers defined by linear recurrences, such as the Fibonacci and Lucas numbers, also have SNFS polynomials, but these are a little more difficult to construct. For example, has polynomial, and the value of x satisfies. If you already know some factors of a large SNFS-number, you can do the SNFS calculation modulo the remaining part; for the NFSNET example above, 3^479+1 = times a 197-digit composite number, and the SNFS was performed modulo the 197-digit number. The number of relations required by SNFS still depends on the size of the large number, but the individual calculations are quicker modulo the smaller number.
Limitations of algorithm
This algorithm, as mentioned above, is very efficient for numbers of the form re±s, for r and s relatively small. It is also efficient for any integers which can be represented as a polynomial with small coefficients. This includes integers of the more general form are±bsf, and also for many integers whose binary representation has low Hamming weight. The reason for this is as follows: The Number Field Sieve performs sieving in two different fields. The first field is usually the rationals. The second is a higher degree field. The efficiency of the algorithm strongly depends on the norms of certain elements in these fields. When an integer can be represented as a polynomial with small coefficients, the norms that arise are much smaller than those that arise when an integer is represented by a general polynomial. The reason is that a general polynomial will have much larger coefficients, and the norms will be correspondingly larger. The algorithm attempts to factor these norms over a fixed set of prime numbers. When the norms are smaller, these numbers are more likely to factor.