A Verifiable Blockchain Indexing Method Supporting Boolean Queries and Range Queries

By introducing fixed window accumulators and related data structures into the blockchain system, the blockchain system's inefficiency and credibility guarantee problems in Boolean query and scope query are solved, and efficient and trustworthy query processing is achieved.

CN117131049BActive Publication Date: 2025-07-01BEIJING INST OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311090767.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-28
Publication Date
2025-07-01
Estimated Expiration
2043-08-28

AI Technical Summary

Technical Problem

Existing blockchain systems have problems inefficiency and credibility assurance in supporting Boolean queries and scope queries, especially the latency and untrustworthiness of off-chain databases.

Method used

A verifiable blockchain indexing method based on fixed window accumulator is proposed, including FWA-ObjReg-tree, FWA-trie and FWA-B+-tree data structures. Through these data structures, Boolean query and scope query are supported, and the public key management problem of cryptographic accumulator is overcome.

Benefits of technology

This method improves query efficiency and index construction speed, reduces the size and calculation overhead of the accumulator public key, enhances the credibility of query results, and saves storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117131049B_ABST
    Figure CN117131049B_ABST
Patent Text Reader

Abstract

The present invention provides a verifiable blockchain indexing method that supports Boolean queries and range queries, which relates to the field of blockchain technology. The method specifically includes: proposing a fixed-window accumulator blockchain indexing construction method, called the FWA blockchain indexing construction method; the FWA blockchain indexing construction method is to divide all blocks in the blockchain system into regions, and each divided region is called a time window. Taking the time window as a unit, the FWA blockchain index is constructed in the form of a Merkle hash tree; according to the FWA blockchain indexing construction method, three data structures for indexing and verification are constructed, namely, an object registration tree based on a fixed-window accumulator, a trie tree based on a fixed-window accumulator, and a B+ tree based on a fixed-window accumulator, and the trusted query task processing is performed based on the above three data structures; it overcomes the public key management problem of the verifiable index structure of the cryptographic accumulator and saves the space overhead occupied by index construction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a verifiable blockchain indexing method supporting Boolean queries and range queries. Background Art

[0002] To meet users' requirements for query types and performance in blockchain system applications, there are currently two most common methods. One is to map on-chain block data to an off-chain external database, that is, reorganize and map on-chain block data to an existing mature database system, making full use of the high query efficiency and rich query types of the existing database system. The other is to maintain a corresponding index structure in the blockchain system for specific query requirements to accelerate query efficiency.

[0003] The paper "VQL: Efficient and Verifiable Cloud Query Services for Blockchain Systems" published in IEEE Transactions on Parallel and Distributed Systems, Volume 33, Issue 6, pages 1393-1406 in 2022 introduced a query method by mapping on-chain data to an off-chain cloud database. In this paper, the blockchain system reorganizes all block data within a fixed time period into a micro-database and synchronizes the micro-database to the cloud database system, and all micro-databases are also merged into a total database in the cloud. The total database in the cloud can be implemented relying on existing mature database systems, and using the rich query functions provided by these mature database systems to meet users' query requirements.

[0004] The paper "Authenticated Keyword Search in Scalable Hybrid-Storage Blockchains" published in the 996-1007 pages of the 2021 IEEE 37th International Conference on Data Engineering introduced a method for implementing keyword queries by maintaining an index structure on-chain using Ethereum smart contracts in a hybrid storage model. In this paper, the original data is managed by a storage service provider. In the blockchain system, only the keywords corresponding to each off-chain original data object are stored through smart contracts, and a Merkle inverted index based on the MB tree is maintained on-chain for each keyword at the same time for verifiable keyword queries. Since all data objects have a serial number that increases in the order of being uploaded to the chain, based on this, a verifiable "AND" query for multiple keywords is implemented on multiple MB trees.

[0005] For users, neither full nodes nor storage service providers are trustworthy. Therefore, in addition to query results, users also need to be provided with a trustworthy guarantee that can ensure the correctness and integrity of the results. This kind of trustworthy guarantee is currently mainly achieved based on trusted hardware and on authenticated data structures (ADS).

[0006] The ADS-based method can be further divided into ADS based on Merkle hash trees and ADS based on cryptographic accumulators. The ADS based on Merkle hash trees mainly adds a hash value field for nodes. The hash value of a leaf node is the hash value of the data saved by the leaf node, and the hash value of a non-leaf node is the value obtained by concatenating the hash values of the child nodes of the non-leaf node and then performing a hash operation. Finally, the obtained root hash value is saved in the block header. Using the ADS based on Merkle hash trees, a verifiable object VO can be generated synchronously during the query operation to provide users with a trustworthy proof of the query result. For example, the Merkle Patricia Tree for keyword queries and the Merkle B+Tree for numerical range queries.

[0007] Cryptographic accumulators can prove the existence of a certain element in a set. Based on this feature, operations and proofs between sets can be performed, which enables the ADS based on cryptographic accumulators to achieve trustworthy queries for boolean queries between multiple attributes.

[0008] There are two problems with the method of mapping on-chain block data to an off-chain external database: The first is that when storing blockchain data in other database systems, the data needs to be reorganized and stored, and there is a delay in this process, which cannot meet the needs of users for real-time queries. The second is that the off-chain database cannot guarantee that the data will not be tampered with, and it may send incorrect or incomplete query results to users. Although the method of constructing ADS can be used to ensure the trustworthiness of query results, the verification object VO needs to include all the data of one or more blocks, resulting in a large communication overhead.

[0009] To ensure the trustworthiness of query results, the solution of constructing an index on-chain needs to construct an ADS based on Merkle hash trees or an ADS based on cryptographic accumulators. However, the former supports a relatively single type of query and does not support boolean queries, while the latter has the problem of public key management of cryptographic accumulators. Summary of the Invention

[0010] The method of the present invention proposes a verifiable blockchain indexing method that supports boolean queries and range queries. By proposing a construction method of a fixed window accumulator (FWA) blockchain index, and on this basis, three data structures for indexing and verification are proposed: an object registration tree based on the fixed window accumulator (FWA-ObjReg-tree), a trie tree based on the fixed window accumulator (FWA-trie), and a B+ tree based on the fixed window accumulator (FWA-B+-tree), as well as a trusted query task processing process based on the above three data structures; it overcomes the public key management problem of the verifiable index structure of cryptographic accumulators.

[0011] Step 1: Propose a construction method of a fixed window accumulator blockchain index, called the FWA blockchain index construction method;

[0012] The FWA blockchain index construction method includes: dividing every k blocks in the blockchain system into a region, and calling each divided region a time window, where k is the size of the time window and k is a positive integer greater than 2; taking the time window as a unit, constructing the FWA blockchain index in the form of a Merkle hash tree. The method is: within the same time window, when constructing the index of the current block, copy the index root node of the previous block, start inserting the data objects of the current block from this copy of the index root node, traverse from this copy of the index root node according to the index structure in the previous block, copy all non-leaf nodes on all traversal paths in sequence during the traversal, and save each copied non-leaf node into an array until reaching the insertion position of the data object inserted in this block, and create a new leaf node or copy and update the original leaf node at this position to complete the insertion of the data object. Reverse-modify the successor child pointers and hash values of all non-leaf nodes in the array, so that the successor child pointers originally pointing to the nodes in the previous block point to the next non-leaf node in the array, and the non-successor child pointers are not modified and still reuse all the nodes provided by the previous block index that are not on the traversal path to complete the index construction;

[0013] Step 2: Construct an index structure according to the FWA blockchain index construction method;

