What Exactly is a Bitcoin Address?

At a high level, a bitcoin address comprises of 256 1’s and 0’s pushed through some algorithms to result in a ~34 character string that can be given out to receive funds.

A bitcoin address as a QR code representing: 18BgGGrBms3eGCRj2Vvrxso4XzWjJEEMBv

That’s the short version. Here is the long version.

What does a bitcoin address look like?

Here is a sample bitcoin address: “18BgGGrBms3eGCRj2Vvrxso4XzWjJEEMBv”. A random combination of numbers and letters. I generated it with my bitcoin wallet and it is ~33/34 characters long which is the typical length of a bitcoin address.

A neat thing you can do is go to blockchain.info and check out the history of this address. ie the amount of bitcoins received and the amount spent. It is a public ledger after all! https://blockchain.info/address/18BgGGrBms3eGCRj2Vvrxso4XzWjJEEMBv

But what exactly is a bitcoin address?

Fundamentally, a bitcoin address comprises of 256 random 1’s and 0’s. You could flip a coin 256 times with heads being 1 and tails being 0 and have the beginnings of a bitcoin address. Because 256 digits of 1’s and 0’s is not very convenient to write, it is often represented as hexidecimal. This is what is commonly referred to as your private key.

1 hexidecimal character represents 4 bits. So 256 bits will result in a 64 length hexidecimal representation. Much easy to copy and paste and more friendlier to comprehend. (Relatively speaking.)

What happens next is a bit of magic. This private key then gets transformed into what is known as a public key via some wicked mathematics that was invented back in the mid 1980’s. The algorithm used is called Elliptic Curve Digital Signature Algorithm (ECDSA) which is a variant of DSA. If you are interested to know more, take your chances at this link, but don’t say I didn’t warn you.

The end result is a public key that is now 512 bits long + a prefix. ie it has essentially doubled in length. The reason being is that the public key is a point on a elliptic curve on a graph and as we know, graphs have x and y co-ordinates. 256 bits for the x and 256 for the y.

A special prefix of 04 is added to the front to signify uncompressed x, y coordinates. Again, it is represented in hex (65 chars) to make it a little easier on the eye. (Relatively speaking.)

The main thing to note is that this is a one way function. A public key is generated from a private key, but never the other way around. If someone managed to reverse this, all hell would break lose and life as we know it might just come to an end.

But wait, there’s more

So now we have a 65 character public key but I can’t quite call this a bitcoin address yet. It was decided by Satoshi originally to shorten or compress this to make it more user friendly. To shorten this, a hash function called SHA256 was used. A hash function is another mathematical wonder where no matter how big or small the input, the output will always be of a fixed length and will be unique to that output. (Where would we be without maths!)

So the public key gets put through the ringers again and via the SHA256 hash function, a string of 256 bits gets generated. I can hear you saying, isn’t that the same length as the private key? Yes it is!

Satoshi must have enjoyed it so much that he thought why not double rinse. But this time he used a different hash function called RIPEMD160. This further compresses the output to 160 bits (160 ones and zeros) which makes it 40 characters in length. We’re getting shorter!

The diagram above doesn’t show it, but another prefix is slapped on. It’s called a network byte ID to tell users if it’s a production address or a test address. 0x00 is used for mainnet and 0x6F used for testnet.

It always pays to check

Did you know that your credit card has a checksum? Basically a formula that allows anyone to very quickly check if the credit number is valid or not. Bitcoin has the same thing. A 4 byte checksum is calculated and slapped on the end.

The checksum takes the 160 bit hash of the public key including the network byte ID as well and does a SHA256 double rinse. (Satoshi liked his code clean!) Truncate the result and use only the first 4 bytes.

The resultant length is now 50 characters long.

The last step

Have you ever mistaken an O (the next letter after N) for a 0 (the numerical value zero) or an I (the next letter after H) for a lower case l (the next letter after k)? To remove this potential confusion, an encoding called base58 is used. An additional benefit is that it further reduces the length of the bitcoin address.

Doing a base58 conversion by hand is an intriguing process. One that you can see here. To cut a long process short, the 50 character bitcoin address reduces to anything between 26–35 characters long with the most common length being 33 or 34 characters. The reason why it various in length is because base58 conversion is essentially doing a division with a remainder and it depends on what number you start off with.

Conclusion

It is a bit of a process in understanding a bitcoin address. You start off with 256 1’s and 0’s, put it through the process of encrypting, hashing and encoding and at the end of the process, you get a string of ~33/34 characters that you can proudly show to the world when asking for donations or payments.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.