A data modification method on blockchain based on double hash chain
By forming a dual hash chain structure on the blockchain, allowing nodes to modify and clear harmful or wrong data, the network security governance problems caused by the unmodification of blockchain are solved, and the healthy development of blockchain is achieved.
Patent Information
- Application Number
- CN202111253497.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2041-10-27
AI Technical Summary
The absolute non-modification of blockchain results in illegal or malicious activities that cannot be corrected and error information cannot be cleared, causing troubles in network security governance and affecting the healthy development of blockchain.
Using a data modification method based on a double hash chain, a double hash chain structure is formed by adding a hash chain to form a double hash chain structure, allowing nodes to make modification requests when they find harmful or wrong data, and data replacement is performed after verification and voting. and verify to ensure the integrity of the chain.
The modification and removal of blockchain data is realized, ensuring the standardization and cleanliness of the chain, and ensuring the healthy development of blockchain.
Smart Images

Figure CN114331451B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of blockchain, and in particular to a data modification method on a blockchain based on a double hash chain. Background Art
[0002] In a narrow sense, blockchain is a decentralized shared ledger that combines data blocks into a specific data structure in a chain in chronological order and cryptographically guarantees that it cannot be tampered with or forged. It can safely store simple, sequential, and system-verifiable data. In a broad sense, blockchain technology is a new decentralized infrastructure and distributed computing paradigm that uses encrypted chain block structures to verify and store data, distributed node consensus algorithms to generate and update data, and automated script codes (smart contracts) to program and operate data.
[0003] Blockchain has the characteristics of decentralization, time-series data, collective maintenance, programmability, security, trustworthiness, and immutability. The immutability refers to the fact that once the historical data on the blockchain is confirmed, it cannot be changed. However, the absolute immutability also causes a lot of problems. On an immutable blockchain, illegal or malicious activities may not be corrected. Malicious users upload false news and bad information to spread on the blockchain. The immutability makes these malicious information always exist on the chain and cannot be cleared, which brings great processing troubles to network security data supervision. At the same time, human operation errors are inevitable. The immutability makes the wrong registration information always exist in the blockchain, which brings a lot of troubles to users. The above errors and malicious information need to be corrected urgently.
[0004] With the rapid development of blockchain, more and more data are required to be put on the chain. The data on the chain includes not only financial data, but also a variety of data such as politics, culture, medical care, and technology. The application scenarios of blockchain are becoming more and more extensive. Research on data modification on blockchain will help the healthy development of blockchain applications. Summary of the invention
[0005] It can be seen from the background technology that the absolute immutability of blockchain has greatly damaged network security and caused great trouble to the governance of network security. In order to solve the above problems, the present invention provides a data modification method on blockchain based on double hash chain, which aims to help modify and clear harmful and erroneous data on blockchain.
[0006] The technical solution of the present invention is:
[0007] A method for modifying data on a blockchain based on a double hash chain comprises the following steps:
[0008] Step 1: Based on the original hash chain, add another hash chain to form a double hash chain structure with the original hash chain and the added hash chain;
[0009] Step 2: When any node in the blockchain finds that the data on a block contains harmful or erroneous data, it initiates a request to modify the block. Specifically, the node proposing the modification constructs a candidate transaction and a special transaction, and broadcasts these two transactions;
[0010] The candidate transaction is a transaction used to replace an original transaction containing harmful or erroneous data. Compared with the original transaction, the candidate transaction only modifies or deletes the harmful or erroneous data in the original transaction;
[0011] The special transaction is a transaction used to allow other nodes in the blockchain to receive a modification request initiated by the blockchain node that discovered harmful or erroneous data. The transaction includes the hash value of the candidate transaction and the hash value of the original transaction to indicate the two transactions that need to be verified;
[0012] Step 3: After receiving the modification request initiated by the blockchain node that found harmful or erroneous data, other nodes in the blockchain verify the candidate transaction and the original transaction;
[0013] Step 3.1: Obtain the original transaction based on the hash value of the original transaction provided in the special transaction. The node verifies the original transaction based on the complete blockchain it has to check whether there is harmful or erroneous information in the original transaction. If not, the process ends. If yes, proceed to step 3.2.
[0014] Step 3.2: Obtain the candidate transaction based on the hash value of the candidate transaction provided in the special transaction. The node verifies the candidate transaction to see whether the candidate transaction has only modified or deleted harmful or erroneous data compared to the original transaction. If not, go to step 2. If yes, go to step 4.
[0015] Step 4: The nodes in the blockchain vote on the modification request. The nodes that actually have the right to vote are those that package the blocks. Each time a block is packaged, the information on whether or not to agree to the modification request is written into the newly packaged block.
[0016] Step 5: Verify the vote and determine whether the vote satisfies the voting strategy. If not, end the process. If yes, proceed to step 6.
[0017] Step 6: The node that discovers the erroneous or harmful data replaces the original transaction containing the harmful or erroneous data with the candidate transaction and builds a new block;
[0018] Step 7: The nodes in the blockchain verify the new block.
[0019] Furthermore, according to the data modification method on the blockchain based on the double hash chain, the method for forming the double hash chain structure is: first, a new data field old_merkle_root is added to the existing block header structure of the blockchain to store a copy of the merkle root, thereby obtaining an extended block header structure, and then a new hash chain structure is obtained based on the extended block header structure, thereby forming a double hash chain structure of the blockchain together with the original hash chain.
[0020] Furthermore, according to the data modification method on the blockchain based on the double hash chain, the double hash chain structure of the blockchain includes the original hash chain: H (version, hash_prev, merkle_root, timestamp, nonce) and the newly added hash chain: H (version, hash_prev, old_merkle_root, timestamp, nonce), wherein the value of old_merkle_root is equal to the value of the original merkle_root, i.e., no modification has occurred and the merkle root in the original block is rooted.
[0021] Furthermore, according to the data modification method on the blockchain based on the double hash chain, the voting strategy refers to whether the proportion of affirmative votes in the newly chained blocks reaches 50% during the voting period.
[0022] Furthermore, according to the data modification method on the blockchain based on the double hash chain, after the nodes that package the blocks have packaged the blocks, the hash value of the special transaction is written into the block to indicate that they agree to the modification request.
[0023] Furthermore, according to the data modification method on the blockchain based on the double hash chain, the method for constructing a new block includes: replacing the original transaction containing harmful or erroneous data with the candidate transaction to construct the block body of the new block; recalculating the merkle root value field in the new block header structure according to the block body of the new block, and compared with the header structure of the original block, the other fields in the new block header structure remain unchanged; and calculating the hash value of the new block according to the newly added hash chain.
[0024] Furthermore, according to the data modification method on the blockchain based on the double hash chain, in the process of the node in the blockchain described in step 7 verifying the new block, when verifying the hash value of the new block, the value of old_merkle_root is used instead of merkle_root.
[0025] The present invention has the following beneficial effects: The present invention proposes to adjust the header structure of all blocks in the original blockchain, add a field in the block header structure, namely a copy of the merkle root value, and use the newly added field to build a new hash chain to form a double hash chain structure. When the data modification in the block causes the merkle root value to change and thus causes the original hash chain to break, the new hash chain built according to the newly added field can still be connected. In this way, the link between blocks will not be disconnected, ensuring the integrity of the blockchain. Through such a modification method, illegal and erroneous data in the blockchain can be modified and cleared, making the blockchain network more standardized and clean, and thus enabling the blockchain to develop healthily. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 This is a flow chart of a method for modifying data on a blockchain based on a double hash chain in this embodiment;
[0027] Figure 2 This is a schematic diagram of the block header structure expansion method of this implementation method;
[0028] Figure 3 This is a schematic diagram of the double hash chain structure of this implementation method;
[0029] Figure 4 (a) is a schematic diagram of the original transaction structure containing harmful or erroneous data in this embodiment; (b) is a schematic diagram of the candidate transaction structure corresponding to (a)
[0030] Figure 5 It is a schematic diagram of the structure of a special transaction in this implementation mode;
[0031] Figure 6 This is a schematic diagram of the process of block node voting in this implementation method;
[0032] Figure 7 is a schematic diagram comparing the structures of the new block and the original block in this implementation mode;
[0033] Figure 8 Schematic diagram of chain integrity verification in this implementation mode. DETAILED DESCRIPTION
[0034] In order to facilitate the understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. The preferred embodiments of the present application are given in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thoroughly and comprehensively understood.
[0035] The core idea of the technical solution of the present invention is to first redesign the blockchain structure for all blocks in the blockchain and add a new data field y to the block header structure. The extended block header structure is obtained as (s, x, ctr, y). The existing block header structure of the blockchain is expressed as (s, x, ctr), where s represents the hash value of the previous block, x represents the stored data, and ctr is the proof of work. The extended block header structure obtained after adding the data field y to the block header structure is (s, x, ctr, y). The newly added y=G(s, x). Where G is an encryption function. The hash value of the block is generally calculated as H(ctr, G(s, x)). When harmful or erroneous data is found in the block and modified so that x becomes x', the calculated value of the block hash value becomes H(ctr, G(s, x')), resulting in a break in the original hash chain. At this time, because y is calculated based on y=G(s, x), the y field does not change after the block data is modified. That is, y can be used to construct a new block hash value calculation method H(ctr, y), so that the block hash value remains unchanged before and after the modification, ensuring the integrity of the chain. This y can be understood as an "oldstate", that is, the old state value. In the actual blockchain solution, a copy of the merkle root is used to store it. Then, when any node user in the blockchain finds that the data on the block contains harmful or erroneous information, a modification request for the block can be initiated. Then the nodes in the blockchain vote on the modification request. The nodes that actually have the right to vote are those that package the block. Each time a block is packaged, the node user can write whether or not to agree to the modification request into the newly packaged block. Then the vote is verified to determine whether the vote meets the voting strategy. If not, stop the modification. If it meets, perform data modification. The voting strategy refers to whether the proportion of votes in favor of the newly chained block reaches 50% during the voting period. After the data on the block is modified, the original data x stored in the block changes, x→x′, and the original hash chain is broken. However, since y remains unchanged, it is still calculated from the original data x stored in the block. Therefore, the second hash chain formed by y still holds, ensuring the integrity of the chain.
[0036] Figure 1 This is a flow chart of the data modification method on the blockchain based on the double hash chain in this implementation mode. Figure 1 As shown, the data modification method on the blockchain based on the double hash chain includes the following steps:
[0037] Step 1: Based on the original hash chain, add another hash chain to form a double hash chain structure with the original hash chain and the added hash chain;
[0038] In this embodiment, the double hash chain structure is formed by:
[0039] First, add a new data field old_merkle_root to the existing block header structure of the blockchain, such as Figure 2 As shown, a copy of the merkle root value of the original transaction is used to store, thereby obtaining an extended block header structure. When a new block is generated, the value of old_merkle_root is equal to merkle_root. When harmful or erroneous data is found in the block and the harmful or erroneous data is modified and cleared, the old_merkle_root in the modified block can still provide the original value for calculation, ensuring the integrity of the chain.
[0040] Then, a new hash chain structure is obtained based on the extended block header structure, thereby forming a double hash chain structure of the blockchain together with the original hash chain: Figure 3 The original hash chain shown in the solid line: H (version, hash_prev, merkle_root, timestamp, nonce) and Figure 3 The newly added hash chain shown by the dotted line: H (version, hash_prev, old_merkle_root, timestamp, nonce).
[0041] It is easy for those skilled in the art to know that the block structure of the blockchain can be divided into a block header and a block body. The block header contains the following fields: ①version: version number; ②hash_prev: hash value of the previous block header, using a hash function to calculate the fields in the previous block header structure to ensure the connection of the blockchain; ③merkle_root: the root value of the merkle tree, that is, the root value of the merkle tree composed of all transactions in the block body. Note that if any data in the tree changes, merkle_root will change; ④timestamp: timestamp, used to record the time when the block was generated; ⑤nonce: random number.
[0042] Step 2: The blockchain node user who discovers harmful or erroneous information submits a modification request for the block containing the harmful or erroneous information.
[0043] When harmful or erroneous information is found in a block, any blockchain node user can make a modification request to the block in the blockchain that contains the harmful or erroneous information. At this time, the node making the modification request needs to construct a candidate transaction and a special transaction, and broadcast these two transactions.
[0044] Step 2.1: Construct a candidate transaction. The candidate transaction is used to replace the original transaction that contains harmful or erroneous data. Figure 4The comparison diagram of the candidate transaction and the original transaction with harmful or erroneous data shown in the figure, wherein Figure (a) is a schematic diagram of the structure of the original transaction containing harmful or erroneous data, and Figure (b) is a schematic diagram of the structure of the candidate transaction corresponding to Figure (a). Compared with the original transaction, the candidate transaction only modifies or deletes the harmful or erroneous data in the original transaction. Compared with the original transaction, the only part that can be modified or deleted in the candidate transaction is the harmful or erroneous data, and the rest of the information cannot be modified or deleted.
[0045] Step 2.2: Construct a special transaction. The special transaction is used to allow other nodes in the blockchain to receive a request to modify a block that contains harmful or erroneous data. The transaction includes the hash value of the candidate transaction and the hash value of the original transaction, such as Figure 5 As shown, it is used to indicate the two transactions that need to be verified.
[0046] Step 3: After receiving the modification request initiated by the node that found harmful or erroneous data, other nodes in the blockchain verify the candidate transaction and the original transaction;
[0047] Step 3.1: Obtain the original transaction based on the hash value of the original transaction provided in the special transaction. The node verifies the original transaction based on the complete blockchain it has to check whether there is harmful or erroneous information in the original transaction. If not, the process ends. If yes, proceed to step 3.2.
[0048] Step 3.2: Obtain the candidate transaction based on the hash value of the candidate transaction provided in the special transaction. The node verifies the candidate transaction to see whether the candidate transaction has only modified or deleted harmful or erroneous data compared to the original transaction. If not, go to step 2. If yes, go to step 4.
[0049] After the candidate transaction is broadcast, it is placed in the candidate transaction pool. Other nodes in the block can verify the candidate transaction. The candidate transaction needs to meet some requirements: ① The candidate transaction is the same as the original transaction, except that it can delete or modify data. ② The candidate transaction can only modify and delete erroneous or harmful data, and other data cannot be modified. ③ Voting data cannot be modified. For example, modifying a certain voting data.
[0050] Step 4: The nodes in the blockchain vote on the modification request. The nodes that actually have the voting rights are those that package the blocks. Each time a block is packaged, the node user will write the information on whether or not to agree to the modification request into the newly packaged block.
[0051] like Figure 6As shown in the figure, in this step, the nodes that can vote are those that have the right to package the block. After the nodes that package the block have packaged the block, they can write the hash value of the special transaction in the block to indicate their agreement to the modification request.
[0052] Step 5: Verify the vote and determine whether the vote satisfies the voting strategy. If not, end the process. If yes, proceed to step 6.
[0053] The voting strategy formulated in the present invention refers to whether the proportion of affirmative votes in the newly-added blocks reaches 50% during the voting period. That is, after the modification request is made, a number of new blocks are generated (i.e., during the voting period), and the number of hash values containing special transactions in these blocks exceeds 50%, which means that the voting strategy is satisfied.
[0054] Step 6: Nodes that discover harmful or erroneous data build new blocks. Figure 7 This is the overall structure diagram of the new block. This step is to build a new block to replace the block containing harmful or erroneous data.
[0055] Step 6.1: Construction of the block body. The construction of a new block first replaces the original harmful or erroneous transactions with candidate transactions.
[0056] Step 6.2: Block header construction. During the construction of a new block, the value of old_merkle_root is the root value of the merkle tree of the original old data. The value of old_merkle_root cannot be modified.
[0057] Step 6.3: Since the transactions in the block body of the new block have changed, its merkle_root must have changed. Therefore, the merkle_root value needs to be recalculated for the new block. In addition, the field values in the new block header structure are the same as those in the original block and remain unchanged.
[0058] In the construction of a new block, in order to ensure the integrity of the chain, the hash_prev field value in the next block of the newly constructed block needs to be equal to the hash value of the newly constructed block. Since the merkle root value field in the newly constructed block has changed, the original calculation method H (version, hash_prev, merkle_root, timestamp, nonce) of the old chain is not equal to the hash_prev field value of the next block. At this time, since the present invention adds an old_merkle_root field to all blocks, this field value has not changed in the newly constructed block compared to the original block. Then the hash value calculation method of the new block can be changed to the new chain calculation method H (version, hash_pre, old_merkle_root, timestamp, nonce), and the calculation result is equal to the hash_prev value of the next block of the new block. In this way, the structure of the double hash chain ensures that the block changes, the old chain breaks, and the new chain can still be connected, thus ensuring the integrity of the chain.
[0059] Step 7: The nodes in the blockchain verify the new block;
[0060] After the new block is built, it also needs to be verified by the nodes in the blockchain, which includes the following steps:
[0061] Step 7.1: Block header structure verification. Compared with the new block, the only thing that has changed in the block header structure is the merkle_root of the block. The reason is that the transaction in the block body has changed. The other fields in the remaining block header, including nonce, remain unchanged.
[0062] Step 7.2: Block body verification. Block body verification is to scan all blocks to ensure that non-harmful or erroneous transactions have not been modified.
[0063] By following Figure 8 The chain integrity verification process flow diagram shown in FIG. verifies the integrity of the blockchain after data modification using the method of the present invention. The chain integrity verification involves three blocks: a new block B′ obtained by modifying or deleting harmful or erroneous data x , B x ′The previous block B pre and B′ x The next block B aft Specifically, first verify the new block B x ′ is equal to the value of the field hash_prev in the previous block B. preThe block header structure fields in the block are calculated according to the hash value of H (version, hash_prev, merkle_root, timestamp, nonce); then verify B aft Is the value of hash_prev in the block equal to the value of the previous block B? x ′’s block header structure field is calculated according to the hash value of H (version, hash_prev, old_merkle_root, timestamp, nonce). At this time, please pay attention, because B x ′ has changed. If we use the original calculation method H(version, hash_prev, merkle_root, timestamp, nonce) to calculate the hash value, the value we get will not correspond. In this case, we need to use the new calculation method H(version, hash_prev, old_merkle_root, timestamp, nonce) to calculate the hash value. This method ensures that the hash chain is not broken after the data is modified.
[0064] It should be understood that, inspired by the technical concept of the present invention, those skilled in the art may make various improvements or changes based on the above description without departing from the content of the present invention, which still fall within the protection scope of the present invention.
Claims
1. A data modification method on a blockchain based on a double hash chain, characterized in that: The steps include: Step 1: Based on the original hash chain, add another hash chain to form a double hash chain structure with the original hash chain and the added hash chain; Step 2: When any node in the blockchain finds that the data on a block contains harmful or erroneous data, it initiates a request to modify the block. Specifically, the node proposing the modification constructs a candidate transaction and a special transaction, and broadcasts these two transactions; The candidate transaction is a transaction used to replace an original transaction containing harmful or erroneous data. Compared with the original transaction, the candidate transaction only modifies or deletes the harmful or erroneous data in the original transaction; The special transaction is a transaction used to allow other nodes in the blockchain to receive a modification request initiated by the blockchain node that discovered harmful or erroneous data. The transaction includes the hash value of the candidate transaction and the hash value of the original transaction to indicate the two transactions that need to be verified; Step 3: After receiving the modification request initiated by the blockchain node that found harmful or erroneous data, other nodes in the blockchain verify the candidate transaction and the original transaction; Step 3.1: Obtain the original transaction based on the hash value of the original transaction provided in the special transaction. The node verifies the original transaction based on the complete blockchain it has to check whether there is harmful or erroneous information in the original transaction. If not, the process ends. If yes, proceed to step 3.
2. Step 3.2: Obtain the candidate transaction based on the hash value of the candidate transaction provided in the special transaction. The node verifies the candidate transaction to see whether the candidate transaction has only modified or deleted harmful or erroneous data compared to the original transaction. If not, go to step 2. If yes, go to step 4. Step 4: The nodes in the blockchain vote on the modification request. The nodes that actually have the right to vote are those that package the blocks. Each time a block is packaged, the information on whether or not to agree to the modification request is written into the newly packaged block. Step 5: Verify the vote and determine whether the vote satisfies the voting strategy. If not, end the process. If yes, proceed to step 6. Step 6: The node that discovers the erroneous or harmful data replaces the original transaction containing the harmful or erroneous data with the candidate transaction and constructs a new block; Step 7: The nodes in the blockchain verify the new block.
2. The data modification method on the blockchain based on the double hash chain according to claim 1 is characterized in that: The method for forming the double hash chain structure is as follows: first, a data field old_merkle_root is added to the existing block header structure of the blockchain to store a copy of the merkle root, thereby obtaining an extended block header structure, and then a new hash chain structure is obtained based on the extended block header structure, thereby forming a double hash chain structure of the blockchain together with the original hash chain.
3. The data modification method on the blockchain based on the double hash chain according to claim 2 is characterized in that: The double hash chain structure of the blockchain includes the original hash chain: H (version, hash_prev, merkle_root, timestamp, nonce) and the newly added hash chain: H (version, hash_prev, old_merkle_root, timestamp, nonce), where the value of old_merkle_root is equal to the value of the original merkle_root, that is, no modification has occurred and the merkle root in the original block has not been modified.
4. The data modification method on the blockchain based on the double hash chain according to claim 1 is characterized in that: The voting strategy refers to whether the proportion of affirmative votes in the newly chained blocks reaches 50% during the voting period.
5. The data modification method on the blockchain based on the double hash chain according to claim 1 is characterized in that: After the nodes that package the blocks have packaged the blocks, they write the hash value of the special transaction into the block to indicate their agreement to the modification request.
6. The data modification method on the blockchain based on the double hash chain according to claim 1 is characterized in that: The method for constructing a new block includes: replacing an original transaction containing harmful or erroneous data with a candidate transaction to construct a block body of a new block; recalculating a merkle root value field in a new block header structure according to the block body of the new block, and compared with the header structure of the original block, other fields in the new block header structure remain unchanged; and obtaining a hash value of the new block by calculating according to a newly added hash chain.
7. The data modification method on the blockchain based on the double hash chain according to claim 2 is characterized in that: In the process of verifying the new block by the node in the blockchain described in step 7, when verifying the hash value of the new block, the value of old_merkle_root is used instead of merkle_root.
Citation Information
Patent Citations
Self-securing storage system and self-securing storage method for block chain
CN106295406A
Method and system for generating block chain modified in expansion
CN106897352A
Permissioned blockchain constructing and controlling method based on Chameleon hash function
CN108830602A
Blockchain-based data verification method, apparatus and system
WO2021174499A1
