A thorough understanding of how the blockchain works?

Why is the blockchain called a "trust machine"? How does it work? Here's the easiest explanation!

 

llThis article is translated from Authorito Capital CEO's blog post "WTF is The Blockchain?", with slight deletions.

llOriginal link: https://hackernoon.com/wtf-is-the-blockchain-1da89ba19348

 

The rule of the game for blockchain is that there must be enough people who don’t want to rely on a third party for transactions. How many people count as "enough"? At least three.

 

Let's assume that there are ten players who want to give up the bank or any third party who, by mutual agreement, have the details of each other's account without knowing their identity. At this point, the game begins.

 

 

 

a blank ledger

Each player starts with a blank ledger. As the "game" begins, each player keeps writing things on this blank ledger, with more and more transactions, and the number of pages in the ledger is also increasing. This ledger is our "register" for tracking transaction records.

 

when there is a transaction

Each player in the system has a blank ledger, and whenever a transaction occurs, they record the transaction on the ledger.

Now, suppose player 2 wants to transfer 10 bucks to player 9. In order to conduct the transaction, No. 2 shouted in the system, "Guys, I'm going to transfer 10 yuan to the girl No. 9, you can write it down in the account book."

 

Next, each player starts to check whether No. 2 really has 10 yuan to transfer to No. 9. If she does have enough money, then all players will record the transfer on a blank page of the ledger. In this way, a transaction is completed.

 

transaction continues

Over time, more and more players in the system need to transfer money to others. Whenever they want to transfer money, they just need to tell all players in the system that as long as one person hears it, he/she will record the transaction on the ledger.

Accounting continues until all players have used up the current blank page. Assuming that one page of ledger can record ten transactions, when ten transactions are completed, then this page cannot continue to record.

At this time, just save this page of records to the folder, then turn to the next blank page, and continue to book.

 

The page that was turned over

Before we turn the page with 10 transactions, it needs to be sealed with a "mystery lock (key)" that every player in the system agrees to. Sealing ensures that no one can make any changes to this page once a copy of the record has been released to each player's folder. Once in the folder, it will be sealed inside forever. "Sealing" is the key to this game.

 

How to seal a page

Before we look at how to seal a page, let's take a look at how "seal" works.

1. The magic machine

Imagine a machine surrounded by thick walls, if you send a box with content in from the left of the machine, on the right, it will spit out a box with other content.

This machine is called a "hash function", but we don't have to be so academic, so let's call it the magic machine.

Suppose you enter the number 4 from the left, we will find it spits out the following word from the right: 'dcbea'.

How does it convert the number 4 into the word? no one knows. But we need to know that this is an irreversible process. If we know that the word coming out on the right is "dcbea", we can't figure out what is being fed into the machine from the left, but every time we feed the machine the number 4 from the left, the word "dcbea" will inevitably appear on the right.

Let's try entering a different number, such as "26". We get '94c8e' this time. interesting!

If I ask you this question:

Can you tell me what should I input from the left side of the machine so that I can get numbers or words starting with three zeros from the right side? For example, 000ab or 00098 or 000fa or whatever.

As I said before, this machine has a strange property: if I know what's going out on the right, there's no way to figure out what's going in on the left. With such a machine, how can it be possible to answer the above question?

I figured out a way to try each number one by one until we get a word that starts with 000. Perhaps after thousands of attempts, we can get this result.

When we are given the output on the right, it is very, very difficult to calculate the content of the input on the left. But at the same time, it is very easy to verify that a given input produces the desired output. Remember that the machine will give the same output for one word every time.

If I give you a number, say 72533, and I ask you "Does this number go into the machine, does it get a word or number that starts with 000?" all you need to do is throw the number into the machine and see you Just get what you get on the right.

The most important feature of this machine is this: given an output, it is very difficult to compute the input, but if there is an input and an output, it is easy to verify that the input produces the output.

 

2. How to use this machine to seal the ledger page

We'll use this magic machine to generate a "stamp" for our page.

Suppose I give you two boxes. The first box contains the number 20893. Then I ask you: "Can you work out a number, add it to the number in the first box, feed it into a machine, and end up giving us a word that starts with three zeros?" We said before Well, the only way to come up with that number is to go through every number in the universe.

After thousands of tries, we stumbled upon a number 21191 which, when added to 20893 (ie 21191 + 20893 = 42084) and fed into the machine, produced a word that met our requirements.

In this case, the number 21191 becomes the seal of the number 20893. Suppose there is a page with the number 20893 written on it. To seal the page, we will place a badge on it labeled "21191". The page is sealed once the seal number (ie 21191) fits snugly on the page.

The sealed number is called a "proof of work," meaning that the number is proof that it was worked out.

If someone wanted to verify that the records on the page were changed, all he had to do was add the contents of the page to the magic machine along with the seal number. If the machine's result is a word beginning with three zeros, the content has not been modified. If the words that come out do not meet our requirements, then we can discard the page, because its content has been modified.

We will use a similar sealing method to seal all of our record pages and eventually arrange them in our respective folders.

 

Finally, seal the page

To seal the page where the transaction is recorded, we need to calculate a number, append it to the list of transactions, enter it into the machine, and get a result that starts with 000.

Note: "words starting with three zeros" is just my example to demonstrate how the hash function works, the real hash result is more complicated than that.

Once the number is calculated on the machine, the page is sealed with that number. Anyone can verify the integrity of the page content by sealing the password.

Now let's go back to the time when the tenth transaction was recorded. As soon as the page is used up, each player starts calculating the "seal password" that seals the page. The first calculated player will tell all players in the system the seal password.

As soon as the seal password is heard, each player begins to verify that the password is correct, and if the password is correct, each player marks their page with this number and places it in their folder.

But what if someone, such as player No. 7, says "This seal password is incorrect, I can't verify it"? This rarely happens, but if it does, it could be for the following reasons:

1. He may have misunderstood the transactions published in the network;

2. He may have miswritten transactions published in the network;

3. He may attempt to defraud for his own interests.

 

Whatever the reason, player 7 has only one option - discard his page and copy it from someone else so he can put it in the folder too.

If he doesn't put his pages in the folder, he can't continue to record transactions in the system, so he can't continue to be a part of the system.

One question, if we all know there is one person who can calculate the sealed number and make it public, why do we need everyone to spend time and resources to calculate it, isn't it good to sit and wait for the result?

Because it's paid! The first person to figure it out gets paid. This is the incentive mechanism in blockchain.

For example, if player 5 is the first to figure out the seal code, he will receive a bonus of 1 yuan. On the Bitcoin blockchain, this bonus is Bitcoin. The bonus motivates each player to keep working on the system.

 

Friends, this is how blockchain works. Here, each page of the ledger is regarded as a block, and the entire ledger is regarded as a chain, which is the blockchain.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325856336&siteId=291194637