Demystifying Blockchain
2020-03-23
Blockchain is a subject which enjoys a lot of hype, promising to revolutionize finance, contracts, supply chains, and more, yet it remains a mystery to most people. Here I seek to demystify blockchain technology by demonstrating how a blockchain works by practical example; an in-browser blockchain inspired by bitcoin with visual aid to help understanding.
The purpose of a blockchain is first and foremost to keep data secured and to prevent tampering. In practice this is done by structuring the data as a block containing (1) the data, (2) the identity of the previous block, (3) a Nonce number, and (4) the identity of the block. The identity of the block is chained to the previous block’s identity, the block’s data, and block’s Nonce.
The block identity is decided through a hashing function. A hashing function is simply a function which converts any value to another, in this case we will be using the SHA-256 hashing algorithm, the same algorithm used for hashing in Bitcoins blockchain. The Hashing function takes the data in the block, a number called ‘Nonce’ and the identity of the previous block as an input and returns a ‘Hash’ as an output. This Hash will be the identity of the block. As each block's unique identity is built upon information from the previous blocks any change to a block in the system would affect its identity rendering it invalid as well as all of the subsequent blocks making the blocks effectively immutable.
For a block to be accepted as valid by the blockchain it needs to be mined. The mining mechanism, also sometimes referred to as ‘proof of work’ (PoW) exists as the main security mechanism of the blockchain. The process involves having a computer solve a cryptographic puzzle. The puzzle in our case (and in Bitcoins case) is the following: find a value of the Nonce number so that the hash identity starts with ‘n’ amount of zeros, in our case four ‘0000’. This puzzle can be made arbitrarily more difficult by requiring more zeros in the hash, this would result in an increase of the computing power required to mine the block; making the system more secure.
A blockchain can be public or private. The blockchain running on your browser here is a completely private blockchain where you are the only one with permission to add data and where you provide 100% of the computing power in the system. As a result the blockchain loses some of its security and immutability; if you want to change a block you can make the change and then proceed to mine the block and the following blocks in the chain. This could in theory be prevented by increasing the computing power needed to mine the blocks. However, as this would be a costly and time consuming effort for the owner it is an unlikely scenario.
Public blockchains like Bitcoin are open for anyone to access, use and mine. In the case of Bitcoin anyone can make transactions and actors compete to mine new blocks, the winner is then rewarded bitcoins for their effort. This incentive and the computing power that follows allows Bitcoin to have a high difficulty for the mining process making the chain incredibly secure. Adversely, the setup of the blockchain in addition to the growing popularity and value of bitcoin has resulted in Bitcoin using an estimated 126 Terrawatt-hours of electricity during 2019, and growing. To put it in perspective, this would place Bitcoin between Sweden and Norway’s yearly electricity consumption. A tremendous amount by any standard.
Blockchains strength lies in being able to keep data secured without the need of a third party. In the case of currency transactions it can allow us to bypass banks when using digital currencies, enabling peer to peer transactions just like the traditional paper currency resulting in potentially cheaper and faster transactions. In addition the technology has the potential to reduce bureaucracy, improve financial transactions, record keeping, and more. Though its value has already been demonstrated through practical examples as Bitcoin it remains to be seen how the world will make use of the technology.