A blockchain system implementation method for updating IoT data based on bsdiff
By adopting a blockchain system based on the bsdiff differential algorithm in the Internet of Things system to generate and process reference packets, differential packets and compensation packets, the problems of difficult and tamper-evident data transmission and storage in the Internet of Things are solved, and efficient and secure data storage and transmission are achieved.
Patent Information
- Application Number
- CN202310564293.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-18
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2043-05-18
AI Technical Summary
IoT data transmission and storage are difficult, and there are security issues such as easy tampering. Traditional blockchain networks are not suitable for IoT data storage. The similarity data uploaded by IoT devices each time leads to a waste of storage space.
A blockchain system based on the bsdiff differential algorithm is used to process data packets through IoT sensing nodes to generate benchmark packets, bsdiff differential packets and bsdiff compensation packets. The blockchain network is used for data storage and verification to ensure the security and integrity of the data.
It effectively reduces the space requirements for IoT data transmission and storage, improves data transmission speed, ensures data security and non-tamperability, and solves the problem of waste of IoT data storage space.
Smart Images

Figure CN116436694B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet of Things data storage, and in particular to a blockchain system implementation method for updating Internet of Things data based on bsdiff. Background Art
[0002] With the rapid development of the Internet and embedded devices, more and more devices are being connected via the Internet to form specialized IoTs. A common example is the Internet of Vehicles (IoV). In-vehicle devices utilize wireless communication technologies to effectively utilize all vehicle dynamic information on the information network platform, providing various functional services during vehicle operation. However, due to the continuous expansion of IoT networks and the continuous improvement of IoT device performance, the amount of data collected by IoT is also increasing. This makes the transmission and storage of IoT data difficult, and there are security issues such as tampering during the data transmission and storage process. Therefore, how to securely and efficiently store such massive amounts of IoT data has become particularly critical.
[0003] Traditionally, IoT data is stored in a centralized database, where data collected from various connected devices is transferred to a centralized database for storage. This approach cannot guarantee data security and is susceptible to tampering. It also hinders the circulation of IoT data, preventing trusted third parties from fully and effectively utilizing the collected IoT data.
[0004] Blockchain is a decentralized, distributed database technology commonly used to record transaction data and electronic assets. It consists of multiple blocks and uses cryptographic methods to ensure data security and transparency. Each block in a blockchain can contain one or more transaction data, as well as a hash of the previous block. Tampering with the transaction data in a particular block requires tampering with all subsequent blocks, which consumes significant resources and time. This ensures the blockchain's immutability. Each node in a blockchain network stores complete data, organized in a chain-like structure. No single node can independently record a block; it must be broadcast and all nodes must reach consensus before it can be added to the blockchain. Therefore, data or information stored in a blockchain possesses the advantages of being unforgeable, traceable, traceable, transparent, and collectively maintained.
[0005] However, traditional blockchain networks are not suitable for storing IoT data. Due to the sheer volume of IoT data, storing it directly on the blockchain is not a design principle. Therefore, IoT data must be stored in multiple centralized data storage nodes, with the corresponding index information stored on the blockchain. However, each data uploaded by an IoT device contains a large amount of repetitive and unchanging data. If complete and similar IoT data were transmitted to multiple data storage nodes for storage, transmission time would be long and storage space would be wasted. Furthermore, IoT data stored in centralized data storage nodes is susceptible to tampering and theft, among other security issues.
[0006] The Bsdiff (Binary software differences or Bytewise subtraction differences) differential algorithm is an excellent cross-platform differential algorithm developed by Conlin Percival. Compared to other differential algorithms, such as Exediff and Xdelta, it still has relatively excellent differential and compression efficiency. Unlike traditional differential algorithms based on copying and insertion operations, Bsdiff introduces the concept of diff strings to make the generated differential packets smaller. The Bsdiff differential algorithm can generate differential files by comparing the similarities and differences between new and old data packets, and compress them by calling the Bzip2 compression algorithm to produce differential packets. The differential packets are much smaller than the size of the complete new data packet, which is conducive to remote transmission and storage. The new data packet can also be easily restored based on the differential packet and the old data packet.
[0007] The process of generating differential packets using Bsdiff can be simply divided into the following three steps: (1) Generate a dictionary for all substrings in the old data packet; (2) Use the generated dictionary to compare the old and new data packets to generate a diff string and an extra string; (3) Use Bzip2 to compress the diff string, extra string, and corresponding control words into a compressed packet. The time required for Bsdiff to generate differential packets is mainly related to the Faster suffixsorting algorithm used by Bsdiff (i.e., forming a dictionary for all substrings in the old data packet). Its time complexity is O(nlog n), where n is the byte size of the old data packet. Summary of the Invention
[0008] The present invention proposes a blockchain system implementation method for updating IoT data based on bsdiff, so as to solve the problems of storage space waste of similarity data uploaded by IoT devices each time and IoT data stored in data storage nodes being easily tampered with and stolen.
[0009] The technical solution adopted by the present invention is: comprising the following steps:
[0010] S1: The IoT sensing node processes the collected IoT data packets and obtains the data packets to be uploaded and the index information of the data packets, where the data packets can be one of the three types: reference packets, bsdiff difference packets and bsdiff compensation packets;
[0011] S2: The IoT sensing node encrypts the index information of the data packet and transmits it to the blockchain node in the nearest blockchain network;
[0012] S3: The blockchain node receives the data packet index information from the IoT sensing node, decrypts the index information, and verifies it. After verification, it waits to receive data packet storage certificates from multiple bsdiff data storage nodes contained in the index information.
[0013] S4: The IoT sensing node transmits the data packet to multiple bsdiff data storage nodes in the bsdiff data storage network for storage;
[0014] S5: The bsdiff data storage node receives the data packet from the IoT sensing node and verifies it. After the verification is passed, the data packet is processed accordingly and stored in the corresponding location. Then, a data packet storage certificate is sent to the corresponding blockchain node to inform the blockchain node that the data packet has been correctly stored.
[0015] S6: The blockchain node uses the public key of the corresponding bsdiff data storage node to decrypt and verify the received data packet storage certificate. The blockchain node can only broadcast the index information to the blockchain network after receiving the data packet storage certificates from all bsdiff data storage nodes included in the index information;
[0016] S7: Each blockchain node calls the smart contract to process the index information and then executes the PoW algorithm. That is, each blockchain node continuously calculates a hash value related to the index information until the hash value calculated by a blockchain node meets the difficulty specified by the PoW algorithm. In this case, the blockchain node is considered to have completed the PoW algorithm first.
[0017] S8: The blockchain node that first completes the PoW algorithm packages the index information into a candidate block and broadcasts it within the blockchain network. After reaching a consensus within the blockchain network, each blockchain node receives the broadcasted candidate block and determines whether the candidate block meets the difficulty specified by the PoW algorithm. If so, all blockchain nodes add the candidate block to their own blockchain, that is, the candidate block is put on the chain.
[0018] Furthermore, step S1 includes the following steps:
[0019] First, the following definitions are given:
[0020] The IoT sensing network is composed of the multiple IoT sensing nodes. The IoT sensing nodes are used to process collected IoT data packets to obtain data packets that need to be uploaded and index information of the data packets. The data packets are divided into the following three types: reference packets, bsdiff difference packets, and bsdiff compensation packets. The IoT sensing nodes transmit the index information of the data packets to a blockchain node in a nearby blockchain network, and transmit the data packets to multiple bsdiff data storage nodes in the bsdiff data storage network for storage.
[0021] The bsdiff data storage network is composed of multiple bsdiff data storage nodes. The bsdiff data storage nodes are used to receive and verify data packets from IoT sensing nodes. After verification, the bsdiff data packets are processed and stored in the corresponding location. The bsdiff data packet storage certificate is then sent to the corresponding blockchain node to inform the blockchain node that the data packet has been correctly stored. In particular, multiple data packets sent from the same IoT sensing node will be stored in the form of reference packet, bsdiff difference packet, bsdiff compensation packet, bsdiff difference packet, bsdiff compensation packet...
[0022] The blockchain network is composed of multiple blockchain nodes, which are used to receive data packet index information transmitted by the IoT sensing node and verify the index information. After verification, if the data packet storage certificate is received from multiple bsdiff data storage nodes contained in the index information, the index information is broadcast to the blockchain network. Each blockchain node calls the smart contract to process the index information and then executes the PoW algorithm. The blockchain node that completes the PoW algorithm first packages the index information into a block and broadcasts it within the blockchain network. After consensus is reached within the blockchain network, all blockchain nodes add the block to their own blockchain, that is, the block is put on the chain.
[0023] D IOT (N) represents the IoT data packet collected by the IoT sensing node for the Nth time, D base (N) represents the benchmark package generated at the Nth time, D basestor Denotes the reference package stored in the IoT sensing node, D diff (N) represents the bsdiff difference packet generated for the Nth time, D diffstor Indicates the bsdiff differential packet stored in the IoT sensing node, D patch (N) represents the bsdiff compensation packet generated at the Nth time, D(N) represents the data packet uploaded at the Nth time, D icbase(N) indicates the Nth time that the Fastersuffix sorting algorithm is used to sort the benchmark package D basestor The generated dictionary, D icbasestor The dictionary representing the reference packets stored in the IoT sensing node, D icdiff (N) indicates the Nth time that the Faster suffix sorting algorithm is used to sort the bsdiff difference packet D. diffstor The generated dictionary, D icdiffstor A dictionary representing the bsdiff difference packets stored in IoT sensing nodes;
[0024] S1-1: If the IoT sensing node is uploading a data packet for the first time, that is, N=1, then let D(N)=D base (N)=D IOT (N) and generate the index information of D(N), and at the same time base (N) is stored in the node, that is, let D basestor =D base (N), in addition to D basestor Generate dictionary D icbase (N), and D icbase (N) is stored in the node, that is, let D icbasestor =D icbase (N), S1 ends here and executes step S2; otherwise, execute S1-2;
[0025] S1-2: Using D icbasestor , for D basestor and D IOT (N) Use the bsdiff algorithm to generate a total byte size much smaller than D IOT (N)D diff (N), judge D diff Is the byte size of (N) less than the set threshold? If so, execute S1-3; otherwise, discard the generated D diff (N), let D(N)=D base (N)=D IOT (N) and generate the index information of D(N), and use D base (N) Replace D basestor Stored in the node, let D basestor =D base (N), in addition to D basestor Generate dictionary D icbase (N), and use D icbase (N) Replace D icbasestor Stored in the node, let D icbasestor =D icbase (N), S1 ends here, and step S2 is executed;
[0026] S1-3: Determine whether a bsdiff difference packet D has been stored in the IoT sensing node diffstor If yes, execute S1-4, otherwise, set D(N)=D diff (N) and generate the index information of D(N), and at the same time diff (N) is stored in the IoT sensing node, that is, D diffstor =D diff (N), in addition to D diffstor Generate dictionary D icdiff (N), and D icdiff (N) is stored in the node, that is, let D icdiffstor =D icdiff (N), S1 ends here and goes to step S2;
[0027] S1-4: Using D icdiffstor , for D diffstor and D diff (N) Use the bsdiff algorithm to generate a total byte size less than D diff (N)D patch (N), let D(N)=D patch (N) and generate the index information of D(N), and delete the bsdiff difference packet D originally stored in the node diffstor and dictionary D icdiffstor , S1 ends here, and step S2 is executed;
[0028] From the above, we can see that there is a byte size: D base >>D diff >D patch , and by utilizing D icbasestor and D icdiffstor , which greatly shortens the time required for bsdiff to generate differential packets and compensation packets, and improves the efficiency of uploading IoT data.
[0029] Furthermore, the index information IndexInf in step S2 includes the address of the IoT sensing node, the addresses of multiple bsdiff data storage nodes for storing the data packet uploaded this time, the MD5 value of the data packet, the timestamp and other information. The IoT sensing node calculates the hash value of IndexInf and encrypts the hash value with its private key to obtain the digital signature Signature IndexInf , and finally (IndexInf, Signature IndexInf ) to transmit the index information to the blockchain node.
[0030] Furthermore, step S3 includes the following steps:
[0031] S3-1: Blockchain node receives (IndexInf, Signature IndexInf ) and use the public key of the IoT sensing node to sign IndexInf Decrypt to get Hash IndexInf ;
[0032] S3-2: Calculate the Hash value of IndexInf and compare it with Hash IndexInf If the two are the same, it means that this is the correct and untampered index information from the legitimate IoT perception node, and the node waits to receive the data packet storage proof from multiple bsdiff data storage nodes contained in the index information; otherwise, the IoT perception node is considered untrustworthy and the message is broadcast on the blockchain network.
[0033] Furthermore, the data packets D(N) uploaded in step S4 are divided into three types: when D(N)=D base (N), it indicates that the data packet type is a reference packet; when D(N)=D diff (N), it indicates that the data packet type is bsdiff differential packet, and D(N) contains D basestor The hash value of D basestor unique identifier information; when D(N)=D patch (N), it indicates that the data packet type is bsdiff compensation packet, and D(N) additionally contains D basestor and D diffstor The hash value of D basestor and D diffstor The IoT sensing node calculates the Hash value of D(N) and encrypts the Hash value with its private key to obtain the digital signature. D , and finally (D(N), Signature D ) to transmit D(N) to multiple bsdiff data storage nodes.
[0034] Furthermore, step S5 includes the following steps:
[0035] First, the following definitions are given:
[0036] Addr represents the IoT sensing node address field in D(N), Type represents the data packet type field in D(N), Uid represents the unique identifier field in D(N), Ts represents the timestamp field in D(N), K pub Indicates the public key of the bsdiff data storage node, K pri Indicates the private key of the bsdiff data storage node, K symaddrIndicates the symmetric key used by the bsdiff data storage node to encrypt and decrypt data packets sent by the IoT sensing node with address Addr;
[0037] S5-1: bsidff data storage node receives (D(N), Signature D ) and use the public key of the IoT sensing node to sign D Decrypt to get Hash D ;
[0038] S5-2: Calculate the Hash value of D(N) and compare it with Hash D Compare and if the two are the same, it means that this is a correct data packet that has not been tampered with from a legitimate IoT sensing node;
[0039] S5-3: If D(N)=D base (N), that is, Type is the base packet type, then the remaining part of D(N) excluding Addr, Type, Uid and Ts plus Uid is calculated using K symaddr After encryption, it is stored in the bsdiff data storage node. That is, the data packet format stored in the node is Addr+Type+Uid+Ts+K symaddr (D(N)-Addr-Type-Ts), in particular, the bsdiff data storage node uses K pub K symaddr Encrypt and keep it, and use K when you need to use it pri Decryption gets K symaddr ; If D(N)=D diff (N), that is, Type is bsdiff differential packet type, then D(N) is directly stored. In particular, D(N) contains D basestor Uid, that is, D basestor Hash value; if D(N)=D patch (N), that is, Type is the bsdiff compensation packet type, then D(N) is directly stored. In particular, D(N) contains D basestor and D diffstor Uid, that is, D basestor and D diffstor Hash value;
[0040] S5-4: The bsdiff data storage node calculates the hash value of its address bsaddr and encrypts the hash value with its private key to obtain the data packet storage proof Signature bsaddr , and then send (bsaddr,Signature bsaddr), in order to inform the blockchain node that the data packet has been correctly stored; otherwise, the IoT perception node is considered untrustworthy and the message is broadcast on the bsdiff data storage network.
[0041] Furthermore, step S6 includes the following steps:
[0042] S6-1: Blockchain node waits for receiving (bsaddr, Signature bsaddr ) and use the public key of the corresponding bsdiff data storage node to sign bsaddr Decrypt to get Hash bsaddr ;
[0043] S6-2: Calculate the Hash value of bsadrr and compare it with Hash bsaddr Compare them. If the two are the same, it means that this is an untampered and correct data packet storage certificate from a legitimate bsdiff data storage node; otherwise, the data packet storage certificate is considered unreliable and discarded.
[0044] S6-3: Determine whether the blockchain node has received data packet storage certificates from all bsdiff data storage nodes included in the index information. If so, broadcast the index information to the blockchain network and S6 ends; otherwise, execute S6-1.
[0045] Furthermore, step S7 includes the following steps:
[0046] S7-1: Each blockchain node receives the index information and calls the smart contract to generate a candidate block based on the index information. The candidate block consists of a block header and a block body. The block header contains the hash value, timestamp, and other information of the last block in the blockchain, while the block body contains the index information.
[0047] S7-2: Each blockchain node executes the PoW algorithm, that is, each blockchain node calculates the hash value SHA-256, the hash value of the candidate block header information + the index information + the random number Nonce. The "candidate block header information" and "index information hash value" are fixed. The blockchain node must continuously change the value of the random number Nonce until the calculated hash value meets the difficulty specified by the PoW algorithm;
[0048] S7-3: If the hash value calculated by a blockchain node first meets the difficulty specified by the PoW algorithm, the blockchain node is considered to have completed the PoW algorithm first;
[0049] In particular, the difficulty specified in S7-2 that meets the requirements of the PoW algorithm means that the calculated Hash value must satisfy the requirement that the first N numbers are 0. For example, the difficulty specified in PoW is that the first 6 numbers of the calculated Hash value must be 0.
[0050] Furthermore, step S8 includes the following steps:
[0051] S8-1: The blockchain node that first completes the PoW algorithm adds the random number Nonce that meets the difficulty of the PoW algorithm to the block header of the candidate block and broadcasts the candidate block within the blockchain network;
[0052] S8-2: After receiving the candidate block, other blockchain nodes in the blockchain network calculate SHA-256, the hash value of the candidate block header information + index information + the random number Nonce in the candidate block header, and determine whether the calculated hash value meets the difficulty specified by the PoW algorithm. If so, all blockchain nodes will add the candidate block to their own blockchain, that is, the candidate block will be put on the chain.
[0053] The beneficial effects of the present invention are:
[0054] (1) Combining the bsdiff differential algorithm to process the collected IoT data can greatly reduce the byte size of the data packet required to be uploaded by the IoT sensing node, improve the data transmission speed, and solve the problem of storage space waste of similarity data uploaded by IoT devices each time. That is, by introducing three data packets: baseline packet, bsdiff differential packet and bsdiff compensation packet, the storage space of the bsdiff data storage node is greatly saved.
[0055] (2) By storing the dictionary generated by the Faster suffix sorting algorithm for the corresponding baseline packet and bsdiff differential packet in the IoT sensing node, the time for generating bsdiff differential packets and compensation packets using the bsdiff differential algorithm can be greatly saved, thereby further improving the efficiency of uploading IoT data to the bsdiff data storage node.
[0056] (3) By utilizing the relationship and characteristics among the reference package, bsdiff differential package and bsdiff compensation package, the reference package can be further encrypted at the bsdiff data storage node to ensure that all IoT data stored in the bsdiff data storage node are not easily tampered with or stolen. The specific analysis is as follows: 1) Encrypting the reference package can ensure that the reference package is not easily tampered with or stolen; 2) Since both the bsdiff differential package and the bsdiff compensation package contain the unique identifier of the corresponding reference package, that is, the hash value of the reference package, if you want to tamper with the differential package or the compensation package, you must first tamper with the reference package, which is almost impossible; 3) If the bsdiff differential package or the bsdiff compensation package is arbitrarily modified, an error will occur when the bsdiff differential package or the bsdiff compensation package is used to restore the IoT data packet, and it can be determined that the differential package or the compensation package has been arbitrarily modified; 4) If the bsdiff differential package or the bsdiff compensation package is stolen, since the decrypted reference package cannot be obtained, the original IoT data cannot be restored through the differential package or the compensation package. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 This is a schematic diagram of the blockchain system structure for updating IoT data based on bsdiff in the present invention;
[0058] Figure 2 It is an execution flow chart of the present invention;
[0059] Figure 3 It is a flow chart of the method for generating data packets and index information thereof according to the present invention. DETAILED DESCRIPTION
[0060] like Figure 1 The figure shows a schematic diagram of the blockchain system structure for updating IoT data based on bsdiff provided by the present invention, including an IoT perception network, a bsdiff data storage network and a blockchain network.
[0061] The IoT sensing network is composed of multiple IoT sensing nodes, which are used to process collected IoT data packets to obtain data packets and index information of data packets that need to be uploaded. The data packets are divided into the following three types: baseline packets, bsdiff difference packets, and bsdiff compensation packets. The IoT sensing node transmits the index information of the data packet to a blockchain node in a nearby blockchain network, and transmits the data packet to multiple bsdiff data storage nodes in the bsdiff data storage network for storage;
[0062] The bsdiff data storage network consists of multiple bsdiff data storage nodes, each of which receives and verifies data packets from IoT sensing nodes. Once verified, the bsdiff data storage nodes process the data packets and store them in the appropriate location. They then send a data packet storage certificate to the corresponding blockchain node, informing the blockchain node that the data packet has been correctly stored. Specifically, multiple data packets sent from the same IoT sensing node are stored in the form of (baseline packet, bsdiff difference packet, bsdiff compensation packet, bsdiff difference packet, bsdiff compensation packet, etc.);
[0063] The blockchain network is composed of multiple blockchain nodes, which are used to receive data packet index information transmitted by the IoT sensing node and verify the index information. After the verification is passed, if the data packet storage certificate is received from multiple bsdiff data storage nodes contained in the index information, the index information is broadcast to the blockchain network. Each blockchain node calls the smart contract to process the index information and then executes the PoW algorithm. The blockchain node that completes the PoW algorithm first packages the index information into a block and broadcasts it within the blockchain network. After consensus is reached within the blockchain network, all blockchain nodes add the block to their own blockchain, that is, the block is put on the chain.
[0064] The implementation method of blockchain system based on bsdiff to update IoT data, such as Figure 2 As shown, the following steps are included:
[0065] S1: The IoT sensing node processes the collected IoT data packets and obtains the data packets to be uploaded and the index information of the data packets. The data packets can be three types: reference packets, bsdiff difference packets and bsdiff compensation packets.
[0066] S2: The IoT sensing node encrypts the index information of the data packet and transmits it to the blockchain node in the nearest blockchain network;
[0067] S3: The blockchain node receives the data packet index information from the IoT sensing node, decrypts the index information, and verifies it. After verification, it waits to receive data packet storage certificates from multiple bsdiff data storage nodes contained in the index information.
[0068] S4: The IoT sensing node transmits the data packet to multiple bsdiff data storage nodes in the bsdiff data storage network for storage;
[0069] S5: The bsdiff data storage node receives the data packet from the IoT sensing node and verifies it. After the verification is passed, the data packet is processed accordingly and stored in the corresponding location. Then, a data packet storage certificate is sent to the corresponding blockchain node to inform the blockchain node that the data packet has been correctly stored.
[0070] S6: The blockchain node uses the public key of the corresponding bsdiff data storage node to decrypt and verify the received data packet storage certificate. The blockchain node can only broadcast the index information to the blockchain network after receiving the data packet storage certificates from all bsdiff data storage nodes included in the index information;
[0071] S7: Each blockchain node calls the smart contract to process the index information and then executes the PoW algorithm. That is, each blockchain node continuously calculates a hash value related to the index information until the hash value calculated by a blockchain node meets the difficulty specified by the PoW algorithm. In this case, the blockchain node is considered to have completed the PoW algorithm first.
[0072] S8: The blockchain node that first completes the PoW algorithm packages the index information into a candidate block and broadcasts it within the blockchain network. After reaching a consensus within the blockchain network, each blockchain node receives the broadcasted candidate block and determines whether the candidate block meets the difficulty specified by the PoW algorithm. If so, all blockchain nodes add the candidate block to their own blockchain, that is, the candidate block is put on the chain.
[0073] Furthermore, if Figure 3 As shown, step S1 includes the following steps:
[0074] First, the following definitions are given:
[0075] D IOT (N) represents the IoT data packet collected by the IoT sensing node for the Nth time, D base (N) represents the benchmark package generated at the Nth time, D basestor Denotes the reference package stored in the IoT sensing node, D diff (N) represents the bsdiff difference packet generated for the Nth time, D diffstor Indicates the bsdiff differential packet stored in the IoT sensing node, D patch (N) represents the bsdiff compensation packet generated at the Nth time, D(N) represents the data packet uploaded at the Nth time, D icbase (N) indicates the Nth time that the Fastersuffix sorting algorithm is used to sort the benchmark package D basestor The generated dictionary, D icbasestor The dictionary representing the reference packets stored in the IoT sensing node, Dicdiff (N) indicates the Nth time that the Faster suffix sorting algorithm is used to sort the bsdiff difference packet D. diffstor The generated dictionary, D icdiffstor A dictionary representing the bsdiff difference packets stored in IoT sensing nodes;
[0076] S1-1: If the IoT sensing node is uploading a data packet for the first time, that is, N=1, then let D(N)=D base (N)=D IOT (N) and generate the index information of D(N), and at the same time base (N) is stored in the node, that is, let D basestor =D base (N), in addition to D basestor Generate dictionary D icbase (N), and D icbase (N) is stored in the node, that is, let D icbasestor =D icbase (N), S1 ends here and executes S2; otherwise, execute S1-2;
[0077] S1-2: Using D icbasestor , for D basestor and D IOT (N) Use the bsdiff algorithm to generate a total byte size much smaller than D IOT (N)D diff (N). Judgment D diff Is the byte size of (N) less than the set threshold? If so, execute S1-3; otherwise, discard the generated D diff (N), let D(N)=D base (N)=D IOT (N) and generate the index information of D(N), and use D base (N) Replace D basestor Stored in the node, let D basestor =D base (N), in addition to D basestor Generate dictionary D icbase (N), and use D icbase (N) Replace D icbasestor Stored in the node, let D icbasestor =D icbase (N), S1 ends here and S2 is executed;
[0078] S1-3: Determine whether a bsdiff difference packet D has been stored in the IoT sensing node diffstor If yes, execute S1-4, otherwise, set D(N)=D diff(N) and generate the index information of D(N), and at the same time diff (N) is stored in the IoT sensing node, that is, D diffstor =D diff (N), in addition to D diffstor Generate dictionary D icdiff (N), and D icdiff (N) is stored in the node, that is, let D icdiffstor =D icdiff (N), S1 ends here and S2 is executed;
[0079] S1-4: Using D icdiffstor , for D diffstor and D diff (N) Use the bsdiff algorithm to generate a total byte size less than D diff (N)D patch (N), let D(N)=D patch (N) and generate the index information of D(N), and delete the bsdiff difference packet D originally stored in the node diffstor and dictionary D icdiffstor , S1 ends here and S2 is executed;
[0080] From the above, we can see that there is a byte size: D base >>D diff >D patch , and by utilizing D icbasestor and D icdiffstor , which greatly shortens the time required for bsdiff to generate differential packets and compensation packets, and improves the efficiency of uploading IoT data.
[0081] Furthermore, the index information IndexInf in step S2 includes the address of the IoT sensing node, the addresses of multiple bsdiff data storage nodes for storing the data packet uploaded this time, the MD5 value of the data packet, the timestamp and other information. The IoT sensing node calculates the hash value of IndexInf and encrypts the hash value with its private key to obtain the digital signature Signature IndexInf , and finally (IndexInf, Signature IndexInf ) to transmit the index information to the blockchain node.
[0082] Furthermore, step S3 includes the following steps:
[0083] S3-1: Blockchain node receives (IndexInf, Signature IndexInf ) and use the public key of the IoT sensing node to sign IndexInf Decrypt to get Hash IndexInf ;
[0084] S3-2: Calculate the Hash value of IndexInf and compare it with Hash IndexInf If the two are the same, it means that this is the correct and untampered index information from the legitimate IoT perception node, and the node waits to receive the data packet storage proof from multiple bsdiff data storage nodes contained in the index information; otherwise, the IoT perception node is considered untrustworthy and the message is broadcast on the blockchain network.
[0085] Furthermore, the data packets D(N) uploaded in step S4 are divided into three types: when D(N)=D base (N), it indicates that the data packet type is a reference packet; when D(N)=D diff (N), it indicates that the data packet type is bsdiff differential packet, and D(N) contains D basestor The hash value of D basestor unique identifier information; when D(N)=D patch (N), it indicates that the data packet type is a bsdiff compensation packet, and D(N) additionally contains D basestor and D diffstor The hash value of D basestor and D diffstor The IoT sensing node calculates the Hash value of D(N) and encrypts the Hash value with its private key to obtain the digital signature. D , and finally (D(N), Signature D ) to transmit D(N) to multiple bsdiff data storage nodes.
[0086] Furthermore, step S5 includes the following steps:
[0087] First, the following definitions are given:
[0088] Addr represents the IoT sensing node address field in D(N), Type represents the data packet type field in D(N), Uid represents the unique identifier field in D(N), Ts represents the timestamp field in D(N), K pub Indicates the public key of the bsdiff data storage node, K pri Indicates the private key of the bsdiff data storage node, K symaddr Indicates the symmetric key used by the bsdiff data storage node to encrypt and decrypt data packets sent by the IoT sensing node with address Addr;
[0089] S5-1: bsidff data storage node receives (D(N), Signature D) and use the public key of the IoT sensing node to sign D Decrypt to get Hash D ;
[0090] S5-2: Calculate the Hash value of D(N) and compare it with Hash D Compare and if the two are the same, it means that this is a correct data packet that has not been tampered with from a legitimate IoT sensing node;
[0091] S5-3: If D(N)=D base (N), that is, Type is the base packet type, then K is used for the remaining part of D(N) excluding Addr, Type, Uid and Ts. symaddr After encryption, it is stored in the bsdiff data storage node. That is, the data packet format stored in the node is Addr+Type+Uid+Ts+K symaddr (D(N)-Addr-Type-Uid-Ts), in particular, the bsdiff data storage node uses K pub K symaddr Encrypt and keep it, and use K when you need to use it pri Decryption gets K symaddr ; If D(N)=D diff (N), that is, Type is bsdiff differential packet type, then D(N) is directly stored. In particular, D(N) contains D basestor Uid, that is, D basestor Hash value; if D(N)=D patch (N), that is, Type is the bsdiff compensation packet type, then D(N) is directly stored. In particular, D(N) contains D basestor and D diffstor Uid, that is, D basestor and D diffstor Hash value;
[0092] S5-4: The bsdiff data storage node calculates the hash value of its address bsaddr and encrypts the hash value with its private key to obtain the data packet storage proof Signature bsaddr , and then send (bsaddr,Signature bsaddr ), in order to inform the blockchain node that the data packet has been correctly stored; otherwise, the IoT perception node is considered untrustworthy and the message is broadcast on the bsdiff data storage network.
[0093] In particular, due to the connections and characteristics between the baseline packet, bsdiff difference packet, and bsdiff compensation packet, further encryption of the baseline packet through S5-3 ensures that all IoT data stored in the bsdiff data storage node is resistant to tampering and theft. The specific analysis is as follows: 1) Encrypting the baseline packet ensures that the baseline packet is resistant to tampering and theft; 2) Because both the bsdiff difference packet and the bsdiff compensation packet contain the unique identifier of the corresponding baseline packet, namely the hash value of the baseline packet, tampering with the difference packet or the compensation packet requires tampering with the baseline packet first, which is almost impossible; 3) If the bsdiff difference packet or the bsdiff compensation packet is arbitrarily modified, an error will occur when using the bsdiff difference packet or the bsdiff compensation packet to restore the IoT data packet, indicating that the difference packet or the compensation packet has been arbitrarily modified; 4) If the bsdiff difference packet or the bsdiff compensation packet is stolen, the original IoT data cannot be restored from the difference packet or the compensation packet because the decrypted baseline packet cannot be obtained.
[0094] Furthermore, step S6 includes the following steps:
[0095] S6-1: Blockchain node waits for receiving (bsaddr, Signature bsaddr ) and use the public key of the corresponding bsdiff data storage node to sign bsaddr Decrypt to get Hash bsaddr ;
[0096] S6-2: Calculate the Hash value of bsadrr and compare it with Hash bsaddr Compare them. If the two are the same, it means that this is an untampered and correct data packet storage certificate from a legitimate bsdiff data storage node; otherwise, the data packet storage certificate is considered unreliable and discarded.
[0097] S6-3: Determine whether the blockchain node has received data packet storage certificates from all bsdiff data storage nodes included in the index information. If so, broadcast the index information to the blockchain network and S6 ends; otherwise, execute S6-1.
[0098] Furthermore, step S7 includes the following steps:
[0099] S7-1: Each blockchain node receives the index information and calls the smart contract to generate a candidate block based on the index information. The candidate block consists of a block header and a block body. The block header contains the hash value, timestamp, and other information of the last block in the blockchain, while the block body contains the index information.
[0100] S7-2: Each blockchain node executes the PoW algorithm, that is, each blockchain node calculates the hash value SHA-256 (candidate block header information + index information hash value + random number Nonce), where "candidate block header information" and "index information hash value" are fixed. The blockchain node must continuously change the value of the random number Nonce until the calculated hash value meets the difficulty specified by the PoW algorithm;
[0101] S7-3: If the hash value calculated by a blockchain node first meets the difficulty specified by the PoW algorithm, the blockchain node is considered to have completed the PoW algorithm first.
[0102] In particular, the difficulty specified in S7-2 that meets the requirements of the PoW algorithm means that the calculated Hash value must satisfy the requirement that the first N numbers are 0. For example, the difficulty specified in PoW is that the first 6 numbers of the calculated Hash value must be 0.
[0103] Furthermore, step S8 includes the following steps:
[0104] S8-1: The blockchain node that first completes the PoW algorithm adds the random number Nonce that meets the difficulty of the PoW algorithm to the block header of the candidate block and broadcasts the candidate block within the blockchain network;
[0105] S8-2: After receiving the candidate block, other blockchain nodes in the blockchain network calculate SHA-256 (candidate block header information + index information hash value + random number Nonce in the candidate block header) to determine whether the calculated hash value meets the difficulty specified by the PoW algorithm. If so, all blockchain nodes will add the candidate block to their own blockchains, that is, the candidate block will be put on the chain.
[0106] The present invention proposes a blockchain system implementation method for updating IoT data based on BSDiff, which saves IoT data storage space, is highly reliable, and has excellent security. By introducing a reference packet, a BSDiff difference packet, and a BSDiff compensation packet, the size of the data packet required to be uploaded by IoT sensing nodes each time can be greatly reduced, improving data transmission speed while also solving the problem of wasted storage space for similarity data uploaded by IoT devices each time. Furthermore, by introducing a dictionary of reference packets and BSDiff difference packets, the time required to generate BSDiff difference packets and compensation packets can be greatly shortened, further improving the efficiency of IoT data upload. Furthermore, by leveraging the connections and characteristics between the reference packet, BSDiff difference packet, and BSDiff compensation packet, the reference packet can be further encrypted at the data storage node to ensure that all IoT data stored therein is not easily tampered with or stolen.
[0107] The above is only an embodiment of the present invention and is not intended to limit the present invention. Any equivalent structure and process made by utilizing the contents of the present invention and the drawings and applied to other related fields shall be included in the protection scope of the present invention.
Claims
1. A blockchain system implementation method for updating IoT data based on bsdiff, characterized in that: The following steps are involved: S1: The IoT sensing node processes the collected IoT data packets and obtains the data packets to be uploaded and the index information of the data packets, where the data packets can be one of the three types: reference packets, bsdiff difference packets and bsdiff compensation packets; S2: The IoT sensing node encrypts the index information of the data packet and transmits it to the blockchain node in the nearest blockchain network; S3: The blockchain node receives the data packet index information from the IoT sensing node, decrypts the index information, and verifies it. After verification, it waits to receive data packet storage certificates from multiple bsdiff data storage nodes contained in the index information. S4: The IoT sensing node transmits the data packet to multiple bsdiff data storage nodes in the bsdiff data storage network for storage; S5: The bsdiff data storage node receives the data packet from the IoT sensing node and verifies it. After the verification is passed, the data packet is processed accordingly and stored in the corresponding location. Then, a data packet storage certificate is sent to the corresponding blockchain node to inform the blockchain node that the data packet has been correctly stored. S6: The blockchain node uses the public key of the corresponding bsdiff data storage node to decrypt and verify the received data packet storage certificate. The blockchain node can only broadcast the index information to the blockchain network after receiving the data packet storage certificates from all bsdiff data storage nodes included in the index information; S7: Each blockchain node calls the smart contract to process the index information and then executes the PoW algorithm. That is, each blockchain node continuously calculates a hash value related to the index information until the hash value calculated by a blockchain node meets the difficulty specified by the PoW algorithm. In this case, the blockchain node is considered to have completed the PoW algorithm first. S8: The blockchain node that first completes the PoW algorithm packages the index information into a candidate block and broadcasts it within the blockchain network. After reaching a consensus within the blockchain network, each blockchain node receives the broadcasted candidate block and determines whether the candidate block meets the difficulty specified by the PoW algorithm. If so, all blockchain nodes add the candidate block to their own blockchain, that is, the candidate block is put on the chain.
2. A blockchain system implementation method for updating Internet of Things data based on bsdiff according to claim 1, characterized in that: The step S1 comprises the following steps: First, the following definitions are given: The IoT sensing network is composed of the multiple IoT sensing nodes. The IoT sensing nodes are used to process collected IoT data packets to obtain data packets that need to be uploaded and index information of the data packets. The data packets are divided into the following three types: reference packets, bsdiff difference packets, and bsdiff compensation packets. The IoT sensing nodes transmit the index information of the data packets to a blockchain node in a nearby blockchain network, and transmit the data packets to multiple bsdiff data storage nodes in the bsdiff data storage network for storage. The bsdiff data storage network is composed of multiple bsdiff data storage nodes. The bsdiff data storage nodes are used to receive and verify data packets from IoT sensing nodes. After verification, the bsdiff data packets are processed and stored in the corresponding location. The bsdiff data packet storage certificate is then sent to the corresponding blockchain node to inform the blockchain node that the data packet has been correctly stored. In particular, multiple data packets sent from the same IoT sensing node will be stored in the form of reference packet, bsdiff difference packet, bsdiff compensation packet, bsdiff difference packet, bsdiff compensation packet... The blockchain network is composed of multiple blockchain nodes, which are used to receive data packet index information transmitted by the IoT sensing node and verify the index information. After verification, if the data packet storage certificate is received from multiple bsdiff data storage nodes contained in the index information, the index information is broadcast to the blockchain network. Each blockchain node calls the smart contract to process the index information and then executes the PoW algorithm. The blockchain node that completes the PoW algorithm first packages the index information into a block and broadcasts it within the blockchain network. After consensus is reached within the blockchain network, all blockchain nodes add the block to their own blockchain, that is, the block is put on the chain. D IOT (N) represents the IoT data packet collected by the IoT sensing node for the Nth time, D base (N) represents the benchmark package generated at the Nth time, D basestor Denotes the reference package stored in the IoT sensing node, D diff (N) represents the bsdiff difference packet generated for the Nth time, D diffstor Indicates the bsdiff differential packet stored in the IoT sensing node, D patch (N) represents the bsdiff compensation packet generated at the Nth time, D(N) represents the data packet uploaded at the Nth time, D icbase (N) indicates the Nth time the Faster suffixsorting algorithm is used to sort the benchmark package D. basestor The generated dictionary, D icbasestor The dictionary representing the reference packets stored in the IoT sensing node, D icdiff (N) indicates the Nth time that the Faster suffix sorting algorithm is used to sort the bsdiff difference packet D. diffstor The generated dictionary, D icdiffstor A dictionary representing the bsdiff difference packets stored in IoT sensing nodes; S1-1: If the IoT sensing node is uploading a data packet for the first time, that is, N=1, then let D(N)=D base (N)=D IOT (N) and generate the index information of D(N), and at the same time base (N) is stored in the node, that is, let D basestor =D base (N), in addition to D basestor Generate dictionary D icbase (N), and D icbase (N) is stored in the node, that is, let D icbasestor =D icbase (N), S1 ends here and executes step S2; otherwise, execute S1-2; S1-2: Using D icbasestor , for D basestor and D IOT (N) Use the bsdiff algorithm to generate a total byte size much smaller than D IOT (N)D diff (N), judge D diff Is the byte size of (N) less than the set threshold? If so, execute S1-3; otherwise, discard the generated D diff (N), let D(N)=D base (N)=D IOT (N) and generate the index information of D(N), and use D base (N) Replace D basestor Stored in the node, let D basestor =D base (N), in addition to D basestor Generate dictionary D icbase (N), and use D icbase (N) Replace D icbasestor Stored in the node, let D icbasestor =D icbase (N), S1 ends here, and step S2 is executed; S1-3: Determine whether a bsdiff difference packet D has been stored in the IoT sensing node diffstor If yes, execute S1-4, otherwise, set D(N)=D diff (N) and generate the index information of D(N), and at the same time diff (N) is stored in the IoT sensing node, that is, D diffstor =D diff (N), in addition to D diffstor Generate dictionary D icdiff (N), and D icdiff (N) is stored in the node, that is, let D icdiffstor =D icdiff (N), S1 ends here and goes to step S2; S1-4: Using D icdiffstor , for D diffstor and D diff (N) Use the bsdiff algorithm to generate a total byte size less than D diff (N)D patch (N), let D(N)=D patch (N) and generate the index information of D(N), and delete the bsdiff difference packet D originally stored in the node diffstor and dictionary D icdiffstor , S1 ends here, and step S2 is executed; From the above, we can see that there is a byte size: D base >>D diff >D patch , and by utilizing D icbasestor and D icdiffstor , which greatly shortens the time required for bsdiff to generate differential packets and compensation packets, and improves the efficiency of uploading IoT data.
3. A blockchain system implementation method for updating Internet of Things data based on bsdiff according to claim 1, characterized in that: The index information IndexInf in step S2 includes the address of the IoT sensing node, the addresses of multiple bsdiff data storage nodes for storing the data packet uploaded this time, the MD5 value of the data packet, the timestamp and other information. The IoT sensing node calculates the hash value of IndexInf and encrypts the hash value with its private key to obtain the digital signature Signature IndexInf , and finally (IndexInf, Signature IndexInf ) to transmit the index information to the blockchain node.
4. A blockchain system implementation method for updating Internet of Things data based on bsdiff according to claim 1, characterized in that: The step S3 comprises the following steps: S3-1: Blockchain node receives (IndexInf, Signature IndexInf ) and use the public key of the IoT sensing node to sign IndexInf Decrypt to get Hash IndexInf ; S3-2: Calculate the Hash value of IndexInf and compare it with Hash IndexInf If the two are the same, it means that this is the correct and untampered index information from the legitimate IoT perception node, and the node waits to receive the data packet storage proof from multiple bsdiff data storage nodes contained in the index information; otherwise, the IoT perception node is considered untrustworthy and the message is broadcast on the blockchain network.
5. The method for implementing a blockchain system for updating IoT data based on bsdiff according to claim 1, characterized in that: The data packets D(N) uploaded in step S4 are divided into three types: when D(N)=D base (N), it indicates that the data packet type is a reference packet; when D(N)=D diff (N), it indicates that the data packet type is bsdiff differential packet, and D(N) contains D basestor The hash value of D basestor unique identifier information; When D(N)=D patch (N), it indicates that the data packet type is a bsdiff compensation packet, and D(N) additionally contains D basestor and D diffstor The hash value of D basestor and D diffstor The IoT sensing node calculates the Hash value of D(N) and encrypts the Hash value with its private key to obtain the digital signature. D , and finally (D(N), Signature D ) to transmit D(N) to multiple bsdiff data storage nodes.
6. A blockchain system implementation method for updating Internet of Things data based on bsdiff according to claim 1, characterized in that: The step S5 comprises the following steps: First, the following definitions are given: Addr represents the IoT sensing node address field in D(N), Type represents the data packet type field in D(N), Uid represents the unique identifier field in D(N), Ts represents the timestamp field in D(N), K pub Indicates the public key of the bsdiff data storage node, K pri Indicates the private key of the bsdiff data storage node, K symaddr Indicates the symmetric key used by the bsdiff data storage node to encrypt and decrypt data packets sent by the IoT sensing node with address Addr; S5-1: bsidff data storage node receives (D(N), Signature D ) and use the public key of the IoT sensing node to sign D Decrypt to get Hash D ; S5-2: Calculate the Hash value of D(N) and compare it with Hash D Compare and if the two are the same, it means that this is a correct data packet that has not been tampered with from a legitimate IoT sensing node; S5-3: If D(N)=D base (N), that is, Type is the base packet type, then the remaining part of D(N) excluding Addr, Type, Uid and Ts plus Uid is calculated using K symaddr After encryption, it is stored in the bsdiff data storage node. That is, the data packet format stored in the node is Addr+Type+Uid+Ts+K symaddr (D(N)-Addr-Type-Ts), in particular, the bsdiff data storage node uses K pub K symaddr Encrypt and keep it, and use K when you need to use it pri Decryption gets K symaddr ; If D(N)=D diff (N), that is, Type is bsdiff differential packet type, then D(N) is directly stored. In particular, D(N) contains D basestor Uid, that is, D basestor Hash value; if D(N)=D patch (N), that is, Type is the bsdiff compensation packet type, then D(N) is directly stored. In particular, D(N) contains D basestor and D diffstor Uid, that is, D basestor and D diffstor Hash value; S5-4: The bsdiff data storage node calculates the hash value of its address bsaddr and encrypts the hash value with its private key to obtain the data packet storage proof Signature bsaddr , and then send (bsaddr,Signature bsaddr ), in order to inform the blockchain node that the data packet has been correctly stored; otherwise, the IoT perception node is considered untrustworthy and the message is broadcast on the bsdiff data storage network.
7. A blockchain system implementation method for updating Internet of Things data based on bsdiff according to claim 1, characterized in that: The step S6 comprises the following steps: S6-1: Blockchain node waits for receiving (bsaddr, Signature bsaddr ) and use the public key of the corresponding bsdiff data storage node to sign bsaddr Decrypt to get Hash bsaddr ; S6-2: Calculate the Hash value of bsadrr and compare it with Hash bsaddr Compare them. If the two are the same, it means that this is an untampered and correct data packet storage certificate from a legitimate bsdiff data storage node; otherwise, the data packet storage certificate is considered unreliable and discarded. S6-3: Determine whether the blockchain node has received data packet storage certificates from all bsdiff data storage nodes included in the index information. If so, broadcast the index information to the blockchain network and S6 ends; otherwise, execute S6-1.
8. The method for implementing a blockchain system for updating IoT data based on bsdiff according to claim 1, characterized in that: The step S7 includes the following steps: S7-1: Each blockchain node receives the index information and calls the smart contract to generate a candidate block based on the index information. The candidate block consists of a block header and a block body. The block header contains the hash value, timestamp, and other information of the last block in the blockchain, while the block body contains the index information. S7-2: Each blockchain node executes the PoW algorithm, that is, each blockchain node calculates the hash value SHA-256, the hash value of the candidate block header information + the index information + the random number Nonce. The "candidate block header information" and "index information hash value" are fixed, and the blockchain node must continuously change the value of the random number Nonce until the calculated hash value meets the difficulty specified by the PoW algorithm; S7-3: If the hash value calculated by a blockchain node first meets the difficulty specified by the PoW algorithm, the blockchain node is considered to have completed the PoW algorithm first.
9. A blockchain system implementation method for updating Internet of Things data based on bsdiff according to claim 8, characterized in that: The difficulty of meeting the requirements of the PoW algorithm in S7-2 means that the calculated hash value must satisfy the requirement that the first N numbers are 0.
10. The method for implementing a blockchain system for updating IoT data based on bsdiff according to claim 1, characterized in that: The step S8 comprises the following steps: S8-1: The blockchain node that first completes the PoW algorithm adds the random number Nonce that meets the difficulty of the PoW algorithm to the block header of the candidate block and broadcasts the candidate block within the blockchain network; S8-2: After receiving the candidate block, other blockchain nodes in the blockchain network calculate SHA-256, the hash value of the candidate block header information + index information + the random number Nonce in the candidate block header, and determine whether the calculated hash value meets the difficulty specified by the PoW algorithm. If so, all blockchain nodes will add the candidate block to their own blockchain, that is, the candidate block will be put on the chain.
Citation Information
Patent Citations
Version updating management method and device, computer equipment and readable storage medium
CN112035155A
System and method for managing program memory on a storage device
WO2019077607A1