Factoring Lab

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

C2 · Weak keysWorks only on weak keys

p and q too close

on toy keys with shrinking , and the rule in the standards that prevents it.

The idea

Write N = a² − b² = (a − b)(a + b). When p and q are close, a = (p + q)/2 is just above √N and b is small, so , which tries a = ⌈√N⌉, ⌈√N⌉ + 1, … finds them in about (q − p)²/(8√N) steps. A generator that picks q as “the next prime after p” makes that one step.

Watch it

The test

For q − p from 2 to 2³⁰, 60 seeded toy keys each (31-bit p, so N stays below 2⁶⁴), Fermat with a budget of 1,000 steps. We find the distance where half the keys survive and compare with the formula. Then 60 properly made keys get a budget of 100,000 steps each.

Fig. C2.2Share of keys Fermat breaks within 1,000 steps, against the distance between p and q

Measuring…