Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: schnuber on May 14, 2016, 08:11:58 PM



Title: What is the probability of a bitcoin address starting with "11..." ?
Post by: schnuber on May 14, 2016, 08:11:58 PM
Hi
This is not a very important question that some statistics geeks of you probably may answer easily.
I wonder because I am currently writing code that creates a bitcoin address, and this question just occurred to me.

Greets


Title: Re: What is the probability of a bitcoin address starting with "11..." ?
Post by: vlamer on May 14, 2016, 09:40:53 PM
can i answer this question with yes or no  ;D
maybe this can explain your question https://en.bitcoin.it/wiki/Vanitygen (https://en.bitcoin.it/wiki/Vanitygen) , because I also just learned from there.


Title: Re: What is the probability of a bitcoin address starting with "11..." ?
Post by: hhanh00 on May 15, 2016, 02:38:28 AM
The first 1 comes from the address version and is always there for a normal bitcoin address. Every other 1 requires a byte equal to 0 is the pub key hash.
- 11: 1/2^8 = 1/256
- 111: 1/2^16 = 1/65536
- 1111: 1/2^24
etc


Title: Re: What is the probability of a bitcoin address starting with "11..." ?
Post by: jl777 on May 15, 2016, 03:41:06 AM
The first 1 comes from the address version and is always there for a normal bitcoin address. Every other 1 requires a byte equal to 0 is the pub key hash.
- 11: 1/2^8 = 1/256
- 111: 1/2^16 = 1/65536
- 1111: 1/2^24
etc

are you sure?
It seems base58 would have a 1/58th chance for a '1'


Title: Re: What is the probability of a bitcoin address starting with "11..." ?
Post by: 2c0de on May 15, 2016, 08:47:02 AM
1/58

about 1.7%


Title: Re: What is the probability of a bitcoin address starting with "11..." ?
Post by: amaclin on May 15, 2016, 09:06:16 AM
are you sure?
It seems base58 would have a 1/58th chance for a '1'
There are no bitcoin addresses starting with "1Z...", "1Y..."
The formula for probability is more complicated


Title: Re: What is the probability of a bitcoin address starting with "11..." ?
Post by: hhanh00 on May 15, 2016, 09:42:58 AM
1/58

about 1.7%

That can't be this simple since 100% of the p2kh addresses begin with 1  ;)


Title: Re: What is the probability of a bitcoin address starting with "11..." ?
Post by: shorena on May 15, 2016, 07:58:47 PM
are you sure?
It seems base58 would have a 1/58th chance for a '1'
There are no bitcoin addresses starting with "1Z...", "1Y..."
The formula for probability is more complicated

No?

Code:
Address: 1ZXt58NWzZaGxmdcYBccLJL2WNQrTqhuR
Privkey: 5JCQvCDYtQ9fKkkngyAMsS2przu41Gv5KfC4F7zC4XYbikJyXQX

Address: 1YoF7HgrHKxrSH3TyawU9r61DkShpqKd6
Privkey: 5K8r11CxkJy3nJURHEUjpt1zRP8gChNparReacZKsLi2zpCbzoR

For a reference that hhanh00 is correct, see the footnote (marked with *), here[1]

[1] https://en.bitcoin.it/w/images/en/9/9b/PubKeyToAddr.png


Title: Re: What is the probability of a bitcoin address starting with "11..." ?
Post by: amaclin on May 15, 2016, 08:04:20 PM
Oups. Sorry.
There are no 35-character long (this is most popular length for standard address) addresses starting with "1Z...", "1Y..."
The probability to generate such address is less than 1/58
So, the probability for others is not 1/58  :D


Title: Re: What is the probability of a bitcoin address starting with "11..." ?
Post by: deepceleron on May 16, 2016, 03:35:12 PM
The first 1 comes from the address version and is always there for a normal bitcoin address. Every other 1 requires a byte equal to 0 is the pub key hash.
- 11: 1/2^8 = 1/256
- 111: 1/2^16 = 1/65536
- 1111: 1/2^24
etc

are you sure?
It seems base58 would have a 1/58th chance for a '1'

Base58 conversion always preserves leading 0 bytes by directly encoding them as a "1" at the start of an address. This is the reason all standard Bitcoin addresses start with 1, because of the hard-coded network ID byte of 00 for Bitcoin.

A byte can store a value 0-255; the chance that the next byte (the first digit of the hash) is also 0x00h is 1 in 256, and so on.

The Bitcoin address in it's native binary form (that you never see) is 25 bytes, it's parts are:
byte 0: Network ID Byte (0x00 for main bitcoin network)
byte 1-20: ripemd160 hash (20 bytes) of sha256 hash (32 bytes) of 0x04+public key (65 bytes)
byte 21-24: checksum: first four bytes of sha256 hash of sha256 hash of bytes 0-20 above


Only after the leading byte preservation is the address then put through Base58-encoding.

The other non-related "answers" seen in this thread are also wrong: because the largest Bitcoin address (all FFFFs for the hash plus checksum) is 1QLbz7JHiBTspS962RLKV8GndWFwi5j6Qr, there are strange address probabilities. The chance of an address starting with characters 12 - 1P is about 1-in-23; an address starting 1R-1z must be a 33 character or less address, and chances are 1-in-1353. As we now know, starting in 11 is 1-in-256.