This article is for any individual who is interested in blockchain yet has no clue about what it is by and large. The objective is to cause you to get what is blockchain. Here, we are starting with an analogy of money transfer from one bank account to another account. Keep in mind, blockchain has numerous utilizations cases, money transfer system is one of them.
Imagine four friends John, James, Peter, and mark meet up for a dinner and after they are done John pays the bill and all of them decide to split the bill amongst each other. James sends his own share to John via bank transfer and the transaction was successful. Peter and Mark send their respective share to John via bank transfer but the transactions failed. The failed transactions sight some issues at the bank. We have many ways bank transactions could fail:
- sometimes due to technical issues at the bank
- daily transfer limit being exceeded
- additional charges associated with transferring money and so on. To solve this problem the concept of cryptocurrency came into existence.
Cryptocurrencies are a form of digital or virtual currencies that runs on a form of technology known as blockchain. Cryptocurrencies are immune to counterfeiting, they don’t require a central authority and they are protected by strong and complex encryption algorithms.
Going back to our analogy Peter, James and Mark now decide to use bitcoin so they send two bitcoins each to John as their contribution to last night's dinner. Let’s assume Peter, James and Mark have three bitcoins each in reserve and John has five bitcoins.
First Peter sends two bitcoins to John
A record is created in form of a block that contains the transaction details between them. This block also holds the number of bitcoins each of the friends own. Since Peter sends two bitcoin he now has one bitcoin left and John gains two more bitcoins.
Next James sends two bitcoins to John a new block is created for each of these transactions.
and a new record is created also
Mark also sends two bitcoins to John
And again we have a new record created
These blocks are linked to each other as each of them takes reference from the previous one with a number of bitcoin each friend has.
This chain of records or blocks is called a ledger and this ledger is shared among all of them this forms the basics of blockchain.
Now, James, has one bitcoin left what happens if he tries to send two bitcoins to John again? the transaction will fail this is because all his friends have a copy of the ledger, and is clear that James has only one bitcoin left. His friends will flag this transaction as invalid.
A hacker will not be able to alter the record in the blockchain because each user has a copy of the ledger and the data within the block are encrypted by complex algorithms. All of these are made possible with the help of blockchain technology.
Blockchain can be described as a collection of records linked with each other strongly resistant to alteration and protected using cryptography.
An Overview of Cryptography
In cryptography, a keypair is often used for encryption and decryption of data. Let’s say John needs to send Peter a critical, secret message
- Peter generates a keypair. This keypair consists of a private key and a public key.
- Peter sends his public key to John. Peter never shares his private key with anybody. He can share the public key with as many people as he pleases.
- Once John has Peter’s public key, he’ll write his message and use Peter’s public key to encrypt this message. The encryption process transforms the message into an unreadable random string of characters. For example, when Hello is encrypted, it can become PWwN4DxlM+jT4wov/4UdJUdW6s=
- John then sends the encrypted message to Peter. The only way to get the understandable original is to decrypt it with the private key. Peter’s private key is the only key that can decrypt a message encrypted with his public key. This procedure is very secure because even if someone intercepted it, he wouldn’t be able to make any sense of it without Peter’s private key.
Now let’s go through this process for a real-world scenario. Every user in the bitcoin network has two keys, a public key, and a private key. A public key is an address that everyone on the network knows of just like an email address of a user while a private key is a unique address that only a user has knowledge of just like a password.
Let’s take a closer look at James and John transactions and find out how it works. James passes the number of bitcoins he wants to send to john along with his and John’s wallet address through a hashing algorithm remember all of these are part of transaction details. These details are encrypted using an encryption algorithm together with James' unique private key. This is done to digitally sign the transaction and to indicate that the transaction came from James. This output is transmitted across the world using John’s and this transaction can only be decrypted by John’s private key which only John has knowledge of. Different cryptocurrencies use different hashing algorithms for example bitcoin use sha256 and ethereum uses Ethash and so on.
These transactions are taking place all over the world and are validated and added block by block. The people who validate these blocks are called miners and for a block to be validated and added to the blockchain miners need to solve a complex math problem. The miner who solves this problem first, and adds the block to the blockchain is reward with 12.5 bitcoins. The process of solving this complex mathematical problem is called proof of work and the process of adding a block to a blockchain is called mining. With this James and John's wallets are updated just like everyone on the bitcoin network. That is all for now.