Blockchain - a chain structure that affects the whole body

foreword

We have deeply analyzed the two typical hashing applications of proof of work and Merkle tree. This time we discuss the third application of hashing, which is also the core content of digital currency, the chain structure of blockchain.

insert image description here

Please pay attention to the gitcoins Douyin channel . We'll be sharing fun, high-quality, cryptocurrency-related videos.
insert image description here

block structure

Everyone knows that the blockchain is a chain structure, and this chain structure connects blocks one by one to form a blockchain. Let's zoom in on one of the blocks and dissect the sparrow. You will find that there is a cartoon person in each block. The body of this cartoon person is a triangle, which is the Merkle tree we discussed earlier. Today we analyze the header structure of the block to see how each block is linked? The header mainly includes the following information:

Merkle Root
Previous Block Hash
Difficulty Target
Nonce

insert image description here

How blocks are linked

What kind of information can link all the blocks to form this blockchain. The header information of each block contains a hash value, which is the hash value of the header information of the previous block. Through this hash value, we can find its previous block, also called the direct leader block. That is to say, each block does not know its position in the global blockchain, but only knows where its previous block is.
insert image description here

back link

The blockchain is like the organizational structure of a company. We only pay attention to who our direct leaders or first-line leaders are. We never care who the second-line and third-line leaders are, because it is the first-line leaders who assign jobs to you and decide your promotion. salary. The second-line leaders are the first-line leaders' concern, because the first-line leaders must fully understand the second-line leaders' personality, hobbies, work style, etc., because the second-line leaders determine whether the first-line leaders can be promoted. In this way, as the company's hierarchy continues to rise and the company's scale continues to expand, a relationship chain of company leaders is formed, which is the company's organizational structure. In computing, a data structure that only cares about direct leaders and first-line leaders is called a back-linked list.
insert image description here

In the blockchain, the header of each block records who its direct leader is, and the hash value of its direct leader displayed in this block is like this, that is, whose header information After the hash is this value, whoever is my direct leader. In this way, the block has a link relationship with his direct leader. Similarly, the head of the direct leader also records the hash value of the second-line leader. Whoever has this value after hashing the header information is the second-line leader the direct leader is looking for. The world of blockchain is so beautiful, all the blocks are interlocking.
insert image description here

fork

The development of the blockchain is the same as ours. Many people follow the same direct leader. If some businesses are not started, it is not an outlet and does not conform to the laws of the market. Then this person has not been developed and reused. Some people have done the right thing. , The faster the team grows, the more rewards they will get. This process is called a fork in the blockchain.
insert image description here

If the transaction in the block is tampered with

If a hacker enters the full node and tampers with the transaction data in a block, the protocol will gradually discover the problem according to the rules. First of all, according to the verification rules of the Merkle tree, the hash value of the root of the tree will change, and the root of the tree will change, that is, the content of the block header is different from before, so the hash value of the block header will also be different from before .
insert image description here

That is to say, the hash value of the head of the direct leader has changed. Since the information of the subordinate blocks remains unchanged, the subordinates can no longer find the direct leader, which will lead to tearing and disconnection of the blockchain.
insert image description here

When the full node is loaded again, the following chains are no longer considered valid data and are directly deleted.

insert image description here

In addition, when the hash value of the tree root changes, the entire proof of work becomes invalid, because the previous video also said that the NONCE in the header is based on the previous hash value of the tree root and other information to mine on the entire network. It is calculated under the requirement of difficulty (diffculty). If the hash value of the tree root changes, the information in the header (direct leader, timestamp, tree root hash value) and NONCE are hashed again to get a value, which usually cannot meet the mining difficulty requirements. That is, this block is an invalid block and is deleted by all nodes.
insert image description here

At this point, everyone can understand that the blockchain has a strict security verification mechanism, and small changes will cause changes in the whole body, which will be noticed soon.

conclusion

The application of hash in the blockchain is ubiquitous. We have deeply analyzed how to prove the workload, how the Merkle tree detects tamper-proof, and the chain structure of the blockchain that affects the whole body. Hash is the first key to open cryptocurrency. In order to lay a good foundation for learning cryptocurrency, the Gitcoins Douyin channel will continue to output the technical principles related to encrypted digital currency for everyone, and discuss the core of digital currency with you through intuitive and visual videos. Please like and follow. We will discuss the mechanism of symmetric encryption and asymmetric encryption in the next issue.

Guess you like

Origin blog.csdn.net/gitcoins/article/details/125938048