A method for constructing a blockchain data storage extension model for the Internet of Things
By decoupling the consensus and data storage of blockchain in the Internet of Things environment, using lightweight nodes and storage node division, combining vector commitment tree and P2P distributed storage, the blockchain storage pressure and poor scalability in the Internet of Things is solved. The problem has achieved efficient and secure blockchain data storage and expansion.
Patent Information
- Application Number
- CN202210524126.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-13
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2042-05-13
AI Technical Summary
Traditional blockchain models have problems such as high storage pressure, low node access efficiency and poor storage scalability in the Internet of Things environment, and cannot efficiently integrate blockchain technology with IoT scenarios, resulting in data redundancy and resource waste.
A blockchain storage expansion model for the Internet of Things is proposed. By decoupling consensus and data storage, a lightweight layer and storage layer are established. Lightweight nodes are responsible for transaction consensus and verification, and storage nodes are responsible for distributed storage of blockchain data. Use a vector commitment tree to ensure data integrity and compress verification information, and combine it with a P2P distributed data storage system for data offloading and sharding storage.
A lightweight, secure and scalable blockchain storage model is realized, reducing the storage load and resource waste of nodes, improving the blockchain expansion efficiency and the efficiency of new node expansion in the Internet of Things environment, and enhancing the ability of data Reliability and storage security.
Smart Images

