CN115081031A - Tamper-proof block chain data storage method and system - Google Patents

Tamper-proof block chain data storage method and system Download PDF

Info

Publication number
CN115081031A
CN115081031A CN202210883403.XA CN202210883403A CN115081031A CN 115081031 A CN115081031 A CN 115081031A CN 202210883403 A CN202210883403 A CN 202210883403A CN 115081031 A CN115081031 A CN 115081031A
Authority
CN
China
Prior art keywords
node
transaction
leaf node
binary search
tree
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
CN202210883403.XA
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.)
Chengdu Yunzhi Digital Security Technology Co ltd
Original Assignee
Chengdu Yunzhi Digital Security Technology 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 Chengdu Yunzhi Digital Security Technology Co ltd filed Critical Chengdu Yunzhi Digital Security Technology Co ltd
Priority to CN202210883403.XA priority Critical patent/CN115081031A/en
Publication of CN115081031A publication Critical patent/CN115081031A/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/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3823Payment protocols; Details thereof insuring higher security of transaction combining multiple encryption tools for a transaction
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3825Use of electronic signatures
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3827Use of message hashing
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management

Abstract

An embodiment of the present specification provides a tamper-resistant blockchain data storage method and system, and belongs to the field of distributed accounts, where the system includes: the storage layer is a k-v database and is used for storing data in a distributed mode and backing up a plurality of copies for each blockchain; the network layer is used for data transmission among nodes and determining the sequence of the blocks according to a consensus protocol, wherein the nodes comprise user nodes and mechanism nodes, and the mechanism nodes comprise at least one database; the organization node is used for packaging the signed transaction into a block and constructing a binary search tree for the block; the mechanism node is also used for generating a hash-based index for each non-leaf node of the binary search tree, and the k-v database is also used for storing the index of each non-leaf node of the binary search tree; the structure node is also used for receiving the query request sent by the user node and feeding back the query information to the user node based on the binary search tree, and the structure node has the advantages of improving the data carrying capacity and the transaction efficiency.

Description

