How likely is it that someone could guess your Bitcoin private key?
By: Bram Van Genabet
Tags: Cryptography, Bitcoin

How likely is it that someone could guess your Bitcoin private key?

There are 2¹⁶⁰ possible Bitcoin addresses out there. And yes, that is a lot.

1,461,501,637,330,902,918,203,684,832,716,283,019,655,932,542,976 to be precise…

So if you wanted to get reassurance that you don’t need to panic sell your precious HODL’ed bitcoins, then I can tell you “Hakuna Matata”. No need to worry.

I found the answer on the Bitcoin wiki about the (un)likeliness of hash collisions not very satisfactory…

Because the space of possible addresses is so astronomically large it is more likely that the Earth is destroyed in the next 5 seconds, than that a collision occur in the next millenium.

Large numbers are fascinating, but there must be a better way to quantify the risk someone would randomly guess your Bitcoin private key. After all, computing power rises exponentially, so is it really correct to assume this will not happen in the foreseeable future?

“There are more Bitcoin addresses than atoms in the universe.”

There are an estimate 10⁸² atoms in the observable universe. That includes all galaxies and blackholes in a 46.5 billion light year radius. Even though it sounds plausible that there are more Bitcoin addresses than atoms in the universe, after all 2¹⁶⁰ sounds larger than 10⁸², the statement is in fact very wrong. It just illustrates how bad the human brain is at imagining vast numbers.

When writing out 10⁸² it becomes a little bit more visible

10,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000

There are ~ 6.8 *10³³ less Bitcoin addresses than atoms in the universe. But again it is difficult to imagine how much less. Written in full, it might become a bit more clear : 6,842,277,657,836,020,854,119,773,355,907,794. But let’s face it, big numbers are hard to imagine.

To avoid being deceived when comparing large numbers it helps to express them on the same base : 2¹⁶⁰ =10^(log2)*160 ~10⁴⁸. Comparing the amount of Bitcoin addresses to the size of the universe does not really help to appreciate how large a number 2¹⁶⁰ really is.

Let’s imagine a lot of sand… 2¹⁶⁰ grains to be precise

For arguments’ sake, the other popular statement “there are more bitcoin addresses than grains of sand on earth” is indeed true. There is an estimated 2⁶³ (~ 9.2*10¹⁸) grains of sand on earth, so for each grain of sand there are 2⁹⁷ (~1.5*10²⁹) bitcoin addressess. Well that doesn’t make it much easier to imagine now, does it? Let’s try it in a different way.

Imagine you’re walking on a beautiful beach and you’re watching all those grains of sand. Now imagine all the grains of sand on the entire coastline, even those under the water, for as far as you can see . This is not even close to where we’re heading. Imagine you zoom out from where you’re standing to imagine all the sand from all beaches in the country, the continent and eventually the entire planet.

Now line up all these grains of sand in an endless row and imagine each grain of sand is an entire new earth with the same amount of grains of sand. Since earth has a radius of 6,371km, this row would be 3.1*10²¹ light years long. The observable universe has a diameter of 93 billion light years, so this row of earths would stretch 33.5 billion times the entire diameter of the observable universe.

Are we getting close? Not really… We now have reached 2⁶³ * 2⁶³= 2¹²⁶. This amount of sand would still only be 0.0000000058% of the amount of Bitcoin addresses in existence. The remaining part a factor of 2³⁴ (2¹³⁶*2³⁴ = 2¹⁶⁰). This would correspond to the surface of a square with a length of 2¹⁷ earths (131,072) stacked next to each other. This is ~11 times the distance between the earth and the sun.

So there we have it. The amount of possible bitcoin addresses would correspond to the amount of sand grains in a square of 131,072 x 131,072 earths next to each. One edge of this square would cover the distance between the earth and the sun ~11 times. Then stacking this square of earths on top of each other to reach 33.5 billion times the lenght of the entire observable universe. That’s the closest I could come to imagine how to visualize the vast amount of possible Bitcoin addresses out there.

I don’t know about you, but I actually enjoyed trying to visualize how astronomically large 2¹⁶⁰ really is. Maybe it’s because I like spending time on the beach…

How safe is your bitcoin address?

The risk of someone finding the private key of a wallet which contains any Bitcoin will depend mainly on two things : how many wallets with bitcoin exist and how many wallets can be generated in a reasonable time.

