Air environment monitoring data identification system and method
Through hash processing and Merkel-Patricia tree technology, combined with blockchain evidence storage and smart contracts, the problems of long data collection cycle and easy tampering in traditional environmental monitoring are solved, and efficient, secure sharing and traceability of the entire process of air pollution prevention data is achieved.
Patent Information
- Application Number
- CN202510855708.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-25
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-06-25
AI Technical Summary
Traditional ecological environment monitoring has problems such as long data collection cycle, poor real-time performance, serious data island phenomenon, easy to tamper with data storage centralization, lack of data integrity verification mechanisms and fine-grained access control, and the storage pressure in blockchain technology applications is too high and processing efficiency is low.
Hash processing is used to generate data fingerprints, store them in pieces to distributed networks, and combine the Merkel-Patricia tree computing root hash on the chain to store evidence. Data integrity is ensured through sampling verification strategies, and access permissions are managed based on smart contracts to achieve traceability and tamper-proof of the entire life cycle of data.
It realizes the full-process trusted storage and verification of the entire air pollution prevention data, reduces on-chain storage costs, improves data sharing efficiency and access records, and ensures data integrity and security.
Smart Images

Figure CN120372700B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of environmental monitoring, and in particular to an air environment monitoring data identification system and method. Background Art
[0002] Traditional ecological and environmental monitoring relies on manual inspections or single-point sensors, which suffer from the following shortcomings: long data collection cycles and poor real-time performance; severe data silos, making it difficult to share diverse monitoring data; centralized data storage, which presents the risk of tampering; data traceability, which makes it difficult to identify responsibilities; decentralized monitoring equipment management, resulting in inefficient maintenance; and imperfect mechanisms for verifying data authenticity. Blockchain technology, with its decentralized, tamper-proof, and traceable characteristics, offers a new approach to addressing these issues. However, directly uploading all monitoring data to the blockchain can lead to excessive storage pressure and low processing efficiency.
[0003] For example, Chinese patent application publication number CN119583592A discloses a digital wetland ecological environment monitoring system, comprising: an intelligent sensing terminal deployed in a wetland experimental sample area for collecting multi-source heterogeneous wetland monitoring data and transmitting the multi-source heterogeneous wetland monitoring data to an information transmission device; an information transmission device for receiving, sending, aggregating, storing, and analyzing the multi-source heterogeneous wetland monitoring data; and a wetland data center for obtaining aggregated multi-source heterogeneous wetland monitoring data through the information transmission device. Based on the multi-source heterogeneous wetland monitoring data, the system provides online data analysis services using distributed computing, analysis technology, and data mining tools, providing data services to the application service center and the intelligent decision-making center. This technical solution integrates multi-source heterogeneous data, integrates wetland ecological monitoring-related management applications and data services into a unified monitoring platform, and realizes its application in ecological evaluation and simulation prediction, thereby further realizing the informatization, digitization, and intelligence of wetland ecological monitoring.
[0004] The above existing technologies have the following problems: the lack of data integrity verification mechanism cannot effectively prevent data tampering or damage during transmission; data centers centrally store multi-source data, which is prone to single point failure; there is a lack of fine-grained access control based on roles or attributes, and there is a lack of dynamic data verification mechanism. Summary of the Invention
[0005] In response to the shortcomings of the existing technology, the present invention proposes an air environment monitoring data identification system and method, which obtains air pollution prevention and control data from the entire process, performs hash processing to generate data fingerprints; stores data in shards on a distributed network to generate unique content identifiers; constructs a Merkle-Patricia tree based on the data fingerprint, content identifier, and key metadata to calculate the root hash and store it on the chain; verifies the consistency of the off-chain distributed data based on the on-chain root hash, and ensures data integrity through a sampling verification strategy; the requester applies for access rights through a smart contract, obtains the data content identifier and storage node information after permission verification, and stores the access records on the chain. Through the collaborative verification mechanism of the Merkle-Patricia tree and the blockchain, the present invention achieves traceability and tamper-proofing of data throughout its entire life cycle, thereby improving data security and sharing efficiency.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] Air environment monitoring data identification method, including:
[0008] Step S1: Obtaining the full-process data of air pollution prevention and control, performing hash processing on the full-process data of air pollution prevention and control, generating a data fingerprint and temporarily caching it;
[0009] Step S2: storing the air pollution prevention full process data in shards in a distributed network and obtaining content identifiers;
[0010] Step S3: Packing the data fingerprint, content identifier, and key metadata to generate a Merkle-Patricia tree, obtaining a Merkle-Patricia root hash, and storing the Merkle-Patricia root hash on-chain; the key metadata is configured based on the full-process data of air pollution prevention;
[0011] Step S4: Calculate the hash value of the data stored off-chain based on the Merkle-Patricia root hash stored on-chain, compare the on-chain and off-chain hash values, and verify the comparison result using a sampling verification strategy; the data stored off-chain is a distributed storage of the full process data block of air pollution prevention;
[0012] Step S5: The requester applies for data access rights through the smart contract. After receiving the requester's application, the system verifies the requester's authority according to the preset authority management policy, and returns the content identifier and storage node information of the air pollution prevention full process data to the verified requester. At the same time, the access record is stored on the blockchain;
[0013] The specific steps of step S2 include:
[0014] S2.1: Apply a cryptographic hash function to each storage node IP:Port combination in the distributed network to obtain a storage node hash value; the IP:Port combination is a combination of an IP address and a port number;
[0015] S2.2: Sort the hash values of all storage nodes to form a clockwise ring structure to obtain a storage node hash ring;
[0016] S2.3: Obtain the full-process data of air pollution prevention and control, and split the full-process data of air pollution prevention and control into N data blocks according to a sharding key; the sharding key is a combination of a timestamp and a monitoring point ID;
[0017] S2.4: Apply a cryptographic hash function to the air pollution prevention full process data of each data block to generate a content fingerprint hash value;
[0018] S2.5: Find the location corresponding to the content fingerprint hash value on the storage node hash ring. Starting from the location where the content fingerprint hash value is located, search along the storage node hash ring in a clockwise direction to find the first storage node with a hash value greater than or equal to the content fingerprint hash value.
[0019] If no storage node with a hash value greater than the content fingerprint is found after traversing the entire storage node hash ring, the first storage node on the storage node hash ring is selected;
[0020] S2.6: Allocate the corresponding air pollution prevention full process data block to the found storage node for storage;
[0021] S2.7: Based on the allocation result in S2.6, each air pollution prevention full process data block is stored in the corresponding storage node. At the same time, the generated content fingerprint is used as the content identifier, and the content identifier corresponding to each data block is recorded;
[0022] The specific steps of step S3 include:
[0023] S3.1: Collect data fingerprints, content identifiers, and key metadata; key metadata includes the time, location, and monitoring equipment information for data collection throughout the air pollution prevention process;
[0024] S3.2: Convert the data fingerprint, content identifier, and key metadata into a composite key-value pair; the composite key-value pair includes a composite key and a composite value;
[0025] S3.3: For each composite key-value pair, create a leaf node;
[0026] S3.4: Perform hash calculation on the composite value of each leaf node to obtain the leaf node hash value;
[0027] S3.5: Recursively construct expansion nodes and branch nodes based on the prefix of the composite key and the structure of the Merkle-Patricia tree;
[0028] S3.6: For extension nodes and branch nodes, combine the hash values of their child nodes and perform hash calculation to obtain the hash value of the current node;
[0029] S3.7: Starting from the leaf node, calculate the hash value of each node layer by layer until the root node, and obtain the Merkle-Patricia root hash;
[0030] S3.8: Use smart contracts to record the Merkle-Patricia root hash as transaction data on the Hyperledger Fabric blockchain. At the same time, the blockchain assigns a unique transaction hash to the transaction data.
[0031] Specifically, the temporary caching process in step S1 includes:
[0032] S1.1: Select the distributed cache system Redis cluster as a temporary cache carrier;
[0033] S1.2: Set up the hash ring;
[0034] S1.3: Calculate the corresponding physical node hash value for each physical node in the temporary cache carrier through a hash function, and map the physical node hash value to the hash ring;
[0035] S1.4: Map each generated data fingerprint to the hash ring through the hash function to obtain the corresponding data fingerprint hash value ; The data fingerprint hash value is used to determine the node to which the data fingerprint is assigned on the hash ring;
[0036] S1.5: From data fingerprint hash value Start at position on the hash ring;
[0037] If the data fingerprint hash value If it is greater than the hash value of all nodes on the hash ring, The corresponding data fingerprint is assigned to the node with the smallest hash value on the hash ring for temporary caching;
[0038] If the data fingerprint hash value If the hash value of a node is less than or equal to that of any node on the hash ring, search clockwise along the hash ring and The corresponding data fingerprint is assigned to the first encountered node found for temporary caching;
[0039] S1.6: Allocate a node based on the determined data fingerprint, connect to the physical node in the corresponding temporary cache carrier, and store the data fingerprint in the cache of the physical node in the form of a key-value pair; the key-value pair consists of a data fingerprint hash value and the data fingerprint.
[0040] Specifically, the specific steps of constructing the extension node and the branch node in S3.5 include:
[0041] S3.51: Determine the structure and construction rules of the Merkle-Patricia tree, including node types, node storage methods, and prefix processing rules; the node types include leaf nodes, extension nodes, and branch nodes;
[0042] S3.52: Based on S3.3, obtain the composite key-value pairs of all leaf nodes and sort the composite keys of all leaf nodes in lexicographic order;
[0043] S3.53: Traverse the sorted composite keys and find the set of composite keys with the same prefix;
[0044] S3.54: For a set of composite keys having the same prefix, create an extension node; the extension node includes a prefix and a pointer to a child node;
[0045] If the child node set of the expanded node still contains at least two nodes, recursively search for a common prefix and construct a new expanded node or branch node until only one node, i.e., a leaf node, remains in the child node set.
[0046] S3.55: If the set of child nodes of the expanded node contains at least two different composite keys and no common prefix, then create a branch node; the branch node contains at least two child node pointers, each pointing to a different child node;
[0047] S3.56: Repeat the iteration until all leaf nodes are included in the Merkle-Patricia tree structure.
[0048] Specifically, the specific steps of step S4 include:
[0049] S4.1: Locate the storage node storing the air pollution prevention full process data block through S2.7 and read it;
[0050] S4.2: Splicing the read air pollution prevention full process data blocks into complete air pollution prevention full process data according to the original order of the air pollution prevention full process data;
[0051] S4.3: Based on step S3, use the concatenated air pollution prevention process data to construct a Merkle-Patricia tree and obtain the root hash value of the off-chain Merkle-Patricia tree.
[0052] S4.4: Connect to the blockchain network using the Hyperledger Fabric SDK and query the Merkle-Patricia root hash value stored on the blockchain based on the transaction hash in S3.8.
[0053] Specifically, the specific steps of step S4 also include:
[0054] S4.5: Directly compare the root hash of the off-chain Merkle-Patricia tree with the Merkle-Patricia root hash stored on the blockchain;
[0055] If the two are different, it indicates that there is an error in the air pollution prevention process data, and error information is extracted; the error information includes the hash value difference, timestamp, and data shard location;
[0056] If the two are the same, it means that the air pollution prevention full process data has not been tampered with during storage and transmission;
[0057] S4.6: Set sampling rules; the sampling rules are to perform sampling according to the time range of the data;
[0058] S4.7: According to the set sampling rules, M data blocks are selected from the read air pollution prevention full process data as sampling data;
[0059] S4.8: Construct a Merkle-Patricia tree for the selected sample data and calculate its root hash value;
[0060] S4.9: Compare the root hash of the sampled data to the Merkle-Patricia root hash stored on the blockchain;
[0061] If the results are consistent, it means that the data of the entire process of air pollution prevention is complete;
[0062] If the results are inconsistent, it means that there are errors in the data of the entire air pollution prevention process and wrong information is extracted.
[0063] Specifically, the specific steps of step S5 include:
[0064] S5.1: The requester initiates a data access permission request by calling a smart contract in Hyperledger Fabric.
[0065] S5.2: After receiving the request from the requester, the smart contract passes the request information to the system's access control module, which reads the preset permission management policy from the system; the permission management policy includes user role, data type, and access time range;
[0066] S5.3: Verify the identity of the requester and the data being accessed based on the pre-set permission management policy.
[0067] If the requester's permission verification is successful, the system returns the data content identifier and storage node information to the requester;
[0068] If the requester's permission verification fails, the system returns access denial information to the requester and explains the reason for the denial;
[0069] S5.4: Record the access information of the requester, including the identity information of the requester, the time of the request, the identifier of the data content requested for access, and the verification result, and write the access record as transaction data into the Hyperledger Fabric blockchain through the smart contract.
[0070] Air environment monitoring data identification system, including: data processing module, distributed storage module, blockchain module, collaborative verification module, access control module;
[0071] The data processing module is used to obtain data from the entire air pollution prevention process and perform preliminary processing and caching;
[0072] The distributed storage module is used for data fingerprint caching, distributed shard storage of air pollution prevention full-process data, and hash verification;
[0073] The blockchain module is used to build a data verification structure and store evidence on the chain;
[0074] The collaborative verification module is used to verify the integrity of off-chain data through on-chain anchor points;
[0075] The access control module is used to control and audit data access permissions based on smart contracts.
[0076] Specifically, the distributed storage module includes: a data sharding unit, a distributed storage unit, and a content identification generation unit;
[0077] The data slicing unit is used to slice the air pollution prevention full process data according to the time and space dimensions to obtain air pollution prevention full process data blocks;
[0078] The distributed storage unit is used to store the air pollution prevention full process data blocks in the distributed network;
[0079] The content identifier generation unit is used to generate a unique content identifier for each air pollution prevention full-process data block as a basis for data addressing.
[0080] Compared with the prior art, the present invention has the following beneficial effects:
[0081] 1. The present invention proposes an air environment monitoring data identification system and optimizes and improves the architecture, operation steps and processes. The system has the advantages of simple process, low investment and operation costs, and low production work costs.
[0082] 2. This paper proposes an air environment monitoring data identification method. Through the chain verification mechanism of data fingerprint and Merkle-Patricia tree, it realizes the full-process trusted storage and verification of air pollution prevention data. Through hash sharding storage and dynamic sampling verification technology, it reduces the on-chain storage cost while ensuring data integrity. Secondly, the blockchain-based permission management system realizes fine-grained control of data access. Combined with the traceability capability of transaction hash, it reduces the risk of data leakage and improves the credibility of access records.
[0083] 3. The present invention proposes an air environment monitoring data identification method, and constructs a trusted circulation system for the entire process of air pollution prevention and control through a cross-chain collaborative verification mechanism. Specifically, it includes: First, the use of a dynamic hash mapping algorithm realizes the intelligent matching of data shards and storage nodes, thereby improving data retrieval efficiency; Second, through the combination of blockchain evidence storage and smart contracts, it realizes the automated approval of data access rights, shortening the processing time from the traditional hours to minutes, while ensuring the traceability of all operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0084] Figure 1 Schematic diagram of the air environment monitoring data identification method of the present invention;
[0085] Figure 2 This is a flow chart showing the principle of the air environment monitoring data identification method of the present invention;
[0086] Figure 3 This is a flow chart of the content identification acquisition method of the air environment monitoring data of the present invention;
[0087] Figure 4 This is a network topology diagram of the air environment monitoring data identification system of the present invention;
[0088] Figure 5 This is a flow chart of the interaction between the modules of the air environment monitoring data identification system of the present invention. DETAILED DESCRIPTION
[0089] Example 1
[0090] See also Figure 1-Figure 3 The present invention provides an embodiment of an air environment monitoring data identification method, comprising the following steps:
[0091] Step S1: Obtaining the full-process data of air pollution prevention and control, performing hash processing on the full-process data of air pollution prevention and control, generating a data fingerprint and temporarily caching it;
[0092] Among them, the full-process data of air pollution prevention and control covers the data involved in the entire process from the source of air pollution to the implementation of air pollution prevention and control measures. Specifically, the full-process data of air pollution prevention and control include but are not limited to air pollutant emission data, such as the type, concentration, and emission volume of industrial waste gas emissions; meteorological data, such as temperature, humidity, wind speed, wind direction, etc. These factors will significantly affect the diffusion and dilution of air pollutants; pollution source information, such as the factory's geographical location, production process, and the operating status of pollution control facilities; and implementation data of air pollution prevention and control measures, such as the commissioning of pollution control equipment.
[0093] Furthermore, the specific steps of step S1 include:
[0094] (1) Obtain data from the entire air pollution prevention process and perform preprocessing, including data cleaning and normalization;
[0095] (2) According to the importance of different data and the degree of impact on air pollution prevention and control, different weights are assigned to the pre-processed air pollution prevention and control full-process data to obtain weighted air pollution prevention and control full-process data;
[0096] (3) Using the SHA-3 method to perform hash processing on the weighted air pollution prevention full process data to generate a unique hash value, which is the data fingerprint;
[0097] (4) The generated data fingerprints are temporarily stored in the Redis distributed cache system, and a unique identifier is assigned to each data fingerprint.
[0098] Step S2: storing the air pollution prevention full process data in shards in a distributed network and obtaining content identifiers;
[0099] Step S3: Packing the data fingerprint, content identifier, and key metadata to generate a Merkle-Patricia tree, obtaining a Merkle-Patricia root hash, and storing the Merkle-Patricia root hash on-chain; the key metadata is configured based on the full-process data of air pollution prevention;
[0100] Step S4: Calculate the hash value of the data stored off-chain based on the Merkle-Patricia root hash stored on-chain, compare the on-chain and off-chain hash values, and verify the comparison result using a sampling verification strategy; the data stored off-chain is a distributed storage of the full process data block of air pollution prevention;
[0101] Step S5: The requester applies for data access rights through a smart contract. After receiving the application from the requester, the system verifies the requester's authority according to the preset authority management policy, and returns the content identifier and storage node information of the air pollution prevention and control full process data to the verified requester. At the same time, the access record is stored in the blockchain.
[0102] The temporary caching process in step S1 includes:
[0103] S1.1: Select the distributed cache system Redis cluster as a temporary cache carrier;
[0104] S1.2: Set a hash ring; the range of the hash ring is , where, because the hash value is 32 bits, the range of the hash ring is set to ;
[0105] S1.3: Calculate the corresponding physical node hash value for each physical node in the temporary cache carrier through a hash function, and map the physical node hash value to the hash ring;
[0106] Furthermore, the specific steps of S1.3 include:
[0107] (1) Determine all physical nodes in the temporary cache carrier, where these physical nodes are usually represented in the form of IP addresses and port numbers;
[0108] (2) Using the MurmurHash function to perform hash calculation on each physical node to obtain the corresponding physical node hash value, wherein the MurmurHash function is the existing technical content in this field and is not the inventive solution of this application, and is not described in detail here;
[0109] (3) Map the calculated physical node hash value to the range on the hash ring.
[0110] S1.4: Map each generated data fingerprint to the hash ring through the hash function to obtain the corresponding data fingerprint hash value ; The data fingerprint hash value is used to determine the node to which the data fingerprint is assigned on the hash ring;
[0111] Furthermore, the specific steps of S1.4 include:
[0112] (1) Obtain the generated data fingerprint;
[0113] (2) Use the MurmurHash function to calculate each data fingerprint to obtain the corresponding data fingerprint hash value;
[0114] (3) Map the calculated data fingerprint hash value to the range on the hash ring.
[0115] S1.5: From data fingerprint hash value Start at position on the hash ring;
[0116] If the data fingerprint hash value If it is greater than the hash value of all nodes on the hash ring, The corresponding data fingerprint is assigned to the node with the smallest hash value on the hash ring for temporary caching;
[0117] If the data fingerprint hash value If the hash value of a node is less than or equal to that of any node on the hash ring, search clockwise along the hash ring and The corresponding data fingerprint is assigned to the first encountered node found for temporary caching;
[0118] It should be noted that in the present invention, when the data fingerprint hash value is greater than the hash values of all existing physical nodes on the hash ring, if it is not assigned to the node with the smallest hash value, then the data fingerprint will not be able to find a suitable storage location on the hash ring, which will destroy the integrity and continuity of the entire data distribution. Assigning it to the node with the smallest hash value can ensure that all data fingerprints have corresponding storage nodes on the hash ring, maintain the integrity of the data distribution logic, and also help to distribute the data fingerprints more evenly on the various nodes of the hash ring.
[0119] S1.6: Assign a node according to the determined data fingerprint, connect to the physical node in the corresponding temporary cache carrier, and store the data fingerprint in the cache of the physical node in the form of a key-value pair; the key-value pair consists of a data fingerprint hash value and a data fingerprint, wherein the physical node connected to the corresponding temporary cache carrier is implemented based on the redis-py library.
[0120] The specific steps of step S2 include:
[0121] S2.1: Apply a cryptographic hash function to each storage node IP:Port combination in the distributed network to obtain a storage node hash value; the IP:Port combination is a combination of an IP address and a port number, wherein the cryptographic hash function uses SHA-256;
[0122] S2.2: Sort the hash values of all storage nodes to form a clockwise ring structure to obtain a storage node hash ring;
[0123] S2.3: Obtain the full-process data of air pollution prevention and control, and split the full-process data of air pollution prevention and control into N data blocks according to a sharding key; the sharding key is a combination of a timestamp and a monitoring point ID;
[0124] Furthermore, the specific steps of S2.3 include:
[0125] (1) Define the shard key:
[0126] Based on the characteristics and business needs of the full-process data for air pollution prevention, a combination of timestamp and monitoring point ID is selected as the sharding key. For example, sharding by time can divide data by day, hour, etc.; sharding by monitoring point ID can store data from different monitoring points separately.
[0127] (2) Data segmentation:
[0128] Traverse the acquired air pollution prevention data and distribute it into different data blocks according to the shard key value.
[0129] Create a container for each data block and add data that matches the same shard key to the corresponding container; the container is a list or dictionary.
[0130] S2.4: Apply a cryptographic hash function to the air pollution prevention full-process data of each data block to generate a content fingerprint hash value; where the content fingerprint is a 64-bit hexadecimal string;
[0131] Furthermore, the specific steps of S2.4 include:
[0132] (1) Obtain the divided data blocks from S2.3;
[0133] (2) Take the air pollution prevention full process data x in the divided data block as input and use the formula Calculate and get the hash value ,in, Represents the SHA-256 cryptographic hash function;
[0134] (3) The calculated hash value is used as the content fingerprint hash value, which is usually converted into a hexadecimal string for easy storage and transmission.
[0135] S2.5: Find the location corresponding to the content fingerprint hash value on the storage node hash ring. Starting from the location where the content fingerprint hash value is located, search along the storage node hash ring in a clockwise direction to find the first storage node with a hash value greater than or equal to the content fingerprint hash value.
[0136] If no storage node with a hash value greater than the content fingerprint is found after traversing the entire storage node hash ring, the first storage node on the storage node hash ring is selected;
[0137] S2.6: Allocate the corresponding air pollution prevention full process data block to the found storage node for storage;
[0138] S2.7: Based on the allocation result in S2.6, each air pollution prevention full-process data block is stored in the corresponding storage node. At the same time, the generated content fingerprint is used as the content identifier, and the content identifier corresponding to each data block is recorded.
[0139] The specific steps of step S3 include:
[0140] S3.1: Collect data fingerprints, content identifiers, and key metadata; key metadata includes the time, location, and monitoring equipment information for data collection throughout the air pollution prevention process;
[0141] S3.2: Convert the data fingerprint, content identifier, and key metadata into a composite key-value pair; the composite key-value pair includes a composite key and a composite value;
[0142] Furthermore, the specific process of converting the data fingerprint, content identifier, and key metadata into a composite key-value pair includes:
[0143] (1) Determine the composition rules of composite keys and composite values:
[0144] Composite key: Select one or more unique pieces of information to form a composite key, ensuring that different data blocks have different composite keys. Common choices are a combination of data fingerprint, collection time, and monitoring point ID.
[0145] Composite value: A composite value is formed by combining the content identifier and key metadata. The key metadata includes the time, location, and monitoring equipment information of the air pollution prevention full process data collection.
[0146] (2) Check data fingerprints, content identifiers and key metadata to ensure the integrity and accuracy of the data;
[0147] (3) Combine information according to the determined composite key composition rules. During the combination process, separators are needed to distinguish different parts of information;
[0148] (4) Combining the content identifier and key metadata into a data structure, such as a dictionary or list, as a composite value;
[0149] (5) Combine the constructed composite key and composite value into a key-value pair, completing the conversion from data fingerprint, content identification and key metadata to composite key-value pair.
[0150] S3.3: For each composite key-value pair, create a leaf node;
[0151] Furthermore, the specific steps of S3.3 include:
[0152] (1) Define the data structure of the leaf node, where the leaf node should contain a composite key, a composite value, and the hash value of the node;
[0153] (2) Create a leaf node class in the programming language and define the corresponding properties and methods in the leaf node class;
[0154] (3) Traverse all compound key-value pairs and create a corresponding leaf node for each compound key-value pair;
[0155] (4) Assign the composite key and composite value to the corresponding attributes of the leaf node respectively.
[0156] S3.4: Perform hash calculation on the composite value of each leaf node to obtain a leaf node hash value, and assign the calculated leaf node hash value to the hash attribute of the leaf node;
[0157] S3.5: Recursively construct expansion nodes and branch nodes based on the prefix of the composite key and the structure of the Merkle-Patricia tree;
[0158] S3.6: For extension nodes and branch nodes, combine the hash values of their child nodes and perform hash calculation to obtain the hash value of the current node;
[0159] Furthermore, the specific steps of S3.6 include:
[0160] (1) Determine whether the currently processed node is an expansion node or a branch node;
[0161] (2) Collect child node hash values, where:
[0162] The extended node has only one child node, so the hash value of the child node is directly obtained;
[0163] A branch node has at least two child nodes. The hash values of all child nodes must be collected and arranged in lexicographical order to ensure consistency of each calculation.
[0164] (3) Combine the prefix information of the extended node with the hash value of the child node, where the prefix information is determined when constructing the extended node and represents a group of composite keys with the same prefix;
[0165] (4) Concatenate the hash values of all collected child nodes in sequence to obtain the combined hash value;
[0166] (5) Use the SHA-256 cryptographic hash function to calculate the combined hash value to obtain the current node hash value;
[0167] (6) Store the calculated hash value of the current node in the node object.
[0168] S3.7: Starting from the leaf node, calculate the hash value of each node layer by layer until the root node, and obtain the Merkle-Patricia root hash;
[0169] S3.8: Use a smart contract to record the Merkle-Patricia root hash as transaction data on the Hyperledger Fabric blockchain. At the same time, the blockchain assigns a unique transaction hash to the transaction data.
[0170] Furthermore, the specific steps of S3.8 include:
[0171] (1) Building a Hyperledger Fabric network, including creating organizations, nodes, and channels, and using the configtxgen tool to generate configuration files. The process of building a Hyperledger Fabric network is prior art in this field and is not an inventive solution of this application, so it will not be described in detail here.
[0172] (2) Developing a smart contract using a programming language, where the smart contract needs to include a function for recording the Merkle-Patricia root hash;
[0173] (3) Get the Merkle-Patricia root hash from S3.7;
[0174] (4) Use Hyperledger Fabric’s SDK to connect to the established Hyperledger Fabric network. The Hyperledger Fabric SDK connection method is a prior art in this field and is not an inventive solution of this application, so it will not be described in detail here.
[0175] (5) In the client application, create a transaction proposal, call the function in the smart contract that records the Merkle-Patricia root hash, and pass the Merkle-Patricia root hash as a parameter to the function;
[0176] (6) Sign the transaction proposal and then submit it to the endorsement node in the Hyperledger Fabric network. The endorsement node will execute the smart contract code, verify the legitimacy of the transaction proposal, and return the endorsement result. The transaction proposal is signed using the elliptic curve digital signature algorithm. The elliptic curve digital signature algorithm is a prior art in this field and is not an inventive solution of this application. It will not be described in detail here.
[0177] Among them, the endorsement node is the node in the network responsible for verifying and endorsing transaction proposals; the endorsement result includes the signature, the identity information of the endorsement node, and the execution result.
[0178] (7) Send the endorsed transaction proposal to the sorting service node, which will sort the transaction proposal and generate a block. The transaction proposal is sorted using Kafka sorting. Kafka sorting is a prior art in this field and is not an inventive solution of this application. It will not be described in detail here.
[0179] Furthermore, the specific steps of generating a block include:
[0180] The upper limit of the number of transactions contained in each block is determined based on network configuration and performance considerations. When the number of sorted transactions reaches or exceeds the upper limit, a new block is constructed;
[0181] Create a block body and add the sorted transaction proposals to the block body in sequence to generate a block.
[0182] (8) The sorted blocks will be broadcast to all nodes in the network, and the nodes will write the blocks into the local ledger to complete the transaction record;
[0183] (9) After the transaction is written to the ledger, the transaction result is queried through the client application to obtain the unique transaction hash assigned by the blockchain to the transaction data.
[0184] The specific steps of constructing the extension node and the branch node in S3.5 include:
[0185] S3.51: Determine the structure and construction rules of the Merkle-Patricia tree, including node types, node storage methods, and prefix processing rules; the node types include leaf nodes, extension nodes, and branch nodes;
[0186] S3.52: Based on S3.3, obtain the composite key-value pairs of all leaf nodes and sort the composite keys of all leaf nodes in lexicographic order. This makes it easier to find composite keys with the same prefix, preparing for building expansion nodes and branch nodes.
[0187] S3.53: Traverse the sorted composite keys and find a set of composite keys with the same prefix. The length of the same prefix can be adjusted according to the actual situation. Generally, start with the shorter prefix.
[0188] S3.54: For a set of composite keys having the same prefix, create an expansion node; the expansion node comprises a prefix and a pointer to a child node, wherein the prefix is a common prefix of the composite keys and the child node can be another expansion node, a branch node, or a leaf node;
[0189] If the child node set of the expanded node still contains at least two nodes, continue to recursively search for common prefixes and build new expanded nodes or branch nodes until only one node, i.e., a leaf node, remains in the child node set.
[0190] S3.55: If the set of child nodes of the expanded node contains at least two different composite keys and has no common prefix, create a branch node; the branch node contains at least two child node pointers, each pointing to a different child node;
[0191] S3.56: Repeat the iteration until all leaf nodes are included in the Merkle-Patricia tree structure.
[0192] The specific steps of step S4 include:
[0193] S4.1: Locate and read the block storage nodes storing the full-process data of air pollution prevention through S2.7;
[0194] S4.2: Splicing the read air pollution prevention full process data blocks into complete air pollution prevention full process data according to the original order of the air pollution prevention full process data;
[0195] S4.3: Based on step S3, use the concatenated air pollution prevention process data to construct a Merkle-Patricia tree and obtain the root hash value of the off-chain Merkle-Patricia tree. The specific steps for constructing the Merkle-Patricia tree are the same as those in step S3.
[0196] S4.4: Connect to the blockchain network using the Hyperledger Fabric SDK and query the Merkle-Patricia root hash stored on the blockchain based on the transaction hash in S3.8.
[0197] S4.5: Directly compare the root hash of the off-chain Merkle-Patricia tree with the Merkle-Patricia root hash stored on the blockchain;
[0198] If the two are different, it indicates that there is an error in the air pollution prevention process data. The error information is extracted and notified to the system administrator; the error information includes the hash value difference, timestamp, and data shard location;
[0199] If the two are the same, it means that the air pollution prevention full process data has not been tampered with during storage and transmission;
[0200] S4.6: Set sampling rules; the sampling rules are to perform sampling according to the time range of the data;
[0201] S4.7: According to the set sampling rules, M data blocks are selected from the read air pollution prevention full process data as sampling data;
[0202] S4.8: Construct a Merkle-Patricia tree for the selected sample data and calculate its root hash value;
[0203] S4.9: Compare the root hash of the sampled data to the Merkle-Patricia root hash stored on the blockchain;
[0204] If the results are consistent, it means that the data of the entire process of air pollution prevention is complete;
[0205] If the results are inconsistent, it means that there is an error in the air pollution prevention and control full process data. The error information is extracted and notified to the system administrator.
[0206] The specific steps of step S5 include:
[0207] S5.1: The requester initiates a data access permission request by calling a smart contract in Hyperledger Fabric, where the request information is passed as a parameter to the corresponding function of the smart contract;
[0208] S5.2: After receiving the request from the requester, the smart contract passes the request information to the system's access control module, which reads the preset permission management policy from the system; the permission management policy includes user role, data type, and access time range;
[0209] S5.3: Verify the identity of the requester and the data being accessed, based on the pre-set permission management policy. For example, check whether the requester's role has permission to access the data and whether the requested access time is within the permitted range.
[0210] If the requester's permission verification is passed, the system returns the data content identifier and storage node information to the requester;
[0211] If the requester's permission verification fails, the system returns a message of access denial to the requester and explains the reason for the denial;
[0212] S5.4: Record the access information of the requester, including the identity information of the requester, the time of the request, the identifier of the data content requested for access, and the verification result, and write the access record as transaction data into the Hyperledger Fabric blockchain through the smart contract.
[0213] Example 2
[0214] See also Figure 4 and Figure 5 ,exist Figure 4In the embodiment, all front-end IoT sensing data is input through the Internet and then output by the output end. Users of the data acquisition end and terminal access can access the platform through the terminal access interface. Users of Internet terminal access can access the platform through the Internet port opened by the output end. Another embodiment provided by the present invention: an air environment monitoring data identification system, comprising:
[0215] Data processing module, distributed storage module, blockchain module, collaborative verification module, access control module;
[0216] Data processing module, used to obtain data from the entire air pollution prevention process and perform preliminary processing and caching;
[0217] Distributed storage module, used for data fingerprint caching, distributed shard storage and hash verification of air pollution prevention data throughout the entire process;
[0218] The blockchain module is used to build a verifiable data structure, ensure that the data cannot be tampered with, and store it on the chain;
[0219] Collaborative verification module, used to verify the integrity of off-chain data through on-chain anchor points;
[0220] Access control module, used for permission control and auditing of data access based on smart contracts.
[0221] The data processing module includes: a data cache unit and a hash calculation unit;
[0222] Data cache unit, used to temporarily store acquired air pollution prevention full-process data;
[0223] The hash calculation unit is used to calculate the hash value of the entire air pollution prevention process data and generate a unique data fingerprint for subsequent integrity verification.
[0224] The distributed storage module includes: a data sharding unit, a distributed storage unit, and a content identification generation unit;
[0225] A data sharding unit is used to shard the air pollution prevention full process data according to the time and space dimensions to obtain air pollution prevention full process data blocks;
[0226] Distributed storage unit, used to store data blocks of the entire air pollution prevention process in a distributed network;
[0227] The content identification generation unit is used to generate a unique content identification for each air pollution prevention full-process data block as a basis for data addressing.
[0228] The blockchain module includes: metadata management unit, Merkle-Patricia tree construction unit, and blockchain evidence storage unit;
[0229] Metadata management unit, used to integrate data fingerprints, content identifiers, and key metadata to form a structured index;
[0230] A Merkle-Patricia tree construction unit, configured to construct a Merkle-Patricia tree using the data fingerprint, content identifier, and key metadata as leaf nodes, and generate a root hash of the Merkle-Patricia tree;
[0231] The blockchain evidence storage unit is used to write the root hash to the blockchain and record the timestamp and transaction hash.
[0232] The collaborative verification module includes: hash comparison unit and sampling verification unit;
[0233] The hash comparison unit is used to recursively calculate the hash value of the off-chain distributed storage data based on the on-chain root hash and perform consistency comparison;
[0234] The sampling verification unit is used to randomly extract some content identifiers through the smart contract, request the node to return the corresponding air pollution prevention full process data block, and verify whether the hash matches the leaf node of the Merkle-Patricia tree.
[0235] The access control module includes: identity authentication unit, permission policy unit, data distribution unit, and audit log unit;
[0236] Identity authentication unit, used to verify the identity of the requester;
[0237] The permission policy unit is used to dynamically authorize access rights according to the preset permission management policy;
[0238] The data distribution unit is used to return the content identifier and storage node information of the target data to the authorized requester for querying the data;
[0239] The audit log unit is used to store access records on-chain to achieve tamper-proof audit tracking. The access records include the request time, requester identity, and authorization result.
[0240] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific embodiments. The above-mentioned specific embodiments are merely illustrative and not restrictive. Under the guidance of the present invention, ordinary technicians in this field can also change, modify, replace and modify the above-mentioned embodiments without departing from the purpose and scope of protection of the present invention. These are all protected by the present invention.
Claims
1. The air environment monitoring data identification method is characterized by: include: Step S1: Obtaining the full-process data of air pollution prevention and control, performing hash processing on the full-process data of air pollution prevention and control, generating a data fingerprint and temporarily caching it; Step S2: storing the air pollution prevention full process data in shards in a distributed network and obtaining content identifiers; Step S3: Packing the data fingerprint, content identifier, and key metadata to generate a Merkle-Patricia tree, obtaining a Merkle-Patricia root hash, and storing the Merkle-Patricia root hash on-chain; the key metadata is configured based on the full-process data of air pollution prevention; Step S4: Calculate the hash value of the data stored off-chain based on the Merkle-Patricia root hash stored on-chain, compare the on-chain and off-chain hash values, and verify the comparison result using a sampling verification strategy; the data stored off-chain is a distributed storage of the full process data block of air pollution prevention; Step S5: The requester applies for data access rights through the smart contract. After receiving the requester's application, the system verifies the requester's authority according to the preset authority management policy, and returns the content identifier and storage node information of the air pollution prevention full process data to the verified requester. At the same time, the access record is stored on the blockchain; The specific steps of S2 include: S2.1: Apply a cryptographic hash function to each storage node IP:Port combination in the distributed network to obtain a storage node hash value; the IP:Port combination is a combination of an IP address and a port number; S2.2: Sort the hash values of all storage nodes to form a clockwise ring structure to obtain a storage node hash ring; S2.3: Obtain the full-process data of air pollution prevention and control, and split the full-process data of air pollution prevention and control into N data blocks according to a sharding key; the sharding key is a combination of a timestamp and a monitoring point ID; S2.4: Apply a cryptographic hash function to the air pollution prevention full process data of each data block to generate a content fingerprint hash value; S2.5: Find the location corresponding to the content fingerprint hash value on the storage node hash ring. Starting from the location where the content fingerprint hash value is located, search along the storage node hash ring in a clockwise direction to find the first storage node with a hash value greater than or equal to the content fingerprint hash value. If no storage node with a hash value greater than the content fingerprint is found after traversing the entire storage node hash ring, the first storage node on the storage node hash ring is selected; S2.6: Allocate the corresponding air pollution prevention full process data block to the found storage node for storage; S2.7: Based on the allocation result in S2.6, each air pollution prevention full process data block is stored in the corresponding storage node. At the same time, the generated content fingerprint is used as the content identifier, and the content identifier corresponding to each data block is recorded; The specific steps of step S3 include: S3.1: Collect data fingerprints, content identifiers, and key metadata; key metadata includes the time, location, and monitoring equipment information for data collection throughout the air pollution prevention process; S3.2: Convert the data fingerprint, content identifier, and key metadata into a composite key-value pair; the composite key-value pair includes a composite key and a composite value; S3.3: For each composite key-value pair, create a leaf node; S3.4: Perform hash calculation on the composite value of each leaf node to obtain the leaf node hash value; S3.5: Recursively construct expansion nodes and branch nodes based on the prefix of the composite key and the structure of the Merkle-Patricia tree; S3.6: For extension nodes and branch nodes, combine the hash values of their child nodes and perform hash calculation to obtain the hash value of the current node; S3.7: Starting from the leaf node, calculate the hash value of each node layer by layer until the root node, and obtain the Merkle-Patricia root hash; S3.8: Use smart contracts to record the Merkle-Patricia root hash as transaction data on the Hyperledger Fabric blockchain. At the same time, the blockchain assigns a unique transaction hash to the transaction data.
2. The air environment monitoring data identification method according to claim 1, wherein: The temporary caching process in step S1 includes: S1.1: Select the distributed cache system Redis cluster as a temporary cache carrier; S1.2: Set up the hash ring; S1.3: Calculate the corresponding physical node hash value for each physical node in the temporary cache carrier through a hash function, and map the physical node hash value to the hash ring; S1.4: Map each generated data fingerprint to the hash ring through the hash function to obtain the corresponding data fingerprint hash value ; The data fingerprint hash value is used to determine the node to which the data fingerprint is assigned on the hash ring; S1.5: From data fingerprint hash value Start at position on the hash ring; If the data fingerprint hash value If it is greater than the hash value of all nodes on the hash ring, The corresponding data fingerprint is assigned to the node with the smallest hash value on the hash ring for temporary caching; If the data fingerprint hash value If the hash value of a node is less than or equal to that of any node on the hash ring, search clockwise along the hash ring and The corresponding data fingerprint is assigned to the first encountered node found for temporary caching; S1.6: Allocate a node based on the determined data fingerprint, connect to the physical node in the corresponding temporary cache carrier, and store the data fingerprint in the cache of the physical node in the form of a key-value pair; the key-value pair consists of a data fingerprint hash value and the data fingerprint.
3. The air environment monitoring data identification method according to claim 2, wherein: The specific steps of constructing the extension node and the branch node in S3.5 include: S3.51: Determine the structure and construction rules of the Merkle-Patricia tree, including node types, node storage methods, and prefix processing rules; the node types include leaf nodes, extension nodes, and branch nodes; S3.52: Based on S3.3, obtain the composite key-value pairs of all leaf nodes and sort the composite keys of all leaf nodes in lexicographic order; S3.53: Traverse the sorted composite keys and find the set of composite keys with the same prefix; S3.54: For a set of composite keys having the same prefix, create an extension node; the extension node includes a prefix and a pointer to a child node; If the child node set of the expanded node still contains at least two nodes, recursively search for a common prefix and construct a new expanded node or branch node until only one node, i.e., a leaf node, remains in the child node set. S3.55: If the set of child nodes of the expanded node contains at least two different composite keys and no common prefix, then create a branch node; the branch node contains at least two child node pointers, each pointing to a different child node; S3.56: Repeat the iteration until all leaf nodes are included in the Merkle-Patricia tree structure.
4. The air environment monitoring data identification method according to claim 3, wherein: The specific steps of step S4 include: S4.1: Locate the storage node storing the air pollution prevention full process data block through S2.7 and read it; S4.2: Splicing the read air pollution prevention full process data blocks into complete air pollution prevention full process data according to the original order of the air pollution prevention full process data; S4.3: Based on step S3, use the concatenated air pollution prevention process data to construct a Merkle-Patricia tree and obtain the root hash value of the off-chain Merkle-Patricia tree. S4.4: Connect to the blockchain network using the Hyperledger Fabric SDK and query the Merkle-Patricia root hash value stored on the blockchain based on the transaction hash in S3.
8.
5. The air environment monitoring data identification method according to claim 4, characterized in that: The specific steps of step S4 also include: S4.5: Compare the root hash of the off-chain Merkle-Patricia tree to the Merkle-Patricia root hash stored on the blockchain; If the two are different, it indicates that there is an error in the air pollution prevention process data, and error information is extracted; the error information includes the hash value difference, timestamp, and data shard location; If the two are the same, it means that the air pollution prevention full process data has not been tampered with during storage and transmission; S4.6: Set sampling rules; the sampling rules are to perform sampling according to the time range of the data; S4.7: According to the set sampling rules, M data blocks are selected from the read air pollution prevention full process data as sampling data; S4.8: Construct a Merkle-Patricia tree for the selected sample data and calculate its root hash value; S4.9: Compare the root hash of the sampled data to the Merkle-Patricia root hash stored on the blockchain; If the results are consistent, it means that the data of the entire process of air pollution prevention is complete; If the results are inconsistent, it means that there are errors in the data of the entire air pollution prevention process and wrong information is extracted.
6. The air environment monitoring data identification method according to claim 5, characterized in that: The specific steps of step S5 include: S5.1: The requester initiates a data access permission request by calling a smart contract in Hyperledger Fabric. S5.2: After receiving the request from the requester, the smart contract passes the request information to the system's access control module, which reads the preset permission management policy from the system; the permission management policy includes user role, data type, and access time range; S5.3: Verify the identity of the requester and the data being accessed based on the pre-set permission management policy. If the requester's permission verification is successful, the system returns the data content identifier and storage node information to the requester; If the requester's permission verification fails, the system returns access denial information to the requester; S5.4: Record the requester's access information, including the requester's identity information, the time of the request, the identifier of the data content requested for access, and the verification result. The access record is written as transaction data into the Hyperledger Fabric blockchain through a smart contract.
7. An air environment monitoring data identification system, which is used to implement the air environment monitoring data identification method according to any one of claims 1 to 6, characterized in that: include: Data processing module, distributed storage module, blockchain module, collaborative verification module, access control module; The data processing module is used to obtain data from the entire air pollution prevention process and perform preliminary processing and caching; The distributed storage module is used for data fingerprint caching, distributed shard storage of air pollution prevention full-process data, and hash verification; The blockchain module is used to build a data verification structure and store evidence on the chain; The collaborative verification module is used to verify the integrity of off-chain data through on-chain anchor points; The access control module is used to control and audit data access permissions based on smart contracts.
8. The air environment monitoring data identification system according to claim 7, characterized in that: The distributed storage module includes: a data sharding unit, a distributed storage unit, and a content identification generation unit; The data slicing unit is used to slice the air pollution prevention full process data according to the time and space dimensions to obtain air pollution prevention full process data blocks; The distributed storage unit is used to store the air pollution prevention full process data blocks in the distributed network; The content identifier generation unit is used to generate a unique content identifier for each air pollution prevention full-process data block as a basis for data addressing.
Citation Information
Patent Citations
Digital wetland ecological environment monitoring system
CN119583592A
Intelligent monitoring system and method for environmental monitoring data
CN113592349A
Medical image encryption and secure storage method and system based on block chain
CN120110790A