A blockchain-based method and device for managing agricultural product traceability data.
By constructing a consortium blockchain architecture that integrates the management chain and data chain using blockchain technology, and combining consensus mechanisms and permission matching, the problem of cross-departmental collaboration in agricultural product quality supervision data has been solved, enabling secure and efficient management of agricultural product quality traceability data and joint control by multiple departments.
Patent Information
- Application Number
- CN202510349213.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-03-24
AI Technical Summary
The current technology has a low degree of cross-departmental data supervision and auditing of agricultural product quality supervision data, which makes it impossible to fully guarantee the accuracy and effectiveness of agricultural product quality supervision data.
By adopting a blockchain-based management chain and data chain architecture, a consortium blockchain is built. Through consensus and permission matching mechanisms, accurate access and efficient management of agricultural product traceability data are achieved. Combined with knowledge graph generation technology, user permissions and data access are accurately identified.
This has enabled the security of agricultural product quality traceability data and multi-departmental joint management, improved the efficiency and accuracy of data use, and ensured the quality and safety of agricultural products.
Smart Images

Figure CN120296088B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, and in particular to a blockchain-based method and apparatus for managing traceability data of agricultural products. Background Technology
[0002] The supervision and protection of agricultural product quality and safety cannot be separated from the efficient management and traceability of quality supervision data. Only by accurately recording and managing the quality monitoring data of agricultural products in all aspects of production, circulation and sales can we accurately and quickly locate and solve problems when they occur, thereby effectively ensuring the quality and safety of agricultural products.
[0003] Currently, the main methods for information management of agricultural product quality supervision data include barcodes, RFID, and other identification technologies combined with information systems to achieve data traceability and application. Because agricultural product quality supervision involves multiple stages, including farmers, producers, logistics companies, distributors, and retailers, and each stage is overseen by different regulatory departments, the validity and accuracy of agricultural product quality supervision data requires joint review and consensus among these departments. Traditional methods have a low degree of effectiveness in cross-departmental data supervision and review, resulting in insufficient assurance of the accuracy and validity of agricultural product quality supervision data.
[0004] Therefore, a way is needed to achieve accurate access, efficient management, and data access based on different permissions for agricultural product traceability data. Summary of the Invention
[0005] This invention provides a blockchain-based method and apparatus for managing agricultural product traceability data, which enables accurate access, efficient management, and data access based on different permissions for agricultural product traceability data.
[0006] According to one aspect of the present invention, a blockchain-based method for managing agricultural product traceability data is provided, comprising:
[0007] A consortium blockchain architecture consisting of a management chain and a data chain is constructed, wherein each data chain stores traceability data of at least one link in the agricultural product supply chain, and the management chain stores the data chain identification information of each data chain, the data node identification information on the data chain, and the encrypted exchange information of the data node data.
[0008] When a new node is added to a data link, a request is sent to the management chain corresponding to the data link to enable the nodes of the management chain to initiate consensus, and the access result of the new node is determined based on the consensus result.
[0009] In response to an external data access request, the system performs permission matching on the data access request, assigns permissions to the data access request based on the matching result, and displays the data in the data chain that the permission allows to be accessed.
[0010] Optionally, the step of sending a request to the management chain corresponding to the data chain to initiate consensus among the nodes of the management chain, and determining the access result of the newly added data chain node based on the consensus result, includes:
[0011] A node in the management chain is randomly selected as the master node to initiate an access request. After the master node receives the access request, it initiates consensus with the other nodes in the management chain.
[0012] If consensus is successful, the master node exchanges access response data with the data chain that issued the access request, including the new node's identification information, attribute information, and ciphertext information, and stores them in their respective block nodes. The new node's identification information is a unique identifier ID of the consortium blockchain, generated based on the timestamp generated when the access request occurs; the attribute information identifies the new node's category information and business information; and the ciphertext information is the pair of secret keys agreed upon when accessing the new node.
[0013] Optionally, the step of initiating consensus with other nodes of the management chain after the master node receives the access request includes:
[0014] The nodes are randomly and evenly grouped according to the total number of nodes. Each group has a candidate list and a non-candidate list. Candidate nodes are selected from the candidate list, and the remaining nodes in the candidate list are used as backup nodes. The master node and the candidate nodes construct a consensus network.
[0015] The master node sends a preparation message to the candidate nodes in the consensus network so that the candidate nodes can respond after receiving the preparation message. Nodes that do not respond or whose response message is incorrect are set as suspicious nodes.
[0016] When the total number of suspicious nodes is less than the set consensus network threshold, an execution message is sent to the candidate node in the consensus network so that the candidate node returns a verification result after receiving the execution message. When a preset number of verification messages indicating successful verification are received, consensus is confirmed.
[0017] When the total number of suspicious nodes is not less than the consensus network threshold, all suspicious nodes are moved to the non-candidate list, and the consensus network is reorganized.
[0018] Optionally, the encrypted information is generated and used in the following manner:
[0019] The master node generates and stores the encryption function and the set of independent variables, constructs the equivalent function of the encryption function on the set of independent variables, and the new node stores the equivalent function.
[0020] In response to the data node access request for the new node, the encryption function and a random number belonging to the set of independent variables are requested from the master node to calculate the ciphertext verification information;
[0021] The encrypted verification information and the random number are packaged into the data access request and sent to the data chain where the new node is located. The data chain calculates the verification value based on the encrypted verification information and the equivalent function, and compares the verification value with the encrypted verification information. If the difference is within the threshold, the encrypted verification passes; otherwise, the encrypted verification fails.
[0022] Optionally, the permissions include a first permission and a second permission, wherein the second permission allows access to all information stored in the management chain node, and the first permission allows access to less information than the second permission; correspondingly, in response to an external data access request, permission matching is performed on the data access request, and permissions are assigned to the data access request according to the matching result, displaying the data of the data chain that the permission allows access to, including:
[0023] Calculate the authentication result value of the data access request, and determine whether the data access request matches the first permission or the second permission based on the authentication result value;
[0024] If the first permission is matched, the data that the first permission allows access to is displayed. If the second permission is matched, the encrypted information in the all information is sent to the data chain where the corresponding data chain node is located for secondary verification based on the identification information in the all information. After successful verification, a knowledge graph based on the data of the corresponding data node is generated and fed back.
[0025] Optionally, calculating the authentication result value of the data access request and determining whether the data access request matches the first permission or the second permission based on the authentication result value includes:
[0026] The authentication result value is calculated using the following formula:
[0027] ;
[0028] in, The identity verification result value is n, where n is the total number of agricultural product supervision links. Configure permissions for agricultural products at the i-th regulatory stage; For agricultural products, the requesting end claims access rights to data at the i-th regulatory stage; This establishes a matching relationship between the permission configuration for agricultural products at the i-th regulatory stage and the permission claimed by the requesting end. The value is [0,1]. =0 indicates a complete mismatch. =1 indicates a complete match;
[0029] Substitute the user information contained in the data access request into the above formula to calculate the authentication result value;
[0030] The value of the authentication result determines whether the data access request matches the first permission or the second permission.
[0031] Optionally, generating a knowledge graph based on the data of the corresponding data nodes includes:
[0032] Based on the data nodes, extract the main object set; traverse all data chains to extract the object set related to the main object;
[0033] Applying knowledge from the field of crops, design a set of relationships between subject and object;
[0034] Entities are extracted from the set of subject objects and the set of object relationships to obtain a core entity set; relation entities are extracted from the set of subject and object relationships to form a relation entity set; attribute entities are extracted based on and to form an attribute entity set.
[0035] Design the connection mechanism of the core entity set, the relation entity set, and the attribute entity set, establish a formal triple ontology model, and use a knowledge graph representation language to describe the triple ontology model to obtain the knowledge graph.
[0036] According to another aspect of the present invention, a blockchain-based agricultural product traceability data management device is provided, comprising:
[0037] The node access unit is used to send a request to the management chain corresponding to the data chain when a new node is added to a data chain, so that the nodes of the management chain initiate consensus, and determine the access result of the new node based on the consensus result;
[0038] The data access unit is used to respond to external data access requests, perform permission matching on the data access requests, assign permissions to the data access requests based on the matching results, and display the data of the data chain that is allowed to be accessed by the permissions.
[0039] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0040] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to execute the blockchain-based agricultural product traceability data management method according to any embodiment of the present invention.
[0041] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions, the computer instructions being configured to cause a processor to execute and implement the blockchain-based agricultural product traceability data management method described in any embodiment of the present invention.
[0042] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program that, when executed by a processor, implements the blockchain-based agricultural product traceability data management method described in any embodiment of the present invention.
[0043] The technical solution of this invention adopts a management chain plus data chain architecture, which enables data access and other activities of the data chain to be included in the supervision and review of the management chain. While ensuring the security of agricultural product quality traceability data, it also effectively realizes the joint management and control of agricultural product quality and safety by multiple departments. Through the authentication and access control strategy for data reading, it can accurately identify the user's permission to use data, thereby improving the efficiency of data use while ensuring the security of agricultural product quality supervision data.
[0044] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This is a flowchart of a blockchain-based agricultural product traceability data management method provided in Embodiment 1 of the present invention;
[0047] Figure 2 This is a schematic diagram of a consortium blockchain applicable to Embodiment 1 of the present invention;
[0048] Figure 3 This is a schematic diagram of a control module applicable to Embodiment 1 of the present invention;
[0049] Figure 4 This is a flowchart of a data node access method provided in Embodiment 2 of the present invention;
[0050] Figure 5This is a flowchart of a data reading method provided in Embodiment 3 of the present invention;
[0051] Figure 6 This is a schematic diagram of the structure of a blockchain-based agricultural product traceability data management device provided in Embodiment 4 of the present invention;
[0052] Figure 7 This is a schematic diagram of the structure of an electronic device that implements the blockchain-based agricultural product traceability data management method according to embodiments of the present invention. Detailed Implementation
[0053] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0054] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0055] Example 1
[0056] Figure 1 This is a flowchart of a blockchain-based agricultural product traceability data management method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations involving the management of agricultural product traceability data. The method can be executed by a blockchain-based agricultural product traceability data management device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes:
[0057] S110. Construct a consortium blockchain architecture consisting of a management chain and a data chain. Each data chain stores traceability data for at least one link in the agricultural product supply chain, while the management chain stores the data chain identification information, data node identification information, and encrypted data exchange information of each data chain.
[0058] Figure 2 This is a schematic diagram of a consortium blockchain applicable to Embodiment 1 of the present invention. Its overall architecture consists of a management chain and a data chain. The management chain is used by the competent authorities and similar organizations, while the data chain is used by personnel at each stage of the agricultural product supply chain. Each participating chain is equipped with a control module for implementing management functions. The consortium blockchain is used to enable the access and retrieval of traceability data.
[0059] For example, the data in the data chain includes traceability data for five stages required for safety supervision: production, processing, logistics, warehousing, and sales. This data is stored and retrieved using encrypted verification. Taking jujubes as an example of agricultural products, the data content includes: 1) Traceability data for the production stage: jujube variety, origin, batch number, growing environment, growth cycle, fertilization, yield information, and pesticide residues; 2) Traceability data for the processing stage: jujube grade information, quality inspection information, entry time, exit time, processing batch number, operator information, processing equipment, and processing technology; 3) Traceability data for the logistics stage: logistics provider, tracking number, logistics method, order information, and transportation route; 4) Traceability data for the warehousing stage: warehousing company information, warehouse address, warehousing batch, warehousing environment, and management personnel; 5) Traceability data for the sales stage: sales company, sales time, sales location, selling price, sales personnel, and quantity purchased.
[0060] The management chain primarily stores summary information about the data chains it manages, including: data chain identification information (e.g., if the identification information is for the production process, then the data chain stores traceability data for the production process), data node identification information on the data chain (e.g., for a data chain storing traceability data for the production process, there may be situations where one node cannot store all the data, requiring storage through multiple nodes; the data node identification information consists of the unique identification number or other type of identification information for each node), and encrypted data exchange information for the data nodes.
[0061] S120. When a new node is added to a data chain, a request is sent to the management chain corresponding to the data chain to enable the nodes of the management chain to initiate consensus, and the access result of the new node is determined based on the consensus result.
[0062] When a new node is connected to a data chain, the set data access smart contract is invoked to send a request to the management chain. All nodes of the management chain initiate a consensus. After the consensus is reached, the review result is notified to the data chain, and the data node connection is completed.
[0063] Specifically, when a new node needs to join the data chain, a data access smart contract is invoked. Once activated, the smart contract randomly selects a node in the management chain as the master node and sends an access request to it. Upon receiving the access request, the selected master node in the management chain initiates consensus using an improved Byzantine algorithm based on elastic grouping and reputation scoring. Once all nodes in the management chain reach a consensus, they notify the data chain of the review results. If the consensus is successful, the new node officially joins the data chain; if the consensus fails, the data node's access is rejected.
[0064] S130. In response to an external data access request, perform permission matching on the data access request, assign permissions to the data access request based on the matching results, and display the data in the data chain that is allowed to be accessed by the permission.
[0065] When an external data access request is received, the authentication smart contract is activated. A specific algorithm is used to authenticate permissions, with the results categorized into group permission matching and final permission matching. If the requester passes group permission matching, it can read the attribute information stored in the corresponding management chain node, thus obtaining summary information (e.g., a visitor wanting to view relevant traceability data, but lacking sufficient permissions, can only view a summary to understand the general content). If the requester passes final permission matching, it can read all information (including identifier, attribute, and encrypted information) stored in the corresponding management chain node. Based on the identifier, the requester sends the encrypted information to the corresponding data chain node for secondary verification. Upon successful verification, the data chain control module calls the knowledge graph generation smart contract to generate a knowledge graph based on the corresponding data node's data, which is then fed back to the requesting party, completing an external data access.
[0066] Figure 3 This is a schematic diagram of a control module applicable to Embodiment 1 of the present invention, as shown below. Figure 3As shown, the control module participating in the chain can call various programs and smart contracts, including the aforementioned data access smart contract, authentication smart contract, and knowledge graph generation smart contract, to implement related functions. These functions include data access and data reading. Regarding data access, when a new node joins the data chain, the control module calls the data access smart contract. It randomly selects a master node from the management chain, and the master node uses an improved Byzantine algorithm to initiate consensus among all nodes in the management chain. If consensus is reached, the master node exchanges response data with the newly joined data node, and the new node joins the corresponding data chain, completing the data access. If consensus is not reached, the data node's access is rejected. Regarding data reading, when there is an external data access request, the control module activates the authentication smart contract to perform authorization authentication using a specific algorithm. The authentication result is divided into group authorization matching and final authorization matching. If the requesting end passes group authorization matching, it can read the attribute information stored by the corresponding management chain node; if it passes final authorization matching, it can read all information (including identifier, attributes, and encrypted information). Afterwards, the requesting end sends the encrypted information to the data chain where the corresponding data chain node is located for secondary verification. After successful verification, the control module calls the knowledge graph to generate a smart contract, generates graph data based on the data of the corresponding data node, and feeds it back to the requesting end to complete the data reading.
[0067] The technical solution of this invention adopts a management chain plus data chain architecture, which enables data access and other activities of the data chain to be included in the supervision and review of the management chain. While ensuring the security of agricultural product quality traceability data, it also effectively realizes the joint management and control of agricultural product quality and safety by multiple departments. Through the authentication and access control strategy for data reading, it can accurately identify the user's permission to use data, thereby improving the efficiency of data use while ensuring the security of agricultural product quality supervision data.
[0068] Example 2
[0069] Figure 4 This is a flowchart of a data node access method provided in Embodiment 2 of the present invention. This embodiment further explains and illustrates the method based on Embodiment 1 described above. Figure 4 As shown, the method includes:
[0070] S410. Randomly select a node in the management chain as the master node to initiate an access request. After the master node receives the access request, it initiates consensus with other nodes in the management chain.
[0071] When a node joins the data chain, an "access smart contract" is activated on the corresponding data chain management terminal. This contract selects a random node on the management chain as the master node and sends an access request. Upon receiving the request, the selected master node on the management chain initiates consensus using an improved Byzantine Fault Tolerance algorithm. If consensus is successful, the master node exchanges access response data with the data chain that issued the access request, including the new node's identification information, attribute information, and encrypted information, and stores them in their respective block nodes. The new node's identification information is the unique identifier ID of the consortium blockchain, generated by a 16-bit timestamp when the access request occurred; the attribute information identifies the data node's category and business information; and the encrypted information is the pair of keys agreed upon when accessing the data node.
[0072] S420. If consensus is successful, the master node exchanges access response data with the data chain that issued the access request, including the new node's identification information, attribute information, and ciphertext information, and stores them in their respective block nodes. The new node's identification information is the unique identifier ID of the consortium blockchain, generated based on the timestamp generated when the access request occurs; the attribute information identifies the new node's category information and business information; and the ciphertext information is the pair of secret keys agreed upon when accessing the new node.
[0073] In this embodiment of the invention, after the master node receives the access request, it initiates consensus with other nodes in the management chain, including:
[0074] The nodes are randomly and evenly grouped according to the total number of nodes. Each group has a candidate list and a non-candidate list. Candidate nodes are selected from the candidate list, and the remaining nodes in the candidate list are used as backup nodes. The master node and the candidate nodes construct a consensus network.
[0075] The master node sends a preparation message to the candidate nodes in the consensus network so that the candidate nodes can respond after receiving the preparation message. Nodes that do not respond or whose response message is incorrect are set as suspicious nodes.
[0076] When the total number of suspicious nodes is less than the set consensus network threshold, an execution message is sent to the candidate node in the consensus network so that the candidate node returns a verification result after receiving the execution message. When a preset number of verification messages indicating successful verification are received, consensus is confirmed.
[0077] When the total number of suspicious nodes is not less than the consensus network threshold, all suspicious nodes are moved to the non-candidate list, and the consensus network is reorganized.
[0078] The nodes in the management chain are dynamically grouped. For example, let the total number of nodes in the management chain be... These nodes are randomly divided into r groups, with the following grouping rules:
[0079] ;
[0080] Nodes within each group are labeled: nodes participating in consensus are labeled TY, and nodes not participating are labeled TN. Each group has a TY candidate list, selecting several nodes to participate in consensus based on their reputation. Initially, all nodes in the group are on the candidate list; nodes that fail to participate in consensus are labeled TN and removed from the TY candidate list. Nodes participating in consensus can be categorized as primary nodes, candidate nodes, consensus nodes, suspicious nodes, and backup nodes. Primary nodes are those that accept requests and initiate consensus; candidate nodes are those that participate in consensus other than primary nodes—when the primary node is functioning normally, candidate nodes participate normally, and when the primary node is unavailable, candidate nodes can replace it; suspicious nodes are those that passively participate in consensus, fail to forward information, or spread false information; backup nodes are those that replace consensus nodes. Generally, backup nodes do not participate in consensus; only when the number of consensus nodes falls below the threshold set by the consensus mechanism due to failure or becoming suspicious will backup nodes be included in the consensus process for negotiation.
[0081] The consensus process includes:
[0082] 1. Request Phase: External request information is sent to a master node in the management chain.
[0083] 2. Pre-prepare phase: After receiving the request information, the master node selects the top 50% of the nodes in each group as candidate nodes and the remaining nodes as backup nodes. The master node and all candidate nodes then build a consensus network.
[0084] 3. Prepare phase: The master node sends a prepare message to all nodes in the consensus network and receives responses. Nodes that do not respond or whose response messages are incorrect are set as suspicious nodes. The total number of suspicious nodes is f. When f is less than the set consensus network threshold, the process proceeds to the next phase. When f is greater than the set consensus network threshold, all suspicious nodes are marked as suspicious, and the process returns to the previous phase to reorganize the consensus network.
[0085] 4. Commit (Execution) Phase: The control module of the management chain sends an execution message to all nodes in the consensus network. After receiving the execution message, each node in the consensus network needs to return a verification message. When the control module receives 2f+1 successful verification messages, it can be considered that a consensus has been reached.
[0086] 5. Response Phase: The control module of the management chain sends the consensus response result to the requesting end. Each node in the group can be regarded as the consistent response result of the receiving node.
[0087] In this embodiment of the invention, the encrypted information is generated and used in the following manner:
[0088] The master node generates and stores the encryption function and the set of independent variables, constructs the equivalent function of the encryption function on the set of independent variables, and the new node stores the equivalent function;
[0089] In response to a data node access request for a new node, the system requests an encryption function and a random number belonging to the set of independent variables from the master node to calculate the ciphertext verification information.
[0090] The encrypted verification information and a random number are packaged into a data access request and sent to the data chain where the new node is located. The data chain calculates the verification value based on the encrypted verification information and the equivalent function, and compares the verification value with the encrypted verification information. If the difference is within the threshold, the encrypted verification passes; otherwise, the encrypted verification fails.
[0091] The master node generates an encryption function. and the set of values of the independent variable , build exist Equivalent function on ;
[0092] 2) Master node storage encryption function The equivalent function for storing newly accessed nodes ;
[0093] 3) When making a data node access request, the encryption function for that data node should first be requested from the management chain. and a random number And use this to calculate the ciphertext verification information. ; with k and The data access request is packaged and sent to the data chain where the data node resides; the data chain management module is based on... and equivalent function ,calculate Compare l with k. If the difference is within the threshold, the ciphertext verification passes and the access is valid. Otherwise, the ciphertext verification fails and access is denied.
[0094] In Embodiment 2 of this invention, when new quality supervision data is accessed, an improved Byzantine algorithm is applied for consensus. This ensures consensus efficiency while also incorporating more regulatory agencies into the consensus system, guaranteeing the accuracy and immutability of agricultural product quality traceability data and preventing regulatory loopholes. The mechanism for generating and using encrypted information, through encryption algorithms and a rigorous verification process, effectively prevents unauthorized access and tampering of data. Even if data is acquired during transmission or storage, its content cannot be deciphered without the correct key and verification process, thus ensuring the security and integrity of agricultural product quality and safety traceability data and ensuring that only authorized access parties can obtain the corresponding data.
[0095] Example 3
[0096] Figure 5 This is a flowchart of a data reading method provided in Embodiment 3 of the present invention. This embodiment further explains and illustrates the method based on Embodiment 1 above. The permissions include a first permission and a second permission. The second permission allows access to all information stored in the management chain node, while the first permission allows access to less information than the second permission. Figure 5 As shown, the method includes:
[0097] S510. Calculate the authentication result value of the data access request, and determine whether the data access request matches the first permission or the second permission based on the authentication result value.
[0098] S520. If the first permission is matched, display the data that the first permission allows to access. If the second permission is matched, send the encrypted information in the full information to the data chain where the corresponding data chain node is located for secondary verification based on the identifier information in the full information. After successful verification, generate a knowledge graph based on the data of the corresponding data node and provide feedback.
[0099] Among them, the first permission is the group permission, and the second permission is the final permission. When the requesting end is matched by the group permission, the requesting end can read the attribute information stored in the corresponding management chain node matched by the accessed request, thereby completing the external acquisition of summary information; when the requesting end is matched by the final permission, the requesting end can read all the information (including identification information, attribute information and encrypted information) stored in the corresponding management chain node matched by the accessed request.
[0100] In this embodiment of the invention, calculating the authentication result value of the data access request and determining whether the data access request matches the first permission or the second permission based on the authentication result value includes:
[0101] The authentication result value is calculated using the following formula:
[0102] ;
[0103] in, The identity verification result value is n, where n is the total number of agricultural product supervision links. Configure permissions for agricultural products at the i-th regulatory stage; For agricultural products, the requesting end claims access rights to data at the i-th regulatory stage; This establishes a matching relationship between the permission configuration for agricultural products at the i-th regulatory stage and the permission claimed by the requesting end. The value is [0,1]. =0 indicates a complete mismatch. =1 indicates a complete match;
[0104] Substitute the user information contained in the access request into the above formula to calculate the authentication result value;
[0105] The value of the authentication result determines whether the data access request matches the first or second permission.
[0106] The core of the authentication formula is based on the HMAC (Hash Message Authentication Code) algorithm. The user information sent in the data request is substituted into the formula to calculate the value of W0, which is then used to determine the user's permissions.
[0107] When 0 < When n ≤ n, the requesting end matches based on group permissions. In this case, the requesting end can read the attribute information stored in the corresponding management chain node matched by the accessed request, thereby obtaining some summary information about agricultural product quality and safety traceability data, meeting the needs of some scenarios with lower data sensitivity requirements.
[0108] when When =n, it represents the final authorization match. The requesting end can read all the information stored in the corresponding management chain node that matches the access request, including identification information, attribute information, and encrypted information. However, after obtaining the encrypted information, it still needs to be sent to the data chain where the corresponding data chain node resides for secondary verification. Only after successful verification can the complete traceability data be obtained. This mechanism ensures the security of highly sensitive data. If the value is 0, it means there is no match at all, and the data will be refused to be read to ensure that the data is not accessed illegally.
[0109] In this embodiment of the invention, generating a knowledge graph based on data from corresponding data nodes includes:
[0110] Extract the main object set based on the data node; traverse all data chains to extract the object set related to the main object;
[0111] Applying knowledge from the field of crops, design a set of relationships between subject and object;
[0112] Entities are extracted from the set of subject objects and the set of object relations to obtain the core entity set; relation entities are extracted from the set of subject and object relations to form the relation entity set; attribute entities are extracted based on and to form the attribute entity set;
[0113] Design a connection mechanism for the core entity set, relation entity set, and attribute entity set, establish a formal triplet ontology model, and use a knowledge graph representation language to describe the triplet ontology model to obtain a knowledge graph.
[0114] The requesting end sends the encrypted information to the corresponding data chain node for secondary verification based on the identification information. Upon successful verification, the data chain control module calls the knowledge graph generation smart contract to generate a knowledge graph based on the data from the corresponding data node, which is then fed back to the requesting end, thus completing an external data access. Utilizing models such as NER (Named Entity Recognition), casRel (a relation extraction model based on cascaded decoding), and MetaPad (a specific entity alignment model), entities and relationships are extracted from the data of the corresponding data node, constructing a triplet ontology (P, W, Q), and converting it into a knowledge graph in RDF (Resource Description Framework) format. For example, from jujube production data, entities such as "jujube origin," "pesticide use," and "harvesting time," as well as the relationships between them, such as "jujube - produced in - a certain location" and "jujube - used - a certain pesticide," can be identified.
[0115] The knowledge graph data generation and unified identification adopted in this embodiment of the invention can accurately and vividly trace the source data and its relationship with other data. While enhancing the visual appeal of the data display, it also enhances the understandability and operability of the traced data, making the data application more comprehensive.
[0116] Example 4
[0117] Figure 6 This is a schematic diagram of the structure of a blockchain-based agricultural product traceability data management device provided in Embodiment 4 of the present invention. Figure 6 As shown, the device includes:
[0118] Building unit 610 is used to build a consortium blockchain architecture consisting of a management chain and a data chain. Each data chain stores traceability data of at least one link in the agricultural product supply chain, and the management chain stores the data chain identification information of each data chain, the data node identification information on the data chain, and the encrypted exchange information of the data node data.
[0119] The node access unit 620 is used to send a request to the management chain corresponding to the data chain when a new node is added to a data chain, so that the nodes of the management chain can initiate consensus, and determine the access result of the new node based on the consensus result.
[0120] The data access unit 630 is used to respond to external data access requests, perform permission matching on the data access requests, assign permissions to the data access requests based on the matching results, and display the data of the data chain that is allowed to be accessed by the permission.
[0121] The blockchain-based agricultural product traceability data management device provided in this embodiment of the invention can execute the blockchain-based agricultural product traceability data management method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.
[0122] Example 5
[0123] Figure 7 A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0124] like Figure 7 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0125] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0126] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, central processing unit (CPU), graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as blockchain-based agricultural product traceability data management methods.
[0127] In some embodiments, the blockchain-based agricultural product traceability data management method can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the blockchain-based agricultural product traceability data management method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to execute the blockchain-based agricultural product traceability data management method by any other suitable means (e.g., by means of firmware).
[0128] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0129] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0130] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0131] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0132] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0133] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0134] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0135] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A blockchain-based method for managing agricultural product traceability data, characterized in that, include: A consortium blockchain architecture consisting of a management chain and a data chain is constructed, wherein each data chain stores traceability data of at least one link in the agricultural product supply chain, and the management chain stores the data chain identification information of each data chain, the data node identification information on the data chain, and the encrypted exchange information of the data node data. When a new node is added to a data link, a request is sent to the management chain corresponding to the data link to enable the nodes of the management chain to initiate consensus, and the access result of the new node is determined based on the consensus result. In response to an external data access request, the system performs permission matching on the data access request, assigns permissions to the data access request based on the matching result, and displays the data in the data chain that the permission allows to access. The permissions include a first permission and a second permission. The second permission allows access to all information stored in the management chain node, while the first permission allows access to less information than the second permission. Correspondingly, in response to an external data access request, permission matching is performed on the data access request. Based on the matching result, permissions are assigned to the data access request, and the data of the data chain that the permission allows to access is displayed, including: Calculate the authentication result value of the data access request, and determine whether the data access request matches the first permission or the second permission based on the authentication result value; If the first permission is matched, the data that the first permission allows to access is displayed. If the second permission is matched, the encrypted information in the all information is sent to the data chain where the corresponding data chain node is located for secondary verification based on the identification information in the all information. After successful verification, a knowledge graph based on the data of the corresponding data chain node is generated and fed back. The step of calculating the authentication result value of the data access request and determining whether the data access request matches the first permission or the second permission based on the authentication result value includes: The authentication result value is calculated using the following formula: ; in, The identity verification result value is n, where n is the total number of agricultural product supervision links. Configure permissions for agricultural products at the i-th regulatory stage; For agricultural products, the requesting end claims access rights to data at the i-th regulatory stage; This establishes a matching relationship between the permission configuration for agricultural products at the i-th regulatory stage and the permission claimed by the requesting end. The value is [0,1]. =0 indicates a complete mismatch. =1 indicates a complete match; Substitute the user information contained in the data access request into the above formula to calculate the authentication result value; The value of the authentication result determines whether the data access request matches the first permission or the second permission.
2. The method according to claim 1, characterized in that, The step of sending a request to the management chain corresponding to the data chain to initiate consensus among the nodes of the management chain, and determining the access result of the new node based on the consensus result, includes: A node in the management chain is randomly selected as the master node to initiate an access request. After the master node receives the access request, it initiates consensus with the other nodes in the management chain. If consensus is successful, the master node exchanges access response data with the data chain that issued the access request, including the new node's identification information, attribute information, and ciphertext information, and stores them in their respective block nodes. The new node's identification information is a unique identifier ID of the consortium blockchain, generated based on the timestamp generated when the access request occurs; the attribute information identifies the new node's category information and business information; and the ciphertext information is the pair of secret keys agreed upon when accessing the new node.
3. The method according to claim 2, characterized in that, The step of initiating consensus with other nodes in the management chain after the master node receives the access request includes: The nodes in the management chain are randomly and evenly grouped according to the total number of nodes. Each group has a candidate list and a non-candidate list. Candidate nodes are selected from the candidate list, and the remaining nodes in the candidate list are used as backup nodes. The master node and the candidate nodes build a consensus network. The master node sends a preparation message to the candidate nodes in the consensus network so that the candidate nodes can respond after receiving the preparation message. Nodes that do not respond or whose response message is incorrect are set as suspicious nodes. When the total number of suspicious nodes is less than the set consensus network threshold, an execution message is sent to the candidate node in the consensus network so that the candidate node returns a verification result after receiving the execution message. When a preset number of verification messages indicating successful verification are received, consensus is confirmed. When the total number of suspicious nodes is not less than the consensus network threshold, all suspicious nodes are moved to the non-candidate list, and the consensus network is reorganized.
4. The method according to claim 2, characterized in that, The encrypted information is generated and used in the following manner: The master node generates and stores the encryption function and the set of independent variables, constructs the equivalent function of the encryption function on the set of independent variables, and the new node stores the equivalent function; In response to the data node access request for the new node, the encryption function and a random number belonging to the set of independent variables are requested from the master node to calculate the ciphertext verification information; The encrypted verification information and the random number are packaged into the data access request and sent to the data chain where the new node is located. The data chain calculates the verification value based on the encrypted verification information and the equivalent function, and compares the verification value with the encrypted verification information. If the difference is within the threshold, the encrypted verification passes; otherwise, the encrypted verification fails.
5. The method according to claim 1, characterized in that, The generation of a knowledge graph based on data from corresponding data nodes includes: Based on the data chain node, extract the main object set; traverse all data chains to extract the object set related to the main object; Applying knowledge from the field of crops, design a set of relationships between subject and object; Entities are extracted from the set of subject objects and the set of object relationships to obtain a core entity set; relation entities are extracted from the set of subject and object relationships to form a relation entity set; attribute entities are extracted based on and to form an attribute entity set. Design the connection mechanism of the core entity set, the relation entity set, and the attribute entity set, establish a formal triple ontology model, and use a knowledge graph representation language to describe the triple ontology model to obtain the knowledge graph.
6. A blockchain-based agricultural product traceability data management device, characterized in that, include: The building unit is used to build a consortium blockchain architecture consisting of a management chain and a data chain. Each data chain stores traceability data of at least one link in the agricultural product supply chain, and the management chain stores the data chain identification information of each data chain, the data node identification information on the data chain, and the encrypted exchange information of the data node data. The node access unit is used to send a request to the management chain corresponding to the data chain when a new node is added to a data chain, so that the nodes of the management chain can initiate consensus, and determine the access result of the new node based on the consensus result; The data access unit is used to respond to external data access requests, perform permission matching on the data access requests, assign permissions to the data access requests based on the matching results, and display the data of the data chain that the permissions allow to access. The permissions include a first permission and a second permission. The second permission allows access to all information stored in the management chain node, while the first permission allows access to less information than the second permission. Correspondingly, when the data access unit responds to an external data access request, performs permission matching on the data access request, assigns permissions to the data access request based on the matching result, and displays the data of the data chain that the permission allows access to, it specifically performs the following: Calculate the authentication result value of the data access request, and determine whether the data access request matches the first permission or the second permission based on the authentication result value; If the first permission is matched, the data that the first permission allows to access is displayed. If the second permission is matched, the encrypted information in the all information is sent to the data chain where the corresponding data chain node is located for secondary verification based on the identification information in the all information. After successful verification, a knowledge graph based on the data of the corresponding data chain node is generated and fed back. When the data access unit performs the calculation of the authentication result value of the data access request and determines whether the data access request matches the first permission or the second permission based on the authentication result value, it specifically performs the following: The authentication result value is calculated using the following formula: ; in, The identity verification result value is n, where n is the total number of agricultural product supervision links. Configure permissions for agricultural products at the i-th regulatory stage; For agricultural products, the requesting end claims access rights to data at the i-th regulatory stage; This establishes a matching relationship between the permission configuration for agricultural products at the i-th regulatory stage and the permission claimed by the requesting end. The value is [0,1]. =0 indicates a complete mismatch. =1 indicates a complete match; Substitute the user information contained in the data access request into the above formula to calculate the authentication result value; The value of the authentication result determines whether the data access request matches the first permission or the second permission.
7. An electronic device, characterized in that, The electronic device includes: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the blockchain-based agricultural product traceability data management method according to any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the blockchain-based agricultural product traceability data management method according to any one of claims 1-5.
9. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the blockchain-based agricultural product traceability data management method according to any one of claims 1-5.
Citation Information
Patent Citations
Food production process traceability method and device and food circulation process traceability method and device
CN113610546A
Block chain copyright evidence storage system and method based on improved Byzantine algorithm
CN117951222A