Secrets from primes

Every secure website relies on clock arithmetic with enormous primes. Here is the same machinery with small ones: drag the hand to choose a message, and watch the prime-built key scramble it and bring it back.

A clock with n = 3 × 11 = 33 hours. Each faint chord joins an hour x to x³ mod 33, where encryption sends it; no two hours land on the same place, so the scramble can be undone (the small loops mark hours that encrypt to themselves). The hand is the message (here 4); the red arrow is its ciphertext, the dashed green arrow the way back, taken with the private exponent d = 7. Drag the hand around the rim or type a message; change p, q and e to build other clocks. These numbers are teaching-sized and offer no security at all.

Begin with the primes themselves →

A prime number can be divided evenly only by 1 and itself: 2, 3, 5, 7, 11, 13 and on forever. Multiply two large primes and you get a number that nobody can split back into its factors in any reasonable time, even though anyone can check that a number is prime almost instantly. That one-way door, used on the dial of clock arithmetic, is what protects your connection to a bank, an email server or this page.

The three chapters below build it up from the beginning. First the primes themselves: what they are, why 1 is not one, how to find them with the sieve of Eratosthenes, how they thin out, and how to prove that a 24-digit number is prime without finding a factor. Then clock arithmetic: remainders, when you can divide on a clock, and why powers on a prime clock always come back to 1. Then the locks: RSA, Diffie–Hellman, and how large real keys are. Every figure can be operated, and the tools below answer the questions people most often bring.

How this is made and checked

Every number on this site is computed exactly, with whole-number arithmetic of unlimited size; no floating point touches a remainder, a factor or a verdict. The prime checker proves its answers (by trial division up to 1012, and above that by a strong primality test whose 13 bases are known to be enough for every number below 3.3 × 1024) and refuses larger numbers instead of guessing. The engine is tested against published tables: the counts of primes below each power of ten, every Carmichael number below 560,000 and every strong pseudoprime to base 2 up to 486,737, the known Mersenne primes, and the worked example in the original RSA paper. An independent reviewer checks every claim against its source, and every simplification is named next to the figure that makes it. More about how it is checked.