prime numbers have been my obsession since my childhood and they are source of continue interest for me. Actually thanks to People that knows me well are well aware thathave been mysince my childhood andare source of continue interest for me. Actually thanks to cryptography they are a relevant part of my everyday life.

factoring. One of the most important problem in cryptography since the discovery of RSA is

One of the most intriguing part of filtering is that at the first sight these methods look trivial (because well, they are) but my main point, that drove me to write this blog post, is that they are probably one of the most important part of the all NFS algorithm.

The current NFS record factorization is RSA-768, an integer of 768 bits (232 digits). At the beginning of the filtering step, the matrix had about 47 billion rows and 35 billion columns. After the first part of the filtering step, the matrix had about 2.5 billion rows and 1.7 billions columns. At the end of the filtering step, the matrix used in the linear algebra had about 193 million rows and columns. So the filtering step reduced the size of the matrix by more than 99%!!!

..What is this filtering about?

All the modern factorization procedures consist basically of 3 steps :

Relation Building Elimination GCD Computation

Filtering is part of step 2 (Elimination). The main goal of the filtering step is to reduce the size of a large sparse matrix over a finite field in order to being able to compute its kernel (we will see that for the factorization problem what we actually need is the left kernel). We will see that filtering per see is a 4 steps process:

Removing duplicates Removing singletons Removing cliques Merging As we said in this example we focus on filtering that is part of Elimination so in order to showcase it, we borrow a simple Relation Building example from



from "An Introduction to Mathematical Cryptography"

Again, without going to much in details, the goal here is to find a subset of all these relations whose product is a square on each side of the equality. This is equivalent to: the sum of the exponents in all chosen relations must be even. If you wonder why, we are trying to leverage one of the simplest of the identities in all of the mathematics:



X^2 - Y^2 = (X+Y)(X-Y)

But let's not diverge from out today's topic and let's focus on filtering. The problem above can be translated in a linear algebra problem. If one sees the relations as rows of a matrix where each column corresponds to an ideal, the coefficients of the matrix are the exponents of the ideals in the relations. As we are looking for even exponents, one can consider the matrix over GF(2).





computing the left kernel of the matrix. So lets translate A to B = A'





As we mentioned before, the matrix that comes out from factoring problem is huge (in the order of billions of row/columns). Our goal is to minimize the size of the matrix before the kernel computation in order to make this operation possible. So let's filter

Removing duplicates The first step of filtering is extremely trivial. It is simply about removing the duplicate rows in the matrix. As weird at it sounds having those rows is inevitable though in the factorization context (because lattice sieving with many distinct special q-primes will produce identical relations).

Removing singletons The rule of removing singleton is as simple as the removing duplicates above: if there is a row in B that contains only a single entry that is non-zero module 2 them the column containing non-zero entry can not occur in a dependency. Such column, called singleton, can be removed from B (together with the respective row). In order to give an example let's use a simpler matrix then B above called M



Now let's apply the removing singleton filter:



M . But we are not done yet as you can see this removal generated a new singleton (the first column of the new matrix) so several passes are normally requited before all singleton are normally removed from M . Continuing until the very end may not be worth the effort though (we will see in the next post how to handle this part).

Conclusion Filtering is a really important step in Number Field Sieve and it is implemented also in important integer factorizatiion tools as CADO -NFS, Msieve and GGNFS. In this blog post we covered the first to phases of filtering as removing duplicates and removing singleton. Stay tuned for the last two steps removing cliques and merging coming in part II of the blog post series.



For more crypto goodies, follow me on Twitter.







As we said in this example we focus onthat is part ofso in order to showcase it, we borrow a simpleexample from "An Introduction to Mathematical Cryptography" Again, without going to much in details, the goal here is to find a subset of all these relations whose product is a square on each side of the equality. This is equivalent to: the sum of the exponents in all chosen relations must be even. If you wonder why, we are trying to leverage one of the simplest of the identities in all of the mathematics:But let's not diverge from out today's topic and let's focus on filtering. The problem above can be translated in a linear algebra problem. If one sees the relations as rows of a matrix where each column corresponds to an ideal, the coefficients of the matrix are the exponents of the ideals in the relations. As we are looking for even exponents, one can consider the matrix over GF(2).Finding a linear combination of relations such as every exponent is even is equivalent tocomputing the left kernel of the matrix. So lets translatetoAs we mentioned before, the matrix that comes out from factoring problem is huge (in the order of billions of row/columns). Our goal is to minimize the size of the matrix before the kernel computation in order to make this operation possible. So let's filterThe first step of filtering is extremely trivial. It is simply. As weird at it sounds having those rows is inevitable though in the factorization context (because lattice sieving with many distinct special q-primes will produce identical relations).The rule of removing singleton is as simple as the removing duplicates above:. Such columncalled, can be removed fromrow). In order to give an example let's use a simpler matrix thenabove calledNow let's apply thefilter:So we removed the first row and column of. But we are not done yet as you can see this removal generated a new singleton (the first column of the new matrix) so several passes are normally requited before all singleton are normally removed from. Continuing until the very end may not be worth the effort though (we will see in the next post how to handle this part).is a really important step in Number Field Sieve and it is implemented also in important integer factorizatiion tools asand. In this blog post we covered the first to phases ofas rand. Stay tuned for the last two stepsandcoming in part II of the blog post series.

But let's go in order...