What Is a Blockchain?
- A blockchain is a data structure.
- Blockchain technology is the backbone of cryptocurrencies but not specific to them.
- Blockchain enables the implementation of a distributed, decentralised, permissionless ledger.
From Centralised to Decentralised Networks
Historically, most of our interaction with data on the internet has been through the client-server paradigm (Chart 1). In this, clients, computers or programmes that make requests for content, interact with a centralised server, another set of computers or programmes that provide content. Crucially, the server manages and controls the flow of information. This introduces a dependency between the clients and the server. Decentralisation aims to remove this dependency.
An alternative is peer-to-peer models (Chart 2). These rely on an interconnected network of nodes, computers or programmes in a network, that simultaneously do the job of a client and a server.
A key benefit is the removal of a single point of failure – the server in the client-server model – as information replicates across a distributed network of computers (the peers/nodes). A direct consequence of this is superior resistance against attacks. Bitcoin leverages a peer-to-peer network model at its core.
Understanding Distributed Ledgers
Another important concept is the ledger, which is a collection of accounts and transactions. In principle, this is much like the ledger accountants use to keep track of transactions. Each account on the ledger has an opening balance, a record of transactions, and a closing balance.
For bitcoin and other cryptocurrencies to be an effective electronic cash system, they implement a distributed ledger. This is a database of accounts that is shared, replicated, and maintained by nodes in a decentralised network. The underlying network model for distributed ledgers is the peer-to-peer framework.
But who has access to the account information on the ledger? That is, what are the permissioning requirements?
- A permissioned ledger has restrictions on who can access it based on prior authorisation.
- A permissionless ledger allows anyone to access it without any prior authorisation.
Bitcoin and other cryptocurrencies aim to implement a permissionless ledger.
So far, we have touched on three key concepts. These are the need for decentralisation, the benefits of a distributed network (e.g., more security), and permissionless frameworks. We have not mentioned blockchains yet – the underlying technology that ties these concepts together to deliver a truly decentralised, permissionless, and secure electronic payment system. Before that, we need to understand what a hash function is.
Hash Functions
A (cryptographic) hash function is an operation that maps data, such as numbers, images and documents, of arbitrary size to encrypted values of a fixed size. We call the values a hash function returns hashes. Three important properties of hash functions include:
- They are one-way operations so you cannot retrieve the input from the hashed output.
- The same input will always produce the same hashed output.
- Any change to the input data will change the output of the hash function.
Those long strings of numbers and letters you may have seen describing various crypto transactions that look something like 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f are the output of hash functions. That one is the hash of the first bitcoin block ever created. Hash functions are used to secure blocks/transactions on the blockchain by providing what can be considered a unique identifier. Hashes are analogous to fingerprints and are used to identify a block and the block’s contents.
What Is a Blockchain?
A blockchain is a data structure. That is a collection of data, the relationships between them and any functions that we can apply to them. We can use the blockchain to implement a distributed, decentralised, and permissionless ledger over a peer-to-peer network. Importantly, blockchain technology is a data storage mechanism. It is not specific to cryptocurrencies. But cryptocurrencies leverage them in a decentralised manner to implement a digital ledger.
In a blockchain, data, such as transactions, are stored in a data structure or blocks that are chained together using cryptography (Chart 3). Each block in a blockchain contains:
- A reference/pointer to the hash of the previous block.
- A timestamp showing the time of creation of the block.
- A nonce, which is a random number that can only be used once by miners to solve for new blocks on the blockchain. They are used to iterate the output of a hash function in a trial-and-error fashion until a valid output is reached, at which point a new block is added to the chain.
- The block’s transactions.
Technically, each block also has its own hash that acts as a unique identifier. But this is not part of the block structure and is stored as metadata across the network to facilitate faster retrieval of blocks.
How a Blockchain Works
We can think of blocks as packages of transactions. The very first block, known as the genesis block, contains an initial package of transactions. Miners add successive blocks with new packages of transactions to the genesis block. How blocks are added to the blockchain will be the topic of another explainer. For now, it is enough to state that miners in the network must validate any new blocks before they are added by coming to a consensus on the network.
The blocks are linked together via a pointer. This is an object that stores a reference or memory address to the previous block hash. Remember, these are unique identifiers and any change in the block structure, such as a transaction, will change the hash value. Since blocks are only added if the network has come to a consensus on their validity, any attempts to make malicious changes along the blockchain will change the hash of those blocks (see the third property of hash functions), which will invalidate them. This ensures that the blockchain is secure against attacks that attempt to change balances or insert fake transactions, etc.
The blockchain is defined in terms of itself since each block is a function of the blocks that came before it. This recursive design ensures that the data is immutable and allows any node in the network to traverse the full history of transactions starting from the genesis block up to the most recently validated block with confidence.
The Bottom Line
A blockchain allows for the implementation of a distributed (over a peer-to-peer network), decentralised (there is no central authority), and permissionless (anyone can start mining and add blocks to the chain without prior authorisation) digital ledger that is both secure and immutable. How blocks are added to the chain (mining) and consensus protocols (e.g., proof of work) will be the topics of our next crypto explainers.