Introduction To Blockchain & Cryptocurrency

Introduction To Blockchain & Cryptocurrency

Content

Background

In this article, we would like to understand Blockchain & Cryptocurrency. Why it exists & how could you leverage it as a developer. We will not look at any piece of code in this article, but definitely yes in the coming post.

I am a full stack developer by passion, started learning blockchain about 1 and half years ago. I have done several blockchain projects & achieved Blockchain Developer Nanodegree certification in the past 6 months.

Prerequisites

None for this article. After reading it several times, I think even a first-year undergrad student could read and understand it. I would love to hear if you have watched HBO's show Silicon Valley.

Photo: HBO. The fictional Richard Hendricks explains an Internet of mobile devices in HBO's Silicon Valley.
Photo: HBO. The fictional Richard Hendricks explains an Internet of mobile devices in HBO's Silicon Valley.

At The Core - Data

The reason a thing like a blockchain exists is because of our data. Data that is generated when you text someone, transfer money, add a post in LinkedIn, send email to colleague.. and so on. The data we create on the internet could be stored at various places around the world. 100s of feet underwater in oceans or football court size data centres spread across the world. That's right it is not with you or even if you believe you have backed it up on your hard drive but "they" still have it.

Any transaction you do with the bank, sending money to friends and family or receiving your monthly salary from your workplace or institution via bank; "they" have it on the record somewhere how much you earn, how much you spend, what you would like to buy and more. That is why we have so many laws (and new ones coming every year) to protect your data from being misused.

I think you get the idea now, how critical & volatile is data. Wouldn't it be awesome if we control data, how it is stored & make it anonymous? Even quantum computers might not be able to get into data & make a copy.

The idea of Blockchain tries to solve this issue. It aims to make data distributed and at the same time Anonymous, bringing in world-class security algorithms to cipher - a secret or disguised way of writing the information so that only "allowed" people or people who own the data can access it.

Baran, P. (1964). On Distributed Communications, Memorandum RM-3420-PR.
Baran, P. (1964). On Distributed Communications, Memorandum RM-3420-PR.

The above diagram tells us different ways data can be stored at the place(s). (It tells even more, but let us limit our scope to data for now).

  • Centralized: Information is stored at a single location and all the systems - stations that are part of the network strongly depends on it.
  • Decentralized: Information is not at one place, it is at several places. Perhaps as a backup or keeping just the grouped relevant ones. Stations form partially independent clusters.
  • Distributed: Aha! Every station has the data and even if a single or group of stations get its data corrupted, the rest are unaffected and would help them restore data by distributing copies.

In brief, blockchain brings two things to the table, data distribution & security :

  1. Use of it will make information distributed i.e. there won't be any central authority who stores our data and could potentially misuse it. 
  2. This distributed information is Anonymous - meaning even if someone has a piece of your data, it would be cipher text - not readable unless decrypted.

There are three terms that one should know when learning about blockchain:

  1. Hashing: It is essentially a process whereby you convert (hash) a piece of information into a fixed or varying size hexadecimal value such that it is impossible to get back the original piece of information. It is an irreversible process.
  2. Encryption: When we say we want to encrypt a piece of information, we would like to convert it into cypher text - a secret message and later it could be converted back to its original form.
  3. Decryption: The process of finding original information from an encrypted form is termed decryption. The reverse of encryption.
We will have an entire article to practically see how to hash, decrypt and encrypt a piece of information with Node Js.

Blockchain

After understanding why something called blockchain was introduced and what problem it tries to solve, I think it is time we understand what is blockchain. Let us first imagine the context and then formally know what it is. 

You must have seen a banking statement of your account. It contains the list of "transactions". A list of how much money was added at a particular date - time & how much was deducted when you went shopping last time. The list containing all debits and credits from a given start date to a given end date. Below is an example of Alice's banking statement from 26th May 2020 to 5th June 2020.

An example of how a banking statement looks like.
An example of how a banking statement looks like.

The technical term for the above statement table is Ledger. The above Ledger has transactions of Alice's account only. Our current banking system maintains a ledger of this kind for every account holder & it is this table that helps them to solve the double-spending problem.

Double-spending is a potential flaw in a digital cash scheme in which the same single digital token can be spent more than once. Unlike physical cash, a digital token consists of a digital file that can be duplicated or falsified.
Wikipedia: https://en.wikipedia.org/wiki/Double-spending

I would not like to go in deep with the double-spending problem, I think the above line from Wikipedia is clear and concise.

Essentially we do not want to give all powers to a central authority. It is your money, only you should be in charge of it. Why have a 2nd entity like a bank that knows each and everyone's financials? Blockchain comes to the rescue.

