Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Kwothe117 on December 16, 2017, 01:59:28 AM



Title: Private keys
Post by: Kwothe117 on December 16, 2017, 01:59:28 AM
I'm starting to get my head around Bitcoin, Blockchain etc. but I want to learn more about private keys, their generation, and use.

As I understand any 128-bit sequence can be a private key which can, in turn, be used to generate a 32-bit address using a one-way function.

1. Is there a set of rules that narrow down what is a good private key?
2. Is there anything in place to avoid collisions (multiple private keys to one address) other than statistics?

Also, roughly how many public addresses are currently storing bitcoin?


Title: Re: Private keys
Post by: aplistir on December 16, 2017, 07:29:12 AM
I'm starting to get my head around Bitcoin, Blockchain etc. but I want to learn more about private keys, their generation, and use.

As I understand any 128-bit sequence can be a private key which can, in turn, be used to generate a 32-bit address using a one-way function.

1. Is there a set of rules that narrow down what is a good private key?
2. Is there anything in place to avoid collisions (multiple private keys to one address) other than statistics?

Also, roughly how many public addresses are currently storing bitcoin?


Some mistakes in your text. Any 256bit number works as a private key, and addresses are 160bit.

1. There are no set of rules that narrow private keys, but my own opinion is that there should be. While it is unlikely that your private key would be really small, or close to 1/2 or 3/4 of the search space (psychological values, where humans could start searching for your key) You still would not want your private key to be there.
2. Nothing to avoid collisions, except the huge amount of possible keys, which makes a collision extremely improbable.

About 2 months ago there were:
~21600000 addresses containing some balance and
~661000 addresses containing > 1BTC


Title: Re: Private keys
Post by: samson on December 16, 2017, 08:08:54 AM
The the OP : You need to read the manuals which explain how Bitcoin actually works.

Developer Guide : https://bitcoin.org/en/developer-documentation

Developer Referrence (contains everything in low level detail) : https://bitcoin.org/en/developer-reference

These are the things you need to learn about :

sha256
ripemd160
ECDSA using secp256k1 for signature creation and verification

Also what a public key is and how it's used to create and verify a signature based on some arbitrary data like an sha256 hash. It's not like RSA where something is encrypted with one key and decrypted with the other, that's not how it works with ECC.

Forget anything you're read about RSA, it's not applicable here.


Title: Re: Private keys
Post by: bob123 on December 16, 2017, 09:00:41 AM
1. Is there a set of rules that narrow down what is a good private key?

A private key is a 256 bit number. So basically there is just 1 (very important) rule: Randomness.
The RNG is probably the most popular attack path when trying to crack (implemented) crypthographic functions.


2. Is there anything in place to avoid collisions (multiple private keys to one address) other than statistics?

Multiple private public keys to one address referes to hash collision:
Since there are 2^256 public keys and 2^160 addresses, there are 2^96 public keys which match to one address (on average).
 
For address collision (where 2 people accidentially generate the same address (spendable priv-/pub- keypair for this address):
Not statistics is keeping this from happening, but maths. 2^160 is about 1,460,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.
There isn't enough energy on earth to even generate a small percentage of all of those addresses.


Title: Re: Private keys
Post by: DannyHamilton on December 16, 2017, 09:18:59 AM
- snip -
there are 2^256 public keys and 2^160 addresses,
- snip -
2^160 is about 1,460,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.
- snip -

Or precisely:
1,461,501,637,330,902,918,203,684,832,716,283,019,655,932,542,976

- snip -
Also, roughly how many public addresses are currently storing bitcoin?

- snip -
About 2 months ago there were:
~21600000 addresses containing some balance and
- snip -

Note that there could NEVER be more than 2,099,999,997,690,000 addresses storing bitcoins at any moment in time.

Furthermore, due to lost bitcoins and some addresses storing more than 0.00000001 BTC, the actual maximum number of addresses that ever WILL store bitcoins at any given moment in time will ALWAYS be SIGNIFICANTLY less than 2,099,999,997,690,000 addresses.

Therefore, the absolute worst case scenario (an imaginary situation where there actually are 2,099,999,997,690,000 addresses storing bitcoins) would result in less than:
0.0000000000000000000000000000002 % of the available address space being used to store bitcoins at any moment.


Title: Re: Private keys
Post by: Kwothe117 on December 18, 2017, 09:12:32 AM
Thanks guys for clearing that all up for me! Great answers. Seems like I've got some reading up to do but I'm really impressed by blockchain :D