Blockchain Technology and Application - Study Notes 3 [Bitcoin Data Structure]

Hello everyone, I am Bit Tao. This series of notes only focuses on exploring the principles of blockchain technology and does not discuss other matters that violate relevant regulations. Blockchain technology has been included in the national 14th Five-Year Plan. In the chapter "Accelerating Digital Development and Building Digital China", blockchain is listed as one of the seven key industries of the digital economy during the 14th Five-Year Plan, ushering in a new era of innovation and development. opportunity.

Approved by the Ministry of Science and Technology, the National Blockchain Technology Innovation Center has landed in the Beijing Zhongguancun National Independent Innovation Demonstration Zone and will be officially put into operation on May 10, 2023.
Insert image description here

Table of contents

Blockchain Technology and Application - Study Note 1 [Introduction]
Blockchain Technology and Application - Study Note 2 [Basic Cryptography]
(The series of notes are being updated...the catalog will be integrated after the update)

This article mainly explains the data structure of Bitcoin. Bitcoin mainly connects blockchains through hash linked lists. The content within each block is organized through Merkel trees to achieve the function of efficiently organizing records.
Insert image description here

1. Hash pointer

Each block in Bitcoin is organized using a linked list of hash pointers, and each block contains multiple transaction information. Everyone should be familiar with the traditional linked list. Its predecessor and successor are both pointed to by memory pointers. The hash pointer is slightly different from the ordinary pointer. The structure of the hash pointer is shown in the figure below:
Insert image description here
All data in each block will form a hash value to ensure that the data in the block has not been tampered with. And each block (except the genesis block) contains the hash value of the previous block. The next block will then undergo another hash operation based on the hash value of the previous block. So it is guaranteed that as long as you get the hash value of the latest block, all the data on the previous blockchain has not been modified.

In practical applications, an entire chain may be cut off and stored in multiple places. If the user only owns one of the sections, when using the previous part of the block data, he can directly ask other nodes in the system for it. When it is time to arrive, you can judge whether the given content is the real content on the blockchain only by calculating whether the last hash value is consistent with the saved hash value.

2. Merkle tree Merkle tree

The difference between a Binary tree and a binary tree is that hash pointers represent ordinary pointers:
Insert image description here
blocks in the blockchain include light nodes and full nodes. Light nodes only have hash values, while full nodes also have content information. This is because the full node contains all transaction information, and a block is 1M in size. For ordinary scenarios, there is no need to save the entire ledger on the blockchain, so just save one and the hash value. Ordinary nodes are just light nodes with root hash values, but when light nodes need to verify whether a certain transaction data in the block is legal. Then you need to ask the full node for Merkle Proof, that is, pass the red and green hash values ​​in the picture above to the light node. After the light node gets it, it can start from the bottom: take the hash value of the transaction to be verified to see if it is equal to the value sent by the full node. If it is the same, add red and count it to the next level, and calculate it in sequence. The result is calculated to be exactly the same as the hash value, proving that the transaction is legal.

In addition, the linked list used by the blockchain does not have cycles. Because its own content contains the hash value of the previous block, and because the next block must contain the hash value of the previous block, there will be a circular dependency problem if there is a ring.
Insert image description here

Guess you like

Origin blog.csdn.net/u012558210/article/details/132735644