Nowadays there has been a lot of buzz around cryptocurrencies and blockchain. This has in part helped by the record breaking prices of Bitcoin and Ethereum. According to google trends report, the interest in blockchain is as high as ever:
There are those who are putting in money into initial coin offering(ICO) in hopes of hitting the next big jackpot. Then there are those who want to use the innovation called “blockchain” in different implementations.
Blockchain offers a world of opportunities in our hyper connected world. But there seems to a be general confusion around the technology. Over the years, I have been interested in learning the technological aspects of cryptocurrencies. I have always found the articles online to be too technical or abstract to make sense of things. Please follow along my journey as I understand each part of the crypto currency phenomena.
What is cryptocurrency?
As per Wikipedia: A cryptocurrency (or crypto currency) is a digital asset designed to work as a medium of exchange using cryptography to secure the transactions and to control the creation of additional units of the currency.
Let’s breakdown the definition even more:
Asset by definition is something we own and have rights to use. Example, a house is a physical asset. A digital asset is something which exist digitally on a computer. A good example will be your last vacation pics. These are your digital assets.
Medium of exchange is something which can be used to trade. Example, the money in your wallet is a medium of exchange. You can exchange it to get a burger, a car ride or even the house which turns into asset later.
Cryptography in pure layman terms is study of hiding information. A good example will be finding a way to securing or hiding your facebook password.
Now when we talk about a digital asset – think of your vacation photos. I can create copies of them by simply doing copy and paste. Here cryptography is used control the “copies”.
So these currencies are cryptographically secured and act like currency. Hence, the moniker “cryptocurrency”.
What types of Cryptocurrencies and blockchains are available?
By last estimate there were over 840 different coins. Some of them defunct while others with negligible value. If you talk to someone who is into the cryptocurrency scene, they will tell you there are two major currencies:
- Bitcoin – Satoshi Nakomoto created bitcoin back in 2008. He also introduced the innovative technology of blockchain.
- Ethereum – As years passed, people found blockchain could go beyond it’s original purpose. It lead to coins like Storj – decentralised storage using blockchain etc. Each of the coins catered to a single purpose. Vitalik Buterin released Ethereum in 2015. It made it easier for people to utilize blockchain technology for whatever purpose they saw fit using “smart contracts”.
Confused? Have tons of questions like:
How does one own it?
How does one spend it?
What does cryptographically securing transaction mean?
Let’s look at this one step at a time. First step:
The very first challenge in digital money is – ownership. It’s easy in case of government issued currency. If I hold the cash in hand, I am the owner. If it is a non-cash transaction then my signature is the proof.
How are digital currencies solving this? (note: words in italics are technical terms)
Encryption is a way to ensure data or message can only be read by the intended recipient. While this doesn’t stop people from intercepting the message in between it ensures they cannot find out what the actual data/message is. Think of battle plans, whatsapp messages, your emails or even those snapchat pictures etc.
There are three parts to this – first the plaintext which is the original message. Then there is a key which is used to encrypt the message. Once the plaintext goes through encryption it becomes ciphertext. The process of deciphering the ciphertext back to the plaintext is known as decryption.
There are two types of encryption:
This was the very first form of encryption. It is called symmetric because encryption and decryption can be done using the same key. To understand this let’s look at an example:
The oldest known symmetric key is Caesar Cipher. The idea was to shift the alphabet by 3. So,
H = K
O = R
This is how encryption and decryption of a simple message flow will look like between two people – Mr. Red and Mr. Green:
As you can see both encryption and decryption requires the same key.
2. Asymmetric encryption
If you understand the nature of symmetric encryption, this shouldn’t be a tough one to guess. Using the same key to encrypt and decrypt no longer works:
So how does it work really? By using public-key infrastructure (PKI).
In public key encryption, everyone generates one set of keys – private and public. The public key is be shared with everyone. While only the owner is aware of the the private key. Now for a two way communication a key exchange needs to happen.
Let’s re-look at the above example to establish communication between Mr. Green and Mr. Red:
Step 1. Both of them create their own public and private key pairs
Step 2. Both of them need to have the other person’s public key. The sharing can be through publishing it outright to doing an exchange as shown here. Important – Never share your private keys.
Step 3. Now two-way communication can happen between Mr Red and Mr Green. Mr. Red can send message encrypted using Mr. Green’s public key. Mr. Green can decrypt the message using his own private key:
Similarly, Mr. Green can reply back using Mr. Red’s public key. Red’s private key is required to de-crypt this reply. Thereby establishing two-way communication.
Public-private key pair uniqueness is the most important feature of public key encryption. You can think of this as unique as your own thumb print. This uniqueness is utilized to create digital signatures.
Going back to our example above – Suppose at some point Red doubts Green’s identity. So Red can ask Green to prove it. Green does this by writing a message and sending it along with a signature generated using the private key. Once Red receives the message, he can then use the public key on the message and verify the identity:
Cryptocurrencies utilize the same idea to ensure ownership.
The first thing your wallet gives is – a string of numbers and alphabets – also known as your address. This is where your digital coins are stored. The address is the public key portion of PKI and can be shared with anyone. People are only associated with their public key which ensures anonymity.
Wallet also generates a private key. It helps to prove your ownership of the coins via digital signature.
Pro-tip 1: Never share your private key with anyone. This is very important as you can lose control of your coins.
A good example of this happened back in 2013. Matt Miller on Bloomberg bought a physical bitcoin card. He unintentionally showed the private key on live TV. Someone stole his bitcoins. Video here:
Pro-tip 2: Always secure your private key using a strong password. It ensures an extra layer of protection. Even if someone hacks your computer they will be unable to use the private key.
Expanding on ownership, let’s look at an advanced feature provided by crypto currencies – Multiple-Signatures or Mutli-Sig.
Public-private pair key is required to generate digital signatures. In multisig, the pairing goes beyond the 1:1. It changes the equation to multiple private keys mapped to a single public key. Furthermore, we can create a rule outlining the number of private keys required to generate valid signature.
Let us go back to our example, Green runs a business with his partner Blue. A key paired created is of type 2 out of 2. Then while interacting with Red, the only way to generate a valid signature requires both Green and Blue private key too. If either of them sign a transaction with only their key, it becomes invalid:
To expand this, let’s assume there is a new partner – Yellow. So, we can create a new key “pair”. This will follow 3 out of 3 rule. So, unless all three sign there is no way to generate a valid signature.
Key can also follow the “2 out of 3 rule”. In which case signing requires any two keys. So, any two of three, Yellow, Blue or Green, can sign a transaction.
The important point here is the combination can be anything we want. So, we can do –
3 out 5 – 3 keys required out of 5
2 out 5 – 2 keys required out of 5
7 out of 10 – 7 keys required out of 10
Now that we have resolved the ownership problem, here’s the second one – While the public key infrastructure (PKI) works for two-way communication. How do we ensure mass communication between people for currency transactions? We will cover this aspect in part 2.
Also published on Medium.