A Method and System for Traceability of Agricultural Product Pollution Sources Based on Blockchain and Intelligent Analytics
By combining blockchain and intelligent analytics technologies with data collected from barcode scanning terminals and IoT sensors, and employing hierarchical encryption and federated learning to train AI models, pollution sources can be identified. This solves the problems of data tampering and privacy leaks in traditional agricultural product traceability systems, achieving reliable traceability across the entire chain and efficient pollution source location.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING DEBAN CONSULTANCY CO LTD
- Filing Date
- 2025-09-11
- Publication Date
- 2026-04-17
AI Technical Summary
Traditional agricultural product traceability systems rely on manual investigation of pollution sources one by one, lack intelligent analysis tools, are difficult to adapt to multi-level distribution scenarios, affect traceability effectiveness, and data is easily lost or tampered with, making it difficult to determine responsibility.
Using a blockchain and intelligent analytics approach, data is collected through barcode scanning terminals and IoT sensors, encrypted hierarchically, and stored on the Hyperledger Fabric consortium blockchain. Combined with federated learning to train AI models, pollution patterns are identified, and permissions are dynamically matched through smart contracts to generate a high-risk product recall list.
It enables reliable traceability of the entire agricultural product chain, accurate location of pollution sources and efficient recall, ensures food safety and supply chain privacy, and solves the problems of data tampering and privacy leakage.
Smart Images

