Simplifying Blockchain

What is Blockchain

Blockchain is a growing list of records called blocks, which are linked together and protected by cryptographic methods.

What is blockchain
Blockchain simplified

What’s inside a block?

A block can contain some data inside of it, or it can be a collection of data. It can contain anything from a string to a list of words to a group of transactions.

A block will also contain a value known as own hash, as well as a previous block hash. A hash is like a fingerprint of data. When you hash any data you’ll get a string of characters that represents that data.

In addition, blocks also contain some metadata about themselves such as block number.

Blocks are made up of the following components

  1. Some data.
  2. Its own hash.
  3. Hash of the previous block.
  4. Metadata about the block.
Whats in a block
Whats in a block

How do blockchains connect these blocks?

A Block consists of some data, a hash of its own data, and a hash of the previous block, which acts as a reference to the block that preceded it. This is how blocks are linked together in blockchain. Each block has its own fingerprint, as well as references the fingerprint of the previous block.

As a result, if someone attempted to change the data in a block, its fingerprint would change. Accordingly, the reference fingerprint in the next block would also change. That is how blocks are linked cryptographically.

How blocks are connected in a blockchain
How blocks are connected

What is Hashing

In simple terms, hashing means taking any input and converting it into an output of fixed length. The input can be a word, a sentence, a longer text, or even an entire file. Any digital file can be hashed, so any video or audio files can be hashed and converted to a fixed length hash value.

For e,g: SHA 256 is a hashing function that converts an input of any size to fixed 256 bits.

Whats a hash function
Hash Function

How Blockchain keeps the data Safe?

Blockchain is immutable. A blockchain’s immutability refers to the fact that once the data is stored on top of it, it cannot be modified.

If someone attempts to tamper with data in a specific block, the result would be that this will change the hash of that block. Consequently, the previous hash parameter of the next block which links this changed block does not match. This would require the person to change the next block as well.

Because of this cryptographic link, when some one change one block, all those blocks that follow will no longer be valid. They will not be connected to the chain, so it will be difficult for the anyone to tamper with the data in the block.

Yes, blockchain blocks are connected by these cryptographic links, but someone can get access to this computer or server where these entire blocks are stored and can alter a block. The only thing they need to do is alter all the other blocks after that. What prevents them from doing so?

Well, the blockchain is actually copied across multiple computers. Blockchain employs a distributed peer-to-peer network, which consists of lots of computers that are interconnected. Each computer in this network will maintain its own identical copy of the blockchain.

Imagine, if we have 1000 computers connected inside this network, all those 1000 computers will store the same data and will update information as it is being updated on a single machine. As soon as one machine creates data, the data will be communicated to all others, and they will update that data as well.

So we have our block data copied across thousands and thousands of computers. And the system is designed in a way that each computer is constantly checking their peers to see if their blockchain data is consistent with peers. In the event that they find any inconsistencies, they will inform their peers that their blockchain appears different to them, and this will make the wrong computer automatically restore the right blockchain data that most computers have.

So what you can see here is even someone changes data in the block and change the subsequent blocks, it’s not enough. They need to attach all of the same blocks at every computer and at the same time. This makes it impossible to change the data.

Distributed peer to peer network
Distributed peer to peer network

This is a simple introduction to blockchain, but the blockchain is a lot more than this. There are asymmetric cryptographic techniques, Merkle trees, consensus protocols, mining, Smart Contracts, etc.

A real-world blockchain analogy

Let’s take a look at how the blockchain performs its core functions using an example.

Let’s imagine 5 people Monica, Rachel, Ross, Chandler, Phoebe, Joey decided to create a lending ledger for any kind of borrowing between them. Monica was designated to keep track of all the transactions between them in a notebook which is kept at Monica’s house.

Days passed and Monica wrote down every transaction from the beginning between them in the notebook, like

Chandler gave four dollars to Ross

Rachel gave five dollars to Joey

This notebook acts as a source of transparency and verification for the group.

Joey being Joey decided to edit the money he borrowed from Rachel, so what he did is he changed the entry:

“Rachel gave five dollars to Joey” to “Rachel gave five dollars to Ross”

Monica noticed someone had modified the notebook and decided to protect the entries using a hash function. When you pass a transaction to the hash function it will return a unique hash.

Hash Function (“Rachel gave five dollars to Joey” ) = 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969

She started adding this hash inside the notebook in such a way that after each transaction, there is a hash of the transaction.

“Rachel gave five dollars to Joey” — 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969

Now even a single bit of change in the record will lead to a different hash result. Now if Joey tries to change the entry the hash of the transaction will be different from the old one and Monica who knows the hash function can validate this hash added to the transaction.

Somehow Joey learned this hash function and successfully modified entries again. He modified a transaction, passed the modified transaction through the hash function, and added the new hash also to the entry. He made sure that if Monica tries to verify the transactions by using the hash function, then the transactions get validated.

He changed

“Rachel gave five dollars to Joey” — 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969

changed to

“Joey gave five dollars to Rachel” —

“15e44b142fd638cb2a323ea028b5cfc7149c1fb0fdad3fd19e9827acbf13648c”

Somehow, Monica noticed again that someone had tampered with the notebook. She combined each hash with the previous one to make the records even more complicated. So each transaction record is added with the last hash transaction and passed through the hash function. So each entry depends on the previous entry.

Hash Function (“Rachel gave five dollars to Joey” + previous entries hash ) = “125f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826334344”

This is repeated for all the records in the notebook, making sure all the records are linked to each other forming a chain of records. Now if the attacker tries to change any record in the notebook, then he needs to replace all the entries after that inside the notebook.

But Joey went to Monica’s home again and got the notebook and he spent the whole night creating all the hashes that come after the modified entry and managed to change the hash inside the notebook.

Monica decided to add some more complications with the entries in the notebook. She decided to add a random number after each transaction record, which will be called the nonce.

Another important decision was made to keep copies of this notebook with multiple people. And once she adds to the notebook she will inform all others who hold the copy of the notebook, they will also update the same. Similarly, everyone will communicate with every other notebook holder to make an entry.

Now if Joey needs to change the entries within Monica’s notebook, he needs to replace all the entries present in different notebooks, which are located with different people.

If somebody tries to change any data in the blockchain, then anyone who is part of the network can verify that this data existed originally. Participants can catch the culprits and reject the changes.This is why it is almost impossible to hack the blockchain.

That’s a simple explanation of how blockchain works through a real world example.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store