How to create a Bitcoin address from a Public Key?

12 Feb 2015

As seen in our guides to elliptic curve cryptography and how to create a Bitcoin Private key – a public key is in fact just coordinates on the Bitcoin curve calculated through multiplying the generator point by the private key number.

x coordinate= 7a633d546e723c3f41794549272f63617057382a227b6d393b35303d38

y coordinate= 44437a7439746e35565d3a27713c706423557e78444f4e767a22515724

These numbers are shown in Hexadecimal format, or 256 binary digits shown as 64 hexadecimal digits. If the number was shown in decimal format it would be 1077 figures long.

If you take these two coordinates and concatenate them i.e. join them end to end to make a 128 characters long string in Hexadecimal format, and then hash them whilst adding to the front a 1 (to indicate an address on the main network, if the address was for the testnet it would start with an m or an n).

Public_K=G Private_K=(x,y)
Address=(Network Version) & Ripemd160(sha256(x&y) & checksum

There is also the checksum to add which is essentially a hash of the address of the hash of the address – this is to check that the address is what it is – to stop typos et al.

Checksum=First four bytes of sha256(sha256((Network Version)&Ripemd160(sha256(x&y))

The last step is to change the coding structure into a more readable format or Base58 in the case of Bitcoin. Base 58 is similar to base 64 but with a few characters removed. Base64 uses A-Z, a-z, 0-9, + and /.

Base 58 uses the same symbols but removes +,/,0,O, I and l. All the symbols that could be confused for each other are removed making the format readable. The end result is a Bitcoin address of between 27 and 34 characters long! Such as below.

1BitBE9zZDwTGhXJwPSapWtViWJf2NJYyt

Notice that this address begins with 1 meaning it is a Bitcoin main network address and also that the first three characters spell the word Bit – in other words this is a vanity address.