A neat overview
Just like in traditional banking systems, Bitcoin makes use of addresses in order to send or receive funds. All of this is done automatically and transparently by your Bitcoin client. To understand Bitcoin addresses, you need to know how asymmetric encryption works, and more specifically the relation between private and public keys. Recall that in asymmetric (or public key-) encryption, there is a pair of mathematically related keys: a private key and a public key. Messages can be encrypted with any of these, but decrypted only with the opposite key. For example, what has been encrypted with the private key can only be decrypted by the public key. Similarly what has been encrypted by the public key, can only be decrypted by the private key. By keeping the private key “private” and sharing the public key with as many people as possible, anyone who receives a message that can be decrypted with your public key can be sure that you were the author of the message, since only the owner of the private key could create it.
Bitcoin addresses are simply the hashes of public keys. Since Bitcoin makes use of Elliptic Curve Cryptography (a more secure variation of traditional asymmetric crypto), the process of generating an address looks as follows:
2. Through elliptic curve multiplication (don’t worry about the details), K is translated into the public key L.
3. The pub key L is hashed through SHA256.
4. The obtained hash is hashed again through RIPEMD160, resulting in a 160bit hash. This is your Bitcoin address.
It is important to never share private keys. Anyone with access to one of your priv. keys is able to spend the balance of the address associated with it.
Here are a few examples of what Bitcoin addresses look like:
The dirty details
There are a few important details which I deliberately omitted. If you only wanted to get a basic idea of BTC addresses, this should be the case now. If you are interested in all of the details, read on.
Private keys , public keys, and Bitcoin addresses are encoded in a user-friendlier format. This is called Base58 and consists of a total of 58 letters and numbers, except the dubious ones such as (I, l, 0[zero], O) in order to prevent typos. In addition, an identifying prefix allows to easily distinguish between them. For example private keys have the prefixes “5, K, or L” and Bitcoin addresses “1” or “3”. This means that because 15Es24Cq9Gq4VKZ4QbYwYmo5YSuQ39DQxZ begins with a “1” it is a Bitcoin address. Kx1ohbM6hgCBhAG81qedBUjdM4W7FA6aKUsyQbWZUna6T42kJ8i6 starting with a “K” can only mean it is a private key. As you can see, these encoded formats are a lot handier than a 256-digit string such as
Another safety measure against typos is a checksum, which is appended at the end of a private key or address. This is simply the first four bytes (32bits) of a double-SHA256 hash of the private key or address and their prefix. Let us see what all of this means when creating a Bitcoin address. Note that prepending either 0 or 5 before the Base58 encoding leads to either 1 or 3 as an address prefix.
Another detail which was left unmentioned is that public keys in Elliptic Curve Cryptography represent points on a geometrical curve. Therefore they consist of an X value and a Y value for each corresponding axis. Because the curves are horizontally symmetric, there are two ways of indicating the coordinates. You can either define X and Y with their respective coordinates, or you can only define X and tell whether Y is positive or negative (+ or -). Let us visualise this:
The red point on the elliptic curve has the coordinates X = 2.2 and Y = 2.6. One way of indicating its position is to simply write down both coordinates: (2.2, 2.6). Alternatively, because the curve is symmetric you can only give the X-coordinate and indicate whether Y is above or below the horizontal line: (2.2, +).
The second method has the advantage of reducing data. Usually these points are hundreds of digits long. By indicating only one of the points, and whether the other is positive or negative, you save 50% of valuable space.
Because a Bitcoin address is a hashed public key, this introduces a problem. Hashing (2.2, 2.6) would give a completely different address than hashing (2.2, +). Recall that a public key is derived from the private key. Therefore one private key corresponds to two addresses.. and we need to know which one to use. The solution is simple: add “01” at the end of the private key whenever the compressed notation (X, +/-) is to be used. With a Base58 encoding, this always results in either K or L as private key prefix. Otherwise, if (X,Y) notation is to be used, the resulting prefix is always 5.
Now you should know the most important details about Bitcoin addresses.