What is blockchain?

What is blockchain?

Blockchain is a big technical topic with huge potential. To understand not only what blockchain is, but also the problems it solves, we need to dive into its origin story alongside the technicalities of its make-up.

In this blockchain 101 series, we will be exploring all of these aspects to give you a good grasp of blockchain and its uses.

In this article you will find:

  • A brief description of what a blockchain is
  • A description of the three essential parts of how a blockchain works: 
    • Cryptography
    • Data structures
    • Rewards and punishments – blockchain game theory

 

What is a blockchain?

What: Blockchains are a type of distributed (shared) database. The amazing thing about blockchain is that a potentially infinite number of people (specifically their computers) can have a copy of the database and can make changes, but everyone knows for certain that the data is true.  

How: This is possible because to participate in a blockchain computers must follow a set of rules to both store data and to process inputs called transactions if they wish to change any data. These rules or protocols ensure that only true information can be added to the database. 

Strict protocol adherence is enabled using a system called the Byzantine Fault Tolerant (BFT) system. BFT ensures that a blockchain can reach consensus in a distributed system when technical failures and malicious actors are present. This means that the data held in the blockchain can still be secure even when computers participating on the chain are operated by malicious parties.

Blockchain also makes use of cryptography techniques to ensure cryptographically verifiable information and to replace trust only interactions.

In a nutshell: Blockchain is an innovative data storage system with a wide range of applications. It is a cryptographically verifiable record of events, notarized by a distributed computer network using a BFT consensus protocol.

 

The 3 ingredients of blockchain

There are three essential parts that make up a blockchain network:

  1. Cryptography 
  2. Data Structures 
  3. Rewards and punishments – blockchain game theory

 

Cryptography

Cryptography is a method of securely storing and transferring information so that only the intended recipient can read or process it. It basically describes the process of taking plain text or readable data, scrambling it so that it is unintelligible, and then unscrambling it again once it has been delivered. 

Blockchains use cryptography to create secure signatures and data fingerprints so that everyone on the network can verify every transaction and therefore trust that the blockchain’s data is correct. There are 2 main systems of cryptography used in a blockchain:

1.Public Key Cryptography (e.g ECC, RSA)

A public-key cryptographic algorithm system uses a pair of keys: a public key associated with the sender for encrypting messages, and a private key that only the originator knows which is used to decrypt that information.

Blockchain uses a public key cryptography algorithm called Elliptic Curve Cryptography (ECC). ECC is used to allow someone to sign a message or piece of data to say they agree that it is correct. You can see it as the equivalent of signing a contract but in the digital realm. This allows the chain to prove that all the right people have agreed to a transaction and the correct validator (responsible for authoring new blocks in a proof of stake consensus mechanism) has signed their block after making it – signalling their agreement to all the data within that block.

2.Cryptographic Hashes (e.g SHA-256)

A cryptographic hash function is an algorithm that can take data input of any size and produce a fixed-size output of enciphered text called a hash. Hashes have some fixed properties:

  • They are deterministic which means that the same data always produces the same hash.
  • It is impossible for the same hash to be generated from different pieces of data.
  • You cannot use a hash to recreate the original data.
  • Small changes to data should change the hash value so extensively that a new hash value appears uncorrelated with the old hash value, what’s known as the avalanche effect.
  • Hashes are fast to generate, no matter the size of the data input.

 

In blockchains, cryptographic hashes are used to compress and fingerprint data. This means anyone on the chain can identify specific blocks and transactions, as each piece of data has a totally unique hash that is easily verified.

Data structures

Blockchain data is organised into:

  • Transactions: A digitally signed message to change the blockchain’s state. These are similar to database transactions.
  • Block: Groups of transactions and some extra metadata. This metadata includes a blockhash, parent hash and time stamp.
  • State: Emergent data at some time after applying all previous blocks (transactions). The state of a blockchain is whatever the blockchain thinks to be true at that particular moment, based on the blocks and their transactions.
Data in a blockchain

 

Merkle trees

On top of the basic organisation into transactions and blocks, blockchain data is structured into Merkle trees (also known as binary hash trees). Merkle trees provide a way to efficiently and quickly prove that a piece of data belongs within a set, this means that anyone on the chain can check when a transaction occurred (or what block it occurred within). This is super useful for proving what order transactions happened in, giving everyone on the network a verifiable record of events and ultimately cryptographic proof of the current state of the blockchain. 

How does it work:

Each transaction is given a cryptographic hash (using the cryptographic hash algorithm). The hashes of all the transactions within a block are concatenated and hashed together to create a master hash, known as a Merkle Root attached to the final block.

Merkle trees diagram

 

The Merkle root acts as a fingerprint for the whole data set and can be used to prove that a particular transaction is inside that particular block. Blockchain nodes are able to work backwards from any given Merkle Root to verify for you whether an individual transaction is within a specific block. This structure underpins the cryptography on the chain and makes data quickly and easily verifiable for everyone. 

In essence, the use of Merkle Trees means you don’t need to trust anything on a blockchain, you can get cryptographic proof that the data exists in a specific location. 

The big picture: Merkle trees are great for verifying the whereabouts of individual transactions, but they are also essential on a larger scale. 

Every block contains its own Merkle tree (derivable from its Merkle root) which lists the transaction set. It also contains a parent hash, which is the Merkle root of the previous block. 

This means each block is linked to the one before it, so it is possible to work back through a chain of blocks (the blockchain) verifying data within every part of it and its definite order. Altogether this creates a cryptographically verifiable record of events, which allows us to definitively prove the current state of the blockchain. 

Each block has it's own Merkle tree

 

Rewards and punishments – game theory for blockchain

The final ingredient of a blockchain is incentives and disincentives, or to put it another way, a bit of game theory. 

Blockchain requires a decentralised structure in order to fulfil its purpose of being trustless. Without decentralisation, a single authority could arbitrarily change protocols to manipulate the data to suit them and censor transactions.

To achieve decentralisation a blockchain needs to: 

  1. Replicate the record of events across many computers in a peer to peer network, so no one computer has complete control over the network’s data.
  2. Define some way for all the computers in the peer to peer network to agree on changes to the blockchain state, i.e. the next set of transactions and blocks.

Achieving consensus: consensus mechanisms

Peer to peer networks are not unique to blockchain, they exist to varying degrees of success elsewhere in the tech world. It’s the second bullet point in the list that is what makes blockchain such a powerful tool. Blockchain has succeeded in creating a system that achieves consensus among multiple entities, regardless of whether those entities are trustworthy.

Blockchain’s system for achieving consensus between entities that do not trust each other is called a consensus mechanism. Consensus mechanisms are blockchain’s version of a BFT system. 

There are several different versions of consensus mechanisms, but all of them utilise game theory to ensure correct participation in the system by rational economic actors. 

To participate in a blockchain system all participators are encouraged to follow the rules using a basic system of punishments and rewards:

  • Incentive = Those who do the right thing and correctly follow protocols are rewarded with money (usually tokens).
  • Disincentive = Those who do not follow protocol are fined money (usually tokens).

This makes it more beneficial and profitable for participants to follow blockchain protocol than to try and get around it. Blockchains are a deterministic system, so when everyone follows protocol correctly, everyone will reach the same conclusion= total consensus across the network. 

There are 2 main types of consensus mechanisms currently: Proof of Work and Proof of Stake. You can learn more about how they work here

 

Coming up next:

The next part of the blockchain 101 series will look at the origins of blockchain, explaining the development of Bitcoin and the double-spending problem and the development of the second generation of blockchain covering smart contracts and the state transition function.