Blockchain: Building The Trust

Kartik ganiga
Jan 30, 2019 · 10 min read

Blockchain concept initially came from these two people Stuart Haber and W.Scott Stornetta. They didn’t introduce the term blockchain which came much later after the original paper by Satoshi Nakamoto but these two gentlemen wanted to implement a system where document timestamps could not be tampered with. In 1991 they published a paper called How to Time-Stamp a Digital Document and the paper includes the concepts what we now call the Blockchain and all or most of the features and ideas behind the notion actually were presented in that paper.

The Blockchain is a type of distributed ledger for maintaining a permanent and tamper-proof record of transactional data, called blocks, which are linked using cryptography. “Blocks” on the blockchain are made up of digital pieces of information because it’s a record! And obviously, it has some data inside it. For instance, it might have just a string of words “hello world”. Then it will have a field which is called previous hash which is like a fingerprint of some amount of data of the block.

Basically, A hash is a function that converts an input of letters or numbers into an encrypted output of a fixed length. The blockchain only contains validated transactions, which prevents fraudulent transactions. The validation process relies on data being encrypted using algorithmic hashing. The function used to generate the hash is deterministic, meaning that it will produce the same result each time the same input is used; can generate a hashed input efficiently; makes determining the input difficulty (leading to mining), and makes small changes to the input result in a very different hash.

The first ever block created on the chain is called the Genesis block. As one can guess the Genesis block does not have the Previous hash value in it. If the next block is created on the chain it will have some data and the previous hash field which is same as the hash of the previous block.

We will discuss what nonce is in the upcoming topics.

For now, let’s think of a hash as a fingerprint. As you can see above, the previous hash of block number 2 is identical to block number 1’s hash and that is where the link comes. That is why the term is called a chain or a blockchain because the blocks are cryptographically linked with each other through these hashes. And again, more and more blocks are created, the blocks will have its own fingerprint(hash) and the reference of the previous block. So, if anything were to change block number 1’s hash would change the reference in the second block which will not match and mismatching of hashes happens. The system will get to know that something has happened which tried to alter the block.

Let’s assume the data field in the first block has been attempted to tamper somehow. Now what?

Now the field Nonce comes into the picture. Due to the introduction of the nonce, the hash output of the contents of the block will change. The puzzle that miners solve is to identify the value of nonce so that the hash output of the block being mined starts with a specific number of leading zeroes. Note, the hash of the contents of the block being mined should start with a specific number of leading zeroes. The value of the nonce that will achieve this is basically what miners are trying to solve for.

Solving the hash requires the miner to determine which number to use as the nonce, which itself requires a significant amount of trial-and-error. This is because the nonce is a random number. It is highly unlikely that a miner will successfully come up with the correct nonce on the first try, meaning that the miner may potentially test a large number of nonce options before getting it right. The greater the difficulty — a measure of how hard it is to create a hash that meets the requirement of the target hash- the longer it is likely to take to generate a solution.

Now we will specifically discuss some important and must know concepts which fly around the blockchain world.

Terminologies around the Blockchain

1. Cryptography/ Hashing:

We’re going to understand what is the role of SHA256 hashing algorithm plays in the blockchain.

Before getting deeper into the world of SHA256 let’s take an example first and then relate the same to the algorithm. So, let’s look at a person, which could be me or you and we have a fingerprint and different people have different fingerprints. There is a possibility that there’ll be somebody with the same fingerprint. But it is very unlikely the happening of that is about one in 60 million.

Now, what if we could take the same principle and apply it to digital documents? what if we could come up with a sort of fingerprint that would identify these documents for us? Such a fingerprint exists it’s called SHA256 hash. SHA256 is a cryptographic hash function designed by the NSA(National Security Agency). SHA stands for Secure Hash Algorithm and 256 is the number of bits it takes up in memory. This Hexadecimal hash is always of 64 characters.

And the important thing to note here is that this algorithm works not just for numbers, text. It works for any digital document like word documents, audio, video, photos, you could put a whole operating system in there!.

1. It has to be one way: You cannot go from the hash to determine what document contains. Thus you cannot restore or reverse engineer the hash.

2. It has to be deterministic: It means that if I take the same document and run SHA256 algorithm again algorithm should generate the same result.

3. Avalanche effect: It means that if you take the document and you change it, the output(hash) will drastically change. It’s very similar to an avalanche where one tiny wrong step can cause snow to start moving and then more snow moves.

4. Avoid collision: It means no two inputs should have the same hash. The collision must be avoided to maintain the data integrity and there’s a reason for it. Say, a pirate/hacker tries to replicate the same document you provided and what then? The chain will assume that the owner of that document is that pirate? So, collision should not happen.