Tamper-proof block chain data storage method and system
Technical Field
The present disclosure relates to distributed accounts, and in particular, to a method and a system for storing tamper-resistant blockchain data.
Background
The ledger is a record keeping system that contains all transactions across businesses. Similarly, a distributed ledger is a unique database controlled by a group of participants in a distributed environment. The data may be accessed or updated at different locations or geographic locations and by multiple people. The network participant has one copy of the same ledger, and any updates to it are reflected in all copies, thereby securing the ledger from external attacks. Blockchains are a distributed ledger technique. A blockchain is an immutable point-to-point ledger, consisting of ordered units called cryptographic security blocks. The block consists of a timestamp, a transaction set, and a hash of the previous block. A trade is an order that updates the current ledger and is validated through a consensus mechanism and grouped with other trades into blocks that are attached to each participant's ledger. Given the hash of the last block, it is possible to go all the way to the first block in the ledger. Blockchains have advantages over centralized systems in nature, such as: 1. since each node on the blockchain network has a copy of the ledger, all participants have access to transactions and data, and the system is transparent; 2. once a transaction is added to the blockchain, it is almost impossible to change it, making the ledger immutable; 3. dispersing: the blockchain is not managed by a single authority, but is maintained by nodes in the network; 4. the safety is improved: with the decentralized of the blockchain, there is no single point of failure. A ledger copy is stored on each node and a consensus mechanism is used to ensure the integrity of each copy. The existing distributed account book technology based on the block chain has many defects, for example, 1, the amount of data received is seriously limited; 2. the transaction efficiency is low; 3. the transaction verification time is long; 4. the delay of data confirmation is high.
Therefore, it is desirable to provide a tamper-resistant blockchain data storage method and system, which are used to apply blockchain technology to database management to improve data throughput and transaction efficiency.
Disclosure of Invention
One of the embodiments of the present specification provides a tamper-resistant blockchain data storage system, including: the storage layer is a k-v database and is used for storing data in a distributed mode and backing up a plurality of copies for each blockchain; the network layer is used for data transmission among nodes and determining the sequence of the blocks according to a consensus protocol, wherein the nodes comprise user nodes and mechanism nodes, and the mechanism nodes comprise at least one database; the organization node is used for packaging the signed transaction into a block and constructing a binary search tree for the block, wherein a data structure of the transaction in the block comprises a transaction key value; said organization node further configured to generate a hash-based index for each non-leaf node of said binary search tree, said k-v database further configured to store an index for each said non-leaf node of said binary search tree; and the structure node is also used for receiving the query request sent by the user node and feeding back query information to the user node based on the binary search tree.
It can be understood that the tamper-resistant blockchain data storage system adopts the blockchain technology in combination with the database kernel technology, so that high-performance, high-concurrency and data tamper resistance are realized. Furthermore, index information about key values of the transactions is added in the binary search tree of the block, so that the root nodes of the binary search tree can directly search corresponding transactions according to target key values in the query requests, the queryability of the transactions is realized, and meanwhile, the indexes are stored in the binary search tree through Hash operation, and the indexes are guaranteed to be not falsified.
In some embodiments, the data structure for the transaction in the block comprises a transaction header and transaction data, wherein the transaction header contains a version number, a parent transaction hash, a transaction time, a transaction next owner public key, a signature to prove that the transaction is valid; the transaction data includes the transaction key value and at least one field.
In some embodiments, the binary search tree is generated based on a red-black tree and a Merkel tree.
It can be understood that generating the binary search tree of the block based on the red-black tree and the merkel tree can make the query time within o (logn), and ensure that the parent node is hashed by the child node, and when inserting a new node, the parent node information can be updated accordingly.
In some embodiments, constructing the binary search tree comprises: storing transaction records in leaf nodes of the binary search tree; for each non-leaf node, the non-leaf node is configured to store a key value of the non-leaf node, a hash value of a left sub-tree, and a hash value of a right sub-tree, the key values in the left sub-tree of the non-leaf node are all less than or equal to the key value of the non-leaf node, and the key values in the right sub-tree of the non-leaf node are all greater than the key value of the non-leaf node.
It can be understood that by setting the key values in the left subtrees of the non-leaf nodes to be less than or equal to the key values of the non-leaf nodes, and setting the key values in the right subtrees of the non-leaf nodes to be greater than the key values of the non-leaf nodes, the data insertion or query efficiency can be improved.
In some embodiments, constructing the binary search tree further comprises: the key value of the non-leaf node is the largest key value in the left sub-tree of the non-leaf node.
In some embodiments, constructing the binary search tree further comprises: and carrying out hash operation on the hash value of the left subtree of the non-leaf node, the hash value of the right subtree of the non-leaf node and the key value of the non-leaf node to determine the hash value of the non-leaf node.
In some embodiments, the feeding back, by the structure node, query information to the user node based on the binary search tree includes: acquiring a target key value based on the query request; searching in the memory block of the structure node based on the target key value, and judging whether a target leaf node exists in the memory block; if the target leaf node does not exist in the memory block, repeatedly executing the step of obtaining the index of the previous block from the k-v database according to the sequence of the blocks, and judging whether the target leaf node exists in the previous block or not until the leaf node is inquired or the target leaf node does not exist in all the blocks.
It can be understood that by setting the query rule, whether a target leaf node exists in the memory block is first searched, and when the target leaf node does not exist in the memory block, the index of the previous block is obtained from the k-v database according to the sequence of the blocks, and whether the target leaf node exists in the previous block is judged, so that the data query efficiency can be effectively improved.
In some embodiments, the feeding back, by the structure node, query information to the user node based on the binary search tree includes: and for the memory block or the previous block, searching from a root node of the binary search tree, if the target key value is less than or equal to the root node of the binary search tree, judging whether the target leaf node exists in a left sub-tree of the root node, and if the target key value is greater than the root node of the binary search tree, judging whether the target leaf node exists in a right sub-tree of the root node, wherein the target leaf node is a leaf node of which the key value is equal to the target key value.
It can be understood that by starting with the root node of the binary search tree and comparing the target key value with the key values of the nodes, the leaf nodes that need to be compared with the key values can be quickly obtained.
In some embodiments, the system further comprises: the block chain layer is used for displaying the world state of the block chain; and the application layer is used for carrying out data query operation and further analyzing and processing the queried data.
In some embodiments, a k-v database is established;
one of the embodiments of the present specification provides a tamper-resistant blockchain data storage method, including: establishing a k-v database; acquiring a transaction, packaging the signed transaction into a block by an organization node, and constructing a binary search tree for the block, wherein a data structure of the transaction in the block comprises a transaction key value; generating a hash-based index for each non-leaf node of the binary search tree; storing an index of each of the non-leaf nodes of the binary search tree to the k-v database; and the mechanism node receives a query request sent by a user node and feeds back query information to the user node based on the binary search tree.
Drawings
The present description will be further explained by way of exemplary embodiments, which will be described in detail by way of the accompanying drawings. These embodiments are not intended to be limiting, and in these embodiments like numerals are used to indicate like structures, wherein:
FIG. 1 is a block schematic diagram of a tamper-resistant blockchain data storage system in accordance with some embodiments of the present description;
FIG. 2 is a schematic illustration of water quality information that needs to be obtained for different types of wastewater as shown in some embodiments herein;
FIG. 3 is a schematic diagram of a binary search tree of blocks shown in accordance with some embodiments of the present description;
FIG. 4 is a schematic diagram illustrating a binary search tree data before and after insertion with a root node empty in accordance with some embodiments of the present description;
FIG. 5 is a schematic diagram of a binary search tree before and after insertion of data having a key value of newly inserted data that is less than a key value of a branch node, in accordance with some embodiments of the present description;
FIG. 6 is a schematic diagram of a binary search tree data before and after insertion with a key value of newly inserted data less than a key value of a branch node and a right child of the branch node being empty, in accordance with some embodiments of the present description;
FIG. 7 is a schematic diagram of a binary search tree data before and after insertion, according to some embodiments of the present description, where the key value of the newly inserted data is greater than the key value of a branch node and the right child of the branch node is not empty;
fig. 8 is an exemplary flow diagram of a tamper-resistant blockchain data storage method, shown in some embodiments herein.
Detailed Description
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only examples or embodiments of the present description, and that for a person skilled in the art, the present description can also be applied to other similar scenarios on the basis of these drawings without inventive effort. Unless otherwise apparent from the context, or otherwise indicated, like reference numbers in the figures refer to the same structure or operation.
It should be understood that "system", "apparatus", "unit" and/or "module" as used herein is a method for distinguishing different components, elements, parts, portions or assemblies at different levels. However, other words may be substituted by other expressions if they accomplish the same purpose.
As used in this specification and the appended claims, the terms "a," "an," "the," and/or "the" are not intended to be inclusive in the singular, but rather are intended to be inclusive in the plural, unless the context clearly dictates otherwise. In general, the terms "comprises" and "comprising" merely indicate that steps and elements are included which are explicitly identified, that the steps and elements do not form an exclusive list, and that a method or apparatus may include other steps or elements.
Flow charts are used in this description to illustrate operations performed by a system according to embodiments of the present description. It should be understood that the preceding or following operations are not necessarily performed in the exact order in which they are performed. Rather, the various steps may be processed in reverse order or simultaneously. Meanwhile, other operations may be added to the processes, or a certain step or several steps of operations may be removed from the processes.
The existing distributed account book is mainly realized based on a bit currency network, and has many defects, for example, 1, the amount of received data is severely limited, specifically, the existing bit currency network processes 1M data in 10 minutes, and runs for 10 years, about 280G data is accumulated, so that the amount of data which can be received subsequently is limited; 2. the transaction efficiency is low, specifically, the transaction number per second of the bitcoin block chain is 7, the transaction number per second of the ether house is 10 to 20, and the transaction number per second of the wiki chain can reach 1000+, but the transaction under the scene of vigorous demand cannot be met; 3. the transaction verification time is long, specifically, taking bitcoin as an example, the one-time confirmation time of the current bitcoin transaction is about 10 minutes on average, which is also the generation time of one block. In case of 6 confirmations, it is necessary to wait for 1 hour; 4. the delay of data confirmation is high, specifically, when 2 or more nodes compete for the accounting right on the network at the same time, 2 or more block chain branches are generated in the network, and at this time, which branch records the data is valid, the next accounting period is waited for, and finally the longest block chain branch is used to determine.
Therefore, it is desirable to provide a tamper-resistant blockchain data storage method and system, which are used to apply blockchain technology to database management to improve data throughput and transaction efficiency.
FIG. 1 is a block schematic diagram of a tamper-resistant blockchain data storage system, according to some embodiments of the present description. As shown in fig. 1, a tamper-resistant blockchain data storage system may include a storage layer, a network layer, a blockchain layer, and an application layer.
The storage layer is a k-v database and is responsible for storing data in a distributed mode, and multiple copies are backed up for each blockchain.
The network layer may be responsible for data transmission between nodes and determining the block order according to a consensus protocol. The nodes are composed of mechanism nodes and user nodes, each mechanism node is a storage node and is used for storing data information of the mechanism, and the data information can comprise one database or a plurality of databases. When data related to a user is added or modified, the data needs to be signed and approved by the organization node and the user node together; and (4) encapsulating the signed data into a block by the mechanism node, and when the size of the block reaches a certain threshold value, packaging and sending the block to other mechanism nodes for verification. And verifying the correctness of the blocks according to a consensus algorithm among the mechanism nodes, and determining the sequence of the blocks. The organization node sends the blocks which are verified to be correct to other organization nodes for storage, and broadcasts the block headers to all nodes including all organization nodes and user nodes.
When the query operation is carried out, a user sends a query request to the storage node, the storage node returns the queried record item and the query path, and the user can verify the correctness of the query result according to the query path and the block header information.
The blockchain layer may be used to display the world state of the blockchain.
The intelligent contracts, chain code, and decentralized applications constitute an application layer. The application layer includes programs that an operator uses to communicate with the blockchain network, of which scripts, Application Programming Interfaces (APIs), user interfaces, and frameworks are a part. The application layer may perform a query operation on the blockchain data according to the world state of the blockchain displayed by the blockchain layer, and perform further analysis processing on the queried data, for example, perform data management, credit evaluation, and the like.
Adding records: when data is added for the first time, a data owner specifies a public key capable of data writing operation, generates an authority locking script, and then signs the data by using a private key of the data owner.
In a tamper-resistant blockchain data storage system, data operations may include adding records, modifying records, looking up records, and deleting records.
Adding records: when data is added for the first time, a data owner specifies a public key capable of data writing operation, generates an authority locking script, and then signs the data by using a private key of the data owner.
And (3) modifying the record: the operator signs the father record by the private key of the operator, then verifies whether the signature can unlock the locking script of the father record, and only under the condition of unlocking the locking script, the record with the same key value can be added, so that the father record can be modified. Wherein the rights lock script is only modifiable by the data owner. It should be noted that the data modification does not conflict with the data tamper-proofing, the data of the corresponding version cannot be modified, and the modification history of the data, although not modifiable, supports the data to be updated from the older version to the new version. It will be appreciated that the modification of the data is effected by writing a new transaction.
Searching for records: all participants can perform a lookup operation, which returns the latest value as a valid value, but can view the complete modification history of the record through a tracing operation.
And deleting the record: once added, the data cannot be deleted, and when the data is modified multiple times and is in a very old version, specific information of the data can be deleted in order to save disk space, but the hash value of the data needs to be permanently saved.
FIG. 2 is a diagram of a data structure for transactions in blocks, shown in accordance with some embodiments of the present description. As shown in fig. 2, the data structure of the transaction in the block includes a transaction header and transaction data, where the transaction header includes a version number, a parent transaction hash, a transaction time, a transaction next owner public key, and a signature for proving that the transaction is valid; the transaction data includes a transaction key value and at least one field. The authority management and the non-tampering and traceability of the data are realized through the transaction head part, and various types of data are recorded through the transaction data. Where the parent transaction hash points to the previous transaction of the same transaction key value.
It can be understood that, when data is written, whether a transaction with a key value as a transaction key value exists is firstly inquired; if the signature is valid, checking whether the signature for proving that the current transaction is valid is matched with the signature for proving that the current transaction is valid, and considering that the current transaction is valid only under the condition of matching; if the transaction key value is the 1 st occurrence, the parent transaction hash for the transaction is set to 0. When data reading is carried out, retrieval is carried out according to the transaction key value, the latest query result is returned, but source tracing can be carried out according to the parent transaction hash in the transaction.
The facility nodes may also be used to construct a binary search tree for the blocks. In some embodiments, the binary search Tree may be generated based on a Red Black Tree and a merkel Tree, where the Red Black Tree (Red Black Tree) is a self-balancing binary search Tree, and may be searched and inserted in o (log n) time, and one reason for selecting the binary search Tree based on the Red Black Tree and the merkel Tree to construct a block is that the Red Black Tree grows from bottom to top as the Red Black Tree and the merkel Tree (Merkle trees), so that it can be ensured that a parent node is hashed by child nodes, and when a new node is inserted, parent node information may be updated accordingly. In some embodiments, to improve the efficiency of searching and inserting, for each non-leaf node, the non-leaf node is configured to store a key value of the non-leaf node, a hash value of the left sub-tree, and a hash value of the right sub-tree, where the key value in the left sub-tree of the non-leaf node is less than or equal to the key value of the non-leaf node, and the key value in the right sub-tree of the non-leaf node is greater than the key value of the non-leaf node. Wherein the key value of the non-leaf node is the largest key value in the left sub-tree of the non-leaf node.
The organization node is further configured to generate a hash-based index for each non-leaf node (e.g., a root node or a branch node) of the binary search tree, and the k-v database of the storage layer is further configured to store an index for each non-leaf node of the binary search tree, where the index for each non-leaf node is mapped based on the hash value of the non-leaf node, and the hash value of the left sub-tree of the non-leaf node, the hash value of the right sub-tree of the non-leaf node, and the key value of the non-leaf node may be hashed to determine the hash value of the non-leaf node. The hash value for a certain non-leaf node may be determined based on the following equation:
Hash(Node)=Hash(lefthash, righthash, key);
wherein the content of the first and second substances,Hash(Node) Is the hash value of a non-leaf node,lefthashis the hash value of the left sub-tree of the non-leaf node,righthashis the hash value of the right sub-tree of the non-leaf node,keyis the key value of the non-leaf node.
FIG. 3 is a schematic diagram of a binary search tree of blocks shown in accordance with some embodiments of the present description. As shown in fig. 3, there are 6 transaction records: data1, Data2, …, Data 6; each transaction record has a key value of 5, 8, 10, 12, 15, 16, respectively. And storing the 6 transaction records into 6 leaf nodes from left to right according to the key value from small to large. Since the key value of the non-leaf node is the largest key value in the left sub-tree of the non-leaf node, the branch node of the third level: (Node1、Node2、Node3) Is/are as followsCritical values of 5, 10, 15, respectively, branch nodes of the second level: (Node4) The key value of (c) is 8 and the key value of the root node (root) is 12. The branch nodes store the hash values and key values of the left and right subtrees, and the key values in the left subtree of the branch node are ensured to be less than or equal to the key value of the branch node, and the key values in the right subtree are ensured to be greater than the key value of the branch node.
When data insertion is needed, inserting data from a root node, and if the key value of the transaction record is less than or equal to the key value of the root node, inserting the data into a left sub-tree of the root node; if it is greater than the key value of the root node, insert into the right sub-tree of the root node.
Fig. 4 is a schematic diagram of binary search tree data before and after insertion with a root node being empty according to some embodiments of the present disclosure, and as shown in fig. 4, it can be understood that when the root node of the binary search tree is empty, a leaf node may be newly created firstNode1 for storing newly inserted data and creating a branch nodeNode2 and defining the branch nodeNode2 left child is the leaf node mentioned aboveNode1. This also means that as long as the binary search tree is not empty, its branch nodes must not be empty, and the key value of the last level of branch nodes must be the same as the key value of its left child.
FIG. 5 is a schematic diagram of a binary search tree before and after insertion of data having a key value of newly inserted data less than a key value of a branch node, as shown in FIG. 5, it being understood that when the key value of the newly inserted data is less than the key value of a branch node, the newly inserted data should be inserted into the branch nodeNode1, when the left child of the branch node is not empty and is a leaf nodeNode2 hours, a new leaf node can be builtNode3 storing the newly inserted data and then creating a new branch nodeNode4, the key of which is the key value of the newly inserted data, the branch nodeNode4, the left child is a newly-built leaf nodeNode3, the branch nodeNodeThe right child of 4 is a branch nodeNode1 (i.e., leaf node)Node2) The branch nodeNode4 as branch nodeNode1。
FIG. 6 is a schematic diagram of data before and after insertion of a binary search tree with a newly inserted data key value less than the branch node key value and the branch node right child being empty, as shown in FIG. 6, according to some embodiments of the present description, it being understood that if the newly inserted data key value is greater than the branch node key valueNode1, and the branch nodeNode1, if the right child is empty, directly creating a new leaf nodeNode2 storing data and defining it as new leaf nodeNode2 is a branch nodeNode1, right child.
It will be appreciated that if the key value of the newly inserted data is greater than the branch nodeNode1, and is located at the branch nodeNodeThe right child of the key value of 1 is not empty, and the leaf node can be newly built firstNode2 storing data and then building new branch nodeNode3, the branch nodeNodeThe key value of 3 is the key value of the newly inserted data and the original branch node (i.e., the branch node)Node1) The smaller of the key values of the right child of, the branch nodeNodeThe left child of 3 is the smaller of the newly inserted data and the key value of the right child of the original branch nodeNode3 right child is larger, the branch nodeNode3 as the original branch node (i.e. branch node)Node1). FIG. 7 is a schematic diagram of data before and after insertion of a binary search tree according to some embodiments of the present disclosure, wherein the key value of the newly inserted data is greater than the key value of a branch node and the right child of the branch node is not empty, and the key value of the newly inserted data is less than the original branch node (i.e., the branch node), as shown in FIG. 7Node1) Right child of (i.e. branch node)Node4) The key value of (2) then creates a branch nodeNode3, the left child is a newly-built leaf nodeNode2, newly building branch nodeNodeThe right child of 3 is a branch nodeNode4。
After data is inserted, a binary search tree starting from a root node can be obtained, the hash value of each node is completely mapped into a hash-based non-falsifiable index, data is written into a memory block firstly, when the size of the memory block reaches a certain threshold value, the block is written into a disk sequentially, and the corresponding index is stored into a k-v database, wherein the storage format in the k-v database is as follows: k = Hash (lefthash, righthash, key), v = (lefthash, righthash, key). In some embodiments, the threshold of the memory block size is preset, for example, the threshold of the memory block size may be set to the number of transactions in the block to 1024. It is understood that the threshold of the memory block size may be set according to the hardware configuration.
It can be understood that, the blockchain database requires that its data satisfy the non-tamper property, and the index to the data should also be non-tamper, and the defined blocks are not modifiable once formed, so that a binary search tree is constructed for each block, and then the data and the binary search tree are hashed together, thereby implementing the non-tamper of the data and the index.
When data is required to be searched, a target key value can be obtained based on a query request; searching in the memory block of the structure node based on the target key value, and judging whether a target leaf node exists in the memory block or not; if the target leaf node does not exist in the memory block, repeatedly executing the step of obtaining the index of the previous block from the k-v database according to the sequence of the blocks, and judging whether the target leaf node exists in the previous block or not until the leaf node is inquired or the target leaf node does not exist in all the blocks.
In some embodiments, when retrieving a target leaf node in a block, the retrieval may be started from a root node of a binary search tree, and if a target key value is less than or equal to the root node of the binary search tree, it is determined whether the target leaf node exists in a left sub-tree of the root node, and if the target key value is greater than the root node of the binary search tree, it is determined whether the target leaf node exists in a right sub-tree of the root node, where the target leaf node is a leaf node whose key value is equal to the target key value. Still taking fig. 3 as an example, when the target key value is 8, starting with the root node of the binary search tree, the target key value (8) is less than the key value (12) of the root node of the binary search tree, and therefore,finding whether there is a target leaf node in the left sub-tree of the root node, and associating the target key value (8) with the next branch node in the left sub-tree of the root node: (Node4) Is compared, the target key value (8) is equal to the branch node: (Node4) Is required at the branch node, thereforeNode4) Finding whether a target leaf node exists in the left sub-tree of (1), and connecting a target key value (8) with a branch node (c)Node4) The next branch node in the left sub-tree of (a)Node1) Is compared, the target key value (8) is greater than the branch node: (Node1) Thus, the branch node is obtained: (Node1) Judging whether the key value of the right child is a target key value, if so, successfully inquiring and acquiring data stored by a target leaf node; if the key value of the right child is not the target key value, the transaction record to be searched is not in the block.
Fig. 8 is an exemplary flowchart of a tamper-resistant blockchain data storage method according to some embodiments of the present disclosure, and as shown in fig. 8, one of the embodiments of the present disclosure provides a tamper-resistant blockchain data storage method, including: establishing a k-v database; acquiring a transaction, packaging the signed transaction into a block by an organization node, and constructing a binary search tree for the block, wherein a data structure of the transaction in the block comprises a transaction key value; for each non-leaf node of the binary search tree, generating a hash-based index; storing the index of each non-leaf node of the binary search tree to a k-v database; and the mechanism node receives the query request sent by the user node and feeds back query information to the user node based on the binary search tree. A tamper-resistant blockchain data storage method may be performed by the tamper-resistant blockchain data storage system shown in fig. 1 to fig. 1, and further description on the tamper-resistant blockchain data storage method may refer to the relevant description of the tamper-resistant blockchain data storage system, which is not described herein again.
Most of the current blockchain technologies adopt a middleware to achieve a target of blockchain application, and the tamper-resistant blockchain data storage method or system provided in some embodiments of the present specification combines a database kernel technology with a blockchain technology to achieve a high-performance, high-concurrency, and data tamper-resistant blockchain database technology. The working mode and the technical scheme of adopting the database kernel layer to introduce the block chain technology and simultaneously supporting the upper application have at least the following advantages: 1. the transaction performance of the block chain is improved by 5-10 times, the concurrent transaction amount of the traditional block chain technology can only reach 3000 pens/second generally, and the tamper-proof block chain data storage method or system provided by some embodiments of the present disclosure enables the transaction concurrent performance to reach more than 10000 pens/second and 15000 pens/second. 2. The traditional block chain technology data tamper-proofing adopts a distributed Hash mode to achieve tamper-proofing, if an illegal person obtains data of more than half of nodes, the data can be restored, and the purpose of modifying the data is achieved.
It should be noted that the above description of the tamper-resistant blockchain data storage system and its modules is for convenience of description only and should not limit the scope of the present disclosure to the illustrated embodiments. It will be appreciated by those skilled in the art that, given the teachings of the present system, any combination of modules or sub-system configurations may be used to connect to other modules without departing from such teachings. Such variations are within the scope of the present disclosure.
Having thus described the basic concept, it will be apparent to those skilled in the art that the foregoing detailed disclosure is to be regarded as illustrative only and not as limiting the present specification. Various modifications, improvements and adaptations to the present description may occur to those skilled in the art, although not explicitly described herein. Such alterations, improvements, and modifications are intended to be suggested hereby, and are intended to be exemplary of the principles of the invention.
Also, the description uses specific words to describe embodiments of the description. Reference throughout this specification to "one embodiment," "an embodiment," and/or "some embodiments" means that a particular feature, structure, or characteristic described in connection with at least one embodiment of the specification is included. Therefore, it is emphasized and should be appreciated that two or more references to "an embodiment" or "one embodiment" or "an alternative embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, some features, structures, or characteristics of one or more embodiments of the specification may be combined as appropriate.
Additionally, the order in which the elements and sequences of the process are recited in the specification, the use of alphanumeric characters, or other designations, is not intended to limit the order in which the processes and methods of the specification occur, unless otherwise specified in the claims. While various presently contemplated embodiments of the invention have been discussed in the foregoing disclosure by way of example, it is to be understood that such detail is solely for that purpose and that the appended claims are not limited to the disclosed embodiments, but, on the contrary, are intended to cover all modifications and equivalent arrangements that are within the spirit and scope of the embodiments herein. For example, although the system components described above may be implemented by hardware devices, they may also be implemented by software-only solutions, such as installing the described system on an existing server or mobile device.
Similarly, it should be noted that in the preceding description of embodiments of the present specification, various features are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure aiding in the understanding of one or more of the embodiments. This method of disclosure, however, is not intended to imply that more features than are expressly recited in a claim. Indeed, the embodiments may be characterized as having less than all of the features of a single embodiment disclosed above.
For each patent, patent application publication, and other material, such as articles, books, specifications, publications, documents, etc., cited in this specification, the entire contents of each are hereby incorporated by reference into this specification. Except where the application history document does not conform to or conflict with the contents of the present specification, it is to be understood that the application history document, as used herein in the present specification or appended claims, is intended to define the broadest scope of the present specification (whether presently or later in the specification) rather than the broadest scope of the present specification. It is to be understood that the descriptions, definitions and/or uses of terms in the accompanying materials of this specification shall control if they are inconsistent or contrary to the descriptions and/or uses of terms in this specification.
Finally, it should be understood that the embodiments described herein are merely illustrative of the principles of the embodiments of the present disclosure. Other variations are also possible within the scope of the present description. Thus, by way of example, and not limitation, alternative configurations of the embodiments of the specification can be considered consistent with the teachings of the specification. Accordingly, the embodiments of the present description are not limited to only those embodiments explicitly described and depicted herein.

