CN112182105A - Block chain data modification method based on Merkle tree - Google Patents

Block chain data modification method based on Merkle tree Download PDF

Info

Publication number
CN112182105A
CN112182105A CN202011037777.7A CN202011037777A CN112182105A CN 112182105 A CN112182105 A CN 112182105A CN 202011037777 A CN202011037777 A CN 202011037777A CN 112182105 A CN112182105 A CN 112182105A
Authority
CN
China
Prior art keywords
data
block
root
area
nodes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011037777.7A
Other languages
Chinese (zh)
Other versions
CN112182105B (en
Inventor
朱国胜
吴梦宇
祁小云
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hubei University
CERNET Corp
Original Assignee
Hubei University
CERNET Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hubei University, CERNET Corp filed Critical Hubei University
Priority to CN202011037777.7A priority Critical patent/CN112182105B/en
Publication of CN112182105A publication Critical patent/CN112182105A/en
Application granted granted Critical
Publication of CN112182105B publication Critical patent/CN112182105B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/278Data partitioning, e.g. horizontal or vertical partitioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to a block chain data modification method based on a Merkle tree. The security of the front block chain depends on its non-tamper-ability, but this property also makes it impossible for erroneous or false data stored in the block chain to be deleted or modified. Aiming at the problem, the invention divides the block body of the block chain into a data area and an expansion area, the data is only stored in the data area, the two areas independently construct a Merkle tree, and the roots of the two Merkle trees are respectively stored in the block head. And for error data needing to be modified, after agreement of a certain number of nodes is obtained, rewriting the data in the expansion area and reconstructing a Merkle tree of the expansion area. And experiments are carried out from two aspects of data modification and integrity verification, and the experimental result shows that the scheme has higher feasibility.

Description

Block chain data modification method based on Merkle tree
Technical Field
The invention relates to the technical field of network security, in particular to a block chain data modification method based on a Merkle tree.
Background
With the continuous development of computer technology and the internet, data security is more and more important. The blockchain is a distributed decentralized, non-falsifiable and high-security data storage technology, and more blockchain items begin to fall to the ground, and storing data into the blockchain can really guarantee the integrity and security of the data, but just because the blockchain has non-tamper property, some error data and false data stored in the blockchain cannot be corrected and deleted.
An important application scenario of the block chain is product traceability at present, traceability data are uploaded to the block chain from each data providing department node, the traceability data are generally manually input, a data input error situation is inevitable, and the data can not be guaranteed to be correct in percentage despite other node confirmation mechanisms. Whether the public chain like the EtherFang or the constructed private chain is adopted, data are not changeable once written into the block, so that a user queries that part of product tracing information is probably wrong, the product tracing itself needs to be true, and therefore research on a block chain data modification scheme is necessary.
Document 1: the block chain data modification scheme is based on a trapdoor one-way function and a novel block chain structure, and the block signature subblocks are reconstructed by introducing a maneuvering factor, so that the legal modification of the block data can be realized after the nodes exceeding a certain threshold agree. Although the scheme realizes the modification of the data in the block on the premise of not modifying the integrity verification mode of the block chain, the scheme is only effective for the block chain with the special block structure adopting a space certification (PoSpace) consensus mechanism, and the data modification can not be realized through the scheme by adopting other consensus mechanisms such as workload certification (PoW), rights and interests certification (PoS) and delegation rights and interests certification (DPoS).
Disclosure of Invention
The purpose of the invention is: in order to solve the above problems, the present invention provides a method for modifying block chain data based on a Merkle tree. The method realizes modification of the block chain data by adding the extension area. The block is divided into a data area and an expansion area, the two areas are separated to construct a Merkle tree, the data is only written into the data area when the block is packaged, and if some error data is required to be modified, the data is rewritten in the expansion area of the block where the data is located after the agreement of a certain number of nodes is obtained.
In order to solve the problems, the technical scheme adopted by the invention is as follows:
a block chain data modification method based on a Merkle tree is characterized by comprising the following steps:
step 1, dividing a block body of a block chain into a data area and an expansion area, wherein data is only stored in the data area, the two areas independently construct a Merkle tree, and the roots of the two Merkle trees are respectively stored in a block head;
and 2, after obtaining agreement of a certain number of nodes for error data needing to be modified, rewriting the data in the expansion area and reconstructing a Merkle tree of the expansion area.
Further, the step 1 specifically includes the following steps:
step 1.1, dividing a block body into a data area and an expansion area, respectively calculating hash values of all data as leaf nodes when packing the block, calculating the hash values as father nodes after pairwise matching of the leaf nodes, calculating the hash values by pairwise matching of two adjacent father nodes, and repeating the steps until only one node is left as a root node, so as to construct a Merkle tree 1, and storing the Merkle tree 1 in the data area;
step 1.2, storing a Merkle tree 2 only containing root nodes in the expansion area, wherein the value of the root nodes is the same as that of the root nodes in the data area;
step 1.3, storing two Root node values Merkle1_ Root and Merkle2_ Root into a block header, and storing a hash value PreHash obtained by carrying out hash calculation on a previous block data area into the block header, wherein the blocks form a front-back link relation through the PreHash.
Further, the step 2 specifically includes the following steps:
step 2.1: if a certain node finds that the data uploaded by the node is wrong, a block data modification request needs to be initiated, and the block number where the data is located, the wrong data ID and the correct data are signed together and then broadcast to the nodes of the whole network;
step 2.2, the other nodes verify the signature and the data after receiving the message, and determine whether to approve the data modification after the verification is passed;
and 2.3, legally modifying the block data after obtaining the agreement of a certain number of nodes.
Further, when the Merkle root of the expansion area is the same as the Merkle root of the data area, it is indicated that the block has not been modified, the data in the data area remains unchanged, the data to be modified is rewritten into the modified data in the expansion area, the data ID is consistent with the original data ID in the data area, and then hash calculation is performed to obtain the hash value of the data, which is used as a leaf node and paired with itself to construct a Merkle tree.
Further, when the Merkle root of the expansion area is different from the Merkle root of the data area, the data modification is performed, if the IDs of the last two data in the expansion area are the same, the data modification is performed, the data modification is paired with the expansion area, one of the data modification is selected to be paired with the new modified data hash value again, and a Merkle tree is reconstructed; if the IDs of the last two data in the expansion area are different, the new modified data hash value is still matched with the new modified data hash value, and then a Merkle tree is reconstructed; and after the modification is successful, updating the Merkle2_ Root in the block header to a new Merkle Root in the extension area.
Further, for the block after completing the data modification, Merkle2_ Root in the block header may be changed; because the Merkle1_ Root and the Merkle2_ Root are the same in the initial state of the block, when acquiring data from the block, only the values of the Merkle1_ Root and the Merkle2_ Root in the block header need to be compared firstly to determine whether the values are the same, and if the values are the same, all the data in the data area are directly taken out; if the data in the block is different from the data in the block, the data in the expansion area is completely taken out, all data ID sets are taken out independently, the data of the data ID in the data area in the set are the original data of the modified data, the data need to be removed, and the data in the data area after being removed and the data in the expansion area are effective data in the block.
Further, reconstructing a Merkle tree in the data area and a Merkle tree in the extension area at the trusted node to obtain a trusted Merkle1_ Root set and a trusted Merkle2_ Root set; and then, verifying other nodes, wherein during verification, the trusted Merkle1_ Root set and the trusted Merkle2_ Root set are required to be respectively compared with Merkle1_ Root and Merkle2_ Root in all block headers one by one, if the two are consistent, the chain is complete, no matter whether the chain is Merkle1_ Root or Merkle2_ Root, as long as the inconsistency occurs, namely that the block data is incomplete, discarding the block, and resynchronizing the data from the verified node.
Furthermore, if illegal data modification behaviors are found, the Merkle2_ Root in the extension area and the block header of the block is directly reset to the initial state, the original data can still be taken out from the data area when the data is fetched, and the data cannot be lost or damaged.
The technical scheme provided by the invention has the beneficial effects that at least: compared with the prior art, the invention has the advantages that: aiming at the problem that error data written into a block chain cannot be modified or deleted, the invention realizes modification of the block chain data by adding an extension area. The block is divided into a data area and an expansion area, the two areas are separated to construct a Merkle tree, the data is only written into the data area when the block is packaged, and if some error data is required to be modified, the data is rewritten in the expansion area of the block where the data is located after the agreement of a certain number of nodes is obtained. And experimental verification is carried out on the two aspects of data modification and integrity verification, and the experimental result shows that the scheme has higher feasibility.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:
FIG. 1 is a block structure of modifiable data according to an embodiment of the present invention.
Fig. 2 is a block structure after data modification according to an embodiment of the present invention.
Fig. 3 shows data of block 2 before modification according to an embodiment of the present invention.
Fig. 4 shows the data of block 2 after the data modification according to the embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The invention divides the block body of the block chain into a data area and an expansion area, and provides a block chain data modification scheme based on a Merkle tree. And data is only stored in the data area, the two areas independently construct a Merkle tree, and the roots of the two Merkle trees are respectively stored in the block head. And for error data needing to be modified, after agreement of a certain number of nodes is obtained, rewriting the data in the expansion area and reconstructing a Merkle tree of the expansion area. The present invention will be described with reference to examples.
1 Block Structure partitioning
In a traditional unmodified block chain, a block consists of a block head and a block body, a Merkle tree in the block body is formed by computing hash values of all data in the block and pairing and rolling the hash values, and the Merkle root value is stored in the block head. If some data in a block is modified, its hash value changes, the change of the leaf node affects the whole Merkle tree, and the Merkle root in the final block header also changes. When the block chain is subjected to integrity verification, the Merkle tree is reconstructed from the trusted node to obtain a trusted Merkle root, the Merkle root of the block for modifying data is different from the trusted Merkle root, and the integrity verification cannot be passed, so that for the traditional block chain, once the block is generated, the data cannot be modified.
According to the scheme, a block body is divided into a data area and an expansion area, when the blocks are packed, data and a constructed Merkle tree are stored in the data area according to a traditional block chain mode, the expansion area stores the Merkle tree only containing root nodes, the value of the root nodes is the same as that of the Merkle roots in the data area, the two Merkle roots are all placed in a block head, and PreHash in the block head is the Hash value of the data area of the previous block. The block structure of the modifiable data is shown in fig. 1.
2 data modification method
If a certain node finds that the uploaded data is wrong, a block data modification request needs to be initiated, the block number where the data is located, the wrong data ID and the correct data are signed and then broadcast to nodes in the whole network, other nodes verify the signature and the data after receiving the message, whether the data modification is approved or not is determined after the verification is passed, and the block data can be legally modified after the approval of a certain number of nodes is obtained.
When the Merkle root of the expansion area is the same as the Merkle root of the data area, the block is not modified, the data in the data area is kept unchanged, the data to be modified is rewritten into the modified data in the expansion area, the data ID is consistent with the original data ID in the data area, then the Hash calculation is carried out to obtain the Hash value of the data, the Hash value is used as a leaf node and is matched with the leaf node to construct a Merkle tree.
When the Merkle root of the expansion area is different from the Merkle root of the data area, indicating that data modification is performed, if the IDs of the last two data in the expansion area are the same, indicating that the data modification is performed, pairing the data modification with the expansion area, taking one of the two data to be paired with a new modified data hash value again, and reconstructing a Merkle tree; if the last two data IDs in the expansion area are different, the new modified data hash value is still matched with the new modified data hash value, and then the Merkle tree is reconstructed. After the modification is successful, the Merkle2_ Root in the chunk header is updated to be the new Merkle Root in the extension, and the modified chunk is shown in fig. 2.
As can be seen from a comparison of fig. 1 and fig. 2, the data area and the Merkle1_ Root are unchanged before and after the data modification, and only the extension area and the Merkle2_ Root are modified. The purpose of this design is:
(1) data in the data area is generally more, the structure of the Merkle tree is more complex, if the data is directly modified in the data area, the reconstruction of the whole Merkle tree is caused, and the data modification and the data synchronization between the modified nodes take longer time. The data volume of the expansion area is less, the number of layers of the Merkle tree is less, the reconstruction is faster, and the time overhead brought by data modification is smaller.
(2) There are many attack means for attacking the block chain, and if an attacker uses a certain attack means to pass the data modification validity verification, the illegal modification of the data in the block is completed. After the illegal behavior is found, the data in the extension area is directly destroyed, the Merkle2_ Root in the Merkle tree and the block header is reset to the initial state, the original data is still stored in the data area, and the original data on the block chain cannot be influenced.
3 modified data acquisition
For the block after completing the data modification, Merkle2_ Root in the block header is changed. Because the Merkle1_ Root and the Merkle2_ Root are the same in the initial state of the block, when acquiring data from the block, only the values of the Merkle1_ Root and the Merkle2_ Root in the block header need to be compared firstly to determine whether the values are the same, and if the values are the same, all the data in the data area are directly taken out; if the data in the block is different from the original data, the data in the expansion area is completely extracted, all the data ID sets are independently extracted, the data of the data ID in the data area in the set are the original data of the modified data, and only other data except the original data need to be extracted.
4 integrity verification
The block chain integrity verification of the traditional structure is to acquire data from a trusted node, reconstruct Merkle trees in all blocks to obtain a trusted Merkle _ Root set, and compare the trusted Merkle Root set with Merkle roots in all block heads of other nodes to verify the integrity of the blocks. For the new architecture blockchain proposed above, the integrity verification is slightly different from the conventional architecture blockchain. Firstly, reconstructing a Merkle tree in a data area and a Merkle tree in an extension area at a trusted node to obtain a trusted Merkle1_ Root set and a trusted Merkle2_ Root set. And then, verifying other nodes, wherein during verification, the trusted Merkle1_ Root set and the trusted Merkle2_ Root set are required to be respectively compared with Merkle1_ Root and Merkle2_ Root in all block headers one by one, if the two are consistent, the chain is complete, no matter whether the chain is Merkle1_ Root or Merkle2_ Root, as long as the inconsistency occurs, namely that the block data is incomplete, discarding the block, and resynchronizing the data from the verified node.
The modifiable blockchain has more alignment work than the traditional structure blockchain to reconstruct the Merkle2 tree and Merkle2_ Root. Because only the blocks subjected to data modification need to reconstruct the Merkle2 tree, the block ratio of the data modification is very small, the time for constructing the Merkle2 tree is short, the comparison of Merkle2_ Root is simple character string matching, and the time is short. Therefore, the time spent on the integrity verification of the modifiable block chain is only slightly larger than that of the traditional structure block chain, the influence on the verification efficiency is almost negligible, and the comparison experiment of the time spent on the integrity verification of the traditional structure block chain and the data modifiable block chain provided by the section is carried out later.
5 Experimental and results analysis
5.1 Experimental Environment
The block chain prototype of a traditional block structure and the block chain prototype of a data modifiable block structure designed in section 2.1 are realized by writing by using a Python3 language and a Python flash Web framework, 6 computers with different configurations are used as block chain nodes, the configuration information of the 6 nodes is shown in the following table 1, a data non-modifiable test block chain 1 and a data modifiable test block chain 2 are respectively built by using the two block chain prototypes, experiments are carried out from the modification of block data in the block chain and the time spent on integrity verification after the modification of data, and Postman is used as a Web interface request tool to acquire data.
Table 1 node configuration information
Figure BDA0002705591700000091
5.2 Block data modification
And (4) performing experiments by using the test block chain 2, and setting the number of the nodes for verifying the data modification validity to be 4. The examination report with the report number of YW2008-006 is uploaded, and in order to simulate an input error when data is recorded, the report number is erroneously input as YW 2008-0006. Since a created block is generated by block chain initialization, the verification report is packed and stored in block 2, the block data acquisition interface/chain is written, and the data of block 2 is returned using the Postman request/chain interface as shown in fig. 3.
And (3) using the node 1 to initiate data modification request broadcasting to other nodes, operating the nodes 2, 3, 4 and 5 to agree with data modification, and simulating validity verification of the data modification. After all 4 nodes return confirmation information, the node 1 modifies the error data of the block 2, corrects the report number to YW2008-006, and uses Postman to request/chain interface again, and the returned data of the block 2 is as shown in FIG. 4.
As can be seen from fig. 3 and fig. 4, only the value of Merkle2_ Root is changed before and after data modification, and the value of Merkle1_ Root is not changed, which indicates that data modification only changes the Merkle2 tree in the extension area, and does not change the Merkle1 tree in the data area, and meets the design of the modification scheme in section 2. Because the PreHash in the block head is the Hash value of the data area of the previous block, and the data modification does not change the data area, the Hash value of the current data area after the data modification is still consistent with the PreHash in the next block head, which shows that the block data modification does not destroy the link relation between the previous block and the next block.
5.3 integrity verification time spending
The 300 product inspection report data are divided into 30 groups by 10 groups and circularly uploaded to the test block chain 1. The founder block is created as the first run of the blockchain system, cannot store data, and each block stores a set of 10 product inspection report data starting from block 2. When 3001 blocks are generated, the integrity of the block chain is verified for the node 6, the integrity is verified for 5 times by taking the nodes 1 to 5 as trusted nodes respectively, and the time spent in each verification is recorded. And then stopping the operation of the test block chain 1 system of the 6 nodes, starting the test block chain 2, circularly uploading 30 groups of product inspection reports in the same mode, respectively modifying data with the ID of 1 in 3000 block data areas, namely the blocks 2 to 3001, through data modification application, carrying out 5 times of integrity verification on the node 6 by taking the nodes 1 to 5 as trusted nodes after the data modification is completed, and recording the time spent in each verification. The integrity verification time overhead for both test blockchains is shown in table 2 below.
TABLE 2 integrity verification time spending
Figure BDA0002705591700000111
As can be seen from table 2, the integrity verification time cost of the test blockchain 2 with 6 nodes as trusted nodes is slightly increased by milliseconds compared with that of the test blockchain 1. In the course of the actual operation of the blockchain, the time-consuming increase in milliseconds is not noticeable without the use of a timing algorithm, and this is the extreme case when 3000 blocks are reconstructed from the extent Merkle tree with data modification. In practice, the block data modification will not occur so much, and the increase of the integrity verification time cost will be less obvious. Therefore, the addition of the expansion area can not cause obvious change of integrity verification time expense, and the influence on verification efficiency can be ignored.
5.4 safety assay
The distinction of data-modifiable block chains from traditional structured block chains is the addition of Merkle trees in the extension area and the extension area, and the security of traditional structured block chains depends on the security of the extension area because they are not tamper-modifiable. In the modifiable block chain, the block data can be modified only by obtaining the validity confirmation of a certain number of nodes, the setting of the number of confirmed nodes is related to the number of nodes in the whole network, the more the number is, the safer the node is, but the longer confirmation waiting time is brought, and the number of nodes is set according to the actual requirement in the actual system operation process. When the number of the confirmation nodes is large enough, if the validity confirmation of all the nodes is obtained, the realization difficulty is not inferior to the difficulty of '51% attack' in a block chain. Even if the setting of the number of the confirmed nodes is not enough, an attacker passes data modification validity verification by using a certain unknown attack means and tamps the block data, once the behavior is found, the data in the expansion area is directly emptied, the Merkle2 tree in the expansion area and the Merkle2_ Root in the block header are reset to the initial state, the original data before being tampered are still stored in the data area, and the original data of the block chain cannot be influenced.
And (3) ending: aiming at the problem that error data written in a block chain can not be modified or deleted, the block is divided into a data area and an expansion area, the data area stores the data written in the block, the expansion area is used for data rewriting during modification, a Merkle tree is independently constructed in the two areas, and Merkle roots of the two areas are stored in the block head, so that a block chain data modification scheme is provided. And an experimental environment is set up to carry out experiments from two aspects of data modification and integrity verification, and the experimental result shows that the scheme has high feasibility.
It should be understood that the specific order or hierarchy of steps in the processes disclosed is an example of exemplary approaches. Based upon design preferences, it is understood that the specific order or hierarchy of steps in the processes may be rearranged without departing from the scope of the present disclosure. The accompanying method claims present elements of the various steps in a sample order, and are not intended to be limited to the specific order or hierarchy presented.
In the foregoing detailed description, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the claimed embodiments of the subject matter require more features than are expressly recited in each claim. Rather, as the following claims reflect, invention lies in less than all features of a single disclosed embodiment. Thus, the following claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. Of course, the processor and the storage medium may reside as discrete components in a user terminal.
For a software implementation, the techniques described herein may be implemented with modules (e.g., procedures, functions, and so on) that perform the functions described herein. The software codes may be stored in memory units and executed by processors. The memory unit may be implemented within the processor or external to the processor, in which case it can be communicatively coupled to the processor via various means as is known in the art.
What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, any use of the term "or" in the specification of the claims is intended to mean a "non-exclusive or".

Claims (8)

1. A block chain data modification method based on a Merkle tree is characterized by comprising the following steps:
step 1, dividing a block body of a block chain into a data area and an expansion area, wherein data is only stored in the data area, the two areas independently construct a Merkle tree, and the roots of the two Merkle trees are respectively stored in a block head;
and 2, after obtaining agreement of a certain number of nodes for error data needing to be modified, rewriting the data in the expansion area and reconstructing a Merkle tree of the expansion area.
2. The method as claimed in claim 1, wherein the step 1 comprises the following steps:
step 1.1, dividing a block body into a data area and an expansion area, respectively calculating hash values of all data as leaf nodes when packing the block, calculating the hash values as father nodes after pairwise matching of the leaf nodes, calculating the hash values by pairwise matching of two adjacent father nodes, and repeating the steps until only one node is left as a root node, so as to construct a Merkle tree 1, and storing the Merkle tree 1 in the data area;
step 1.2, storing a Merkle tree 2 only containing root nodes in the expansion area, wherein the value of the root nodes is the same as that of the root nodes in the data area;
step 1.3, storing two Root node values Merkle1_ Root and Merkle2_ Root into a block header, and storing a hash value PreHash obtained by carrying out hash calculation on a previous block data area into the block header, wherein the blocks form a front-back link relation through the PreHash.
3. The method of claim 1, wherein the step 2 comprises the following steps:
step 2.1: if a certain node finds that the data uploaded by the node is wrong, a block data modification request needs to be initiated, and the block number where the data is located, the wrong data ID and the correct data are signed together and then broadcast to the nodes of the whole network;
step 2.2, the other nodes verify the signature and the data after receiving the message, and determine whether to approve the data modification after the verification is passed;
and 2.3, legally modifying the block data after obtaining the agreement of a certain number of nodes.
4. The method as claimed in claim 3, wherein when the Merkle root in the extension area is the same as the Merkle root in the data area, it indicates that the block has not been modified, the data in the data area remains unchanged, the data to be modified is rewritten in the extension area as modified data, the data ID is consistent with the original data ID in the data area, and then the hash value of the data is obtained by performing hash calculation, and the hash value is used as a leaf node and paired with itself to construct the Merkle tree.
5. The method as claimed in claim 3, wherein when the Merkle root of the extension area is different from the Merkle root of the data area, it indicates that the data modification has been performed, and if the IDs of the last two data in the extension area are the same, it indicates that the two data are paired with itself, and one of the two data is taken to be re-paired with the new modified data hash value, and the Merkle tree is reconstructed; if the IDs of the last two data in the expansion area are different, the new modified data hash value is still matched with the new modified data hash value, and then a Merkle tree is reconstructed; and after the modification is successful, updating the Merkle2_ Root in the block header to a new Merkle Root in the extension area.
6. The method as claimed in claim 3, wherein for the block after completing the data modification, the Merkle2_ Root in the block header changes; because the Merkle1_ Root and the Merkle2_ Root are the same in the initial state of the block, when acquiring data from the block, only the values of the Merkle1_ Root and the Merkle2_ Root in the block header need to be compared firstly to determine whether the values are the same, and if the values are the same, all the data in the data area are directly taken out; if the data in the block is different from the data in the block, the data in the expansion area is completely taken out, all data ID sets are taken out independently, the data of the data ID in the data area in the set are the original data of the modified data, the data need to be removed, and the data in the data area after being removed and the data in the expansion area are effective data in the block.
7. The method as claimed in claim 6, wherein the Merkle tree in the data zone and the Merkle tree in the extension zone are reconstructed at the trusted node, and the trusted Merkle1_ Root set and Merkle2_ Root set are obtained; and then, verifying other nodes, wherein during verification, the trusted Merkle1_ Root set and the trusted Merkle2_ Root set are required to be respectively compared with Merkle1_ Root and Merkle2_ Root in all block headers one by one, if the two are consistent, the chain is complete, no matter whether the chain is Merkle1_ Root or Merkle2_ Root, as long as the inconsistency occurs, namely that the block data is incomplete, discarding the block, and resynchronizing the data from the verified node.
8. The method as claimed in claim 6, wherein if illegal data modification behavior is found, Merkle2_ Root in the extension area and block header of the block is directly reset to initial state, and original data is still taken out from the data area when data is fetched, and data will not be lost or damaged.
CN202011037777.7A 2020-09-28 2020-09-28 Block chain data modification method based on Merkle tree Active CN112182105B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011037777.7A CN112182105B (en) 2020-09-28 2020-09-28 Block chain data modification method based on Merkle tree

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011037777.7A CN112182105B (en) 2020-09-28 2020-09-28 Block chain data modification method based on Merkle tree

Publications (2)

Publication Number Publication Date
CN112182105A true CN112182105A (en) 2021-01-05
CN112182105B CN112182105B (en) 2022-06-17

Family

ID=73944400

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011037777.7A Active CN112182105B (en) 2020-09-28 2020-09-28 Block chain data modification method based on Merkle tree

Country Status (1)

Country Link
CN (1) CN112182105B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113469713A (en) * 2021-07-21 2021-10-01 贵州大学 Block chain-based food data anti-counterfeiting tracing method and system
CN113469712A (en) * 2021-07-21 2021-10-01 贵州大学 Food multi-source heterogeneous data integration method and system based on block chain technology
CN113836233A (en) * 2021-09-26 2021-12-24 承德石油高等专科学校 Audit data storage and source tracing method and terminal based on block chain

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108520050A (en) * 2018-03-30 2018-09-11 北京邮电大学 A kind of Merkle trees buffer storage based on two-dimensional localization and its operating method to Merkle trees
CN108804706A (en) * 2018-06-20 2018-11-13 南方科技大学 A kind of block chain data processing method, device, equipment and storage medium
US20190103973A1 (en) * 2017-09-29 2019-04-04 R3 Ltd. Hash subtrees for grouping components by component type
CN111488396A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 Data synchronization method and device for service data block chain
CN111639935A (en) * 2020-04-30 2020-09-08 南京理工大学 Account book modification method applicable to editable block chain

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190103973A1 (en) * 2017-09-29 2019-04-04 R3 Ltd. Hash subtrees for grouping components by component type
CN108520050A (en) * 2018-03-30 2018-09-11 北京邮电大学 A kind of Merkle trees buffer storage based on two-dimensional localization and its operating method to Merkle trees
CN108804706A (en) * 2018-06-20 2018-11-13 南方科技大学 A kind of block chain data processing method, device, equipment and storage medium
CN111488396A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 Data synchronization method and device for service data block chain
CN111639935A (en) * 2020-04-30 2020-09-08 南京理工大学 Account book modification method applicable to editable block chain

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
毛志来等: "区块链性能扩展与安全研究", 《技术研究》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113469713A (en) * 2021-07-21 2021-10-01 贵州大学 Block chain-based food data anti-counterfeiting tracing method and system
CN113469712A (en) * 2021-07-21 2021-10-01 贵州大学 Food multi-source heterogeneous data integration method and system based on block chain technology
CN113836233A (en) * 2021-09-26 2021-12-24 承德石油高等专科学校 Audit data storage and source tracing method and terminal based on block chain
CN113836233B (en) * 2021-09-26 2023-09-08 承德石油高等专科学校 Audit data evidence-storing and tracing method and terminal based on blockchain

Also Published As

Publication number Publication date
CN112182105B (en) 2022-06-17

Similar Documents

Publication Publication Date Title
CN112182105B (en) Block chain data modification method based on Merkle tree
EP3678346B1 (en) Blockchain smart contract verification method and apparatus, and storage medium
JP7405745B2 (en) Computer-implemented systems and methods for linking a blockchain to a set of digital twins
CN109542888B (en) Data modification and synchronization method, device, equipment and storage medium of block chain
Argyros et al. Sfadiff: Automated evasion attacks and fingerprinting using black-box differential automata learning
Curtmola et al. Robust remote data checking
CN107463597B (en) Passive verification method and system for block chain of modified block volume data
CN109271326B (en) Cloud database testing method and device, equipment and storage medium thereof
CN109543065B (en) Video active identification method combined with block chain
BR112021003852A2 (en) system and method for smart contract implemented by improved blockchain
US20090260084A1 (en) Method for verifying conformity of the logical content of a computer appliance with a reference content
CN107391292B (en) Block chain verification method and system for realizing error correction aiming at data of block body
CN107391557B (en) Block chain serial query method and system for setting out-of-chain fault table
CN111327490A (en) Byzantine fault-tolerant detection method of block chain and related device
CN113065169A (en) File storage method, device and equipment
CN111782551A (en) Test method and device for block chain item and computer equipment
CN109635595B (en) Block chain-based data tamper-proof method
CN107239358A (en) Startup method, mobile terminal and the device with store function of Android system
CN110730074A (en) Implementation method and data structure of nested traceable digital twin body
CN107451007B (en) Verification method and system of block chain for error correction aiming at added blocks
Hilgert et al. Syntactical carving of PNGs and automated generation of reproducible datasets
CN111460436B (en) Unstructured data operation method and system based on blockchain
CN110502209B (en) Method for preventing random number generator from injection attack
CN111147477A (en) Verification method and device based on block chain network
WO2018218814A1 (en) Method for storing off-line transaction record, and computer device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant