Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: BlackHatCoiner on October 26, 2020, 07:26:09 PM



Title: Calculating the storage that would be needed to store all addresses.
Post by: BlackHatCoiner on October 26, 2020, 07:26:09 PM
All private keys are 2256, but all addresses that can exist are 2160, which is an enormous difference. This means that there must be some address collisions.

If I wanted to calculate the storage that would be needed for 1M of addresses I would do that on a csv file:
Code:
PRIVATE_KEY1,ADDRESS1_LEGACY,ADDRESS1_BECH32,ADDRESS1_P2SH
PRIVATE_KEY2,ADDRESS2_LEGACY,ADDRESS2_BECH32,ADDRESS2_P2SH
...
PRIVATE_KEY10000000,ADDRESS10000000_LEGACY,ADDRESS10000000_BECH32,ADDRESS10000000_P2SH

One line is 165 bytes:
Code:
L1CaDFTppeWGoz7pstPR1B8GUCTa2vw5C2fHBGp1G33vQd9PepBM,1BUp7h85TuZxPFarjD2zjChPpr5Upwnj1A,bc1qwtearx8uglkvf2ehv37na5k7myl9sll9uyjqx0,3PE7q99B22vj3qHYesF8YSioTpwC1EYCtk

So, 1 million of addresses would be 165 million bytes which is equal with 165 megabytes. Pretty heavy csv file, my computer would crash if I opened it.

_______________________________________________

But how about 2256 lines? Well, that's:

115​792​089​237​316​195​423​570​985​008​687​907​853​269​984​665​640​564​039​457​584​007​913​129​639​936 times 165.

= 1910569472415717224488921252643350479578954746983069306651050136130566639058944 0 bytes

We can't pretend to understand that number, but let's try. Based on this quora (https://www.quora.com/What-is-the-physical-size-of-one-byte-on-a-current-computer-hard-drive-and-how-does-that-compare-with-one-bit-of-information-on-the-DNA-molecule-like-guanine-cytosine-or-adenine-thymine) link, the 2018's 3D flash drives contain 1600 bits per cubic nanometer. This means that we will need:

9,552,847,362,078,586,122,444,606,263,216,752,397,894,773,734,915,346,533,255,250,680,652 cubic meters of pure hardware.

Universe has been calculated that it's 1.8 x 10^28 cubic meters. That's 1/530713742337699229024700347956486244327 of the needed hardware space. Have I made any mistakes? Because it seems too huge to me.


Title: Re: Calculating the storage that would be needed to store all addresses.
Post by: jackg on October 26, 2020, 08:12:58 PM
That's only 700 square light years though if it's right (you should've used a factor of 10^-27 for converting metres to nanometers).


Title: Re: Calculating the storage that would be needed to store all addresses.
Post by: BlackHatCoiner on November 04, 2020, 08:08:24 PM
That's only 700 square light years though if it's right (you should've used a factor of 10^-27 for converting metres to nanometers).
So, will I get an even bigger number? Isn't it going crazy?


Title: Re: Calculating the storage that would be needed to store all addresses.
Post by: jackg on November 04, 2020, 10:48:14 PM
That's only 700 square light years though if it's right (you should've used a factor of 10^-27 for converting metres to nanometers).
So, will I get an even bigger number? Isn't it going crazy?

Yeah if you didn't cube the 10^-9 then it'll be out by a factor of 10^18...

If you need an explanation, a decimetre square is 10cmx10cmx10cm. This is 1000cm2 but is also 0.1x0.1x0.1=0.001m2.


Title: Re: Calculating the storage that would be needed to store all addresses.
Post by: odolvlobo on November 05, 2020, 04:56:04 AM
All private keys are 2256, but all addresses that can exist are 2160, which is an enormous difference. This means that there must be some address collisions.

An address is an encoding of a 1-byte network value plus a 20-byte hash, plus a checksum. So, the space needed to store an address is 21 bytes. Since there are 28 possible network values and 2160 possible hashes, the amount of space needed to store all of the addresses is 21 x 2168 bytes, or approximately 8x1051 bytes. That's equivalent to 8,000,000,000,000,000,000,000,000,000,000,000,000,000 1 TB drives.

However, it raises the question, why would you want to store every address, when any address can easily be generated?

As for collisions... Yes. Each possible address can be derived from an average of 297 private keys, which is an extraordinarily small number compared to the 2256 possible private keys.


Title: Re: Calculating the storage that would be needed to store all addresses.
Post by: odolvlobo on November 05, 2020, 05:20:52 AM
So, 1 million of addresses would be 165 million bytes which is equal with 165 megabytes. Pretty heavy csv file, my computer would crash if I opened it.

I see. You are really asking about how much space is needed to store a private key for every address.

Since a private key is 256 bits (plus a checksum and an 8-bit prefix that we can assume is always 0x80), it requires 32 bytes. The space required to store a private key for every address is 32 x 2160 bytes, or approximately 4.7x1049 bytes.

Assuming that you can store 200 bytes (1600 bites) in a nm3, that means that the volume required is 235,000,000,000,000,000,000 m3 ( 4.7x1049 / 200 / 1027 ).