Blockchain 101 - What are they? What do they do? Why should I care?
Blockchains have become incredibly popular over the past few years. But what are they are, what do they do and what problems do they actually solve.
As the name says, a blockchain is a chain of blocks, and - simply put - these blocks contain data and, sometimes, executable programs. None of that sounds particularly remarkable initially, as computers have been storing data and executing programs for over half a century. Blockchains, however, have some particular properties that do make them very useful for certain scenarios.
The blockchain concept was originally described by Haber & Stornetta in their 1991 article relating to time stamping documents. They proposed a blockchain concept so that it was not possible to back date documents or to tamper with them.
However, as useful as this technique was, it went by largely unnoticed until……was adapted by Satoshi Nakamoto in 2009 to create the digital cryptocurrency - Bitcoin. Now, to this day, no one really know who Satoshi Nakamoto is - that’s the name used by the unknown person or people who developed bitcoin, authored the bitcoin white paper, and created and deployed bitcoin's original reference implementation. Bitcoin became phenomenally popular due its use of blockchain which meant that financial transactions could not be tampered with.
This was incredibly important when there was little or no trust as it ensured that both parties had no choice but to honour transactions executed on the Bitcoin network.
It is important to note that the rise of cryptocurrencies, like bitcoin, were largely due to the resilience and immutable nature of the blockchain technology. However, although cryptocurrencies rely on the blockchain technology, the reverse in not the case, blockchains do not rely on a crypto currency. In order to understand this, let’s dive into the blockchain technology to understand how it works.
This is a block. A block contains three main elements. It contains...
2. A hash…
3. And the hash of the previous block.
The first element of a block is the data. The type of data that is stored within the block depends on the type of blockchain.
The bitcoin blockchain stores the details of a financial transaction in the block, such as the Sender, Receiver and the Amount of bitcoin to be transferred. However, financial or cryptocurrency transactions are not the only type of data that a blockchain can store.
A blockchain could store legal agreements……or medical records……or data relating to the shipping and transport of goods. In fact, a blockchain can store any type of data in a tamper-proof way.The second element of a block is the hash.
A hash is kind of like a finger print. It identifies a block, and all of its contents and it is always unique. Once a block is created, then it’s hash is calculated. One of the unique properties of a hash is that it is always the same length regardless of the amount of data being hashed.
For example, if we use a hash algorithm to hash a telephone number then it will create a cryptographic finger print of a certain length. If we use the exact same algorithm to hash the entire text of Tolstoy’s novel “War and Peace” then it will create a different cryptographic finger print of the exact same length. Therefore, it is impossible to determine the size and complexity of the data being hashed by looking at the hash fingerprint itself. However, if you change a number in the phone number or just a single character or comma in Tolstoy’s “War and Peace” then the hash fingerprint also changes.
Therefore, hashes are very useful when you want to detect changes to blocks. If the hash of a block changes then it is no longer the same block and you therefore know that the block has been tampered with.
The third element inside a block is the hash of the previous block. This effectively creates a chain of blocks and it is this technique that makes the blockchain so secure.
Let’s take an example. Here we have a blockchain containing four blocks. As you can see, each block stores its own hash and the hash of the previous block. So, block number 4 points to block number 3,number 3 points to number 2,And number 2 points to number 1. Now the first block is a bit special, it cannot point to the previous block because it is the first one. We call this block the “genesis” block.
Now, let’s say, you tamper with the third block. This causes the hash of the block to change as well. In turn, that will make block 4 and all following blocks invalid too because they no longer store a valid hash of the previous block. So, changing a single block will make all following blocks invalid.
But, using hashes is not enough to prevent tampering. Computers today are very fast and can calculate tens of thousands of hashes per second. So, you could effectively tamper with a block and then recalculate the hash for that block and all subsequent blocks to revalidate your blockchain.
In order to mitigate against this, most public blockchains have something called “Proof of work”. It’s a mechanism that slows down the creation of new blocks.
In bitcoins case, it takes about 10 mins to calculate the required proof of work and add a new block to the blockchain. This makes it very difficult to tamper with the blocks, because if you tamper with one block, you have to recalculate the proof of work for that block and all subsequent blocks in order to make the blockchain valid again.
So the security of the blockchain comes from its creative use of hashing and its proof of work mechanism.
The only downside of Proof of Work is that it can consume a lot of energy and processing power to complete the task.Therefore, some blockchains are beginning to use a more efficient means of preventing blockchain tampering by using something called “Proof of Stake”.
Proof of stake is a means of creating blocks using each nodes “stake” based on, for example, their age or wealth. We’ll talk about Proof of Stake in more detail in subsequent articles.
But there is one more way that blockchains secure themselves… ….and that is by being distributed. Instead of using a central entity to manage the chain, blockchains use a peer-to-peer network which many people are allowed to join.
When someone joins the network, …they get a full copy of the blockchain. In this way, their peer, or node, uses this copy to validate that they have an exact match of the blockchain when compared to all the nearby peers in the network.
So, let’s see what happens when someone creates a new block. That block is sent to everyone on the network. Each node then verifies the block to make sure it hasn’t been tampered with. Then, if everything checks out, each node then adds this block to their blockchain. All the nodes then check up on each other to verify that they agree with this being the next block.
This is what we call “Consensus”. All nodes must agree which blocks are valid and which blocks aren’t. Blocks that are invalid are rejected by the nodes in the network. We will discuss “consensus” in more detail in later articles.
Therefore, to successfully tamper with a blockchain……you’ll need to recalculate all the hash values for all the blocks on the blockchain following the tampered block……recalculate the proof or work for all of these the blocks… …and successfully take over control… …of over 50% of the peer-to-peer network. Only then, would your tampered block be accepted by everyone else.
There are many, many uses for blockchains in modern business. Any system that would benefit from data being immutable and trustworthy could make use of blockchains. Blockchains are not only for cryptocurrencies, like Bitcoin, but could be used in the medical, supply chain and legal industries too, to name just a few.
However, in order for blockchains to be useful, they do need to execute code logic. The source code for this code logic is stored on the blockchain too, as data, so it cannot be tampered with either. Executable programs that are stored on the blockchain are often referred to as “Smart Contracts”. We’ll discuss Smart Contracts in more detail in a later articles.