How Does a Blockchain Work?

Blockchains are incredibly popular nowadays, but what is a blockchain? How do they work? What problems do they solve? How can they be used? Like the name indicates, a blockchain is a chain of blocks that contains information.

This technique was originally described in 1992 by a group of researchers that was originally intended to timestamp digital documents so that it's not possible to back date them or to tamper with them, almost like a notary. However, it went by mostly unused until it was adopted by Satoshi Nakamoto in 2009 to create a digital cryptocurrency, Bitcoin. Now a blockchain is a distributed ledger that is completely open to anyone.

They have an interesting property, once the data has been recorded inside a blockchain, it becomes very difficult to change it. So how does that work? Let's take a closer look at a block.

Each block contains some data, the hash of a block and the hash of the previous block. The data that is stored inside a block depends on the type of blockchain. The Bitcoin block for example, stores the details about a transaction, such as the sender, receiver and the amount of coins. A block also has a hash, you can compare a hash to a fingerprint that identifies a block and all of its contents and it's always unique, just as a fingerprint. Once a block is created, it's hash is being calculated, changing something inside the block will cause the hash to change, so in other words, hashes are very useful when you want to detect changes to blocks. If the fingerprint to a block changes, it no longer is the same block.

The third element inside each block is the hash of the previous block and this effectively creates a chain of blocks and it's this technique that makes a blockchain so secure. Let's take a look at an example. Here we have a chain of three blocks, as you can see, each block has a hash and the hash of the previous block. So Block 3 points to Block 2 and Block 2 points to Block 1:

  1. Block 1 a. Hash: 1Z8F b. Previous Hash: 0000
  2. Block 2 a. Hash: 6BQ1 b. Previous Hash: 1Z8F
  3. Block 3 a. Hash: 3H4Q b. Previous Hash: 6BQ1

The first block is a bit special, it cannot point to a previous block because it's well, the first one. We call this block, the Genesis Block.

Let's say you tamper with Block 2, this causes the hash of the block to change as well, in turn that will make Block 3 and all following blocks invalid because they no longer store a valid hash of the previous block. So changing a single block will make all following blocks invalid. But using hashes is not enough to prevent tampering. Computers these days are very fast and can calculate hundreds of thousands of hashes per second.

You can effectively tamper with a block and recalculate all of the hashes of other blocks to make your blockchain valid again. So to mitigate this, blockchains have something is called proof of work. It's a mechanism that slows down the creation of new blocks. In Bitcoins case, it takes about 10 minutes to calculate the required proof of work to add a new block to the chain. This mechanism makes it very hard to tamper with the blocks because if you tamper with one block, you'll need to recalculate the proof of work for all of the following blocks. So the security of a blockchain comes from it's creative use of hashing and the proof of work mechanism.

But there is one more way that blockchains secure themselves and that is by being distributed. Instead of using a central entity to enter manage a chain, blockchains choose a peer to peer network and everyone is allowed to join. When someone joins this network, he gets a full copy of the blockchain. The node can use this to verify that everything is still in order. Let's see what happens when someone creates a new block.

That block is sent to everyone on the network, each node then verifies the block to make sure that It hasn't been tampered with. If everything checks out, each node adds this block to their own blockchain.

All of the nodes in this network create consensus. They agree about which blocks are valid, and which aren't. Blocks that are tampered with will be rejected by other nodes in the network. To successfully tamper with a blockchain, you'll need to tamper with all of the blocks on the chain, redo the proof of work for each block and take control of over 50% of the peer to peer network. Only then will your tampered block become accepted by everyone else. So this is almost impossible to do. Blockchains are also constantly evolving, one of the most recent developments is the creation of smart-contracts. These contracts are simple programs that are stored on the blockchain and can be used to automatically exchange coins under certain conditions.

The creation of blockchain technology peaked a lot of peoples interest, soon others realized this technology can be used for other things like storing medical records, creating a digital notary or even collecting taxes. 

author default image
CoinJolt.com - Managing Institutional Investments In Digital Currency

Buy, sell and invest in digital currency instantly with zero fees. A managed cryptocurrency portfolio with full custody solutions. Click here to create an account.