Skip to main content

How does a blockchain technology work

Blockchains are incredibly popular nowadays. But what is a blockchain? How do they work, what problems do they solve and 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 1991 by a group of researchers and was originally intended to timestamp digital documents so that it’s not possible to backdate them or to tamper with them. Almost like a notary. 



           However it went by mostly unused until it was adapted by Satoshi Nakamoto in 2009 to create the digital cryptocurrency Bitcoin. A blockchain is a distributed ledger thatis completely open to anyone. They have an interesting property: once somedata has been recorded inside a blockchain, it becomes very difficult to change it. So how does that work? Well, let’s take a closer look at a block. Each block contains some data, the hash ofthe block and the hash of the previous block. The data that is stored inside a block dependson the type of blockchain. The Bitcoin blockchain for example storesthe details about a transaction in here, such as the sender, receiver and amount of coins. A block also has a hash. You can compare a hash to a fingerprint. It identifies a block and all of its contentsand it's always unique, just as a fingerprint. 

           Once a block is created, it’s hash is beingcalculated. Changing something inside the block will causethe hash to change. So in other words: hashes are very usefulwhen you want to detect changes to blocks. If the fingerprint of a block changes, itno longer is the same block. The third element inside each block is thehash of the previous block. This effectively creates a chain of blocksand it’s this technique that makes a blockchain so secure. Let's take an example. Here we have a chain of 3 blocks. As you can see, each block has a hash andthe hash of the previous block. So block number 3 points to block number 2 and number 2 points to number 1. Now the first block is a bit special, it cannotpoint to previous blocks because it's the first one. We call this the genesis block. Now let's say that you tamper with the secondblock. This causes the hash of the block to changeas well. In turn that will make block 3 and all followingblocks invalid because they no longer store a valid hash of the previous block. So changing one block will make all followingblocks invalid. 

           But using hashes is not enough to preventtampering. Computers these days are very fast and cancalculate hundreds of thousands of hashes per second. You could effectively tamper with a blockand recalculate all the hashes of other blocks to make your blockchain valid again. So to mitigate this, blockchains have somethingcalled proof-of-work. It's a mechanism that slows down the creationof new blocks. In Bitcoins case: it takes about 10 minutesto calculate the specified proof-of-work and add a replacement block to the chain. This mechanism makes it very hard to tamperwith the blocks, because if you tamper with 1 block, you will need to recalculate the proof-of-workfor all the subsequent blocks. So the security of a blockchain comes fromits creative use of hashing and therefore the proof-of-work mechanism. But there's another way that blockchainssecure themselves and that is by being distributed. Instead of using a central entity to managethe chain, blockchains use a peer-to-peer network and anyone is allowed to join. When someone joins this network, he gets thefull copy of the blockchain. The node can use this to verify that everything is still in order. Now let's see what happens when someone creates a new block. 

           That new block is send to everyone on thenetwork. 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 the nodes in this network create consensus. They agree about what blocks are valid and which aren't. Blocks that are tampered with will be rejectedby other nodes in the network. So to successfully tamper with a blockchain you'll need to tamper with all blocks on the chain, redo the proof-of-work for each blockand take control of more than 50% of the peer-to-peer network. Only then will your tampered block becomeaccepted by everyone else. This is almost impossible to do! Blockchains are also constantly evolving. One of the more recent developments is thecreation of smart contracts. These contracts are simple programs that arestored on the blockchain and can be used to automatically exchange coins based on certainconditions. More on smart contracts in a later video. The creation of blockchain technology peakeda lot of people’s interest. Soon, others realized that the technologycould be used for other things like storing medical records, creating a digital notaryor even collecting taxes. So now you know what a blockchain is, howit works on basic level and what problems it solves

Comments