CN115618422A - Block chain-based data tamper-proof method and device - Google Patents

Block chain-based data tamper-proof method and device Download PDF

Info

Publication number
CN115618422A
CN115618422A CN202211295870.7A CN202211295870A CN115618422A CN 115618422 A CN115618422 A CN 115618422A CN 202211295870 A CN202211295870 A CN 202211295870A CN 115618422 A CN115618422 A CN 115618422A
Authority
CN
China
Prior art keywords
target
verification
target database
hash value
node
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.)
Pending
Application number
CN202211295870.7A
Other languages
Chinese (zh)
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.)
Guangdong Planning and Designing Institute of Telecommunications Co Ltd
Original Assignee
Guangdong Planning and Designing Institute of Telecommunications Co Ltd
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 Guangdong Planning and Designing Institute of Telecommunications Co Ltd filed Critical Guangdong Planning and Designing Institute of Telecommunications Co Ltd
Priority to CN202211295870.7A priority Critical patent/CN115618422A/en
Publication of CN115618422A publication Critical patent/CN115618422A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • 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
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Business, Economics & Management (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Finance (AREA)
  • Accounting & Taxation (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Storage Device Security (AREA)

Abstract

The invention discloses a data tamper-proofing method and device based on a block chain, wherein the method comprises the following steps: after receiving a user operation request, acquiring current data information of a target database, and calculating a current hash value corresponding to the target database according to the current data information of the target database; and judging whether the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database, if so, executing target operation on the target database according to the user operation request, and returning a first operation result corresponding to the target operation executed on the target database to the user after the target operation is executed. Therefore, the method and the device can reduce the throughput disadvantage of the block chain and improve the timeliness of the falsification of the database.

Description

Block chain-based data tamper-proof method and device
Technical Field
The invention relates to the technical field of block chains, in particular to a data tamper-proofing method and device based on a block chain.
Background
The traditional database does not have the capability of data tamper resistance, so that enterprises usually need to spend extra costs of manpower, material resources and financial resources to ensure the operation safety of data in the database, but in production practice, the phenomenon that the data of the enterprises are tampered maliciously or modified accidentally still happens.
The prior art solves the problem of data tampering by combining a block chain technology, but the problems that the throughput disadvantage of a block chain is difficult to avoid, the performance of a traditional database must be greatly reduced to match the throughput of the block chain, the integrity of data is detected only at a specific moment, and the data tampering is difficult to find in time and the like still exist. Therefore, the prior art has certain defects and needs to be solved urgently.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a block chain-based data tamper-proofing method and device, which can be beneficial to improving the timeliness of finding that data is tampered, and improving the database tamper-proofing capability, thereby improving the data security.
In order to solve the technical problem, a first aspect of the present invention discloses a data tamper-proofing method based on a block chain, where the method includes:
after receiving a user operation request, acquiring current data information of the target database, and calculating a current hash value corresponding to the target database according to the current data information of the target database, wherein the user operation request at least comprises a target operation which is requested to be executed on the target database by a user, and the current data information is real-time data information when the data information of the target database is acquired;
judging whether the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database, if so, executing the target operation on the target database according to the user operation request, and returning a first operation result corresponding to the target operation executed on the target database to a user after the target operation is executed;
and the historical hash value corresponding to the target database is obtained by calculation according to the historical latest data information of the target database before the user operation request is received, and is used for being packaged and stored on the block chain.
As an optional implementation manner, in the first aspect of the present invention, the target operation at least includes a write operation, and the performing the target operation on the target database according to the user operation request includes:
executing the write operation on the target database according to the user operation request so as to update the current data information of the target database;
wherein after the performing the write operation on the target database according to the user operation request to update the current data information of the target database, the method further comprises:
and calculating a current hash value corresponding to the target database according to the updated current data information of the target database, updating a historical hash value corresponding to the target database according to the current hash value corresponding to the target database, and packaging and storing the updated historical hash value corresponding to the target database to the block chain.
As an alternative implementation, in the first aspect of the present invention, the method further includes:
and if the current hash value corresponding to the target database is judged to be different from the historical hash value corresponding to the target database, returning a second operation result to the user, and sending a warning signal to the user, wherein the second operation result is used for indicating that the target database refuses to execute the target operation according to the user operation request, and the warning signal is used for reminding the user that the historical latest data information of the target database is changed before executing the target operation according to the user operation request.
As an optional implementation manner, in the first aspect of the present invention, the storing the updated historical hash value corresponding to the target database in a package to the block chain includes:
packaging the updated historical hash value corresponding to the target database into a target transaction, and sending the target transaction to one of target consensus nodes on a block chain to trigger the target consensus nodes to execute the following operations:
storing, by the target consensus node, the target transaction to a candidate tile in the chain of tiles;
after the target transaction is stored in the candidate block, the target consensus node sends the candidate block to other consensus nodes on the block chain, and the other consensus nodes are used for verifying the candidate block through a consensus algorithm after receiving the candidate block to obtain a corresponding first verification result;
after the target transaction is stored to the candidate block, the target consensus node verifies the candidate block through a consensus algorithm to obtain a corresponding second verification result;
acquiring a first verification result corresponding to the other common identification nodes by the target common identification node, judging whether the candidate block meets a preset uplink condition according to a second verification result corresponding to the target common identification node and the first verification results corresponding to all the other common identification nodes, and recording the candidate block into the block chain when the judgment result is yes;
and the other common identification nodes are further configured to obtain the second verification result and first verification results corresponding to the remaining other common identification nodes, determine whether the candidate block meets a preset uplink condition according to the second verification result and the first verification results corresponding to the remaining other common identification nodes, and record the candidate block into the block chain when the determination result is yes.
As an optional implementation manner, in the first aspect of the present invention, the verifying, by the target consensus node, the candidate block by using a consensus algorithm to obtain a corresponding second verification result includes:
the target consensus node verifies the candidate block according to a preset verification rule, stores block information corresponding to the candidate block after passing verification, and generates first signature information corresponding to the target consensus node according to the block information corresponding to the candidate block after passing verification;
receiving, by the target consensus node, second signature information corresponding to the other consensus nodes, where the second signature information is generated by the other consensus nodes according to a preset verification rule, storing block information corresponding to the candidate block after passing the verification, and according to the block information corresponding to the candidate block after passing the verification;
and judging whether the first signature information corresponding to the target consensus node and the second signature information corresponding to the other consensus nodes received by all the target consensus nodes meet preset verification conditions or not by the target consensus node to obtain a second verification result corresponding to the target consensus node.
As an optional implementation manner, in the first aspect of the present invention, the determining, by the target common node, whether the second verification result corresponding to the target common node and the first verification results corresponding to all other common nodes satisfy a predetermined uplink condition includes:
judging whether a second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block or not by the target consensus node;
when the target consensus node judges that the second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block, the target consensus node determines a first number of all target verification results in first verification results corresponding to all other consensus nodes obtained by the target consensus node, and judges whether the first number is greater than a first preset threshold, wherein all the target verification results are used for indicating that the corresponding consensus node passes the verification of the candidate block received by the target consensus node in the first verification results corresponding to all other consensus nodes obtained by the target consensus node;
when the target common identification node judges that the first number is larger than a first preset threshold value, determining that a second verification result corresponding to the target common identification node and first verification results corresponding to all other common identification nodes meet a preset uplink condition;
and when the target common identification node judges that the first number is less than or equal to a first preset threshold value, determining that a second verification result corresponding to the target common identification node and first verification results corresponding to all other common identification nodes do not meet a preset uplink condition.
As an optional implementation manner, in the first aspect of the present invention, the determining, by the target consensus node, whether the first signature information corresponding to the target consensus node and the second signature information corresponding to the other consensus nodes received by all the target consensus nodes satisfy a preset verification condition includes:
comparing, by the target common identification node, the first signature information corresponding to the target common identification node with the second signature information corresponding to the other common identification nodes, and screening all target signature information from the second signature information corresponding to all the other common identification nodes, where all the target signature information is the second signature information corresponding to the other common identification nodes that is the same as the first signature information corresponding to the target common identification node;
determining a second quantity of all the target signature information by the target consensus node, and judging whether the second quantity is greater than a second preset threshold value;
if the target consensus node judges that the second number is larger than the second preset threshold, determining that the first signature information corresponding to the target consensus node and the second signature information corresponding to all other consensus nodes received by the target consensus node meet the preset verification condition;
when the first signature information corresponding to the target consensus node and the second signature information corresponding to all the other consensus nodes received by the target consensus node satisfy the preset verification condition, the second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block.
The second aspect of the invention discloses a data tamper-proof device based on a block chain, which comprises:
the acquisition module is used for acquiring the current data information of the target database after receiving a user operation request, wherein the user operation request at least comprises a target operation which is requested to be executed on the target database by a user;
the calculation module is used for calculating a current hash value corresponding to the target database according to the current data information of the target database acquired by the acquisition module, wherein the current data information is real-time data information when the data information of the target database is acquired;
the judging module is used for judging whether the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database;
the execution module is used for executing the target operation on the target database according to the user operation request if the judgment module judges that the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database;
the return module is used for returning a first operation result corresponding to the target operation executed on the target database to a user after the execution of the target operation by the execution module is completed;
and the historical hash value corresponding to the target database is obtained by calculation according to the historical latest data information of the target database before the user operation request is received, and is used for being packaged and stored on the block chain.
As an optional implementation manner, in the second aspect of the present invention, the target operation at least includes a write operation, and a specific manner in which the execution module executes the target operation on the target database according to the user operation request is as follows:
executing the write operation on the target database according to the user operation request so as to update the current data information of the target database;
the calculation module is further configured to calculate, after the execution module executes the write operation on the target database according to the user operation request to update current data information of the target database, a current hash value corresponding to the target database according to the updated current data information of the target database;
the device further comprises:
the updating module is used for updating the historical hash value corresponding to the target database according to the current hash value corresponding to the target database calculated by the calculating module after the executing module executes the writing operation on the target database according to the user operation request so as to update the current data information of the target database;
and the storage module is used for packing and storing the historical hash value corresponding to the target database updated by the updating module into the block chain after the executing module executes the write operation on the target database according to the user operation request so as to update the current data information of the target database.
As an optional implementation manner, in the second aspect of the present invention, the returning module is further configured to return a second operation result to the user if the determining module determines that the current hash value corresponding to the target database is different from the historical hash value corresponding to the target database;
the device further comprises:
the sending module is used for sending a warning signal to a user if the judging module judges that the current hash value corresponding to the target database is different from the historical hash value corresponding to the target database;
the second operation result is used for indicating that the target database refuses to execute the target operation according to the user operation request, and the warning signal is used for reminding a user that the historical latest data information of the target database is changed before the target operation is executed according to the user operation request.
As an optional implementation manner, in the second aspect of the present invention, a specific manner in which the storage module packages and stores the historical hash value corresponding to the target database updated by the updating module to the block chain is as follows:
packaging the updated historical hash value corresponding to the target database into a target transaction, and sending the target transaction to one of target consensus nodes on a block chain to trigger the target consensus nodes to execute the following operations:
storing, by the target consensus node, the target transaction to a candidate tile in the chain of tiles;
after the target transaction is stored in the candidate block, the target consensus node sends the candidate block to other consensus nodes on the block chain, and the other consensus nodes are used for verifying the candidate block through a consensus algorithm after receiving the candidate block to obtain a corresponding first verification result;
after the target transaction is stored in the candidate block, the target consensus node verifies the candidate block through a consensus algorithm to obtain a corresponding second verification result;
acquiring a first verification result corresponding to the other common identification nodes by the target common identification node, judging whether the candidate block meets a preset uplink condition according to a second verification result corresponding to the target common identification node and the first verification results corresponding to all the other common identification nodes, and recording the candidate block into the block chain when the judgment result is yes;
and the other common identification nodes are further configured to obtain the second verification result and first verification results corresponding to the remaining other common identification nodes, determine whether the candidate block meets a preset uplink condition according to the second verification result and the first verification results corresponding to the remaining other common identification nodes, and record the candidate block into the block chain when the determination result is yes.
As an optional implementation manner, in the second aspect of the present invention, a specific manner of verifying the candidate block by the target consensus node through a consensus algorithm to obtain a corresponding second verification result is as follows:
the target consensus node verifies the candidate block according to a preset verification rule, stores block information corresponding to the candidate block after passing verification, and generates first signature information corresponding to the target consensus node according to the block information corresponding to the candidate block after passing verification;
receiving, by the target consensus node, second signature information corresponding to the other consensus nodes, where the second signature information is generated by the other consensus nodes according to a preset verification rule, storing block information corresponding to the candidate block after passing the verification, and according to the block information corresponding to the candidate block after passing the verification;
and judging whether the first signature information corresponding to the target consensus node and the second signature information corresponding to the other consensus nodes received by all the target consensus nodes meet preset verification conditions or not by the target consensus node to obtain a second verification result corresponding to the target consensus node.
As an optional implementation manner, in the second aspect of the present invention, a specific manner of determining, by the target common node, whether the second verification result corresponding to the target common node and the first verification results corresponding to all other common nodes satisfy a pre-set uplink condition is:
judging whether a second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block or not by the target consensus node;
when the target consensus node judges that the second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block, the target consensus node determines a first number of all target verification results in first verification results corresponding to all other consensus nodes obtained by the target consensus node, and judges whether the first number is greater than a first preset threshold, wherein all the target verification results are used for indicating that the corresponding consensus node passes the verification of the candidate block received by the target consensus node in the first verification results corresponding to all other consensus nodes obtained by the target consensus node;
when the target common identification node judges that the first number is larger than a first preset threshold value, determining that a second verification result corresponding to the target common identification node and first verification results corresponding to all other common identification nodes meet a preset uplink condition;
and when the target common identification node judges that the first number is less than or equal to a first preset threshold value, determining that a second verification result corresponding to the target common identification node and first verification results corresponding to all other common identification nodes do not meet a preset uplink condition.
As an optional implementation manner, in the second aspect of the present invention, a specific manner for the target consensus node to determine whether the first signature information corresponding to the target consensus node and the second signature information corresponding to the other consensus nodes received by all the target consensus nodes satisfy a preset verification condition is:
comparing, by the target consensus node, first signature information corresponding to the target consensus node with second signature information corresponding to the other consensus nodes, and screening all target signature information from the second signature information corresponding to the other consensus nodes, where all the target signature information is the second signature information corresponding to the other consensus nodes that is the same as the first signature information corresponding to the target consensus node;
determining a second quantity of all the target signature information by the target consensus node, and judging whether the second quantity is greater than a second preset threshold value;
if the target consensus node judges that the second number is larger than the second preset threshold, determining that the first signature information corresponding to the target consensus node and the second signature information corresponding to all other consensus nodes received by the target consensus node meet the preset verification condition;
when the first signature information corresponding to the target consensus node and the second signature information corresponding to all the other consensus nodes received by the target consensus node satisfy the preset verification condition, the second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block.
The third aspect of the invention discloses another block chain-based data tamper-proofing device, which comprises:
a memory storing executable program code;
a processor coupled with the memory;
the processor calls the executable program code stored in the memory to execute the block chain-based data tamper-proofing method disclosed by the first aspect of the invention.
The fourth aspect of the present invention discloses a computer storage medium, which stores computer instructions, and when the computer instructions are called, the computer instructions are used for executing the block chain-based data tamper-proofing method disclosed in the first aspect of the present invention.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
in the embodiment of the invention, after a user operation request is received, the current data information of a target database is obtained, and a current hash value corresponding to the target database is calculated according to the current data information of the target database; and judging whether the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database, if so, executing target operation on the target database according to the user operation request, and returning a first operation result corresponding to the target operation executed on the target database to the user after the target operation is executed. Therefore, after receiving a user operation request every time, the present hash value of the target database can be recalculated according to the present data information of the target database, and whether the recalculated present hash value is the same as the historical hash value stored on the block chain is judged, and the target operation is executed when the present hash value is the same as the historical hash value, thereby being beneficial to reducing the throughput disadvantage of the block chain by only chaining the hash value, and being beneficial to improving the timeliness of discovering that the database is tampered by calculating and comparing the present hash value before executing the target operation on the target database each time.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a block chain-based data tamper-proofing method according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of another block chain-based data tamper-proofing method disclosed in the embodiment of the present invention;
fig. 3 is a schematic structural diagram of a data tamper-proofing device based on a block chain according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart of another block chain-based data tamper-proofing method disclosed in the embodiment of the present invention;
fig. 5 is a schematic structural diagram of another block chain-based data tamper-proofing apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," and the like in the description and claims of the present invention and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, apparatus, article, or article that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or article.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the invention. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The invention discloses a data tamper-proofing method and device based on a block chain, which can recalculate the current hash value of a target database according to the current data information of the target database after receiving a user operation request each time, judge whether the recalculated current hash value is the same as a historical hash value stored on the block chain, execute target operation when the current hash value is the same as the historical hash value, facilitate to reduce the throughput disadvantage of the block chain by only winding up the hash value, and facilitate to improve the timeliness of discovering that the database is tampered by calculating and comparing the current hash value before executing the target operation on the target database each time. The following are detailed below.
Example one
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating a block chain-based data tamper-proofing method according to an embodiment of the present invention. The block chain-based data tamper-proofing method described in fig. 1 may be applied to a terminal device, where the terminal device may be a mobile terminal such as a mobile phone and a tablet, or a non-mobile terminal such as a computer and a smart television, and the embodiment of the present invention is not limited thereto. As shown in fig. 1, the method for preventing data from being tampered based on the blockchain may include the following operations:
101. and after receiving the user operation request, acquiring the current data information of the target database.
In the embodiment of the present invention, the user operation request at least includes a target operation that the user requests to execute on the target database, preferably, the target operation may include a write operation, a read operation, and the like, and preferably, the write operation may include an add operation, a delete operation, a modify operation, and the like.
In the embodiment of the invention, the current data information is real-time data information when the data information of the target database is acquired. Preferably, the target database may be a relational database, a non-relational database, a K-V database, which contains a plurality of database tables.
102. And calculating the current hash value corresponding to the target database according to the current data information of the target database.
In the embodiment of the invention, the Hash value (Hash value) is an output which is obtained by converting input information with any length into a fixed length through a Hash algorithm, and the output is the Hash value, and the Hash value is equivalent to a digital 'fingerprint', and is generally represented by a character string consisting of short random letters and numbers. The Hash value is unique and changes once the original data has changed.
In the embodiment of the invention, the process counter is initialized, that is, when K =0, the current data information of the target database is the initial data information of the target database, the current Hash value obtained by calculating according to the initial data information of the target database is the initial Hash value, the initial Hash value is linked to the Nth block for evidence storage, and the initial Hash value can be recorded as the Hash value N The nth block refers to a new block generated by packing, the block number is N,n = number of blocks (or block height) +1 existing block chain.
103. And judging whether the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database.
In the embodiment of the present invention, the historical hash value corresponding to the target database is calculated according to the historical latest data information of the target database before the user operation request is received, and the historical hash value corresponding to the target database is used for being stored in a block chain in a packed manner.
In the embodiment of the invention, the calculated Hash value can be recorded as Hash Calculated value The historical Hash value is the Hash value stored in the (N + K) th block and is marked as Hash N+K When K =0, the historical Hash value is the initial Hash value Hash N
In the embodiment of the invention, the block chain is a chain formed by blocks, certain information is stored in each block, the blocks are connected into a chain according to the time sequence generated by each block, and the chain is stored in all the servers. Preferably, the blockchain can be a public chain, a alliance chain and a private chain, wherein the public chain is a chain which can be used and maintained by anyone, and most of the participants are anonymous; the private chain is managed and restricted by a centralized manager, only a few people in the private chain can use the private chain, and information is not disclosed; a federation chain is a blockchain maintained by several organizations working together (e.g., supply chain organizations or banking unions, etc.), the use of which must be restricted access with permissions, and the related information protected.
In the embodiment of the invention, in the block chain, each block has the hash value of the previous block, and when any data of the current block is modified, the hash value of the block is changed, so that the previous block is influenced, and because the address of the previous block is contained, the authenticity of recording and viewing the data is maintained.
104. And if the current hash value corresponding to the target database is judged to be the same as the historical hash value corresponding to the target database, executing target operation on the target database according to the user operation request.
105. And after the target operation is executed, returning a first operation result corresponding to the target operation executed on the target database to the user.
In the embodiment of the present invention, if the target operation is a read operation, the first operation result may include a result of successful operation or a result of failed operation, data queried when the operation is successful, a failure reason when the operation is failed, and the like; if the target operation is a write operation, the first operation result may include a result of successful operation or a result of failed operation, uplink information of the hash value when the operation is successful, a failure reason when the operation is failed, and the like.
It can be seen that, with the implementation of the data tamper-proofing method based on the block chain described in fig. 1, after each user operation request is received, the current hash value of the target database is recalculated according to the current data information of the target database, and it is determined whether the recalculated current hash value is the same as the historical hash value stored on the block chain, and the target operation is performed when the current hash value is the same as the historical hash value, so that the throughput disadvantage of the block chain is favorably reduced by only chaining the hash value, and the timeliness of discovering that the database is tampered is favorably improved by performing calculation and comparison on the current hash value before performing the target operation on the target database each time.
In an optional embodiment, the block chain-based data tamper-proofing method may further include the following operations:
and if the current hash value corresponding to the target database is judged to be different from the historical hash value corresponding to the target database, returning a second operation result to the user, and sending a warning signal to the user.
In the embodiment of the invention, the second operation result is used for indicating that the target database refuses to execute the target operation according to the user operation request, and the warning signal is used for reminding the user that the historical latest data information of the target database is changed before the target database executes the target operation according to the user operation request.
Therefore, by implementing the data tamper-proofing method based on the block chain, which is described in the embodiment of the invention, the current hash value and the historical hash value can be compared before the target operation is performed on the target database each time, and the second operation result is returned and the warning signal is sent when the current hash value is different from the historical hash value, so that the target database can be found to be tampered before the target operation is performed on the target database each time, and the data security of the target database is improved.
Example two
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating a block chain-based data tamper-proofing method according to an embodiment of the present invention. The block chain-based data tamper-proofing method described in fig. 2 may be applied to a terminal device, where the terminal device may be a mobile terminal such as a mobile phone and a tablet, or a non-mobile terminal such as a computer and a smart television, and the embodiment of the present invention is not limited thereto. As shown in fig. 2, the method for preventing data from being tampered based on the blockchain may include the following operations:
201. and after receiving the user operation request, acquiring the current data information of the target database.
202. And calculating the current hash value corresponding to the target database according to the current data information of the target database.
203. And judging whether the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database.
In the embodiment of the present invention, please refer to the detailed description of steps 101 to 103 in the first embodiment for the detailed description of steps 201 to 203, which is not described again in the embodiment of the present invention.
204. If the judgment result is yes, writing operation is executed on the target database according to the user operation request so as to update the current data information of the target database.
In the embodiment of the invention, the operations of adding, deleting, modifying and the like are carried out on the target database according to the user operation request, and the current data information in the target database is updated after the operations are finished.
205. And calculating the current hash value corresponding to the target database according to the updated current data information of the target database.
In the embodiment of the invention, after the current data information in the target database is updated, correspondingly, the current Hash value corresponding to the target database changes along with the update of the current data information, the current Hash value of the target database can be recalculated according to the updated current data information by using any Hash function, and the recalculated current Hash value can be recorded as the Hash N+K+1
206. And updating the historical hash value corresponding to the target database according to the current hash value corresponding to the target database.
In the embodiment of the invention, the historical Hash value is the Hash value stored in the (N + K) th block and is marked as the Hash N+K After a round of writing, the new current Hash value obtained by calculation may be Hash-processed N+K+1 Determined as a historical hash value.
207. And packaging and storing the historical hash value corresponding to the updated target database to a block chain.
In the embodiment of the invention, the historical Hash value corresponding to the updated target database is Hash N+K+1 To Hash N+K+1 And packaging and storing the data to the (N + K + 1) th block for storage.
208. And after the target operation is executed, returning a first operation result corresponding to the target operation executed on the target database to the user.
In the embodiment of the present invention, please refer to the detailed description of step 105 in the first embodiment for the detailed description of step 208, which is not repeated herein.
It can be seen that, by implementing the block chain-based data tamper-proofing method described in fig. 2, after the write-in operation is performed, the current hash value corresponding to the target database can be recalculated according to the current data information of the updated target database, and the current hash value is used as the updated historical hash value to be linked to the block chain, so that the timeliness of updating the data of the target database can be improved, and the timeliness and accuracy of tampering the data when the target operation is performed next time can be improved, so as to ensure the data security of the target database.
In an optional embodiment, the step of storing the historical hash values corresponding to the updated target database to the blockchain in a packed manner includes the following steps:
2071. and packaging the historical hash value corresponding to the updated target database into the target transaction.
In the embodiment of the invention, the target transaction is used for representing the historical hash value to be linked. After each write operation is performed, the current data information of the target database is updated, and at this time, a new current hash value is calculated to update the historical hash value, so that a new target transaction is generated after each write operation is performed.
2072. Sending the target transaction to one of the target consensus nodes on the block chain to trigger the target consensus node to perform the following operations:
storing, by the target consensus node, the target transaction to a candidate block in the block chain;
after the target transaction is stored in the candidate block, the target consensus node sends the candidate block to other consensus nodes on the block chain, and the other consensus nodes are used for verifying the candidate block through a consensus algorithm after receiving the candidate block to obtain a corresponding first verification result;
after the target transaction is stored in the candidate block, the target consensus node verifies the candidate block through a consensus algorithm to obtain a corresponding second verification result;
acquiring first verification results corresponding to other common identification nodes by a target common identification node, judging whether the candidate block meets a preset uplink condition according to a second verification result corresponding to the target common identification node and the first verification results corresponding to all other common identification nodes, and recording the candidate block into a block chain when the judgment result is yes;
and the other common identification nodes are also used for acquiring a second verification result and first verification results corresponding to the rest of the other common identification nodes, judging whether the candidate block meets the preset uplink condition according to the second verification result and the first verification results corresponding to the rest of the other common identification nodes, and recording the candidate block into the block chain when the judgment result is yes.
In an embodiment of the present invention, the consensus node is configured to pack the target transaction into a block to obtain a candidate block. A candidate block refers to a new block generated on the blockchain for storing the target transaction, and the candidate block has not passed verification and review of each block. The first verification result is used for indicating whether other consensus nodes verify the candidate block, and the second verification result is used for indicating whether the target consensus node verifies the candidate block.
In this embodiment of the present invention, preferably, the federation chain and the private chain may selectively use consensus algorithms such as PBFT, PAXOS, RAFT, and the like, and the public chain may use consensus algorithms such as POW, POS, DPOS, and the like, which is not limited in this embodiment of the present invention.
Therefore, by implementing the block chain-based data tamper-proofing method described in the embodiment of the invention, after the target transaction is sent to the target consensus node and packaged into the candidate block, the candidate block can be broadcasted by the target consensus node, the candidate block can be verified by the consensus algorithm, then whether each consensus node meets the uplink condition or not can be judged according to the verification result of each of the target consensus node and other consensus nodes and the interaction condition between the verification results, and the candidate block is uplinked when the condition is met, so that the accuracy of uplinking the historical hash value is improved, and the security of data in the target database is improved.
In another alternative embodiment, the step of verifying the candidate block by the target consensus node through the consensus algorithm to obtain the corresponding second verification result may include the following steps:
the target consensus node verifies the candidate block according to a preset verification rule, stores block information corresponding to the candidate block after passing the verification, and generates first signature information corresponding to the target consensus node according to the block information corresponding to the candidate block after passing the verification;
receiving second signature information corresponding to other common identification nodes by the target common identification node, wherein the second signature information is generated by other common identification nodes according to the block information corresponding to the candidate block after passing the verification and storing the block information corresponding to the candidate block after passing the verification;
and judging whether the first signature information corresponding to the target consensus node and the second signature information corresponding to other consensus nodes received by all the target consensus nodes meet preset verification conditions or not by the target consensus node to obtain a second verification result corresponding to the target consensus node.
In the embodiment of the invention, the preset check rule is used for determining whether the block executor is called to take out the target transaction from the candidate block for execution or not after the target consensus node and other consensus nodes receive the candidate block. Preferably, the chunk information corresponding to the candidate chunk after passing the verification may include a chunk hash, where the chunk hash is used to uniquely determine a certain chunk, and the chunk hash is a hash value of the certain chunk obtained by performing hash calculation on a chunk header. The first signature information is used for indicating whether the target consensus node completes block execution or not, and the second signature information is used for indicating whether other consensus nodes complete block execution or not.
It can be seen that, by implementing the block chain-based data tamper-proofing method described in the embodiment of the present invention, a second verification result of a target consensus node can be obtained by determining first signature information and second signature information corresponding to the target consensus node and other consensus nodes on a block chain, and determining whether the first signature information and the second signature information satisfy a preset verification condition, so as to improve the accuracy of determining whether the target consensus node verifies a candidate block.
In yet another optional embodiment, the determining, by the target common node, whether the second verification result corresponding to the target common node and the first verification results corresponding to all other common nodes satisfy the predetermined uplink condition may include:
judging whether a second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block or not by the target consensus node;
when the target consensus node judges that the second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block, the target consensus node determines a first number of all target verification results in first verification results corresponding to all other consensus nodes acquired by the target consensus node, and judges whether the first number is greater than a first preset threshold value or not;
when the target common identification node judges that the first quantity is larger than a first preset threshold value, determining that a second verification result corresponding to the target common identification node and first verification results corresponding to all other common identification nodes meet a preset chain winding condition;
and when the target common identification node judges that the first quantity is less than or equal to a first preset threshold value, determining that a second verification result corresponding to the target common identification node and first verification results corresponding to all other common identification nodes do not meet the preset cochain condition.
In the embodiment of the invention, all the target verification results are the verification results of the corresponding consensus node for verifying the received candidate block, wherein the verification results are the first verification results corresponding to all other consensus nodes acquired by the target consensus node. Preferably, when the second verification result corresponding to the target consensus node is used to indicate that the target consensus node verifies the candidate block, and the number of the target verification results is greater than a first preset threshold, it indicates that the candidate block is consistent on most of the consensus nodes, and then the candidate block passes the block verification and can be packaged and stored in the block chain. Preferably, the first preset threshold may be 2f, f is the maximum number of malicious nodes that can be tolerated by the current blockchain network.
Therefore, by implementing the block chain-based data tamper-proofing method described in the embodiment of the present invention, when the second verification result corresponding to the target consensus node is used to indicate that the target consensus node passes the verification of the candidate block, it can be determined whether the number of target verification results is greater than a first preset threshold, and when the determination result is yes, it is determined that the candidate block meets the uplink condition, so that the accuracy of the uplink storage historical hash value is improved, and the data security of the target database is further improved.
In yet another optional embodiment, the determining, by the target consensus node, whether the first signature information corresponding to the target consensus node and the second signature information corresponding to other consensus nodes received by all the target consensus nodes satisfy the preset verification condition may include:
comparing the first signature information corresponding to the target common identification node with the second signature information corresponding to other common identification nodes by the target common identification node, and screening out all target signature information from the second signature information corresponding to all other common identification nodes, wherein all the target signature information is the second signature information corresponding to other common identification nodes which is the same as the first signature information corresponding to the target common identification node;
determining a second quantity of all target signature information by the target consensus node, and judging whether the second quantity is greater than a second preset threshold value;
if the target common identification node judges that the second quantity is larger than a second preset threshold value, determining that the first signature information corresponding to the target common identification node and the second signature information corresponding to all other common identification nodes received by the target common identification node meet a preset verification condition;
when the first signature information corresponding to the target consensus node and the second signature information corresponding to all other consensus nodes received by the target consensus node meet a preset verification condition, a second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes verification on the candidate block.
Therefore, by implementing the block chain-based data anti-tampering method described in the embodiment of the present invention, the first signature information that is the same as the target consensus node can be screened from the second signature information corresponding to all other consensus nodes, and when the number of the same first signature information is greater than the second preset threshold, the second verification result corresponding to the target consensus node can be determined to indicate that the candidate block passes verification, so as to improve the accuracy of determining whether the target consensus node passes verification on the candidate block.
EXAMPLE III
Referring to fig. 3, fig. 3 is a schematic structural diagram of a data tamper resistant device based on a block chain according to an embodiment of the present invention. The block chain-based data tamper-proofing device described in fig. 3 may be applied to a terminal device, where the terminal device may be a mobile terminal such as a mobile phone and a tablet, or a non-mobile terminal such as a computer and a smart television, and the embodiment of the present invention is not limited thereto. As shown in fig. 3, the block chain-based data tamper-proofing device may include:
an obtaining module 301, configured to obtain current data information of a target database after receiving a user operation request, where the user operation request at least includes a target operation that a user requests to execute on the target database;
a calculating module 302, configured to calculate a current hash value corresponding to the target database according to the current data information of the target database acquired by the acquiring module 301, where the current data information is real-time data information when the data information of the target database is acquired;
a judging module 303, configured to judge whether the current hash value corresponding to the target database calculated by the calculating module 302 is the same as the historical hash value corresponding to the target database;
an executing module 304, configured to execute a target operation on the target database according to the user operation request if the determining module 303 determines that the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database;
a returning module 305, configured to return, to the user, a first operation result corresponding to the target operation performed on the target database after the target operation performed by the performing module 304 is completed;
the historical hash value corresponding to the target database is obtained by calculation according to the historical latest data information of the target database before the user operation request is received, and the historical hash value corresponding to the target database is used for being packaged and stored on the block chain.
It can be seen that, implementing the data tamper-proofing apparatus based on the blockchain described in fig. 3 can help to reduce the throughput disadvantage of the blockchain by only chaining the hash value, and can help to improve the timeliness of discovering that the database is tampered by performing the calculation and comparison of the current hash value before each target operation is performed on the target database.
In an optional embodiment, the target operation at least includes a write operation, and the specific way for the execution module 304 to execute the target operation on the target database according to the user operation request is as follows:
executing write-in operation on the target database according to the user operation request so as to update the current data information of the target database;
the calculating module 302 is further configured to, after the executing module 304 executes a write operation on the target database according to the user operation request to update the current data information of the target database, calculate a current hash value corresponding to the target database according to the updated current data information of the target database;
as shown in fig. 4, the apparatus further includes:
an updating module 306, configured to update the historical hash value corresponding to the target database according to the current hash value corresponding to the target database calculated by the calculating module 302 after the executing module 304 performs a write operation on the target database according to the user operation request to update the current data information of the target database;
and the storing module 307 is configured to, after the executing module 304 executes a write operation on the target database according to the user operation request to update the current data information of the target database, package and store the historical hash value corresponding to the target database updated by the updating module 306 into the block chain.
Therefore, the block chain-based data tamper-proofing device described in the embodiment of the present invention can recalculate the current hash value corresponding to the target database according to the current data information of the updated target database after the write-in operation is performed, and link the current hash value as the updated historical hash value to the block chain, so as to improve the timeliness of updating the data of the target database, and further improve the timeliness and accuracy of finding data tamper when the target operation is performed next time, so as to ensure the data security of the target database.
In another optional embodiment, the returning module 305 is further configured to return a second operation result to the user if the determining module 303 determines that the current hash value corresponding to the target database is not the same as the historical hash value corresponding to the target database;
as shown in fig. 4, the apparatus further includes:
a sending module 308, configured to send a warning signal to the user if the determining module 303 determines that the current hash value corresponding to the target database is different from the historical hash value corresponding to the target database;
the second operation result is used for indicating that the target database refuses to execute the target operation according to the user operation request, and the warning signal is used for reminding the user that the historical latest data information of the target database is changed before the target database executes the target operation according to the user operation request.
Therefore, the data tamper-proofing device based on the block chain, which is described in the embodiment of the invention, can compare the current hash value with the historical hash value before the target operation is performed on the target database each time, and return the second operation result and send the warning signal when the current hash value is different from the historical hash value, so that the target database can be found to be tampered before the target operation is performed on the target database each time, and the data security of the target database is improved.
In yet another optional embodiment, the specific way for the storage module 307 to store the historical hash values corresponding to the target database updated by the updating module in a block chain in a packed manner is as follows:
packaging the historical hash value corresponding to the updated target database into a target transaction, and sending the target transaction to one of the target consensus nodes on the block chain to trigger the target consensus node to execute the following operations:
storing, by the target consensus node, the target transaction to a candidate block in the block chain;
after the target transaction is stored in the candidate block, the target consensus node sends the candidate block to other consensus nodes on the block chain, and the other consensus nodes are used for verifying the candidate block through a consensus algorithm after receiving the candidate block to obtain a corresponding first verification result;
after the target transaction is stored in the candidate block, the target consensus node verifies the candidate block through a consensus algorithm to obtain a corresponding second verification result;
acquiring first verification results corresponding to other common identification nodes by a target common identification node, judging whether the candidate block meets a preset uplink condition according to a second verification result corresponding to the target common identification node and the first verification results corresponding to all other common identification nodes, and recording the candidate block into a block chain when the judgment result is yes;
and the other common identification nodes are also used for acquiring a second verification result and first verification results corresponding to the rest of the other common identification nodes, judging whether the candidate block meets the preset uplink condition according to the second verification result and the first verification results corresponding to the rest of the other common identification nodes, and recording the candidate block into the block chain when the judgment result is yes.
Therefore, the block chain-based data tamper-proofing device described in the embodiment of the invention can be beneficial to improving the accuracy of the uplink chain certificate historical hash value, and further improve the security of data in the target database.
In another optional embodiment, the specific manner of verifying the candidate block by the target consensus node through the consensus algorithm to obtain the corresponding second verification result is as follows:
the target consensus node verifies the candidate block according to a preset verification rule, stores block information corresponding to the candidate block after passing the verification, and generates first signature information corresponding to the target consensus node according to the block information corresponding to the candidate block after passing the verification;
receiving second signature information corresponding to other common identification nodes by the target common identification node, wherein the second signature information is generated by other common identification nodes according to the block information corresponding to the candidate block after passing the verification and storing the block information corresponding to the candidate block after passing the verification;
and judging whether the first signature information corresponding to the target consensus node and the second signature information corresponding to other consensus nodes received by all the target consensus nodes meet preset verification conditions or not by the target consensus node to obtain a second verification result corresponding to the target consensus node.
Therefore, the block chain-based data tamper-proofing device described in the embodiment of the present invention can obtain the second verification result of the target consensus node by determining the first signature information and the second signature information corresponding to the target consensus node and other consensus nodes on the block chain, and determining whether the first signature information and the second signature information satisfy the preset verification condition, so as to improve the accuracy of determining whether the target consensus node passes the verification of the candidate block.
In yet another optional embodiment, the specific manner for the target common node to determine whether the second verification result corresponding to the target common node and the first verification results corresponding to all other common nodes satisfy the predetermined uplink condition is as follows:
judging whether a second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block or not by the target consensus node;
when the target consensus node judges that the second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block, the target consensus node determines a first number of all target verification results in first verification results corresponding to all other consensus nodes obtained by the target consensus node, and judges whether the first number is greater than a first preset threshold value or not, wherein all the target verification results are used for indicating that the corresponding consensus node passes the verification of the candidate block received by the target consensus node in the first verification results corresponding to all other consensus nodes obtained by the target consensus node;
when the target consensus node judges that the first number is larger than a first preset threshold value, determining that a second verification result corresponding to the target consensus node and first verification results corresponding to all other consensus nodes meet a preset uplink condition;
and when the target common identification node judges that the first quantity is less than or equal to a first preset threshold value, determining that a second verification result corresponding to the target common identification node and first verification results corresponding to all other common identification nodes do not meet the preset uplink condition.
Therefore, the block chain-based data tamper-proofing device described in the embodiment of the present invention can determine whether the number of target verification results is greater than a first preset threshold value when a second verification result corresponding to a target common identification node is used to indicate that the target common identification node passes verification on the candidate block, and determine that the candidate block meets the uplink condition when the determination result is yes, so as to improve the accuracy of the uplink certified historical hash value, and further improve the data security of the target database.
In yet another optional embodiment, the specific manner for the target consensus node to determine whether the first signature information corresponding to the target consensus node and the second signature information corresponding to other consensus nodes received by all the target consensus nodes satisfy the preset verification condition is as follows:
comparing the first signature information corresponding to the target common identification node with the second signature information corresponding to other common identification nodes by the target common identification node, and screening out all target signature information from the second signature information corresponding to all other common identification nodes, wherein all the target signature information is the second signature information corresponding to other common identification nodes which is the same as the first signature information corresponding to the target common identification node;
determining a second quantity of all target signature information by the target consensus node, and judging whether the second quantity is greater than a second preset threshold value;
if the target common identification node judges that the second quantity is larger than a second preset threshold value, determining that the first signature information corresponding to the target common identification node and the second signature information corresponding to all other common identification nodes received by the target common identification node meet a preset verification condition;
when the first signature information corresponding to the target consensus node and the second signature information corresponding to all other consensus nodes received by the target consensus node meet a preset verification condition, a second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes verification on the candidate block.
Therefore, the block chain-based data tamper-proofing device described in the embodiment of the present invention can screen out the first signature information that is the same as the target consensus node from the second signature information corresponding to all other consensus nodes, and when the number of the same first signature information is greater than the second preset threshold, can determine that the second verification result corresponding to the target consensus node is used to indicate that the candidate block passes verification, thereby improving the accuracy of determining whether the target consensus node passes verification on the candidate block.
Example four
Referring to fig. 5, fig. 5 is a schematic structural diagram of a data tamper resistant device based on a block chain according to an embodiment of the present invention. The block chain-based data tamper-proofing device described in fig. 5 may be applied to a terminal device, where the terminal device may be a mobile terminal such as a mobile phone and a tablet, or a non-mobile terminal such as a computer and a smart television, and the embodiment of the present invention is not limited thereto. As shown in fig. 5, the device for preventing data tampering based on a blockchain may include:
a memory 401 storing executable program code;
a processor 402 coupled with the memory 401;
the processor 402 calls the executable program code stored in the memory 401 to execute the steps in the data tamper-proofing method based on the blockchain described in the first embodiment or the second embodiment of the present invention.
EXAMPLE five
The embodiment of the invention discloses a computer storage medium, which stores computer instructions, and when the computer instructions are called, the computer instructions are used for executing the steps of the data tamper-proofing method based on the block chain described in the first embodiment or the second embodiment of the invention.
EXAMPLE six
The embodiment of the invention discloses a computer program product, which comprises a non-transitory computer readable storage medium storing a computer program, wherein the computer program is operable to make a computer execute the steps of the data tamper-proofing method based on the block chain described in the first embodiment or the second embodiment.
The above-described embodiments of the apparatus are merely illustrative, and the modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above detailed description of the embodiments, those skilled in the art will clearly understand that each embodiment may be implemented by software plus a necessary general hardware platform, and may also be implemented by hardware. Based on such understanding, the above technical solutions may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, wherein the storage medium includes a Read-Only Memory (ROM), a Random Access Memory (RAM), a Programmable Read-Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), a One-time Programmable Read-Only Memory (OTPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a Compact Disc-Read-Only Memory (CD-ROM) or other Memory capable of storing data, a magnetic tape, or any other computer-readable medium capable of storing data.
Finally, it should be noted that: the method and apparatus for preventing data from being tampered with based on a block chain disclosed in the embodiments of the present invention are only preferred embodiments of the present invention, and are only used for illustrating the technical solutions of the present invention, not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art; the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A data tamper-proofing method based on a blockchain is characterized by comprising the following steps:
after receiving a user operation request, acquiring current data information of the target database, and calculating a current hash value corresponding to the target database according to the current data information of the target database, wherein the user operation request at least comprises a target operation which is requested to be executed on the target database by a user, and the current data information is real-time data information when the data information of the target database is acquired;
judging whether the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database, if so, executing the target operation on the target database according to the user operation request, and returning a first operation result corresponding to the target operation executed on the target database to a user after the target operation is executed;
and the historical hash value corresponding to the target database is obtained by calculation according to the historical latest data information of the target database before the user operation request is received, and is used for being packaged and stored on the block chain.
2. The method according to claim 1, wherein the target operation at least comprises a write operation, and the performing the target operation on the target database according to the user operation request comprises:
executing the write operation on the target database according to the user operation request so as to update the current data information of the target database;
wherein after the performing the write operation on the target database according to the user operation request to update the current data information of the target database, the method further comprises:
and calculating a current hash value corresponding to the target database according to the updated current data information of the target database, updating a historical hash value corresponding to the target database according to the current hash value corresponding to the target database, and packaging and storing the updated historical hash value corresponding to the target database to the block chain.
3. The blockchain-based data tamper-proofing method according to claim 1, further comprising:
and if the current hash value corresponding to the target database is judged to be different from the historical hash value corresponding to the target database, returning a second operation result to the user, and sending a warning signal to the user, wherein the second operation result is used for indicating that the target database refuses to execute the target operation according to the user operation request, and the warning signal is used for reminding the user that the historical latest data information of the target database is changed before executing the target operation according to the user operation request.
4. The method for preventing data from being tampered based on the blockchain according to claim 2, wherein the step of storing the updated historical hash value corresponding to the target database to the blockchain in a packed manner comprises:
packaging the updated historical hash value corresponding to the target database into a target transaction, and sending the target transaction to one of target consensus nodes on a block chain to trigger the target consensus nodes to execute the following operations:
storing, by the target consensus node, the target transaction to a candidate tile in the chain of tiles;
after the target transaction is stored in the candidate block, the target consensus node sends the candidate block to other consensus nodes on the block chain, and the other consensus nodes are used for verifying the candidate block through a consensus algorithm after receiving the candidate block to obtain a corresponding first verification result;
after the target transaction is stored in the candidate block, the target consensus node verifies the candidate block through a consensus algorithm to obtain a corresponding second verification result;
acquiring a first verification result corresponding to the other common identification nodes by the target common identification node, judging whether the candidate block meets a preset uplink condition according to a second verification result corresponding to the target common identification node and the first verification results corresponding to all the other common identification nodes, and recording the candidate block into the block chain when the judgment result is yes;
the other common identification nodes are further configured to obtain the second verification result and first verification results corresponding to the remaining other common identification nodes, determine whether the candidate block meets a preset uplink condition according to the second verification result and the first verification results corresponding to the remaining other common identification nodes, and record the candidate block into the block chain when the determination result is yes.
5. The block chain-based data tamper-proofing method according to claim 4, wherein the verifying the candidate block by the target consensus node through a consensus algorithm to obtain a corresponding second verification result comprises:
the target consensus node verifies the candidate block according to a preset verification rule, stores block information corresponding to the candidate block after passing verification, and generates first signature information corresponding to the target consensus node according to the block information corresponding to the candidate block after passing verification;
receiving, by the target consensus node, second signature information corresponding to the other consensus nodes, where the second signature information is generated by the other consensus nodes according to a preset verification rule, storing block information corresponding to the candidate block after passing the verification, and according to the block information corresponding to the candidate block after passing the verification;
and judging whether the first signature information corresponding to the target consensus node and the second signature information corresponding to the other consensus nodes received by all the target consensus nodes meet preset verification conditions or not by the target consensus node to obtain a second verification result corresponding to the target consensus node.
6. The method according to claim 5, wherein the determining, by the target common node, whether the second verification result corresponding to the target common node and the first verification results corresponding to all other common nodes satisfy a predetermined uplink condition includes:
judging whether a second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block or not by the target consensus node;
when the target consensus node judges that the second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block, the target consensus node determines a first number of all target verification results in first verification results corresponding to all other consensus nodes obtained by the target consensus node, and judges whether the first number is greater than a first preset threshold, wherein all the target verification results are used for indicating that the corresponding consensus node passes the verification of the candidate block received by the target consensus node in the first verification results corresponding to all other consensus nodes obtained by the target consensus node;
when the target common identification node judges that the first number is larger than a first preset threshold value, determining that a second verification result corresponding to the target common identification node and first verification results corresponding to all other common identification nodes meet a preset uplink condition;
and when the target common identification node judges that the first quantity is less than or equal to a first preset threshold value, determining that a second verification result corresponding to the target common identification node and first verification results corresponding to all other common identification nodes do not meet a preset uplink condition.
7. The method according to claim 6, wherein the determining, by the target consensus node, whether the first signature information corresponding to the target consensus node and the second signature information corresponding to the other consensus nodes received by all the target consensus nodes satisfy a predetermined verification condition includes:
comparing, by the target common identification node, the first signature information corresponding to the target common identification node with the second signature information corresponding to the other common identification nodes, and screening all target signature information from the second signature information corresponding to all the other common identification nodes, where all the target signature information is the second signature information corresponding to the other common identification nodes that is the same as the first signature information corresponding to the target common identification node;
determining a second quantity of all the target signature information by the target consensus node, and judging whether the second quantity is greater than a second preset threshold value;
if the target consensus node judges that the second number is larger than the second preset threshold, determining that the first signature information corresponding to the target consensus node and the second signature information corresponding to all other consensus nodes received by the target consensus node meet the preset verification condition;
when the first signature information corresponding to the target consensus node and the second signature information corresponding to all the other consensus nodes received by the target consensus node satisfy the preset verification condition, the second verification result corresponding to the target consensus node is used for indicating that the target consensus node passes the verification of the candidate block.
8. A blockchain-based data tamper-resistant apparatus, the apparatus comprising:
the acquisition module is used for acquiring the current data information of the target database after receiving a user operation request, wherein the user operation request at least comprises a target operation which is requested to be executed on the target database by a user;
the calculation module is used for calculating a current hash value corresponding to the target database according to the current data information of the target database acquired by the acquisition module, wherein the current data information is real-time data information when the data information of the target database is acquired;
the judging module is used for judging whether the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database;
the execution module is used for executing the target operation on the target database according to the user operation request if the judgment module judges that the current hash value corresponding to the target database is the same as the historical hash value corresponding to the target database;
the return module is used for returning a first operation result corresponding to the target operation executed on the target database to a user after the execution of the target operation by the execution module is completed;
and the historical hash value corresponding to the target database is obtained by calculation according to the historical latest data information of the target database before the user operation request is received, and is used for being packaged and stored on the block chain.
9. A blockchain-based data tamper-resistant apparatus, the apparatus comprising:
a memory storing executable program code;
a processor coupled with the memory;
the processor calls the executable program code stored in the memory to execute the block chain based data tamper-proofing method according to any of claims 1-7.
10. A computer storage medium storing computer instructions for performing the blockchain-based data tamper-proofing method of any one of claims 1 to 7 when invoked.
CN202211295870.7A 2022-10-21 2022-10-21 Block chain-based data tamper-proof method and device Pending CN115618422A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211295870.7A CN115618422A (en) 2022-10-21 2022-10-21 Block chain-based data tamper-proof method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211295870.7A CN115618422A (en) 2022-10-21 2022-10-21 Block chain-based data tamper-proof method and device

Publications (1)

Publication Number Publication Date
CN115618422A true CN115618422A (en) 2023-01-17

Family

ID=84863713

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211295870.7A Pending CN115618422A (en) 2022-10-21 2022-10-21 Block chain-based data tamper-proof method and device

Country Status (1)

Country Link
CN (1) CN115618422A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117273974A (en) * 2023-11-21 2023-12-22 中国人寿保险股份有限公司上海数据中心 Large enterprise expense reimbursement data generation and verification method based on block chain consensus

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117273974A (en) * 2023-11-21 2023-12-22 中国人寿保险股份有限公司上海数据中心 Large enterprise expense reimbursement data generation and verification method based on block chain consensus
CN117273974B (en) * 2023-11-21 2024-02-06 中国人寿保险股份有限公司上海数据中心 Large enterprise expense reimbursement data generation and verification method based on block chain consensus

Similar Documents

Publication Publication Date Title
CN112491551B (en) Data verification method and device based on block chain and electronic equipment
EP3812993B1 (en) Method and apparatus for constructing merkle trees, and method and apparatus for simplified payment verification
US20220311618A1 (en) Nested blockchain system
CN110278211A (en) A kind of data checking method and device based on block chain
CN112000730B (en) Tracing information writing and tracing information verification method and system based on block chain
CN110599174A (en) Block chain information processing method and related equipment
CN112087502A (en) Method, device and equipment for processing request and storage medium
CN112131309A (en) Data evidence storing method and system based on block chain technology
CN115618422A (en) Block chain-based data tamper-proof method and device
CN111367923A (en) Data processing method, data processing device, node equipment and storage medium
CN114022151A (en) Block chain data visualization method and system, electronic device and storage medium
CN110347678B (en) Financial data storage method, system, device and equipment
CN114817399B (en) Block management method and device
CN110941672A (en) Household registration management method, device, equipment and storage medium
CN113362068A (en) Method for verifying block chain state transfer by light node
CN111291300B (en) Webpage data processing method and device, webpage system and server
CN111985004A (en) Method for judging information integrity and computer system thereof
CN112037055A (en) Transaction processing method and device, electronic equipment and readable storage medium
CN115913734A (en) User authority management method, device and equipment applied to alliance chain
WO2020228564A1 (en) Application service method and device
CN114090689A (en) Intelligent contract data processing method based on alliance chain and related equipment thereof
CN112948847A (en) Data sharing system based on block chain and data correctness verification method
CN112800132A (en) Block chain storage method of electronic file
CN112671738A (en) Login method, device, terminal and storage medium of enterprise internal system
CN111125593A (en) Block chain-based family tree information processing method and 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