Claims (10)

1. A tamper-resistant blockchain data storage system, comprising:
the storage layer is a k-v database and is used for storing data in a distributed mode and backing up a plurality of copies for each blockchain;
the network layer is used for data transmission among nodes and determining the sequence of the blocks according to a consensus protocol, wherein the nodes comprise user nodes and mechanism nodes, and the mechanism nodes comprise at least one database; the organization node is used for packaging the signed transaction into a block and constructing a binary search tree for the block, wherein a data structure of the transaction in the block comprises a transaction key value; said organization node further configured to generate a hash-based index for each non-leaf node of said binary search tree, said k-v database further configured to store an index for each said non-leaf node of said binary search tree; and the structure node is also used for receiving the query request sent by the user node and feeding back query information to the user node based on the binary search tree.
2. The tamper-resistant blockchain data storage system of claim 1, wherein the data structure of the transactions in the block includes a transaction header and transaction data, wherein the transaction header contains a version number, a parent transaction hash, a transaction time, a transaction next owner public key, a signature to prove the transaction valid; the transaction data includes the transaction key value and at least one field.
3. The tamper-resistant blockchain data storage system of claim 1, wherein the binary search tree is generated based on a red-black tree and a Merkel tree.
4. The tamper-resistant blockchain data storage system of claim 3, wherein constructing the binary search tree comprises:
storing transaction records in leaf nodes of the binary search tree;
for each non-leaf node, the non-leaf node is configured to store a key value of the non-leaf node, a hash value of a left sub-tree, and a hash value of a right sub-tree, the key values in the left sub-tree of the non-leaf node are all less than or equal to the key value of the non-leaf node, and the key values in the right sub-tree of the non-leaf node are all greater than the key value of the non-leaf node.
5. The tamper-resistant blockchain data storage system of claim 4, wherein constructing the binary search tree further comprises:
the key value of the non-leaf node is the maximum key value in the left sub-tree of the non-leaf node.
6. The tamper-resistant blockchain data storage system of claim 5, wherein constructing the binary search tree further comprises:
and carrying out hash operation on the hash value of the left sub-tree of the non-leaf node, the hash value of the right sub-tree of the non-leaf node and the key value of the non-leaf node to determine the hash value of the non-leaf node.
7. The tamper-resistant blockchain data storage system of any one of claims 1 to 6, wherein the structure node feeds back query information to the user node based on the binary search tree, including:
acquiring a target key value based on the query request;
searching in the memory block of the structure node based on the target key value, and judging whether a target leaf node exists in the memory block;
if the target leaf node does not exist in the memory block, repeatedly executing the step of obtaining the index of the previous block from the k-v database according to the sequence of the blocks, and judging whether the target leaf node exists in the previous block or not until the leaf node is inquired or the target leaf node does not exist in all the blocks.
8. The tamper-resistant blockchain data storage system of claim 7, wherein the structure node feeds back query information to the user node based on the binary search tree, comprising:
for the memory block or the previous block,
searching from the root node of the binary search tree, if the target key value is less than or equal to the root node of the binary search tree, judging whether the target leaf node exists in the left sub-tree of the root node, and if the target key value is greater than the root node of the binary search tree, judging whether the target leaf node exists in the right sub-tree of the root node, wherein the target leaf node is a leaf node of which the key value is equal to the target key value.
9. The tamper-resistant blockchain data storage system of any one of claims 1 to 6, wherein the system further comprises:
the block chain layer is used for displaying the world state of the block chain;
and the application layer is used for carrying out data query operation and further analyzing and processing the queried data.
10. A tamper-resistant blockchain data storage method, comprising:
establishing a k-v database;
acquiring a transaction, packaging the signed transaction into a block by an organization node, and constructing a binary search tree for the block, wherein a data structure of the transaction in the block comprises a transaction key value;
generating a hash-based index for each non-leaf node of the binary search tree;
storing an index of each of the non-leaf nodes of the binary search tree to the k-v database;
and the mechanism node receives a query request sent by a user node and feeds back query information to the user node based on the binary search tree.
CN202210883403.XA 2022-07-26 2022-07-26 Tamper-proof block chain data storage method and system Pending CN115081031A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210883403.XA CN115081031A (en) 2022-07-26 2022-07-26 Tamper-proof block chain data storage method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210883403.XA CN115081031A (en) 2022-07-26 2022-07-26 Tamper-proof block chain data storage method and system

