Food safety supervision method and system based on artificial intelligence and blockchain
Through food safety supervision methods based on artificial intelligence and blockchain, the problems of information silos in the food industry chain and inefficient traditional supervision have been solved, traceability and intelligent supervision of the entire life cycle of food have been achieved, supervision efficiency and accuracy have been improved, and the transparency and credibility of the food supply chain have been enhanced.
Patent Information
- Application Number
- CN202411262983.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2044-09-10
AI Technical Summary
The modern food industry chain is complex and has serious information silos. Traditional regulatory methods cannot achieve full industry chain coverage and effective control. Manual supervision is inefficient and it is difficult to detect food safety hazards in a timely manner.
A food safety supervision method based on artificial intelligence and blockchain is adopted. Through the regional food alliance chain and heterogeneous information analysis module, traceability and intelligent supervision of the entire life cycle of food are achieved. Public-private key pairs and digital signature technology are used to ensure data authenticity and non-repudiation, identify abnormal food circulation information, and report it to the regional supervision platform in a timely manner through a multi-level linkage mechanism.
It has improved the efficiency and accuracy of food safety supervision, enhanced the transparency and credibility of the food supply chain, achieved rapid response and handling of food safety issues, and built a safer and more reliable food safety assurance system.
Smart Images

Figure CN119204801B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of food safety management, and specifically relates to a food safety supervision method and system based on artificial intelligence and blockchain. Background Art
[0002] The modern food industry chain is long, complex, and involves numerous stakeholders, including production, processing, storage, transportation, and sales. Each link presents potential food safety risks. Furthermore, participants in different links often utilize independent information systems, resulting in severe information silos and hindering data sharing and circulation. Given this complex industry structure and information fragmentation, traditional regulatory approaches appear insufficient. Regulatory agencies often employ a decentralized and fragmented regulatory model, each responsible for specific links or regions. While this approach meets the needs of localized supervision to a certain extent, it struggles to achieve comprehensive coverage and effective control of the entire industry chain. The coexistence of regulatory blind spots and duplication of supervision not only wastes resources but also fails to effectively prevent systemic risks.
[0003] On the other hand, traditional manual oversight methods struggle to cope with the massive volume of food safety data. The massive amount of production records, test reports, logistics information, and other data generated daily far exceeds the capacity of manual processing. This not only leads to inefficient oversight, but also makes it difficult to detect many potential safety issues in a timely manner. Even if anomalies are discovered, traditional oversight systems often struggle to quickly and effectively trace them to the source. Determining the source, scope, and responsible parties often requires significant time and effort. This not only delays problem resolution but also poses significant risks to consumer health. Summary of the Invention
[0004] The present invention provides a food safety supervision method and system based on artificial intelligence and blockchain to solve the above technical problems.
[0005] In a first aspect, the present invention provides a food safety supervision method based on artificial intelligence and blockchain, which is applied to a target area where a regional supervision platform is deployed, wherein the target area includes multiple target areas, each of which is deployed with a regional supervision platform, and all of the regional supervision platforms are in communication with the regional supervision platform. The regional supervision platform is configured with a regional user registration center, a regional platform server, and a heterogeneous information analysis module. In each of the target areas, a regional food alliance chain is created based on the regional platform server and in combination with the regional user registration center, and the regional platform server in each of the target areas has the highest management authority over the regional food alliance chain in the same target area.
[0006] The method comprises the following steps:
[0007] For each target area, the regional user registration center obtains the account registration application of the user client in the target area, and the regional platform server verifies the account registration application using the consensus mechanism preset in the regional food alliance chain. The user client is a user terminal held by a food producer, food processor, food storage, food transporter, food seller, or food buyer;
[0008] Creating a user node account of the regional food alliance chain for the target user client whose account registration application has passed the verification, generating an account key pair for the user node account, and storing the account public key in the account key pair in the public key database preset by the user registration center;
[0009] The food circulation information uploaded by the user node account is uploaded to the regional food alliance chain through the regional platform server, wherein the food circulation information includes the user signature of the user node account, and the user signature is generated based on the account private key in the account key;
[0010] Extracting the account public keys of all the user node accounts from the public key database through the heterogeneous information analysis module, and using all the account public keys to query the regional food alliance chain to obtain all the food circulation information;
[0011] Based on all the user node accounts and using the heterogeneous information analysis module to analyze the heterogeneous information features in all the food circulation information, and identifying abnormal food circulation information in the food circulation information according to the heterogeneous information features;
[0012] When the heterogeneous information analysis module identifies the abnormal food circulation information, the abnormal food circulation information and the basic user information of all abnormal user clients associated with the abnormal food circulation information are uploaded to the regional supervision platform through the regional platform server.
[0013] Optionally, after the target user client that has passed the account registration application verification creates a user node account for the regional food alliance chain, the following steps are further included:
[0014] Identify the account type of the user node account based on the basic user information in the account registration application;
[0015] Allocating account permissions for the user node account based on the account type;
[0016] Adding the user node account after the authority is assigned to the network node topology of the regional food alliance chain;
[0017] The consensus mechanism is used to configure the consensus parameters of the user node account, and all blockchain public data of the regional food alliance chain are synchronized to the user node account through the consensus parameters.
[0018] Optionally, the step of uploading the food circulation information uploaded by the user node account to the regional food alliance chain through the regional platform server includes the following steps:
[0019] When any one or more target user node accounts upload the initial food circulation information to the regional food alliance chain, the alliance chain smart contract preset in the regional food alliance chain is triggered. After the alliance chain smart contract is triggered, the following steps are performed:
[0020] Verify the account permissions and the consensus parameters of the target user node account based on the consortium chain smart contract and using the regional platform server;
[0021] If the account permissions and consensus parameters of the target user node account are verified, the sensitive information in the initial food circulation information is encrypted using an asymmetric encryption algorithm based on the account private key in the account key pair of the target user node account to obtain encrypted food circulation information;
[0022] Converting the encrypted food circulation information into food circulation hash data through the alliance chain smart contract;
[0023] Using the regional platform server as the initial broadcast node, and utilizing the Byzantine fault-tolerant consensus mechanism preset in the regional food alliance chain, broadcast the food circulation hash data and the encrypted food circulation information to all other user node accounts except the target user node account;
[0024] Receiving, through the regional platform server, verification feedback results of all the other user node accounts in response to the Byzantine fault-tolerant consensus mechanism, and determining whether the target user node account has passed the alliance chain consensus verification based on the verification feedback results;
[0025] If the target user node account passes the alliance chain consensus verification, the food circulation hash data and the encrypted food circulation information of the target user node account are uploaded to the regional food alliance chain using the regional platform server.
[0026] Optionally, the initial food circulation information includes any one or more of food production information, food processing information, food storage information, food transportation information, food sales information and food purchase information.
[0027] Optionally, analyzing heterogeneous information features in all the food circulation information based on all the user node accounts and using the heterogeneous information analysis module, and identifying abnormal food circulation information in the food circulation information according to the heterogeneous information features includes the following steps:
[0028] All the user node accounts are used as account graph nodes, and an initial food flow heterogeneous graph is constructed based on all the account graph nodes and using the heterogeneous information analysis module;
[0029] generating heterogeneous node edges between all the account graph nodes in the initial food circulation heterogeneous graph according to all the food circulation information, thereby obtaining a food circulation heterogeneous graph, wherein different types of heterogeneous node edges represent different types of food circulation information;
[0030] Extracting high-order heterogeneous information features from the food flow heterogeneous graph using the heterogeneous information analysis module;
[0031] Retrieving an abnormal food circulation feature set from the regional supervision platform through the regional platform server, and transmitting the abnormal food circulation feature set to the heterogeneous information analysis module;
[0032] Based on the abnormal food circulation feature set and using the heterogeneous information analysis module, abnormal correlation features in the high-order heterogeneous information features are identified, and the abnormal food circulation features in all the food circulation information are determined according to the abnormal correlation features.
[0033] Optionally, the extracting high-order heterogeneous information features from the food flow heterogeneous graph by using the heterogeneous information analysis module includes the following steps:
[0034] Selecting a plurality of account graph node pairs from the food flow heterogeneous graph using the heterogeneous information analysis module, wherein each account graph node must belong to at least one account graph node pair, and the node types of two account graph nodes in the account graph node pair are different;
[0035] Mapping all the account graph node pairs to a preset high-dimensional feature space through the heterogeneous information analysis module;
[0036] In the high-dimensional feature space, based on a double-layer heterogeneous attention mechanism and through the heterogeneous information analysis module, node pair association features of each of the account graph node pairs are extracted, wherein the node pair association features include graph node features of the two account graph nodes in the account graph node pair and node edge features of the heterogeneous node edge between the two account graph nodes;
[0037] For each of the account graph node pairs, any one of the account graph nodes in the account graph node pair is used as the central graph node, and the node pair association features corresponding to the N-order neighbor graph nodes of the central graph node are aggregated into N-order neighbor graph node aggregate features, where N is less than or equal to the number of types of heterogeneous node edges;
[0038] The heterogeneous information analysis module is utilized to extract all the N-order neighbor graph node aggregation features from the high-dimensional feature space as high-order heterogeneous information features.
[0039] Optionally, the step of identifying abnormal correlation features in the high-order heterogeneous information features based on the abnormal food circulation feature set and using the heterogeneous information analysis module, and determining abnormal food circulation features in all the food circulation information according to the abnormal correlation features includes the following steps:
[0040] The abnormal food circulation feature set is input into a preset abnormal circulation feature recognition model using the heterogeneous information analysis module, and all data in the abnormal food circulation feature set have abnormal feature labeling information;
[0041] Completing the model training process of the abnormal food circulation feature recognition model through the abnormal food circulation feature set;
[0042] Using the heterogeneous information analysis module to input the high-order heterogeneous information features into the trained abnormal flow feature recognition model, the abnormal flow feature recognition model identifies and outputs abnormal correlation features in the high-order heterogeneous information features;
[0043] Based on the abnormal correlation features, the abnormal food circulation features in all the food circulation information are determined through the heterogeneous information analysis module.
[0044] Optionally, when the heterogeneous information analysis module identifies the abnormal food circulation information, uploading the abnormal food circulation information and basic user information of all abnormal user clients associated with the abnormal food circulation information to the regional supervision platform through the regional platform server includes the following steps:
[0045] Within any preset supervision time period, when the heterogeneous information analysis module of the regional supervision platform in one and only one target area identifies the abnormal food circulation information, the abnormal food circulation information and the user basic information of all abnormal user clients associated with the abnormal food circulation information are uploaded to the regional supervision platform through the regional platform server.
[0046] Optionally, the method further comprises the following steps:
[0047] During any one of the supervision time periods, when the heterogeneous information analysis modules of the regional supervision platforms in multiple target areas simultaneously identify the abnormal food circulation information, the abnormal food circulation information and the basic user information of all abnormal user clients associated with the abnormal food circulation information are uploaded to the regional supervision platform through the abnormal regional platform servers that each identify the abnormal food circulation information;
[0048] Randomly select a target regional supervision platform from the multiple regional supervision platforms that have not identified the abnormal food circulation information within the current supervision time period;
[0049] Sending all the abnormal food circulation information to the target area supervision platform through the abnormal area platform server;
[0050] The target area platform server of the target area supervision platform is used to identify the cross-regional association information between all the abnormal food circulation information, and upload the cross-regional association information to the regional supervision platform.
[0051] In a second aspect, the present invention also provides a food safety supervision system based on artificial intelligence and blockchain, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the food safety supervision method based on artificial intelligence and blockchain as described in the first aspect is implemented.
[0052] The beneficial effects of the present invention are:
[0053] The present invention achieves traceability of the entire life cycle of food through a regional food alliance chain, fundamentally solving the problems of information opacity and difficulty in traceability in traditional supervision. The present invention adopts a strict user registration and identity verification mechanism to ensure the authenticity and credibility of the participants and effectively prevent the input of false information. By using public-private key pairs and digital signature technology, it not only protects the privacy of users but also ensures the authenticity and non-repudiation of data. The present invention uses a heterogeneous information analysis module to perform intelligent analysis of massive amounts of food circulation information, which can quickly identify abnormal information and greatly improve the efficiency and accuracy of supervision. This automated anomaly detection mechanism enables regulatory authorities to promptly identify potential food safety risks and take preventive measures. By reporting abnormal information to the regional supervision platform in a timely manner, a multi-level linkage supervision system is realized, which is conducive to the rapid response and handling of food safety issues. In summary, the present invention not only improves the efficiency and accuracy of food safety supervision, but also enhances the transparency and credibility of the entire food supply chain, providing strong technical support for building a safer and more reliable food safety assurance system. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 This is a system topology diagram between the regional regulatory platform and the zone regulatory platform in one embodiment of the present application.
[0055] Figure 2 This is a flowchart of a food safety supervision method based on artificial intelligence and blockchain in one embodiment of the present application. DETAILED DESCRIPTION
[0056] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field are within the scope of protection of this application.
[0057] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.
[0058] Reference Figure 1 The food safety supervision method based on artificial intelligence and blockchain disclosed in the present invention constructs a multi-level, distributed supervision system, aiming to achieve comprehensive, accurate and efficient supervision of food safety. The application scenario of this method is a target area where a regional supervision platform is deployed. This target area can be understood as a larger administrative area. In order to achieve more refined and localized management, the target area is divided into multiple target areas. In each target area, a regional supervision platform is deployed. These regional supervision platforms are the basic units of the entire supervision system, responsible for directly interacting with the main bodies of each link in the food industry chain within the jurisdiction. All regional supervision platforms maintain communication connections with the superior regional supervision platforms, forming a vertically connected information transmission channel. This design ensures that supervision information can be quickly transmitted from the bottom up, and can also be effectively issued from the top down, realizing a multi-level linkage supervision model.
[0059] The core components of each regional regulatory platform include three key components: a regional user registration center, a regional platform server, and a heterogeneous information analysis module. The regional user registration center manages the identity information of all participants in the food industry chain within its jurisdiction, ensuring the authenticity and trustworthiness of each participant. The regional platform server serves as the hub of the entire regional regulatory platform, coordinating the work of various modules and managing the regional food alliance chain. The heterogeneous information analysis module utilizes artificial intelligence technology to intelligently analyze the massive amounts of data on the chain, identifying potential risks and anomalies. In each target region, a regional food alliance chain is established based on the regional platform server and integrated with the regional user registration center. Only verified users can join this alliance chain, ensuring the credibility of the chain information. The regional food alliance chain records information on the entire food production and distribution process within the region, providing a reliable data foundation for food safety supervision.
[0060] The regional platform server in each target region is granted supreme management authority over that region's food alliance chain. This means the regional platform server can deploy and manage smart contracts on the chain, set and adjust chain operating parameters, and perform emergency intervention when necessary. This design not only ensures effective regulatory control over the chain, but also, through the decentralized nature of blockchain technology, ensures data immutability and traceability. This multi-level, distributed regulatory architecture not only adapts to the specific circumstances of different regions, enabling flexible localized management, but also, through a layered information transmission mechanism, builds a comprehensive and responsive food safety regulatory network.
[0061] Reference Figure 2 , Figure 2 FIG1 is a flow chart of a food safety supervision method based on artificial intelligence and blockchain in one embodiment. It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2 At least part of the steps in the above process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but may be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but may be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps. Figure 2 As shown, the food safety supervision method based on artificial intelligence and blockchain disclosed in the present invention specifically includes the following steps:
[0062] S101. For each target area, obtain the account registration application of the user client in the target area through the regional user registration center, and verify the account registration application through the regional platform server using the consensus mechanism preset in the regional food alliance chain.
[0063] Among them, the user client is the user terminal held by the food producer, food processor, food storage, food transporter, food seller or food buyer. This step first receives and processes the account registration applications of various food-related entities in the target area through the regional user registration center. These entities submit registration applications through their respective user terminals (such as smartphones, tablets or personal computers). The registration application usually contains the user's basic information, business license number (for corporate users) or ID number (for individual users), contact information, etc. The regional user registration center will first perform a preliminary format and integrity verification on this information.
[0064] The regional platform server then invokes the pre-set consensus mechanism within the regional food alliance chain to further verify these account registration applications. This consensus mechanism can employ a modified Proof of Stake algorithm, which considers not only the applicant's identity information but also factors such as their role in the food industry chain and their credit history. For example, for a food producer's registration application, the consensus mechanism requires existing nodes on the chain (such as regulatory authorities or other verified producer nodes) to vote on the application for confirmation. Only when the voting results reach a preset threshold is the application considered verified. This rigorous verification mechanism effectively guarantees the authenticity and credibility of every user entering the system. It not only prevents malicious users from registering but also lays a solid foundation for subsequent food traceability and regulation.
[0065] S102. Create a user node account of the regional food alliance chain for the target user client whose account registration application has passed the verification, generate an account key pair for the user node account, and store the account public key in the account key pair in the public key database preset by the user registration center.
[0066] Among them, after the account registration application is verified, the system will generate a unique public-private key pair for the user. This key pair is usually generated using the elliptic curve encryption algorithm, which can provide high security and has a relatively short key length, making it suitable for use in blockchain systems. In the generated key pair, the private key will be securely stored in the user's client device, while the public key will be stored in the public key database preset by the user registration center. The public key database may be stored in a high-availability distributed database system to ensure data reliability and fast access. The generated user node account will contain multiple pieces of information, such as account address (usually derived from the public key), basic user information, account creation time, etc. This information will be written into the regional food alliance chain in the form of a transaction, becoming the user's identity on the chain.
[0067] This step establishes a unique, secure on-chain identity for each verified user. The use of public-private key pairs ensures the uniqueness and unforgeability of user identities while also providing a foundation for subsequent digital signatures and encrypted communications. Storing public keys in a centralized database facilitates subsequent authentication and data queries while protecting user privacy.
[0068] S103. The food circulation information uploaded by the user node account is uploaded to the regional food alliance chain through the regional platform server.
[0069] Food flow information includes the user signature of the user's node account, which is generated based on the account's private key in the account key. The user prepares food flow information on the client. This information may include detailed data such as the food's production date, batch number, raw material source, processing technology, storage conditions, transportation route, and sales location. To ensure the authenticity and non-repudiation of the data, the user needs to digitally sign this information using their account's private key. The signing process typically uses the ECDSA algorithm, which follows the following steps: calculating the hash value of the data to be signed (such as using the SHA-256 algorithm); signing the hash value with the private key to generate an (r, s) signature pair; and packaging the original data, the signature result, and the user's public key together.
[0070] Next, the user client sends the packaged data to the regional platform server via a secure communication channel (such as HTTPS). Upon receiving the data, the server first verifies the validity of the digital signature to ensure that the data has not been tampered with and indeed comes from the claimed user. It then checks the legitimacy of the data format and content. The verified data is encapsulated as a blockchain transaction and broadcast to the regional food alliance chain network. Upon receiving the transaction, the nodes of the regional food alliance chain further verify its validity before packaging it into a block. Once the new block is successfully mined and reaches network consensus, the food transaction information is officially uploaded to the blockchain, becoming a permanent and immutable record.
[0071] S104. The account public keys of all user node accounts are extracted from the public key database through the heterogeneous information analysis module, and all account public keys are used to query all food circulation information in the regional food alliance chain.
[0072] The heterogeneous information analysis module initiates a query request to the public key database to obtain the public key information of all registered users. This query process may use batch or paginated query methods to cope with the potentially large amount of data. After obtaining the public key information, the heterogeneous information analysis module traverses these public keys and queries each public key on the regional food alliance chain. This query process may involve complex blockchain data retrieval algorithms. Because the blockchain is a continuously growing data structure, the following strategies may be adopted to improve query efficiency:
[0073] Use index: Maintain an address-transaction index on the blockchain node to quickly locate all transactions related to a specific address.
[0074] Parallel query: Assign query tasks to multiple nodes to perform them simultaneously to improve processing speed.
[0075] Cache mechanism: caches frequently used query results to reduce repeated calculations.
[0076] Finally, the heterogeneous information analysis module performs preliminary processing and organization of the retrieved food circulation information in preparation for subsequent analysis. This includes standardizing the data format, sorting the time series, and checking data integrity. This step results in the construction of a comprehensive food circulation information dataset. Public key association ensures data authenticity and integrity. This dataset encompasses all on-chain information for all registered users, providing a comprehensive and reliable foundation for subsequent heterogeneous information analysis. Furthermore, this public key-based query method protects user privacy, as only users with the matching private key can prove ownership of a piece of information.
[0077] S105. Based on all user node accounts and using the heterogeneous information analysis module, analyze the heterogeneous information features in all food circulation information, and identify abnormal food circulation information in the food circulation information based on the heterogeneous information features.
[0078] The heterogeneous information analysis module preprocesses the collected food circulation information. This includes data cleaning (removing noise and outliers), data standardization (unifying data formats from different sources), and feature extraction (extracting meaningful features from the raw data). Next, the heterogeneous information analysis module uses a variety of algorithms to analyze the processed data to identify heterogeneous information features. These algorithms may include:
[0079] Time series analysis: Detecting time anomalies in the food circulation process, such as excessive storage time and unreasonable transportation time.
[0080] Cluster analysis: Cluster similar food flow information and identify abnormal samples that are significantly different from the main group.
[0081] Association rule mining: Discover the associations between various links in the food circulation process and identify abnormal associations that do not conform to normal patterns.
[0082] Anomaly detection algorithms, such as Isolation Forest or Local Outlier Factor, are used to identify data points that exhibit anomalies across multiple dimensions.
[0083] The result of this step is the ability to accurately identify potential anomalies within the vast amount of food flow information. This data-driven anomaly detection approach not only uncovers obvious violations but also identifies subtle anomalies that might be overlooked by manual oversight. This significantly improves the efficiency and accuracy of food safety oversight, providing strong support for the timely detection and prevention of food safety issues.
[0084] S106. When the heterogeneous information analysis module identifies abnormal food circulation information, the abnormal food circulation information and the basic user information of all abnormal user clients associated with the abnormal food circulation information are uploaded to the regional supervision platform through the regional platform server.
[0085] Among them, first of all, the regional platform server needs to integrate abnormal food circulation information and the basic information of related users. Abnormal food circulation information includes specific data items marked as abnormal, such as abnormal production date, unreasonable transportation time, storage temperature outside the normal range, etc. User basic information may include the user's registered name, business license number (for corporate users), contact information, etc. This information needs to be extracted and combined from the database of the regional food alliance chain and the user registration center. Next, the regional platform server needs to ensure the secure transmission of this sensitive information. The following security measures are usually adopted:
[0086] Data encryption: Encrypt data using a strong encryption algorithm such as AES-256.
[0087] Secure communication protocol: Use HTTPS or the more secure TLS1.3 protocol for data transmission.
[0088] Digital Signature: Digitally sign the uploaded data package to ensure the integrity and source verifiability of the data.
[0089] Access control: Use two-factor authentication and other methods to ensure that only authorized regional regulatory platforms can receive this information.
[0090] Upon receiving this information, the regional regulatory platform will immediately initiate the appropriate processing procedures. This may include further risk assessments, on-site inspection arrangements, and communication with relevant parties. At the same time, the regional regulatory platform may send a receipt confirmation to the regional platform server to ensure that the information is correctly conveyed. The implementation of this step has the effect of establishing a fast, secure, and effective abnormal situation reporting mechanism. It enables potential food safety risks to be promptly known and handled by higher-level regulatory authorities, greatly improving the response speed and efficiency of the entire food safety regulatory system. At the same time, through strict data security and privacy protection measures, the security of information during transmission and processing is also ensured, balancing the needs of public safety and personal privacy.
[0091] In one embodiment, after creating a user node account of the regional food alliance chain for the target user client whose account registration application has been verified, the following steps are also included:
[0092] Identify the account type of the user's node account based on the basic user information in the account registration application;
[0093] Assign account permissions to user node accounts based on account type;
[0094] Add the user node account with assigned permissions to the network node topology of the regional food alliance chain;
[0095] The consensus mechanism is used to configure the consensus parameters of the user node account, and all blockchain public data of the regional food alliance chain is synchronized to the user node account through the consensus parameters.
[0096] In this embodiment, the user node account type is first identified based on the basic user information in the account registration application. This step involves in-depth analysis and classification of the user-provided information. The specific implementation principle is to use a preset classification algorithm to conduct a multi-dimensional analysis of user-provided information, such as company type, business scope, and registered capital. For example, a decision tree algorithm can be used to make branching decisions based on different information features. For example, if a food production company applies for registration, the system will first check the business license information provided to confirm whether it falls into the food production category. Then, based on information such as annual output value and number of employees, it will further determine whether the company is large, medium, or small. It also considers whether the company holds relevant food production licenses and its past food safety record. This information is input into a preset decision model, ultimately determining the account type, such as large food production company, small or medium-sized food distributor, or individual food operator. The implementation of this step can accurately classify users, laying the foundation for subsequent permission allocation. Through this precise classification, we can ensure that each user can obtain appropriate permissions that are consistent with their identity and business, so that normal business will not be affected by insufficient permissions, nor will security risks be brought about by excessive permissions.
[0097] Next, user node accounts are assigned account permissions based on their account type. This step is implemented using a role-based access control (RBAC) model. This model first defines a set of food safety-related operational permissions, such as uploading production records, viewing supply chain information, and initiating food recalls. Then, a series of roles are pre-defined based on different account types, each with a specific set of permissions. For example, a large food manufacturer might be assigned the producer role, which includes permissions such as uploading production records, viewing its own supply chain information, and initiating product recalls. A food regulatory agency might be assigned the regulator role, which grants higher-level permissions such as viewing all company information, initiating inspections, and handling complaints. This step creates a precise permission configuration for each user account, ensuring that users can only access and operate functions and data appropriate to their role. This not only improves system security but also simplifies permission management, enabling efficient and flexible permission control even with a large number of users.
[0098] The third step is to add the user node account, after assigning permissions, to the regional food alliance chain's network node topology. The implementation principles of this step involve node management and topology updates in the distributed network. First, the system generates a unique node identifier for the new user node, typically an address generated using a public key cryptography algorithm. Then, the system broadcasts the new node's information to the entire network. This process utilizes a gossip-based information dissemination mechanism. Upon receiving the new node's information, each existing node randomly selects a subset of its connected nodes and forwards the information. This process repeats until the entire network is aware of the new node. Simultaneously, the new node receives information from other nodes in the network, establishing its own view of the network. Over time, the number of nodes aware of the new node's information grows exponentially, quickly reaching full network coverage. During this process, the system also considers load balancing, ensuring that new nodes are distributed across different parts of the network to avoid localized congestion. This is achieved using an algorithm called consistent hashing, which minimizes the need for data migration when nodes join or leave. The effect of this step is to seamlessly integrate new user nodes into the existing network structure, enabling them to participate in various blockchain network operations such as data synchronization and transaction verification. At the same time, through optimized node distribution, the stability and performance of the entire network can be improved.
[0099] The final step is to use the consensus mechanism to configure the consensus parameters of the user's node account and synchronize all public blockchain data of the regional food alliance chain to the user's node account through the consensus parameters. The implementation principle of this step involves the core mechanisms of the blockchain: consensus algorithm and data synchronization. First, the system needs to configure the consensus parameters for the newly added node. In scenarios such as food safety that require a high degree of trust, variants of the consensus algorithm based on Proof of Stake (PoS) are usually adopted, such as Delegated Proof of Stake (DPoS). Under this mechanism, the voting weight of a node is proportional to its equity in the network (which may be based on its market share, credit rating, etc.). Specifically, the system will assign an initial equity value to the node based on its account type and other relevant information. This equity value determines the weight of the node in participating in the consensus process and can be expressed by the following formula:
[0100]
[0101] Among them, Wi is the voting weight of node i, Si is the stake value of node i, Sj is the stake value of the jth node, and N is the total number of nodes participating in the consensus.
[0102] After configuring consensus parameters, the new node can begin syncing blockchain data. This process typically uses a segmented download method, with the new node simultaneously requesting different segments of block data from multiple existing nodes to speed up synchronization. The new node verifies each received block, including checking the block's hash value and verifying transaction signatures. This process can be described by the following steps: the new node broadcasts a data synchronization request to the network; the nodes receiving the request return their current block header information; the new node compares this information and selects the longest valid chain; the new node begins downloading block data from multiple nodes in parallel; each downloaded block is verified; and if verification passes, the block is added to the local chain.
[0103] During this process, the new node also establishes its own set of UTXOs (unspent transaction outputs), which is crucial for quickly verifying new transactions. This step ensures that the new node has complete and up-to-date blockchain data, enabling immediate participation in network operations. Furthermore, through properly configured consensus parameters, the new node can participate appropriately in the consensus process based on its actual status and contributions, while ensuring network security.
[0104] In one embodiment, uploading food circulation information uploaded by a user node account to the regional food alliance chain through a regional platform server includes the following steps:
[0105] When any one or more target user node accounts upload the initial food circulation information to the regional food alliance chain, the alliance chain smart contract preset in the regional food alliance chain is triggered. After the alliance chain smart contract is triggered, the following steps are executed:
[0106] Based on the consortium chain smart contract and using the regional platform server to verify the account permissions and consensus parameters of the target user node account;
[0107] If the account permissions and consensus parameters of the target user node account are verified, the sensitive information in the initial food circulation information is encrypted using an asymmetric encryption algorithm based on the account private key in the target user node account's account key pair to obtain encrypted food circulation information;
[0108] Convert encrypted food circulation information into food circulation hash data through alliance chain smart contracts;
[0109] Use the regional platform server as the initial broadcast node and utilize the Byzantine fault-tolerant consensus mechanism preset in the regional food alliance chain to broadcast food flow hash data and encrypted food flow information to all other user node accounts except the target user node account;
[0110] Receive verification feedback results from all other user node accounts in response to the Byzantine Fault Tolerance consensus mechanism through the regional platform server, and determine whether the target user node account has passed the alliance chain consensus verification based on the verification feedback results;
[0111] If the target user node account passes the alliance chain consensus verification, the regional platform server will be used to upload the target user node account's food circulation hash data and encrypted food circulation information to the regional food alliance chain.
[0112] In this embodiment, the initial food flow information includes any one or more of food production, processing, storage, transportation, sales, and purchase information. When any one or more target user node accounts upload this initial food flow information to the regional food alliance chain, a pre-set alliance chain smart contract is triggered. This smart contract is a pre-written, self-executing program code that defines actions to be performed under specific conditions. In this embodiment, the act of uploading the initial food flow information serves as the triggering condition. The smart contract is triggered automatically, requiring no human intervention. Once new food flow information is detected, the smart contract is immediately activated. The use of smart contracts ensures the automation and standardization of the entire process, significantly improving efficiency while reducing the possibility of human error and intervention. Furthermore, since the smart contract code is public, it can be reviewed by all participants, increasing the transparency and credibility of the entire process.
[0113] Based on the consortium chain smart contract and utilizing the regional platform server, the target user node account's account permissions and consensus parameters are verified. This step works as follows: First, the smart contract checks the digital signature of the user node account that uploaded the information to confirm that the operation was indeed initiated by that account. This process uses an asymmetric encryption algorithm, with the user's public key used to verify the authenticity of the digital signature. Next, the smart contract queries the account's permission information stored on the blockchain. This permission information typically includes the account type (such as manufacturer, distributor, regulator, etc.) and a list of specific operational permissions. For example, only accounts with food manufacturer permissions can upload new food production information. Permission verification is implemented using access control lists (ACLs). Each operation has a corresponding permission requirement, and the system checks whether the user's permissions meet the requirements. Simultaneously, the user's consensus parameters must be verified, which typically include metrics such as the user's credit score and participation in the network. A weighted average method is used to calculate the user's consensus parameter score. Only when the consensus parameter score exceeds a preset threshold is the consensus parameter verification considered passed. This verification process is performed by the regional platform server, which has greater computing power and more comprehensive data access. The verification results are recorded on the blockchain and serve as the basis for subsequent operations. This step effectively prevents unauthorized users from uploading information or performing operations beyond their authority, while also ensuring that the nodes participating in the consensus are trustworthy, thus maintaining the security and reliability of the entire system.
[0114] If the target user node account's account permissions and consensus parameters are verified, the initial food flow information will be encrypted. Specifically, the system will first divide the initial food flow information into two parts: sensitive information and non-sensitive information. Sensitive information may include specific formulas, supplier details, and other commercial secrets, while non-sensitive information may include public information such as product names and production dates. For sensitive information, the system will use the target user node account's account private key to encrypt it. Asymmetric encryption algorithms such as RSA or elliptic curve cryptography (ECC) are used here. The result of the entire encryption process is encrypted food flow information, which consists of two parts: sensitive information encrypted with the private key and unencrypted non-sensitive information.
[0115] Next, the encrypted food flow information is converted into food flow hash data through the alliance chain smart contract. A hash function is an algorithm that converts input data of arbitrary length into a fixed-length output. It has characteristics such as one-way and collision resistance, making it very suitable for data integrity verification and fast retrieval. In this step, the smart contract calls a predefined hash function, such as SHA-256 or Keccak-256, to process the encrypted food flow information. The generated hash value is usually a string of fixed length (such as 256 bits), which can uniquely identify this encrypted food flow information. The characteristic of the hash value is that even if the original data has a slight change, the generated hash value will be completely different. This makes it very suitable for verifying the integrity and consistency of data.
[0116] The primary purposes of converting encrypted information into hashed data are as follows: First, it significantly reduces the amount of data required to be stored on the blockchain, as the hash value is fixed in length regardless of the original data size. Second, it provides a quick way to verify data integrity; other nodes in the network can verify that the data they receive is consistent with the original data by comparing the hash value. Finally, it adds an additional layer of privacy, as it is virtually impossible to deduce the original data from the hash value. This step results in the generation of a compact, unique, and irreversible data fingerprint that can be used for subsequent data verification and tracking without revealing the original data content. This hash value plays a key role in the subsequent consensus process, enabling other nodes in the network to efficiently verify the data without having to access or decrypt the original encrypted information.
[0117] Next, the regional platform server is used as the initial broadcast node, and the Byzantine fault-tolerant consensus mechanism preset in the regional food alliance chain is used to broadcast the food circulation hash data and encrypted food circulation information to all other user node accounts other than the target user node account. The Byzantine Fault Tolerance (BFT) consensus mechanism is designed to solve how to reach consensus in the presence of malicious nodes. Its core idea is that even if some nodes in the system fail or behave maliciously, the entire system can still operate normally and reach consensus. In this embodiment, the regional platform server will first package the food circulation hash data and encrypted food circulation information into a message. The structure of this message is as follows:
[0118] "type":"food_transfer",
[0119] "hash":"8a1c7557f7fceadae6fe2f2eb6f80b8cdeea14b6fd7ec8e630da8fd24986e3c9",
[0120] "encrypted_data":"base64_encoded_encrypted_data_here",
[0121] "timestamp":1630450000,
[0122] "sender":"node_id_of_original_uploader"
[0123] The regional platform server then broadcasts this message to other nodes in the network. During the BFT consensus process, each node performs preliminary verification upon receiving the message and then sends a prepare message to other nodes. Once a node receives prepare messages from more than two-thirds of the nodes, it sends a commit message. Finally, once a node receives commit messages from more than two-thirds of the nodes, the message is considered to have reached consensus. Throughout this process, each node maintains a state machine to record the current consensus progress. This consensus mechanism can tolerate no more than one-third of malicious nodes, ensuring the security and reliability of the system. This step ensures that new food flow information is quickly and securely disseminated throughout the network, achieving unanimous agreement on this information. This not only ensures the integrity and consistency of the information but also lays the foundation for subsequent verification and on-chain operations. This decentralized consensus mechanism significantly reduces the risk of single points of failure and improves the reliability and resilience of the entire system.
[0124] In the Byzantine Fault Tolerant consensus mechanism, each node verifies the message it receives and sends the verification results back to the network. The regional platform server, acting as a central node, is responsible for collecting and analyzing these verification results. During the verification process, each node checks whether the message format is correct, whether the hash value matches the encrypted data, whether the sending node has permission to perform the operation, and whether the timestamp is within a reasonable range. Each node's verification result can be simplified to a Boolean value: true indicates verification passed, and false indicates verification failed. The regional platform server collects and compiles these results. Assuming that there are N nodes participating in the verification in the network, the received verification results can be represented as an array: [r1, r2, ..., rN], where ri ∈ {true, false}. The criterion for determining whether consensus verification has passed is typically a positive response from more than two-thirds of the nodes. If this condition is met, the target user node account is considered to have passed the consortium chain consensus verification. In practice, node weight may also be taken into account, assigning different voting weights to different nodes. For example, weights can be assigned based on node reputation or network status. The weighted approach can better reflect the importance of different nodes in the network and improve the quality of consensus.
[0125] During implementation, the regional platform server will set a timeout. If sufficient feedback is not received within this time, the consensus will be considered a failure. The setting of this timeout requires a balance between network latency and efficiency, and may usually be set to a few seconds to tens of seconds. In addition, to prevent malicious nodes from repeatedly sending verification results and interfering with statistics, the system will deduplicate the feedback from each node and only accept the first feedback from each node. The effect of this step is to ensure the authenticity and validity of the uploaded food circulation information through the joint verification of multiple nodes in the network. It effectively prevents the possibility of a single malicious node tampering with or forging information, and improves the credibility of the entire system. At the same time, this distributed verification mechanism also enhances the transparency of the system, because each node participating in the verification can view and verify the information, which is very important for the food safety traceability system.
[0126] If the target user node account passes the alliance chain consensus verification, the regional platform server will use the target user node account's food flow hash data and encrypted food flow information to be uploaded to the regional food alliance chain. The implementation principle of this step is as follows: First, the regional platform server will package the verified food flow hash data and encrypted food flow information into a transaction. In this embodiment, the structure of this transaction is as follows:
[0127] "type":"food_transfer",
[0128] "hash":"8a1c7557f7fceadae6fe2f2eb6f80b8cdeea14b6fd7ec8e630da8fd24986e3c9",
[0129] "encrypted_data":"base64_encoded_encrypted_data_here",
[0130] "timestamp":1630450000,
[0131] "sender":"node_id_of_original_uploader",
[0132] "consensus_result":"passed",
[0133] "validator_signatures":["sig1","sig2",...,"sigN"]
[0134] Among them, the validator_signatures field contains the digital signatures of the nodes involved in the verification. These signatures can be used to prove that enough nodes have participated in the verification and given a positive result. Next, the regional platform server will broadcast this transaction to the entire regional food alliance chain network. Other nodes in the network will receive this transaction and try to package it into the next block. Once the block is accepted by enough nodes, it can be considered that the food circulation information has been successfully uploaded to the chain. The effect of this step is to permanently record the verified food circulation information on the blockchain. Due to the immutability of the blockchain, this information cannot be modified at will once it is uploaded to the chain, which provides a reliable data foundation for food safety traceability. At the same time, due to the distributed nature of the blockchain, this information will be copied to multiple nodes in the network, greatly improving the security and availability of the data.
[0135] In one embodiment, based on all user node accounts and using a heterogeneous information analysis module to analyze heterogeneous information features in all food circulation information, identifying abnormal food circulation information in the food circulation information based on the heterogeneous information features includes the following steps:
[0136] All user node accounts are used as account graph nodes, and the initial food flow heterogeneous graph is constructed based on all account graph nodes and using the heterogeneous information analysis module;
[0137] Generate heterogeneous node edges between all account graph nodes in the initial food flow heterogeneous graph based on all food flow information, and obtain a food flow heterogeneous graph. Different types of heterogeneous node edges represent different types of food flow information.
[0138] The heterogeneous information analysis module is used to extract high-order heterogeneous information features from the food flow heterogeneous graph;
[0139] Retrieving abnormal food circulation feature sets from the regional supervision platform through the regional platform server, and transmitting the abnormal food circulation feature sets to the heterogeneous information analysis module;
[0140] Based on the abnormal food circulation feature set and using the heterogeneous information analysis module, the abnormal correlation features in the high-order heterogeneous information features are identified, and the abnormal food circulation features in all food circulation information are determined according to the abnormal correlation features.
[0141] In this embodiment, first, each user node account needs to be mapped to a node in the graph. This node can contain multiple attributes, such as account ID, user type (such as manufacturer, transporter, retailer, etc.), registration time, etc., and an adjacency list or adjacency matrix can be used to represent this graph structure. The role of the heterogeneous information analysis module in this step is to assign an initial feature vector to each node. This feature vector can contain a variety of information, such as the type of node, the historical transaction frequency of the node, the credit score of the node, etc. The implementation effect of this step is to create an initial graph structure, which lays the foundation for subsequent analysis. This graph structure not only contains the basic information of the user node, but also captures more implicit information through the feature vector, which is very important for subsequent anomaly detection.
[0142] Next, it is necessary to process and analyze a large amount of food flow information and convert this information into edges in the graph. First, different types of edges need to be defined, and these edge types correspond to different types of food flow information. For example, a production-transportation edge can be defined to represent the flow from the producer to the transporter, a transportation-retail edge can be defined to represent the flow from the transporter to the retailer, and a retail-consumption edge can be defined to represent the flow from the retailer to the consumer, etc. Each type of edge can contain multiple attributes, such as flow time, flow quantity, food type, temperature record, etc. In an embodiment, a multigraph data structure can be used to represent this complex relationship, because there may be multiple types of edges between two nodes. For each piece of food flow information, a corresponding edge needs to be created to connect the corresponding two nodes. The weight of the edge can be determined based on the frequency or quantity of the flow.
[0143] For example, if an adjacency matrix is used, multiple matrices can be created, each corresponding to a different edge type. A specific implementation might involve traversing all food flow records R = {r1, r2, ..., rn} and, for each record ri, extracting its starting node si, ending node ti, flow type ci, and other attributes ai. Then, an edge of type ci from si to ti is added to the graph, with the edge attributes set to ai. This step can be mathematically represented as: E = {eij | eij = (si, ti, ci, ai, wi), for all ri in R}, where E is the set of edges. This step effectively integrates previously dispersed food flow information into a unified graph structure. This structure not only preserves all original information but also reflects the overall pattern of food flow through the graph's topology. This is extremely valuable for subsequent analysis, as graph theory and network analysis methods can be used to study the characteristics of food flow, such as identifying key nodes, analyzing flow paths, and detecting abnormal patterns.
[0144] Extracting high-order heterogeneous information features from the heterogeneous graph of food circulation using a heterogeneous information analysis module involves a variety of graph analysis technologies. High-order heterogeneous information features generally include node-level features, edge-level features, and graph-level features. Node-level features may include the degree centrality, betweenness centrality, eigenvector centrality, etc. of the node. These indicators reflect the importance and influence of the node in the network. Edge-level features may include edge weights, frequencies, time distributions, etc. These features reflect the patterns of different types of food circulation. Graph-level features may include the density of the graph, clustering coefficient, size of the largest connected subgraph, etc. These features reflect the global characteristics of the entire food circulation network. In this embodiment, a variety of graph analysis algorithms and machine learning methods can be used to extract these features. For example, graph neural networks (GNNs) can be used to learn embedded representations of nodes, which can capture the local and global structural information of the nodes. Specifically, graph convolutional networks (GCNs) or graph attention networks (GATs) can be used to implement this. This step effectively transforms complex graph structures into a series of numerical features that contain rich structural and semantic information. This transformation facilitates subsequent analysis and anomaly detection, as various machine learning algorithms can be applied directly to these features. These high-level features also provide a deeper understanding of the food flow network, revealing patterns and regularities that are not readily observable, such as the special role of certain nodes or subgraphs in the network, or the importance of certain types of flows within the network as a whole.
[0145] Next, the regional platform server sends a request to the regional regulatory platform for a feature set of abnormal food flows. This request may include parameters such as time range, geographic region, and food type to retrieve the most relevant feature set. Upon receiving the request, the regional regulatory platform retrieves the corresponding abnormal feature set from its database. This feature set may be manually defined by experts or automatically generated from historical data using a machine learning algorithm. The feature set format may be a JSON array, with each element describing an abnormal feature, including the feature's name, description, and threshold. The regional regulatory platform packages this feature set and sends it back to the regional platform server via a secure channel. Upon receiving the data, the regional platform server parses the feature set and converts it into a format that can be directly used by the heterogeneous information analysis module. The regional platform server then transmits the processed feature set to the heterogeneous information analysis module. This process incorporates officially defined abnormal feature knowledge into the analysis system, which is crucial for improving the accuracy and interpretability of anomaly detection. Officially defined feature sets typically incorporate the knowledge and experience of domain experts and can capture complex, rule-based abnormal patterns. Combining these features with features previously learned from data can create a more comprehensive and robust anomaly detection system. This approach also improves the flexibility and updability of the system, as the latest anomaly feature definitions can be obtained from the regulatory platform at any time, allowing it to quickly adapt to emerging anomaly patterns or changing regulatory requirements.
[0146] Next, the abnormal food flow feature set obtained from the regulatory platform needs to be matched and compared with the previously extracted high-level heterogeneous information features. This process can utilize a variety of machine learning and data mining techniques, such as anomaly detection algorithms and pattern matching algorithms. Specifically, density-based methods (such as DBSCAN), distance-based methods (such as LOF), or model-based methods (such as SVM) can be used to identify anomalies. This step enables accurate identification of truly abnormal flows from massive amounts of food flow information. The advantage of this approach is that it considers not only the anomalies of individual nodes or edges, but also the relationships between them, significantly improving the accuracy and interpretability of anomaly detection. Furthermore, this approach is highly adaptable and scalable. As new abnormal patterns emerge, the abnormal food flow feature set can be updated and algorithm parameters adjusted to quickly adapt to new situations. Furthermore, by utilizing efficient algorithms such as graph mining, this approach can handle large-scale food flow networks and meet the performance requirements of practical applications.
[0147] In one embodiment, extracting high-order heterogeneous information features from a food flow heterogeneous graph using a heterogeneous information analysis module includes the following steps:
[0148] Use the heterogeneous information analysis module to select multiple account graph node pairs from the food flow heterogeneous graph. Each account graph node must belong to at least one account graph node pair, and the two account graph nodes in the account graph node pair must have different node types.
[0149] All account graph node pairs are mapped to a preset high-dimensional feature space through the heterogeneous information analysis module;
[0150] In the high-dimensional feature space, based on the double-layer heterogeneous attention mechanism and the heterogeneous information analysis module, the node-pair association features of each account graph node pair are extracted. The node-pair association features include the graph node features of the two account graph nodes in the account graph node pair and the node-edge features of the heterogeneous node edge between the two account graph nodes.
[0151] For each account graph node pair, take any account graph node in the account graph node pair as the central graph node, aggregate the node pair association features corresponding to the central graph node's N-order neighbor graph nodes into the N-order neighbor graph node aggregate features, where N is less than or equal to the number of types of heterogeneous node edges;
[0152] The heterogeneous information analysis module is used to extract the aggregated features of all N-order neighbor graph nodes from the high-dimensional feature space as high-order heterogeneous information features.
[0153] In this embodiment, the breadth-first search (BFS) or depth-first search (DFS) algorithm can be used to traverse the entire heterogeneous graph. During the traversal process, for each node encountered, an adjacent node of a different type is found to form a node pair. For example, if the current node is of supplier type, it may form a pair with a node of dealer or retailer type. It should be noted here that each account graph node must belong to at least one node pair, which ensures that all nodes are taken into account. At the same time, the two node types in the node pair must be different, which reflects the characteristics of the heterogeneous graph and helps to capture the relationship between nodes of different types. In actual operation, a hash table can be used to record the pairings that have been formed for each node to ensure that all nodes are covered and duplication is avoided.
[0154] Next, all account graph node pairs are mapped to a preset high-dimensional feature space. For each node pair, a variety of features can be extracted, including but not limited to: the attributes of the node itself (such as account age, transaction frequency, etc.), the topological characteristics of the node in the graph (such as degree centrality, betweenness centrality, etc.), and the relationship characteristics between node pairs (such as transaction amount, transaction frequency, etc.). These features can be combined and transformed in a variety of ways, such as using principal component analysis (PCA) for dimensionality reduction or using autoencoders for nonlinear transformation. The effect of this step is to convert the original heterogeneous graph structure into a dense vector representation. These vectors contain rich information about nodes and edges, providing a good foundation for subsequent analysis. This representation method can capture complex nonlinear relationships and has good generalization capabilities, and can handle unseen nodes and relationships.
[0155] Then, in the high-dimensional feature space, the node-pair correlation features of each account graph node pair are extracted based on the double-layer heterogeneous attention mechanism. The core of this step is to use the attention mechanism to capture the complex interactions between node pairs. The double-layer heterogeneous attention mechanism includes two levels: node-level attention and type-level attention. In the node-level attention, for the node pair (v i , v j ), calculate the attention weight between them: α ij =softmax(a T ·[W i ·h i ||W j ·h j ]), where a is a learnable attention vector, W i and W j is a type-specific transformation matrix, h i and h j is the feature vector of the node, and || represents the concatenation operation. This attention weight reflects the importance between two nodes. In type-level attention, different types of edges are considered and type-specific attention weights are calculated: β r =softmax(b T tanh(W r μ r )), where b is a learnable vector, W r is the transformation matrix of edge type r, μ r is the average feature of edge type r. The final node pair association feature can be expressed as: f ij =σ(∑ r β r ·(α ij ·(W i ·h i +W j ·h j )+We ·e ij )), where e ij is the edge feature vector, and σ is a nonlinear activation function. This step generates semantically rich node-pair association features. These features encompass not only the node information itself but also the interactions between nodes and edge information. This approach effectively handles complex relationships in heterogeneous graphs, particularly between nodes of different types.
[0156] For each account graph node pair, with one of the nodes as the center, aggregate the node pair association features of its N-order neighbors. The purpose of this step is to capture more extensive structural information. The specific implementation can be recursive. First, define the aggregation function of the first-order neighbors: h1(v) = AGG1(f vu : u∈N(v)), where N(v) is the set of direct neighbors of v, f vu is the node pair association feature of v and u, AGG1 is the first-order aggregation function, which can be a simple average operation or a more complex attention mechanism. Then the aggregation function of the k-order neighbor is recursively defined, and the final N-order neighbor graph node aggregation feature can be expressed as a combination of these N aggregation results: H(v)=COM(h1(v),h2(u),...,h N (u)), where the COM function can be a simple concatenation function. It is important to note that N should be less than or equal to the number of heterogeneous node edge types to ensure that all types of relationship information are captured without introducing excessive redundancy. This step results in the generation of node representations that contain rich contextual information. These representations reflect not only the characteristics of the node itself but also its structural information within a larger context. This approach can effectively capture long-range dependencies and complex structural patterns and is particularly effective for discovering hidden associations and abnormal patterns.
[0157] Finally, the aggregated features of all N-order neighbor graph nodes are extracted from the high-dimensional feature space as high-order heterogeneous information features. The core of this step is to integrate the local features generated previously into global features. Specifically, an importance weight is assigned to the N-order aggregated features of each node: w v =q T tanh(W H(v)), where q and W are learnable parameters. Then, the global feature can be expressed as a weighted sum: G = ∑ v softmax(w v)·H(v). This global feature G is the final high-order heterogeneous information feature. In addition, more advanced graph-level feature extraction methods such as graph isomorphism networks (GIN) can also be considered. These methods can capture more fine-grained structural information. The effect of this step is to generate a comprehensive graph-level representation that integrates the local and global information of all nodes in the graph. This high-order heterogeneous information feature can comprehensively describe the characteristics of the entire food circulation network, including its overall structure, the interaction patterns between various entities, and potential abnormal patterns. This provides strong support for subsequent tasks such as anomaly detection and risk assessment.
[0158] In one embodiment, based on the abnormal food flow feature set and using the heterogeneous information analysis module to identify abnormal correlation features in high-order heterogeneous information features, and determining abnormal food flow features in all food flow information based on the abnormal correlation features includes the following steps:
[0159] The abnormal food flow feature set is input into the preset abnormal flow feature recognition model using the heterogeneous information analysis module. All data in the abnormal food flow feature set have abnormal feature annotation information.
[0160] The model training process of the abnormal food flow feature recognition model is completed through the abnormal food flow feature set;
[0161] The heterogeneous information analysis module is used to input high-order heterogeneous information features into the trained abnormal flow feature recognition model. The abnormal flow feature recognition model then identifies and outputs abnormal correlation features in the high-order heterogeneous information features.
[0162] Based on the abnormal correlation features and through the heterogeneous information analysis module, the abnormal food circulation features in all food circulation information are determined.
[0163] In this embodiment, first, the abnormal food circulation feature set is input into the preset abnormal circulation feature recognition model. The abnormal food circulation feature set is a data set containing known abnormal features, and each data is accompanied by abnormal feature annotation information. These data may come from historical cases, expert annotations or simulation generation. Before inputting the model, the data needs to be preprocessed, including feature standardization, missing value processing and encoding conversion. The preset abnormal circulation feature recognition model can be various machine learning or deep learning models, such as random forest, support vector machine (SVM) or neural network. Taking neural network as an example, a multi-layer perceptron (MLP) structure can be designed, and the model initialization can use Xavier or He initialization method to ensure a good starting point for training.
[0164] Next, the abnormal food flow feature set is used to complete the model training process for the abnormal flow feature recognition model. The training process typically uses batch gradient descent or its variants (such as Adam and RMSprop) to minimize the loss function. In each training step, the model calculates predicted values through forward propagation and then updates the parameters through backpropagation. To prevent overfitting, regularization techniques such as L2 regularization can be employed. In addition, techniques such as dropout and early stopping can also be used. During the training process, the dataset is typically divided into training, validation, and test sets, for example, in a ratio of 7:2:1. The training set is used for model training, the validation set is used for hyperparameter tuning and early stopping, and the test set is used for final evaluation of model performance. Model performance can be evaluated using metrics such as accuracy, precision, recall, and F1 score. The training process may require multiple epochs until the model converges or a preset stopping condition is reached. The result of this step is a fully trained abnormal flow feature recognition model that can effectively identify abnormal patterns from the input features. This training method enables the model to learn the complex patterns of abnormal food flow, improving the accuracy and robustness of the model in practical applications.
[0165] Next, it is necessary to ensure that the high-order heterogeneous information features have the same format and dimensionality as the training data. If there are discrepancies, feature alignment or dimensionality reduction may be necessary. For example, principal component analysis (PCA) can be used to reduce the high-dimensional features to the same dimensionality as the training data. These processed features are then fed into the trained model for inference. For neural network models, this process is known as forward propagation. The model's final output is the probability of each sample being classified as an anomaly. Next, anomaly-related features need to be identified from these outputs. Specifically, SHAP (SHapley Additive exPlanations) values can be used to explain the model's decisions and identify important features. SHAP values calculate the contribution of each feature to the model output. Features with large SHAP values are considered anomaly-related features. This step effectively identifies key features associated with abnormal food flow from the high-order heterogeneous information features. These features reflect potential abnormal patterns or risk factors. Finally, the identified anomaly-related features need to be mapped back to the original food flow heterogeneous graph. Next, patterns matching the anomaly-related features are searched within the original food flow heterogeneous graph. Specifically, we can use the subgraph isomorphism algorithm, and then mark all possible abnormal food flow characteristics based on the matching results and propagation analysis.
[0166] In one embodiment, when the heterogeneous information analysis module identifies abnormal food circulation information, uploading the abnormal food circulation information and basic user information of all abnormal user clients associated with the abnormal food circulation information to the regional supervision platform via the regional platform server includes the following steps:
[0167] During any preset supervision time period, when the heterogeneous information analysis module of the regional supervision platform in one and only one target area identifies abnormal food circulation information, the abnormal food circulation information and the basic user information of all abnormal user clients associated with the abnormal food circulation information will be uploaded to the regional supervision platform through the regional platform server.
[0168] In this embodiment, within any supervision time period, when the heterogeneous information analysis modules of the regional supervision platforms in multiple target areas simultaneously identify abnormal food circulation information, the abnormal food circulation information and the basic user information of all abnormal user clients associated with the abnormal food circulation information are uploaded to the regional supervision platform through the abnormal regional platform servers that each identify the abnormal food circulation information;
[0169] Randomly select a target regional supervision platform from multiple regional supervision platforms that have not identified abnormal food circulation information during the current supervision period;
[0170] All abnormal food flow information is sent to the target area supervision platform through the abnormal area platform server;
[0171] The target area platform server of the target area supervision platform is used to identify the cross-regional correlation information between all abnormal food circulation information, and upload the cross-regional correlation information to the regional supervision platform.
[0172] In this embodiment, within any preset supervision time period, when the heterogeneous information analysis module of the regional supervision platform in one and only one target area identifies abnormal food circulation information, the association analysis process is immediately triggered, and all user nodes directly related to the abnormal record are found through a graph traversal algorithm (such as depth-first search). Next, the basic information of these users is extracted from the user database, which may include ID, name, contact information, etc. Finally, the regional platform server packages the abnormal food circulation information and the associated user information into a JSON format data packet and securely uploads it to the regional supervision platform via the HTTPS protocol.
[0173] During any supervision time period, when the heterogeneous information analysis modules of the regional supervision platforms in multiple target areas simultaneously identify abnormal food circulation information, the abnormal food circulation information and the user basic information of all abnormal user clients associated with the abnormal food circulation information are uploaded to the regional supervision platform through the abnormal regional platform servers that identify the abnormal food circulation information. In this step, in order to handle concurrent uploads, the regional supervision platform needs to implement a high-concurrency receiving system. Next, it is necessary to randomly select a target regional supervision platform from the multiple regional supervision platforms that have not identified abnormal food circulation information during the current supervision time period. Then all abnormal food circulation information is sent to the target regional supervision platform through the abnormal regional platform server. This process takes into account that the abnormal food circulation information may involve a large amount of sensitive data, and a secure and reliable transmission protocol needs to be adopted. The HTTPS protocol based on TLS1.3 can be used to ensure end-to-end encrypted transmission.
[0174] Next, the target regional platform server of the target regional regulatory platform is used to identify cross-regional correlations between all abnormal food flow information. A graph database (such as Neo4j) is then used to construct a simple food flow network, where each node represents an entity (such as food, user, location) and edges represent relationships between them (such as flow, production, and consumption). Anomaly detection algorithms (such as graph anomaly detection) are used to identify abnormal structures in the network. For example, a centrality metric (such as PageRank value) can be calculated for each node, and nodes that significantly deviate from the average are marked as potential anomalies. Finally, the analysis results are subjected to information extraction and aggregation. A report containing key findings can be generated, such as identified cross-regional flow paths, entities with high levels of abnormality, and potential risk areas. The generated cross-regional correlation information is uploaded to the regional regulatory platform via a secure channel (such as VPN).
[0175] The present invention also discloses a food safety supervision system based on artificial intelligence and blockchain, including a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, it implements the food safety supervision method based on artificial intelligence and blockchain as described in any of the above embodiments.
[0176] Among them, the processor can adopt a central processing unit (CPU). Of course, according to actual usage, other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. can also be adopted. The general-purpose processor can adopt a microprocessor or any conventional processor, etc., and this application does not impose any restrictions on this.
[0177] Among them, the memory can be an internal storage unit of a computer device, such as a hard disk or memory of a computer device, or an external storage device of a computer device, such as a plug-in hard disk, smart memory card (SMC), secure digital card (SD) or flash memory card (FC) equipped on the computer device. In addition, the memory can also be a combination of an internal storage unit and an external storage device of a computer device. The memory is used to store computer programs and other programs and data required by the computer device. The memory can also be used to temporarily store data that has been output or is to be output. This application does not impose any restrictions on this.
[0178] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of protection of the present application is limited to these examples. In line with the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of different aspects of one or more embodiments of the present application as above, which are not provided in detail for the sake of simplicity.
[0179] The one or more embodiments of this application are intended to encompass all such substitutions, modifications, and variations that fall within the broad scope of this application. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of this application should be included in the scope of protection of this application.
Claims
1. A food safety supervision method based on artificial intelligence and blockchain, characterized in that: Applicable to a target area where a regional supervision platform is deployed, the target area includes multiple target areas, each of which is deployed with a regional supervision platform, all of which are in communication connection with the regional supervision platform, the regional supervision platform is configured with a regional user registration center, a regional platform server and a heterogeneous information analysis module, each of which is based on the regional platform server and combined with the regional user registration center to create a regional food alliance chain, and the regional platform server in each target area has the highest management authority of the regional food alliance chain in the same target area; The method comprises the following steps: For each target area, the regional user registration center obtains the account registration application of the user client in the target area, and the regional platform server verifies the account registration application using the consensus mechanism preset in the regional food alliance chain. The user client is a user terminal held by a food producer, food processor, food storage, food transporter, food seller, or food buyer; Creating a user node account of the regional food alliance chain for the target user client whose account registration application has passed the verification, generating an account key pair for the user node account, and storing the account public key in the account key pair in the public key database preset by the regional user registration center; Uploading the food circulation information uploaded by the user node account to the regional food alliance chain through the regional platform server, wherein the food circulation information includes the user signature of the user node account, and the user signature is generated based on the account private key in the account key pair; Extracting the account public keys of all the user node accounts from the public key database through the heterogeneous information analysis module, and using all the account public keys to query the regional food alliance chain to obtain all the food circulation information; Based on all the user node accounts and using the heterogeneous information analysis module to analyze the heterogeneous information features in all the food circulation information, and identifying abnormal food circulation information in the food circulation information according to the heterogeneous information features; When the heterogeneous information analysis module identifies the abnormal food circulation information, the abnormal food circulation information and the basic user information of all abnormal user clients associated with the abnormal food circulation information are uploaded to the regional supervision platform through the regional platform server; The step of analyzing the heterogeneous information features in all the food circulation information based on all the user node accounts and using the heterogeneous information analysis module, and identifying abnormal food circulation information in the food circulation information according to the heterogeneous information features comprises the following steps: All the user node accounts are used as account graph nodes, and an initial food flow heterogeneous graph is constructed based on all the account graph nodes and using the heterogeneous information analysis module; generating heterogeneous node edges between all the account graph nodes in the initial food circulation heterogeneous graph according to all the food circulation information, thereby obtaining a food circulation heterogeneous graph, wherein different types of heterogeneous node edges represent different types of food circulation information; Selecting a plurality of account graph node pairs from the food flow heterogeneous graph using the heterogeneous information analysis module, wherein each account graph node must belong to at least one account graph node pair, and the node types of two account graph nodes in the account graph node pair are different; Mapping all the account graph node pairs to a preset high-dimensional feature space through the heterogeneous information analysis module; In the high-dimensional feature space, based on a double-layer heterogeneous attention mechanism and through the heterogeneous information analysis module, node pair association features of each of the account graph node pairs are extracted, wherein the node pair association features include graph node features of the two account graph nodes in the account graph node pair and node edge features of the heterogeneous node edge between the two account graph nodes; For each of the account graph node pairs, any one of the account graph nodes in the account graph node pair is used as the central graph node, and the node pair association features corresponding to the N-order neighbor graph nodes of the central graph node are aggregated into N-order neighbor graph node aggregate features, where N is less than or equal to the number of types of heterogeneous node edges; Utilizing the heterogeneous information analysis module to extract all the N-order neighbor graph node aggregation features from the high-dimensional feature space as high-order heterogeneous information features; Retrieving an abnormal food circulation feature set from the regional supervision platform through the regional platform server, and transmitting the abnormal food circulation feature set to the heterogeneous information analysis module; Based on the abnormal food circulation feature set and using the heterogeneous information analysis module, abnormal correlation features in the high-order heterogeneous information features are identified, and the abnormal food circulation features in all the food circulation information are determined according to the abnormal correlation features.
2. The food safety supervision method based on artificial intelligence and blockchain according to claim 1 is characterized in that: After the target user client, which has passed the verification of the account registration application, creates a user node account for the regional food alliance chain, the following steps are also included: Identify the account type of the user node account based on the basic user information in the account registration application; Allocating account permissions for the user node account based on the account type; Adding the user node account after the authority is assigned to the network node topology of the regional food alliance chain; The consensus mechanism is used to configure the consensus parameters of the user node account, and all blockchain public data of the regional food alliance chain are synchronized to the user node account through the consensus parameters.
3. The food safety supervision method based on artificial intelligence and blockchain according to claim 2 is characterized in that: The process of uploading the food circulation information uploaded by the user node account to the regional food alliance chain through the regional platform server includes the following steps: When any one or more target user node accounts upload the initial food circulation information to the regional food alliance chain, the alliance chain smart contract preset in the regional food alliance chain is triggered. After the alliance chain smart contract is triggered, the following steps are performed: Verify the account permissions and consensus parameters of the target user node account based on the consortium chain smart contract and using the regional platform server; If the account permissions and consensus parameters of the target user node account are verified, the sensitive information in the initial food circulation information is encrypted using an asymmetric encryption algorithm based on the account private key in the account key pair of the target user node account to obtain encrypted food circulation information; Converting the encrypted food circulation information into food circulation hash data through the alliance chain smart contract; Using the regional platform server as the initial broadcast node, and utilizing the Byzantine fault-tolerant consensus mechanism preset in the regional food alliance chain, broadcast the food circulation hash data and the encrypted food circulation information to all other user node accounts except the target user node account; Receiving, through the regional platform server, verification feedback results of all the other user node accounts in response to the Byzantine fault-tolerant consensus mechanism, and determining whether the target user node account has passed the alliance chain consensus verification based on the verification feedback results; If the target user node account passes the alliance chain consensus verification, the food circulation hash data and the encrypted food circulation information of the target user node account are uploaded to the regional food alliance chain using the regional platform server.
4. The food safety supervision method based on artificial intelligence and blockchain according to claim 3 is characterized in that: The initial food circulation information includes any one or more of food production information, food processing information, food storage information, food transportation information, food sales information and food purchase information.
5. The food safety supervision method based on artificial intelligence and blockchain according to claim 1 is characterized in that: The method of identifying abnormal correlation features in the high-order heterogeneous information features based on the abnormal food circulation feature set and using the heterogeneous information analysis module, and determining abnormal food circulation features in all the food circulation information according to the abnormal correlation features, includes the following steps: The abnormal food circulation feature set is input into a preset abnormal circulation feature recognition model using the heterogeneous information analysis module, and all data in the abnormal food circulation feature set have abnormal feature labeling information; Completing the model training process of the abnormal food circulation feature recognition model through the abnormal food circulation feature set; Using the heterogeneous information analysis module to input the high-order heterogeneous information features into the trained abnormal flow feature recognition model, the abnormal flow feature recognition model identifies and outputs abnormal correlation features in the high-order heterogeneous information features; Based on the abnormal correlation features, the abnormal food circulation features in all the food circulation information are determined through the heterogeneous information analysis module.
6. The food safety supervision method based on artificial intelligence and blockchain according to claim 1 is characterized in that: When the heterogeneous information analysis module identifies the abnormal food circulation information, uploading the abnormal food circulation information and the basic user information of all abnormal user clients associated with the abnormal food circulation information to the regional supervision platform through the regional platform server includes the following steps: Within any preset supervision time period, when the heterogeneous information analysis module of the regional supervision platform in one and only one target area identifies the abnormal food circulation information, the abnormal food circulation information and the user basic information of all abnormal user clients associated with the abnormal food circulation information are uploaded to the regional supervision platform through the regional platform server.
7. The food safety supervision method based on artificial intelligence and blockchain according to claim 6 is characterized in that: The method further comprises the steps of: During any one of the supervision time periods, when the heterogeneous information analysis modules of the regional supervision platforms in multiple target areas simultaneously identify the abnormal food circulation information, the abnormal food circulation information and the basic user information of all abnormal user clients associated with the abnormal food circulation information are uploaded to the regional supervision platform through the abnormal regional platform servers that each identify the abnormal food circulation information; Randomly select a target regional supervision platform from the multiple regional supervision platforms that have not identified the abnormal food circulation information within the current supervision time period; Sending all the abnormal food circulation information to the target area supervision platform through the abnormal area platform server; The target area platform server of the target area supervision platform is used to identify the cross-regional association information between all the abnormal food circulation information, and upload the cross-regional association information to the regional supervision platform.
8. A food safety supervision system based on artificial intelligence and blockchain, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the food safety supervision method based on artificial intelligence and blockchain is implemented as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Food safety supervision method and device, blockchain alliance management platform and medium
CN111402101A
Food safety tracing system and method, equipment and readable storage medium
CN113094365A