paint-brush
The Quick, 3-Step Guide to Blockchain Technology.by@thijsmaas
6,612 reads
6,612 reads

The Quick, 3-Step Guide to Blockchain Technology.

by OnramperOctober 24th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Ask 10 people “what is blockchain technology?” and you get 10 different answers — even in the crypto-scene itself. The best approach to forming a true understanding blockchain is by understanding the underlying technologies step-by-step.

People Mentioned

Mention Thumbnail
Mention Thumbnail

Company Mentioned

Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - The Quick, 3-Step Guide to Blockchain Technology.
Onramper HackerNoon profile picture

Understanding the 3 fundamental technologies behind Bitcoin.

Ask 10 people “what is blockchain technology?” and you get 10 different answers — even in the crypto-scene itself. The best approach to forming a true understanding blockchain is by understanding the underlying technologies step-by-step.

Therefore, in this post, I will go over the three main components of blockchain technology: the blockchain itself, peer-to-peer networks and consensus mechanisms. Bitcoin would not be able to exist if any one of these components did not exist. Let’s start with the blockchain.

If you can’t explain it simply, you don’t understand it well enough. — Albert Einstein

Einstein explaining blockchain technology, 1422 B.C.

1. Understanding the blockchain itself

In short, a blockchain is just a way to structure data. That’s all there is to it. It is a ledger: A file that keeps track of accounting records.

This file is comparable to a book that is never finished.

Each page in a book has information written on it and a page number on the bottom. Because of this page number, you immediately know where the page belongs in the book. Page 49 is obviously found between page 48 and 50.

Just like pages, blocks are filled with information. Although blocks don’t have exact numberings, they have a timestamp, which fulfills the exact same function. A new block is always added after the block with the most recent timestamp. As such, a chain forms.

The cool thing about blockchains is that they use cryptography to make sure that we notice it when any information on any page in the book is changed. This property makes it a good data structure to keep track of records of anything of value.

Use cases for blockchains.

In Bitcoin’s blockchain, the blocks contain information about transactions in Bitcoin. The block states who sents which Bitcoins to whom.

As the blockchain has been used to keep track of the movement of all Bitcoins since their inception, the ledger can be checked to know exactly who owns which Bitcoin at any time. The ‘who owns what’ at any time, is what we call the current ‘state’ of the blockchain.

A transaction only occurs once it is included in a block and added to the chain. Hence, when a block is added to the chain, the state of the blockchain is updated. After all, Bitcoins have moved.

This means that if I want to validate whether someone actually made a transaction to me or not, I have to be able to check the state of the blockchain. To be able to do this, the ledger has to be publicly available. This is where peer-to-peer networks come in.

2. Understanding the role of peer-to-peer networks

To use a blockchain as a ledger for transactional data, I have to be able to check in the blockchain if someone actually made a transaction to my address or wallet.

If the blockchain was only stored on one computer, and it happened to be turned off, this would be annoying to say the least. Therefore, the current state of the blockchain is downloaded, synchronized and made available by a large number of computers worldwide.

These computers are called ‘nodes’, and they work together in a peer-to-peer network to ensure the blockchain is secure and up-to-date. Every one of these nodes stores the complete, updated version of the blockchain. Every time a new block is added, all the nodes update their blockchain. Using a peer-to-peer network has certain advantages:

  • I can always check the state of the blockchain myself using a blockchain explorer.
  • I don’t have to rely on one party to know the true state of the blockchain.
  • I don’t have to rely on the security of one server to know the blockchain is secure.
  • A malicious party would have to hack thousands of computers at the same time, instead of one single server.
  • I can rest assured that the blockchain is never deleted, because it would have to be deleted by all nodes.

A server-based model vs. a peer-to-peer network

This is all very important, but the above doesn’t mean that the blockchain is now suddenly secure enough to be of any actual use to store or transact value.

For example, how do I know that the (transaction) data in the blockchain is correct? How do I know there are no invalid transactions in the blocks? And if there are different versions of the blockchain out there, how do I know which shows the true state of the blockchain?

These concerns are all taken care, in a quite ingenious fashion, by the consensus mechanism, the use of which is made possible in the first place by the peer-to-peer network.

3. Understanding the consensus mechanism

A peer-to-peer mechanism was used in ’99 already by Napster.

The blockchain, too, already existed before Bitcoin.

The ingenious part of Satoshi Nakamoto’s, the mysterious, anonymous founder of Bitcoin, white paper was combining the two with a consensus mechanism based on cryptography. The consensus mechanisms is where the real magic happens: it allows nodes in a peer-to-peer network to work together without having to know or trust each other.

“The purpose of a consensus algorithm is to allow for the secure updating of a state according to some specific state transition rules, where the right to perform the state transitions is distributed among (…) users which are given the right to collectively perform transitions through an algorithm” — Vitalik Buterin

Now, if you didn’t quite catch that, the consensus mechanism is simply a set of rules, which is agreed upon by the nodes in the network by running the software of the network. These rules make sure the network works as intended and stays in sync.

The consensus protocol sets rules on:

  • How blocks are to be added to the chain,
  • when blocks are considered to be valid, and
  • how conflicts of truth are resolved.

Adding blocks to the chain

Different blockchains add blocks to their chains in different ways. The most-known consensus mechanism is Bitcoin’s Proof of Work (PoW).

The first rule of Proof of work is that one block should be added to the blockchain, on average, every ten minutes.