2. Immutable Ledger:

So, How the Blockchain is an immutable ledger? Let’s take one example.

Let’s say you want to buy a house. You take your money and buy that Dreamhouse of yours. So, what do you get in exchange? you actually get the home. But how do you know that you own that home? Well because in exchange for that money what you get is a deed, a title deed to the house and whoever has the deed is the owner of the house. To prove that it’s your house you need to take the deed to government authority and register your ownership and after that, you can say that this is my house now. The authority writes down your entry in a ledger.

An interesting thing here is that most of the countries still use written documents as ledgers. Well, this is all you have as proof! you have the deed entry of yours which is a little tiny entry in a book somewhere in a building that belongs to the government where it says you own the house. What if that building burns down or what if somebody steals that book and alter the page where everything is the same except for your entry. You don’t have your Dream home now!

So how this thing can be solved by using blockchain technology?

Let’s say every single title deed, every time somebody bought something or sold a house, it’s a new block that’s added to the chain which is created by the government authority. Now you buy a house and you add in each transaction to the block. A couple of months or year later somebody comes along and decides to take your home away from you by tampering with the data in the block. What now? Here the things get interesting.

What’s happened in those past couples of months or years is that more property transactions have happened. People had bought or sold the house and everything was recorded in the ledger (aka Blockchain).

If this person tries to tamper with the data in that specific block then what happens is that it will change the hash of that block. And what that means is that cryptographic link will no longer work because the hash now is different. So, this person would have to change next blocks hash as well which causes the Avalanche effect in the chain. It becomes very hard for any person to tamper the record in the chain where it grows continuously and that’s what we mean that Blockchain is an immutable ledger. Because you cannot change data. So, the longer, more the time passes, the harder it becomes to change and eventually becomes practically impossible.

My articles are free, but you know you can press the clap👏 button 50 times? The higher you go, the more it motivates me to write more stuff for you guys.

Feeling super exited? 😎 Buy me a coffee. ☕️ 😃

3. Distributed Peer to Peer Network

As we saw an example on house property, blockchain can add more protection and make the whole ledger immutable and make it very difficult for somebody to change the records. However, the question here is, what if I try to attack this Blockchain which is maintained just by that government authority? then what prevents me from going in? and what if I have enough time to change the blocks in the blockchain? After all, we’re talking about a property that might be worth a couple of hundred thousand dollars. It might be worthwhile for somebody to actually put in the effort to change the block here, replace your name with their name and then the hash will be updated and then they will change all the next block’s hash!

So what prevents them from doing it? what if there is some system error!?. So, this is a problem and distributed peer to peer networking takes up its role in the blockchain.

In a distributed P2P system lots of computers are interconnected and the more they’re connected the better is the trust. But of course, we can’t possibly be connected to everybody at the same time in right? Some computers are far away from you and some are near. But in the end, everybody is interconnected through the network.

How is this used in Blockchain? Well, this Blockchain is actually copied across all of those computers.

Let’s think about our example of house property. Instead of just keeping it on one system in that government computer, we copy it across thousands and thousands of computers. Everything will now be connected through cryptographic keys.

Let’s go with this example.

So once your block is added to the chain, what happens is that information is communicated throughout the network and that block is added further and further throughout the network until all of the computers have this block. So, in this case, the transaction of the house that we purchased is now copied onto all of the networks. So, what if somebody tries to hack your entry or there’s an error that has been made to the entry? As soon as this thing happens we know that the cryptographic links between the blocks will cause a problem for them because now all of the blocks after the tampered blocks are all of the sudden are invalid. They might go ahead and find the hashes of all next blocks, before having distributed peer to peer networking, it would have been the end of your hundred thousand dollars of your Dreamhouse. But in distributed P2P networks what happens is, the blocks are all synced up constantly and the network is constantly checking. That’s how the Blockchain system is designed.

A hacker cannot just attack one computer. Now he will have to attack all of the blockchains copies at the same time. But now to successfully attack they actually have to attack not all of the piers but they have to take more than 50 percent of the computers in the chain which is called 51% attack which will discuss in upcoming topics. That’s the only way the attacker can break into a blockchain. And the more you have computers and the more peers you have the harder it is to break the chain.

Let’s keep the thing interesting. We will discuss the Mining and Consensus protocol in Part 2 of this article.

Thank you all for reading this article. Hope you people will like Part 2.

Get Best Software Deals Directly In Your Inbox


Coinmonks is a non-profit Crypto educational publication.