[0014] Step 2-1: Obtain data objects and pack the data objects into the block body of the current block to be submitted;

[0015] Step 2-2: In the current block, construct an index structure according to the FWA blockchain index construction method;

[0016] The index structure includes: an object registration tree FWA-ObjReg-tree based on a fixed-window accumulator, a keyword index structure FWA-trie based on a fixed-window accumulator, and a numerical attribute range query index FWA-B+-tree based on a fixed-window accumulator;

[0017] Further, the construction method of the object registration tree FWA-ObjReg-tree based on a fixed-window accumulator is as follows: construct the FWA-ObjReg-tree according to the FWA blockchain index construction method, map the hash value of the data object to the data object identity ObjectID, and construct the FWA-ObjReg-tree in the form of a multi-way Merkle hash tree. In the FWA-ObjReg-tree, there are leaf nodes and non-leaf nodes of the FWA-ObjReg-tree. Among them, the leaf nodes of the FWA-ObjReg-tree store the hash values h of all data objects from the first block to the current block within the current time window i , and h i =H(o i ), where H(·) is a cryptographic hash function; the non-leaf nodes of the FWA-ObjReg-tree store the hash value obtained by concatenating the hash values stored in all its child nodes and then performing a hash operation;

[0018] The mapping rule for mapping the hash value of a data object to the data object identity is: the data object identity ObjectID corresponding to the hash value of the data object on a certain leaf node is the path value from the root node to the leaf node in the FWA-ObjReg-tree;

[0019] The construction method of the keyword index structure FWA-trie based on a fixed-window accumulator is: construct the keyword index structure FWA-trie based on a Merkle Patricia tree, including: leaf nodes of the FWA-trie, non-leaf non-root nodes of the FWA-trie, and the root node of the FWA-trie;

[0020] The leaf nodes of the FWA-trie include: a keyword string field ε n , a set field S n , an accumulator field acc n , and a hash value field h n ; the non-leaf non-root nodes of the FWA-trie include: a keyword string field ε n , a child hash field childHash n , and a hash value field h n; The root node of the FWA-trie includes: keyword string field ε n , set field S n , child hash field childHash n , accumulator field acc n , hash value field h n ;

[0021] Construct the FWA-trie according to the index construction method of FWA. During the construction process, it is necessary to continuously insert the keyword of the data object to be inserted and the data object identity identifier ObjectID into the index structure. During the insertion process, it is necessary to maintain the acc on the root node and leaf node on the insertion path n , S n , and the method is: it is necessary to perform incremental update on acc n , add the ObjectID of the data object to be inserted to the set of S n , and at the same time update the acc on this node correspondingly n . If the insertion position of this data object finally reached is an empty node, it is necessary to create a new leaf node, and the value of the acc of this leaf node n is the accumulated value obtained from the ObjectID of the data object to be inserted, and S n consists only of the ObjectID of the data object to be inserted;

[0022] The construction method of the numerical attribute range query index FWA-B+-tree based on the fixed window accumulator is: based on the Merkle B+ tree, construct the numerical attribute range query index FWA-B+-tree only according to the numerical attributes of the data object, including: the leaf nodes of the FWA-B+-tree, the non-leaf nodes of the FWA-B+-tree;

