Factoring Lab

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

C1 · Weak keysWorks only on weak keys

Shared factors: batch GCD

1,000 toy keys from a bad random generator; a product tree finds every pair that shares a prime.

The idea

If N₁ = p·q₁ and N₂ = p·q₂, then (N₁, N₂) = p, found in microseconds with Euclid’s algorithm. Checking every pair of a million keys is too many pairs, so multiplies all keys together in a tree and works back down, testing each key against the product of all the others at once.

Watch it

Twelve toy keys from a good generator and six from a broken one, shuffled. The batch GCD column is computed against the product of all the other keys at once.

The test

1,600 seeded toy keys (two 32-bit primes each); 5% come from a generator that picks primes from a pool of 60. We compare what flags with which keys really share a prime, and time it against all-pairs for 50 to 1,600 keys.

Fig. C1.2Time to check n keys: every pair against batch GCD

Measuring…