In February 2020 there were a reported 615,463,205 Bitcoin addresses with a non-zero balance. Since there will only be a total of 21 million Bitcoins each consisting of 10⁸ satoshis, the absolute maximum of addresses that can contain any Bitcoin at the same time is 2.1*10¹⁵. This is about 29 million times more than addresses currently in use.

For the sake of argument let’s assume this worst case scenario. The highest possible amount of Bitcoin addresses that can each contain 1 satoshi is 2.1*10¹⁵. This is 4392 times less than the amount of sand on earth.

Since the surface area of earth is 510 million km2, 1/4392th would be 116,120 km2. This is more or less equivalent to the surfce area of Greece (131,057 km2)

So the probability of finding a bitcoin address with 1 satoshi in a perfectly distributed situation, would be equivalent to the amount of sand in Greece on 1 of those earths in the vast beam of earths that streches 33.5 billion times the observable universe.

Now since you probably have only 1 or 2 bitcoin addresses with a substantial amount, the chances of someone randomly guessing the private key to your address, would be equivalent to finding 1 specific grain of sand.

Extremely unlikely.

… but wait, there is Moore !

Ok, bad joke. But I genuinly wondering with all the computing power we have right now which is growing exponentially, how safe are we really from someone accidentally stumbling on your unique grain(s) of sand?

The total hashrate of the entire BTC network stands right now at 144 EH/s = 144*10⁶ TH/s = 144*10¹⁸ H/s. Let’s assume that this is the rate at which bitcoin addresses can be generated and checked if they have a balance or not. In reality this will be a lot slower, because bitcoin uses a double hash and the checking of the balance also will take a bit of time. But anyway, let’s see where this would take us.

The approach to calculate the probability of any search generated key in an address containing bitcoin would be to assume we have a large bucket of sand with white and black grains. Each white grain represents an address with balance (max 2.1*10¹⁵) and each black grain represents a possible address (2¹⁶⁰).

Let’s calculate how many attemps would be needed to have a 10% change of finding at least 1 white grain of sand (address with a balance). This can be expressed as :

probability of finding at least one white grain

= 1- (probability of finding a black grain)^(number of attempts)

probability of finding a black grain

= 1 - #addresses with non-zero balance / # max number of addresses

= 1- (2.1*10¹⁵ / 2¹⁶⁰)

= 0.9999999999999999999999999999999986

10% probability of finding a white grain means(probability of finding a black grain)^(number of attempts) = 0.9

number of attempts = log(0.9) / log( 0.9999999999999999999999999999999986 ) = 7.52575E+31

Assuming all bitcoin miners in the world would start to generate addresses at a hashrate of 144*10¹⁸ H/s it would take about 16572 years to have a 10% chance of finding 1 address with 1 satoshi.

Using the same principle, finding the key of 1 particular address would a bit longer. It would take 4882 billion billion billion billion years for a 10% chance to find 1 specific key.

Moore’s law states computing power doubles every 18 months. The fastest miner currently achieves a hashrate of ~100TH/s. Let’s assume the hashrate increases another 100 fold in the next 10 years bringing it to 10000 TH/s. And now lets assume population has grown to 10 billion people and we give each person 1000 of these miners. This would bring the global hashrate to approximately 10²⁹ H/s.

How long would it take to find 1 address with 1 satoshi?

10% probability to find at least one address would take ~12 minutes

90% probability to find at least one address would take ~4.5 hours

Well there we have it. But then again this last scenario isn’t going to happen anytime soon. The current electricity computer of all bitcoin miners combined adds up to the power of ~7 nuclear power plants. Assuming the energy efficiency for the hashrate gets a 1000x more efficient, the above scenario would still require ~4.8 million nuclear powerplants each generating 1 GW.

Moreover, it would be far far easier if this were to become reality to fork bitcoin to an enhanced protocol using a different hash function bringing it for instance to 2²⁵⁶ …

How random is random?

One major consideration I do need to mention is the randomness of random. If the private key to derive the bitcoin address from is not purely random but only covers a subset of the 2¹⁶⁰ possible combinations, the probability of collissions would dramatically increase. Obviously simple passphrases like sha-256(‘bitcoin’) would be very easy to find.

To illustrate it you can try it.

from hashlib import sha256

passphrase = 'bitcoin'

sha256(passphrase.encode('utf-8')).hexdigest() >>>6b88c087247aa2f07ee1c5956b8e1a9f4c7f892a70e324f1bb3d161e05ca107b

If you generate a bitcoin address from this private key you get the address 1E984zyYbNmeuumzEdqT8VSL8QGJi3byAD … and yes this address is empty but it has been used in the past and we all have access to it.