[0023] The leaf nodes of the FWA-B+-tree include: numerical attribute value field v n , set field S n , accumulator field acc n , hash value field h n ; The non-leaf nodes of the FWA-B+-tree include: numerical range field Range[l n , u n , where l n , u n are respectively the minimum and maximum values of the numerical attributes of all data objects saved in the subtree with the current node as the root node, set field S n , accumulator field acc n , child hash field childHash n , hash value field h n;

[0024] Construct the FWA - B+-tree according to the indexing construction method of FWA. During the construction process, it is necessary to continuously insert the numerical attribute value value and the data object identity identifier ObjectID of the data object to be inserted into the index structure. During this insertion process, it is necessary to maintain the acc of all nodes on the insertion path n and S n , and the maintenance rule is the same as the maintenance rule in the FWA - trie. At the same time, it is also necessary to maintain the numerical range fields of non - leaf nodes on all paths. The method is as follows: If l n > value or u n < value for a non - leaf node on the path, then update the corresponding l n or u n value of the numerical range field of this node to the value of value; otherwise, keep the original numerical range field unchanged. During the process of inserting a data object, if the number of child nodes of the current node exceeds the fan - out of the FWA - trie, node splitting will occur. The S n and acc n values of the newly created nodes after splitting need to be calculated using the S n of the child nodes of the newly created nodes. The S n of the newly created nodes is the union of the S n of all child nodes of the newly created nodes, and acc n is the cumulative value calculated for all ObjectIDs in S n . When the child nodes of the newly created nodes are non - leaf nodes, the l n in the numerical range field of the newly created node is the l n value of the numerical range field of the first child node, and u n is the u n value of the numerical range field of the last child node; when the child nodes of the newly created nodes are leaf nodes, the l n in the numerical range field of the newly created node is the v n value of the numerical range field of the first child node, and u n is the v n value of the numerical range field of the last child node;

[0025] Step 2 - 3: Save the hash value of the root node in the index structure of the current block to be submitted into the block header. At the same time, pack the timestamp and the hash value of the previous block of this block into the block header, and form the current block to be submitted together with the block body of the current block to be submitted;

[0026] Step 2-4: Broadcast the current block to be submitted through the network to all nodes in the blockchain query system for verification and determine whether consensus is reached. If consensus is reached, add this block to the local blockchain; otherwise, do not add this block to the local blockchain, and complete the index construction process;

[0027] Step 3: Use the constructed index structure to process the trusted query task;

[0028] Step 3-1: The lightweight node proposes a query task and sends it to the full node;

[0029] The query task is: q = <[t s ,t e ,α,β>, where [t s ,t e represents the time range of the query task, t s and t e respectively represent the start time and end time of the query, and correspond to the timestamps of two specific blocks before and after in the blockchain. In this way, the time range [t s ,t e of the query task is converted into a block range composed of these two blocks and all the blocks in between. Since each time range can be converted into a block range, the time range is represented by the block range; α represents the numerical attribute range of the query task, and β represents the attribute requirements of the query task for keywords. If there are multiple keywords in the query task, the multiple keywords are modified by Boolean operators;

[0030] Step 3-2: The full node divides the received query task to obtain query subtasks;

[0031] The method of dividing the received query task is as follows: Determine which block index structures need to be queried according to the time range, and it is divided into three cases: full coverage, that is, the time range in the query task completely covers a certain time window. At this time, query the index structure of the last block in this window; left coverage, that is, the time range of the query task falls within a certain time window from the first block to a specified block that is not the last block. At this time, query the index structure of this specified block; right coverage, that is, the query time range falls between any non-first block and the last block in a certain time window. At this time, query the index structures of two blocks, which are the last block in this time window and the block before the first block that meets the time range of the query task in this window, and perform a difference set operation on the results of the two queries;

[0032] The subquery is to query a single numerical attribute or a single keyword in the subquery task. That is, when α in the query task is the numerical range of a single attribute, the FWA-B+-tree is used to query the numerical range of a single attribute in the specified block of the subquery task; when β in the query task is a single keyword, the FWA-trie is used to query a single keyword in the specified block of the subquery task.

[0033] Step 3-3: The full node uses the constructed index structure to perform a subquery on the subquery task and generates a verification object VO and a subquery result set of the subquery.

[0034] Step 3-4: The full node uses the subquery result set and the VO of the subquery to generate a final query result set and a VO of the final query, and determines the final query result according to the final query result set and the VO of the final query.

[0035] Step 3-5: The light node verifies locally according to the final query result set and the VO of the final query obtained by the full node.

[0036] The beneficial effects of adopting the above technical solutions are as follows:

[0037] Compared with the prior art, the method of the present invention uses the FWA-ObjReg-tree to hash-map a long data object into a short object identity identifier ObjectID, reducing the universe parameter of the value range that needs to be input when generating the accumulator public key for supporting nested set operations and incremental updates. Thereby, the size of the generated accumulator public key is reduced, making the accumulator public key easier to store and transmit; the calculation speed of the accumulator supporting nested set operations and incremental updates will increase as the public key size decreases. Therefore, compared with the prior art, the method of the present invention reduces the calculation overhead of the accumulator during the construction of the index structure nodes and saves the time overhead for constructing the index structure; the smaller public key size also reduces the time for performing accumulator operations during the query process, so the query efficiency is also accelerated; in addition, the FWA blockchain index construction method saves the space overhead occupied by index construction through the method of node reuse within the same time window. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 It is a schematic structural diagram of the blockchain query system in this embodiment;

[0039] Figure 2 It is a flowchart of a verifiable blockchain index method supporting boolean queries and range queries in this embodiment;

[0040] Figure 3 It is a schematic diagram of the fixed window accumulator index construction method in this embodiment;

[0041] Figure 4 Schematic diagram of the FWA-ObjReg-tree structure in this embodiment;

[0042] Figure 5 Structure diagram of the FWA-ObjReg-tree of block No. 4 in the FWA-ObjReg-tree structure in this embodiment;

[0043] Figure 6 Schematic diagram of the FWA-trie structure in this embodiment;

[0044] Figure 7 Schematic diagram of the FWA-B+-tree structure in this embodiment;

[0045] Figure 8 Schematic diagram of query task division in this embodiment. Specific implementation mode

[0046] The following combines the accompanying drawings and embodiments to further describe in detail the specific implementation mode of the present invention. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.

[0047] In this embodiment, the blockchain query system structure relied on by the present invention is as Figure 1 shown. There are three roles for the nodes in this query system, namely full nodes that are query service providers SP, consensus nodes, and light nodes that are query users user;

[0048] Full node: Responsible for verifying and processing query tasks for the blocks published by the consensus nodes. That is, after receiving the blocks published by the consensus nodes, the full node is responsible for checking whether the blocks meet the established requirements of the blockchain system, which includes checking whether the root hash value of the index structure in the block header is correct; in addition, as the SP, the full node also needs to generate a query result R and a verification object VO based on the query task Q of the light node using the locally saved index structure;

[0049] Consensus node: Responsible for packing and publishing blocks. The consensus node constructs an index structure while packing the blocks and maintains the root hash value of the index structure in the block header, and then broadcasts the packed blocks to other nodes;

[0050] Light node: Responsible for proposing query tasks and verifying query results: The light node only performs consensus on the block header. It, as a query user, proposes a query task to the full node and reconstructs the root hash value of the index structure locally using the query result and the verification object, and determines whether the query result is credible by comparing whether the root hash value is the same as the root hash value already existing in the local block header.

[0051] In this embodiment, the method of the present invention proposes a verifiable blockchain index method that supports boolean queries and range queries, as Figure 2 shown, including:

[0052] Step 1: Propose a Fixed Window Accumulator (FWA) blockchain index construction method, called the FWA blockchain index construction method;

[0053] Step 2: Construct an index structure according to the FWA blockchain index construction method;

[0054] Step 3: Use the constructed index structure to process trusted query tasks;

[0055] The FWA blockchain index construction method is to divide all blocks in the blockchain system into regions, and each divided region is called a time window. Taking the time window as a unit, construct the FWA blockchain index in the form of a Merkle hash tree; specifically including:

[0056] Divide every k blocks in the blockchain system into a region, and each divided region is called a time window. Among them, k is called the time window size, and k is a positive integer greater than 2; taking the time window as a unit, construct the FWA blockchain index in the form of a Merkle hash tree. The method is: within the same time window, when constructing the index of the current block, copy the index root node of the previous block, start inserting the data object of the current block from this copy of the index root node, traverse according to the index structure in the previous block from this copy of the index root node, copy all non-leaf nodes on all traversal paths in order during the traversal process, and save each copied non-leaf node to an array until reaching the insertion position of the data object inserted in this block, and create a new leaf node or copy and update the original leaf node at this position to complete the insertion of the data object. Reverse the successor child pointers and hash values of all non-leaf nodes in the array, so that the successor child pointers originally pointing to the nodes in the previous block point to the next non-leaf node in the array, and the non-successor child pointers are not modified and still reuse all the nodes provided by the previous block index that are not on the traversal path to complete the index construction;

[0057] In this embodiment, as Figure 3 shown, when the time window size k = 3, that is, the block number starts from 1, every three blocks are a time window, and the index structure root node is index root; with Figure 3Taking block No. 2 in the first time window as an example, the index construction process of this block is as follows: First, copy the index root node of block No. 1, then start traversing from this root node copy, and find the insertion position of the data object inserted into block No. 2 through nodes n2 and n4. During this traversal process, copy the non-leaf nodes n2 and n4 on the traversal path in sequence, and mark the copies of these two nodes as n5 and n6. Insert the new leaf node n7 after n6, then update the successor child pointer and hash value field of n6. Finally, update the successor child pointer and the hash value of the child node on the traversal path of n5 and the root node copy respectively, that is, add a child pointer pointing to n7 to n6, and update the hash value of the child node under this child pointer of n6 to the hash value of node n7; change the child pointer of n5 originally pointing to n4 to point to n6, and update the hash value of the child node under this child pointer of n5 to the hash value of node n7; change the child pointer of the root node copy originally pointing to n2 to point to n5, and update the hash value of the child node under this child pointer of the root node copy to the hash value of node n7. Take this root node copy as the root node of the newly built index structure of block No. 2, and the non-successor child pointer is not modified, still reusing all the nodes provided by the previous block index that are not on the traversal path to complete the index construction; Figure 3 The small squares in it represent the nodes of the tree, and the dotted lines are the pointers pointing to the nodes of the previous block, which are used for node reuse; the index structure of the second time window is not shown.

[0058] The method for constructing an index structure according to the FWA blockchain index construction method includes:

[0059] Step 2-1: Obtain a data object and pack the data object into the block body of the block to be submitted;

[0060] Specifically, the data object is: construct all the data objects Object stored in the blockchain system into a time series object sequence {o1, o2, …, o i , …, o s}, where i is the unique identifier of a certain data object in the time series object sequence, s is the number of data objects, o i is the i-th data object stored in the block, and o i = <t i , v i , W i >, t i is the timestamp of this data object, which is consistent with the timestamp of the block where this data object is located; v i is the numerical attribute of this data object; W i is the set of all keyword attributes of this data object;

[0061] Step 2-2: In the current block, construct an index structure according to the FWA blockchain index construction method, where the index structure includes: an object registration tree FWA-ObjReg-tree based on a fixed-window accumulator, a keyword index structure FWA-trie based on a fixed-window accumulator, and a numerical attribute range query index FWA-B+-tree based on a fixed-window accumulator;

[0062] The method for constructing the object registration tree FWA-ObjReg-tree based on a fixed-window accumulator is as follows:

[0063] Construct the FWA-ObjReg-tree according to the FWA blockchain index construction method, map the hash value of the data object to the data object identity ObjectID, and construct it in the form of a multi-way Merkle hash tree. That is, in the FWA-ObjReg-tree, it includes the leaf nodes of the FWA-ObjReg-tree and the non-leaf nodes of the FWA-ObjReg-tree. Among them, the leaf nodes of the FWA-ObjReg-tree store the hash values h of all data objects from the first block to the current block within the current time window i , and h i =H(o i ), where H(·) is a cryptographic hash function; the non-leaf nodes of the FWA-ObjReg-tree store the hash value obtained by concatenating the hash values stored in all its child nodes and then performing a hash operation;

[0064] In this embodiment, each block has a corresponding FWA-ObjReg-tree, whose function is to map the hash value of the data object to the data object identity ObjectID and is constructed using the FWA index construction method; the FWA-ObjReg-tree can map the relatively long hash value of the data object into a shorter ObjectID; for example Figure 4As shown, the registered root is the root node of the FWA-ObjReg-tree. The root node stores the root hash value of the FWA-ObjReg-tree. When the time window size k = 4, a ternary FWA-ObjReg-tree is constructed. For ease of representation, assume that each block contains only two data objects. The FWA-ObjReg-tree of block 2 is constructed according to the FWA indexing method. First, the root node of the FWA-ObjReg-tree in block 1 needs to be copied. Starting from this copied root node, the insertion operations of data objects o2 and o3 are performed. Only the nodes on the traversal path are newly created during the insertion operation, and the non-successor child pointers of the nodes on the traversal path of the insertion operation are not modified during this process. The pointers still point to the nodes of the previous block's index structure; the leaf nodes of the ternary FWA-ObjReg-tree store the hash values of the data objects, such as Figure 4 h3 = H(o3) in

[0065] The mapping rule for mapping the hash value of a data object to the data object identity is that the data object identity ObjectID corresponding to the hash value of the data object on a certain leaf node is the path value from the root node to this leaf node in the FWA-ObjReg-tree;

[0066] In this embodiment, as Figure 5 shown, when the time window size k = 4, a ternary FWA-ObjReg-tree is constructed. Taking block 4 as an example, the FWA-ObjReg-tree in this block can map the hash value of the data object inserted into this block to the data object identity ObjectID. For example, the ObjectID of o7 is 7, which exactly corresponds to the number 021 in ternary, where the ternary is the same as the fan-out number of this ternary FWA-ObjReg-tree; this ObjectID is the same as the path of the leaf node storing the hash value of o7 in the tree, that is, from the 0th node in the first layer (the serial number starts from 0, and the first layer is the root node) to the 2nd node in the second layer divided by the 0th node in the first layer, and then to the 1st node in the third layer divided by the 2nd node in the second layer.

[0067] In the FWA-trie and FWA-B+-tree index structures proposed in the method of the present invention, since both of these index structures are tree-like index structures, the fields included in the nodes of these two index structures are introduced first, specifically including:

[0068] ε n : The keyword string field, whose value is the keyword string segment stored by the current node;

[0069] S n: A set field, where the elements of the set are the ObjectIDs of data objects;

[0070] acc n : An accumulator field, whose value is the result of performing a cryptographic set accumulator operation on the S n field in the current node, that is, acc n = acc(S n ), where acc(·) is a cryptographic set accumulator;

[0071] h n : A hash value field, whose value is the result of performing a hash operation on some fields in the current node, and is used to represent the hash value of the current node;

[0072] childHash n : A child hash field, whose value is the hash value obtained by concatenating the hash values of all child nodes of the current node as strings and then performing a hash operation;

[0073] Among them, n represents a certain node of these two tree - shaped index structures, and here n generally refers to a certain node of all tree - shaped index structures in this article and does not specifically refer to a certain type of node of a certain index structure; It should be noted that not all nodes of the two index structures store all the above - mentioned field types. Which fields are stored in a certain type of node of a specific index structure and the specific calculation rules of these field values will be given below;

[0074] The method for constructing the keyword index structure FWA - trie based on a fixed - window accumulator is as follows:

[0075] Construct the keyword index structure FWA - trie based on the Merkle Patricia Tree. The FWA - trie includes: the leaf nodes of the FWA - trie, the non - leaf and non - root nodes of the FWA - trie, and the root node of the FWA - trie;

[0076] The leaf nodes of the FWA - trie include: the keyword string field ε n , the set field S n , the accumulator field acc n , the hash value field h n , where ε n stores the remaining string fragment of the keyword saved by the leaf node; S n stores the set of ObjectIDs of data objects that contain the keyword formed by concatenating the keyword string fields from the root node to this node in order in the current index structure; acc n stores the result of the accumulator operation on the set field in the current node; hn What is saved is the hash value of the current node, i.e., h n = H(H(ε n ) || acc n );

[0077] The non - leaf and non - root nodes of the FWA - trie include: keyword string field ε n , child hash field childHash n , hash value field h n , where ε n saves the maximum common prefix string of the remaining keywords after removing the keyword prefix formed by sequentially connecting the keyword string fields from the root node to this node; childHash n saves the value obtained by concatenating the h n fields of all child nodes and then calculating the hash value, i.e., childHash n = H(h c1 || ··· || h cF ), h c1 ……h cF represents the hash values of all child nodes of the current node; h n saves the hash value of the current node, i.e., h n = H(H(ε n ) || childHash n );

[0078] The root node of the FWA - trie includes: keyword string field ε n , set field S n , child hash field childHash n , accumulator field acc n , hash value field h n , where ε n saves the maximum common prefix string segment of all the remaining keyword strings under the current path; S n saves the set of ObjectIDs of all data objects in the current index structure; childHash n saves the value obtained by concatenating the h n fields of all child nodes and then calculating the hash, i.e., childHash n = H(h c1 || ··· || h cF ); acc n saves the operation result of the accumulator operation on the set field in the current node; h n saves the hash value of the current node, i.e., h n = H(H(ε n)||childHash n ||acc n );

[0079] Construct the FWA-trie according to the indexing construction method of FWA. During the construction process, it is necessary to continuously insert the keywords and ObjectID of the data object of this block into the index structure. During the insertion process, it is necessary to maintain the acc on the root node and leaf node on the insertion path n 、S n ,The method is: it is necessary to perform incremental update on acc n ,Add the ObjectID of the data object to be inserted in this block to the set of S n ,and at the same time update the acc on this node n 。If the insertion position of this data object finally reached is an empty node, a new leaf node needs to be created, and the acc n value of this leaf node is the accumulated value obtained from the ObjectID of the data object to be inserted, and S n is only composed of the ObjectID of the data object to be inserted;

[0080] In this embodiment, Table 1 shows each data object and its block number, ObjectID, and keywords contained in the block;

[0081] Table 1 Each data object and its block number, ObjectID, and keywords contained in the block

[0082] Data object Block number ObjectID Included keywords <![CDATA[o1]]> <![CDATA[Block1]]> <![CDATA[id1]]> {0c2f,0cde} <![CDATA[o2]]> <![CDATA[Block2]]> <![CDATA[id2]]> {5e9b} <![CDATA[o3]]> <![CDATA[Block3]]> <![CDATA[id3]]> {5e7a,5e9b} <![CDATA[o4]]> <![CDATA[Block4]]> <![CDATA[id4]]> {5e7a}

[0083] For the sake of easy representation, assume that each block only stores one data object. As Figure 6 shown, the table in the picture shows that the time window size is k = 4; the dotted line is the pointer pointing to the previous block node; the hash value of the FWA-trie index root node trie root is the hash value of the FWA-trie root node in each block; Figure 6 The "*" in the root node in d represents that the common prefix of the keywords of the index structure is an empty string; taking block 2 as an example, when constructing the FWA-trie of block 2, first copy the root node of the FWA-trie index in block 1, and start traversing from this root node copy n d ,and then update the S n and acc n of n d ,that is, add the ObjectID of the data object o2 to be inserted, which is id2, to the S n of n d ,and at this time the S n of node n d, then according to S d for n d acc n perform incremental update to generate acc(S d ); According to Figure 6 it can be known that since the keyword of the data object o2 to be inserted has no common prefix with the ε d of the root node n n in the current block, it is necessary to change the ε n of the root node to an empty string and create a new non-leaf node n e as the child of the root node. At the same time, make the original children of n d , that is, Figure 6 the child nodes n a of the root node n b and n c in the previous block in e as the children of the non-leaf node n d . Then continue to find the successor node in the n f node. Since there is no child node with the same prefix as the keyword of the data object o2 to be inserted, an empty node is reached. At this time, it is necessary to create a new leaf node n f . The ε n of the node n f is the keyword contained in the data object o2 to be inserted. The S n of the node n f is the set S f containing only the ObjectID of o2, that is, id2. The acc n of the node n f is the cumulative value acc(S f ) of the set S

[0084] The method for constructing the numerical attribute range query index FWA-B+-tree based on the fixed window accumulator is as follows:

[0085] Constructing the numerical attribute range query index FWA-B+-tree based on the Merkle B+ tree only according to the numerical attributes of the data object includes: the leaf nodes of FWA-B+-tree and the non-leaf nodes of FWA-B+-tree;

[0086] In this embodiment, based on the form of the Merkle B+Tree, an FWA-B+-tree is constructed only according to the numerical attributes of data objects. That is, an FWA-B+-tree needs to be constructed for each numerical attribute. If the same numerical attribute is contained in different data objects, the data objects containing this numerical attribute need to be saved in the FWA-B+-tree corresponding to this numerical attribute to achieve multi-dimensional numerical attribute query;

[0087] The leaf nodes of the FWA-B+-tree include: a numerical attribute value field v n , a set field S n , an accumulator field acc n , a hash value field h n , where v n stores the numerical attribute value of the data object saved in this leaf node; S n stores the set of ObjectIDs of all data objects with the numerical attribute value of v n in all data objects saved in the current index; acc n stores the operation result of the accumulator operation on the set field in the current node; h n stores the hash value of the current node, that is, h n =H(H(v n )||acc n );

[0088] The non-leaf nodes of the FWA-B+-tree include: a numerical range field Range[l n ,u n , a set field S n , an accumulator field acc n , a child hash field childHash n , a hash value field h n , where in Range[l n ,u n , l n and u n are respectively the minimum and maximum values of the numerical attribute values of all data objects saved in the subtree with the current node as the root node. Since the children of all non-leaf nodes are arranged in ascending order of the numerical attribute values of the data objects in the numerical range field, so [l n ,u n takes the value of [l c1 ,u cF , the subscript c1 represents the node c1, which is the first child node of the node n, and the subscript cF represents the node cF, which is the last child node of the node n; S nWhat is saved is the set of ObjectIDs of all data objects under the subtree rooted at this node; and S n = S c1 ∪···∪ S cF , acc n What is saved is the operation result of the accumulator operation on the set field in the current node; childHash n What is saved is to concatenate the h n fields of all child nodes and then calculate the hash value, that is, childHash n = H(h c1 ||···|| h cF ), h c1 , ……, h cF represent the hash values of all child nodes of the current node; h n What is saved is the hash value of the current node, that is, h n = H(H(Range[l n , u n ) || acc n || childHash n );

[0089] Construct the FWA-B+-tree according to the index construction method of FWA. During the construction process, it is necessary to continuously insert the numerical attribute value value and ObjectID of the data object to be inserted into the index structure. During this insertion process, it is necessary to maintain the acc n and S n of all nodes on the insertion path. The maintenance rule is the same as the maintenance rule in the FWA-trie. At the same time, it is also necessary to maintain the numerical range field of non-leaf nodes on all paths. The method is as follows: If l n > value or u n < value for a non-leaf node on the path, then update the value of l n or u n corresponding to the numerical range field of this node to the value of value, otherwise, keep the original numerical range field unchanged; During the process of inserting a data object, if the number of child nodes of the current node exceeds the fan-out of the FWA-trie, node splitting will occur. The values of S n and acc n of the newly created nodes after splitting need to be calculated using the S n of the child nodes of the newly created nodes. The S n of the newly created nodes is the union of the S n of all child nodes of the newly created nodes, and acc n is the accumulator operation on S nThe accumulated value calculated by all ObjectIDs in the new node. When the child node of the new node is a non-leaf node, the l in the value range field of the new node n l is the value range field of the first child node n Value, u n u is the value range field of the last child node n ; When the child node of the new node is a leaf node, the l in the value range field of the new node n v is the value range field of the first child node n Value, u n v is the value range field of the last child node n value;

[0090] In this embodiment, Table 2 shows each data object and its block number, ObjectID, and numerical attribute value;

[0091] Table 2 Block number, ObjectID, and numerical attribute value of each data object and its block

[0092] Data object Block number ObjectID Numerical attribute value <![CDATA[o1]]> <![CDATA[Block1]]> <![CDATA[id1]]> 1 <![CDATA[o2]]> <![CDATA[Block2]]> <![CDATA[id2]]> 6 <![CDATA[o3]]> <![CDATA[Block3]]> <![CDATA[id3]]> 7 <![CDATA[o4]]> <![CDATA[Block4]]> <![CDATA[id4]]> 3

[0093] For ease of representation, only one data object is stored in each block, such as Figure 7 As shown, the time window size is k=4; the dotted line is a pointer to the previous block node; the B+ tree root bplus root is the hash value of the FWA-B+-tree root node of each block; when the fan-out of the FWA-B+ tree structure is 2, the root node of the index of block No. 2 will be copied when constructing the FWA-trie of block No. 3, and the root node copy n will be copied from this root node u Start traversing and first update n u Range[l n ,u n ], acc n , S n Since the value of the numeric attribute of the data object o3 to be inserted is 7, n Updated to 7 and in S u Add the ObjectID of the data object o3 to be inserted, that is, n u S u ={id1,id2,id3}, and for n u acc n Perform incremental updates and then u Find the successor node in the child node of the node. Since the child node n of the original root node x 、n z are all leaf nodes and their v n Both are the same as v of the data object o3 to be insertedn is different, and at this time, a new leaf node n needs to be created w , n w 's v n is 7, n w 's S n only contains the ObjectID of the data object o3 to be inserted, that is, id3, acc n is the cumulative value of id3; at this time, the node n u has three children exceeding the fan-out of the FWA-B+ tree structure, and node splitting is required. Split out node n x and node n v , where the l v of the Range of the new node n n value is the v n value of the first child of this node, which is 6, u n is the v n value of the last child of this node, which is 7, the S v of the new node n v is the union of the S n sets of all child nodes of this node, that is, {id2, id3}, n v 's acc n is the cumulative value calculated for all ObjectIDs in this set, that is, acc n = acc(S v ), completing the construction of the FWA-B+ tree index in the current block.

[0094] Step 2-3: Save the hash value of the root node in the index structure of the current block to be submitted into the block header. At the same time, pack the timestamp and the hash value of the previous block of this block into the block header, and form the current block to be submitted together with the block body of the current block to be submitted;

[0095] Step 2-4: Broadcast the current block to be submitted to all nodes in the blockchain query system through the network for verification and determine whether consensus is reached. If consensus is reached, add this block to the local blockchain; otherwise, do not add this block to the local blockchain, completing the index construction process;

[0096] In this embodiment, the consensus node broadcasts the constructed block to other nodes in the blockchain query system through the network. After receiving the constructed block, other nodes will verify the block. In addition to the content that needs to be verified by default in the existing blockchain system, it also includes the verification of the hash values of the root nodes of the FWA-ObjReg-tree, FWA-trie, and FWA-B+-tree saved in the block header. During the verification process, the full node will use the data objects saved in the block body to reconstruct the FWA-ObjReg-tree, FWA-trie, and FWA-B+-tree locally in the same construction manner as in step 1-2, calculate the hash values of the root nodes corresponding to each index structure, and respectively compare the hash values with the relevant fields in the block header of the current block to be verified. If the two values are the same, the verification is passed, the consensus is reached, and this block is added to its own local blockchain to complete the index construction process. If they are different, the consensus is not reached, and this block will not be added to its own local blockchain.

[0097] The method for processing the trusted query task by using the index structure includes:

[0098] In this embodiment, the full node will process the query tasks of the light nodes through the FWA-ObjReg-tree, FWA-trie, and FWA-B+-tree in all the blocks that have been verified and reached consensus.

[0099] Step 3-1: The light node proposes a query task and sends it to the full node;

[0100] Specifically, the query task proposed by the light node is: q = <[t s ,t e ,α,β>, where [t s ,t e represents the time range of the query task, t s and t e respectively represent the start time and end time of the query, and correspond to the timestamps of two specific blocks in the blockchain. In this way, the time range [t s ,t e of the query task is converted into a block range composed of these two blocks and all the blocks in between. Since each time range can be converted into a block range, the block range will be used to represent the time range hereinafter; α represents the numerical attribute range of the query task, and β represents the attribute requirements for the keywords of the query task. If there are multiple keywords in the query task, the multiple keywords are modified by Boolean operators;

[0101] In this embodiment, for example, α = {[1, a, b], [2, c, d]}, which means that there are two numerical attributes in the query task. The query range of the first numerical attribute is from a to b, and the query range of the second numerical attribute is from c to d; It means that the requirements of the query task for the keyword attribute are data objects that include both "0c25" and "0c84" or data objects that do not contain "ac84";

[0102] Step 3-2: The full node divides the received query task to obtain query subtasks;

[0103] Specifically, the method of dividing the query task is to determine which block index structures need to be queried according to the time range, which is divided into three cases: full coverage, that is, the time range in the query task completely covers a certain time window. At this time, query the index structure of the last block in this window; left coverage, that is, the time range of the query task falls within a certain time window from the first block to a specified block other than the last block. At this time, query the index structure of this specified block; right coverage, that is, the query time range falls between any non-first block and the last block in a certain time window. At this time, query the index structures of two blocks, which are the last block in this time window and the block before the first block that meets the time range of the query task in this window, and perform a difference set operation on the results of the two queries;

[0104] In the above case of right coverage, it is necessary to perform a difference set operation on the query results of two blocks in the same time window, which requires that the ObjectID that uniquely represents a data object in the same time window cannot be repeated; due to reasons such as performance, security, consensus mechanism, and data management, the number of data objects stored in a single block is limited. Let the maximum number of data objects stored in a single block be m, and the time window size be k. Then the maximum value of the ObjectID starting from zero that can be saved in the FWA-ObjReg-tree is not less than km - 1;

[0105] In this embodiment, as Figure 8 shown, the large black brackets represent the time window, the dashed large brackets are the query time range of the query task, the gray blocks are the blocks for which the corresponding index structures need to be queried, and the obtained query result set is denoted as R[a - b], which means that the query results contain all data objects that meet the requirements of the query task between block a and block b. Figure 8The two expressions in it are operations on the query result set. The "-" is the difference set operation, and the "+" is the union set operation. When the time window size k = 4, the query task with a time range of [4, 11] is divided. This time range contains three time windows. Among them, the blocks numbered 5 - 8 within the time range of the query task cover time window 2, satisfying complete coverage. At this time, the index structure of block 8 needs to be queried. The blocks numbered 9 - 11 within the time range of the query task fall from the first block numbered 9 to the non - last block numbered 11 of time window 3, satisfying left coverage. At this time, the index structure corresponding to block 11 needs to be queried. And the block numbered 4 within the time range of the query task is the last block in time window 1, satisfying right coverage. At this time, the index structures of the last block 4 and block 3 need to be queried, and the difference set operation is performed on the query results of the two. After completing the above steps, three sub - query tasks are obtained. The three query sub - tasks respectively need to query the index structures stored in blocks 8, 11, 3, and 4.

[0106] Step 3 - 3: The full node uses the constructed index structure to perform sub - queries on the sub - query tasks, and generates the verification object VO and sub - query result set of the sub - query.

[0107] The sub - query is to query a single numerical attribute or a single keyword in the sub - query task. That is, for the numerical range of a single attribute α in the query task, query the FWA - B+-tree in the specified block of the sub - query task. For a single keyword β in the query task, query the FWA - trie in the specified block of the sub - query task.

[0108] In this embodiment, the purpose of this step is to query the index structure of the specified block in the sub - query task. For the numerical range query of a single attribute in α of the query task, query the corresponding FWA - B+-tree. For the single keyword query in β of the query task, query the FWA - trie, and generate the verification object VO of the sub - query for the query results of the numerical range query of all single attributes and the single keyword query respectively. In this way, the numerical attribute or single keyword query of a single attribute is called a sub - query.

[0109] The process of generating the verification object VO of the single keyword query and sub - query using the FWA - trie is as follows: First, create an empty verification object VO of the sub - query and a sub - query result set. Start traversing the FWA - trie from the root node in the specified block in a top - down manner. During the traversal, if the ε of the current node n does not match the string of the keyword to be queried, then all data objects under this node do not contain the keyword to be queried. In this case, if the current node is a leaf node of the FWA - trie, then the ε of the current node n and acc nAdd it to the VO of the subquery; if the current node is a non-leaf and non-root node of the FWA-trie, then add the ε of the current node n and childHash n to the VO of the subquery; if the current node is the root node of the FWA-trie, then add the ε of the current node n 、childHash n and acc n to the VO of the subquery; if the string of the keyword to be queried matches the ε of the current node n , in this case, if the current node is a leaf node of the FWA-trie, then add the S of the current node n to the subquery result set, and add the ε of the current node n and acc n to the VO of the subquery; if the current node is a non-root and non-leaf node of the FWA-trie, then add the ε of the current node n to the VO of the subquery; if the current node is the root node of the FWA-trie, then add the ε of the current node n and acc n to the VO of the subquery, and then continue to traverse the subtree until the traversal process is completed to generate the VO of the subquery and the subquery result set for the specified block;

[0110] The process of generating the VO of the subquery for the numerical range query of a single attribute using the FWA-B+-tree is as follows: For the query range α = {[1, a, b]} of the given numerical attribute, first create an empty VO and subquery result set, and start traversing the FWA-B+-tree in a top-down manner from the root node of the FWA-B+-tree of the first numerical attribute in the specified block; if the current node is a non-leaf node, then make the following judgments: If the [l n , u n of the current node is completely covered by the query range [a, b], then add the S of the current node n to the subquery result set, and add acc n , Range, Childhash n to the VO of the subquery; if the query range [a, b] partially intersects with the [l n , u n of the current node, then add Range and acc n to the VO, and decide whether to traverse this child node according to whether the [l n , u n of the child node of the current node intersects with the query range [a, b]; if the query range [a, b] and the [l n , u nIf there is no intersection, then add Range and childhash n and acc n to the VO of the subquery; if the current node is a leaf node, then make the following judgment: if the query range [a, b] includes the v n of the current node, then add S n to the subquery result set, and add v n and acc n to the VO of the subquery; if the query range [a, b] does not include the v n of the current node, and only add v n and acc n to the VO of the subquery, and then continue to traverse the subtree until the traversal process is completed, generating the VO of the subquery and the subquery result set of the specified block;

[0111] In this embodiment, if the query range of the numerical attribute in the query task is α = {[1, a, b], [2, c, d]}, then the query task can be decomposed into two subquery tasks, which are to query all data objects whose first numerical attribute is in the range [a, b] and to query all data objects whose second numerical attribute is in the range [c, d], and use the corresponding FWA-B+-tree for query; if the keyword attribute in the query task is then the query task can be decomposed into three subquery tasks, which are to query data objects containing "0c25", to query data objects containing "0c84", and to query data objects containing "ac84", and use the corresponding FWA-trie for query;

[0112] Step 3-4: The full node generates the final query result set and the final query VO by using the subquery result set and the VO of the subquery, and determines the final query result according to the final query result set and the final query VO;

[0113] Furthermore, create an empty final query VO for each time window involved in the query range of this query task, and then add the VO of the subquery of each time window to the final query VO; the boolean operators "∧", "∨" in the query task, Logically corresponding to the intersection, union, and difference operations of the query result sets of subqueries, the subquery result sets in the same time window are subjected to these set operations to obtain the final query result set of this time window. Using the accumulators in each subquery result set, a credible proof is generated for the set operation result of the subquery result set, and the credible proof is added to the VO of the final query to prove to the light node that the final query result set obtained through Boolean operations is credible; when dividing the query task according to the time range in step 2-2, when the time window and the query range satisfy right coverage, it is also necessary to perform a difference operation on the query result sets of two blocks within the same time window, and use their accumulators to generate a credible proof, and add the credible proof to the VO of the final query to prove to the light node that this difference operation is credible;

[0114] After the above steps, the query tasks on all time windows all obtain a final query result set. Query the FWA-ObjReg-tree of the last block within the query range for each time window to obtain the hash values of the data objects corresponding to all ObjectIDs in the final query result set, and use the FWA-ObjReg-tree to generate a Merkel proof for the correspondence between the ObjectID and the hash value of the data object, add the Merkel proof to the VO of the final query, and then query the corresponding data object with the hash value of the data object as the final query result, and send it to the light node together with the VO of the final query to complete the query task;

[0115] In this embodiment, the attribute requirements of the query task for the keyword are In a time window included in the query time range, through step 2-2, it is possible to determine the blocks that need to be queried by the query subtasks within this time window, and then through step 2-3, query the FWA-trie of the blocks determined in step 2-2 to obtain the query result sets R1, R2, R3 of the single keywords "0c25", "0c84", "ac84" and the corresponding accumulators acc1, acc2, acc3. Calculate the intersection R of R1 and R2 according to the Boolean expression 1∩2 and the accumulator acc 1∩2 and use acc1 and acc2 to generate a proof Π for the result 1∩2 , and the difference set R of the universal set Ω and R3 Ω-3 and the accumulator acc Ω-3 and use the accumulator acc of the universal set Ω and acc3 to generate a proof Π for the result Ω-3 , where, Ω and acc Ω are the S n and acc n of the root node of the FWA-trie of the current block, and finally calculate R1∩2 and R Ω-3 The union of and R is used as the query result set R of β β and utilize acc 1∩2 and acc Ω-3 Generate a proof Π for the result β ; Similarly, for the numerical attribute range α of the query task, the corresponding query result set R can also be obtained α1 、R α2 ……R αn and the accumulator acc α1 、acc α2 ……acc αn , where is the query result set of the j-th numerical attribute, and acc αj is the accumulator of the query result set of the j-th numerical attribute; use R β and R α1 、R α2 ……R αn Calculate the intersections in sequence and use their accumulators to generate a credible proof. Finally, obtain the set R of ObjectIDs of all data objects that meet the query conditions within the time window included in the query time range; add the set operation results, accumulators, and credible proofs of the above keyword attribute query and numerical attribute query result sets to the VO. Query the FWA-ObjReg-tree of the last block that meets the query time range in this time window to obtain the corresponding data object hash values of the ObjectIDs of the data objects that meet the query conditions within the time window where this block is located. At the same time, generate a Merkel proof for the query result and add it to the VO. Then, query the corresponding data objects based on these data object hash values and send these data objects, together with the VO, to the light node. Perform the above operations for each time window within the query range to finally complete the query task.

[0116] Step 3 - 5: The light node verifies locally according to the final query result set obtained by the full node and the final query VO

[0117] Specifically, the verification method is as follows: The light node uses the accumulators and accumulator set operation proofs in the final query VO to verify the set operation, reconstructs the root hash values of the three index structures using the VO information in the FWA-trie, FWA-B+-tree, and FWA-ObjReg-tree, and compares them with the hash values of the root nodes verified in step 2 - 4 in the light node. If all the verifications described in this paragraph pass, it proves that the query result is correct and complete.

[0118] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.

Claims

1. A verifiable blockchain indexing method supporting Boolean queries and range queries, characterized in that, Including: Step 1: Propose a fixed-window accumulator blockchain index construction method, called the FWA blockchain index construction method; The FWA blockchain index construction method includes: dividing every k blocks in the blockchain system into one area, and calling each divided area a time window, where k is the size of the time window and k is a positive integer greater than 2; taking the time window as a unit, constructing the FWA blockchain index in the form of a Merkle hash tree. The method is: within the same time window, when constructing the index of the current block, copy the index root node of the previous block, start inserting the data object of the current block from this copy of the index root node, traverse from this copy of the index root node according to the index structure in the previous block, copy all non-leaf nodes on all traversal paths in order during the traversal, and save each copied non-leaf node into an array until reaching the insertion position of the data object inserted into this block, and create a new leaf node or copy and update the original leaf node at this position to complete the insertion of the data object. Reverse-modify the successor child pointers and hash values of all non-leaf nodes in the array, so that the successor child pointers originally pointing to the nodes in the previous block point to the next non-leaf node in the array, while the non-successor child pointers are not modified and still reuse all the nodes provided by the previous block index that are not on the traversal path to complete the index construction; Step 2: Construct the index structure according to the FWA blockchain index construction method; Step 3: Use the constructed index structure to process the trusted query task.

2. The verifiable blockchain indexing method for supporting Boolean queries and range queries according to claim 1, wherein, The constructing the index structure according to the FWA blockchain index construction method in Step 2 includes: Step 2-1: Obtain the data object and pack the data object into the block body of the current block to be submitted; Step 2-2: In the current block, construct the index structure according to the FWA blockchain index construction method; Step 2-3: Save the hash value of the root node in the index structure of the current block to be submitted into the block header, and at the same time pack the timestamp and the hash value of the previous block of this block into the block header, and form the current block to be submitted with the block body of the current block to be submitted; Step 2-4: Broadcast the current block to be submitted to all nodes in the blockchain query system through the network for verification and determine whether consensus is reached. If consensus is reached, add this block to the local blockchain, otherwise this block will not be added to the local blockchain to complete the index construction process.

3. A verifiable blockchain indexing method that supports boolean queries and range queries according to claim 2, characterized in that The using the constructed index structure to process the trusted query task in Step 3 includes: Step 3-1: The lightweight node proposes a query task and sends it to all nodes; Step 3-2: All nodes divide the received query task to obtain query subtasks; Step 3-3: All nodes use the constructed index structure to perform subqueries on the subquery tasks and generate a verification object VO and a subquery result set for the subqueries; Step 3-4: All nodes use the subquery result set and the VO of the subquery to generate a final query result set and a VO of the final query, and determine the final query result according to the final query result set and the VO of the final query; Step 3-5: The light node verifies locally the final query result set obtained from the full node and the VO of the final query.

4. A verifiable blockchain indexing method for supporting Boolean queries and range queries according to any one of the above claims, characterized in that, The index structure includes: an object registration tree FWA-ObjReg-tree based on a fixed-window accumulator, a keyword index structure FWA-trie based on a fixed-window accumulator, and a numerical attribute range query index FWA-B+-tree based on a fixed-window accumulator.

5. The verifiable blockchain indexing method for supporting Boolean queries and range queries according to claim 4, wherein The construction method of the object registration tree FWA-ObjReg-tree based on the fixed window accumulator is as follows: construct the FWA-ObjReg-tree according to the FWA blockchain indexing method, map the hash value of the data object to the data object identity identifier ObjectID, and construct the FWA-ObjReg-tree in the form of a multi-way Merkle hash tree. That is, in the FWA-ObjReg-tree, it includes the leaf nodes of the FWA-ObjReg-tree and the non-leaf nodes of the FWA-ObjReg-tree. Among them, the leaf nodes of the FWA-ObjReg-tree save the hash values h of all data objects from the first block to the current block within the current time window i , and h i = H(o i ), where H(·) is a cryptographic hash function; the non-leaf nodes of the FWA-ObjReg-tree save the hash value obtained by concatenating the hash values saved in all its child nodes and then performing a hash operation; The mapping rule for mapping the hash value of a data object to the data object identity is: the data object identity ObjectID corresponding to the hash value of the data object on a certain leaf node is the path value from the root node to this leaf node in the FWA-ObjReg-tree.

6. The verifiable blockchain indexing method for supporting Boolean queries and range queries according to claim 4, characterized in that The construction method of the keyword index structure FWA-trie based on a fixed-window accumulator is: constructing the keyword index structure FWA-trie based on a Merkle Patricia tree, including: the leaf nodes of the FWA-trie, the non-leaf and non-root nodes of the FWA-trie, and the root node of the FWA-trie; The leaf nodes of the FWA-trie include: keyword string field ε n , set field S n , accumulator field acc n , hash value field h n ; The non-leaf and non-root nodes of the FWA-trie include: keyword string field ε n , child hash field childHash n , hash value field h n ; The root node of the FWA-trie includes: keyword string field ε n , set field S n , child hash field childHash n , accumulator field acc n , hash value field h n ; Construct the FWA-trie according to the indexing construction method of FWA. During the construction process, it is necessary to continuously insert the keyword of the data object to be inserted and the data object identity identifier ObjectID into the index structure. During the insertion process, it is necessary to maintain the acc on the root node and the leaf node on the insertion path. n , S n , the method is: it is necessary to perform incremental update on acc n . Add the ObjectID of the data object to be inserted to the set of S n , and at the same time update the acc n on this node correspondingly. If the insertion position of this data object finally reached is an empty node, it is necessary to create a new leaf node, and the acc n value of this leaf node is the accumulated value obtained from the ObjectID of the data object to be inserted, and S n is only composed of the ObjectIDs of the data objects to be inserted.

7. A verifiable blockchain indexing method for supporting Boolean queries and range queries according to claim 4, characterized in that The construction method of the numerical attribute range query index FWA-B+-tree based on a fixed-window accumulator is: constructing the numerical attribute range query index FWA-B+-tree based on a Merkle B+ tree only according to the numerical attributes of data objects, including: the leaf nodes of the FWA-B+-tree, the non-leaf nodes of the FWA-B+-tree; The leaf nodes of the FWA-B+-tree include: a numerical attribute value field v n , a set field S n , an accumulator field acc n , a hash value field h n ; The non-leaf nodes of the FWA-B+-tree include: a numerical range field Range[l n ,u n , where l n , u n are respectively the minimum and maximum values of the numerical attribute values of all data objects stored in the subtree with the current node as the root node, a set field S n , an accumulator field acc n , a child hash field childHash n , a hash value field h n ; Construct the FWA-B+-tree according to the indexing construction method of FWA. During the construction process, it is necessary to continuously insert the numerical attribute value value and the data object identity identifier ObjectID of the data object to be inserted into the index structure. During this insertion process, it is necessary to maintain the acc of all nodes on the insertion path n and S n . The maintenance rule is the same as the maintenance rule in the FWA-trie. At the same time, it is also necessary to maintain the numerical range fields of non-leaf nodes on all paths. The method is as follows: If l n > value or u n < value, then update the corresponding l n or u n value of the numerical range field of this node to the value of value. Otherwise, keep the original numerical range field unchanged; during the process of inserting a data object, if the number of child nodes of the current node exceeds the fan-out of the FWA-trie, node splitting will occur. The S n and acc n values of the newly created nodes after splitting need to be calculated using the S n of the child nodes of the newly created nodes. The S n of the newly created nodes is the union of the S n of all child nodes of the newly created nodes. acc n is the cumulative value calculated for all ObjectIDs in S n . When the child nodes of the newly created nodes are non-leaf nodes, the l n in the numerical range field of the newly created nodes is the l n value of the numerical range field of the first child node, and u n is the u n value of the numerical range field of the last child node; when the child nodes of the newly created nodes are leaf nodes, the l n in the numerical range field of the newly created nodes is the v n value of the numerical range field of the first child node, and u n is the v n value of the numerical range field of the last child node.

8. A verifiable blockchain indexing method supporting Boolean queries and range queries according to claim 1 or claim 3, characterized in that, The query task is: q = <[t s , t e , α, β>, where [t s , t e represents the time range of the query task, t s and t e respectively represent the start time and the end time of the query, and correspond to the timestamps of two specific consecutive blocks in the blockchain. In this way, the time range [t s , t e is transformed into a block range composed of these two blocks and all the blocks in between. Since each time range can be transformed into a block range, the time range is represented by the block range; α represents the numerical attribute range of the query task, and β represents the attribute requirements of the query task for keywords. If there are multiple keywords in the query task, the multiple keywords are modified by Boolean operators.

9. A verifiable blockchain indexing method that supports Boolean queries and range queries according to claim 3, characterized in that, The method for partitioning the received query task is: determining which index structures corresponding to which blocks need to be queried according to the time range, and there are three cases: full coverage, that is, the time range in the query task completely covers a certain time window, and at this time, query the index structure of the last block in this window; left coverage, that is, the time range of the query task falls within a specified block from the first block to a non-end block in a certain time window, and at this time, query the index structure of this specified block; right coverage, that is, the query time range falls between any non-first block and the end block in a certain time window, and at this time, query the index structures corresponding to two blocks, which are the last block in this time window and the block before the first block that meets the time range of the query task in this window, and perform a difference set operation on the results of the two queries.

10. A verifiable blockchain indexing method that supports Boolean queries and range queries according to claim 3, characterized in that, The sub-query is to query a single numerical attribute or a single keyword in the sub-query task, that is, when α in the query task is the numerical range of a single attribute, use the FWA-B+-tree to perform a numerical range query of a single attribute on the specified block in the sub-query task; when β in the query task is a single keyword, use the FWA-trie to perform a single-keyword query on the specified block in the sub-query task.

Citation Information

Patent Citations

  • Verifiable query optimization method for reputation-behavior associated double block chains

    CN113535732A

  • Block chain assisted medical big data search mechanism and privacy protection method

    CN114579998A