An introductory blockchain primer for the unfamiliar but discerningly curious reader. What is a blockchain, its principle security measures and its applications will be described.
Core model of blockchain
A blockchain is a distributed ledger that is open to anyone. The chain is comprised of blocks all linked together in linear fashion; e.g. block A is connected to block B, and block B to block C, thus blocks A, B and C interconnected.
A block is composed of three elements: data, a hash, and the hash of the previous block.
Data: in terms of the type of data stored on the block, it can take various forms depending on the type of blockchain being used. The most recognizable form with cryptocurrencies such as Bitcoin is the information about a financial transaction: the sender, receiver and amount of coin.
Hash: the block hash is the unique ‘digital fingerprint’ of each block. It is used to identify individual blocks. If a block is altered, its hash will change. Therefore, hashes can be useful in identifying changes to blocks, and block tampering.
Hash of previous block: in addition to storing the block’s individual hash, it will also record the hash of the previous block it is linked to (e.g. block B will have the hash of block A stored in it), creating the link between the blocks and thus creating the chain. Intuitively, the first block cannot point back to a previous block. The first block is called the ‘Genesis Block’.
An inevitable point of controversy with regards to storing digital data is security and susceptibility of data infiltration (hacking). There are a few principle forms of security to prevent data tampering in blockchains: proof of work, peer-to-peer consensus.
Proof of work
If a block is tampered or altered, its hash would change. This would mean that the ‘hash of previous block’ on the following block would be invalid as they would not match. This would make the blockchain invalid. Therefore, to successfully tamper with a block it is required to tamper with all of the following blocks in the chain to ensure the hashes of previous blocks along the chain are validated, thus the blockchain valid. With great computer processing power this is possible, so to prevent our less than friendly digital experts from taking everything we hold dear blockchains may require proof of work (as with Bitcoin). This is in essence a mathematical question which your computer has to break with brute force calculations, slowing down the ability to alter or create new blocks – in Bitcoin, proof of work takes roughly around 10 minutes. Therefore, if we hacked one block, we would need to recalculate the proof of work for that block, and then hack and recalculate the proof of work for all following blocks. This now take much longer and means attempted tampering can be highlighted to the system.
P2P network consensus
A peer-to-peer (or P2P) network is basically a group of computers interconnected with each other, allowing data to pass between computers (nodes) within the network. When a user joins the P2P network for a particular blockchain, they get a complete copy of the blockchain ledger. The user (node) can therefore verify the integrity of the blockchain by cross-referencing with other nodes. When a new block is created, the block is sent to everyone on the network. Each node verifies that the block hasn’t been tampered, and once the nodes have a majority consensus, each node adds the block to their own blockchain. Therefore, blocks which have been agreed by consensus to have been tampered with will be rejected by all nodes on the P2P network.
Therefore, tampering with a system which uses proof of work and consensus is extremely difficult. To hack the blockchain you need to tamper with all the blocks on the chain, recalculate all proof of work for the blocks, and take control of over 50% of the P2P network to achieve consensus. Only then will the tampered block become accepted by all nodes on the P2P network.
Applications: smart contracts
Smart contracts are a useful application within blockchains. They were introduced in 1994 by Nick Szabo, aimed at facilitating the exchange of an item of value (money, property, shares etc.) in a conflict-free way that does not require a middle man. It is a self-executing contract which utilizes cryptography, digital signatures, and secure computation.
Suppose you wanted to rent an apartment using a smart contract. You would deposit money in the blockchain and receive a receipt that is held in the virtual contract. The landlord would give the digital entry key to arrive at a pre-specified date. If the key doesn’t come on time, the blockchain releases a refund. If the rental key is delivered before the specified date, the contract holds it, then releases both the money to the landlord and the key to you at the specified date. This system revolves heavily around the ‘if – then’ functions used in programming. The smart contract is overseen by hundreds (or thousands) of nodes within the blockchain, ensuring a legitimate contract. You can see that there is no legal oversight that would typically be present in ensuring these contracts in the ‘real world’. This is one example, but it shows the huge potential on offer to reduce costs and ensure quick, secure transactions.
Second year economics undergraduate at the UCL.