The process to facilitate this is called ‘mining’. Nodes that try to add a block to the chain (called ‘miners’) use computational power of their computers to try and solve a cryptographic ‘puzzle’. The rules state that only when this puzzle is solved, a block can be added to the chain.

The miner that solves the puzzle, and therefore ‘mines’ the new block to add to the chain, is rewarded by the network. A predefined amount of new coins is created and given to him, together with the transaction costs of all transactions contained in the block.

Subsequently, all miners will start mining the next block.

A bitcoin mining rig. To have enough processing power to mine, you need a lot of GPU’s.

Bitcoin’s Proof of Work is not the only consensus mechanism. Proof of Stake (PoS) is also commonly used in distributed ledgers. In a Proof of Stake based mechanism, one can ‘stake’ his coins for a chance to be picked to add the next block. In a sense, a staker says: “ I bet my coins that I add this block correctly”. If he lies, he loses his coins.

There is a larger debate on which consensus mechanisms is best. Still, regardless of how the block is created, other nodes in the network still have to be able to decide on whether the block is valid or not.

The validity of blocks

When a miner solves the puzzle and mines the block, all the nodes in the network will check if the block is valid and add it to their copy of the chain. The nodes first need to reach consensus on the validity. Only then the network synchronises and the state of the blockchain updates.

Nodes will only add a newly mined block to the chain if it follows the rules stated by the consensus mechanism. The software they run checks if a block is valid or not. An invalid block will simply be rejected.

Naturally, a block is only as valid as the transactions contained therein. Using Bitcoin as an example, the rules of the protocol state that nobody can send bitcoins they have not first received from someone else or from mining a block.

In other words, the nodes’ software check for all the transactions in a block if the senders have received enough Bitcoin to make their transactions. To do this, they check the state of the network.

Now, let’s say I have received 1 Bitcoin, which I later send to Alice. I then try to send the same Bitcoin to Bob. As soon as the block with my first transaction in it is added to the chain, all nodes will update the blockchain to reflect that I don’t have that Bitcoin anymore. Any newly mined block that would contain my transaction to Bob would simply be rejected by the nodes. The nodes’ software sees that the block does not follow the rules, thus, they don’t update the blockchain for this block.

The rules also dictate that a transaction is only valid when it is signed with a digital signature from the owner of the bitcoin. Only the person who controls the wallet or address from which the bitcoin is send can sign of on the transaction. Therefore, only you can spend your Bitcoin.

How conflicts of truth are resolved

It can occur that, on accident, two miners add a valid blocks to the chain at the same time. Imagine that a part of the nodes have accepted one valid block and another part has accepted another block. The first group included a block with my transaction to Alice and the other included my transaction to Bob. Now we suddenly have have two different states of the blockchain at the same time!

We call this an (unintentional) ‘fork’: The blockchain has forked in two different chains. Does Alice or Bob have my Bitcoin? Which of the two chains is the ‘true’ blockchain?

Generally, all consensus protocols solve this problem with a simple rule: The longest chains wins.

Visualisation of blockchain fork.

When we have an unintentional fork, some miners will start mining on one chain, and others will start mining on another chain. Inevitably, one chain will have more miners than the other, and as such, will add new blocks to its chain faster. The rest of the miners will then switch over to the longer chain and the forked chain will always die out. No damage is done to the main chain.

Why do we know this will always happen?

Because miners are economic actors that act in self interest. A miner has no interest in mining on a forked chain, knowing it will die out. All transactions (state transactions) on the forked chain have never occurred on the main chain, which means that miners who mined blocks on the forked chain are not rewarded for their work. The miners’ opportunity cost of mining blocks that will not be included in the main chain is simply too high.

In rare occasions, it can occur that a forked chain has a substantial amount of mining power. In this case, it can take a while before it is clear which chain is the main chain. Conventional wisdom dictates that it is therefore wise to wait for 6 blocks to really confirm a transaction.

Visualisation of an extended blockchain fork. This almost never happens for more than 5 blocks.

The rule that the longest chain wins, combined with the fact that one needs immense processing power to add blocks to the chain makes the blockchain incredibly secure. Pretty much the only way to attack the network is by going back to some block in the blockchain, forking the chain and starting to mine new blocks from there. However, to do so, an attacker would have to re-do all the work done by miners from that point and catch up to the main chain. Without having more computational power than the whole network of miners combined, this is simply impossible. Simply said, the electricity and GPU’s needed for such an operation would be far to costly.

Conclusion

The above should be seen as a very brief introduction to how distributed ledgers work. You might now understand why “blockchain” is a bit of a misnomer for the distributed ledgers we see today.

However, next time someone mentions blockchains at a party, please don’t do what I just did and go: “H_ey man, a blockchain is only a way to structure data. I think you mean to refer to a distributed ledger used for record-keeping, which is hosted on a peer-to-peer network of participating nodes and miners whose cooperation is both enabled and governed by a consensus protocol which states rules of the network.”_

Instead, it might be time to accept that the term has evolved to become an overarching concept to indicate the synthesis of the technologies that make distributed ledgers possible.

In my next article, I will delve into the role that modern cryptography plays in the blockchain and the consensus mechanism.

If that is not an exciting prospect then I don’t know what is…

About the Author:

Thijs Maas is a law student with a healthy obsession for the legal challenges that arise in relation to the wave of innovation brought by distributed ledger technologies. He recently founded www.lawandblockchain.eu, a website that acts as a hub for information, insights and academic research on the subject.