Factoring Lab

Receipts for factoring ideas: which work, which don’t, and how fast they stop working.

A4 · The graveyardWorks only on weak keys

Searching near √N

is instant when p and q are close together, and hopeless when they are random. Real keys keep them far apart.

The idea

Fermat noticed N = a² − b² = (a − b)(a + b). Start with a just above √N and step up until a² − N is a perfect square b². If p and q are close, that happens on the first step. Each doubling of the distance between p and q makes the search about four times longer.

Watch it

The test

Seeded keys with 31-bit p and q = p + about 2^k, for k from 4 to 26. The chart shows steps against the distance; above the knee the line climbs with slope 2.

Fig. A4.2Fermat steps against the distance between p and q (31-bit primes)

Measuring…