Blockchain is a distributed ledger containing information. No single person owns this ledger & information stored in this ledger is encrypted. Information once added to the ledger cannot be manipulated, it is strictly immutable! We can add new entries in the ledger but cannot modify or delete previous ones.

Distributed Ledger

Let us try to understand a bit more about the distributed ledger, the problems it could have without blockchain.

Imagine we put transactions of every family members, friends, colleagues, cousins, etc. in one ledger not just Alice's. Then distribute it in the network instead of asking a central authority like a bank to maintain it. Two practical problems with that :

  1. Ledger would be huge! Imagine having 1 million people's transactions in 1 table 😄
  2. Right to privacy! People can see how much money another person has, that's dangerous!

Blockchain breaks down the complete list of transactions into smaller blocks. Each block has a small part of the entire ledger. Several thousands of small blocks form the entire ledger consisting of everyone's financial transactions (or information). It is not just one person whose transactions are present, millions of people.

The estimated number of global crypto users has passed 100 million. Around 106 million people are now using cryptocurrencies around the world, Crypto.com estimated in a report.
Source: Business Insider India

All the information inside blocks is strongly encrypted thus maintaining anonymity. Person A cannot see Person B's financial transactions or information without having consent from person A. Since the information stored is immutable therefore it solves the double-spending problem too.

We will talk about giving consents, how information is secure and related things in the next article. I want to cover the basics only in this one. So for time being just assume that these mechanisms are present.

Cryptocurrency

If you noticed, I have used the terms "financial transactions", "information" and "data" interchangeably above. Ultimately blockchain is distributed ledger and the ledger is broken down into smaller chunks with blocks. So it is up to us what we want to store in this ledger. We can perhaps store the birthday date of a person or we could use it to store financial transactions. We could even save real-estate documents in it. How about our profiles? So we can store anything in the ledger!

It is when we have a blockchain consisting of only monetary transactions, we call the currency mentioned in transactions as cryptocurrency. As simple as that!

Crypto is a Greek word meaning hidden

Since the blockchain is secure and uses cryptography methods to secure the data - encrypt, decrypt, sign & verify; it is commonly referred to as cryptocurrency. We will see these cryptography methods in the next article.

I would like you to think it through for some time: What decides buying/purchasing power of cryptocurrency? If I have 100 "foobar" in the blockchain ledger then what can I buy with this 100 "foobar" and which shop will accept this "foobar" cryptocurrency?

Bitcoin & Blockchain

Bitcoin and Blockchain are not the same!! Bitcoin is a cryptocurrency, built with blockchain! I hear people referring to bitcoin as blockchain. If I have a class Person in programming and I call a particular instance of the class (object) "John"; Bitcoin is just like an instance of Blockchain.

We would not go into the dynamics and details of bitcoin but here are two more terms that you might have heard: bitcoin mining & bitcoin miners.

Miner: It is the system that creates a new block after filling it with a lot of new transactions and attaching it with the blockchain ledger. Of course, someone cannot simply put any random transactions - they need to be verified. Let us talk a little bit about this Verification.

Consensus: It is essentially a protocol or set of rules that help Miner to prove to other Miners that the transactions contained in the block are legitimate. So every time before a block gets added to the blockchain it is first verified by several Miners who are part of the same network and then it gets added to the blockchain & accepted by other network nodes (remember ledger is distributed? everyone gets a copy)

Generally, in every cryptocurrency blockchain, miners are rewarded with a fraction of the cryptocurrency involved in the transactions. Consider it analogous to Transaction Fees bank might charge when you do a large number of transactions, transaction fees are like a reward for the miner.

This introduces competition among miners for rewards. That is another reason to have a consensus algorithm. It ensures validity & difficulty in mining new block. 

For Bitcoin, they have a consensus algorithm called Proof-Of-Work, where a miner is required to compute a difficult number with the help of transactions in the memory pool. At the same time, it is very easy to check the validity of this computed number with the help of transactions. Other miners check the validity of this number if it is correct & a majority of miners agree then the block with bitcoin transactions is pushed into blockchain and distributed.

Memory pool: Transactions that are not yet part of the blockchain. These have happened very recently and a miner would put these transactions in a block following consensus algorithm & finally it gets added to the blockchain. The memory pool gets empty & now new transactions can come in. Practically speaking, the memory pool is never empty in the Bitcoin blockchain!

Conclusion

I think we have learned why blockchain exists, what it is, how it operates & what are cryptocurrencies. I wanted to keep this in very simple to understand fashion and yet a little different from what you might have read at several places. I hope you enjoyed it, see you at the next one :)