Blockchain--Consensus Algorithm POW

 

First, let's learn more about what the consensus algorithm is doing by introducing a Byzantine Generals Problem.

 

story:

The Byzantine Empire, with its huge wealth, has been around for a long time with 10 neighbors, but the Byzantine wall stands tall, and no single neighbor can successfully invade. Any invasion by a single neighbor will fail, and may itself be invaded by 9 other neighbors. The Byzantine Empire was so defensive that at least half of its ten neighbors attacked at the same time.

One or several of the neighbors themselves promised to attack together, but in the actual process of betrayal, the invaders may be wiped out.

So each side acted cautiously and dared not easily trust its neighbors. This is the Byzantine Generals problem.

 

So if you want to eat this fat, the most important thing is that the generals of 10 neighboring countries agree to attack the Byzantine Empire. It's a matter of solving 10 distrusting individuals to get the most out of it.

There are several relatively basic solutions to this problem, such as oral information, written agreements, etc., we will not talk about these, and go directly to the advanced point, which is the consensus algorithm pow of Bitcoin.

 

Proof Of Work

If all 10 generals send messages, it will be very easy to mess up, because everyone receives messages from the other 9 people, so Nakamoto stipulates that only one person can send information to launch an attack. This person can be anyone, but there are certain Conditional restrictions, this condition is the "workload", that is to say, the person must complete a calculation work before sending a message, and whoever completes the calculation work first can send a message.

When a general calculates this result, he sends out an attack message, and other generals must sign to indicate their identity after seeing it. Please note here that the signature in ancient times is easy to forge, so Satoshi Nakamoto introduced encryption technology, which is Asymmetric encryption, its benefits: 1. The privacy of the message. 2. Confirm the identity of the signatory. 3. The signature cannot be forged or tampered with.

 

Asymmetric encryption

The asymmetric encryption algorithm uses two different keys for encryption and decryption by the asymmetric encryption algorithm. These two keys are the public key and the private key.

The public key and the private key generally appear in pairs. If the message is encrypted with the public key, the private key corresponding to the public key is required to decrypt it; similarly, if the message is encrypted with the private key, the public key corresponding to the private key is required to decrypt. The role of asymmetric encryption is to protect the content of the message and allow the recipient of the message to determine the identity of the sender.

 

If General Zhang wants to send a message to General Li, in order to prevent the information from leaking, General Zhang only needs to encrypt the information with General Li's public key, and General Li's public key is public, and General Li only needs to use his own private key. The key can be decrypted. General Li wants to declare his identity on the letter. He can write a "signature text" by himself, sign it with his private key, and broadcast it. Everyone can verify the signature according to General Li's public key. identity.

 

Hashcash

This is the calculation that everyone needs to complete. To find a random number, the computer can only find this random number by exhaustive method, and no one can be sure to find it. Randomness is fair, and the mathematical logic of this randomness is recognized by everyone.

 

bonus system

The design of Satoshi Nakamoto is to reward a certain amount of bitcoins for each person who calculates this random number. This mechanism is automatic. This reward mechanism motivates everyone to do this calculation together, and the work is not in vain.

 

 

Summarize:

The consensus algorithm mainly solves who will create the block and how to maintain the unity of the blockchain.

In this paper, proof of work solves the consistency problem, and asymmetric encryption technology solves the trust problem.

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

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