Block chain data query method, device and equipment, medium and program product
By constructing a spatial data index structure of MBR and hash values and a one-dimensional data index structure, combined with Bloom filters, blockchain data queries are optimized, solving the problem of low query efficiency in existing technologies and achieving efficient and accurate data queries.
Patent Information
- Application Number
- CN202510782830.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-12
- Publication Date
- 2025-09-26
AI Technical Summary
Existing blockchain verifiable query solutions are inefficient in processing multi-dimensional aggregate queries and lack suitable data structures to quickly verify the existence of query conditions, resulting in incomplete or incorrect query results.
A spatial data index structure based on the minimum bounding rectangle (MBR) and hash value of spatial data, as well as a one-dimensional data index structure based on the transaction attributes and hash value of one-dimensional data, are constructed. Combined with the Bloom filter structure, the query process is optimized.
By reducing the amount of data comparison, the efficiency of blockchain data query is improved, ensuring the integrity and correctness of the query results.
Smart Images

Figure CN120705182A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to a blockchain data query method, device and equipment, medium and program product. Background Art
[0002] As blockchain-based data storage finds increasing use cases, the demand for querying data stored in blockchain databases is growing. To ensure query integrity and reliability, users can maintain the entire blockchain database and query data locally. However, this approach requires a large amount of data and high maintenance costs. To address this issue, some solutions delegate the storage and query services of complete blockchain data to full nodes, allowing query users to access the full nodes through light nodes and obtain complete information. However, full nodes are not necessarily trustworthy, so the query results obtained by light nodes from full nodes may be incorrect or incomplete. This has led to the emergence of verifiable query solutions.
[0003] Verifiable query schemes mainly rely on Merkle Hash Tree (MHT) and Authenticated Data Structures (ADS) to ensure the integrity and correctness of query results. However, these schemes have shortcomings when processing multi-dimensional aggregate queries of block transactions containing spatial information attributes. They cannot effectively merge spatially adjacent nodes, and when processing blockchain data, they lack suitable data structures to quickly verify the existence of query conditions, resulting in low query efficiency. Summary of the Invention
[0004] The embodiments of the present application provide a blockchain data query method, device and equipment, medium and program product, which can solve the problem of low query efficiency of existing blockchain verifiable queries.
[0005] In a first aspect, an embodiment of the present application provides a blockchain data query method, the method comprising:
[0006] Obtaining industrial chain information sent by the data producer and entering the industrial chain information into the blockchain, wherein the industrial chain information includes spatial data and one-dimensional data other than the spatial data;
[0007] Constructing a spatial data index structure based on the minimum bounding rectangle (MBR) and hash value of the spatial data, and storing the spatial data index structure in the blockchain;
[0008] Constructing a one-dimensional data index structure based on the transaction attributes and hash values of the one-dimensional data, and storing the one-dimensional data index structure in the blockchain;
[0009] Upon receiving a query request sent by a client, determining a query result from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure;
[0010] The query result is sent to the client.
[0011] Optionally, constructing a spatial data index structure based on a minimum bounding rectangle MBR and a hash value of the spatial data includes:
[0012] Obtaining spatial data included in each first leaf node of a first hash tree of a first block, where the blockchain includes a plurality of blocks, and the first block is any one of the plurality of blocks;
[0013] Calculate a first MBR and a first hash value corresponding to the first leaf node based on the spatial data included in the first leaf node;
[0014] Combining the first MBR and the first hash value corresponding to the first leaf node and performing a hash operation to obtain a combined hash value corresponding to the first leaf node;
[0015] According to the order of the first leaf nodes in the first hash tree, a hash operation is performed on the combined hash value corresponding to each of the first leaf nodes layer by layer to obtain a first root node hash value corresponding to the root node of the first hash tree, and the spatial data index structure of the first block includes the first root node hash value and the combined hash value of each of the first leaf nodes.
[0016] Optionally, constructing a one-dimensional data index structure based on the transaction attributes and hash values of the one-dimensional data includes:
[0017] Obtain one-dimensional data included in each second leaf node of the second hash tree of the first block;
[0018] Calculating a node value of the second leaf node based on the transaction attribute of the one-dimensional data included in the second leaf node and the corresponding sorted list;
[0019] Calculating a second hash value of the second leaf node based on the node value of the second leaf node;
[0020] According to the order of the second leaf nodes in the second hash tree, a hash operation is performed on the second hash value of each second leaf node layer by layer to obtain a second root node hash value corresponding to the root node of the second hash tree, and the one-dimensional data index structure of the first block includes the second root node hash value and the second hash value of each second leaf node.
[0021] Optionally, the spatial data index structure and the one-dimensional data index structure both include a Bloom filter structure, which encodes multiple transaction attributes of the spatial data and the one-dimensional data. The Bloom filter structure is used to, upon receiving the query request, compare the code carried by the query request with the code corresponding to the spatial data in the first block and the code corresponding to the multiple transaction attributes of the one-dimensional data in the first block, so as to determine whether the first block contains the data to be queried carried by the query request.
[0022] Optionally, determining a query result from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure includes:
[0023] Determining a second block from the blockchain based on the code carried by the query request and the Bloom filter structure, wherein the code of the Bloom filter structure contained in the second block includes the code carried by the query request;
[0024] Determine a first query result from the one-dimensional data stored in the second block based on the hash value of the one-dimensional data to be queried carried in the query request and the hash value of each node of the second hash tree included in the second block;
[0025] Determine a second query result from the spatial data stored in the second block based on the hash value of the spatial data to be queried carried in the query request, the MBR, and the hash values of each node of the first hash tree included in the second block;
[0026] The first query result and the second query result are aggregated to obtain the query result.
[0027] Optionally, after sending the query result to the client, the method further includes:
[0028] A verification object corresponding to the query result is sent to the client, where the verification object includes the first query result, the second query result, and a traversal record of the first hash tree and the second hash tree included in the second block.
[0029] Optionally, after obtaining the industrial chain information sent by the data producer, the method further includes:
[0030] The industry chain information is stored in the InterPlanetary File System (IPFS).
[0031] In a second aspect, an embodiment of the present application further provides a blockchain data query device, the device comprising:
[0032] A first acquisition module is used to acquire industrial chain information sent by a data producer and enter the industrial chain information into the blockchain, wherein the industrial chain information includes spatial data and one-dimensional data other than the spatial data;
[0033] A first indexing module is configured to construct a spatial data index structure based on a minimum bounding rectangle (MBR) and a hash value of the spatial data, and store the spatial data index structure in the blockchain;
[0034] A second indexing module is configured to construct a one-dimensional data index structure based on the transaction attributes and hash values of the one-dimensional data, and store the one-dimensional data index structure in the blockchain;
[0035] a query module, configured to, upon receiving a query request sent by a client, determine a query result from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure;
[0036] A sending module is used to send the query result to the client.
[0037] In a third aspect, an embodiment of the present application further provides an electronic device comprising a processor, a memory, and a computer program stored on the memory and executable on the processor. When the computer program is executed by the processor, the steps of the blockchain data query method as described in the first aspect are implemented.
[0038] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the blockchain data query method as described in the first aspect are implemented.
[0039] In a fifth aspect, a computer program product is provided, comprising computer instructions, which, when executed by a processor, implement the steps of the blockchain data query method as described in the first aspect.
[0040] In an embodiment of the present application, industrial chain information sent by a data producer is obtained and entered into a blockchain, wherein the industrial chain information includes spatial data and one-dimensional data other than the spatial data; a spatial data index structure is constructed based on the minimum bounding rectangle MBR and hash value of the spatial data, and the spatial data index structure is stored in the blockchain; a one-dimensional data index structure is constructed based on the transaction attributes and hash value of the one-dimensional data, and the one-dimensional data index structure is stored in the blockchain; upon receiving a query request sent by a client, a query result is determined from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure; and the query result is sent to the client. In the above process, a spatial data index structure is constructed based on the MBR and hash value of the spatial data. When querying data, the spatial data carried by the query request can be compared with the spatial data in the blockchain through MBR to query the corresponding spatial data. Since MBR simplifies the spatial range of a group of points or multiple objects into a minimum rectangular boundary, when the spatial data carried by the query request is compared with the spatial data in the blockchain, the two minimum rectangular boundaries are also compared. Compared with the method in the prior art that requires comparing each spatial data point carried by the query request with each spatial data point in the blockchain, the amount of data that needs to be compared can be reduced, thereby improving data query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] 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.
[0042] Figure 1 This is a diagram of the blockchain data query architecture provided by an embodiment of the present application;
[0043] Figure 2 This is a flowchart of a blockchain data query method provided by an embodiment of the present application;
[0044] Figure 3 This is a schematic diagram of the block ADS structure provided by an embodiment of the present application;
[0045] Figure 4 This is a structural diagram of a blockchain data query device provided by an embodiment of the present application;
[0046] Figure 5 This is a structural diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0047] 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 making creative efforts are within the scope of protection of this application.
[0048] The present invention provides a method for querying blockchain data.
[0049] The following describes the definitions related to the blockchain data query method of this application:
[0050] 1. Cryptographic Accumulator: A cryptographic accumulator is a special data structure that serves as the underlying support for block aggregation queries, enabling aggregation queries such as summation (SUM) and average (AVG). For example, a SUM operation calculates the corresponding accumulator value for each data record based on its extended attribute values. Accumulators support adding these values together, so a SUM operation can be performed by calculating the accumulator value of all data records.
[0051] 2. Merkle Hash Tree (MHT): A Merkle Hash Tree (MHT) is a binary tree data structure where leaf nodes contain the hash value of a data record, while non-leaf nodes contain the hash of their child nodes' hash values. This structure allows for rapid verification of the integrity and consistency of data subsets.
[0052] 3. Authenticated Data Structure (ADS): Authenticated Data Structure (ADS) is an efficient cryptographic tool that allows users to quickly verify the correctness of data without accessing the entire dataset. It also supports dynamic data updates, including additions, deletions, and modifications, without compromising security. ADS only stores key information about the data, such as a digest or hash value, thereby optimizing storage space and query efficiency.
[0053] 4. Verification Objects (VO): A data structure used to ensure the integrity of query results. Generated by the full node executing the query, VOs contain all the necessary information to verify the correctness of the query results. VOs enable light nodes to verify that the query results they receive have not been tampered with and are complete without storing the entire blockchain data.
[0054] 5. Data producers: all participants in each link of the industrial chain, including all processes from raw material manufacturers to end consumers, including procurement, production, distribution and delivery, are responsible for producing data and storing the data on the chain.
[0055] 6. Blockchain: A distributed ledger technology that collects and stores information from every link in the industrial chain. Through the automated execution of smart contracts, which require no human intervention, blockchain ensures the integrity and tamper-proofing of industrial chain data. Blockchain records every transaction and ownership change, making all information transparent and immutable. When problems arise at any stage of the industrial chain, indexing technology can quickly locate specific batches and manufacturers, expediting the recall of related products and minimizing the risk of defective products.
[0056] 7. Users (light nodes): Information inquirers, who can be consumers, regulators, agricultural workers, distributors, and other personnel at various links in the industrial chain.
[0057] 8. Server (Full Node): This node is responsible for data processing, data query and response, computation, and storage. The server receives data from various links in the supply chain, including farms, processing plants, transportation, warehousing, and distribution. The server performs preliminary processing, verification, and organization of this data. The server transmits events to the blockchain, enabling it to automatically execute smart contracts that define the rules and operations for each step in the supply chain. The server receives user query requests, processes them, and retrieves relevant data from the blockchain. The server aggregates the retrieved data and generates a verification object (VO), which is then returned to the user.
[0058] 9. InterPlanetary File System (IPFS): IPFS is a distributed file-sharing system used to store large amounts of file data generated by the industrial chain, such as crop photos and processing documents. Combining IPFS with blockchain enables the system to store large amounts of data while maintaining high availability and security.
[0059] System architecture such as Figure 1 As shown, in Figure 1 In, based on Figure 1 The system architecture shown can implement the following steps:
[0060] 1. Data producers use IoT devices to record detailed information about crops at each link in the industry chain, upload it to IPFS, and IPFS returns the storage address.
[0061] 2. While uploading IPFS, call the smart contract created by the developer to upload the data to the blockchain.
[0062] 3. The public key is used to generate and verify the root hash value of the Merkle tree. When creating an ADS, parameters related to the public key are used to calculate the digest value and the root hash of the Merkle tree. In this way, any tampering with the data will cause the root hash value to change and be detected.
[0063] 4. The server creates an index structure for one-dimensional data and an index structure for spatial data attributes.
[0064] 5. The user queries the block data.
[0065] 6. The client sends a query request.
[0066] 7. The server (full node) receives the user's request information. The first step is to process one-dimensional attributes: During the query processing, the multi-dimensional query is first decomposed into multiple one-dimensional range queries, such as "production date" and "production batch", and these queries are executed on the server to obtain intermediate results (the results of all one-dimensional range queries) and proofs. These results and proofs are then used for further set operations, such as intersection and range queries, and finally aggregation operations are performed to obtain the final result. Then, spatial information is processed: the full node collects the data within the query range by depth-first traversing the MR tree and generates a verification object (VO) containing matching records and authentication information.
[0067] 8. Return the query results and VO.
[0068] 9. Send to the client for verification.
[0069] 10. Verify the query results.
[0070] See also Figure 2 , Figure 2 This is a flowchart of the blockchain data query method provided by the embodiment of the present application. Figure 2 As shown, the following steps are included:
[0071] Step 101: obtain the industrial chain information sent by the data producer and enter the industrial chain information into the blockchain. The industrial chain information includes spatial data and one-dimensional data other than the spatial data.
[0072] Industrial chain information can be data producers using IoT devices to record detailed information about crops at each stage of the supply chain, such as planting location, time, fertilization, and transportation. Industrial chain information can include two types of data: spatial data, which indicates data related to a specific location, such as the planting location or a specific point during transportation; and one-dimensional data, which includes all other data types, such as production date, weight, and volume.
[0073] The spatial data information generated by the industry chain during the production, transportation, and storage of goods is processed one by one and stored on the blockchain. The information in the table is stored on the blockchain. An example of the information on the chain is as follows:
[0074] "previous_hash": "Hash value of the previous block",
[0075] "transactions":[
[0076] {
[0077] "transaction_id":"Tx1",
[0078] "location":{"latitude":39.9056,"longitude":116.4015},
[0079] "production_date":"2024-06-06T00:00:00",
[0080] "weight":6,
[0081] "volume":1,
[0082] "transaction_hash": "Transaction hash"
[0083] }
[0084] ],
[0085] "timestamp": "Block creation time",
[0086] "nonce":"Nonce for proof of work",
[0087] "current_hash": "The hash value of the current block".
[0088] Step 102: construct a spatial data index structure based on the minimum bounding rectangle (MBR) and hash value of the spatial data, and store the spatial data index structure in the blockchain.
[0089] In this step, the MBR, as a compact data representation method, simplifies the spatial extent of a set of points or multiple objects into a minimal rectangular boundary. As leaf nodes in the Merkle R-tree, the MBR contains specific spatial data, providing precise positioning for subsequent queries and verification. The Merkle R-tree construction process organizes these leaf nodes into a tree structure in a certain order and calculates a hash value for each node. The root of the constructed Merkle R-tree is stored in the SpatialDigest field, resulting in a spatial data index structure.
[0090] Step 103: construct a one-dimensional data index structure based on the transaction attributes and hash values of the one-dimensional data, and store the one-dimensional data index structure in the blockchain.
[0091] In this step, the authentication data structure (ADS) consists of multiple lists sorted by transaction attribute values and a Merkle hash tree constructed based on these lists. For each transaction type, a sorted list is created based on its attribute values. Next, a prefix set is defined and its digests are calculated. These digests include accumulator values, which are dynamically calculated based on the attribute values of the transactions in the prefix set. A Merkle tree is constructed using these digests as leaf nodes, and the root hash value is stored in the AgrDigest field of the block header, resulting in a one-dimensional data index structure.
[0092] Step 104: upon receiving a query request sent by the client, determining a query result from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure.
[0093] In this step, users, regulators, distributors, and other personnel in the industry chain log in to the client (light node) and send query content to query information about the product during the production and transportation process, generating a query request. For example, the query content includes "production time = 2023-1-2, production batch = Batch1, weight > 15, 50 < volume < 70, (1, 2) < coordinates < (3, 4)", where coordinates are spatial data, and production time, production batch, weight, and volume are all one-dimensional data. The one-dimensional data carried in the query request is converted into a data format corresponding to the one-dimensional data index structure and compared with the data of the one-dimensional data index structure corresponding to each block in the blockchain. The spatial data carried in the query request is converted into a data format corresponding to the spatial data index structure and compared with the data of the spatial index structure corresponding to each block in the blockchain, thereby determining the data stored in the corresponding blockchain from the blockchain.
[0094] Step 105: Send the query result to the client.
[0095] The obtained query structure is sent to the client to complete the data query process of the blockchain.
[0096] In the method provided in the embodiment of the present application, a spatial data index structure is constructed based on the MBR and hash value of the spatial data. When querying data, the spatial data carried by the query request can be compared with the spatial data in the blockchain by MBR to query the corresponding spatial data. Since the MBR simplifies the spatial range of a group of points or multiple objects into a minimum rectangular boundary, when the spatial data carried by the query request is compared with the spatial data in the blockchain, the two minimum rectangular boundaries are also compared. Compared with the method in the prior art that requires comparing each spatial data point carried by the query request with each spatial data point in the blockchain, the amount of data that needs to be compared can be reduced, thereby improving the efficiency of data query.
[0097] For one-dimensional data index structures and spatial data index structures, see Figure 3 , Figure 3 This is a schematic diagram of the block ADS structure. Figure 3 In the figure, after the industry chain information is entered into the blockchain, an index structure ADS is created for each block. For each block, in addition to the original PrevHash field, BlockHeight field, and TimeStamp field, two fields are added: AgrDigest field and SpatialDigest field, which are used to store the one-dimensional data index structure and spatial data index structure respectively. Figure 3 middle:
[0098] (1) d(t) is used to represent the query dimension, which refers to the independent criteria or parameters used to filter and aggregate data based on different attributes or fields when performing query operations in a database or blockchain system;
[0099] (2) Transaction type is represented by t, which refers to different types of transactions or operations in the blockchain, such as transfer, smart contract execution, data storage, etc. They have a unified structure and are organized and stored according to certain rules.
[0100] (3) Using a1, a2, a3, …, a n Transaction type attributes. Transaction type attributes refer to the fields contained in a specific transaction type in the blockchain, which are used to describe and process transactions.
[0101] (4) Use To represent a sorted list. A sorted list is a list in which transactions are sorted according to the value of an attribute.
[0102] (5) Use Represents a list of transactions The corresponding prefix set. The prefix set is the subset of transactions from the first item to the jth item in the sorted list.
[0103] (6) Each prefix set p corresponds to a summary dp. The summary consists of an accumulator value p r The accumulator value is calculated based on the transaction attribute values in the prefix set. The accumulator value of Calculated as where b m for The mth transaction, b m .a n The prefix set summary is used to verify the transaction subset in the sorted list, ensuring its data integrity in blockchain queries. By calculating the accumulator value, the summary helps verify the correctness of the query results and supports the verification of multi-dimensional queries.
[0104] (7) Use v to represent attribute value. Attribute value refers to the data value of a specific attribute related to a transaction. For example, the time, batch number, weight, etc. of a transaction. During the verification process, the attribute value is expanded to include column identifiers, transaction IDs, and other information to support multi-dimensional query and verification operations. The extended value of attribute value v is e v =(cid||v||tid), where cid is an incremental column identifier ta i (For example, the first query dimension cid=1, the second query dimension cid=2, tid is the transaction counter of t (for example, the first transaction tid=1) prefix set Summary.
[0105] (8) Use Represents a triple. A triple is a data structure generated by a prefix set in a sorted list, containing the current value, the next value, and its corresponding digest. It is used to construct leaf nodes in the Merkle tree to ensure the integrity and correctness of blockchain query results. in and are the jth and j+1th attribute values in the i-th attribute t.ai of transaction type t.
[0106] Before explaining the spatial data index structure, the following formal definitions and descriptions of verifiable algorithms are given:
[0107] 1. Genkey(1 k ,U)→(sk,pk)
[0108] A third-party trusted oracle generates the system's master key. It takes as input a security parameter k and a set U, and outputs a secret key sk and a public key pk.
[0109] 2. Setup(A,pk)→dA
[0110] Input set A and public key pk, output A's summary d A Given a set A, define two polynomials A(x) = ∑ i∈A x i and A(x,y)=∑ i∈A x q-i It will collect the summary d of a A Computed as a vector of four group elements [A s ,A s,r ,A r ,A r,s ], where A s =g A(s) , A s,r =g A(s,r) , A r =g A(r) , A r,s =g A(r,s) .
[0111] 3.Query(A1,...,A l ,q,pk)→{π,R}
[0112] The server performs a search operation on the chain. Input a query q∈Q and set A1,...,A l and public key pk, output result R and proof π. Take the MIN operation as an example. Let min be the minimum value of set A. Query(A,MIN,pk)→(π,v), output v=min,
[0113] 4.
[0114] The client verifies the search results. l Input summary of A proof π of a query q, an answer R and a public key pk, outputs accept if and only if the query result is correct. For the MIN operation, Verify(d A ,MIN,π,v,pk)→(accept,reject): if and only if Output accept.
[0115] 5.
[0116] Used by the server (full node) to generate proof of element inclusion in the Merkle hash tree. The input includes the base g and two prefix set triples. and and Represents triplets at two different positions in the Merkle hash tree.
[0117] Optionally, constructing a spatial data index structure based on a minimum bounding rectangle MBR and a hash value of the spatial data includes:
[0118] Obtaining spatial data included in each first leaf node of a first hash tree of a first block, where the blockchain includes a plurality of blocks, and the first block is any one of the plurality of blocks;
[0119] Calculate a first MBR and a first hash value corresponding to the first leaf node based on the spatial data included in the first leaf node;
[0120] Combining the first MBR and the first hash value corresponding to the first leaf node and performing a hash operation to obtain a combined hash value corresponding to the first leaf node;
[0121] According to the order of the first leaf nodes in the first hash tree, a hash operation is performed on the combined hash value corresponding to each of the first leaf nodes layer by layer to obtain a first root node hash value corresponding to the root node of the first hash tree, and the spatial data index structure of the first block includes the first root node hash value and the combined hash value of each of the first leaf nodes.
[0122] In this embodiment, when establishing the first hash tree for a block in the blockchain, the combined hash value of each node is first calculated starting from the first leaf node. These combined hash values are generated by combining the data contained in the leaf node (minimum bounding rectangle Rl and hash value hl) and performing a hash operation. Next, these combined hash values are combined with other relevant information (such as attribute sequence number BF) layer by layer to form the combined hash value of the parent node. This process continues until all nodes are calculated and the final first root node hash value is formed. The final generated first root node hash value is stored in the SpatialDigest field (such as Figure 3 The block ADS structure is shown in the block diagram (see the block ADS structure diagram), which is used for data verification and integrity checking. By combining the MBR with the hash value, the spatial data to be queried is also converted into a combination of MBR and hash value when performing subsequent spatial data queries. Since the MBR can represent multiple spatial data, each comparison is equivalent to comparing multiple spatial data in the blockchain with multiple spatial data in the data to be queried, which can reduce the number of data comparisons and thus improve efficiency.
[0123] Optionally, constructing a one-dimensional data index structure based on the transaction attributes and hash values of the one-dimensional data includes:
[0124] Obtain one-dimensional data included in each second leaf node of the second hash tree of the first block;
[0125] Calculating a node value of the second leaf node based on the transaction attribute of the one-dimensional data included in the second leaf node and the corresponding sorted list;
[0126] Calculating a second hash value of the second leaf node based on the node value of the second leaf node;
[0127] According to the order of the second leaf nodes in the second hash tree, a hash operation is performed on the second hash value of each second leaf node layer by layer to obtain a second root node hash value corresponding to the root node of the second hash tree, and the one-dimensional data index structure of the first block includes the second root node hash value and the second hash value of each second leaf node.
[0128] In this embodiment, calculating the node value of the second leaf node based on the transaction attribute of the one-dimensional data included in the second leaf node and the corresponding sorted list includes the following sub-steps:
[0129] Sub-step 1: Insert the attributes in the transaction into the query list
[0130] The server sends the block event to the blockchain, and the blockchain constructs the block index for the block event. Insert transaction t into the existing sorted list Among them Represents a sorted list of the i-th attribute of transaction i.
[0131] Consider a transaction type t with d(t) query dimensions. For each transaction type t, it consists of many attributes a1, a2, a3, ..., a n The composition is shown in Table 1:
[0132]
[0133] Table 1
[0134] According to each attribute a i , create a transaction list Each attribute establishes its corresponding attribute list, which eventually constitutes the total attribute list Sorted List It is based on i The transactions in the sorted list can be represented by pointers instead of actual transactions. The following table shows the style of the transaction list, where the transaction list stores pointers to specific data, as shown in Table 2:
[0135]
[0136] Table 2
[0137] Sub-step 2: Calculate and generate prefix sets The summary value of . Store it in a variable The digest value is used in the subsequent data verification and integrity check process.
[0138] Sub-step 3: Create triples The prefix set Summary value of With two adjacent data values v i,j and v i,j+1 Combined into a triple Store in variables Among them, Represents the jth value of the i-th attribute. The triples corresponding to the prefix set are shown in Table 3:
[0139]
[0140] Table 3
[0141] Sub-step 4: Construct the MHT leaf node value and insert it into the MHT. Initialization As the leaf node value of the MHT, it is then inserted into the MHT.
[0142] After obtaining the node value of the second leaf node, the hash values of each node are calculated and merged to form the final MHT.
[0143] Through the above-mentioned method of this embodiment, a one-dimensional data index structure can be constructed to facilitate subsequent query of the one-dimensional data.
[0144] Since blocks are constantly generated during the search process, the resulting query cost will also rise sharply. The index structure (ADS) of the embodiment of the present application uses a cryptographic accumulator, which can synthesize the accumulator values of multiple elements into a new accumulator value through mathematical operations while retaining the information of all original elements. In this way, the accumulator values of multiple blocks can be combined into a joint accumulator value, representing the data set of all blocks. Merging the ADS of a group of blocks into the ADS of one block reduces the number of blocks traversed, thereby improving query efficiency.
[0145] Optionally, the spatial data index structure and the one-dimensional data index structure both include a Bloom filter structure, which encodes multiple transaction attributes of the spatial data and the one-dimensional data. The Bloom filter structure is used to, upon receiving the query request, compare the code carried by the query request with the code corresponding to the spatial data in the first block and the code corresponding to the multiple transaction attributes of the one-dimensional data in the first block, so as to determine whether the first block contains the data to be queried carried by the query request.
[0146] In this embodiment, a Bloom filter can quickly determine whether an element is absent from a set. A Bloom filter can quickly determine whether an element is absent from a set, but it cannot guarantee that an element is in the set. It maps elements to a bit array using multiple hash functions. If all corresponding bits are 1, the element is likely present; if any bit is 0, the element is definitely absent. A Bloom filter has low memory usage and fast query speed.
[0147] Each transaction attribute is numbered, for example, a1 corresponds to 0001, a2 corresponds to 0010, a3 corresponds to 0011, and a4 corresponds to 0100. The corresponding numbers are stored in a Bloom filter. Later, when a user requests a multi-dimensional query, the Bloom filter can be used to quickly determine whether data for a particular attribute dimension exists in the block. If not, the Bloom filter continues to the next attribute dimension.
[0148] This embodiment introduces a Bloom filter (BF) structure, enabling rapid determination of whether a query condition has corresponding data in the block. The proposal encodes each attribute in the block data in binary format and stores it in a Bloom filter. Upon receiving a user query request, the Bloom filter is used to compare the encoding of the user's query attribute. If the record does not contain the attribute, the search proceeds directly to the next user's query attribute. This design eliminates the need to query every query attribute in the index structure, improving data query efficiency.
[0149] Optionally, determining a query result from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure includes:
[0150] Determining a second block from the blockchain based on the code carried by the query request and the Bloom filter structure, wherein the code of the Bloom filter structure contained in the second block includes the code carried by the query request;
[0151] Determine a first query result from the one-dimensional data stored in the second block based on the hash value of the one-dimensional data to be queried carried in the query request and the hash value of each node of the second hash tree included in the second block;
[0152] Determine a second query result from the spatial data stored in the second block based on the hash value of the spatial data to be queried carried in the query request, the MBR, and the hash values of each node of the first hash tree included in the second block;
[0153] The first query result and the second query result are aggregated to obtain the query result.
[0154] In the industrial chain, efficient and comprehensive indexing of blockchain data is a crucial issue for information stored on the blockchain. Comprehensiveness refers to the ability to satisfy complex customer queries, while efficiency refers to minimizing the number of blocks traversed during the query process through algorithms.
[0155] In this embodiment, the client sends a query request Q to the server according to the query requirements. The query structure is Q = {t, (a, aggr), (a1, l1, u1), ..., (a i ,l i ,u i ),[t s ,t e ]}, where t is the transaction type to be queried, aggr is a SUM-like aggregation type on attribute a, a1,...,a i is the selection attribute of the range predicate, l i ,u i Is attribute a i The lower and upper bounds of the search range are as shown in Table 4:
[0156] Paremeter Value t (query transaction type) Production records a(aggregation type) SUM a1(production time) 2023-01-01to 2023-01-06 a2(weight) 10 to 30 a3 (volume) 50 to 90 ts (start time) 2023-01-01 te (end time) 2023-01-06
[0157] Table 4
[0158] After receiving the query request, you can proceed to the following query steps:
[0159] 1. Get the query attribute and query by attribute. Use Bloom filter to check whether the attribute exists in the block. If the attribute does not exist, search for the next attribute.
[0160] Since Bloom filters can quickly determine whether an element does not exist in a set, during the top-down traversal of the index results, the BF value of the query attribute is compared with the BF value of the node. If the BF value of the query attribute is found to be different from the BF value of the node, the traversal is stopped and it is determined that the query attribute does not exist in the current block.
[0161] 2. According to the query range requested by the user, determine the subscript range i1, i2 in the attribute queue.
[0162] 3. According to the subscript range i1, i2 and the triples stored in MHT Call the MerkleProve function to obtain a Merkle proof. MerkleProve focuses on generating a proof path in the Merkle tree to prove the existence of a data item.
[0163] 4. Call the previously defined Query function and input the prefix set accumulator value And the server's public key pk, get the query result and proof π i ,R i .
[0164] 5. Add VO and change R i Put it into the result set R of the overall query result. is the triplet at position i1 in the prefix set, It is the triplet at position i2 in the prefix set. Each triplet contains the hash value of data in a specific range and the result of subsequent operations to ensure the integrity and correctness of the data. i1 is from the leaf node (corresponding to ) to the hash path of the Merkle tree root, M i2 is from the leaf node (corresponding to ) to the root node of the Merkle tree. It is used to prove that the relevant data does exist in the Merkle tree during the client verification process. πi contains the necessary proof data to perform a specific query (such as SUM or MIN operations within a given range). It ensures that the output of the query is correctly calculated based on the provided input data and operation. i Contains transactions or data entries within a specific query dimension or range, which are used to construct the final query results during the query process.
[0165] 6. Call the SpatialQuery function to perform spatial query operations and return the query proof VO1. For example:
[0166] 1.Function SpatialQuery(QueryRange,TreeRoot):; 2.Initialize a node z; 3.VO1←empty list; 4.If z is a leaf; 5.Append all records in z to VO1; / / To the leaf node, stop searching; 6.Else; 7.For all entries e in z do; 8.Ife.R∩QueryRange is notempty;9.VO2←SpatialQuery(e.subtree,Q);10.Append VO2 to VO1;11.Else;12.Append[eR,eh]to VO1; / / pruned node;13.Foreach all lists L in VO1;14.If L containsrecords;15.Let P Lbe the set of records; 16.Foreach X∈P L ;17.If X matches Qthen;18.Add X to the ResultSet;19.Return VO1, ResultSet.
[0167] In the above process, a breadth-first recursive algorithm is used to traverse the tree (lines 1-12). If node z is a leaf node, the algorithm adds all records in that node to the verification object (VO1) and stops searching (lines 4-5). Otherwise, the algorithm continues searching each child of that node. For each child node entry e, if its minimum bounding rectangle (MBR) eR intersects with the query range QueryRange (line 8), the algorithm recursively calls itself to process the child node and merges the results into the current VO1 (lines 9-10). If there is no intersection, the child node is treated as a "pruned node," and its MBRe.R and hash value eh are recorded and added to VO1 (lines 11-12). Next, the algorithm traverses each list L in VO1 (lines 13-19). If L contains leaf node records (line 14), the algorithm further checks these records. If record X matches the query range Q (line 17), X is added to the result set ResultSet (line 18). Finally, the function returns the constructed VO1 and the query result set ResultSet (line 19). In this way, the algorithm can effectively search and verify the query results in the MR-tree to ensure its completeness and accuracy.
[0168] 7. Integrate the results of all one-dimensional range queries and all spatial information queries. For the query result set R of single-dimensional information, first perform the intersection operation to obtain the intersection query result and prove π ∩ ,R ∩ Next, perform range operations to obtain the range query results and prove π range ,R range Finally, perform aggregation operation to obtain the final result π aggr ,R aggr . Store the final result and proof in VO, for example:
[0169] π ∩ ,R ∩ ←Query(Ri,...,Rj,∩,pk);Addπ ∩ to VO;
[0170] π range ,R range←Query(Ri,...,Rj,RANGE,pk);
[0171] π aggr ,R aggr ←Query(Ri,...,Rj,aggr,pk);
[0172] Addπ aggr ,R to VO.
[0173] 8. Add the spatial data search result set R1 to VO1. aggr Add the spatial query result set R1 to the query result set and integrate the results. Finally, return the query result R to the client. aggr , verification objects VO, VO1.
[0174] Through the above steps, you can query results containing accurate spatial data.
[0175] After sending the query result to the client, the method further includes:
[0176] A verification object corresponding to the query result is sent to the client, where the verification object includes the first query result, the second query result, and a traversal record of the first hash tree and the second hash tree included in the second block.
[0177] The contents of the verification objects VO and VO1 have been described in the above embodiments and will not be repeated here. The following describes how to use the verification objects for verification:
[0178] 1. Obtain a query proof and Merkle proof for a one-dimensional attribute. Get dimension a from the verification object i Proof Verify the aggregate digest AgrDigest and range proof Merkle proof Use the following function to verify:
[0179] If any verification fails, set the flag to reject and return the verification result flag. If any Merkle proof is invalid, the function returns reject and uses the range function to prove and public key pk to verify the proof π i If the verification fails, set the flag to reject. Return the verification result flag. If any proof πi is invalid, the function returns reject.
[0180] 2. Verify the intersection proof. π ∩ Is the intersection proof from VO. Use Verify(π ∩,π i ,...,π j ,∩,pkVerify the intersection proof for all one-dimensional queries. Use the Verify function to verify the intersection proof π ∩ And public key pk. If the verification result is false, set the flag Flag to reject and return the flag.
[0181] 3. Verify the range proof of multi-dimensional attribute query. Step 1 is a one-dimensional range proof. range It is a multi-dimensional attribute range proof from VO. For all one-dimensional queries, verify its range proof. Use Verify(π ∩ ,π range ,RANGE,pk) verify the intersection proof π range If the verification result is false, the flag Flag is set to reject and the flag is returned.
[0182] 4. Verify the proof of the aggregate query. aggr is the aggregate query proof from VO. Verify the aggregate proof for all one-dimensional queries. Use the Verify function to verify the intersection proof π aggr If the verification result is false, the flag Flag is set to reject and the flag is returned.
[0183] 5. Verify the query results of spatial data. For spatial data query, it is mainly performed by calling the SpatialVerify function. The processing process of this function is as follows:
[0184] 1.Function SpatialVerify(QueryRange,VO1):;2.R r ←initialize to storeMBR;3.h r ←initialize to restore the root hash;4;5.For all lists L in VO1;6.IfL contains records;7.Foreach X in L;8.R r ←R r ∪X; 9.s←s|X; 10.If L contains pruned node information; 11.R L ←MBR of node records;12.h L ←digest of noderecords; 13.R r ←Rr ∪R L ;14.s|R L |h L ;15.If L contains nothing;16.R L ←initialize tostore MBR of node records;17.h L ←digest to store of node records;18.(R L ,h L )←SpatialVerify(Q,L);19.R r ←R r ∪R L ;20.s←s|R L |h L ;21.h r =H(s); 22.ReturnR r ,h r .
[0185] The SpatialVerify function processes each piece of information in the input VO1 differently according to the record category. In the algorithm, L can have three different meanings, corresponding to different processing methods. First, when L represents the list of leaf node records (lines 6-9), the algorithm traverses each record X in L. i , and add it to the result set R r , and update the string s, that is, R r =R r ∪X i and s = s | X i Secondly, when L represents the information list of the pruned node (lines 10-14), the algorithm extracts the minimum bounding rectangle R of the pruned subtree L and hash digest h L , then update R r and s, the formula is R r =R r ∪R L and s=s|R L ∣h L Finally, when L represents a verification object (VO) of a subtree (lines 15-20), the algorithm recursively processes L to obtain the result set R of the subtree SL MBRR L and hash h L , and then update R in the same way r and s, so that R r =R r ∪R L and s=s|RL ∣h L Through these processes, the algorithm can effectively build and verify the completeness and correctness of the results, thereby improving the accuracy of the query results.
[0186] Optionally, after obtaining the industrial chain information sent by the data producer, the method further includes:
[0187] The industry chain information is stored in the InterPlanetary File System (IPFS). IPFS can store data in various formats, such as photos and documents. IPFS can be used as a data backup to prevent blockchain data from being lost due to accidents.
[0188] See also Figure 4 , Figure 4 This is a structural diagram of a blockchain data query device provided by an embodiment of the present application. Figure 4 As shown, the apparatus 300 includes:
[0189] The first acquisition module 301 is used to acquire industrial chain information sent by the data producer and enter the industrial chain information into the blockchain. The industrial chain information includes spatial data and one-dimensional data other than the spatial data.
[0190] A first indexing module 302 is configured to construct a spatial data index structure based on the minimum bounding rectangle (MBR) and hash value of the spatial data, and store the spatial data index structure in the blockchain;
[0191] A second indexing module 303 is configured to construct a one-dimensional data index structure based on the transaction attributes and hash values of the one-dimensional data, and store the one-dimensional data index structure in the blockchain;
[0192] a query module 304 configured to, upon receiving a query request sent by a client, determine a query result from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure;
[0193] The sending module 305 is configured to send the query result to the client.
[0194] Optionally, the first indexing module 302 is further configured to:
[0195] Obtaining spatial data included in each first leaf node of a first hash tree of a first block, where the blockchain includes a plurality of blocks, and the first block is any one of the plurality of blocks;
[0196] Calculate a first MBR and a first hash value corresponding to the first leaf node based on the spatial data included in the first leaf node;
[0197] Combining the first MBR and the first hash value corresponding to the first leaf node and performing a hash operation to obtain a combined hash value corresponding to the first leaf node;
[0198] According to the order of the first leaf nodes in the first hash tree, a hash operation is performed on the combined hash value corresponding to each of the first leaf nodes layer by layer to obtain a first root node hash value corresponding to the root node of the first hash tree, and the spatial data index structure of the first block includes the first root node hash value and the combined hash value of each of the first leaf nodes.
[0199] Optionally, the second indexing module 303 is further configured to:
[0200] Obtain one-dimensional data included in each second leaf node of the second hash tree of the first block;
[0201] Calculating a node value of the second leaf node based on the transaction attribute of the one-dimensional data included in the second leaf node and the corresponding sorted list;
[0202] Calculating a second hash value of the second leaf node based on the node value of the second leaf node;
[0203] According to the order of the second leaf nodes in the second hash tree, a hash operation is performed on the second hash value of each second leaf node layer by layer to obtain a second root node hash value corresponding to the root node of the second hash tree, and the one-dimensional data index structure of the first block includes the second root node hash value and the second hash value of each second leaf node.
[0204] Optionally, the spatial data index structure and the one-dimensional data index structure both include a Bloom filter structure, which encodes multiple transaction attributes of the spatial data and the one-dimensional data. The Bloom filter structure is used to, upon receiving the query request, compare the code carried by the query request with the code corresponding to the spatial data in the first block and the code corresponding to the multiple transaction attributes of the one-dimensional data in the first block, so as to determine whether the first block contains the data to be queried carried by the query request.
[0205] Optionally, the query module 304 is further configured to:
[0206] Determining a second block from the blockchain based on the code carried by the query request and the Bloom filter structure, wherein the code of the Bloom filter structure contained in the second block includes the code carried by the query request;
[0207] Determine a first query result from the one-dimensional data stored in the second block based on the hash value of the one-dimensional data to be queried carried in the query request and the hash value of each node of the second hash tree included in the second block;
[0208] Determine a second query result from the spatial data stored in the second block based on the hash value of the spatial data to be queried carried in the query request, the MBR, and the hash values of each node of the first hash tree included in the second block;
[0209] The first query result and the second query result are aggregated to obtain the query result.
[0210] Optionally, the apparatus 300 is further configured to:
[0211] A verification object corresponding to the query result is sent to the client, where the verification object includes the first query result, the second query result, and a traversal record of the first hash tree and the second hash tree included in the second block.
[0212] Optionally, the apparatus 300 is further configured to:
[0213] The industry chain information is stored in the InterPlanetary File System (IPFS).
[0214] It should be noted that the blockchain data query device 300 provided in the embodiment of the present application can achieve the following Figure 2 The entire technical process of the blockchain data query method shown in the embodiment achieves the same technical effect, so to avoid repetition, it will not be repeated here.
[0215] The data sending device in the embodiment of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other device other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a mobile Internet device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc. The non-mobile electronic device can also be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0216] Alternatively, as Figure 5 As shown, an embodiment of the present application further provides an electronic device 400, including a processor 401 and a memory 402, wherein the memory 402 stores a program or instruction that can be run on the processor 401. When the program or instruction is executed by the processor 401, the various steps of the above-mentioned blockchain data query method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.
[0217] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0218] The present application also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements the various processes of the above-mentioned blockchain data query method embodiment and can achieve the same technical effects. To avoid repetition, the details are not described here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0219] The present application also provides a computer program product including computer instructions, which, when executed by a processor, implement the above Figure 2The various processes of the blockchain data query method embodiment shown in the figure can achieve the same technical effect. To avoid repetition, they will not be described here.
[0220] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising 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 apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0221] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0222] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.
Claims
1. A blockchain data query method, characterized in that: The method comprises: Obtaining industrial chain information sent by the data producer and entering the industrial chain information into the blockchain, wherein the industrial chain information includes spatial data and one-dimensional data other than the spatial data; Constructing a spatial data index structure based on the minimum bounding rectangle (MBR) and hash value of the spatial data, and storing the spatial data index structure in the blockchain; Constructing a one-dimensional data index structure based on the transaction attributes and hash values of the one-dimensional data, and storing the one-dimensional data index structure in the blockchain; Upon receiving a query request sent by a client, determining a query result from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure; The query result is sent to the client.
2. The method according to claim 1, characterized in that The step of constructing a spatial data index structure based on the minimum bounding rectangle MBR and the hash value of the spatial data includes: Obtaining spatial data included in each first leaf node of a first hash tree of a first block, where the blockchain includes a plurality of blocks, and the first block is any one of the plurality of blocks; Calculate a first MBR and a first hash value corresponding to the first leaf node based on the spatial data included in the first leaf node; Combining the first MBR and the first hash value corresponding to the first leaf node and performing a hash operation to obtain a combined hash value corresponding to the first leaf node; According to the order of the first leaf nodes in the first hash tree, a hash operation is performed on the combined hash value corresponding to each of the first leaf nodes layer by layer to obtain a first root node hash value corresponding to the root node of the first hash tree, and the spatial data index structure of the first block includes the first root node hash value and the combined hash value of each of the first leaf nodes.
3. The method according to claim 2, characterized in that The step of constructing a one-dimensional data index structure based on the transaction attributes and hash values of the one-dimensional data includes: Obtain one-dimensional data included in each second leaf node of the second hash tree of the first block; Calculating a node value of the second leaf node based on the transaction attribute of the one-dimensional data included in the second leaf node and the corresponding sorted list; Calculate a second hash value of the second leaf node based on the node value of the second leaf node; According to the order of the second leaf nodes in the second hash tree, a hash operation is performed on the second hash value of each second leaf node layer by layer to obtain a second root node hash value corresponding to the root node of the second hash tree, and the one-dimensional data index structure of the first block includes the second root node hash value and the second hash value of each second leaf node.
4. The method according to claim 3, characterized in that The spatial data index structure and the one-dimensional data index structure both include a Bloom filter structure, which encodes multiple transaction attributes of the spatial data and the one-dimensional data. The Bloom filter structure is used to, upon receiving the query request, compare the code carried by the query request with the code corresponding to the spatial data in the first block and the code corresponding to the multiple transaction attributes of the one-dimensional data in the first block, so as to determine whether the first block contains the data to be queried carried by the query request.
5. The method according to claim 4, characterized in that Determining a query result from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure includes: Determining a second block from the blockchain based on the code carried by the query request and the Bloom filter structure, wherein the code of the Bloom filter structure contained in the second block includes the code carried by the query request; Determine a first query result from the one-dimensional data stored in the second block based on the hash value of the one-dimensional data to be queried carried in the query request and the hash value of each node of the second hash tree included in the second block; Determine a second query result from the spatial data stored in the second block based on the hash value of the spatial data to be queried carried in the query request, the MBR, and the hash values of each node of the first hash tree included in the second block; The first query result and the second query result are aggregated to obtain the query result.
6. The method according to claim 5, characterized in that After sending the query result to the client, the method further includes: A verification object corresponding to the query result is sent to the client, where the verification object includes the first query result, the second query result, and a traversal record of the first hash tree and the second hash tree included in the second block.
7. The method according to any one of claims 1 to 6, characterized in that After obtaining the industrial chain information sent by the data producer, the method further includes: The industry chain information is stored in the InterPlanetary File System (IPFS).
8. A blockchain data query device, characterized in that: The device comprises: A first acquisition module is used to acquire industrial chain information sent by a data producer and enter the industrial chain information into the blockchain, wherein the industrial chain information includes spatial data and one-dimensional data other than the spatial data; A first indexing module is configured to construct a spatial data index structure based on a minimum bounding rectangle (MBR) and a hash value of the spatial data, and store the spatial data index structure in the blockchain; A second indexing module is configured to construct a one-dimensional data index structure based on the transaction attributes and hash values of the one-dimensional data, and store the one-dimensional data index structure in the blockchain; a query module, configured to, upon receiving a query request sent by a client, determine a query result from the blockchain based on the query request, the one-dimensional data index structure, and the spatial data index structure; A sending module is used to send the query result to the client.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the blockchain data query method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the blockchain data query method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the blockchain data query method according to any one of claims 1 to 7.