Publications (1)

Publication Number Publication Date
CN115081031A true CN115081031A (en) 2022-09-20

Family

ID=83242624

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210883403.XA Pending CN115081031A (en) 2022-07-26 2022-07-26 Tamper-proof block chain data storage method and system

Country Status (1)

Country Link
CN (1) CN115081031A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109165224A (en) * 2018-08-24 2019-01-08 东北大学 A kind of indexing means being directed to keyword key on block chain database
CN109408551A (en) * 2018-08-06 2019-03-01 杭州复杂美科技有限公司 Data query method and system, common recognition method and system, equipment and storage medium
CN114020737A (en) * 2021-10-20 2022-02-08 大连理工江苏研究院有限公司 Efficient and reliable indexing method for block chain data

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109408551A (en) * 2018-08-06 2019-03-01 杭州复杂美科技有限公司 Data query method and system, common recognition method and system, equipment and storage medium
CN109165224A (en) * 2018-08-24 2019-01-08 东北大学 A kind of indexing means being directed to keyword key on block chain database
CN114020737A (en) * 2021-10-20 2022-02-08 大连理工江苏研究院有限公司 Efficient and reliable indexing method for block chain data

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
焦通等: "区块链数据库:一种可查询且防篡改的数据库", 《软件学报》 *

Similar Documents

