How Does Blockchain Work?
Blockchain is a new and emerging technology with incredible promise. It has already given rise to a number of products, including some sharia-compliant products.
But in order to properly understand if any blockchain-based product is a good investment or sharia-compliant we need to first have a good grounding on what blockchain is.
This article sets out a working definition of what blockchain is.
This article is part of our Halal Cryptocurrency Guide.
An executive summary of this article
- Each block is made up of some data, a hash, and the hash of the previous block
- Each successful chain is a combination of four things: (1) A P2P Network; (2) cryptographic security; (3) a consensus algorithm; and (4) a system of punishment and reward.
- Blockchain networks run on a P2P network to allow safe decentralisation.
- Cryptography ensures secure transaction and communication.
- A consensus algorithm is a set of the rules per blockchain that decide how validation and new block creation will work.
- A system of punishment and reward is used to incentivise users.
What is a block?
Each blockchain system is comprised of blocks that contain information. Each block consists of of three things; some data, a hash, and a hash of the previous block. The data stored can be anything of value.
For example, blocks could typically store information about the time, date, amount, and participants for a particular transaction.
To distinguish from others, each block will have a unique hash- a sort of cryptographic code. Data storage for each block varies per system. For example, within the Bitcoin Cash blockchain, each block can hold up to 8MB of data while Bitcoin blocks can only hold 1MB.
For the new block to be valid, it must have another hash that corresponds to the previous block.
Let’s look at this numerically. The first block (otherwise known as the genesis block) will have hash (X). The next block will have its own hash (Y) and will have to include hash (X) to be validated.
The third block in the chain must now have hash (Z) as well as hash (Y).
As there is a continual chain linking each block, if any data is tampered with, the corresponding hash changes and would disrupt proceeding blocks. This will make any changes easy to detect and gives blockchain its immutable (unchanging) characteristics.
What is a chain?
For every system, there are blocks connected in some way to its previous block. To be a successful chain there must be four features:
- Peer-to-peer (p2p) network
- Consensus algorithm
- A system of punishment and reward.
A p2p network is a group of nodes (users within a blockchain) sharing information. Traditional networks are connected locally or wirelessly and follow a client-server model.
In this type of network, the central server handles, stores and manages the information. Such a network can be dangerous as it opens the possibility for hacks and data misuse through the central server.
In contrast to the tradition client-server model, users in a p2p network are both clients and servers. In this decentralised network, information is constantly shared to participants of the network. Each user has a copy of an online distributed ledger and validates it. This system allows for strangers to work together in a system and trust each other without the need for a central authority.
cryptography allows users within the network to communicate and transact safety. For example, encryption of data is vital for digital wallets while cryptographic hash functions are what give blocks their immutable trait.
consensus algorithms are needed to validate and decide the rules of the blockchain.
Every decentralised ledger needs one, but the algorithm usually differs and depends on each blockchain.
Proof of Work (PoW) is one of the more popular rules which is used by bitcoin. When a new transaction is requested, a new potential block is created. This is sent to every node within the network to validate through the PoW process.
Miners (specific nodes that verify new blocks) will have to compete to solve a cryptographic puzzle. In simple terms, the puzzle requires miners to find the NONCE (“number only used once” – the value that miners will look for) that passes through the hash function and satisfies certain conditions.
It is tackled via brute force, and so requires a huge amount of CPU power and electricity usage. A benefit of this is that it disincentivises network attacks. A successful attack would need such a very high amount of CPU power and time that the costs would outweigh the benefits. Once the puzzle is solved, other miners will validate it and the new block is added to the chain. A consensus is reached when the majority of nodes validate it.
Another important algorithm to know is Proof of Stake (PoS). Because the PoW method uses up a lot of power, there is a demand for an alternative verification process that is more environmentally friendly. In PoS, there is no intense puzzle to solve; instead, miners are elected based on the number of coins held and are rewarded with transaction fees. NXT uses the PoS method with Ethereum soon to follow.
Reward & Punishment
Some element of punishment and reward should exist in a successful blockchain ecosystem. In both algorithms, there is some reward for miners who successfully validate the transaction. PoW miners get some tokens, whereas PoS miners will gain a transaction fee. This is to incentivise validation between nodes in the network which helps add new blocks to the chain. Similarly, punishments like coins removal or revoking participant confidentiality help prevent blockchain misapplications.