Verifiable cross-domain query method and device, equipment and storage medium
By building an Id tree, a commitment tree, a dictionary tree and a scope query tree, combined with the blockchain verification mechanism, the compatibility and accuracy problems of multiple query types in cross-domain queries are solved, and verifiable cross-domain queries of data are realized.
Patent Information
- Application Number
- CN202510582539.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-08-12
AI Technical Summary
The prior art cannot be compatible with multiple query types at the same time, and cannot effectively verify the accuracy of query data. It is especially difficult to support fine-grained non-aggregation queries and multi-dimensional aggregation queries in cross-domain queries.
Build an Id tree, a commitment tree, a dictionary tree and a scope query tree, use the blockchain to store the hash value of the tree root node of the query tree, generate proof content and perform on-chain verification to ensure the correctness of the query results.
Cross-domain queries that are compatible with multiple query types are realized to ensure the accuracy and immutability of query results. Through on-chain proof storage and off-chain proof mechanisms, data traceability is provided.
Smart Images

Figure CN120470152A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of data processing technology, and more specifically, to a verifiable cross-domain query method, apparatus, device, and storage medium. Background Art
[0002] In various fields today, departments often store large amounts of data in different locations. Work often requires data from various departments as support, so cross-domain queries are necessary to obtain data stored in different locations while ensuring data accuracy. In existing technologies, a data query system can be established to input corresponding query conditions and obtain the corresponding data.
[0003] In the prior art, each query system cannot be compatible with various types of query requirements at the same time, and cannot effectively verify the accuracy of the queried data. Summary of the Invention
[0004] The embodiments of the present application provide a verifiable cross-domain query method, apparatus, device, and storage medium, which are intended to implement verifiable cross-domain query that is compatible with multiple query types.
[0005] A first aspect of an embodiment of the present application provides a verifiable cross-domain query method, the method comprising: Determine a corresponding query tree based on the query conditions in the received query statement. The query tree includes at least an ID tree, a commitment tree, a dictionary tree, and a range query tree. The hash value of the root node of the query tree is stored in a backup in the blockchain. Obtaining corresponding query results according to the query tree and the query conditions; The query result and the proof content generated during the query process are sent to the querying party, so that the querying party reconstructs the root node hash value of the query tree based on the proof content and the query result, and compares it with the root node hash value corresponding to the query tree stored on the blockchain to determine whether the query result is correct.
[0006] Optionally, before determining the corresponding query tree according to the query condition in the received query statement, the method further comprises: receiving a target data table; A corresponding ID tree, commitment tree, dictionary tree, and range query tree are established for the target data table.
[0007] Optionally, establishing a corresponding ID tree, commitment tree, dictionary tree, and range query tree for the target data includes: Dividing the target data table into a plurality of windows of the same size; For each of the windows, a corresponding ID is assigned to each data object in the keyword column of the window through a loop counter, where the data object is character data; Taking each of the IDs as a leaf node, mapping the leaf nodes to corresponding positions in the ID tree, and constructing the ID tree, wherein the ID tree has a preset branching factor, and the non-leaf nodes of the ID tree contain hash values corresponding to the non-leaf nodes; Calculate the hash value corresponding to each data object, and store the hash value in the leaf node corresponding to the Id, where the data object is character data.
[0008] Optionally, the method further includes: Dividing the target data table into a plurality of windows of the same size; Sort each row of data in each window according to the value of any value column; For each window, a corresponding ID is assigned to each data object of the value column in the window through a loop counter, where the data object is numerical data; For each of the windows, the Id, value, random number, and Pedersen commitment corresponding to the data object of each of the numerical columns in the window are used as leaf nodes to construct the commitment tree. The Pedersen commitment is generated by the value and the random number, and each non-leaf node of the commitment tree includes the hash value corresponding to the non-leaf node.
[0009] Optionally, the method further includes: For each of the windows, the keywords of each keyword column in the window and the IDs corresponding to the data objects in other columns are set as multiple key-value pairs; For each window, store the byte slice corresponding to each keyword in the window, the ID set of the data objects covered by the node, the accumulated value of the ID set corresponding to the node, and the hash value of the node into a leaf node; Store the byte slice corresponding to the keyword, the ID set of the data objects covered by the node, the accumulated value of the ID set corresponding to the node, the hash values of all child nodes of the node, and the node hash value into the root node; Store the byte slice corresponding to the keyword, the hash values of all child nodes of the node, and the hash value of the node in the intermediate node; The dictionary tree is constructed according to the leaf nodes, the intermediate nodes, and the root node.
[0010] Optionally, the method further includes: For each of the windows, the values of each value column in the window and the IDs corresponding to the data objects in other columns are set as multiple key-value pairs; Store the value of each numerical index, the ID set of the data object covered by the node, the accumulated value of the ID set corresponding to the node, and the hash value of the node into the leaf node; The range of each numerical index, the union of the ID sets of all child nodes of each node, the accumulated value of the ID set corresponding to the node, the hash value of the node, and the hash values of all child nodes of each node are regarded as non-leaf nodes; The range query tree is constructed according to the leaf nodes and the non-leaf nodes.
[0011] Optionally, determining a corresponding query tree according to a query condition in the received query statement includes: When the query condition in the query statement represents that the query operation is a sum query, determining that the corresponding query tree is the range query tree, the dictionary tree, and the commitment tree; In a case where the query condition in the query statement represents that the query operation is a count query, determining that the corresponding query tree is the dictionary tree and the range query tree; When the query condition in the query statement represents that the query operation is a maximum value query or a minimum value query, the corresponding query tree is determined to be a dictionary tree, a range query tree, or a commitment tree.
[0012] When the query condition in the query statement represents that the query operation is a non-aggregate query, the corresponding query tree is determined to be a dictionary tree, a range query tree, a commitment tree, or an ID tree.
[0013] Optionally, obtaining corresponding query results according to the query tree and the query condition includes: In a case where the query condition represents a sum query operation, obtaining a set of IDs that meet the condition in the range query tree or the dictionary tree according to the query condition, and generating a Merkle proof corresponding to the set of IDs, wherein the Merkle proof is used to verify the correctness of the set of IDs; Search the commitment tree according to the ID set to obtain a corresponding data object set, a random number set, and a commitment set, where the data object is numerical data; Accumulating the data object set, random number set, and commitment set respectively to obtain the query result; Optionally, the method further includes: In the case where the query condition represents that the query operation is a count query, querying the dictionary tree or the range query tree in a single window according to the query condition to obtain a corresponding ID set; Count the number of elements in the Id collection; Generate correctness proofs corresponding to counting queries using pre-configured cryptographic accumulators; The number of elements in the ID sets in all windows is calculated to obtain the query result.
[0014] Optionally, the method further includes: In a case where the query condition represents a query operation of an average value query, obtaining query results of the sum query and the count query; The query result of the average value query is calculated based on the query results of the sum query and the count query, and the proof content of the sum query and the count query is generated.
[0015] Optionally, the method further includes: In a case where the query condition represents a minimum value query operation, searching the dictionary tree or the range query tree in a single window according to the query condition to obtain a corresponding ID set; Calculate the minimum element in the Id set; generating a proof of the minimum element by the cryptographic accumulator; The commitment tree is queried according to the minimum element to obtain a corresponding data object and generate a corresponding Merkle proof, where the data object is numerical data.
[0016] Optionally, the method further includes: In the case where the query condition represents that the query operation is a non-aggregate query, obtaining a set of IDs that meet the condition in the range query tree or the dictionary tree according to the query condition, and generating a Merkle proof corresponding to the set of IDs, wherein the Merkle proof is used to verify the correctness of the set of IDs; Search the commitment tree according to the ID set to obtain a corresponding data object set, a random number set, and a commitment set as the query result, wherein the data object is numerical data; The ID tree is searched according to the ID set to obtain a set of corresponding data objects as the query result, wherein the data objects are character data.
[0017] A second aspect of an embodiment of the present application provides a verifiable cross-domain query device, the device comprising: A query tree determination module, configured to determine a corresponding query tree based on the query conditions in the received query statement, wherein the query tree includes at least an ID tree, a commitment tree, a dictionary tree, and a range query tree, and the hash value of the root node of the query tree is stored in a backup in the blockchain; A query result acquisition module, configured to obtain corresponding query results according to the query tree and the query conditions; The query result sending module is used to send the query result and the proof content generated during the query process to the query party, so that the query party can reconstruct the root node hash value of the query tree based on the proof content and the query result, and compare it with the root node hash value corresponding to the query tree stored on the blockchain to determine whether the query result is correct.
[0018] A third aspect of an embodiment of the present application provides a readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps in the method described in the first aspect of the present application are implemented.
[0019] A fourth aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described in the first aspect of the present application are implemented.
[0020] Using the verifiable cross-domain query method provided by this application, a corresponding query tree is determined based on the query conditions in the received query statement, wherein the query tree includes at least an ID tree, a commitment tree, a dictionary tree, and a range query tree, and the hash value of the root node of the query tree is stored in a backup in the blockchain; based on the query tree and the query conditions, a corresponding query result is obtained; The query result and the proof content generated during the query process are sent to the querying party, so that the querying party reconstructs the root node hash value of the query tree based on the proof content and the query result, and compares it with the root node hash value corresponding to the query tree stored on the blockchain to determine whether the query result is correct.
[0021] In this application, an ID tree, a commitment tree, a dictionary tree and a range query tree are pre-constructed. After receiving the query statement sent by the query method, the query tree to be used is determined according to the query conditions, and then the corresponding query tree is used to perform the query to obtain the query result. Through the collaborative query of various query trees, various query requirements of the query method are met, and proof content is generated during the query process. The proof content and the query result are sent to the query party together. When the query party obtains the query result, it can reconstruct the corresponding tree root node hash value according to the query result and the proof content, and can also query the tree root node hash value corresponding to the query result in the blockchain, and then verify the query result to ensure the correctness of the query result. Through the on-chain evidence storage and off-chain proof mechanism, the data is traceable and cannot be tampered with, thereby ensuring the correctness of the query result. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0023] Figure 1 This is a schematic diagram of the ID tree structure proposed in one embodiment of the present application; Figure 2 This is a schematic diagram of the commitment tree structure proposed in one embodiment of the present application; Figure 3 This is a schematic diagram of a key-value pair table proposed in one embodiment of the present application; Figure 4 This is a diagram of a dictionary tree structure proposed in one embodiment of the present application; Figure 5 This is a diagram of a dictionary tree query process proposed in an embodiment of the present application; Figure 6 This is the key-value pair representation proposed in one embodiment of the present application; Figure 7 This is a schematic diagram of a range query tree structure proposed in an embodiment of the present application; Figure 8 This is a schematic diagram of a numerical range query proposed in an embodiment of the present application; Figure 9 This is a flowchart of a verifiable cross-domain query method proposed in one embodiment of the present application; Figure 10 This is a schematic diagram of an aggregate query proposed in an embodiment of the present application; Figure 11 This is a schematic diagram of a verifiable cross-domain query device proposed in one embodiment of the present application; Figure 12 FIG. 1 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0025] For ease of understanding, the terms appearing in the embodiments of this application are first explained in a unified manner: ADS: ADS, or Authenticated Data Structure, is a specialized data structure that ensures data integrity and authenticity while supporting efficient data query and verification. The core goal of ADS is to provide verifiability for data operations (such as queries and updates) through cryptographic techniques, enabling users or verifiers to confirm the correctness of query results without having to fully trust the data store.
[0026] Merkle hash tree: A Merkle hash tree is a binary tree (or multi-tree). Its core concept is to extend data integrity verification from a single data block to the entire dataset through layer-by-layer hash calculations. The main function of the Merkle hash tree is to support efficient data integrity verification, enabling: 1) Data integrity verification: Users can verify whether the entire dataset has been tampered with by comparing the Merkle root. If any data block is modified, its hash value will change, ultimately changing the Merkle root. 2) Partial data verification: Users can verify the integrity of the relevant data block without downloading the entire dataset; they only need to obtain the relevant data block and its corresponding Merkle proof (verification path) to verify the integrity of the data block.
[0027] Cryptographic Accumulators: Cryptographic accumulators are functions that map a set to a constant-size digest. Similar to a cryptographic hash function, this digest can be used to prove the corresponding set. In addition, it supports a variety of verifiable set operations, including intersection ( ), Union( ), difference (\), sum (SUM), count (COUNT), minimum (MIN), and maximum (MAX). These set operations can be called in a nested manner and verified using the accumulated value of the input set.
[0028] The cryptographic accumulator scheme consists of the following probabilistic polynomial-time algorithm: 1) : Enter a security parameter and a domain , output the public key .
[0029] 2) : In the input set and public key After that, output The accumulated value of .
[0030] 3) :Input two sets and , a set operation , and the public key , returns the result of the set operation The results and proof are given .
[0031] 4) : Input collection and The accumulated value of , about operations prove , the result set The accumulated value of , and the public key , if and only if , returns 1.
[0032] Commitment mechanism: The cryptographic commitment mechanism is a two-phase interactive protocol involving two parties, the committer and the recipient.
[0033] 1) The first stage: the commitment stage. The committer selects a message m and sends it to the receiver in the form of ciphertext, which means that m will not be changed by the committer.
[0034] 2) Second stage: In the opening stage, the committer discloses the message m and the blinding factor (equivalent to the secret key), which the receiver uses to verify whether it is consistent with the message received in the commitment stage.
[0035] The commitment mechanism has two basic properties: hiding and binding. Hiding means that the commitment value does not leak any information about the message m. Binding means that no malicious party can open the commitment as a message other than m and pass verification. In other words, the recipient can be sure that m is the message corresponding to the commitment.
[0036] Pedersen commitments: Pedersen commitments are a type of commitment mechanism based on the difficulty assumption of the discrete logarithm problem. Pedersen commitments have an important property: homomorphism. This property states that the sum of two Pedersen commitments equals the sum of their plaintexts.
[0037] Bulletproof range proofs: Bulletproof range proofs are an efficient, non-interactive zero-knowledge proof protocol designed for verifying whether a value lies within a specified range. At its core, Bulletproof range proofs transform range proofs into compact mathematical expressions through the inner-product argument. This reduces the proof size from thousands of bytes required by traditional methods to a constant few hundred bytes (e.g., 64 bytes) without requiring a trusted setup. For example, in blockchain scenarios, users can prove that their account balance satisfies "0 ≤ amount ≤ 1,000" at the time of a transaction without revealing the specific value. This verification requires only logarithmic computational complexity (approximately O(log(n))). Bulletproof range proofs are widely used in scenarios requiring both privacy protection and efficient verification, such as private transactions (e.g., hiding amounts in Monero) and data integrity verification (e.g., age compliance checks in medical records).
[0038] In the existing technology, tree-based verifiable query technology supports fewer query types and is not compatible with non-aggregate queries, numerical range queries, keyword matching and aggregate queries. Many tree-based methods support single-dimensional range queries, but do not support multi-dimensional range queries. IntegriDB is designed for outsourced databases and can support multiple query methods, but for keyword matching type queries, it converts keywords into ASCII codes and processes them as numerical values. This method causes the size of the numerical value to grow exponentially with the length of the string, resulting in high storage overhead and lower query efficiency. The cryptographic accumulators used in the verification of many tree-based verifiable query methods have limitations, and the size of the public key required is closely related to the data scale and data size. When the data scale or data size is large, the size of the public key will also increase significantly, resulting in a significant increase in the complexity of public key generation and storage management.
[0039] Existing tree-based verifiable query technologies struggle to support fine-grained non-aggregate queries and multi-dimensional aggregate queries. For example, Changan Chain's verifiable off-chain database ensures the trustworthiness and integrity of off-chain stored data, but it only supports simple numeric range queries. Furthermore, because the leaf nodes of the Merkle hash tree store pointers to data records, the query granularity is relatively coarse and does not support queries on specific fields in a table. vChain+ binds the accumulated values of the leaf nodes of the Merkle hash tree to the complete data record within the block. This makes it unable to support queries on specific fields of data objects and aggregate queries in a blockchain environment. It only supports numeric range queries and keyword matching queries based on block data objects. E2VQ appends aggregate values (such as COUNT, SUM, and AVG) to each node in the Merkle hash tree and verifies the integrity of the aggregate results through a hash chain. However, different query conditions use different trees, resulting in this solution only supporting aggregate queries based on a single condition in a blockchain environment, and unable to implement joint aggregate queries based on multi-dimensional conditions. Specifically, the system can handle single-dimensional aggregation operations such as (SUM(col1) WHERE col2<50), but cannot support queries that require combining multiple conditions (for example, SUM(col1) WHERE col2<50 AND col3 = "A").
[0040] In the embodiment of this application, it is first necessary to construct the ADS of the query system. The construction process of the ADS is as follows: S11: Receive the target data table.
[0041] In this embodiment, the target data table is a data table storing various types of data.
[0042] In this embodiment, the query system first needs to receive a target data table storing data.
[0043] S12: Establishing a corresponding ID tree, commitment tree, dictionary tree, and range query tree for the target data table.
[0044] In this embodiment, Consider a data table with m rows and n columns, as shown in Table 1. For the table's keyword columns, such as the "medicine" column, IDs are assigned to construct an ID tree to support non-aggregate queries. For the table's numeric columns, such as the "amount" column, IDs are assigned to construct a commitment tree to support aggregate queries such as SUM, COUNT, AVG, MIN, and MAX. Next, a range query tree supporting numeric range queries is created using each numeric column as a key and the IDs of the remaining columns as values. A dictionary tree supporting keyword matching queries is also constructed using each keyword column as a key and the IDs of the remaining columns as values. The detailed construction process is described below.
[0045] Table 1 m×n data table
[0046] In order to control the data size in each window, the data table needs to be divided. First, set , used to generate keys and limit the maximum number of objects that can be allocated in each window. Set different limits within the , represents the window size, where , according to the window size Divide the data table into multiple windows.
[0047] The specific steps to construct various trees are as follows: S11: Receive the target data table.
[0048] In this embodiment, various types of data are stored in the target data table, including character data (keyword column) and numeric data (numeric column).
[0049] In this embodiment, the query system first receives the target data table.
[0050] For example, a bank data query system first receives data tables from branches in various locations.
[0051] S12 establishes a corresponding ID tree, commitment tree, dictionary tree and range query tree for the target data table.
[0052] In this embodiment, the ID tree is a fully balanced Merkle hash tree with a fixed branching factor (i.e., each node has a fixed number of children). The commitment tree, like the ID tree, is a fully balanced Merkle hash tree with a fixed branching factor and can assign IDs to the values of numeric columns. Unlike the ID tree, the commitment tree stores the ID, value, random number, and commitment value of each numeric column in its leaf nodes. The dictionary tree and range query tree are also Merkle hash trees, used for keyword matching queries and numeric range queries, respectively.
[0053] In this embodiment, after receiving the target data table, a corresponding ID tree, commitment tree, dictionary tree, and range query tree are established for the target data table. The specific steps include: S12-1: Divide the target data table into multiple windows of the same size.
[0054] In this embodiment, when establishing the ID tree, the data table is first divided into multiple windows of the same size, and the size of each window does not exceed the preset maxid.
[0055] S12-2: For each window, a corresponding ID is allocated to each data object in the keyword column of the window through a loop counter, where the data object is character data.
[0056] In this embodiment, for each window, a corresponding ID is allocated to each data object (character data) in the keyword column of the window through a loop counter.
[0057] S12-3: Take each of the Ids as a leaf node, map the leaf nodes to corresponding positions in the Id tree, and construct the Id tree. The Id tree has a preset branching factor, and the non-leaf nodes of the Id tree contain hash values corresponding to the non-leaf nodes.
[0058] In this embodiment, leaf nodes are the basic units for constructing a Merkle hash tree. Non-leaf nodes are the parent nodes of leaf nodes. The branching factor is a core parameter in a tree data structure that measures the number of branches at a node, directly affecting the tree's height and operational efficiency. Each node corresponds to a different hash value.
[0059] In this embodiment, each ID in the window is stored as a leaf node to construct a corresponding ID tree, each ID tree having a preset branching factor. The non-leaf nodes of the ID tree contain corresponding hash values.
[0060] S12-4: Calculate the hash value corresponding to each keyword, and store the hash value in the leaf node corresponding to the Id.
[0061] In this embodiment, after each ID is mapped to a corresponding position in the ID tree, a hash value of the data object (character data) corresponding to each ID is calculated, and the hash value is stored in the corresponding leaf node.
[0062] For example, in order to support non-aggregation queries on specific fields of the keyword column, an ID tree is constructed for the keyword column.
[0063] Assigning IDs: Within each window, the system traverses each data object (character data) in the key column and assigns an atomic identifier to each data object (character data) in the key column using a loop counter modulo maxid. Whenever a new data object (character data) needs to be inserted into the tree, the counter is incremented and a new ID is assigned to the data object.
[0064] Position mapping: Based on the assigned ID, the data object (character data) is inserted into the ID tree. Since the ID tree is a completely balanced tree with a fixed branching factor, the branching factor can be used as a base to convert the ID into a base-12 β-radix (e.g., ID = 5 and β = 3 corresponds to base-12 β). The resulting digit sequence is directly mapped to the hierarchical path of the tree node, thereby calculating the data object's position in the tree.
[0065] The leaf nodes of the Id tree contain . Is a hash value. When a new data object (character data) needs to be inserted into the ID tree, its hash value is calculated and stored in the leaf node. Whenever a new leaf node is inserted, a unique ID is assigned to the node. The ID is obtained by a modulus of The counter is generated incrementally, ensuring the uniqueness and traceability of each data object (character data).
[0066] The non-leaf nodes of the Id tree contain , here is the hash value ,in It is The hash value of each child node.
[0067] refer to Figure 1 , Figure 1 This is a schematic diagram of the ID tree structure proposed in one embodiment of the present application. Figure 1 As shown: Id=1 corresponds to the data object "Aspirin" in the "medicine" column. Suppose you need to query the value corresponding to Id=1. The query and verification process is as follows: Query: Since the branching factor of Figure 1 is 2, Id=1 can be converted to binary "01", that is, the level path [0,1], and then by tracing the 0th node of the first level in the tree , the first node of the second layer To determine the location of "aspirin". With the ID tree and query ID, the ID tree can be used to verify the query result just like in a normal Merkle hash tree. The data party will return the result ,prove To the inquiring party.
[0068] The querying party reconstructs the hash value of the root node of the ID tree based on the result and proof, and compares it with the hash value of the root node stored in the blockchain. If the verification is successful, the data object can be guaranteed to be It does correspond to Id=1. The method for calculating the hash value of the root node of the tree is: first calculate the hash value of the query result , then use the hash value of the sibling node in the proof Calculate upwards layer by layer until the hash value of the root node is obtained.
[0069] In this embodiment, the ID tree construction provides an efficient and scalable method for managing and querying data objects in keyword columns within data tables. Through window partitioning, ID assignment, and a fully balanced tree structure, it effectively controls data size and significantly improves the efficiency of query and insert operations. It also provides strong support for the application of cryptographic accumulators in large-scale data scenarios while reducing the complexity of public key generation and storage management.
[0070] In this embodiment, the method further includes: S12-5: Divide the target data table into multiple windows of the same size.
[0071] In this embodiment, in order to control the data size in each window, the commitment tree needs to divide the data table like the ID tree, and a commitment tree is constructed in each window.
[0072] S12-6: Sort each row of data in the target data table according to the value of any value column.
[0073] In this embodiment, in order to construct the commitment tree, each row of data in the target data table is first sorted according to the value of the value column.
[0074] S12-7: For each window, assign a corresponding ID to each data object in the value column in the window through a loop counter, where the data object is numerical data.
[0075] In this embodiment, when creating the commitment tree, it is necessary to allocate a corresponding ID to each data object in the value column in the window through a loop counter, and the data object is numerical data.
[0076] S12-8: For each of the windows, the Id, value, random number, and Pedersen commitment corresponding to the value of each of the value columns in the window are used as leaf nodes to construct the commitment tree, wherein the Pedersen commitment is generated by the value and the random number, and each non-leaf node of the commitment tree includes a hash value corresponding to the non-leaf node.
[0077] In this embodiment, for the keyword in each window, the Id, value, random number, and Pedersen commitment corresponding to the value of the numerical column in the window are used as leaf nodes, and the leaf nodes are mapped to the corresponding places in the commitment tree to construct a commitment tree. The Pedersen commitment is generated by the values corresponding to the numerical column and the random number, and each non-leaf node of the commitment tree contains the hash value corresponding to the non-leaf node.
[0078] For example, Table 2 sorts the contents of Table 1 by amount. To support MIN / MAX queries, the present invention first sorts the data table by the aggregate attribute. After sorting the "amount" column, Table 2 is as follows: Table 2
[0079] According to Table 2, construct Figure 2 The commitment tree shown, Figure 2 This is a schematic diagram of the commitment tree structure proposed in one embodiment of the present application. Figure 2 It includes a root node, two non-leaf nodes and four leaf nodes.
[0080] Among them, the commitment tree subnode contains I Whenever a new leaf node is inserted, it is assigned a unique ID. This ID is generated by incrementing a counter modulo maxid, ensuring the uniqueness and traceability of each data object. v represents the value corresponding to each row of a numeric column (such as the "amount" column). r represents a random number generated for each row. represents a Pedersen commitment generated from a numerical value and a random number. .
[0081] The non-leaf nodes of the commitment tree contain : hash value ,in It is The hash value of each child node.
[0082] As shown in Figure 2, Id=1 corresponds to the data object "17" in the "amount" column. If you need to query the value corresponding to Id=1, the query and verification process is as follows: Verification: The query party first Calculating Commitment Value , and P middle Then, use and The root node hash value of the reconstructed commitment tree is compared with the root node hash value stored in the blockchain. If the verification passes, it can be confirmed that the data object "17" does correspond to ID=1. The method for calculating the root node hash value is: first calculate the hash value of the query result , then use the hash value of the sibling node in the proof Calculate upwards layer by layer until the hash value of the root node is obtained.
[0083] In this embodiment, the commitment tree supports aggregate queries. For example, a SUM query first retrieves a set of matching IDs using the dictionary trie (or range query tree). The commitment tree then retrieves the corresponding values for each ID and adds these values to the commitment value. The querying party leverages the homomorphic nature of Pedersen commitments, combined with the ADS root stored on-chain, the result, and the proof to verify data integrity.
[0084] In this embodiment, the method further includes: S12-9: For each of the windows, set the keywords of each keyword column in the window and the IDs corresponding to the data objects in other columns as multiple key-value pairs.
[0085] In this embodiment, for each window, the keyword of each keyword column in the window and the ID corresponding to the data objects in other columns are set as multiple key-value pairs. The data objects in other columns can be data objects of the keyword column or data objects of the value column.
[0086] S12-10: For each of the windows, the byte slice corresponding to each keyword in the window, the ID set of the data object covered by the node, the accumulated value of the ID set corresponding to the node, and the hash value of the node are stored in the leaf node, where the ID set is the ID set corresponding to the keyword column or the ID set corresponding to the value column.
[0087] In this embodiment, the byte slice corresponding to the keyword refers to the slice obtained after splitting the keyword, and the ID set of the data objects covered by the node is the set of IDs containing all the byte slices.
[0088] In this embodiment, when creating a dictionary tree for each window, the byte slice corresponding to each keyword in the window and the ID set of the data object covered by the node are stored in the leaf node. The ID set is the ID set corresponding to the keyword column or the ID set corresponding to the numerical column, the accumulated value of the ID set corresponding to the node, and the hash value of the node.
[0089] S12-11: Store the byte slice corresponding to the keyword, the ID set of the data object covered by the node, the accumulated value of the ID set corresponding to the node, the hash values of all child nodes of the node, and the node hash value into the root node.
[0090] In this embodiment, the byte slice corresponding to the keyword, the ID set of the data object covered by the node, the accumulated value of the ID set corresponding to the node, the hash value of all child nodes of the node, and the node hash value are stored in the root node.
[0091] S12-12: Store the byte slice corresponding to the keyword, the hash values of all child nodes of the node, and the hash value of the node in the intermediate node.
[0092] In this embodiment, the byte slice corresponding to the keyword, the hash values of all child nodes of the node, and the hash value of the node are stored in the intermediate node.
[0093] S12-13: Construct the trie according to the leaf node, the intermediate node, and the root node.
[0094] In this embodiment, the trie is constructed according to the leaf node, the intermediate node, and the root node.
[0095] Exemplarily, if the keyword is used as the query condition, such as "medicine", and the numerical value is used as the attribute to be queried, such as "amount", to construct a query statement, that is, (select amount from table where medicine = "##"). As can be seen from Table 2, the data table has been sorted according to the amount column, and a commitment tree has been constructed, that is, an Id has been assigned to the value of the amount column. Next, key-value pairs will be constructed according to the idea of Figure 3. Figure 3 It is a schematic diagram of the key-value pair table proposed in an embodiment of the present application. Then, a trie as shown in Figure 4 is constructed according to the key-value pairs. Figure 4 It is a schematic diagram of the trie structure proposed in an embodiment of the present application.
[0096] Figure 4 It includes: Trie leaf node: contains . The byte slice representing the keyword, such as "lin" in "amoxicillin". The set of Ids of the data objects covered by node n. The cumulative value of the set of Ids corresponding to node n. The hash value of the node .
[0097] Trie root node: contains . : The byte slice representing the keyword, such as "a" in "amoxicillin". : The set of Ids of the data objects covered by node n. : The cumulative value of the set of Ids corresponding to node n. : The hash value of node n. , The hash values of all child nodes. .
[0098] Trie intermediate node: contains . , .
[0099] If the query condition is a keyword type: given a keyword matching query of the form "select amount from table where medicine='Amoxicillin'", the data cube should return the prescribed amount of the drug named "Amoxicillin". The specific query and verification process is as follows: Query: Query process is as follows Figure 5 As shown, Figure 5 This is a diagram of the dictionary tree query process proposed in one embodiment of this application. The model first queries the dictionary tree to obtain the result ID set , and generate a Merkle proof
[0100] Then, according to Searching the commitment tree yields the final result He Zheng For verification by the inquiring party.
[0101] Verification: The verification process is divided into two steps, which require verifying the dictionary tree and the commitment tree separately.
[0102] For the verification of the dictionary tree: the querying party needs to reconstruct the hash value of the dictionary tree root node:
[0103]
[0104]
[0105]
[0106]
[0107]
[0108] if If it is the same as the ADS root stored on the chain, the dictionary tree verification passes.
[0109] For the verification of the commitment tree: the query party first Calculating Commitment Value ,and middle Then, use Reconstruct the root node hash value of the commitment tree and compare it with the root node hash value stored in the blockchain. If the verification is successful, the data object can be guaranteed It does correspond to Id=0. The method to reconstruct the hash value of the root node of the tree is: first calculate the hash value of the query result , then use the hash value of the sibling node in the proof Calculate upwards layer by layer until the hash value of the root node is obtained.
[0110] Optionally, the method further includes: S12-14: For each window, the value of each value column in the window and the ID corresponding to the data objects in other columns are set as multiple key-value pairs.
[0111] In this embodiment, for each window, the value of each value column in the window and the ID corresponding to the data objects in other columns are set as multiple key-value pairs. The data objects in other columns can be data objects of keyword columns or data objects of value columns.
[0112] S12-15: Store the value of each numerical index, the ID set of the data objects covered by the node, the accumulated value of the ID set corresponding to the node, and the hash value of the node into the leaf node.
[0113] In this embodiment, in order to construct a range query tree, the value of each numerical index, the ID set of the data objects covered by the node, the accumulated value of the ID set corresponding to the node, and the hash value of the node are first stored in the leaf node.
[0114] S12-16: The range of each numerical index, the union of the ID sets of all child nodes of each node, the accumulated value of the ID set corresponding to the node, the hash value of the node, and the hash values of all child nodes of each node are taken as non-leaf nodes.
[0115] In this embodiment, the range of each numerical index, the union of the ID sets of all child nodes of each node, the accumulated value of the ID set corresponding to the node, the hash value of the node, and the hash values of all child nodes of each node are used as non-leaf nodes.
[0116] S12-17: Construct the range query tree according to the leaf nodes and the non-leaf nodes.
[0117] In this embodiment, a corresponding range query tree is constructed based on leaf nodes and non-leaf nodes.
[0118] For example, Figure 6 As shown, Figure 6 This is the key-value pair representation proposed in one embodiment of the present application. As can be seen from Table 1 and Figure 1, an ID tree has been constructed for the medicine column, that is, an ID is assigned to the value of the medicine column. The key-value pair will be constructed according to the idea of Figure 6. , and then based on the key-value pair Construct the range query tree shown in Figure 7, Figure 7 This is a schematic diagram of a range query tree structure proposed in an embodiment of the present application. Figure 7As shown, the range query leaf node contains ,in : Indicates the value of a numeric index, such as the index is amount=14. : Represents the ID set of data objects covered by node n. : Indicates the cumulative value of the ID set corresponding to node n. : represents the hash value of node n The non-leaf nodes of the range query tree include .in : Indicates the range of a numerical index, such as the amount range [14,86]. : Represents all child nodes of node n The union of sets. : Indicates the cumulative value of the ID set corresponding to node n. : represents the hash value of node n. . : Represents the hash value of all child nodes. .
[0119] If the query condition is a numerical range: Given a range query of the form "select medicine from table where amountbetween 70 and 100", the data should return , that is, the name of the medicine with a prescribed dosage greater than or equal to 70 and less than or equal to 100.
[0120] Query: The numerical range query is shown in Figure 8. Figure 8 This is a diagram of a numerical range query proposed in an embodiment of the present application. The model first queries the range query tree to obtain the result ID set , and generate a Merkle proof
[0121] Then according to Search the Id tree to get He Zheng To the inquiring party.
[0122] Verification: The verification process is divided into two steps, and the range query tree and the ID tree need to be verified separately.
[0123] For range query tree verification: the querying party needs to reconstruct the hash value of the root node of the range query tree:
[0124]
[0125]
[0126]
[0127]
[0128] if If it is the same as the ADS root stored on the chain, the range query tree verification passes.
[0129] For verification of the Id tree: The query party shall follow the results and proof Reconstruct the hash value of the root node of the ID tree and compare it with the hash value of the root node stored in the blockchain. If the verification is successful, the data object can be guaranteed It does correspond to Id=1. The method for calculating the hash value of the root node of the tree is: first calculate the hash value of the query result , then use the hash value of the sibling node in the proof Calculate upwards layer by layer until the hash value of the root node is obtained.
[0130] For multi-dimensional queries, the model can construct multiple Merkle hash trees for different query conditions (a range query tree for numeric columns and a dictionary tree for keyword columns). During query processing, different Merkle hash trees are first searched for different query conditions to obtain a set of query result IDs that meet the query conditions for that dimension. A verifiable set operation is then called to calculate the final set of IDs. The corresponding value is then searched in the commitment tree or ID tree based on the set of IDs, resulting in the final result and proof for verification by the querying party.
[0131] In this embodiment, after various types of trees are created, these query trees are stored in the query system for use when the storage system queries data, and the hash values of the root nodes of these query trees are backed up in the blockchain, so that the querying party can verify the correctness of the query results based on the query trees in the blockchain.
[0132] In this embodiment, by constructing an ID tree, a commitment tree, a dictionary tree, and a range query tree, the target data can be quickly classified and queried. Various query trees can also be combined to complete queries and statistics under complex conditions, and multiple query trees can be established based on windows, effectively reducing the data size of the key and providing accurate and diverse query services while reducing the amount of calculation.
[0133] refer to Figure 9 , Figure 9 This is a flowchart of a verifiable cross-domain query method proposed in one embodiment of the present application. Figure 9 As shown, the method specifically includes the following steps: S21: Determine the corresponding query tree based on the query conditions in the received query statement. The query tree includes at least an ID tree, a commitment tree, a dictionary tree, and a range query tree. The hash values of the root nodes of each query tree are backed up in the blockchain.
[0134] In this embodiment, a query statement is a statement sent by the data querying party to the data query system, containing the query conditions for the data to be retrieved. The ID tree is used to query the data objects (character data) corresponding to the IDs assigned to keyword columns in a data table. The commitment tree is used to query the data objects (numeric data) corresponding to the IDs assigned to numeric columns. The dictionary tree is used to query the IDs of data objects matching a specific keyword. The range query tree is used to query the IDs corresponding to data objects within a certain numeric range.
[0135] In this embodiment, the specific steps of determining the corresponding query tree according to the query conditions in the received query statement include: S21 - 1 : When the query condition in the query statement represents that the query operation is a sum query, determining that the corresponding query tree is the range query tree, the dictionary tree, and the commitment tree.
[0136] In this embodiment, when the query condition in the query statement represents that the query operation is a sum query, the query trees that need to be used are a range query tree, a dictionary tree, and a commitment tree.
[0137] S21 - 2 : When the query condition in the query statement represents that the query operation is a count query, determining that the corresponding query tree is the dictionary tree and the range query tree.
[0138] In this embodiment, when the query condition in the query statement represents that the query operation is a count query, the query trees that need to be used are the dictionary tree and the range query tree.
[0139] S21 - 3 : When the query condition in the query statement represents a query operation of maximum value query or minimum value query, determine the corresponding query tree as a dictionary tree, a range query tree, or a commitment tree.
[0140] In this embodiment, when the query condition in the query statement represents a query operation of maximum value query and minimum value query, the corresponding query tree is determined to be a dictionary tree, a range query tree, or a commitment tree.
[0141] S21-4: When the query condition in the query statement represents that the query operation is a non-aggregate query, determine the corresponding query tree to be a dictionary tree, a range query tree, a commitment tree, or an ID tree.
[0142] In this embodiment, when the query condition in the query statement indicates that the query operation is a non-aggregate query, the query tree required to be used in the non-aggregate query is determined to be a dictionary tree, a range query tree, a commitment tree, or an ID tree.
[0143] S22: Obtain corresponding query results according to the query tree and the query conditions.
[0144] In this embodiment, after determining the corresponding query tree, the data to be queried and the query method in the query condition are determined, and then the required data is searched from the corresponding query tree to obtain the corresponding query result.
[0145] In this embodiment, the specific steps of obtaining the corresponding query results according to the query tree and the query conditions include: S22-1: When the query condition represents that the query operation is a sum query, a set of IDs that meet the conditions is obtained in the range query tree or the dictionary tree according to the query condition, and a Merkle proof corresponding to the ID set is generated, and the Merkle proof is used to verify the correctness of the ID set.
[0146] In this embodiment, after determining the query conditions and determining that the query operation is a sum query, first, according to the query conditions, a set of IDs that meet the conditions is searched in the range query tree or the dictionary tree. During the query, a Merkle proof corresponding to the ID set is generated. The Merkle proof can be used to verify the correctness of the ID set.
[0147] S22-2: Search the commitment tree according to the Id set to obtain a corresponding set of data objects, a set of random numbers, and a set of commitments, where the data objects are numerical data.
[0148] In this embodiment, the commitment tree is searched according to the ID set to obtain a set of corresponding data objects (numeric data), a set of random numbers, and a set of commitments.
[0149] S22-3: Accumulate the data object set, random number set, and commitment set respectively to obtain the query result.
[0150] In this embodiment, after obtaining the set of data objects, the set of random numbers, and the set of commitments, the three sets are accumulated respectively to obtain corresponding query results.
[0151] For example, when querying a single window, the SUM query first searches the range query tree or dictionary tree according to the query conditions to obtain the ID set that meets the conditions. During the search process, the system generates a Merkle proof , used to verify the Id collection The next step is to search the commitment tree based on the Id set to obtain the corresponding data object (numeric data) set. , a set of random numbers , a set of commitments . Accumulate the results of sets V and E respectively Returned to the querying party, and the corresponding commitment values are accumulated using the homomorphism of Pedersen commitment to obtain It is returned to the querying party as a proof so that the querying party can verify whether the returned SUM is correct. Finally, a Merkle proof of the commitment tree is returned. , so that the querying party can verify whether the value found based on the Id set is correct.
[0152] When the query statement is "select sum(amount) from table where medicine= 'Amoxicillin' or medicine='Atropine'", the query process is as follows Figure 10 As shown, Figure 10 This is a schematic diagram of a sum query proposed in an embodiment of the present application. The model first searches the dictionary tree to obtain and the corresponding Merkle proof , and the corresponding Merkle proof , and then call the verifiable set union to calculate the final ID set is {0, 2}, and the corresponding union proof Then search the commitment tree according to the Id set to get the final result and the corresponding Merkle proof , Proof of Commitment = .
[0153] During the verification process, first , and , Reconstruct the hash value of the dictionary tree root node and compare it with the hash value of the dictionary tree root node on the blockchain to verify the correctness of the ID set obtained by the query; then and Verify the correctness of the union operation; then based on the final result and Reconstruct the hash value of the root node of the commitment tree and compare it with the hash value of the root node of the commitment tree on the blockchain to verify whether the value found according to the Id set is correct; finally, based on the result Calculating Commitment ,and The commitment c in is compared to verify the accuracy of the final result.
[0154] In a global sum query, the goal is to calculate the total sum of a field across the entire data table that meets the query criteria (i.e., the global SUM), while providing a verifiable proof to ensure the correctness of the query result. If the data table is divided into M windows, the global SUM query accumulates the local SUMs of each window and generates a global commitment value and proof.
[0155] First, when querying a single window, the intermediate results include: local SUM value ; Local random number and ; The sum of local commitment values ; Local Merkle proof .in .
[0156] Accumulate the local SUM values of all windows to get the global SUM value: = ; 2) Accumulate the values of the local random number sums of all windows to obtain the global random number sum: = ; 3) Using the homomorphism of Pedersen commitment, the sum of the local commitment values of all windows is accumulated to obtain the global commitment value: = .
[0157] Finally, the result and proof are returned to the querying party, who will receive: global SUM value ; Global random number and ; Global commitment value ; Local Merkle proof for each window .
[0158] During verification, we first verify the integrity of the commitment of a single window using the local Merkle proof of each window, and then calculate ), and Compare them. If all are verified, the integrity of the final result can be ensured.
[0159] In this embodiment, the method further includes: S22-4: When the query condition represents that the query operation is a count query, query the dictionary tree or the range query tree in a single window according to the query condition to obtain a corresponding ID set.
[0160] In this embodiment, when the query operation corresponding to the query condition is a count query, the dictionary tree or range query tree is first queried in a single window to obtain a corresponding ID set.
[0161] S22-5: Calculate the number of elements in the Id set.
[0162] In this embodiment, after the corresponding ID set is found, the number of elements in the ID set is calculated.
[0163] S22-6: Generate the correctness proof corresponding to the counting query through a pre-configured cryptographic accumulator.
[0164] In this embodiment, a correctness proof corresponding to the counting query is generated through a pre-configured cryptographic accumulator.
[0165] S22-7: Calculate the number of elements in the ID sets in all windows to obtain the query result.
[0166] In this embodiment, after obtaining the number of elements in each window, the ID set corresponding to each window is sequentially queried, and then the number of elements in the ID sets in all windows is calculated to obtain the query result.
[0167] For example, in a count query, a search is first performed in a single window based on the query criteria, querying the dictionary or range query tree to obtain a set of IDs that meet the criteria. The number of elements in the ID set is then calculated, and a cryptographic accumulator is used to generate a proof of correctness for the COUNT operation. A global COUNT is then calculated for all windows and returned to the querying party.
[0168] In this embodiment, the method further includes: S22-8: When the query condition represents that the query operation is an average value query, query results of the sum query and the count query are obtained.
[0169] In this embodiment, when the query operation corresponding to the query condition is an average value query, query results of a sum query and a count query are obtained.
[0170] S22-9: Calculate the query result of the average value query based on the query results of the sum query and the count query, and generate proof content of the sum query and the count query.
[0171] In this embodiment, the query result of the average value query is calculated through the query results of the sum query and the count query, and the proof content of the sum query and the count query is generated.
[0172] For example, when calculating AVG (average), you need to first calculate the results of COUNT and SUM, then calculate AVG(A) = SUM(A) / COUNT(A) and return it to the querying party. The querying party needs to verify the integrity of the COUNT and SUM results separately to ensure the integrity of the AVG result.
[0173] In this embodiment, the method further includes: S22-10: When the query condition represents a minimum value query operation, the dictionary tree or the range query tree is searched in a single window according to the query condition to obtain a corresponding ID set.
[0174] In this embodiment, when the query operation corresponding to the query condition is a minimum value query, the dictionary tree or the range query tree is first searched in a single window according to the query condition to obtain an ID set that meets the query condition.
[0175] S22-11: Calculate the minimum element in the Id set.
[0176] In this embodiment, after obtaining an ID set that meets the conditions, the smallest element in the ID set is calculated.
[0177] S22-12: Generate a proof of the minimum element using the cryptographic accumulator.
[0178] In this embodiment, a proof corresponding to the minimum element is generated by a cryptographic accumulator, and the proof is used to prove the correctness of the result.
[0179] S22-13: Query the commitment tree according to the minimum element, obtain the corresponding value, and generate the corresponding Merkle proof.
[0180] In this embodiment, after obtaining the minimum element, a query is performed in the commitment tree based on the minimum element to obtain a corresponding numerical value, which is the minimum value, and a corresponding Merkle proof is generated.
[0181] For example, first search in a single window according to the query conditions, query the dictionary tree or range query tree, obtain the ID set that meets the conditions, and then calculate the minimum element in the ID set , using cryptographic accumulators to generate proof of minimum ID , and traverse the commitment tree according to the minimum Id to get the value corresponding to the Id and Merkle proof of commitment tree Since the values are sorted and assigned IDs when the commitment tree is constructed, the smallest ID corresponds to the smallest value.
[0182] During the verification process, we first use verifiable set operations and verify Is it the smallest element in the Id set? Then use verify Is it correct?
[0183] In the case of global minimum query, if the data table is divided into M windows, the minimum value of each window is obtained to obtain a minimum value set , traverse the set and get the global minimum The window is , construct a Bulletproof range proof for this window , Can prove Base value below . In other windows In the case of , then construct a range proof , Can prove Base value below [ ).
[0184] The querying party will receive the following results and proofs: Global minimum ; The window where the global minimum is located ; Range proof for each window ; Merkle proof for each window .
[0185] When the querying party verifies, it first verifies the Merkle proof of each window , then according to , and Verify the range proof for all windows. If all are verified, the final result is correct.
[0186] In another embodiment of the present application, the query process of the maximum value query in a single window is the same as the minimum value query. In the global query, the maximum value set is obtained. , traverse the set and get the global maximum The window is , construct a Bulletproof range proof for this window , Can prove Base value below . In other windows In the case of , then construct a range proof , Can prove Base value below The verification process for MAX global queries is the same as that for MIN global queries.
[0187] In this embodiment, the method further includes: S22-14: When the query condition represents that the query operation is a non-aggregate query, a set of IDs that meet the conditions is obtained in the range query tree or the dictionary tree according to the query condition, and a Merkle proof corresponding to the ID set is generated, and the Merkle proof is used to verify the correctness of the ID set.
[0188] In this embodiment, when the query operation corresponding to the query condition is a non-aggregate query, the data table fields are retrieved (non-aggregate query). At this time, according to the query condition, a set of IDs that meet the conditions is obtained in the range query tree or dictionary tree, and a Merkle proof corresponding to the ID set is generated to verify the correctness of the ID set.
[0189] S22-15: Search the commitment tree according to the Id set to obtain a corresponding data object set, a random number set, and a commitment set as the query result, where the data object is numerical data.
[0190] In this embodiment, the commitment tree is searched according to the Id set to obtain the corresponding data object set, random number set and commitment set, and the obtained set is used as the query result.
[0191] S22-16: Search the Id tree according to the Id set to obtain a set of corresponding data objects as the query result, where the data objects are character data.
[0192] In this embodiment, the ID tree is searched according to the ID set to obtain a set of corresponding data objects, and the obtained set is used as the query result.
[0193] S23: Send the query result and the proof content generated during the query process to the querying party, so that the querying party reconstructs the root node hash value of the query tree based on the proof content and the query result, and compares it with the root node hash value corresponding to the query tree stored on the blockchain to determine whether the query result is correct.
[0194] In this embodiment, the proof content is a Merkle proof generated during the query process. After the query system executes the query operation according to the query conditions sent by the querying party, the query result and the proof content generated during the query process are sent to the querying party. The querying party reconstructs the root node hash value of the query tree based on the proof content and the query result, and then compares it with the root node hash value corresponding to the query tree stored on the blockchain. If the reconstructed root node hash value is the same as the root node hash value stored on the blockchain, it means that the query result is correct. The specific verification method has been explained in the above embodiment.
[0195] In another embodiment of the present application, in a group work scenario, when the relevant data of each subsidiary of the group, such as the data of a technology subsidiary, a financial subsidiary, and a service subsidiary, needs to be interoperable, the required data is queried through cross-domain query technology, and verifiable computing and blockchain technology are combined to achieve query and verification of private data. This application utilizes the decentralized, tamper-proof, and distributed storage characteristics of blockchain technology to design a cross-domain data verifiable query method. Through on-chain evidence storage and off-chain proof mechanisms, the data is traceable and tamper-proof, providing reliable data to various departments, thereby ensuring the credibility of the data transmission process.
[0196] In the above-described embodiments of this application, various query tree types are constructed to meet the various query requirements of the querying party, and these query trees are stored in the blockchain, addressing the privacy protection, data integrity, and query verification issues in cross-domain data queries. By introducing key technologies such as the Authenticated Data Structure (ADS), cryptographic accumulators, Merkle hash trees, and Pedersen commitments, an efficient and secure cross-domain data query framework is proposed. This framework supports multi-dimensional complex queries, including keyword matching queries, numerical range queries, and aggregate queries (such as SUM, COUNT, AVG, MIN, MAX, etc.).
[0197] Existing tree-based verification schemes based on cryptographic accumulators face key management challenges. The size of the accumulator's public key is positively correlated with the data size and numerical value. When processing large-scale, high-dimensional data sets, the key generation and storage costs increase nonlinearly. This application divides the data table into windowed subsets with controllable size, strictly constraining the accumulator's public key size within a preset threshold. At the same time, it utilizes the homomorphism of Pedersen commitments and Bulletproof range proof verification to solve the problem of merging aggregated query results caused by multiple windows, achieving dual optimization of efficiency and key management complexity.
[0198] Current mainstream tree-based authentication schemes suffer from incomplete query semantics support. Their ADS data structure design struggles to accommodate multiple query requirements, including non-aggregate queries, numerical range queries, keyword matching, and aggregate queries. This paper innovatively constructs a hybrid authentication structure that integrates data structures such as the ID tree (for non-aggregate query verification), the range query tree (for numerical range query verification), the dictionary tree (for keyword matching query verification), and the commitment tree (for aggregate query verification). Furthermore, it designs a query semantics parsing engine based on logical operations to enhance the flexibility and diversity of the query model.
[0199] Existing verification schemes suffer from the structural defect of excessive data coupling, which forcibly binds the accumulator value to the entire row of data records, making it impossible to achieve independent verification of the column dimension. This not only causes redundant data transmission during the verification process (for example, when verifying COL2='A', the entire row of non-related data must be loaded), but also directly restricts the feasibility of multi-dimensional conditional aggregation queries (such as SELECTSUM(COL1) WHERE COL2='A' AND COL3>=m). The present invention establishes a column-level independent accumulator system to achieve atomic verification capabilities for each data column, and innovatively designs a commitment tree structure with homomorphic properties, so that the aggregate attribute verification value can be associated with the multi-dimensional query condition, ultimately achieving the verification requirements of complex conditional aggregation queries while maintaining the advantages of independent column verification.
[0200] In the above embodiments of the present application, the construction process of ADS is introduced, including the design and implementation of ID tree, commitment tree, dictionary tree and range query tree. These tree structures ensure the verifiability and integrity of data queries through hash value and cryptographic accumulator technology. The querying party does not need to access the complete data and can verify the correctness of the query results only through partial proof, thereby providing efficient data query and verification means while protecting data privacy. The implementation method of aggregate queries such as SUM, COUNT, AVG, MIN, MAX is described in detail. By dividing the data table into multiple windows, the system can execute queries independently in each window and generate global query results and their proofs based on the homomorphism of Pedersen commitment and Bulletproof range proof technology. The querying party can ensure the accuracy and completeness of the query results by verifying these proofs.
[0201] The hybrid authenticated data structure (ADS) inherits the ID tree, commitment tree, dictionary tree, and range query tree, supporting composite validation for non-aggregate queries, numeric range queries, keyword matching queries, and aggregate queries. The logical operation engine parses composite query semantics, decomposing multi-dimensional conditions into independent queries within different ADS structures. It also supports cross-tree joint validation, providing complete and reliable data. In the column-level independent accumulator system and fine-grained validation, an independent accumulator is built for each column in the data table, enabling atomic validation of column dimensions and eliminating redundant data, eliminating the need to load the entire row of data when validating a specific column.
[0202] Based on the same inventive concept, an embodiment of the present application provides a verifiable cross-domain query device. Figure 11 , Figure 11 FIG is a schematic diagram of a verifiable cross-domain query device 1100 proposed in one embodiment of the present application. Figure 11 As shown, the device includes: A query tree determination module 1101 is configured to determine a corresponding query tree based on the query conditions in the received query statement. The query tree includes at least an ID tree, a commitment tree, a dictionary tree, and a range query tree. The hash value of the root node of the query tree is backed up in the blockchain. A query result acquisition module 1102 is configured to obtain corresponding query results according to the query tree and the query conditions; The query result sending module 1103 is used to send the query result and the proof content generated during the query process to the query party, so that the query party can reconstruct the root node hash value of the query tree based on the proof content and the query result, and compare it with the root node hash value corresponding to the query tree stored on the blockchain to determine whether the query result is correct.
[0203] Optionally, the query tree construction module includes: A first window division submodule, configured to divide the target data table into a plurality of windows of the same size; An ID allocation submodule is configured to allocate a corresponding ID to each data object in the keyword column of each window through a loop counter, wherein the data object is character data; An ID tree construction submodule is configured to treat each ID as a leaf node, map the leaf node to a corresponding position in the ID tree, and construct the ID tree, wherein the ID tree has a preset branching factor, and the non-leaf nodes of the ID tree contain hash values corresponding to the non-leaf nodes; The hash value calculation submodule is used to calculate the hash value corresponding to each keyword and store the hash value in the leaf node corresponding to the Id.
[0204] Optionally, the device further comprises: A second window division submodule, configured to divide the target data table into a plurality of windows of the same size; A second sorting submodule is used to sort each row of data in each window in the target data table according to the value of any value column; An ID allocation submodule is configured to allocate a corresponding ID to each data object of the value column in each window through a loop counter, wherein the data object is character data; A commitment tree construction submodule is used to construct the commitment tree for each of the windows by using the ID, value, random number, and Pedersen commitment corresponding to the data object of each of the numerical columns in the window as leaf nodes. The Pedersen commitment is generated by the value and the random number, and each non-leaf node of the commitment tree includes a hash value corresponding to the non-leaf node.
[0205] Optionally, the device further comprises: A key-value pair creation submodule is used to set, for each window, the keywords of each keyword column in the window and the IDs corresponding to the data objects in other columns as multiple key-value pairs; The first leaf node creation submodule is used to store, for each window, the byte slice corresponding to each keyword in the window, the ID set of the data objects covered by the node, the accumulated value of the ID set corresponding to the node, and the hash value of the node into the leaf node; A root node creation submodule is used to store the byte slice corresponding to the keyword, the ID set of the data object covered by the node, the accumulated value of the ID set corresponding to the node, and the node hash value into the root node; An intermediate node creation submodule is used to store the byte slice corresponding to the keyword and the hash value of the node into the intermediate node; The dictionary tree creation submodule is used to construct the dictionary tree according to the leaf nodes, the intermediate nodes, and the root node.
[0206] Optionally, the device further comprises: A key-value pair creation submodule is used to set, for each window, the value of each value column in the window and the ID corresponding to the data object of other columns as multiple key-value pairs; The second leaf node creates a submodule, which is used to store the value of each numerical index, the ID set of the data object covered by the node, the accumulated value of the ID set corresponding to the node, and the hash value of the node into the leaf node; The non-leaf node creation submodule is used to take the range of each numerical index, the union of the ID sets of all child nodes of each node, the accumulated value of the ID set corresponding to the node, the hash value of the node, and the hash values of all child nodes of each node as non-leaf nodes; The range query tree construction submodule is used to construct the range query tree according to the leaf nodes and the non-leaf nodes.
[0207] Optionally, the query tree determination module includes: A first query tree determination submodule is configured to determine, when the query condition in the query statement represents a sum query operation, whether the corresponding query tree is the range query tree, the dictionary tree, or the commitment tree; A second query tree determination submodule is configured to determine, when the query condition in the query statement represents that the query operation is a count query, that the corresponding query tree is the dictionary tree and the range query tree; A third query tree determination submodule is configured to determine, when the query condition in the query statement represents a maximum value query or a minimum value query, whether the corresponding query tree is a dictionary tree, a range query tree, or a commitment tree; The fourth query tree determination submodule is used to determine the corresponding query tree as a dictionary tree, a range query tree, a commitment tree, or an ID tree when the query condition in the query statement represents that the query operation is a non-aggregate query.
[0208] Optionally, obtaining the query result includes: A first ID set acquisition submodule is configured to obtain an ID set that meets the conditions in the range query tree or the dictionary tree according to the query condition when the query condition represents a sum query operation, and to generate a Merkle proof corresponding to the ID set, wherein the Merkle proof is used to verify the correctness of the ID set; A commitment tree search submodule, configured to search the commitment tree according to the ID set to obtain a corresponding set of data objects, a set of random numbers, and a set of commitments, wherein the data objects are numerical data; A first query result obtaining submodule is configured to accumulate the set of data objects, the set of random numbers, and the set of commitments to obtain the query result; Optionally, the device further comprises: A second ID set acquisition submodule is configured to query the dictionary tree or the range query tree in a single window according to the query condition to obtain a corresponding ID set when the query condition represents that the query operation is a count query; The element number calculation submodule is used to calculate the number of elements in the Id set; The correctness proof generation submodule is used to generate the correctness proof corresponding to the counting query through a pre-configured cryptographic accumulator; The second query result obtaining submodule is used to calculate the number of elements in the ID set in all windows to obtain the query result.
[0209] Optionally, the device further comprises: A third query result obtaining submodule is configured to obtain query results of the sum query and the count query when the query condition characterizing the query operation is an average value query; The query result calculation submodule is used to calculate the query result of the average value query based on the query results of the sum query and the count query, and generate proof content of the sum query and the count query.
[0210] Optionally, the device further comprises: A third ID set acquisition submodule is configured to, when the query condition represents a minimum value query, search the dictionary tree or the range query tree in a single window according to the query condition to obtain a corresponding ID set; A minimum element calculation submodule, used to calculate the minimum element in the ID set; A minimum element proof generation submodule, configured to generate a proof of the minimum element using the cryptographic accumulator; The Merkle proof generation submodule is used to query the commitment tree according to the minimum element, obtain the corresponding value, and generate the corresponding Merkle proof.
[0211] Optionally, the device further comprises: A fourth ID set acquisition submodule is configured to obtain, when the query condition represents a non-aggregate query, an ID set that meets the condition in the range query tree or the dictionary tree according to the query condition, and generate a Merkle proof corresponding to the ID set, wherein the Merkle proof is used to verify the correctness of the ID set; a fourth query result obtaining submodule, configured to search the commitment tree according to the ID set to obtain a corresponding set of data objects, a set of random numbers, and a set of commitments as the query result, wherein the data objects are numerical data; The fifth query result obtaining submodule is used to search the ID tree according to the ID set to obtain a set of corresponding data objects as the query result, and the data objects are numerical data.
[0212] Based on the same inventive concept, another embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor. When executed, the processor implements the steps of the verifiable cross-domain query method described in any of the above embodiments of the present application.
[0213] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0214] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0215] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0216] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0217] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0218] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0219] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0220] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0221] The above is a detailed introduction to the verifiable cross-domain query method, device, equipment and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A verifiable cross-domain query method, characterized in that: The method comprises: Determine a corresponding query tree based on the query conditions in the received query statement. The query tree includes at least an ID tree, a commitment tree, a dictionary tree, and a range query tree. The hash value of the root node of the query tree is stored in a backup in the blockchain. Obtaining corresponding query results according to the query tree and the query conditions; The query result and the proof content generated during the query process are sent to the querying party, so that the querying party reconstructs the root node hash value of the query tree based on the proof content and the query result, and compares it with the root node hash value corresponding to the query tree stored on the blockchain to determine whether the query result is correct.
2. The verifiable cross-domain query method according to claim 1, characterized in that: Before determining the corresponding query tree according to the query condition in the received query statement, the method further includes: receiving a target data table; A corresponding ID tree, commitment tree, dictionary tree, and range query tree are established for the target data table.
3. The verifiable cross-domain query method according to claim 2, characterized in that: The step of establishing a corresponding ID tree, commitment tree, dictionary tree, and range query tree for the target data table includes: Dividing the target data table into a plurality of windows of the same size; For each of the windows, a corresponding ID is assigned to each data object in a single keyword column in the window through a loop counter, wherein the data object is character data; Taking each of the IDs as a leaf node, mapping the leaf nodes to corresponding positions in the ID tree, and constructing the ID tree, wherein the ID tree has a preset branching factor, and the non-leaf nodes of the ID tree contain hash values corresponding to the non-leaf nodes; Calculate the hash value corresponding to each keyword, and store the hash value in the leaf node corresponding to the Id, where the keyword is character data.
4. The verifiable cross-domain query method according to claim 3, characterized in that: The method further comprises: Dividing the target data table into a plurality of windows of the same size; Sort each row of data in each window according to the value of any value column; For each window, a corresponding ID is assigned to each data object of the value column in the window through a loop counter, where the data object is numerical data; For each window, the ID, value, random number, and Pedersen commitment corresponding to the data object of each value column in the window are used as leaf nodes to construct the commitment tree, where the Pedersen commitment is generated by the value and the random number, and each non-leaf node of the commitment tree includes a hash value corresponding to the non-leaf node; For each of the windows, the keywords of each keyword column in the window and the IDs corresponding to the data objects in other columns are set as multiple key-value pairs; For each window, store the byte slice corresponding to each keyword in the window, the ID set of the data object covered by the node, the accumulated value of the ID set corresponding to the node, and the hash value of the node in the leaf node. The ID set is the ID set corresponding to the keyword column or the ID set corresponding to the value column; Store the byte slice corresponding to the keyword, the ID set of the data object covered by the node, the accumulated value of the ID set corresponding to the node, the hash value of all child nodes of each node, and the node hash value into the root node; Store the byte slice corresponding to the keyword, the hash value of all child nodes of each node, and the hash value of the node in the intermediate node; Construct the dictionary tree according to the leaf nodes, the intermediate nodes, and the root node; For each of the windows, the values of each value column in the window and the IDs corresponding to the data objects in other columns are set as multiple key-value pairs; Store the value of each numerical index, the ID set of the data object covered by the node, the accumulated value of the ID set corresponding to the node, and the hash value of the node into the leaf node; The range of each numerical index, the union of the ID sets of all child nodes of each node, the accumulated value of the ID set corresponding to the node, the hash value of the node, and the hash values of all child nodes of each node are regarded as non-leaf nodes; The range query tree is constructed according to the leaf nodes and the non-leaf nodes.
5. The verifiable cross-domain query method according to claim 1, characterized in that: Determining a corresponding query tree according to the query condition in the received query statement includes: When the query condition in the query statement represents that the query operation is a sum query, determining that the corresponding query tree is the range query tree, the dictionary tree, and the commitment tree; In a case where the query condition in the query statement represents that the query operation is a count query, determining that the corresponding query tree is the dictionary tree and the range query tree; When the query condition in the query statement represents a query operation of maximum value query and minimum value query, determining the corresponding query tree to be a dictionary tree, a range query tree, or a commitment tree; When the query condition in the query statement represents that the query operation is a non-aggregate query, the corresponding query tree is determined to be a dictionary tree, a range query tree, a commitment tree, or an ID tree.
6. The verifiable cross-domain query method according to claim 1, characterized in that: Obtaining corresponding query results according to the query tree and the query conditions includes: In the case where the query condition represents that the query operation is a non-aggregate query, obtaining a set of IDs that meet the condition in the range query tree or the dictionary tree according to the query condition, and generating a Merkle proof corresponding to the set of IDs, wherein the Merkle proof is used to verify the correctness of the set of IDs; Search the commitment tree according to the ID set to obtain a corresponding data object set, a random number set, and a commitment set as the query result, wherein the data object is numerical data; Search the ID tree according to the ID set to obtain a set of corresponding data objects as the query result, wherein the data objects are character data; In a case where the query condition represents a sum query operation, obtaining a set of IDs that meet the condition in the range query tree or the dictionary tree according to the query condition, and generating a Merkle proof corresponding to the set of IDs, wherein the Merkle proof is used to verify the correctness of the set of IDs; Search the commitment tree according to the ID set to obtain a corresponding data object set, a random number set, and a commitment set, where the data object is numerical data; Accumulating the data object set, random number set, and commitment set respectively to obtain the query result; In the case where the query condition represents that the query operation is a count query, querying the dictionary tree or the range query tree in a single window according to the query condition to obtain a corresponding ID set; Count the number of elements in the Id collection; Generate correctness proofs corresponding to counting queries using pre-configured cryptographic accumulators; Calculate the number of elements in the ID set in all windows to obtain the query result; In a case where the query condition represents a query operation of an average value query, obtaining query results of the sum query and the count query; Calculating the query result of the average value query based on the query results of the sum query and the count query, and generating proof content for the sum query and the count query; In a case where the query condition represents a minimum value query operation, searching the dictionary tree or the range query tree in a single window according to the query condition to obtain a corresponding ID set; Calculate the minimum element in the Id set; generating a proof of the minimum element by the cryptographic accumulator; The commitment tree is queried according to the minimum element to obtain a corresponding data object and generate a corresponding Merkle proof, where the data object is numerical data.
7. A verifiable cross-domain query device, characterized in that: The device comprises: A query tree determination module, configured to determine a corresponding query tree based on the query conditions in the received query statement, wherein the query tree includes at least an ID tree, a commitment tree, a dictionary tree, and a range query tree, and the hash value of the root node of the query tree is stored in a backup in the blockchain; A query result acquisition module, configured to obtain corresponding query results according to the query tree and the query conditions; The query result sending module is used to send the query result and the proof content generated during the query process to the query party, so that the query party can reconstruct the root node hash value of the query tree based on the proof content and the query result, and compare it with the root node hash value corresponding to the query tree stored on the blockchain to determine whether the query result is correct.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Verifiable retrieval method and device, equipment, medium and product
CN121705315A