An information verification method for food safety traceability
By dividing the hash groups of the link blockchain in the food safety traceability system and calculating the interchange ratio and change rate, filtering out the tampered data, solving the problem of constant hash value and achieving more accurate food traceability verification.
Patent Information
- Application Number
- CN202510525321.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-04-25
AI Technical Summary
In the food safety traceability system, the hash value remains unchanged after the tamper tampers with a certain part of the data, resulting in the inability to accurately identify whether the data has been tampered during information verification.
By obtaining the food processing data before and after food transportation, it is divided into several link blockchains, the hash value of each link blockchain is calculated, divided into hash groups, the rate of interchange and comparison change is calculated, the tampered food data is screened out, and the hash change sequence and interchange and comparison parameters are used for verification.
The accuracy of food safety traceability information verification is improved, and it can identify whether the tampered data in each link is tampered with. Through the comparison of food data with the same attribute and the newly added attribute, the tampered data can be accurately identified.
Smart Images

Figure CN120069905B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data analysis, and particularly relates to an information verification method for food safety traceability. Background Art
[0002] The food safety traceability system uses automatic identification technology and IT technology to monitor and record information on food in key links such as planting, processing, packaging, inspection, transportation, etc., and presents it to consumers in real time. The data of each link will be uploaded to the blockchain in real time, and each node records this information to generate a "block", which is linked to the previous block to form a chain, creating an immutable historical record; when performing data verification, each block is encrypted through a hash algorithm to ensure that the data in the blockchain cannot be changed. If the block data is tampered with, the hash value will change, resulting in the breakage of the chain, which can be immediately detected. However, with the development of computer technology, it is possible that after a tamperer tampers with a part of the data, the hash value of the block remains unchanged, thus causing it to be impossible to accurately identify whether it has been tampered with during information verification. Summary of the Invention
[0003] To solve the above problems, the present invention provides an information verification method for food safety traceability, and the method includes:
[0004] Obtain the food processing data before and after food transportation; the food processing data before and after food transportation includes all types of food data in the blockchain of several links;
[0005] Obtain the hash value of each link blockchain; divide the hash value of each link blockchain into several hash groups; obtain the intersection-union ratio of each hash group according to the change situation of the hash value character types between the hash groups in adjacent link blockchains; obtain the change rate of each hash group according to the change situation of the elements at different positions of the hash values between the hash groups in adjacent link blockchains; obtain all the changed hash groups of each link blockchain according to the difference situation of the change rates between the hash groups in adjacent link blockchains;
[0006] Obtain the descending hash change sequence and the maximum hash change sequence of each link blockchain before and after food transportation; perform screening according to the intersection-union ratio of each changed hash group of each link blockchain and the difference situation between the descending hash change sequence and the maximum hash change sequence of each link blockchain before and after food transportation to obtain the tampered food data after food transportation;
[0007] Verify the food processing data after food transportation based on the tampered food data after food transportation.
[0008] Preferably, the specific method for obtaining the hash value of each link blockchain includes:
[0009] Rehearse all types of food data in the first - link blockchain in a fixed order by humans to obtain the food data string of the first - link blockchain. Input the food data string of the first - link blockchain into the MD5 method to obtain the hash value of the first - link blockchain. For any type of food data in the second - link blockchain, if the any type of food data is of the same type as any type of food data in the first - link blockchain, record the any type of food data as the same - attribute food data of the second - link blockchain. If the any type of food data is of a different type from all types of food data in the first - link blockchain, record the any type of food data as the newly - added - attribute food data of the second - link blockchain. Input the string composed of all types of same - attribute food data of the second - link blockchain into the MD5 method to obtain the same - attribute hash value of the second - link blockchain. Input the string composed of all types of newly - added - attribute food data of the second - link blockchain into the MD5 method to obtain the new - attribute hash value of the second - link blockchain. Place the new - attribute hash value after the same - attribute hash value to form a combined string, and input it into the MD5 method to obtain the hash value of the second - link blockchain. And so on, obtain the hash values of all link blockchains.
[0010] Preferably, the method of dividing the hash value of each link blockchain into several hash groups includes the following specific method:
[0011] For the same - attribute hash value of the th link blockchain, divide it into 32 hash groups according to four elements in a 128 - bit hash value as a group. For the hash value of the th link blockchain, divide it into 32 hash groups according to four elements in the hash value as a group.
[0012] Preferably, the method of obtaining the intersection - union ratio of each hash group according to the change of the hash value character type between adjacent link blockchains includes the following specific method:
[0013] For the th hash group in the same - attribute hash value of the th link blockchain and the th hash group in the hash value of the th link blockchain, record the number of all hash value character types as the first quantity. For the th hash group in the same - attribute hash value of the <G th link blockchain and the th hash group in the hash value of the th link blockchain, record the number of all identical hash value character types as the second quantity. Take the ratio of the second quantity to the first quantity as the The intersection - union ratio of the th hash group among the same - attribute hash values of the blockchain in each link.
[0014] Preferably, the method for obtaining the change rate of each hash group according to the change of elements at different positions of the hash values between hash groups in adjacent - link blockchains includes the following specific steps:
[0015] If an element at any position between the th hash group in the same - attribute hash values of the blockchain in the th link and the th hash group in the hash values of the blockchain in the th link is the same element, denote the said any - position element as the same element; take the ratio of the number of the same elements between the th hash group in the same - attribute hash values of the blockchain in the th link and the th hash group in the hash values of the blockchain in the th link to 4 as the change rate of the th hash group in the same - attribute hash values of the blockchain in the th link.
[0016] Preferably, the method for obtaining all changed hash groups of each link's blockchain according to the difference in change rates between hash groups in adjacent - link blockchains includes the following specific steps:
[0017] Preset a change - parameter threshold . If the change rate of the th hash group in the same - attribute hash values of the blockchain in the th link is greater than the average value of the change rates of all hash groups in the same - attribute hash values of the blockchain in the th link; and the absolute value of the difference between the change rate of the th hash group in the same - attribute hash values of the blockchain in the th link and the change rate of the th hash group in the hash values of the blockchain in the th link is greater than or equal to the change - parameter threshold , denote the th hash group in the same - attribute hash values of the blockchain in the th link as a changed hash group.
[0018] Preferably, the method for obtaining the descending - order sequence of hash changes and the maximum - hash - change sequence of each link's blockchain before and after food transportation includes the following specific steps:
[0019] For the th link's blockchain before food transportation, take the The sequence formed by sorting all the change hash groups of the blockchain in each link in descending order of the change rate is denoted as the hash change descending sequence of the th link before food transportation; the change hash group with the largest change rate among all the change hash groups of the th link blockchain is denoted as the target hash group of the th link blockchain; the sequence formed by the target hash groups of all the link blockchains before food transportation is denoted as the maximum hash change sequence before food transportation;
[0020] For the th link blockchain after food transportation, the sequence formed by sorting all the change hash groups of the th link blockchain in descending order of the change rate is denoted as the hash change descending sequence of the th link blockchain after food transportation; the change hash group with the largest change rate among all the change hash groups of the th link blockchain is denoted as the target hash group of the th link blockchain; the sequence formed by the target hash groups of all the link blockchains after food transportation is denoted as the maximum hash change sequence after food transportation.
[0021] Preferably, the method for screening according to the intersection ratio of each change hash group of each link blockchain and the difference between the hash change descending sequence and the maximum hash change sequence of each link blockchain before and after food transportation to obtain the tampered food data after food transportation includes the following specific methods:
[0022] Preset an intersection ratio parameter and a number parameter . If the intersection ratio of the th change hash group of the th link blockchain is less than or equal to the intersection ratio parameter , the th change hash group of the th link blockchain is denoted as the tampered point;
[0023] Obtain the tampered link blockchain according to the difference between the hash change descending sequences of each link blockchain before and after food transportation;
[0024] Obtain the tampered data according to the difference between the maximum hash change sequences before and after food transportation;
[0025] Take the tampered point, the tampered link blockchain and the tampered data as the tampered food data after food transportation.
[0026] Preferably, the method for obtaining the tampered blockchain link according to the difference between the descending sequences of the hashing changes of the blockchain in each link before and after food transportation includes the following specific steps:
[0027] If the intersection-union ratio of all changed hash groups of the th link blockchain after food transportation is greater than the intersection-union ratio parameter , then use the permutation cycle algorithm to compare the descending sequence of the hashing changes of the th link blockchain before food transportation with the descending sequence of the hashing changes of the th link blockchain after food transportation to obtain the number of element exchanges. If the number of element exchanges is less than the number parameter , record the [[ID=X]] th link blockchain after food transportation as the same link blockchain; if the number of element exchanges is greater than or equal to the number parameter , record the th link blockchain as the non-same link blockchain after food transportation; if the ratio between the number of same link blockchains after food transportation and the number of all link blockchains after food transportation is less than the intersection-union ratio parameter , record all non-same link blockchains after food transportation as the tampered blockchain links.
[0028] Preferably, the method for obtaining the tampered data according to the difference between the maximum hashing change sequences before and after food transportation includes the following specific steps:
[0029] If the ratio between the number of same link blockchains after food transportation and the number of all link blockchains after food transportation is greater than or equal to the intersection-union ratio parameter , then use the permutation cycle algorithm to compare the maximum hashing change sequence before food transportation with the maximum hashing change sequence after food transportation to obtain the maximum number of element exchanges; if the maximum number of element exchanges is greater than or equal to the number parameter , record the food processing data after food transportation as the tampered data.
[0030] Note: In the translation, the tags -
[0030] are kept as they are because they are 7 - digit tags that need to be preserved exactly. Also, the variable "X" in the translation of step 13 is used to represent the placeholder that should be filled with the actual number in the original text. Since the original text has some placeholders like , , etc., the translation tries to maintain the same structure and use similar placeholders where appropriate for better readability and to follow the rules. The actual meaning of these placeholders would be determined by the context of the original patent text.The beneficial effects of the technical solution of the present invention are as follows: According to the difference in the change rate between hash groups in adjacent blockchain links, all changed hash groups of each blockchain link are obtained; screening is performed based on the intersection ratio of each changed hash group of each blockchain link and the difference between the descending hash change sequence and the maximum hash change sequence of each blockchain link before and after food transportation to obtain the tampered food data after food transportation; verifying the food processing data after food transportation based on the tampered food data after food transportation; thereby identifying whether the food data in each blockchain link is tampered. By dividing the information in different blockchain links into two parts, namely the same attribute food data and the newly added attribute food data, and then comparing the hash value changes of each part with the previous link, the tampered food data after food transportation is obtained, thereby improving the accuracy of the information verification result of food safety traceability. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0032] Figure 1 It is a flowchart of the steps of an information verification method for food safety traceability according to the present invention;
[0033] Figure 2 It is a flowchart of the characteristic relationship of an information verification method for food safety traceability according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0034] In order to further elaborate on the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following will, in conjunction with the accompanying drawings and preferred embodiments, describe in detail the specific implementation manner, structure, characteristics and effects of an information verification method for food safety traceability proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures or characteristics in one or more embodiments can be combined in any suitable form.
[0035] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present invention belongs.
[0036] The following will specifically describe the specific solution of an information verification method for food safety traceability provided by the present invention in conjunction with the accompanying drawings.
[0037] Please refer to Figure 1, which shows a step flowchart of an information verification method for food safety traceability provided by an embodiment of the present invention. The method includes the following steps:
[0038] Step S001: Obtain the food processing data before and after food transportation; the food processing data before and after food transportation includes all types of food data in the blockchain of several links.
[0039] Specifically, first, it is necessary to collect the food processing data before and after food transportation. The specific process is as follows:
[0040] Before food transportation, collect the production batch number in the production link blockchain, the processing date in the processing link blockchain, the ingredients and raw material sources of the food in the storage link blockchain, the ambient temperature and humidity in the transportation link blockchain, and the seller and end user in the sales link blockchain as the food processing data before food transportation;
[0041] After food transportation, collect the production batch number in the production link blockchain, the processing date in the processing link blockchain, the ingredients and raw material sources of the food in the storage link blockchain, the ambient temperature and humidity in the transportation link blockchain, and the seller and end user in the sales link blockchain as the food processing data after food transportation.
[0042] So far, the food processing data before and after food transportation is obtained through the above method.
[0043] Step S002: Obtain the hash value of each link blockchain; divide the hash value of each link blockchain into several hash groups; obtain the intersection ratio of each hash group according to the change situation of the hash value character type between the hash groups in adjacent link blockchains; obtain the change rate of each hash group according to the element change situation at different positions of the hash values between the hash groups in adjacent link blockchains; obtain all the changed hash groups of each link blockchain according to the change rate difference situation between the hash groups in adjacent link blockchains.
[0044] It should be noted that the existing process for users to perform integrity verification through QR codes, barcodes, etc. on food packaging is as follows: Each block is encrypted through a hash algorithm to ensure that the data in the blockchain cannot be changed. If the block data is tampered with, the hash value will change, resulting in a broken chain and being immediately detected; however, with the development of computer hardware and software technologies, there is a probability that a tamperer can tamper with some data, but the hash value of the block remains unchanged. Therefore, in this embodiment, by combining the data changes of food in different link blockchains, the verification of the link blockchain is increased, so as to ensure that the tampered data can be accurately identified.
[0045] Preferably, in some implementation manners of the embodiment of the present invention, the specific method for obtaining the hash value of each link blockchain is:
[0046] Rehearse all types of food data in the blockchain of the first link in a fixed order by humans to obtain the food data string of the blockchain of the first link, and input the food data string of the blockchain of the first link into the MD5 method to obtain the hash value of the blockchain of the first link;
[0047] For any type of food data in the blockchain of the second link, if the any type of food data is of the same type as any type of food data in the blockchain of the first link, record the any type of food data as the same-attribute food data of the blockchain of the second link; if the any type of food data is of different types from all types of food data in the blockchain of the first link, record the any type of food data as the newly added attribute food data of the blockchain of the second link; input the string composed of all types of same-attribute food data of the blockchain of the second link into the MD5 method to obtain the same-attribute hash value of the blockchain of the second link; input the string composed of all types of newly added attribute food data of the blockchain of the second link into the MD5 method to obtain the new-attribute hash value of the blockchain of the second link; place the new-attribute hash value after the same-attribute hash value to form a combined string, and input it into the MD5 method to obtain the hash value of the blockchain of the second link;
[0048] And so on, obtain the hash values of the blockchains of all links.
[0049] Among them, the MD5 method is a prior art, and this embodiment will not elaborate here too much.
[0050] It should be noted that in the process of obtaining the hash value of each link blockchain above, data that can be verified and has higher security is further obtained, avoiding being cracked by attackers; in this embodiment, the data is further verified through the relationship between the change hash group of the same-attribute food data and the degree of change of the change hash group. Even if an attacker can make the hash values of a certain link blockchain the same, the hash values during transportation are different, that is, it is very difficult to ensure that the hash value of each same-attribute food data is the same as that of the previous link blockchain.
[0051] Preferably, in some implementation manners of the embodiment of the present invention, since the hash values obtained by the MD5 method are all 128-bit, the 128-bit hash values are usually represented by 32-bit hexadecimal numbers; in hexadecimal representation, each digit can be a number from 0 to 9 or a letter from A to F, and there are 16 possible characters in total. Therefore, the 128-bit hash value can be represented by 32 hexadecimal characters, and each character has 16 possibilities; then the specific method of dividing the hash value of each link blockchain into several hash groups is as follows:
[0052] The same - attribute hash values of the th link of the blockchain are divided into 32 hash groups according to four elements in a 128 - bit hash value as a group; the hash values of the th link of the blockchain are divided into 32 hash groups according to four elements in the hash value;
[0053] Preferably, in some implementation manners of the embodiments of the present invention, the specific method for obtaining the intersection - union ratio of each hash group according to the change situation of the hash - value character types between the hash groups in adjacent links of the blockchain is as follows:
[0054] The number of all hash - value character types in the th hash group of the same - attribute hash values of the th link of the blockchain and the th hash group of the hash values of the th link of the blockchain is recorded as the first quantity; the number of all the same hash - value character types in the th hash group of the same - attribute hash values of the th link of the blockchain and the th hash group of the hash values of the th link of the blockchain is recorded as the second quantity; the ratio of the second quantity to the first quantity is used as the intersection - union ratio of the th hash group of the same - attribute hash values of the th link of the blockchain;
[0055] Preferably, in some implementation manners of the embodiments of the present invention, the specific method for obtaining the change rate of each hash group according to the change situation of the elements at different positions of the hash values between the hash groups in adjacent links of the blockchain is as follows:
[0056] If any one of the elements at any position between the th hash group of the same - attribute hash values of the th link of the blockchain and the th hash group of the hash values of the th link of the blockchain is the same element, the said any one of the elements is recorded as the same element; the ratio of the number of the same elements between the th hash group of the same - attribute hash values of the th link of the blockchain and the th hash group of the hash values of the th link of the blockchain to 4 is used as the change rate of the th hash group of the same - attribute hash values of the th link of the blockchain;
[0057] Preferably, in some implementation manners of the embodiments of the present invention, in order to ensure the disorderliness of the changed hash groups, it is difficult for an attacker to simulate such disorderliness when not stealing the complete real data. Even if the real data is stolen, it is difficult to find forged data that can make the data at the disordered positions obtained from the original data the same. Then, according to the difference in the change rate between the hash groups in the adjacent-link blockchains, the specific method for obtaining all the changed hash groups of each link blockchain is as follows:
[0058] Preset a change parameter threshold , where in this embodiment, is taken as an example for description, and this embodiment does not make specific limitations, where is determined according to the specific implementation situation;
[0059] If the change rate of the th hash group in the same-attribute hash values of the th link blockchain is greater than the average value of the change rates of all the hash groups in the same-attribute hash values of the th link blockchain; and the absolute value of the difference between the change rate of the th hash group in the same-attribute hash values of the th link blockchain and the change rate of the th hash group in the hash values of the th link blockchain is greater than or equal to the change parameter threshold , then the th hash group in the same-attribute hash values of the th link blockchain is recorded as a changed hash group;
[0060] Thus, all the changed hash groups of each link blockchain are obtained through the above method.
[0061] Step S003: Obtain the descending sequence of hash changes and the maximum hash change sequence of each link blockchain before and after food transportation; screen according to the intersection ratio of each changed hash group of each link blockchain and the difference between the descending sequence of hash changes and the maximum hash change sequence of each link blockchain before and after food transportation, and obtain the tampered food data after food transportation.
[0062] Preferably, in some implementation manners of the embodiments of the present invention, the specific method for obtaining the descending sequence of hash changes and the maximum hash change sequence of each link blockchain before and after food transportation is as follows:
[0063] For the th link blockchain before food transportation, the sequence formed by sorting all the changed hash groups of the th link blockchain in descending order of the change rate is recorded as the The descending sequence of hash changes of each link in the blockchain; the change hash group with the largest change rate among all change hash groups of the th link in the blockchain is denoted as the target hash group of the th link in the blockchain; the sequence composed of the target hash groups of each link in the blockchain before food transportation is denoted as the maximum hash change sequence before food transportation;
[0064] Similarly, obtain the descending sequence of hash changes and the maximum hash change sequence of each link in the blockchain after food transportation.
[0065] Preferably, in some implementation manners of the embodiments of the present invention, screening is performed according to the intersection ratio of each change hash group of each link in the blockchain and the difference between the descending sequence of hash changes and the maximum hash change sequence of each link in the blockchain before and after food transportation. The specific method for obtaining the tampered food data after food transportation is as follows:
[0066] Preset an intersection ratio parameter and a number parameter , where in this embodiment, and are used as examples for description, and this embodiment does not make specific limitations. Among them, and are determined according to the specific implementation situation;
[0067] If the intersection ratio of the th change hash group of the th link in the blockchain after food transportation is less than or equal to the intersection ratio parameter , the th change hash group of the th link in the blockchain after food transportation is denoted as the tampered point;
[0068] If the intersection ratio of all change hash groups of the th link in the blockchain after food transportation is greater than the intersection ratio parameter , then use the permutation cycle algorithm to compare the descending sequence of hash changes of the th link in the blockchain before food transportation with the descending sequence of hash changes of the th link in the blockchain after food transportation to obtain the number of element exchanges. If the number of element exchanges is less than the number parameter , the th link in the blockchain after food transportation is denoted as the same link blockchain; if the number of element exchanges is greater than or equal to the number parameter , the The blockchain of each link after food transportation is denoted as the non - identical link blockchain after food transportation; if the ratio between the number of identical link blockchains after food transportation and the number of all link blockchains after food transportation is less than the intersection - union ratio parameter , all non - identical link blockchains after food transportation are denoted as tampered link blockchains;
[0069] If the ratio between the number of identical link blockchains after food transportation and the number of all link blockchains after food transportation is greater than or equal to the intersection - union ratio parameter , then the permutation cycle algorithm is used to compare the maximum hash change sequence before food transportation and the maximum hash change sequence after food transportation to obtain the maximum number of element swaps; if the maximum number of element swaps is greater than or equal to the number parameter , the food processing data after food transportation is denoted as tampered data;
[0070] The tampered points, tampered link blockchains and tampered data are all regarded as the tampered food data after food transportation.
[0071] Thus, the tampered food data after food transportation is obtained through the above - mentioned method.
[0072] Step S004: Verify the food processing data after food transportation based on the tampered food data after food transportation.
[0073] Preferably, in some implementation manners of the embodiment of the present invention, the specific method for verifying the food processing data after food transportation based on the tampered food data after food transportation is:
[0074] Mark the tampered points, tampered link blockchains and tampered data in the food processing data after transportation, and immediately isolate the relevant data. Search for the front and back links of the data chain through the traceability system to determine the source and scope of the tampering. It can be traced through information such as timestamps, IP addresses, operators, etc.; the system should send an alarm to relevant personnel to notify the occurrence of the data tampering event, and finally restore the correct tampered data through the backup system.
[0075] Please refer to Figure 2 , which shows a characteristic relationship flowchart of an information verification method for food safety traceability;
[0076] Thus, this embodiment is completed.
[0077] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A food safety traceability information verification method, characterized in that: The method comprises the following steps: Obtaining food processing data before and after food transportation; the food processing data before and after food transportation includes all types of food data in the blockchain of several links; Obtain the hash value of each blockchain link; divide the hash value of each blockchain link into several hash groups; obtain the intersection-and-union ratio of each hash group based on the change in the character type of the hash values between hash groups in adjacent blockchain links; obtain the change rate of each hash group based on the change in the elements at different positions of the hash values between hash groups in adjacent blockchain links; obtain all the changed hash groups of each blockchain link based on the difference in the change rates between hash groups in adjacent blockchain links; Obtain the hash change descending sequence and the maximum hash change sequence of each link of the blockchain before and after food transportation; filter based on the intersection-to-union ratio of each change hash group of each link of the blockchain, as well as the difference between the hash change descending sequence and the maximum hash change sequence of each link of the blockchain before and after food transportation, to obtain the tampered food data after food transportation; Verifying food processing data after food transportation based on tampered food data after food transportation; The specific method for obtaining the hash value of each link of the blockchain is as follows: All types of food data in the first link blockchain are rehearsed in an artificially fixed order to obtain the food data string of the first link blockchain, and the food data string of the first link blockchain is input into the MD5 method to obtain the hash value of the first link blockchain; for any type of food data in the second link blockchain, if the any type of food data is the same type as any type of food data in the first link blockchain, the any type of food data is recorded as the same-attribute food data of the second link blockchain; if the any type of food data is a different type from all types of food data in the first link blockchain, the any type of food data is recorded as the newly added attribute food data of the second link blockchain; the string composed of all types of same-attribute food data of the second link blockchain is input into the MD5 method to obtain the same-attribute hash value of the second link blockchain; the string composed of all types of newly added attribute food data of the second link blockchain is input into the MD5 method to obtain the new attribute hash value of the second link blockchain; the new attribute hash value is placed after the same-attribute hash value to form a joint string, and input into the MD5 method to obtain the hash value of the second link blockchain; and so on, to obtain the hash values of all link blockchains.
2. The information verification method for food safety traceability according to claim 1, characterized in that: The method of dividing the hash value of each link blockchain into several hash groups includes: The first The hash values of the blockchain with the same attributes in each link are divided into 32 hash groups according to the four elements in the 128-bit hash value as a group; The hash value of each link of the blockchain is divided into 32 hash groups according to the four elements in the hash value.
3. The information verification method for food safety traceability according to claim 1, characterized in that: The method of obtaining the intersection-and-union ratio of each hash group according to the change of the hash value character type between the hash groups in the adjacent link blockchains includes the following specific methods: The first The hash value of the same attribute in the blockchain of each link The hash group and The hash value of the blockchain in each link The number of all hash value character types in the hash group is recorded as the first number; the The hash value of the same attribute in the blockchain of each link The hash group and The hash value of the blockchain in each link The number of all the same hash value character types in the hash group is recorded as the second number; the ratio of the second number to the first number is recorded as the first number. The hash value of the same attribute in the blockchain of each link The intersection-union ratio of hash groups.
4. The information verification method for food safety traceability according to claim 1, characterized in that: The method of obtaining the change rate of each hash group based on the change of elements at different positions of the hash values between hash groups in adjacent link blockchains includes the following specific methods: Jordi The hash value of the same attribute in the blockchain of each link The hash group and The hash value of the blockchain in each link If the elements at any position between the hash groups are the same element, the elements at any position are recorded as the same element; The hash value of the same attribute in the blockchain of each link The hash group and The hash value of the blockchain in each link The ratio of the number of identical elements between the hash groups to 4 is recorded as The hash value of the same attribute in the blockchain of each link The rate of change of each hash group.
5. The method for verifying food safety traceability according to claim 1, characterized in that: The specific method of obtaining all changed hash groups of each link blockchain according to the difference in change rates between hash groups in adjacent link blockchains is as follows: Preset a change parameter threshold , if The hash value of the same attribute in the blockchain of each link The change rate of the hash group is greater than The average of the change rates of all hash groups in the same attribute hash value of the blockchain in the first link; and The hash value of the same attribute in the blockchain of each link The rate of change of the hash group is The hash value of the blockchain in each link The absolute value of the difference between the change rates of the hash groups is greater than or equal to the change parameter threshold , will The hash value of the same attribute in the blockchain of each link The hash groups are recorded as change hash groups.
6. The method for verifying food safety traceability according to claim 1, characterized in that: The specific method for obtaining the descending hash change sequence and the maximum hash change sequence of each link of the blockchain before and after food transportation includes: Before food transportation The blockchain will The sequence of all the changes in the blockchain in each link is sorted from large to small according to the change rate, and recorded as the first link before food transportation. The hash changes of the blockchain in each link are in descending order; The change hash group with the largest change rate among all the change hash groups in the blockchain of the link is recorded as The target hash group of the blockchain of each link; the sequence composed of the target hash groups of the blockchain of all links before food transportation is recorded as the maximum hash change sequence before food transportation; For food after transportation The blockchain will The sequence of all the changes in the blockchain in each link is sorted from large to small according to the change rate, and recorded as the first link after the food is transported. The hash changes of the blockchain in each link are in descending order; The change hash group with the largest change rate among all the change hash groups in the blockchain of the link is recorded as The target hash group of the blockchain of each link; the sequence composed of the target hash groups of the blockchain of all links after food transportation is recorded as the maximum hash change sequence after food transportation.
7. The method for verifying food safety traceability according to claim 1, characterized in that: The method of screening based on the intersection-to-union ratio of each change hash group of each link blockchain and the difference between the hash change descending sequence and the maximum hash change sequence of each link blockchain before and after food transportation to obtain the tampered food data after food transportation includes the following specific methods: Preset an IoU parameter and the number of parameters , if The first link of the blockchain The IoU ratio of the hash group is less than or equal to the IoU parameter , will The first link of the blockchain The changed hash group is recorded as the tampered point; Obtain the blockchain of the tampered link based on the difference between the hash change descending sequence of each link of the blockchain before and after food transportation; Obtain tampered data based on the difference between the maximum hash change sequence before and after food transportation; The tampered points, tampered link blockchains and tampered data will all be regarded as tampered food data after food transportation.
8. The method for verifying food safety traceability information according to claim 7, characterized in that: The specific method of obtaining the tampered link blockchain based on the difference between the hash change descending sequence of each link blockchain before and after food transportation is as follows: If the food is transported The intersection-to-union ratio of all hash groups of the blockchain in each link is greater than the intersection-to-union ratio parameter , then use the permutation ring algorithm to calculate the first The descending sequence of the hash changes of the blockchain in each link is consistent with the first The hash changes of the blockchain in each link are compared in descending order to obtain the number of element swaps. If the number of element swaps is less than the number parameter , the first The blockchains of the same links are recorded as the blockchains of the same link; If the number of element swaps is greater than or equal to the number parameter , will The link blockchain is recorded as the non-identical link blockchain after food transportation; if the ratio between the number of identical link blockchains after food transportation and the number of link blockchains after all food transportation is less than the intersection ratio parameter , all non-identical link blockchains after food transportation are recorded as tampered link blockchains.
9. The method for verifying food safety traceability information according to claim 7, characterized in that: The method of obtaining the tampered data based on the difference between the maximum hash change sequence before and after the food is transported includes the following specific methods: If the ratio between the number of blockchains in the same link after food transportation and the number of blockchains in all links after food transportation is greater than or equal to the intersection-and-union ratio parameter , then use the permutation ring algorithm to compare the maximum hash change sequence before food transportation with the maximum hash change sequence after food transportation to obtain the maximum number of element swaps; if the maximum number of element swaps is greater than or equal to the number parameter , the food processing data after food transportation is recorded as tampered data.
Citation Information
Patent Citations
Data integrity verification method and system based on block chain technology
CN115618428A