2026-08-17 · 7 min read
Randomness, Entropy and What Your Browser Actually Does
Computers are deterministic machines, so genuine randomness has to come from outside the arithmetic. Modern operating systems maintain an entropy pool fed by physical noise: the exact timing of interrupts, keystroke and mouse jitter, disk and network latency, and on most current CPUs a hardware noise source built into the silicon.
That pool seeds a cryptographically secure pseudo-random generator. 'Cryptographically secure' has a precise meaning: even with the entire output history in hand and unlimited computing patience, you cannot predict the next bit better than guessing, and you cannot run the generator backwards to recover earlier output. That property is what makes it suitable for encryption keys — and more than sufficient for dice.
Math.random offers none of that. It is fast and it is fine for shuffling a background animation, but implementations use small, non-cryptographic algorithms, the seed is not protected, and the output can be reconstructed from a modest sample of previous values. Any roller that decides real outcomes with Math.random is one determined viewer away from being predicted.
The browser exposes the good generator as crypto.getRandomValues, which fills a typed array with uniform random bytes. Getting from uniform bytes to a fair colour is where the last mistake hides.
Take a 32-bit value and compute value modulo 6. There are 2^32 possible inputs, and 2^32 is not a multiple of 6; the remainder classes are not the same size, so four of the six faces get one extra input each. The bias is about one part in seven hundred million per roll — undetectable in practice, but free to eliminate, and 'undetectable' is not a word that belongs in a fairness claim.
Rejection sampling removes it. Compute the largest multiple of 6 that fits under 2^32, and if a draw lands above that cutoff, throw it away and draw again. The discarded region is what caused the imbalance, so the remaining values divide perfectly by six. The expected number of extra draws is effectively zero, and the result is exactly uniform rather than nearly uniform.
Put together, that is the whole fairness story of this site: a hardware-seeded cryptographic generator, reduced without bias, executed on your own machine, with no seed stored and no server involved. There is no state for anyone to inspect, poison or replay — including us.