A blockchain-based verifiable keyword top-k query method
By constructing an RSA accumulator and inverted index in the blockchain, a verifiable multi-keyword Top-K query scheme is developed, which solves the problems of integrity and fuzzy query in the data query verification mechanism of the blockchain. It achieves effective verification of lightweight nodes and efficient query results, while reducing storage overhead.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN UNIV
- Filing Date
- 2022-09-28
- Publication Date
- 2026-04-28
AI Technical Summary
In existing blockchain technologies, data query and verification mechanisms are at risk of losing query integrity and do not support result ranking and fuzzy queries. In particular, the lack of trusted intermediaries in decentralized blockchain databases leads to data untrustworthiness issues.
A verifiable multi-keyword Top-K non-fuzzy query scheme is constructed using an RSA accumulator and an inverted index. An ADS is built by combining a prefix tree to achieve fuzzy queries, ensuring the completeness and correctness of the query results. A dynamic update mechanism is used to maintain the blockchain data.
It enables lightweight nodes to effectively verify the correctness of query results, reduces storage overhead, improves the performance of search, verification, and update operations, and supports fuzzy queries with keywords containing arbitrary characters.
Smart Images

Figure CN115510126B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, specifically to a keyword TOP-K query verification method in blockchain. Background Technology
[0002] Blockchain technology has become a research hotspot in many fields. Simply put, a blockchain is a distributed ledger maintained by a network of mutually distrustful nodes. It uses hash chain technology and consensus protocols to ensure the integrity, consistency, and immutability of data. Currently, blockchain is widely used in finance, supply chain, and healthcare. From a technical perspective, blockchain is a combination of technologies, involving cryptography, distributed systems, computer networks, and databases. Its advantages, such as decentralization and tamper resistance, have led researchers to apply it to data storage and retrieval. Designing efficient, practical, and secure blockchain query frameworks is currently a research hotspot in the field of blockchain querying.
[0003] In a blockchain network, each block consists of a header and a body. The header includes information such as blockchain consensus proof, the hash of the parent block, and a timestamp, while the body primarily contains data records (a list of transactions). Figure 1 As shown, there are two different types of nodes in a blockchain: full nodes and light nodes. A full node is a node that synchronizes all blockchain data, including the block header and all block body information. Through consensus, newly generated blocks are synchronized across all nodes, and each full node ultimately stores a complete and consistent copy of the data. It's important to note that light nodes only contain block header information and do not include the data records. All full nodes contribute to the continuous operation of the blockchain system. For some users, they only need to use the blockchain for transactions and do not participate in the maintenance and construction of the blockchain system. If a user were to store all the content of a block, the required space would be too large and wasteful. Therefore, for such users, participating in the blockchain's operation as a light node is the best choice. When it needs to publish a transaction or wants to know if certain transactions are in the blockchain, it can request them from a full node. For example, a light node can look up the ten most recent transactions (i.e., Top-10 in chronological order) of the username "Alice" on the blockchain network.
[0004] Designing secure and effective data query verification mechanisms has always been a key focus for both industry and academia. Researchers have done extensive work on everything from ensuring the security of remote data storage to ensuring the correctness of query results. While data query verification is relatively mature in cloud computing, it is still in its early stages in the blockchain field. Because blockchain systems are decentralized databases, data is stored across various untrusted nodes. When users exchange data without trusted intermediaries or mutual trust, data unreliability issues arise. For example, when a user initiates a query into the blockchain, it is necessary to ensure that the blockchain returns correct and complete results. Most existing solutions risk losing query integrity and support a limited range of query types. Therefore, designing secure and effective data query verification mechanisms in the blockchain field remains a topic that needs further exploration in blockchain research.
[0005] To reduce costs, existing technologies embed a small Authenticated Data Structure (ADS) in each block header, allowing users to verify search results without maintaining a full copy of the blockchain database. However, current research focuses on precise queries and does not support result ranking. Summary of the Invention
[0006] To address the aforementioned shortcomings in existing technologies, this invention proposes a novel blockchain framework that ensures the integrity of keyword query results and efficient dynamic updates. In the non-fuzzy query scheme, we propose a verifiable multi-keyword Top-K non-fuzzy query scheme based on ADS with an RSA accumulator. In the fuzzy query scheme, ADS based on a prefix tree implements multi-keyword fuzzy Top-K queries, supporting queries where the keyword contains a single arbitrary character ("?") and queries where the keyword ends with any number of arbitrary characters ("*").
[0007] According to a first aspect of the present invention, a blockchain-based verifiable keyword Top-K non-fuzzy query method is provided, characterized in that the blockchain includes full nodes and light nodes, wherein a full node is a node that has synchronized all blockchain data and contains all information of the block header and block body, and each block header includes an ADS structure. Light nodes participate in the blockchain as users, and only contain block header information.
[0008] The methods include:
[0009] Step S110: Execute the key generation algorithm on the full node. and cumulative value generation algorithm To build consensus proof.
[0010] include: For safety parameters, specify the RSA accumulator parameters. and ,in and For large prime numbers, , It is a cyclic group The generators output common parameters and private key .
[0011] This includes: constructing an inverted index based on all data D, where each keyword corresponds to a series of objects sorted from oldest to newest by time; and calculating a validation matrix. Where i represents the i-th keyword, j represents the j-th object in the sorted sequence of keywords, H is the collision-resistant hash function, m is the total number of keywords in D, and n is the total number of objects contained in a single keyword. For the j-th object with the i-th keyword, update when data is updated. ,in, For general hash functions, represent The corresponding prime value is then used to count the number of objects contained in each keyword, and the calculation is performed. ,in This is the total number of objects currently contained in the i-th keyword. Finally, ,Will , and As Add to block header.
[0012] Step S120: The light node initiates a non-fuzzy query request to any full node in the blockchain. The non-fuzzy query request includes the query keyword w and the number of Top-K query results k to the full node.
[0013] Step S130: After receiving the non-fuzzy query request, the full node executes the query algorithm. Obtain the result R, and execute the verification generation algorithm. Calculate the verification object VO and send R and VO to the light node.
[0014] This includes adding the first k objects in the inverted index, from newest to oldest, to R based on w.
[0015] Includes: calculation ,calculate Where w is the r-th key in the inverted index of data D. This represents the total number of objects currently contained in w. .
[0016] Step S140: After the light node receives the result R and the verification object VO returned by the full node, it executes the verification algorithm. Use VO to validate R.
[0017] Includes: Light nodes obtain from the block head Value, Equation If the condition is true, return 0 to indicate verification failure; otherwise, continue verification. calculate And determine the equation The function checks whether the verification is true or false. If it is false, it returns 0 to indicate that the verification failed. If it is true, it returns 1 to indicate that the verification was successful.
[0018] Step S150: When a new block is added, the full node executes the data update algorithm. Update blockchain information.
[0019] Includes: new objects Keywords included The information keywords need to be updated. , Let D be the set of indices for all keywords in data that need to be updated. For each keyword... ,calculate , After adding a new block The total number of objects included, calculated , , In block header storage .
[0020] According to a second aspect of the present invention, a blockchain-based method for verifiable keyword Top-K fuzzy search is provided, characterized in that the blockchain includes full nodes and light nodes, wherein a full node is a node that has synchronized all blockchain data and contains all information of the block header and block body, and each block header includes an ADS structure. Light nodes participate in the blockchain as users, and only contain block header information.
[0021] The methods include:
[0022] Step S210: Execute the key generation algorithm on the full node. And cumulative value generation algorithm To build consensus proof.
[0023] include: For safety parameters, specify the RSA accumulator parameters. and ,in and For large prime numbers, , It is a cyclic group The generators output common parameters and private key .
[0024] This includes: constructing a prefix tree T based on all data D, and hashing the root node of the prefix tree T. As Save to block header.
[0025] The prefix tree T is an ordered multi-way tree data structure used to store keywords. A keyword is composed of all the node characters on the path from the root node to each leaf node.
[0026] The non-leaf nodes of the prefix tree T include: the character s, the hash value of the concatenation of the hash values of all its child nodes, and the hash value of the concatenation. A string consisting of the characters of all ancestor nodes. and the set of all child node characters The root node of the prefix tree T has the start character "$".
[0027] The leaf nodes of the prefix tree T include: the terminator "#", and the cumulative value of all objects contained in that leaf node. and the collection of all objects contained in that leaf node , verification matrix H is a collision-resistant hash function, and n is the total number of objects contained in a leaf node. For each keyword corresponding to a leaf node, sort the objects contained within that leaf node from oldest to newest. For the j-th object, For general hash functions, represent The corresponding prime value.
[0028] Step S220: The light node initiates a fuzzy query request to any full node in the blockchain. The fuzzy query request includes the query keyword w and the number of Top-K query results k to the full node, where w contains the fuzzy query character "*" or "?". Step S230: After receiving the fuzzy query request, the full node executes the query algorithm. Obtain the query result R, and execute the validation generation algorithm. Calculate the verification object VO and send R and VO to the light node.
[0029] This includes: if w contains the fuzzy search character "*", then execute the first fuzzy search; if w contains the fuzzy search character "?", then execute the second fuzzy search.
[0030] The first fuzzy search includes: for query keywords ,in Given characters 1 to t, and the character "*" as the (t+1)th character, find the longest substring of w in the prefix tree T. ,if Then make ,if Then Treat it as the root node to obtain the subtree Extract subtree Middle leaf node The first k objects are added to R; among them, for The value is The node, This is for string concatenation operations.
[0031] The second fuzzy search includes: for query keywords , in The string is obtained by searching the prefix tree T for characters from the 1st to the hth to the tth, and the character "?" as the (h+1th)th character. Longest substring ,if Then make ,if If so, then execute the third fuzzy query.
[0032] The third fuzzy query includes: Each child node is considered as the root node, resulting in a set of search trees. When the root node does not participate in the search, Searching through all trees yields the string. Longest substring ,if ,or and If the child nodes do not contain leaf nodes, then make ,if and If a child node contains a leaf node, then extract that leaf node. The first k objects are added to R; among them, for The value is The node, for The value is The node.
[0033] This includes: if w contains the fuzzy query character "*", then perform the first verification and generation; if w contains the fuzzy query character "?", then perform the second verification and generation.
[0034] The first verification generation includes: in the first fuzzy query, if... From subtree Proof of constructing a prefix tree from the root node of T to the root node of the prefix tree T ,make ,if Calculate the proof in all leaf nodes. ,in , It is a set of keywords that satisfy fuzzy matching. Keywords The current total number of objects, from Proof of constructing a prefix tree from the root node of T to the root node of T ,make ; It is for The generated proof, based on the node information and The root node can be reconstructed.
[0035] The second verification generation includes: in the second fuzzy query, if... ,from Proof of constructing a prefix tree to the root node of T ,make ,if Then, the third verification will be performed.
[0036] The third verification generation includes: in the third fuzzy query, if... ,or and The child nodes do not contain leaf nodes, from Proof of constructing a prefix tree to the root node of T ,make ,if and If the child nodes contain leaf nodes, then calculate... ,by Obtain the subtree from the root node ,make ;
[0037] Step S240: After the light node receives the result R and the verification object VO returned by the full node, it executes the verification algorithm. Use VO to validate R.
[0038] Includes: obtaining the root node hash value of the prefix tree T from the block header. Based on the prefix tree in VO, prove the reconstruction of the root node hash value of T. In the equation If the condition is met, the first verification is performed if w contains the fuzzy query character "*", and the second verification is performed if w contains the fuzzy query character "?".
[0039] The first verification includes: if and Then proceed to step A1, if and Then proceed to step A2.
[0040] Step A1 includes: searching The set of all child node characters Determine whether it contains the character in w. If the query is not included, return 1 to indicate that the query is valid; otherwise, return 0 to indicate that the query is invalid.
[0041] Step A2 includes: according to VO Leaf node reconstruction The root node, and in VO Compare the root node; if they are equal, for All ,if If both conditions are met, return 1 to indicate that the query verification is valid; otherwise, return 0 to indicate that the query verification is invalid.
[0042] The second verification includes: if and Then proceed to step B1, if and Then proceed to step B2, if and Then proceed to step B3.
[0043] Step B1 includes: searching The set of all child node characters Determine whether it contains the character in w. If the query is not included, return 1 to indicate that the query is valid; otherwise, return 0 to indicate that the query is invalid.
[0044] Step B2 includes: searching The set of all child node characters of . ,when When, determine whether it contains the character in w. If the query does not contain the specified value, it returns 1 to indicate that the query validation is valid; otherwise, it returns 0 to indicate that the query validation is invalid. When the query is valid, check if it contains the character "#". If it does not contain "#", return 1 to indicate that the query is valid; otherwise, return 0 to indicate that the query is invalid.
[0045] Step B3 includes: according to Leaf node reconstruction The root node, and in VO Compare the root node; if they are equal, then... If the query is valid, return 1 to indicate that the query is valid; otherwise, return 0 to indicate that the query is invalid.
[0046] Step S250: When a new block is added, the full node executes the data update algorithm. Update blockchain information.
[0047] Includes: new objects Keywords included The information keywords need to be updated. `add` is the set of indices for all keywords in data D that require updates. For each keyword... Find the corresponding leaf node in the prefix tree T and extract the cumulative value. If no corresponding leaf node exists, create a new leaf node and branch, and retrieve the corresponding branch. ,calculate , After adding a new block The total number of objects contained, using renew The corresponding leaf node ,renew The corresponding leaf node ,renew Calculate the hash value of the root node by tracing the ancestor nodes of the corresponding leaf nodes up to the root node. Store in the block header.
[0048] According to a third aspect of the present invention, a computer device is provided, characterized in that it comprises:
[0049] A memory for storing instructions; and a processor for invoking the instructions stored in the memory to execute the method of the first or second aspect.
[0050] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, characterized in that it stores instructions which, when executed by a processor, perform the method of the first or second aspect.
[0051] Compared with the prior art, the above-mentioned technical solution conceived in this invention has at least the following beneficial effects:
[0052] 1. A novel blockchain framework is proposed that allows users to efficiently retrieve the latest data from a blockchain database in a verifiable manner.
[0053] 2. By combining RSA accumulators, inverted indexes, and prefix trees, an Adaptive Data Structure (ADS) is constructed. Based on ranking search, this enables fuzzy keyword querying and validation, as well as efficient dynamic updates of the ADS.
[0054] 3. It enables lightweight nodes to effectively verify the correctness of query results and performs excellently in search, verification, storage, and update operations, making it highly practical.
[0055] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0056] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0057] Figure 1 This is a schematic diagram of a blockchain network.
[0058] Figure 2 This is a schematic diagram of a blockchain ADS1 according to an exemplary embodiment.
[0059] Figure 3 This is a schematic diagram of an inverted index according to an exemplary embodiment.
[0060] Figure 4 This is a schematic diagram of a blockchain ADS2 according to an exemplary embodiment.
[0061] Figure 5 This is a schematic diagram of an index tree according to an exemplary embodiment.
[0062] Figure 6 This is a schematic diagram of an index tree node and an inverted index according to an exemplary embodiment. Detailed Implementation
[0063] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0064] Related terms:
[0065] 1. RSA accumulator
[0066] RSA accumulators are used in the validation phase of a solution, laying the foundation for the correctness of search results. Elements of a set of arbitrary size can be processed by an RSA accumulator to generate a constant-size digest. Furthermore, an RSA accumulator can generate a constant-size witness for any element, thereby proving whether an element is in the set.
[0067] 2. Validation Matrix
[0068] The validation matrix is calculated based on the inverted index of keywords. The inverted index converts the keyword mapping corresponding to an object ID into a mapping from keyword to object ID. Unlike the previous definition, the inverted index in this paper also incorporates the ranking information of each object to achieve Top-K queries. That is, each keyword corresponds to a series of object IDs, which are sorted by the object's time attribute, from oldest to newest.
[0069] The query steps of this invention include: a data initialization step, a data query step, and a data verification step. The process is as follows:
[0070] 1. Full nodes are responsible for building consensus proofs and generating new blocks, achieving consensus among all nodes. The block header adds an ADS structure to the traditional blockchain. Light nodes only store the block header information and participate in the blockchain as users.
[0071] 2. The light node initiates a query request to any full node in the blockchain.
[0072] 3. The full node calculates the result R and the verification object VO based on the information in the blockchain.
[0073] 4. After receiving the result R and the verification object VO returned by the full node, the light node uses VO to verify R.
[0074] 5. When a new block is added, the full node executes the update operation that was performed when adding data to the blockchain.
[0075] Corresponding to different query requests, this invention is divided into two aspects, corresponding to non-fuzzy queries and fuzzy queries respectively.
[0076] The first aspect of this invention is a non-fuzzy query scheme, providing a blockchain-based verifiable keyword Top-K non-fuzzy query method. The main idea is that all nodes construct a structure based on all data, such as... Figure 2The inverted index shown is generated by full nodes sorting the data according to a certain attribute, calculating the verification matrix, and finally calculating ADS1 based on the RSA accumulator and the verification matrix, which is then stored in the block header. When a user queries, they send a query request to any full node. The full node calculates the result R and the verification object VO according to relevant calculation rules. The user then verifies the correctness of R based on VO and the ADS1 in the block header.
[0077] The specific implementation method is as follows:
[0078] Step S110: Execute the key generation algorithm on the full node. And cumulative value generation algorithm To build consensus proof.
[0079] include: For safety parameters, specify the RSA accumulator parameters. and ,in and For large prime numbers, , It is a cyclic group The generators output common parameters and private key .
[0080] This includes: constructing an inverted index based on all data D, where each keyword corresponds to a series of objects sorted from oldest to newest by time; and calculating a validation matrix. Where i represents the i-th keyword, j represents the j-th object in the sorted sequence of keywords, H is the collision-resistant hash function, m is the total number of keywords in D, and n is the total number of objects contained in a single keyword. For the j-th object with the i-th keyword, update when data is updated. ,in, For general hash functions, represent The corresponding prime value is then used to count the number of objects contained in each keyword, and the calculation is performed. ,in This is the total number of objects currently contained in the i-th keyword. Finally, ,Will , and as Add to block header.
[0081] In one embodiment, the content contained in the block header and Structure such as Figure 2 As shown.
[0082] Step S120: The light node initiates a non-fuzzy query request to any full node in the blockchain. The non-fuzzy query request includes the query keyword w and the number of Top-K query results k to the full node.
[0083] Step S130: After receiving the non-fuzzy query request, the full node executes the query algorithm. Obtain the result R, and execute the verification generation algorithm. Calculate the verification object VO and send R and VO to the light node.
[0084] This includes adding the first k objects in the inverted index, from newest to oldest, to R based on w.
[0085] Includes: calculation ,calculate Where w is the r-th key in the inverted index of data D. This represents the total number of objects currently contained in w. .
[0086] Step S140: After the light node receives the result R and the verification object VO returned by the full node, it executes the verification algorithm. Use VO to validate R.
[0087] Includes: Light nodes obtain from the block head Value, Equation If the condition is true, return 0 to indicate verification failure; otherwise, continue verification. calculate And determine the equation The function checks whether the verification is true or false. If it is false, it returns 0 to indicate that the verification failed. If it is true, it returns 1 to indicate that the verification was successful.
[0088] Step S150: When a new block is added, the full node executes the data update algorithm. Update blockchain information.
[0089] Includes: new objects Keywords included The information keywords need to be updated. , Let D be the set of indices for all keywords in data that need to be updated. For each keyword... ,calculate , After adding a new block The total number of objects included, calculated , , In block header storage .
[0090] In one embodiment Examples of operations for updating keywords and inverted indexes are as follows: Figure 4 As shown.
[0091] A second aspect of this invention is a fuzzy search scheme, providing a blockchain-based method for Top-K fuzzy search of verifiable keywords. This scheme extends non-fuzzy schemes, supporting fuzzy searches using the "*" and "?" operators. Figure 4 As shown, this scheme uses a Tire structure as its foundation and combines RSA accumulator technology to construct ADS2, ensuring the correctness and completeness of the fuzzy query results. Here, ADS2 is the hash value of the prefix tree root. This scheme significantly reduces the storage overhead of the blockchain block header while maintaining query efficiency.
[0092] The specific implementation method is as follows:
[0093] The methods include:
[0094] Step S210: Execute the key generation algorithm on the full node. And cumulative value generation algorithm To build consensus proof.
[0095] include: For safety parameters, specify the RSA accumulator parameters. and ,in and For large prime numbers, , It is a cyclic group The generators output common parameters and private key .
[0096] This includes: constructing a prefix tree T based on all data D, and hashing the root node of the prefix tree T. As Save to block header.
[0097] The structure of the prefix tree index in some embodiments is shown below. Figure 5 The information contained in the node can be found here. Figure 6 .
[0098] The prefix tree T is an ordered multi-way tree data structure used to store keywords. A keyword is composed of all the node characters on the path from the root node to each leaf node.
[0099] The non-leaf nodes of the prefix tree T include: the character s, the hash value of the concatenation of the hash values of all its child nodes, and the hash value of the concatenation. A string consisting of the characters of all ancestor nodes. and the set of all child node characters The root node of the prefix tree T has the start character "$".
[0100] The leaf nodes of the prefix tree T include: the terminator "#", and the cumulative value of all objects contained in that leaf node. and the collection of all objects contained in that leaf node , verification matrix H is a collision-resistant hash function, and n is the total number of objects contained in a leaf node. For each keyword corresponding to a leaf node, sort the objects contained within that leaf node from oldest to newest. For the j-th object, For general hash functions, represent The corresponding prime value.
[0101] Step S220: The light node initiates a fuzzy query request to any full node in the blockchain. The fuzzy query request includes the query keyword w and the number of Top-K query results k to the full node, where w contains the fuzzy query character "*" or "?".
[0102] Step S230: After receiving the fuzzy query request, the full node executes the query algorithm. Obtain the query result R, and execute the validation generation algorithm. Calculate the verification object VO and send R and VO to the light node.
[0103] This includes: if w contains the fuzzy search character "*", then execute the first fuzzy search; if w contains the fuzzy search character "?", then execute the second fuzzy search.
[0104] The first fuzzy search includes: for query keywords ,in Given characters 1 to t, and the character "*" as the (t+1)th character, find the longest substring of w in the prefix tree T. ,if Then make ,if Then Treat it as the root node to obtain the subtree Extract subtree Middle leaf node The first k objects are added to R; among them, for The value is The node, This is for string concatenation operations.
[0105] The second fuzzy search includes: for query keywords , in The string is obtained by searching the prefix tree T for characters from the 1st to the hth to the tth, and the character "?" as the (h+1th)th character. Longest substring ,if Then make ,if If so, then execute the third fuzzy query.
[0106] The third fuzzy query includes: Each child node is considered as the root node, resulting in a set of search trees. When the root node does not participate in the search, Searching through all trees yields the string. Longest substring ,if ,or and If the child nodes do not contain leaf nodes, then make ,if and If a child node contains a leaf node, then extract that leaf node. The first k objects are added to R; among them, for The value is The node, for The value is The node.
[0107] This includes: if w contains the fuzzy query character "*", then perform the first verification and generation; if w contains the fuzzy query character "?", then perform the second verification and generation.
[0108] The first verification generation includes: in the first fuzzy query, if... From subtree Proof of constructing a prefix tree from the root node of T to the root node of the prefix tree T ,make ,if Calculate the proof in all leaf nodes. ,in , It is a set of keywords that satisfy fuzzy matching. Keywords The current total number of objects, from Proof of constructing a prefix tree from the root node of T to the root node of T ,make ; It is for The generated proof, based on the node information and The root node can be reconstructed.
[0109] The second verification generation includes: in the second fuzzy query, if... ,from Proof of constructing a prefix tree to the root node of T ,make ,if Then, the third verification will be performed.
[0110] The third verification generation includes: in the third fuzzy query, if... ,or and The child nodes do not contain leaf nodes, from Proof of constructing a prefix tree to the root node of T ,make ,if and If the child nodes contain leaf nodes, then calculate... ,by Obtain the subtree from the root node ,make ;
[0111] Step S240: After the light node receives the result R and the verification object VO returned by the full node, it executes the verification algorithm. Use VO to validate R.
[0112] Includes: obtaining the root node hash value of the prefix tree T from the block header. Based on the prefix tree in VO, prove the reconstruction of the root node hash value of T. In the equation If the condition is met, the first verification is performed if w contains the fuzzy query character "*", and the second verification is performed if w contains the fuzzy query character "?".
[0113] The first verification includes: if and Then proceed to step A1, if and Then proceed to step A2.
[0114] Step A1 includes: searching The set of all child node characters Determine whether it contains the character in w. If the query is not included, return 1 to indicate that the query is valid; otherwise, return 0 to indicate that the query is invalid.
[0115] Step A2 includes: according to VO Leaf node reconstruction The root node, and in VO Compare the root node; if they are equal, for All ,if If both conditions are met, return 1 to indicate that the query verification is valid; otherwise, return 0 to indicate that the query verification is invalid.
[0116] The second verification includes: if and Then proceed to step B1, if and Then proceed to step B2, if and Then proceed to step B3.
[0117] Step B1 includes: searching The set of all child node characters Determine whether it contains the character in w. If the query is not included, return 1 to indicate that the query is valid; otherwise, return 0 to indicate that the query is invalid.
[0118] Step B2 includes: searching The set of all child node characters of . ,when When, determine whether it contains the character in w. If the query does not contain the specified value, it returns 1 to indicate that the query validation is valid; otherwise, it returns 0 to indicate that the query validation is invalid. When the query is valid, check if it contains the character "#". If it does not contain "#", return 1 to indicate that the query is valid; otherwise, return 0 to indicate that the query is invalid.
[0119] Step B3 includes: according to Leaf node reconstruction The root node, and in VO Compare the root node; if they are equal, then... If the query is valid, return 1 to indicate that the query is valid; otherwise, return 0 to indicate that the query is invalid.
[0120] Step S250: When a new block is added, the full node executes the data update algorithm. Update blockchain information.
[0121] Includes: new objects Keywords included The information keywords need to be updated. `add` is the set of indices for all keywords in data D that require updates. For each keyword... Find the corresponding leaf node in the prefix tree T and extract the cumulative value. If no corresponding leaf node exists, create a new leaf node and branch, and retrieve the corresponding branch. ,calculate , After adding a new block The total number of objects contained, using renew The corresponding leaf node ,renew The corresponding leaf node ,renew Calculate the hash value of the root node by tracing the ancestor nodes of the corresponding leaf nodes up to the root node. Store in the block header.
[0122] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.
[0123] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A blockchain-based verifiable keyword Top-K non-fuzzy query method, characterized in that, The blockchain includes full nodes and light nodes, the full nodes are nodes that have synchronized all blockchain data, including block headers and block bodies, each block header includes an ADS structure ; The light node participates in the blockchain as a user, and the light node only contains block header information; the method comprises: Step S110: The full node executes a key generation algorithm and an accumulated value generation algorithm , to construct a consensus proof; comprises: for a security parameter, given RSA accumulator parameters and where and are large prime numbers, , is a generator of the cyclic group outputs public parameters and private key ; comprises constructing inverted index according to data D, wherein each keyword corresponds to a series of objects, the objects are sorted by time from old to new, and a verification matrix is calculated , wherein i represents the ith keyword, j represents the jth object sorted in the keyword, H is an anti-collision hash function, m is the total number of keywords in D, and n is the total number of objects contained in a single keyword, is the jth object of the ith keyword, when data is updated, the verification matrix is updated , wherein is a general hash function, represents corresponding prime value, then the number of objects contained in each keyword is counted, and is calculated is the total number of objects currently contained in the ith keyword, at this time , finally is made , and are added to the block header as Step S120: The light node initiates a non-fuzzy query request to any full node in the blockchain, and the non-fuzzy query request comprises a query keyword w and a Top-K query result number k to the full node; Step S130: After receiving the non-blurred query request, the full node executes a query algorithm Obtain result R, execute verification generation algorithm Calculate verification object VO, and send R and VO to the light node; comprises: according to w, adding the first k objects from new to old corresponding to w in the inverted index of data D into R; comprises calculating , calculating , wherein w is the rth keyword in the inverted index of data D, is the total number of objects currently contained by w, ; Step S140: After the light node receives the result R returned by the full node and the verification object VO, the verification algorithm is executed verify R using VO; Includes: Light nodes obtain from the block head Value, Equation If the condition is true, return 0 to indicate verification failure; otherwise, continue verification. calculate And determine the equation If the condition is not met, return 0 to indicate that the verification failed; if the condition is met, return 1 to indicate that the verification succeeded. Step S150: When there is a new block added, the full node executes the add data update algorithm updating the blockchain information; including: new object containing keywords is the keyword that needs to update information, , is the index set of all keywords that need to update information in data D, for each keyword , calculate , after adding the new block total number of containing objects, calculate , , , store in the block header 2.A blockchain-based verifiable keyword Top-K fuzzy query method, characterized in that, The blockchain includes full nodes and light nodes, the full nodes are nodes that have synchronized all blockchain data, including block headers and block bodies, each block header includes an ADS structure ; The light node participates in the blockchain as a user, and the light node only contains block header information; the method comprises: Step S210: The full node executes a key generation algorithm and an accumulated value generation algorithm , to construct a consensus proof; comprises: for a security parameter, given RSA accumulator parameters and where and are large prime numbers, , is a generator of the cyclic group outputs public parameters and private key ; comprises: constructing a prefix tree T according to the data D, saving the hash value of the root node of the prefix tree T to the block header; and as saving to the block header; The prefix tree T is an ordered multi-path tree data structure, and is used for storing a keyword, wherein all node characters on a path from a root node to each leaf node form a keyword; The non-leaf nodes of the prefix tree T include: a character s, a hash value of a connection of hash values of all child nodes , a string composed of characters of all ancestor nodes , and a set of characters of all child nodes ; the character of the root node of the prefix tree T is a starting symbol "$"; The leaf node of the prefix tree T includes: an end symbol "#", a cumulative value of all objects contained in the leaf node and a set of all objects contained in the leaf node , a verification matrix , H is an anti-collision hash function, n is the total number of objects contained in the leaf node, is the keyword corresponding to the leaf node, the objects contained in the leaf node are sorted from old to new, is the jth object, is a general hash function, represents the corresponding prime value; Step S220: The light node initiates a fuzzy query request to any full node in the blockchain, and the fuzzy query request comprises a query keyword w and a Top-K query result number k to the full node, wherein the w comprises a fuzzy query character "*" or "?". Step S230: After receiving the fuzzy query request, the full node executes the query algorithm Obtain the query result R, and execute the verification generation algorithm Calculate the verification object VO, and send R and VO to the light node; comprises: if w contains the fuzzy query character "*" a first fuzzy query is performed, if w contains the fuzzy query character "?" a second fuzzy query is performed; The first fuzzy search includes: for search keywords ,in Given characters 1 to t, and the character "*" as the (t+1)th character, find the longest substring of w in the prefix tree T. ,if Then make ,if Then Treat it as the root node to obtain the subtree Extract subtree Middle leaf node The first k objects are added to R; among them, for The value is The node, For string concatenation operations; The second fuzzy query includes: for the query keyword , wherein is the 1st to the hth and the tth character, the character "?" is the (h+1)th character, and a longest substring of the string is searched in the prefix tree T , if , then , if , a third fuzzy query is executed; The third fuzzy query includes: Each child node is considered as the root node, resulting in a set of search trees. When the root node does not participate in the search, Searching through all trees yields the string. Longest substring ,if ,or and If the child nodes do not contain leaf nodes, then make ,if and If a child node contains a leaf node, then extract that leaf node. The first k objects are added to R; among them, for The value is The node, for The value is Nodes; comprises: if w contains the ambiguous query character "*" a first verification generation is performed, if w contains the ambiguous query character "?" a second verification generation is performed; The first verification generation comprises: in the first fuzzy query, if , a prefix tree proof is constructed from the root node of the subtree to the root node of the prefix tree T , such that , if , the proofs in all leaf nodes are calculated , wherein , is a set of keywords satisfying the fuzzy match, is the total number of objects currently contained by the keyword , a prefix tree proof is constructed from the root node of the subtree to the root node of the prefix tree T , such that ; is the proof generated for , and the root node can be reconstructed according to the node information inside and . The second verification generation comprises: in the second fuzzy query, if From the root node of T to construct a prefix tree proof Make If Then execute the third verification generation; The third verification generation comprises: in the third fuzzy query, if , or and The leaf node is not contained in the child node of The prefix tree proof is constructed from the root node of T , so that If and The leaf node is contained in the child node of , the subtree is obtained with the root node , so that ; Step S240: After the light node receives the result R returned by the full node and the verification object VO, the verification algorithm is executed The result R is verified using the VO; comprising: obtaining a root node hash value of a prefix tree T from a block header , reconstructing the root node hash value of T according to a prefix tree proof in the VO , in case of equality , performing a first verification if w contains the fuzzy query character "*" and performing a second verification if w contains the fuzzy query character "?" The first verification comprises: if and then step Al is performed, if and then step A2 is performed; Step A1 includes: looking up the set of all child characters of , determining whether it contains the characters in w , and returning 1 if it does, indicating that the query is valid, or 0 if it does not, indicating that the query is invalid; Step A2 includes reconstructing the leaf node according to the leaf node in VO , reconstructing the root node according to the root node in VO , and comparing the root node in VO , if the following conditions are all true , return 1 indicating that the query verification is valid, otherwise return 0 indicating that the query verification is invalid; The second verification comprises: if and then step B1 is performed, if and then step B2 is performed, if and then step B3 is performed; Step B1 includes: looking up the set of all child characters of , determining whether it contains the characters in w , and returning 1 if it does, indicating that the query is valid, or 0 if it does not, indicating that the query is invalid. Step B2 includes: looking up the set of all child characters of when , determining whether it contains the characters in w , if not, returning 1 to indicate that the query verification is valid, otherwise returning 0 to indicate that the query verification is invalid, when , determining whether it contains the character "#", if not, returning 1 to indicate that the query verification is valid, otherwise returning 0 to indicate that the query verification is invalid; Step B3 includes: reconstructing the root node of from the leaf nodes in and comparing with the root node of in VO, in the case of equality, if holds, return 1 indicating that the query verification is valid, otherwise return 0 indicating that the query verification is invalid; Step S250: When there is a new block added, the full node executes the add data update algorithm updating the blockchain information; including: new object containing keywords is the keyword that needs to update information, , add is the index set of all keywords that need to update information in data D, for each keyword , find the corresponding leaf node in prefix tree T, extract the cumulative value , if there is no corresponding leaf node, create a new leaf node and branch and take , calculate , after adding the new block total number of objects contained, use update the , update the , update the ancestor node of the corresponding leaf node until the root node, calculate the hash value of the root node store to the block header.
3. A computer device, comprising: Comprise: A memory for storing instructions; And A processor for calling the instructions stored in the memory to execute the method of claim 1 or 2.
4. A computer-readable storage medium, characterized in that, Instructions are stored, and when the instructions are executed by a processor, the method of claim 1 or 2 is executed.
Citation Information
Patent Citations
Verification method and system for space text Top-k query in outsourced database
CN104536984A
Fuzzy query encryption method supporting dynamic verification in unreliable cloud computing environment
CN106776904A