the bitcoin age

A new era has begun

How Bitcoin keys work

ARTICLES

How Bitcoin keys work

Come funzionano le chiavi di Bitcoin

One of the essential elements for the functioning of Bitcoin and, in general, of all cryptocurrencies, is the system of public key cryptography, also called asymmetric cryptography. This system consists of key pairs in which:

  • the public key is distributed within the network;
  • the private key remains personal and secret.

The public key is generated from the private key through a hash function (in English “to hash” also means to chop in small pieces). This function is called “non-reversible”: once this function is used, the string obtained as a result can no longer be traced back to the string that generated it.

This is why it is also called asymmetric cryptography: it is easy to go in one direction (from the original string to the encrypted one) but you cannot go in the opposite direction (from the encrypted string to the original one).

Asymmetric vs symmetric encryption

This type of cryptography, invented in the 1970s, is an evolution of symmetric cryptography, which dates all the way back to the time of the Roman Empire. Julius Caesar, in fact, is considered by many to be the father of cryptography because he used the so-called Caesar’s cipher to protect his messages in an encrypted manner. This system involved each letter being replaced by the letter that was a certain number of positions later in the alphabet. Caesar generally used a key of 3, so he would write D instead of A, E for B, F for C, and so on. His grandson, Emperor Augustus used it with key 1, so B for A, C for B, and so on.

Even the famous “pizzini” of the Mafia boss Bernando Provenzano, the slips of paper that allowed the boss to communicate during his fugitance, were created using a system similar to Caesar’s cipher. Each letter was replaced with the corresponding number in the alphabet added to 3, so words and names were transformed into seemingly meaningless numbers.

The problem with this system is that if the key is discovered, the entire message can be deciphered, and thus it is a “reversible” system. With symmetric encryption, therefore, it is easy to go in one direction (from the original message to the encrypted one) but it is possible (even though more difficult) to go in the opposite direction (from the encrypted message to the original one), which is impossible in asymmetric encryption.

How Bitcoin transactions work

Asymmetric cryptography, which underlies, among other things, digital signatures and passwords, is an essential element in how Bitcoin works, not only because of how public keys are generated from private keys (and then the Bitcoin address – a sort of bank account number – from public keys), but also because of how the transactions themselves take place.

In Bitcoin’s blockchain, in fact, this type of cryptography allows transactions to be sent securely on a distributed ledger (blockchain) and also allows any node in the network to verify that transactions have occurred correctly.

How transaction work on the Bitcoin blockchain, thanks to public and private key cryptography, can be easily explained with the following analogy:

Alice needs to send a box to Bob but she does not want anyone other than Bob to be able to open it. So Alice asks Bob to send her an already opened lock of which Bob will keep the key. Alice receives the lock from Bob, closes the box and sends it to Bob. Bob receives the box and can open it with the key of which he is the sole owner. Anyone who intercepts the open lock or the box with the closed lock cannot do anything with them because does not have the key.

In Bitcoin, the lock of the example represent the public keys and the key represent the private keys. Asymmetric encryption thus allows bitcoin to be sent without anyone who just sees the transaction being able to take them in any way.

Only those in possession of the private keys can dispose of the bitcoins received. Hence the famous saying “not your keys not your coins” (by Andreas Antonopoulos), which emphasizes the importance of personally keeping the custody of the private keys instead of giving them to a third party (such as the exchange where the bitcoins were bought with traditional money) in order to use bitcoin in the most correct and secure way.

Image Credits: Yegor Petrov