What is a blockchain?
As the name suggests, a blockchain is a chain of blocks that contains data. This technique was originally described in 1991 by a group of researchers leaded by Nick Szabo and was originally intended to timestamp digital documents so that it’s not possible to backdate or change them. Technology was mostly unused until it was adapted by Satoshi Nakamoto in 2009 to create the digital cryptocurrency Bitcoin. A blockchain is a distributed ledger that is completely open to anyone, anyone can join and participate. They have an interesting property, once some data has been recorded inside a blockchain, it becomes almost impossible to change.
How does that work?
Each block contains some data, the hash of the block, the hash of the previous block, and a nonce. The data that is stored inside a block depends on the type of blockchain. One of the more recent developments is the addition of smart contracts into blocks. The Bitcoin blockchain stores the details about a transaction here, such as the sender, receiver, amount of coins, etc. A block also has a hash and a nonce. You can compare a hash with a fingerprint. It identifies a block and all of its contents and it’s always unique, just as a fingerprint. Once a block is created, its 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 block. If the fingerprint of a block changes, it no longer is the same block.
The third element inside each block is the hash of the previous block. With the nonce, this effectively creates a chain of blocks and it’s this technique that makes a blockchain so secure. Changing a single block will make all the following blocks invalid. Using hashes is not enough to prevent changing data. Computers these days are very fast and can calculate millions of hashes per second. You could effectively manipulate with a block and recalculate all the hashes of other blocks to make your blockchain valid again. To prevent this, blockchains have something called Proof Of Work. It’s a mechanism that slows down creation of new blocks. In Bitcoin case it takes about 10 minutes to calculate the required Proof Of Work and add a new block to the chain. To achieve this time, nonce comes into action. The nonce in a bitcoin block is a field whose value is adjusted by POW so that the hash of the block will be less than or equal to the current target of the network, in Bitcoin case, every 10 minutes one is created. More computer power on the network, a nonce is more difficult to get.
There is one more way that blockchains secure themselves and that’s by being distributed. Instead of using a central entity to manage the chain, blockchains use a peer-to-peer network and anyone is allowed to join. When someone joins this network, he gets the full copy of the blockchain. The node can use this to verify that everything is still in order. In recent years, many blockchains transition on Proof Of Stake, where every node guarantee with own coins that transaction he verifies are correct.