Figure CN121190076B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of agricultural product traceability technology, and in particular to a method and system for tracing agricultural product pollution sources based on blockchain and intelligent analysis. Background Technology
[0002] As global food safety issues continue to receive attention, transparency and traceability in the agricultural product supply chain have become core requirements for safeguarding consumer health. Traditional agricultural product traceability systems, due to insufficient data credibility and lack of privacy protection, struggle to meet the demands of modern supply chains for full-chain, real-time, and reliable traceability. Particularly in multi-level distribution scenarios for bulk agricultural products, data from production, processing, and logistics stages is easily lost or tampered with, leading to interruptions in the traceability chain and difficulties in determining responsibility after contamination incidents. Therefore, building a traceability system that combines data immutability, privacy security, and intelligent analysis capabilities is crucial for solving agricultural product safety issues.
[0003] Currently, barcode traceability technology based on centralized databases is widely used in the field of agricultural product traceability. This technology records basic product information (such as place of origin and production date) by affixing one-dimensional or two-dimensional barcodes to agricultural product packaging, and stores the data in a centralized database managed by a third party. Consumers or regulatory agencies can access the database by scanning the barcodes to obtain traceability information. For example, some fresh food e-commerce platforms use this model, manually entering data from each stage to a centralized server to enable information retrieval of products from the place of origin to the sales end.
[0004] Regarding the aforementioned technologies, traditional traceability technologies rely on manual investigation of pollution sources one by one, lack intelligent analysis tools, and are difficult to adapt to multi-level distribution scenarios, thus affecting the traceability effect.
[0005] Based on this, this application provides a method and system for tracing agricultural product pollution sources based on blockchain and intelligent analysis. Summary of the Invention
[0006] To address the shortcomings of traditional traceability technologies, which rely on manual investigation of pollution sources, lack intelligent analysis tools, are ill-suited for multi-level distribution scenarios, and thus affect traceability effectiveness, this application provides a method and system for tracing agricultural product pollution sources based on blockchain and intelligent analysis.
[0007] Firstly, this application provides a method for tracing agricultural product pollution sources based on blockchain and intelligent analysis, employing the following technical solution: including:
[0008] Data is collected from each stage through a scanning terminal, and temperature, humidity and rapid detection data collected in real time by IoT sensors are synchronously integrated. The data is encrypted in a graded manner according to its sensitivity. The encrypted ciphertext data includes: ciphertext data packets, data sensitivity tags and corresponding encryption key indexes.
[0009] A blockchain network is built based on the Hyperledger Fabric consortium blockchain. The blockchain network nodes include producers and regulatory agencies. The PBFT consensus mechanism is adopted. Low-sensitivity data hash values, data sensitivity tags, encryption key indexes and access permission metadata are stored on the chain. High-level sensitive ciphertext is stored off-chain in IPFS. The results are obtained from the blockchain evidence hash, IPFS CID and smart contract address.
[0010] Based on the blockchain notarization hash and the IPFS CID, an AI model is trained through federated learning to analyze encrypted data to identify pollution patterns and output the probability distribution of pollution sources and a recall list of high-risk products.
[0011] Upon receiving an access request, the user's role identity is verified through the smart contract address. Based on the role's permissions and the data sensitivity tag, the corresponding level of decryption key is dynamically matched, and the corresponding decrypted data is displayed.
[0012] Preferably, the step of collecting data at each stage through a barcode scanning terminal, synchronously integrating real-time temperature and humidity data and rapid detection data collected by IoT sensors, and encrypting the data in stages according to data sensitivity, the encrypted data includes:
[0013] The raw data of agricultural products in the planting, processing, logistics and sales stages are collected through QR code scanning terminals. The raw data includes operation logs, timestamps, GPS coordinates and basic product information for each stage.
[0014] Synchronously integrate the real-time temperature and humidity data and rapid detection data collected by IoT sensors, and bind the sensor data with the original data collected by scanning the code through the product's unique identifier and timestamp to form an associated dataset;
[0015] Based on data sensitivity, the associated dataset is divided into high-sensitivity data, medium-sensitivity data, and low-sensitivity data. High-sensitivity data includes farmers' bank accounts and processors' cost data, medium-sensitivity data includes output and transportation temperature, and low-sensitivity data includes product name and place of origin.
[0016] The highly sensitive data is processed by scrambling + XOR + Base64 hybrid encoding and encrypted with the role-specific key K_role derived from the master key Kmaster. The medium sensitive data is encrypted with XOR and then encrypted with the role-specific key K_role. The low sensitive data is encoded with Base64 to generate the hierarchically encrypted ciphertext data packet. The data sensitivity tag and the corresponding encryption key index are added to the ciphertext data packet.
[0017] Preferably, the blockchain network built on the Hyperledger Fabric consortium blockchain includes producers and regulatory agencies as its nodes. It employs the PBFT consensus mechanism, stores low-sensitivity data hash values, data sensitivity tags, encryption key indexes, and access permission metadata on-chain, and stores high-level sensitive ciphertext off-chain via IPFS. This results in the blockchain notarization hash, the IPFS CID, and the smart contract address, including:
[0018] A consortium blockchain network is built based on the Hyperledger Fabric framework. The nodes of the blockchain network include producer nodes and regulatory nodes. The producer nodes correspond to farmers, processing plants and distributors in the agricultural product supply chain, and the regulatory nodes correspond to agricultural authorities.
[0019] The low-sensitivity data hash value, the data sensitivity tag, the encryption key index, and the access permission metadata are written into the main chain of the blockchain network. The access permission metadata includes the mapping relationship between user roles and encryption keys. The access rules for different roles to access data are defined through blockchain smart contracts.
[0020] High-level sensitive ciphertexts are stored off-chain through the IPFS distributed storage system. IPFS generates a unique Content Identifier (CID) for each high-level sensitive ciphertext, and the CID is used to identify the storage location of the ciphertext in the IPFS network.
[0021] The blockchain smart contract associates and binds the hash value of the low-sensitivity data stored on the chain with the CID of the medium-to-high-level sensitive ciphertext stored off-chain in IPFS to generate the blockchain evidence hash. At the same time, the blockchain smart contract for access control is deployed to obtain the blockchain evidence hash, the IPFS CID, and the smart contract address.
[0022] Preferably, the step of training an AI model through federated learning based on the blockchain notarization hash and the IPFS CID, analyzing encrypted data to identify pollution patterns, and outputting the probability distribution of pollution sources and a high-risk product recall list includes:
[0023] Metadata corresponding to the hash value of low-sensitivity data is obtained from the blockchain network through the blockchain evidence hash, and the encrypted data packet of medium-to-high-level sensitive data is pulled from the IPFS distributed storage system through the IPFS CID. Combined with the data sensitivity label and the encryption key index, the encrypted historical traceability data and the encrypted data collected in real time are decrypted to obtain encrypted historical traceability data for model training and encrypted data collected in real time.
[0024] Using producer nodes in the blockchain network as local nodes for federated learning, each local node trains a sub-model using its own encrypted historical traceability data, and uploads the sub-model parameters to the central node through an encrypted parameter aggregation mechanism to generate a global pollution pattern recognition model.
[0025] The encrypted data collected in real time is homomorphically encrypted and then input into the global contamination pattern recognition model. The global contamination pattern recognition model identifies high-risk contamination patterns based on preset risk rules and outputs a probability distribution of contamination sources that includes time and location dimensions.
[0026] Based on the graph algorithm, the topology of the agricultural product distribution network is analyzed, and the risk weight of each distribution node is calculated in combination with the probability distribution of pollution sources. A priority recall list of products in high-risk areas is generated, which includes product batch number, recall priority and corresponding distribution node information.
[0027] Preferably, the producer nodes in the blockchain network serve as local nodes for federated learning. Each local node uses its own encrypted historical tracing data to train a sub-model, and uploads the sub-model parameters to the central node through an encrypted parameter aggregation mechanism to generate a global contamination pattern recognition model, including:
[0028] The producer nodes in the blockchain network are configured as federated learning local nodes. Each local node uses the data sensitivity label and the encryption key index to select a sample set that meets the model training requirements from the encrypted historical traceability data stored in its own storage. The sample set includes timestamps, GPS coordinates, temperature and humidity sequences, product types and historical pollution event labels.
[0029] Each local node trains a sub-model based on its own sample set. During the training process, the K-means clustering algorithm is used to extract features from the environmental parameters in the sample set to generate high-risk feature clusters. The high-risk feature clusters are then associated with the historical pollution event labels using a random forest classifier to obtain a sub-model containing feature weights and classification thresholds.
[0030] Each local node uses the Secure Aggregation protocol to encrypt the feature weights and classification thresholds of its own sub-model parameters and uploads them to the federated learning center node. The center node is a regulatory node in the blockchain network and has the authority to decrypt and aggregate parameters.
[0031] The central node decrypts and weights the received encrypted sub-model parameters to generate the global pollution pattern recognition model. The global pollution pattern recognition model integrates the feature extraction rules and classification logic of all local nodes and can identify complex pollution patterns across stages.
[0032] Preferably, the real-time collected encrypted data is homomorphically encrypted and then input into the global contamination pattern recognition model. The global contamination pattern recognition model identifies high-risk contamination patterns based on preset risk rules and outputs a contamination source probability distribution including time and location dimensions, including:
[0033] The encrypted data collected in real time is verified for data integrity by comparing the hash value with the blockchain evidence hash to determine the trusted data. The data sensitivity tags are then used to filter out the medium and high level sensitive data to be analyzed.
[0034] For the high-level sensitive data to be analyzed, a partial homomorphic encryption algorithm is used to process the original plaintext data into a ciphertext state, ensuring that the data does not need to be decrypted during the model calculation process;
[0035] The homomorphically encrypted ciphertext data is input into the global contamination pattern recognition model. The input features of the global contamination pattern recognition model include environmental parameters, spatiotemporal features, product attributes, and operation logs.
[0036] The global pollution pattern recognition model calls a preset risk rule base, which contains multi-dimensional risk conditions. The global pollution pattern recognition model uses a random forest classifier to match real-time data with risk rules and calculate the pollution probability of each stage.
[0037] Based on the pollution probability calculation results, a pollution source probability distribution containing time and location dimensions is generated, and the pollution source probability distribution is converted into structured data for output.
[0038] Preferably, the step of analyzing the agricultural product distribution network topology based on the graph algorithm, calculating the risk weight of each distribution node in conjunction with the pollution source probability distribution, and generating a priority recall list for products in high-risk areas, the list includes product batch numbers, recall priorities, and corresponding distribution node information, including:
[0039] The agricultural product distribution records are retrieved from the blockchain network using the blockchain notarization hash, and combined with the logistics GPS coordinates collected by IoT sensors to construct a distribution network topology dataset, which includes node attributes and edge attributes.
[0040] The distribution network topology dataset is converted into a directed graph model using the Graph algorithm, where vertices are distribution nodes, directed edges represent the flow relationship of products from upstream nodes to downstream nodes, and edge weights are the product flow volume of the corresponding batch.
[0041] The probability distribution of pollution sources is mapped to each node of the distribution network topology, and the risk weight is calculated in combination with the node attributes: Risk weight = probability of pollution at node location × node level coefficient × proportion of historical turnover of node, wherein the node level coefficient is set according to the node depth of the distribution network.
[0042] Based on the risk weight of each distribution node, the nodes are sorted in descending order, and nodes with risk weights not less than a preset threshold are selected as high-risk area nodes. The product batch numbers associated with the high-risk area nodes are extracted, and the recall priority is determined according to the risk weight values.
[0043] By integrating the product batch numbers of the high-risk area nodes, the recall priority, and the corresponding distribution node information, a structured high-risk area product priority recall list is generated. The list is synchronized to regulatory agency nodes and corresponding distribution nodes through a blockchain smart contract.
[0044] Secondly, this application discloses a device for tracing agricultural product pollution sources based on blockchain and intelligent analysis, which adopts the following technical solution, including:
[0045] The data acquisition module is used to collect data from each stage through a barcode scanning terminal, synchronously integrate temperature and humidity and rapid detection data collected in real time by IoT sensors, and encrypt the data according to the sensitivity level. The encrypted data includes: encrypted data packets, data sensitivity tags and corresponding encryption key indexes.
[0046] The data encryption module is used to build a blockchain network based on the Hyperledger Fabric consortium chain. The blockchain network nodes include producers and regulatory agencies. It adopts the PBFT consensus mechanism and stores low-sensitivity data hash values, data sensitivity tags, encryption key indexes and access permission metadata on the chain. High-level sensitive ciphertext is stored off-chain in IPFS to obtain blockchain evidence hash, IPFS CID and smart contract address.
[0047] The model identification module is used to train an AI model through federated learning based on the blockchain notarization hash and the IPFS CID, analyze encrypted data to identify pollution patterns, and output the probability distribution of pollution sources and a recall list of high-risk products.
[0048] The dynamic decryption module is used to verify the user's role identity through the smart contract address when an access request is received, dynamically match the corresponding level decryption key according to the role permissions and the data sensitivity tag, and display the corresponding decrypted data.
[0049] Thirdly, this application also provides a control device, the device comprising:
[0050] It includes a memory and a processor, wherein the memory stores a computer program that can be loaded and executed by the processor, such as the above-described method for tracing agricultural product pollution sources based on blockchain and intelligent analysis.
[0051] Fourthly, this application also provides a computer-readable storage medium storing a computer program that can be loaded by a processor and executed as described above, a method for tracing agricultural product pollution sources based on blockchain and intelligent analysis.
[0052] In summary, this application collects data from all stages of planting, processing, and logistics through barcode scanning terminals and IoT sensors, encrypts the data according to sensitivity levels, and generates encrypted data containing encrypted data packets, sensitivity tags, and key indexes. Then, a node network is built based on the Hyperledger Fabric consortium blockchain, employing the PBFT consensus mechanism. Low-sensitivity data hashes and permission metadata are stored on-chain, while high-sensitivity encrypted data is stored in IPFS, achieving collaborative on-chain and off-chain evidence storage. Next, producer nodes serve as local nodes for federated learning, training sub-models and encrypting and aggregating them to generate a global contamination pattern recognition model. Homomorphically encrypted real-time data is input into the model to identify high-risk contamination patterns, outputting the spatiotemporal probability distribution of contamination sources. Combined with Graph algorithms, the distribution network is analyzed to generate a high-risk product recall list. Finally, user role permissions are dynamically matched through smart contracts, and the corresponding level of data is decrypted and displayed. This integrates the immutability and privacy protection technologies of blockchain, and uses AI intelligent models to analyze contamination sources, solving problems such as easy tampering of traditional traceability data, privacy leaks, and slow contamination location. This achieves reliable traceability of agricultural products across the entire chain, accurate location of contamination sources, and efficient recall, ensuring food safety and supply chain privacy security. Attached Figure Description
[0053] Figure 1 This is a flowchart illustrating a method for tracing agricultural product pollution sources based on blockchain and intelligent analysis.
[0054] Figure 2 This is a structural block diagram of an agricultural product pollution source traceability device based on blockchain and intelligent analysis. Detailed Implementation
[0055] The following combination Figure 1 - Figure 2 This application will be described in further detail.
[0056] Agricultural product safety is a critical issue concerning the national economy and people's livelihood, and full-chain traceability is the core means to ensure the quality and safety of agricultural products. Currently, traditional agricultural product traceability systems generally face pain points such as insufficient data credibility, lack of privacy protection, and low efficiency in locating contamination: centralized databases are easily tampered with, leading to distorted traceability information; sensitive data lacks protection mechanisms, posing a risk of privacy leaks; contamination incidents rely on manual investigation, which takes weeks and has low accuracy. These problems severely restrict the transparent management of the agricultural product supply chain and the effectiveness of food safety supervision.
[0057] To address the aforementioned issues, this application proposes a method for tracing agricultural product pollution sources based on blockchain and intelligent analysis, aiming to construct a full-chain traceability system through the integration of multiple technologies. By integrating technologies such as barcode scanning, hierarchical encryption, blockchain notarization, federated learning AI analysis, and dynamic access control, it achieves encrypted data collection, tamper-proof notarization, intelligent pollution pattern recognition, and hierarchical access control throughout the entire process from agricultural product planting, processing, logistics to sales.
[0058] Reference Figure 1 The embodiments of this application include at least steps S10 to S40.
[0059] S10 collects data from each stage through a barcode scanning terminal, and synchronously integrates real-time temperature and humidity data and rapid detection data collected by IoT sensors. The data is then encrypted in a hierarchical manner based on its sensitivity, resulting in encrypted data.
[0060] S20 is a blockchain network built on the Hyperledger Fabric consortium blockchain. The blockchain network nodes include producers and regulatory agencies. It adopts the PBFT consensus mechanism. Low-sensitivity data hash values, data sensitivity tags, encryption key indexes and access permission metadata are stored on the chain. High-level sensitive ciphertext is stored off-chain in IPFS. The results are blockchain evidence hash, IPFS CID and smart contract address.
[0061] S30, based on blockchain-based evidence hashing and IPFS CID, trains an AI model through federated learning, analyzes encrypted data to identify pollution patterns, and outputs the probability distribution of pollution sources and a recall list of high-risk products.
[0062] S40, upon receiving an access request, verifies the user's role identity through the smart contract address, dynamically matches the corresponding level decryption key based on role permissions and data sensitivity tags, and displays the corresponding decrypted data.
[0063] The encrypted data includes: encrypted data packets, data sensitivity labels, and corresponding encryption key indexes.
[0064] Specifically, in planting, processing, and logistics, scanning terminals and IoT sensors collect data, which is then encrypted according to sensitivity levels. Low-sensitivity data hashes and permission metadata are stored on the Hyperledger Fabric consortium blockchain, while medium-sensitivity encrypted data is stored on IPFS to ensure data immutability. Producer nodes serve as local nodes for federated learning to train sub-models, which are then encrypted and aggregated to generate a global AI model. Homomorphically encrypted real-time data is input into the model to identify pollution patterns (such as the risk of high temperature + long transportation), outputting the spatiotemporal probability distribution of pollution sources. Combined with the Graph algorithm, the distribution network is analyzed to generate a high-risk product recall list. Through smart contracts, user role permissions are dynamically matched, and corresponding levels of data are decrypted and displayed (consumers see basic information, and regulatory agencies see full-chain data), achieving reliable traceability, accurate pollution location, and privacy protection.
[0065] In some embodiments, step S10 specifically includes the following steps: collecting raw data of agricultural products in each stage of planting, processing, logistics and sales through a QR code scanning terminal. The raw data includes operation logs, timestamps, GPS coordinates and basic product information for each stage; synchronously integrating temperature and humidity data and rapid detection data collected in real time by IoT sensors, and binding the sensor data with the raw data collected by scanning through the product's unique identifier and timestamp to form an associated dataset; dividing the associated dataset into high-sensitivity data, medium-sensitivity data and low-sensitivity data according to data sensitivity, where high-sensitivity data includes farmers' bank accounts and processor cost data, medium-sensitivity data includes yield and transportation temperature, and low-sensitivity data includes product name and place of origin; processing high-sensitivity data with scrambling + XOR + Base64 mixed encoding, and encrypting it with the role-specific key K_role derived from the master key Kmaster; encrypting medium-sensitivity data with XOR and the role-specific key K_role; and encoding low-sensitivity data with Base64 to generate hierarchically encrypted ciphertext data packets, and adding data sensitivity tags and corresponding encryption key indexes to the ciphertext data packets.
[0066] Specifically, in each stage of agricultural product planting, processing, logistics, and sales, farmers, processing plants, and distributors collect operation logs, timestamps, GPS coordinates, and basic product information (such as pesticide usage lists during planting and HACCP key point data during processing) through QR code scanning terminals. Simultaneously, they integrate real-time temperature and humidity data and rapid detection data collected by IoT sensors (such as vehicle temperature and humidity during transportation and pesticide residue test values upon arrival). The scanned data and sensor data are bound together using the product's unique batch number and timestamp to form a related dataset. Based on data sensitivity, the related dataset is categorized: highly sensitive data (farmer's bank account, processor's cost) uses a scrambled + XOR + Base64 hybrid encoding and is encrypted with a role-specific key K_role; medium-sensitive data (yield, transportation temperature) uses XOR encryption and K_role encryption; and low-sensitive data (product name, place of origin) uses Base64 encoding. Finally, a tiered encrypted ciphertext data packet is generated, with data sensitivity tags and corresponding encryption key indexes added, laying the foundation for subsequent blockchain-based evidence storage and access control.
[0067] In some embodiments, step S20 specifically includes the following steps: Constructing a consortium blockchain network based on the Hyperledger Fabric framework. The nodes of the blockchain network include producer nodes and regulatory nodes. Producer nodes correspond to farmers, processing plants, and distributors in the agricultural product supply chain, while regulatory nodes correspond to agricultural authorities. Writing low-sensitivity data hash values, data sensitivity tags, encryption key indexes, and access permission metadata into the main chain of the blockchain network. The access permission metadata includes a mapping relationship between user roles and encryption keys. Defining access rules for different roles through blockchain smart contracts. Storing medium- and high-level sensitive ciphertexts off-chain through the IPFS distributed storage system. IPFS generates a unique Content Identifier (CID) for each medium- and high-level sensitive ciphertext, which identifies the storage location of the ciphertext in the IPFS network. Associating and binding the low-sensitivity data hash value stored on-chain with the CID of the medium- and high-level sensitive ciphertext stored off-chain in IPFS through blockchain smart contracts to generate a blockchain evidence hash. Simultaneously deploying a blockchain smart contract for access control, obtaining the blockchain evidence hash, the IPFS CID, and the smart contract address.
[0068] Specifically, an agricultural product supply chain consortium blockchain is built based on Hyperledger Fabric, with nodes covering producers such as farmers, processing plants, and distributors, as well as regulatory agencies under the agricultural authorities. The PBFT consensus mechanism is used to ensure decentralized trust. Low-sensitivity data hash values, data sensitivity tags, encryption key indexes, and user role-key mapping access permission metadata are written to the main chain. Data access rules for different roles such as farmers, consumers, and regulatory agencies are defined through smart contracts. Medium- and high-level sensitive encrypted data are distributed and stored in IPFS to generate a unique CID. The smart contract associates and binds the on-chain low-sensitivity data hash with the off-chain CID to generate a blockchain evidence hash. At the same time, an access control contract is deployed to ultimately obtain the evidence hash, the IPFS CID, and the contract address, achieving tamper-proof data evidence storage and tiered privacy protection.
[0069] In some embodiments, step S30 specifically includes the following steps: obtaining metadata corresponding to the hash value of low-sensitivity data from the blockchain network through blockchain evidence hashing; pulling encrypted data packets of medium-to-high-level sensitive data from the IPFS distributed storage system through the IPFS CID; decrypting the encrypted historical traceability data and real-time collected encrypted data for model training by combining data sensitivity tags and encryption key indexes; using producer nodes in the blockchain network as local nodes for federated learning, each local node uses its own encrypted historical traceability data to train a sub-model, and uploads the sub-model parameters to the central node through an encrypted parameter aggregation mechanism to generate a global pollution pattern recognition model; inputting the real-time collected encrypted data into the global pollution pattern recognition model after homomorphic encryption processing; the global pollution pattern recognition model identifies high-risk pollution patterns based on preset risk rules and outputs a pollution source probability distribution including time and location dimensions; analyzing the topology of the agricultural product distribution network based on the Graph algorithm, calculating the risk weight of each distribution node by combining the pollution source probability distribution, and generating a priority recall list for products in high-risk areas, which includes product batch numbers, recall priorities, and corresponding distribution node information.
[0070] Furthermore, step S30 also includes the following steps: configuring producer nodes in the blockchain network as local nodes for federated learning; each local node, through data sensitivity tags and encryption key indexes, selects a sample set that meets the model training requirements from its own stored encrypted historical traceability data; the sample set includes timestamps, GPS coordinates, temperature and humidity sequences, product types, and historical pollution event tags; each local node trains a sub-model based on its own sample set; during training, the K-means clustering algorithm is used to extract features from the environmental parameters in the sample set, generating high-risk feature clusters, and a random forest classifier is used to associate the high-risk feature clusters with historical pollution event tags to obtain a sub-model containing feature weights and classification thresholds; each local node uses the Secure Aggregation protocol to encrypt the feature weights and classification thresholds of its own sub-model parameters and uploads them to the federated learning center node; the center node is a regulatory agency node in the blockchain network with parameter decryption and aggregation permissions; the center node decrypts and weights the received encrypted sub-model parameters to generate a global pollution pattern recognition model; the global pollution pattern recognition model integrates the feature extraction rules and classification logic of all local nodes and can identify complex pollution patterns across stages.
[0071] Specifically, low-sensitivity metadata and medium-to-high-sensitivity encrypted data packets are obtained through blockchain notarization hashes and IPFS CIDs. These are then decrypted using sensitivity tags and key indexes to obtain historical traceability data (and real-time collected data, such as transportation temperature and humidity). Farmers, processing plants, and other producer nodes serve as local nodes for federated learning, training sub-models with their own historical data. Parameters are encrypted and uploaded to the regulatory agency's central node for aggregation, generating a global pollution pattern recognition model. Real-time data is homomorphically encrypted and input into the model. Based on preset rules (such as high temperature + long transportation), high-risk pollution patterns are identified, and a pollution source probability distribution with time and location dimensions is output. The topology of the distributor network is analyzed using a graph algorithm, calculating the risk weight of each node (pollution probability × hierarchical coefficient × circulation volume ratio), generating a high-risk product recall list containing batch numbers, priorities, and distribution node information, which is then synchronized to the regulatory agency and corresponding nodes.
[0072] Furthermore, step S30 also includes the following steps: After verifying the integrity of the real-time collected encrypted data by comparing its hash value with the blockchain's notarized hash, trusted data is determined; and high-level sensitive data to be analyzed is selected by combining data sensitivity tags. The high-level sensitive data to be analyzed is processed using a partially homomorphic encryption algorithm to convert the original plaintext data into encrypted state, ensuring that the data does not need to be decrypted during model calculation. The homomorphically encrypted encrypted data is input into the global pollution pattern recognition model, whose input features include environmental parameters, spatiotemporal features, product attributes, and operation logs. The global pollution pattern recognition model calls a preset risk rule base, which contains multi-dimensional risk conditions. The global pollution pattern recognition model uses a random forest classifier to match real-time data with risk rules and calculates the pollution probability of each stage. Based on the pollution probability calculation results, a pollution source probability distribution containing time and location dimensions is generated, and the pollution source probability distribution is converted into structured data for output.
[0073] The risk database is set up by the manufacturer, and the risk rules are entered in advance by the risk rules administrator.
[0074] Specifically, the real-time collected encrypted agricultural product data is first verified for integrity by comparing its hash value with the blockchain's notarized hash to ensure it has not been tampered with, thus confirming it as trustworthy data. Then, sensitivity tags are used to filter out medium- to high-level sensitive data for analysis. This sensitive data is processed into encrypted form using a partially homomorphic encryption algorithm, ensuring that the model does not need to decrypt the original data during calculation. The encrypted encrypted data is then input into a global pollution pattern recognition model. The model receives environmental parameters (temperature and humidity), spatiotemporal features (time stamps, GPS coordinates), product attributes (variety), and operation logs (processing steps), among other features. A pre-defined risk rule base is invoked, and a random forest classifier is used to match real-time data with the rules to calculate the pollution probability in planting, processing, and logistics. Finally, a pollution source probability distribution containing time (e.g., the transportation period of a batch of vegetables) and location (a logistics node) dimensions is generated, converted into structured data, and output to regulatory agencies or enterprises for locating pollution points.
[0075] Furthermore, step S30 also includes the following steps: retrieving agricultural product distribution records from the blockchain network through blockchain notarization hash, and constructing a distribution network topology dataset by combining logistics GPS coordinates collected by IoT sensors. The distribution network topology dataset includes node attributes and edge attributes. The distribution network topology dataset is converted into a directed graph model using a graph algorithm, where vertices are distribution nodes, directed edges represent the flow relationship of products from upstream nodes to downstream nodes, and edge weights are the flow volume of the corresponding batch of products. The probability distribution of pollution sources is mapped to each node of the distribution network topology, and the risk weight is calculated by combining node attributes: Risk weight = node location pollution probability × node level coefficient × node historical flow volume ratio, where the node level coefficient is set according to the node depth of the distribution network. The risk weights of each distribution node are sorted in descending order, and nodes with risk weights not less than a preset threshold are selected as high-risk area nodes. The product batch numbers associated with the high-risk area nodes are extracted, and the recall priority is determined according to the risk weight values. The product batch numbers, recall priorities, and corresponding distribution node information of the high-risk area nodes are integrated to generate a structured high-risk area product priority recall list, which is synchronized to the regulatory agency node and the corresponding distribution node through a blockchain smart contract.
[0076] Specifically, the system retrieves agricultural product distribution records using blockchain-based notarized hashing and constructs a distribution network topology dataset (including node attributes: distributor type, region, and turnover volume; edge attributes: turnover time and transportation distance) using logistics GPS coordinates. A graph algorithm is then used to convert the dataset into a directed graph model, with vertices representing distribution nodes (first- / second-tier distributors, retailers), directed edges representing upstream and downstream product turnover relationships, and edge weights corresponding to batch turnover volumes. The probability distribution of pollution sources is mapped to each node, and risk weights are calculated based on node attributes. Nodes are sorted in descending order of risk weight, high-risk nodes with risk weights not less than a threshold are selected, associated batch numbers are extracted, and recall priorities are determined according to weights. This process integrates and generates a recall list containing batch numbers, priorities, and distributor information, which is then synchronized to regulatory agencies and corresponding distribution nodes via smart contracts to achieve precise recall.
[0077] The implementation principle of the agricultural product pollution source traceability method based on blockchain and intelligent analysis in this application embodiment is as follows: Data from the entire process of planting, processing, and logistics is collected through barcode scanning terminals and IoT sensors. This data is then encrypted according to sensitivity levels to generate encrypted data containing encrypted data packets, sensitivity tags, and key indexes. Next, a node network is built based on the Hyperledger Fabric consortium blockchain, employing the PBFT consensus mechanism. Low-sensitivity data hashes and permission metadata are stored on-chain, while medium- and high-sensitivity encrypted data is stored in IPFS, achieving collaborative on-chain and off-chain evidence storage. Then, producer nodes serve as local nodes for federated learning, training sub-models and encrypting and aggregating them to generate a global pollution pattern recognition model. Homomorphically encrypted real-time data is input into the model to identify high-risk pollution patterns, outputting a spatiotemporal probability distribution of pollution sources. Combined with Graph algorithm analysis of the distribution network, a high-risk product recall list is generated. Finally, user role permissions are dynamically matched through smart contracts, and the corresponding level of data is decrypted and displayed. This technology integrates the immutability and privacy protection of blockchain, and uses AI intelligent models to analyze pollution sources, solving problems such as easy tampering of traditional traceability data, privacy leaks, and slow pollution location. It enables reliable traceability of agricultural products across the entire supply chain, accurate location of pollution sources, and efficient recall, thus ensuring food safety and supply chain privacy.
[0078] Figure 1 This is a flowchart illustrating a method for tracing agricultural product pollution sources based on blockchain and intelligent analytics, as shown in one embodiment. It should be understood that, although... Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows; unless explicitly stated herein, there is no strict order requirement for the execution of these steps, and they can be executed in other orders; and Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0079] Based on the same technical concept, referring to Figure 2 This application also provides a blockchain-based intelligent analysis-based agricultural product pollution source traceability device, which adopts the following technical solution: The device includes:
[0080] The data acquisition module is used to collect data from each stage through a barcode scanning terminal. It synchronously integrates temperature and humidity data collected in real time by IoT sensors and rapid detection data. The data is encrypted in a hierarchical manner according to its sensitivity. The encrypted data includes: encrypted data packets, data sensitivity tags and corresponding encryption key indexes.
[0081] The data encryption module is used to build a blockchain network based on the Hyperledger Fabric consortium blockchain. The blockchain network nodes include producers and regulatory agencies. It adopts the PBFT consensus mechanism. Low-sensitivity data hash values, data sensitivity tags, encryption key indexes and access permission metadata are stored on the chain. High-level sensitive ciphertext is stored off-chain in IPFS. The result is the blockchain evidence hash, IPFS CID and smart contract address.
[0082] The model recognition module is used to train an AI model based on blockchain notarization hash and IPFS CID, analyze encrypted data to identify pollution patterns, and output the probability distribution of pollution sources and a recall list of high-risk products.
[0083] The dynamic decryption module verifies the user's role identity through the smart contract address when an access request is received. Based on the role's permissions and data sensitivity tags, it dynamically matches the corresponding level of decryption key and displays the corresponding decrypted data.
[0084] In some embodiments, the data acquisition module is specifically used to collect raw data of agricultural products in each stage of planting, processing, logistics and sales through a QR code scanning terminal. The raw data includes operation logs, timestamps, GPS coordinates and basic product information for each stage.
[0085] It synchronously integrates real-time temperature and humidity data and rapid detection data collected by IoT sensors, and binds the sensor data with the raw data collected by scanning the code through the product's unique identifier and timestamp to form a related dataset;
[0086] Based on data sensitivity, the associated datasets are divided into high-sensitivity data, medium-sensitivity data, and low-sensitivity data. High-sensitivity data includes farmers' bank accounts and processors' cost data, medium-sensitivity data includes output and transportation temperature, and low-sensitivity data includes product names and place of origin.
[0087] Highly sensitive data is processed using a combination of scrambling, XOR, and Base64 encoding, and then encrypted using a role-specific key K_role derived from the master key Kmaster. Mediumly sensitive data is encrypted using XOR and then encrypted using the role-specific key K_role. Lowly sensitive data is encoded using Base64. This process generates hierarchically encrypted ciphertext data packets, and adds data sensitivity tags and corresponding encryption key indexes to the ciphertext data packets.
[0088] In some embodiments, the data encryption module is specifically used to build a blockchain network in the form of a consortium blockchain based on the Hyperledger Fabric framework. The nodes of the blockchain network include producer nodes and regulatory nodes. Producer nodes correspond to farmers, processing plants and distributors in the agricultural product supply chain, and regulatory nodes correspond to agricultural authorities.
[0089] The hash value of low-sensitivity data, data sensitivity label, encryption key index and access permission metadata are written into the main chain of the blockchain network. The access permission metadata includes the mapping relationship between user roles and encryption keys. The access rules for different roles to access data are defined through blockchain smart contracts.
[0090] High-level sensitive ciphertexts are stored off-chain through the IPFS distributed storage system. IPFS generates a unique Content Identifier (CID) for each high-level sensitive ciphertext, which is used to identify the storage location of the ciphertext in the IPFS network.
[0091] By associating and binding the hash value of low-sensitivity data stored on the blockchain with the CID of medium-to-high-level sensitive ciphertext stored off-chain in IPFS through a blockchain smart contract, a blockchain evidence hash is generated. At the same time, a blockchain smart contract for access control is deployed to obtain the blockchain evidence hash, the IPFS CID, and the smart contract address.
[0092] In some embodiments, the model recognition module is specifically used to obtain metadata corresponding to the hash value of low-sensitivity data from the blockchain network through blockchain evidence hash, pull encrypted data packets of medium- and high-level sensitive data from the IPFS distributed storage system through the IPFS CID, and decrypt the encrypted historical trace data and real-time collected encrypted data for model training by combining the data sensitivity label and encryption key index.
[0093] Using producer nodes in the blockchain network as local nodes for federated learning, each local node trains a sub-model using its own encrypted historical traceability data, and uploads the sub-model parameters to the central node through an encrypted parameter aggregation mechanism to generate a global pollution pattern recognition model.
[0094] The real-time collected encrypted data is homomorphically encrypted and then input into the global contamination pattern recognition model. The global contamination pattern recognition model identifies high-risk contamination patterns based on preset risk rules and outputs a probability distribution of contamination sources that includes time and location dimensions.
[0095] Based on the graph algorithm, the topology of the agricultural product distribution network is analyzed. The risk weight of each distribution node is calculated by combining the probability distribution of pollution sources. A priority recall list of products in high-risk areas is generated. The list includes product batch number, recall priority and corresponding distribution node information.
[0096] In some embodiments, the model identification module is also used to configure the producer nodes in the blockchain network as local nodes for federated learning. Each local node selects a sample set that meets the model training requirements from its own stored encrypted historical traceability data through data sensitivity labels and encryption key indexes. The sample set includes timestamps, GPS coordinates, temperature and humidity sequences, product types and historical pollution event labels.
[0097] Each local node trains a sub-model based on its own sample set. During the training process, the K-means clustering algorithm is used to extract features from the environmental parameters in the sample set to generate high-risk feature clusters. Then, the high-risk feature clusters are associated with historical pollution event labels through a random forest classifier to obtain a sub-model containing feature weights and classification thresholds.
[0098] Each local node uses the Secure Aggregation protocol to encrypt the feature weights and classification thresholds of its own sub-model parameters and uploads them to the federated learning center node. The center node is the regulatory node in the blockchain network and has the authority to decrypt and aggregate parameters.
[0099] The central node decrypts and weights the received encrypted sub-model parameters to generate a global pollution pattern recognition model. This model integrates the feature extraction rules and classification logic of all local nodes and can identify complex pollution patterns across different stages.
[0100] In some embodiments, the model recognition module is also used to determine the credible data after the encrypted data collected in real time is verified by comparing the hash value with the blockchain evidence hash, and to filter out the medium and high level sensitive data to be analyzed by combining the data sensitivity tags.
[0101] For the high-level sensitive data to be analyzed, a partial homomorphic encryption algorithm is used to process the original plaintext data into a ciphertext state, ensuring that the data does not need to be decrypted during the model calculation process;
[0102] The homomorphically encrypted ciphertext data is input into the global contamination pattern recognition model. The input features of the global contamination pattern recognition model include environmental parameters, spatiotemporal features, product attributes, and operation logs.
[0103] The global pollution pattern recognition model calls a preset risk rule base, which contains multi-dimensional risk conditions. The global pollution pattern recognition model uses a random forest classifier to match real-time data with risk rules and calculates the pollution probability of each link.
[0104] Based on the pollution probability calculation results, a pollution source probability distribution containing time and location dimensions is generated, and the pollution source probability distribution is converted into structured data for output.
[0105] In some embodiments, the model recognition module is also used to retrieve agricultural product distribution records from the blockchain network through blockchain evidence hash, and combine logistics GPS coordinates collected by IoT sensors to construct a distribution network topology dataset, which includes node attributes and edge attributes.
[0106] The Graph algorithm is used to convert the distribution network topology dataset into a directed graph model, where vertices are distribution nodes, directed edges represent the flow relationship of products from upstream nodes to downstream nodes, and edge weights are the flow volume of products in the corresponding batch.
[0107] The probability distribution of pollution sources is mapped to each node in the distribution network topology, and the risk weight is calculated by combining the node attributes: Risk weight = probability of pollution at node location × node level coefficient × proportion of historical turnover of node. The node level coefficient is set according to the node depth of the distribution network.
[0108] Based on the risk weight of each distribution node, the nodes are sorted in descending order. Nodes with risk weights not less than a preset threshold are selected as high-risk area nodes. The product batch numbers associated with the high-risk area nodes are extracted, and the recall priority is determined according to the risk weight value.
[0109] By integrating product batch numbers, recall priorities, and corresponding distribution node information from nodes in high-risk areas, a structured priority recall list for products in high-risk areas is generated. This list is then synchronized to regulatory agency nodes and corresponding distribution nodes via blockchain smart contracts.
[0110] This application also discloses a control device.
[0111] Specifically, the control device includes a memory and a processor. The memory stores a computer program that can be loaded and executed by the processor to implement the aforementioned method for tracing agricultural product pollution sources based on blockchain and intelligent analysis.
[0112] This application also discloses a computer-readable storage medium.
[0113] Specifically, the computer-readable storage medium stores a computer program that can be loaded and executed by a processor, such as the aforementioned method for tracing agricultural product pollution sources based on blockchain and intelligent analysis. The computer-readable storage medium includes, for example, various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0114] The above are all preferred embodiments of this application, and are not intended to limit the scope of protection of this application. Therefore, all equivalent changes made in accordance with the structure, shape and principle of this application should be covered within the scope of protection of this application.
Claims
1. A method for tracing agricultural product pollution sources based on blockchain and intelligent analysis, characterized in that, include: Data is collected from each stage through a scanning terminal, and temperature, humidity and rapid detection data collected in real time by IoT sensors are synchronously integrated. The data is encrypted in a graded manner according to its sensitivity. The encrypted ciphertext data includes: ciphertext data packets, data sensitivity tags and corresponding encryption key indexes. A blockchain network is built based on the Hyperledger Fabric consortium blockchain. The blockchain network nodes include producers and regulatory agencies. The PBFT consensus mechanism is adopted. Low-sensitivity data hash values, data sensitivity tags, encryption key indexes and access permission metadata are stored on the chain. High-level sensitive ciphertext is stored off-chain in IPFS. The results are obtained from the blockchain evidence hash, IPFS CID and smart contract address. Based on the blockchain notarization hash and the IPFS CID, an AI model is trained through federated learning to analyze encrypted data to identify pollution patterns and output the probability distribution of pollution sources and a recall list of high-risk products. Upon receiving an access request, the user's role identity is verified through the smart contract address. Based on the role permissions and the data sensitivity tag, the corresponding level decryption key is dynamically matched, and the corresponding decrypted data is displayed. The process of using the blockchain-based notarized hash and the IPFS CID to train an AI model through federated learning, analyzing encrypted data to identify contamination patterns, and outputting the probability distribution of contamination sources and a list of high-risk products for recall includes: Metadata corresponding to the hash value of low-sensitivity data is obtained from the blockchain network through the blockchain evidence hash, and the encrypted data packet of medium-to-high-level sensitive data is pulled from the IPFS distributed storage system through the IPFS CID. Combined with the data sensitivity label and the encryption key index, the encrypted historical traceability data and the encrypted data collected in real time are decrypted to obtain encrypted historical traceability data for model training and encrypted data collected in real time. Using producer nodes in the blockchain network as local nodes for federated learning, each local node trains a sub-model using its own encrypted historical traceability data, and uploads the sub-model parameters to the central node through an encrypted parameter aggregation mechanism to generate a global pollution pattern recognition model. The encrypted data collected in real time is homomorphically encrypted and then input into the global contamination pattern recognition model. The global contamination pattern recognition model identifies high-risk contamination patterns based on preset risk rules and outputs a probability distribution of contamination sources that includes time and location dimensions. Based on the Graph algorithm, the topology of the agricultural product distribution network is analyzed, and the risk weight of each distribution node is calculated in combination with the probability distribution of pollution sources. A priority recall list of products in high-risk areas is generated, which includes product batch number, recall priority and corresponding distribution node information. Specifically, the process involves using producer nodes in the blockchain network as local nodes for federated learning. Each local node trains a sub-model using its own encrypted historical tracing data, and uploads the sub-model parameters to the central node through an encrypted parameter aggregation mechanism to generate a global contamination pattern recognition model, including: The producer nodes in the blockchain network are configured as federated learning local nodes. Each local node uses the data sensitivity label and the encryption key index to select a sample set that meets the model training requirements from the encrypted historical traceability data stored in its own storage. The sample set includes timestamps, GPS coordinates, temperature and humidity sequences, product types and historical pollution event labels. Each local node trains a sub-model based on its own sample set. During the training process, the K-means clustering algorithm is used to extract features from the environmental parameters in the sample set to generate high-risk feature clusters. The high-risk feature clusters are then associated with the historical pollution event labels using a random forest classifier to obtain a sub-model containing feature weights and classification thresholds. Each local node uses the Secure Aggregation protocol to encrypt the feature weights and classification thresholds of its own sub-model parameters and uploads them to the federated learning center node. The center node is a regulatory node in the blockchain network and has the authority to decrypt and aggregate parameters. The central node decrypts and weights the received encrypted sub-model parameters to generate the global pollution pattern recognition model. The global pollution pattern recognition model integrates the feature extraction rules and classification logic of all local nodes and can identify complex pollution patterns across stages. Specifically, the analysis of the agricultural product distribution network topology based on the graph algorithm, combined with the probability distribution of pollution sources to calculate the risk weight of each distribution node, generates a priority recall list for products in high-risk areas. This list includes product batch numbers, recall priorities, and corresponding distribution node information, including: The agricultural product distribution records are retrieved from the blockchain network using the blockchain notarization hash, and combined with the logistics GPS coordinates collected by IoT sensors to construct a distribution network topology dataset, which includes node attributes and edge attributes. The distribution network topology dataset is converted into a directed graph model using the Graph algorithm, where vertices are distribution nodes, directed edges represent the flow relationship of products from upstream nodes to downstream nodes, and edge weights are the product flow volume of the corresponding batch. The probability distribution of pollution sources is mapped to each node of the distribution network topology, and the risk weight is calculated in combination with the node attributes: Risk weight = probability of pollution at node location × node level coefficient × proportion of historical turnover of node, wherein the node level coefficient is set according to the node depth of the distribution network. Based on the risk weight of each distribution node, the nodes are sorted in descending order, and nodes with risk weights not less than a preset threshold are selected as high-risk area nodes. The product batch numbers associated with the high-risk area nodes are extracted, and the recall priority is determined according to the risk weight values. By integrating the product batch numbers of the high-risk area nodes, the recall priority, and the corresponding distribution node information, a structured high-risk area product priority recall list is generated. The list is synchronized to regulatory agency nodes and corresponding distribution nodes through a blockchain smart contract.
2. The method for tracing agricultural product pollution sources based on blockchain and intelligent analysis according to claim 1, characterized in that, The process involves collecting data from each stage via a barcode scanning terminal, synchronously integrating real-time temperature and humidity data from IoT sensors, and encrypting the data according to its sensitivity. The encrypted data includes: The raw data of agricultural products in the planting, processing, logistics and sales stages are collected through QR code scanning terminals. The raw data includes operation logs, timestamps, GPS coordinates and basic product information for each stage. Synchronously integrate the real-time temperature and humidity data and rapid detection data collected by IoT sensors, and bind the sensor data with the original data collected by scanning the code through the product's unique identifier and timestamp to form an associated dataset; Based on data sensitivity, the associated dataset is divided into high-sensitivity data, medium-sensitivity data, and low-sensitivity data. High-sensitivity data includes farmers' bank accounts and processors' cost data, medium-sensitivity data includes output and transportation temperature, and low-sensitivity data includes product name and place of origin. The highly sensitive data is processed by scrambling + XOR + Base64 hybrid encoding and encrypted with the role-specific key K_role derived from the master key Kmaster. The medium sensitive data is encrypted with XOR and then encrypted with the role-specific key K_role. The low sensitive data is encoded with Base64 to generate the hierarchically encrypted ciphertext data packet. The data sensitivity tag and the corresponding encryption key index are added to the ciphertext data packet.
3. The method for tracing agricultural product pollution sources based on blockchain and intelligent analysis according to claim 1, characterized in that, The blockchain network, built on the Hyperledger Fabric consortium blockchain, includes producers and regulatory agencies as its nodes. It employs the PBFT consensus mechanism and stores low-sensitivity data hash values, data sensitivity tags, encryption key indexes, and access permission metadata on-chain. High-level sensitive ciphertext is stored off-chain in IPFS. This results in the blockchain notarization hash, the IPFS CID, and the smart contract address, including: A consortium blockchain network is built based on the Hyperledger Fabric framework. The nodes of the blockchain network include producer nodes and regulatory nodes. The producer nodes correspond to farmers, processing plants and distributors in the agricultural product supply chain, and the regulatory nodes correspond to agricultural authorities. The low-sensitivity data hash value, the data sensitivity tag, the encryption key index, and the access permission metadata are written into the main chain of the blockchain network. The access permission metadata includes the mapping relationship between user roles and encryption keys. The access rules for different roles to access data are defined through blockchain smart contracts. High-level sensitive ciphertexts are stored off-chain through the IPFS distributed storage system. IPFS generates a unique Content Identifier (CID) for each high-level sensitive ciphertext, and the CID is used to identify the storage location of the ciphertext in the IPFS network. The blockchain smart contract associates and binds the hash value of the low-sensitivity data stored on the chain with the CID of the medium-to-high-level sensitive ciphertext stored off-chain in IPFS to generate the blockchain evidence hash. At the same time, the blockchain smart contract for access control is deployed to obtain the blockchain evidence hash, the IPFS CID, and the smart contract address.
4. The method for tracing agricultural product pollution sources based on blockchain and intelligent analysis according to claim 1, characterized in that, The encrypted data collected in real time is homomorphically encrypted and then input into the global contamination pattern recognition model. The global contamination pattern recognition model identifies high-risk contamination patterns based on preset risk rules and outputs a probability distribution of contamination sources including time and location dimensions, including: The encrypted data collected in real time is verified for data integrity by comparing the hash value with the blockchain evidence hash to determine the trusted data. The data sensitivity tags are then used to filter out the medium and high level sensitive data to be analyzed. For the high-level sensitive data to be analyzed, a partial homomorphic encryption algorithm is used to process the original plaintext data into a ciphertext state, ensuring that the data does not need to be decrypted during the model calculation process; The homomorphically encrypted ciphertext data is input into the global contamination pattern recognition model. The input features of the global contamination pattern recognition model include environmental parameters, spatiotemporal features, product attributes, and operation logs. The global pollution pattern recognition model calls a preset risk rule base, which contains multi-dimensional risk conditions. The global pollution pattern recognition model uses a random forest classifier to match real-time data with risk rules and calculate the pollution probability of each stage. Based on the pollution probability calculation results, a pollution source probability distribution containing time and location dimensions is generated, and the pollution source probability distribution is converted into structured data for output.
5. A device for tracing agricultural product pollution sources based on blockchain and intelligent analysis, characterized in that, The apparatus for performing the method as claimed in claim 1 includes: The data acquisition module is used to collect data from each stage through a barcode scanning terminal, synchronously integrate temperature and humidity and rapid detection data collected in real time by IoT sensors, and encrypt the data according to the sensitivity level. The encrypted data includes: encrypted data packets, data sensitivity tags and corresponding encryption key indexes. The data encryption module is used to build a blockchain network based on the Hyperledger Fabric consortium chain. The blockchain network nodes include producers and regulatory agencies. It adopts the PBFT consensus mechanism and stores low-sensitivity data hash values, data sensitivity tags, encryption key indexes and access permission metadata on the chain. High-level sensitive ciphertext is stored off-chain in IPFS to obtain blockchain evidence hash, IPFS CID and smart contract address. The model identification module is used to train an AI model through federated learning based on the blockchain notarization hash and the IPFS CID, analyze encrypted data to identify pollution patterns, and output the probability distribution of pollution sources and a recall list of high-risk products. The dynamic decryption module is used to verify the user's role identity through the smart contract address when an access request is received, dynamically match the corresponding level decryption key according to the role permissions and the data sensitivity tag, and display the corresponding decrypted data.
6. A control device, characterized in that, The device includes: It includes a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and executed as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer program is stored that can be loaded by a processor and executed as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Blockchain-based transverse federated learning model construction method
CN113194126A
Safe and extensible federal learning method based on block chain
CN115018083A