Blockchain: how does it work?

Think of your friend in another country who ran out of his money. He contacts you and asks you to send him some money. You agree and call your bank manager to request some amount of money be transferred from your account to your friend’s account. He checks your account balance to determine if you have enough money to transfer to your friend. Once he does that, he enters the following in the register:

You — — — — — — — — — — — Your friend (amount of money)

Then you call your friend and say that money is transferred, and he can withdraw it.

So, what exactly happened? You and your friend both put your money in the bank’s hands. There was no genuine movement of actual bills to transfer funds. A simple entry in the register was all that was required. Or, to put it another way, an entry in the register that neither you nor your friend owns or controls. And this is the issue with today’s systems.

We rely on individual third parties to develop trust between us. We’ve relied on these intermediaries to trust each other for years. “What is the problem with relying on them?” you might wonder.

The issue is that there are only a few in total. If society needs to be filled with instability, all it takes is for one individual or group to become corrupt, whether intentionally or unintentionally.

And there are dangers as if the register, where the transaction was recorded, maybe burned down, or the account manager may mistakenly enter the wrong amount of money, unintentionally, or even worse intentionally.

Could there be a mechanism that allows us to send money without using a bank?

Consider this for a moment: what does it mean to transfer money? It’s just an entry in the register. Is there a method for us to keep track of the register ourselves rather than having someone else do it for us? And the answer is, as you could have anticipated, the blockchain.

It’s a way for us to keep track of our own records rather than relying on someone else to do it for us. And let’s elaborate on how this distributed register works.

This strategy requires enough persons who would prefer not to rely on a third party. Only then will this group be able to keep track of the register on their own.

Let’s assume that ten people desire to stop using banks or any other third-party service. They always have full access to each other’s accounts, without knowing each other’s identities. And everyone has an empty folder. As time goes by, each of these ten people will continue to add pages to their empty folders. This collection of pages will be used to create the register that will keep track of the transactions.

Now, everyone in the network sits with a blank sheet and a pen in their hands and when a transaction occurs, everyone in the system writes them into their blank sheet. For example, if the third person wants to transfer $20 to the seventh, he or she must do so. “I want to transfer $20 to the seventh person. Please make a note of it on your pages, everyone,” the third person says.

Everyone checks to see if the third person has enough money to send $20 to the seventh. If she has sufficient funds, everyone records the transaction on their blank papers. After then, the transaction is declared complete.

With the passage of time, more members in the network feel the need to send money to others. They notify everyone else whenever they wish to make a transaction. As soon as a person hears the announcement, he or she records it on his or her page. This procedure continues until everyone on the current page runs out of room. Assuming a page has enough space to record twenty transactions, everyone will run out of space after the twentieth transaction is completed. And it’s time to place the page back in the folder, pull out a new page, and repeat the steps above.

Before we file the page, we need to encrypt it with a unique key that everyone in the network agrees on. The core of this procedure is the encryption of the page.

Previously, the third-party/middleman assured us that anything they wrote in the register would never be changed. This encryption will offer credibility in a distributed and decentralized system like ours.

Let’s elaborate on how encryption works.

Consider a machine encased in thick walls. If you send a box from the left with anything inside, it will spit out a box with something else inside. The name of this machine is Hash Function.

For example, if you send the number 8 from the left into it, it will spit out the following word on the right: ‘08uvn.’ How did it get this word from the number 8? No one is aware. Furthermore, it is a procedure that cannot be reversed. It’s hard to discern what the machine on the left was fed based on the word ‘08uvn.’ When you feed the machine the number 8, however, it always spits out the same word: ‘08uvn.’

What if we want to have a specific output, such as ‘0007yue’? What should we send from the left side of the machine to get a word like ‘0007yue’ from the right side?

The machine has a characteristic that prevents us from calculating what we must send from the left after receiving the desired output from the right.

So, if we are lucky, after a few thousand tries perhaps we’ll get a number that produces the required result on the right. Calculating the input given the outcome is incredibly tough. However, it will always be exceedingly simple to verify if the predicted input produces the desired result. Keep in mind that the machine always spits out the same word for a number.

The most essential aspect of such machines is that it is exceedingly difficult to compute the input given output, but it is rather trivial to verify if the input leads to the output given the input and the output.

How can you encrypt a paper with this machine?

For example, you are given two boxes. The number 32346 appears in the first box. Can you come up with a number that, when added to the number in the first box and sent to the machine, gives us a word that begins with three leading zeroes? (This phrase is used as an example to show how Hushing Function works)

The only method to calculate such a number is to test every number in the universe.

After a few thousand tries, if we are lucky, we’ll come up with a number, say 20435, which, when combined with 32346 (i.e. 20435+ 32346 = 52781) and fed to the machine, will produce a word that meets our criteria.

This number, 20435, becomes the encryption for the number 32346 in this situation. Let’s imagine there’s a page with the number 32346 written on it. We’ll place a badge labeled ‘20435’ on top of that page to encrypt it (i.e., no one can change its contents). The paper gets encrypted as soon as the encryption number (i.e. 20435) is pasted on it.

The encryption number is referred to as ‘Proof of Work,’ which means that it is proof that attempts were made to compute it.

If someone wishes to check if the page was tampered with, all they must do is combine the contents of the page with the encryption number and feed it to the machine. The contents were unaffected if the machine outputs a word with three leading zeroes (or your desired output). If the word that comes out doesn’t satisfy our criteria, we can discard the page because its contents have been tampered with and are no longer useful.

We’ll use a similar encryption process to encrypt all our papers before putting them in their proper folders.

These all demonstrate the operation of Hashing Functions. However, problems are far more complex than this. After spending time and electricity on the machine to calculate that number, the page is encrypted with that number. If the contents of the page are ever changed, the encryption number will allow anyone to verify the page’s integrity.

Now that we know how to encrypt a page, we’ll return to the point when we’d completed the twentieth transaction on the page and had run out of room to type anymore. When everyone has run out of space on the page to write more transactions, they begin computing the page’s encryption number so that it can be tucked away in the folder. To encrypt the page containing the network’s transactions, we’ll need to come up with a number that, when appended to the list of transactions and supplied to the machine, produces a word that begins with three leading zeroes on the right.

Upon hearing the encryption number from someone who did the calculation first, everyone checks to see if it produces the desired effect. If it happens, everyone should write this number on their papers and file it away in their folders.

Why does everyone expend energy on the computation when they know it will be done and announced by someone else? Why don’t you just wait for the announcement and do nothing?

This is where the financial incentives come into play. Rewards are available to everybody who participates in the Blockchain. For his efforts, the first person to compute the encryption number is rewarded with free money (i.e. expended CPU power and electricity).

Imagine that if No 9 calculates a page’s encryption number, he is paid with some free money, say $5, that is minted out of air. In other words, No9’s account balance is increased by $5 while no one else’s account balance is affected.

That is how Bitcoin came into being. It was the first cryptocurrency to be used in a Blockchain transaction (i.e. distributed registers). People were given Bitcoins in exchange for continuing to work on the network. Everyone in the network is motivated to keep working because of the incentives.

And once everyone has tucked the page away in their folders, they bring out a new blank page and resume the procedure ad infinitum.

Consider a single page to be a Block of transactions, and a folder to be a Chain of pages (Blocks), resulting in a Blockchain. That is how Blockchain works.

--

Fun NFT products for the world

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