encryptionbitcoinbase58

Bitcoin Address Logic


I am trying to work through some very basic numbers and need a check to see if logically this is correct.

When looking at Bitcoin, there are 2^160 addresses. Bitcoin uses Base58 encoding so there are 24 lower case letters, 24 upper case letters, and ten numeric digits.

Thus, let's say I used Vanitygen and wanted to get an address starting with 1TEST, hypothetically my chances of finding an address starting with 1TEST are 1 in 58^5. Would it be correct to say that the number of bitcoin addresses starting with 1TEST is 2^160/58^5? Thus there are 2.2^39 addresses with 1TEST?


Solution

  • Meta: this is not a programming question and probably belongs on bitcoin.SX, as the tag description says. And it definitely has nothing to do with encryption.

    Nearly. First, bitcoin's base58 is actually alphabet 9 digits, 24 lowercase, 25 uppercase. More important, an encoded address begins with a 'version' (really type) byte, but leading 00 bytes are encoded specially, so the first character 1 actually corresponds to a type byte of 00 meaning plain traditional keyhash (not test, not script, not privatekey). The next 4 characters, if NOT beginning with more 1(s), do represent the high-order digits of the hash, and since TEST cannot not match in the unbalanced part of the range that takes 1+33 chars, it does cover an exact 1/58^4 fraction of the space, i.e. 2^160 / 58^4 which is about 2^136.6.