How the blockchain works.
This is a simple article explaining how blockchain works. As usual, newbies and 5 year old are highly welcomed.
Knowing how the blockchain works is usually a much tougher hassle than what it is, but we're going to learn how blockchain technology is programmed to work today in the most simple and short way possible.
Let's start with dissecting the word blockchain.
Once we get this concept, we are 70 steps in๐
So, the word blockchain can be broken down into two independent words; block and chain.
Blockchain is simply a chain of blocks.
What really is a block and how do they form a chain?
A block is a collection of data.
The data can be a transaction, information, a document, a food recipe, or anything of value that needs to be stored in the blockchain. This data, after being checked and approved as correct and authentic by miners, now makes up a block, let's say block 1(genesis block).
When another set of data is approved(mined), it makes up block 2, and block two is automatically linked to block 1.
A block is linked to other blocks chronologically in a virtually irreversible chain. What this means is that these blocks are linked accordingly and cannot be reversed. So you won't find block 3 after block 10 or block 9 after block 1 in a blockchain.
But how are these blocks actually linked?
They are linked by their hashes.
A hash (sometimes called hash value) is a string of bytes with a fixed length and structure generated from a blockchain input.
Once a block is created, a unique hash is attached to it, alongside its bounce which serves as that block's means of identification.
So every block on the blockchain has a hash.
Block 1's hash is different from Block 2's hash, Block 2's hash is different from Block 3's hash, and so on. No two blocks have the same hash, but every block takes on the hash of its preceding block as a "previous" except the Genesis block (block 1) whose previous is 0000000000000000 since there's no preceding hash.
What this means is that Block 5 MUST take on block 4's hash as its previous, block 4 must take on block 3's hash as 'previous', and block 22 takes on block 21's hash as its previous.
So if block 5 hash is 000054678464846458454945, block 4's previous will definitely be 000054678464846458454945.
In the blockchain demo above, you can see that block 2 carries the hash of block 1 as its 'previous'. The same thing applies to 3 and the rest of the blocks.
You get the concept right?
Each additional block strengthens the verification of the previous block and hence the entire blockchain.
Let me break this down further.
Each block in the blockchain is connected to the one before and after it through its hashes. As data keeps getting approved and more blocks get added to the blockchain, they form a chain.
Now, imagine that a hacker wants to manipulate/change the information in a block, and the hash of the block will automatically change, even if the change is a single number, the hash will still change, rendering that block invalid.
Also, imagine that the data being changed was in block 5 and there are 800 other blocks in the blockchain.
What will happen is that block 6 which carried block 5's initial hash in its 'previous' will throw an error because it's 'previous' has been tampered with. Also, all the blocks after 6 (blocks 7,8,9,10,11...800) will also show errors and be declared invalid since their authentic & approved hashes are linked chronically to one another. Once a block is tampered with, it affects every other block that follows it.
So if a hacker or group of hackers wanted to change any data on a blockchain, they will have to change the hashes and the 'previous' of all the blocks WITHOUT BEING CAUGHT OR EVEN DETECTED, which is almost impossible since there are thousands of nodes monitoring the blockchain.
This shows that the blocks link securely together to prevent any block from being altered or a block from being inserted between two existing blocks.
Another important thing is that the blockchain is a distributed ledger and everything that's happening in the blockchain is distributed to every member node on the network. Each of them has a copy of all the blocks in the blockchain.
In this light, If a hacker group also wanted to manipulate any transaction on a blockchain, they would have to break into the device of every single member node around the world and change all records to show the same thing.
That we know is impossible, so this 'distributed' feature makes it even harder for anyone to change the content of a block.
It is the core reason why blockchain is very secure for storing data because everyone has a copy of the information and one person can't change the content of a block for his/her selfish interest.
Another thing to note is that the blockchain works with cryptographic keys.
Cryptography is a form of securing digital data and messages with special keys that only the sender and recipient have access to. These are special keys used for encryption(locking of the message) and decryption (opening of the message). These keys are known ONLY by the sender and receiver of a transaction or any kind of data. So, to access any transaction you need these keys, and if you don't have them, you can't tamper with them.
In conclusion, I'd like you to think of how blockchain works in these three parts.
The first is that it works chronologically. In the blockchain, the blocks are stored chronologically; linked to each other.
The second is that this digital ledger is distributed. Every member holds an identical copy of the blockchain database on their computer.
The third is that it works with cryptographic keys.
All of these happen without intermediaries or middlemen. No one's exploiting your data or resources.
These features render the blockchain tamper-evident, delivering the key strength of immutability. It removes the possibility of tampering by a malicious actor and makes the blockchain a digital ledger of transactions that people can trust.
This is getting longer than expected and I hope you now understand HOW a blockchain actually works.
I'd love to read your thoughts in the comments. Chao.
P/S: If you didn't read What blockchain is, and what it isn't, here you go
alphawomann.hashnode.dev/what-exactly-is-bl..