Figure CN114915404B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of blockchain and relates to a method for constructing a blockchain data storage extension model for the Internet of Things (IoT). Background Art
[0002] In recent years, with the rapid construction of information infrastructure and the vigorous development of IoT devices, the service scope of IoT has been greatly expanded. Many scholars have introduced blockchain technology into IoT to solve problems such as centralized management of IoT devices, IoT data sharing, data security, access control, and device access. However, the traditional blockchain model is mainly aimed at cryptocurrency or Internet application scenarios, while the number of devices in IoT is large, heterogeneous, and computing and storage resources are limited. Some blockchains require a certain amount of computing power to support transaction consensus and encryption calculations. The data under IoT will be much larger than the existing Internet data volume, which puts higher requirements on the efficiency and throughput of blockchain on-chain.
[0003] In order to ensure that it is not tampered with, the traditional blockchain model does not support the deletion of historical data. As the amount of data increases, the block data storage load will become a bottleneck for the system. The challenges to be faced include: ① When a new node joins the blockchain network, it needs to download a large amount of data to keep the data synchronized with the blockchain, which is not conducive to the expansion of new nodes; ② The increase in data volume will increase the burden on blockchain nodes, and nodes with limited storage space will exit the blockchain network, thus destroying the decentralized nature of the blockchain; ③ Each node in the blockchain participates in computing and storage, resulting in data redundancy and resource waste.
[0004] In the integration of IoT and blockchain technology, if the blockchain is deployed on the cloud far away from IoT, the IoT application will only be the client of the blockchain and will not participate in blockchain transactions. The operation of the blockchain will not be controlled by the IoT device, which will lead to a trust gap between the IoT and the blockchain, and a large delay in accessing the blockchain interface. Therefore, the current blockchain technology cannot be efficiently integrated with the IoT scenario. When facing the IoT environment, there are problems such as high blockchain storage load pressure, low node access efficiency, and poor storage scalability. Summary of the invention
[0005] In view of the fact that the current blockchain technology cannot be efficiently integrated with the Internet of Things scenario, in order to help the blockchain technology to be successfully implemented in the Internet of Things environment, the present invention proposes a method for constructing a blockchain storage expansion model for the Internet of Things, which improves the scalability of the blockchain by decoupling the consensus and data storage in the blockchain, so that each module can be optimized independently. The historical ledger data on the edge node is stored and unloaded, and the integrity of the stored data is guaranteed based on the vector commitment tree. At the same time, the vector commitment can also compress the verification information, so that the edge node only needs to store a certain amount of proof information to achieve the same effect as keeping the complete ledger data, thereby effectively solving the problems of high edge node storage pressure, low node access efficiency, and poor storage scalability during the deep integration of blockchain technology in the Internet of Things.
[0006] The present invention proposes a method for constructing a blockchain data storage extension model for the Internet of Things, comprising the following steps:
[0007] (1) Establish a blockchain storage layered model, including a lightweight layer and a storage layer; lightweight nodes are responsible for collecting transaction data, reaching consensus on transactions, and verifying execution results; storage nodes are responsible for storing transaction history data and status data;
[0008] (2) Construct lightweight nodes. Based on the network structure of the Internet of Things, local nodes in the network partitions belonging to the same geographical range are organized into a cluster with one master and multiple slaves, and the master node is used as a lightweight node. The lightweight node is implemented as follows:
[0009] (2.1) The lightweight node collects transaction requests from IoT devices in the network partition, verifies the sender's identity, checks the address in the transaction request, and checks whether the transaction is replayed to prevent resource waste and malicious attacks. Transaction requests that pass the lightweight node check will be added to the lightweight node's transaction pool for caching, which facilitates the subsequent rapid extraction of transactions and timely response to client requests.
[0010] (2.2) Lightweight nodes conduct transaction consensus. If the transaction request volume in the transaction pool of the lightweight node reaches the maximum delay of the consensus protocol or the maximum transaction volume limit of the block, the lightweight node extracts the transaction ID from the local transaction pool, sorts the transaction requests in the block in chronological order according to the ID and the consensus protocol, packages them into a consensus request list, and broadcasts them to other lightweight nodes. The lightweight node packages the consensus transactions into a simulated execution block and sends the block to the storage node through the asynchronous network.
[0011] (3) Constructing a storage node. Pre-set the physical node in the Internet of Things as a storage node through a configuration file. The storage node is implemented as follows:
[0012] (3.1) Storage nodes execute transactions. After receiving the block, the storage node verifies the lightweight node identity and the digital signature of the transaction request in the block. After verification, it calls the smart contract to execute the transaction. The input of the smart contract is the state data read set and the transaction request tx i , the output is the state data write set and the state code; the read set {state read}Record transaction tx i The submitted state key value in the write collection {state write}Record transaction tx i Updated status key value; status code records the status of transaction execution results;
[0013] (3.2) The storage node executes the ordered transactions in the block, and calculates the vector commitment value in groups of q transactions, and constructs a vector commitment tree; q is a positive integer; for transaction tx i , storage nodes use {state write} and {state read} in the state key value to calculate the vector commitment value and obtain the proof information φ write and φ read ;
[0014] (3.3) The storage node uses the private key pair 〈φ read ,C old ,φ write 〉Signature generation proof φ sig , returns the execution result to the lightweight node exec = <tx i ,{state read},{state write},φ sig > Where C old Indicates that in transaction tx i Execute the root value of the vector commitment tree before;
[0015] After the block is verified by the lightweight node, the storage node will write}Update the status data under the corresponding account, and upload the updated status data and status code to the blockchain for storage.
[0016] (4) The lightweight node verifies the execution results, including:
[0017] After the storage node completes the execution, it generates verification data information for the transaction and broadcasts it to the lightweight node together with the transaction's read-write set as the execution result; the lightweight node saves the latest state data and its vector commitment tree in the last K blocks, verifies the old data in the transaction's read set based on the locally saved vector commitment tree for the execution result sent by the storage node, re-executes the transaction based on the write set to generate a new vector commitment value, and verifies the correctness of the transaction's write set and the verification information from the storage node. Finally, when the verification passes, the lightweight node will update the local vector commitment tree and cache the latest blockchain state data.
[0018] (5) Storage nodes offload and back up blockchain data through the P2P distributed data storage system.
[0019] The execution of blockchain transactions relies on the latest status data. The storage nodes shard the historical data of the blockchain, including historical ledgers and data modification records, and symmetrically encrypt the blockchain data shards. The encrypted data is stored in a distributed P2P storage system, and a routing table is established for the data of each shard to facilitate data download.
[0020] The method of the present invention constructs a secure and scalable blockchain storage model. By establishing a lightweight layer and a storage layer, the lightweight node is responsible for connecting to the terminal devices in the Internet of Things, and the storage node is responsible for the distributed storage of blockchain data. It decouples the consensus and data storage, verification and other processes in the traditional blockchain model, and effectively solves the problems of high data storage pressure and difficult node expansion in the process of combining the Internet of Things and blockchain technology. Compared with the existing blockchain model for the Internet of Things, the advantages and positive effects of the method of the present invention are:
[0021] (1) The method of the present invention realizes a lightweight, secure and scalable model. By decoupling consensus and data storage in the blockchain, each module can be optimized independently, and the lightweight node resource requirements are low, which is conducive to the horizontal expansion of blockchain technology in the Internet of Things environment and the integration of edge devices. The method of the present invention provides an efficient and feasible deployment method for the deep integration of the Internet of Things and blockchain technology.
[0022] (2) The lightweight node constructed in the method of the present invention is deployed at the edge node in the Internet of Things, providing low-latency blockchain on-chain services for edge devices in the Internet of Things, verifying transaction requests, caching transaction requests, completing block transaction order consensus, and verifying transaction execution results, thereby reducing the delay in accessing the blockchain interface and enhancing the credibility of the Internet of Things on-chain data.
[0023] (3) The method of the present invention selects nodes with abundant storage and computing resources in the Internet of Things as storage nodes, which are responsible for the execution of transactions and the storage of complete blockchain ledgers, provide historical data traceability services for the Internet of Things, and combine with lightweight nodes to ensure the security of the blockchain. At the same time, the lightweight design of blockchain node storage reduces the data download amount of newly added nodes, which is conducive to improving the expansion efficiency of blockchain in the Internet of Things.
[0024] (4) The method of the present invention constructs a data integrity verification scheme based on a vector commitment tree. The lightweight node verifies the transaction execution results of the storage node based on the vector commitment tree. The vector commitment can compress the size of the verification information and reduce the bandwidth occupied by transmitting the verification information between nodes, while ensuring data integrity. Based on the vector commitment technology, the method of the present invention realizes the distributed storage of blockchain historical data while ensuring the basic characteristics of the blockchain, reducing the waste of computing and storage resources caused by all nodes storing complete ledgers in the traditional blockchain design.
[0025] (5) The method of the present invention also constructs a P2P distributed data storage system to further reduce the storage load and data redundancy of the storage nodes. Through symmetric encryption technology and data sharding storage, an access mapping table of block and transaction storage locations is constructed at the same time, thereby ensuring the security, scalability and efficiency of data storage.
[0026] (6) The method of the present invention effectively solves the contradiction between the non-deletable historical ledgers of the blockchain and the ever-increasing data storage load in the IoT scenario, effectively solves the load pressure brought by the ever-increasing blockchain storage in the IoT environment, and improves the scalability of blockchain storage and the efficiency of new node expansion. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a flow chart of the construction of the blockchain storage expansion model for the Internet of Things of the present invention;
[0028] Figure 2 It is an overall schematic diagram of the blockchain storage expansion model for the Internet of Things of the present invention;
[0029] Figure 3 It is a schematic diagram of the execution flow of the hierarchical storage expansion model of the present invention;
[0030] Figure 4 It is a schematic diagram of the structure of the vector commitment tree established by the present invention;
[0031] Figure 5 This is an example diagram of the blockchain transaction verification process of the present invention;
[0032] Figure 6 It is a vector commitment tree node update flow chart of the present invention;
[0033] Figure 7 It is a flow chart of storage node data unloading of the present invention. DETAILED DESCRIPTION
[0034] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0035] Figure 1 The five key steps for constructing the storage expansion model of the present invention are described. Step 1: Construct a hierarchical expansion model for blockchain data storage in the IoT scenario, which involves four main roles: IoT devices, lightweight nodes, storage nodes, and distributed storage systems. It includes blockchain components such as access control, transaction consensus, execution engine, data storage, and transaction verification. These components collaboratively process transaction requests from IoT devices to achieve IoT data storage and blockchain data storage hierarchical expansion; Step 2: Lightweight nodes collect transactions. They collect transaction requests from IoT devices in the sensor network area, perform access control on device connections, verify transaction requests, and provide blockchain services for IoT devices in the area; Step 3: The blockchain model consensus generates a new area. Block, lightweight nodes broadcast block data to storage nodes, which are responsible for the execution of complete block transactions; Step 4, lightweight nodes build data integrity verification algorithms through pruning algorithms and vector commitment technology, and storage nodes send read-write sets and verification information representing transaction execution results to lightweight nodes. Lightweight nodes verify the execution results of transactions based on local stored vector commitment trees and status information to ensure that transactions are correctly executed; Step 5, storage nodes encrypt and shard historical data in the blockchain through data offloading technology and P2P distributed storage systems, and store blockchain data in a distributed manner in the P2P storage system through group encryption technology, further reducing the storage burden of storage nodes and reducing redundant data backup on storage nodes. Figures 2 to 6 Each step of the model building method of the present invention is described in detail.
[0036] Step 1: Establish a blockchain data storage expansion model. Figure 2 and Figure 3 shown.
[0037] This paper establishes a new blockchain storage expansion model for the Internet of Things. Under the premise of ensuring the security and verifiability of block transactions, the blockchain ledger data is re-encoded, the transaction status data in the blockchain is stored, and the transaction execution and verification process are decoupled. The entire model is divided into two layers, such as Figure 2 and Figure 3As shown in the figure, it is divided into a lightweight layer and a storage layer. The lightweight layer nodes, referred to as lightweight nodes, are mainly responsible for collecting transaction data, reaching consensus on transactions, and verifying execution results. The storage layer nodes, referred to as storage nodes, are mainly responsible for storing transaction history data and status data. The storage nodes can also encrypt and store blockchain data in a distributed storage system through data offloading technology. The specific construction of the blockchain storage layered model includes the following steps 101 to 104.
[0038] Step 101: Build a security authentication mechanism.
[0039] If IoT devices want to access the blockchain system, they need to register an account with the blockchain and obtain permission to upload data to the blockchain. The system administrator will then authorize the authentication center to issue a digital certificate. The authentication center will send a certificate, public key pk and private key prvk to the client, and the public key will be used to calculate the identity id (pk). The device generates a transaction proposal by signing the transaction request. Unauthorized requests will be rejected by the blockchain. The authorized access control mechanism can prevent the blockchain access interface from being attacked maliciously, prevent the waste of blockchain computing and storage resources, and enhance the robustness of the blockchain.
[0040] Step 102: Build a blockchain lightweight node.
[0041] Lightweight nodes are mainly responsible for verifying the results of blockchain transaction execution, collecting transactions from IoT devices, packaging and generating new blocks, and sorting and arranging consensus on transactions within blocks. According to the characteristics of data timing in IoT, the most important thing in IoT is the most recent data. Lightweight nodes only maintain the most recent K blocks and related block data, and the vector commitment tree used to verify data integrity. The lightweight deployment method of consensus nodes provides low-latency blockchain services for IoT terminal devices, while completing part of the blockchain data processing at the edge terminal, realizing the deep integration of blockchain technology and IoT and the authenticity and credibility of chain data. K is a positive integer.
[0042] Step 103: Build a blockchain data storage node.
[0043] The storage node is responsible for simulating the execution of transactions, maintaining the status data and index data generated by transactions, and supporting transaction history data query and block data download functions. Nodes with sufficient storage and computing power in the Internet of Things are selected as storage nodes of the blockchain. At the same time, in order to prevent the destruction of the decentralized characteristics of the blockchain, the transaction consensus and storage of the blockchain are separated, and the lightweight node is responsible for transaction consensus and transaction execution result verification. This strategy not only ensures the basic characteristics of the blockchain, but also realizes the expansion of blockchain data storage. At the same time, it is also conducive to the expansion of new lightweight nodes in the Internet of Things environment, enhancing the scalability and security of the blockchain.
[0044] Step 104: Build a P2P distributed data storage system.
[0045] The P2P distributed data storage system is responsible for storing the blockchain historical data after encryption and sharding. It further improves the storage scalability of storage nodes through distributed storage technology and sharding encryption, and reduces the storage pressure of storage nodes in the Internet of Things. The storage node shards the historical data of the blockchain and uses symmetric encryption technology to regularly unload the local historical data to the remote P2P distributed storage system, and establishes a mapping table from data shards to storage nodes for the shards. Under the premise of ensuring the encryption security of blockchain data, sharding reduces the redundant storage of blockchain data.
[0046] Step 2: IoT data is stored on the blockchain, including the following steps 201 to 206: Figure 3 shown.
[0047] Step 201: Based on the network structure characteristics of the Internet of Things, the Internet of Things sensor network established with nodes in a certain geographical range is divided into a network partition Region. Several local nodes in the partition form a cluster with one master and multiple slaves, in which the master node becomes a blockchain lightweight node, called a cluster head node. The cluster head node is mainly responsible for processing transactions within the region.
[0048] Step 202: The IoT device sends a transaction request through the SDK (Software Development Kit) interface <tx input ,sig tx >To the local lightweight blockchain node. Among them, tx input Indicates transaction request, sig tx Indicates digital signature, transaction request tx input It contains the account address, transaction sequence number, and account status data that the IoT device wants to access.
[0049] Step 203: The lightweight node verifies whether the identity of the sender is legal, whether the transaction address is legal, and checks whether there is any replay of the sequence number in the transaction request to prevent waste of resources and malicious attacks.
[0050] Step 204: The verified transaction request will be added to the transaction cache pool of the lightweight node to facilitate the subsequent rapid retrieval of transactions and timely response to client requests. In this embodiment of the present invention, when the number of transaction requests reaches the maximum block limit of the PBFT consensus protocol, the lightweight node extracts the transaction ID from the transaction pool, packages it into a consensus request list in chronological order, and broadcasts it to other lightweight nodes in the network.
[0051] Step 205: After receiving the consensus request, other lightweight nodes first verify whether the identity certificate of the requester is legitimate, and verify whether the transaction sequence number and creation timestamp in the consensus request are within the validity period. After successful verification, a consensus success message will be sent to the lightweight node that issued the consensus request, and its own signature will be attached to the response message.
[0052] Step 206: The lightweight node packages the consensus transaction requests into simulated execution blocks and forwards them in batches to the storage node, which executes the transactions in the blockchain and updates the status data corresponding to the transactions.
[0053] Step 3: The storage node executes the transaction, including the following steps 301 to 304.
[0054] The present invention preferentially selects Internet of Things nodes with abundant storage resources as storage nodes, and sets which physical nodes in the Internet of Things serve as storage nodes by presetting configuration files.
[0055] Step 301: The storage node verifies the digital signature of the transaction request in the simulated execution block. After verifying the authenticity of the lightweight node identity, the storage node calls the local smart contract, and the contract drives the execution engine of the storage node to execute the transaction.
[0056] Step 302: The input of the contract execution is the state data read set {state read} and transaction request tx i , the output is a write set {state write} and status code. read}Read the state data key value that is dependent on the transaction request, {state write} is the status data key value of the transaction update. The status code records the status of the transaction execution result, including: failure, update, deletion, and addition. The status code is also recorded in the blockchain ledger, identifying the way the current transaction updates the data. For the deletion operation in the transaction, the corresponding status data is marked as the delete status. If the status data is updated multiple times, the last status shall prevail.
[0057] During the execution of transaction tx, a read-write set {state read} and {state write}, read data is represented by the subscript read, and modify data is represented by the subscript write. The block assembles several transactions tx to generate a block. For each block, a vector commitment tree with transactions as leaves will be calculated. The state tree is used to establish a data index for the state data under the blockchain account. The state tree in the present invention is a vector commitment tree, and its structure is the same as the vector commitment tree of the block.
[0058] Step 303: The storage node establishes a vector commitment tree for the executed block.
[0059] Lightweight nodes cannot fully trust storage nodes. In order to ensure the integrity of stored data, lightweight nodes act as verifiers. Storage nodes correspond to provers. The prover is responsible for verifying whether a piece of data of the prover is consistent with its own. The present invention uses vector commitment values as evidence. The storage node provides testimony, and the lightweight node uses this information to recalculate and check whether it is consistent with its own evidence. The testimony is as follows: exec express:
[0060] Result exec = <tx i ,{state read},{state write},φ sig >
[0061] Among them, {state read},{state write} are respectively transaction tx i The state data read set and write set, φ sig Indicates the storage node for transaction tx i The proof is obtained based on the vector commitment tree.
[0062] The meanings of the parameters involved in the vector commitment calculation of the present invention are as described in Table 1.
[0063] Table 1 Parameter meaning
[0064] parameter describe k Safety parameters pp Public parameters C Vector Commitment Value aux Auxiliary Information q <![CDATA[Magnitude of the vector (m1,…,m q )]]> <![CDATA[m i ]]> <![CDATA[The i-th value of the vector commitment calculation parameter (m1, …, m q )]]> <![CDATA[C old ]]> Old vector commitment value <![CDATA[λ i ]]> <![CDATA[m i Proof of value]]> C′ New vector commitment value U Update information <![CDATA[λ′ j ]]> <![CDATA[Message m j Update proof value corresponding to the position]]>
[0065] First, generate the public parameter pp←VC.KenGen(1 k ,q), where ← is the assignment symbol, 1 k Represents a sequence of k 0,1 strings, the security parameter k is a randomly assigned value, VC.KenGen is the primitive of vector commitment, and here represents the process of calculating the public parameters. The specific calculation method of the public parameters is as follows:
[0066] set up and are two multiplicative cyclic groups, both of which have a prime order p. In addition, they satisfy the bilinear mapping e: definition A random generator from the cyclic group of integers Randomly pick values z1,z2,…,z q , calculate the intermediate parameters Where i=1,2,…,q. Meanwhile, set the intermediate parameters Where i,j=1,2,…,q,i≠j. Then generate the public parameter set pp={g,{h i} i∈[1,q] ,{h i,j} i,j∈[1,q],i≠j}.
[0067] Second, a vector commitment tree is recursively constructed for the ordered transactions in the execution block.
[0068] In the vector commitment tree, the parent node is the vector commitment value of its child nodes, and a transaction is entered on the leaf node to calculate the commitment value. Calculate the vector commitment tree nth i The node with branch number i in the layer The hash is used to calculate the summary value m1 of transaction tx1, that is, m1 = hash(tx1). aux is additional auxiliary information. It is based on the computational primitive Com pp Calculated, it can be expressed as: (C,aux)←VC.Com pp (m1,…,m q ).VC.Com pp Computational primitive Com pp , represents the corresponding calculation process, and the corresponding specific calculation process is expressed as follows:
[0069] Where C is the vector commitment value.
[0070] like Figure 4 As shown in the figure, a vector commitment tree is established. Each leaf node corresponds to a transaction, and the leaf node stores state data. In a block, a group of q transactions is calculated to generate a vector commitment value C. A summary is calculated for each transaction, and the summary of q transactions is represented as m1, m2…, m q ; q is also the number of branches of the tree. In the figure, prefix represents the prefix index of the key. Each branch of the tree represents a different key prefix. Starting from the root of the vector commitment tree, the transaction request tx can be located through the key prefix index. Generally, the key can be calculated using a hash function.
[0071] Figure 4 In the example, the parent node uses the child node value as input to calculate Com pp (m1,…,m q ), generating a vector commitment value, C in the figure i,j Represents the node numbered j at the i-th level branch in the vector commitment tree.
[0072] During the verification process, such as verifying transaction tx n, the storage node sends its vector commitment value φ to the lightweight node. φ is all the commitment values on a path, such as Figure 4 (C 0,1 ,C i,q ,C n-1,q ), the lightweight node verifies the data based on the vector commitment value. If the transaction involves modifying the state value, the vector commitment value will be updated, so there will be operations to update the commitment value and update the proof.
[0073] Step 304: The storage node uses {state write} and {state read}The state data key value in the vector commitment value C is calculated, and these short vector commitment values C replace the hash values in the original Merkle tree nodes.
[0074] Calculate {state read The commitment value C in} read To: Call the proof generation function to calculate pp←VC.KeyGen(1 k ,q),(C read ,aux)←VC.Com pp ({state read}), the subscript read indicates the input value type; we can prove that φ read ={C read},φ read Represents all vector commitment values on the path from tree subnodes (transactions) to the root node.
[0075] Similarly, we can calculate {state write All the commitment values φ in} write .
[0076] Step 305: Finally, the storage node uses the private key pair 〈φ read ,C old ,φ write 〉Signature generation proof φ sig , returns the execution result to multiple lightweight nodes exec , indicating that the transaction is executed correctly. Only when the verification signature endorsement of more than half of the lightweight nodes is received, the storage node is considered to have executed the transaction correctly and formally submitted the block to the blockchain account book. old Represents the root value of the vector commitment tree before the transaction is executed.
[0077] like Figure 5 As shown, the storage node verifies the received blocks, calls the smart contract to execute the transaction, then calculates the commitment value, updates the status data, and publishes the execution results to the lightweight node.
[0078] Step 4: The lightweight node verifies the execution result.
[0079] Step 401: The storage node returns the transaction execution result f({tx i})→result exec , the lightweight node verifies the transaction execution results, mainly checking whether the digital signature in the transaction is legal, whether the calculation result is correct, and whether the storage status data has been tampered with. The verification information on the vector commitment tree is equivalent to a snapshot of a blockchain account database. The snapshot of the current account historical data corresponds to the root node C in the commitment tree. root f represents the execution model of the storage node, for the input transaction tx i Execute and return the execution result result exec .
[0080] Step 402: The lightweight node executes the verification function verify(λ,result exec ,φ old ), φ old Represents the vector commitment value on the vector commitment tree path in the lightweight node. The lightweight node verifies {φ based on the local vector commitment tree read The vector commitment value in} and the locally saved vector commitment value φ old Is it consistent? Recalculate {state write Verify that it is executed correctly.
[0081]
[0082] e(x,y)=g x*y
[0083]
[0084]
[0085] Among them, λ i is m i The proof value is used to verify the result exec Whether the committed value of the midpoint vector is correct. Determine whether both sides of the equation in the third line above are equal. If they are equal, it means that the execution is correct and the verification passes. Otherwise, the verification fails.
[0086] Each lightweight node stores the latest K block status data locally, and generates a vector commitment tree for each block. The lightweight node will update the local vector commitment tree according to the execution result information returned by the storage node. By calculating a vector commitment tree for each block, the storage data of the lightweight node is reduced, while ensuring that the data can be verified on the storage node, ensuring the security of the data.
[0087] Step 403: After the verification is successful, the lightweight node returns the verification success signature to the storage node and updates the verification information in the local vector commitment tree. i 、node j Represents a leaf node in the vector commitment tree, and updates the vector commitment value as follows:
[0088] (C′,U)←Update PP (C,node j ,node i ,{state write} i ,i),
[0089]
[0090] Among them, C′ represents the new vector commitment value, U represents the update information, and m′ and m represent the summaries of the state data after and before the update, respectively.
[0091] Step 404: To support the minimization of the storage load of lightweight nodes, lightweight nodes are not required to store the fully verified state data, and only the state data of the past K blocks and the vector commitment tree verification information need to be maintained. The vector commitment tree and block data content of the past K blocks are updated based on the sliding window. Upon receiving the execution result of the storage node, the past K+1th block is cleared from the window, and the state data and verification information beyond the window range are also pruned and deleted from the tree.
[0092] like Figure 6 As shown in the figure, the vector commitment tree update process starts with checking the new block transaction. If a conflict with other transactions is detected, the transaction is skipped and the next new transaction is obtained. Otherwise, according to the write set {state write}Calculate the transaction tx vector commitment value C tx , locate the insertion position in the vector commitment tree according to the Key prefix, check whether it is new account data, if so, update the C of the vector commitment tree node tx and the state value under the account, otherwise, insert a new leaf node of the vector commitment tree, calculate the root value of the vector commitment tree of the new block, and update the block index.
[0093] Step 405: The lightweight node feeds back the execution result of the transaction to the IoT terminal device and attaches its own signature to the result to facilitate the terminal device to check the authenticity of the execution result.
[0094] Step 5: Unload storage node data, such as Figure 7 As shown, the method includes the following sub-steps.
[0095] Step 501: The storage node starts the data unloading protocol. When the locally stored blockchain ledger data exceeds the protocol threshold, the past n block files and their status data are packaged into a data shard Bucket, and an information mapping table Map of the Bucket is established.
[0096] Step 502: Generate a public key and a private key pair through the AES encryption algorithm, save the current password pair locally, encrypt the Bucket data file using the encryption algorithm, and send the data shard Bucket to IPFS for distributed storage.
[0097] Step 503: IPFS first checks the identity of the data uploader, stores the encrypted text after verification, and creates an IPFS object. After the data is successfully stored, IPFS will return the data hash string for IPFS content addressing access.
[0098] Step 504: Update the data hash table based on the hash string. The data mapping table Map uses the Bucket name as the index, and the data value is the IPFS access path, block number and transaction ID.
[0099] Step 505: The storage node queries the Bucket access path through the mapping table, interacts with IPFS to trigger a download request, and decrypts the Bucket using the homomorphic decryption algorithm.
[0100] Except for the technical features described in the specification, all of them are known technologies to those skilled in the art. The present invention omits the description of known components and known technologies to avoid redundancy and unnecessary limitation of the present invention. The implementation methods described in the above embodiments do not represent all implementation methods consistent with the present application. On the basis of the technical solution of the present invention, various modifications or variations that can be made by those skilled in the art without creative labor are still within the protection scope of the present invention.
Claims
1. A method for constructing a blockchain data storage extension model for the Internet of Things. It is characterized in that The steps include: Step 1) Establish a blockchain storage layered model, which includes a lightweight layer and a storage layer; the lightweight layer is responsible for collecting transaction data, reaching consensus on transactions, and verifying execution results; The storage layer is responsible for the extended storage of transaction history data and status data; Step 2) Build a lightweight node, including: (2.1) Based on the network structure of the Internet of Things, local nodes in the network partition belonging to the same geographical range are organized into a cluster with one master and multiple slaves, with the master node acting as a lightweight node; (2.2) The lightweight node collects transaction requests, including: the lightweight node collects transaction requests sent by IoT devices in the network partition where it is located, verifies whether the identity of the sender is legal, checks whether the address in the transaction request is legal, checks whether there is any replay behavior in the transaction, and adds the transaction requests that pass the check to the transaction pool of the lightweight node for cache; (2.3) Lightweight nodes conduct transaction consensus, including: if the transaction request volume in the transaction pool of the lightweight node reaches the maximum delay of the consensus protocol or the maximum transaction volume limit of the block, the lightweight node extracts the transaction ID from the local transaction pool, sorts the transaction requests in the block in chronological order according to the transaction ID and the consensus protocol, packages them into a consensus request list, and broadcasts them to other lightweight nodes; the lightweight node packages the transaction requests that have reached consensus, generates a simulated execution block, and sends it to the storage node; Step 3) Build a storage node, including: (3.1) Pre-set which physical nodes in the IoT are used as storage nodes through configuration files; (3.2) After receiving the simulated execution block, the storage node verifies the lightweight node identity and the digital signature of the transaction request in the block. After the verification is passed, the local smart contract is called to execute the transaction; the input of the smart contract is the state data read set and the transaction request tx i The output is the state data write set and the state code, the read set {state read }Record transaction tx i The state key value submitted in the write set {state write }Record transaction tx i Updated status key value, the status code records the transaction tx i The status of the execution result; (3.3) The storage node executes the ordered transactions in the block, and calculates the vector commitment value in groups of q transactions, and constructs a vector commitment tree; q is a positive integer; for transaction tx i , storage nodes use {state write } and {state read } in the state key value to calculate the vector commitment value and obtain the proof information φ write and φ read ; (3.4) The storage node uses the private key pair <φ read , C old ,φ write >Signature generation proof φ sig , returns the execution result to the lightweight node exec = <tx i ,{state read }, {state write },φ sig > Where C old Indicates that in transaction tx i Execute the root value of the vector commitment tree before; The storage node uploads the status data and status code of the execution block verified by the lightweight node to the blockchain for storage; Step 4) The lightweight node verifies the execution result, including: The lightweight node saves the latest state data and vector commitment tree in the most recent K executed blocks, verifies the data in the read set of the transaction based on the vector commitment tree of the corresponding block stored locally, and re-executes the transaction based on the read set to generate a new vector commitment value, verifies the write set of the transaction and the execution result of the storage node; when the verification passes, the lightweight node will update the local vector commitment tree and cache the latest state data; K is a positive integer; Step 5) The storage node offloads the backup of blockchain data through the P2P distributed data storage system.
2. The method according to claim 1, It is characterized in that In the above step (2.3), after receiving the consensus request, other lightweight nodes in the network first verify whether the identity certificate of the requester is legal, and verify whether the transaction sequence number and creation timestamp in the consensus request are within the validity period. When the verification is successful, a consensus success response message is returned to the lightweight node that issued the consensus request, and its own signature is attached to the response message.
3. The method according to claim 1, It is characterized in that In the step (3.3), the storage node calculates a vector commitment tree for each execution block, the number of branches of the vector commitment tree is q, each branch represents a different key prefix, and the key represents the key of the state data; each leaf node corresponds to a transaction, and the summary of each transaction is first calculated, and then the vector commitment value is calculated based on the summary; the storage node recursively constructs the vector commitment tree, and the parent node is the vector commitment value of its child node.
4. The method according to claim 1, It is characterized in that In step 4, the lightweight node maintains the status data and vector commitment tree of the past K execution blocks based on the sliding window. After receiving the execution result of the storage node, the past K+1 execution block is cleared from the window, and the status data and vector commitment tree verification information of the execution blocks beyond the window range are deleted.
5. The method according to claim 1, It is characterized in that In step 5, the storage node slices the historical data of the blockchain, symmetrically encrypts the slices, stores the encrypted data in a distributed P2P storage system, and establishes a routing table for the data of each slice.