Publication Publication Date Title
CN109165224B (en) Indexing method for key words on block chain database
RU2744054C2 (en) Device and method of storing data, checking data and binding data
CN110495132B (en) System and method for generating, uploading and executing code blocks within distributed network nodes
CN110785760B (en) Method and system for registering digital documents
US20190327094A1 (en) Information authentication method and system
JP4991283B2 (en) Additional hash functions in content-based addressing
US20210099283A1 (en) Pruning entries in tamper-evident data stores
CN108039943B (en) Verifiable encryption searching method
US11907199B2 (en) Blockchain based distributed file systems
US20100212017A1 (en) System and method for efficient trust preservation in data stores
CN111461751B (en) Real estate information chain organization method based on block chain, historical state tracing method and device
WO2020167887A1 (en) Hybrid blockchains and streamchains using non-crypto hashes for securing audio-, video-, image-, and speech-based transactions and contracts
EP2064637B1 (en) Method for dynamic secure management of an authenticated relational table in a database
US20210165890A1 (en) Cross-partition calls in partitioned, tamper-evident data stores
US8510566B1 (en) Authentic time-stamping for archival storage
US11868339B2 (en) Blockchain based distributed file systems
CN112685436A (en) Traceability information processing method and device
CN111159482A (en) Data verification method and system
US20060106857A1 (en) Method and system for assured document retention
US6941477B2 (en) Trusted content server
CN111858627A (en) Academic degree and academic calendar query system and method based on block chain
CN115081031A (en) Tamper-proof block chain data storage method and system
CN111767168B (en) Block chain-based storage system facilitating data backtracking
CN113094754B (en) Big data platform data modification system and modification, response, cache and verification method
CN111460436B (en) Unstructured data operation method and system based on blockchain

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
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20220920