Intermediate Lesson 5 4 min read

The size of 2^256: why no one can guess a key

The key space is not large, it is absurd. This lesson measures the wall with numbers that one can imagine, and shows where it really gives way.

Every time someone understands that a private key is just a number, the same question arises: what if I keep trying numbers until I get it right? It's a good question, and the answer isn't "it's difficult." The answer is that the attempt hits a wall of physics before it hits engineering, and it's worth seeing how big that wall is.

A private key has 256 bits. This means the number of possible keys is 2 multiplied by itself 256 times: approximately 115 followed by 75 zeros. Writing the quantity is easy; imagining it is not, and the comparisons usually made all fail in the same direction — they are too small.

The grains of sand on all the beaches and deserts of Earth are about seven and a half quintillion, a number with nineteen digits. The stars in all the galaxies that telescopes can reach total something close to ten sextillion, with twenty-two digits. The atoms in the observable universe are around 10^80 — and this is the first comparison that finally surpasses the key space, by a difference of a thousand times. If each possible key received one atom from the universe, there would still be a thousand atoms left for each one.

If each grain of sand on Earth were an attempt, the search wouldn't have even started.

Such large numbers become more concrete when you pay for them in energy. The entire Bitcoin network currently calculates around one sextillion hashes per second, the largest computational effort ever assembled by humanity for a single task. If it stopped mining and started testing keys at this rate, it would cover about 3 followed by 28 zeros per year — and it would take more than 10^48 years to sweep the space. The universe is 13.8 billion years old, a number with eleven digits.

The hardest limit isn't even this, and it was calculated by Bruce Schneier in 1996. There is a minimum amount of energy that any computer needs to spend to change a bit of state, and it comes from thermodynamics, not technology. Doing the math with this theoretical minimum, a perfect computer that captured all the energy emitted by the Sun for thirty-two years would only be able to count up to 2^192. Count. Without verifying anything, without comparing it to any address. And 2^192 is a negligible slice of 2^256.

Counting that high isn't expensive: it's impossible. The energy of an entire star doesn't come close.

Now for the honest correction, because the real security isn't 2^256. There are algorithms that attack the private key through the public key and solve the problem in about the square root of the space — which cuts the exponent in half and brings the effort to the order of 2^128, or 34 followed by 37 zeros. It's the subject of the module on key search, in the advanced track. And 2^128 remains out of reach by a wide margin: the Sun's calculation above already shows that not even 2^192 fits, but even reducing it that much, the number is still larger than the grains of sand on the planet multiplied by itself.

What can be done, and what the world does, is reduce the interval. No one searches in 2^256; they search in 2^70, in 2^80, in ranges where someone already knows the key is. Each bit less cuts the work in half, and it's this arithmetic that separates a project from an impossibility.

It was never the size of the interval that fell. It was the size of the draw.

All the keys that have been discovered in practice fell through this path. None of them were guessed: they were poorly drawn. The phrase chosen by a human, the broken Android generator that the previous lesson mentioned, the tiny interval of a test that became a real wallet. The size of the number never failed; what fails is the draw, and the draw is the only part that depends on someone having done the job right.

This gigantic number, in practice, you never type. It is written in four different ways, and confusing one with the other makes a wallet appear empty without anything having disappeared. In the next lesson, key formats.