A blockchain-based food traceability method

By using blockchain technology for end-to-end encrypted association and hash chain design, the problems of insufficient data credibility and low traceability efficiency in food traceability are solved, realizing the authenticity and security of food traceability information, quickly tracing the flow of food, and improving traceability efficiency and responsibility definition.

CN121146796BActive Publication Date: 2026-04-24四川远方云天食品科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
四川远方云天食品科技有限公司
Filing Date
2025-11-18
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

Existing food traceability solutions suffer from insufficient data credibility and security, supply chain information gaps, lack of data verification mechanisms, chaotic traceability label management, and imperfect timestamp and node confirmation mechanisms, resulting in low traceability efficiency and difficulty in defining responsibilities.

Method used

Blockchain technology is used for end-to-end encrypted association. A unique identifier is generated through a hash algorithm and confirmed by timestamps and nodes to ensure data immutability. The UUIDv4 algorithm is used to generate a unique identifier and bind it to the food unit, building a hash chain association to ensure data integrity and the continuity of the traceability link.

Benefits of technology

It ensures the authenticity and security of food traceability information, enables rapid tracking of food circulation, improves traceability efficiency and the credibility of query results, clearly defines responsibilities, and reduces the complexity of cross-process data integration and information confirmation time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121146796B_ABST
    Figure CN121146796B_ABST
Patent Text Reader

Abstract

The application relates to a kind of food traceability methods based on blockchain, collect production data and generate unique data primary key and identification, after encryption chain binding with food batch;Correlation production link data, collect processing data and secondary hash generation processing link data chain, after chain binding food unit;Identify processing link identification collection transportation data, after progressive encryption by chain correlation and time stamp, generate transportation link identification and record handover information;After checking all chain data, collect sales data, form a closed loop correlation full-link Merkle tree, after encryption chain generation sales link identification and trigger multi-node confirmation;Through the query terminal initiates permission verification request, after blockchain chain verification and local hash verification, according to time axis, complete traceability link containing handover node, responsible person and equipment information is displayed.The application realizes the full life cycle of food traceability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the fields of Internet of Things and blockchain technology, and in particular relates to a blockchain-based food traceability method. Background Technology

[0002] Food safety is related to public health, market order, and social stability. Establishing a fully traceable food traceability system is a core means of ensuring food safety. With consumers increasingly demanding transparency regarding food sources and regulatory authorities requiring more refined oversight of the food supply chain, traditional food traceability models are no longer sufficient to meet current application needs. The industry urgently requires technological innovation to overcome existing bottlenecks.

[0003] Current mainstream food traceability solutions mainly fall into two categories: one is traceability systems based on centralized databases, where enterprises or third-party institutions build centralized servers to store data from each stage; the other is preliminary attempts at traceability incorporating blockchain technology, but these mostly remain at the level of putting basic data on the chain and have not formed a complete technological closed loop. These solutions have revealed many prominent problems in practical applications:

[0004] I. Insufficient data credibility and security.

[0005] The core flaw of traditional centralized traceability systems lies in the vulnerability of data to tampering or forgery. Because data is centrally stored on a single server, companies may arbitrarily modify production and processing records to cover up quality issues, and external attacks can lead to data loss or leakage, leaving consumers unable to verify the authenticity of traceability information. Even when some solutions employ simple encryption methods, the lack of a distributed consensus mechanism makes them vulnerable to malicious tampering. Furthermore, data at each stage is often transmitted in plaintext or with weak encryption, posing a security risk of interception and alteration, thus failing to guarantee the confidentiality and integrity of traceability data.

[0006] Second, information is broken at various stages of the supply chain, and the traceability link is incomplete.

[0007] The food supply chain encompasses multiple independent stages, including production, processing, transportation, and sales. Current solutions often employ separate data recording systems for each stage, lacking standardized information linkage mechanisms. For example, raw material information in the production stage is not effectively linked to process data in the processing stage; temperature and humidity data in the transportation stage are disconnected from warehousing records in the sales stage, making it impossible to establish continuous evidence for traceability. In the event of a food safety issue, it is difficult to quickly pinpoint the problematic stage, resulting in low traceability efficiency and hindering accurate accountability. Furthermore, inconsistent data formats across stages increase the difficulty of cross-stage data integration, further exacerbating the problem of information silos.

[0008] Third, the lack of a data verification mechanism makes it difficult to guarantee the reliability of query results.

[0009] Existing traceability solutions often lack end-to-end data verification mechanisms. When consumers or regulatory authorities query traceability information, they can only passively receive the displayed data and cannot verify whether the data remained intact during transmission and storage. While some blockchain traceability solutions have implemented data on-chain, they lack hash chain association and node confirmation mechanisms, making it impossible to technically prove that the data has not been tampered with. Furthermore, the lack of local verification capabilities during the query process means that the query terminal relies on the single feedback from the blockchain node. If a node is attacked or malfunctions, the query results may be distorted, reducing the credibility of the traceability system.

[0010] Fourth, the management of traceability labels is chaotic, and the efficiency of cross-linking is low.

[0011] Currently, food traceability labels mostly use simple QR codes or barcodes, which can only store basic batch information and cannot form a unique mapping with data at each stage. During supply chain handover, labels are easily copied and replaced, and it is difficult to verify the authenticity of the binding relationship between the label and the food unit. At the same time, the lack of unified generation rules and verification standards for labels at each stage makes it difficult for transportation and sales to quickly and accurately identify the traceability data corresponding to upstream labels, prolonging handover time and reducing supply chain efficiency. In addition, the binding method between labels and data lacks encryption protection, posing a risk of label misuse and data forgery.

[0012] Fifth, the timestamp and node confirmation mechanism is imperfect, making it difficult to define responsibilities.

[0013] In existing solutions, the time recording of data at each stage relies heavily on the local clock of a single node, which may lead to time tampering or desynchronization issues, making it impossible to accurately reconstruct the true timeline of food circulation. Furthermore, the lack of a cross-stage node confirmation mechanism means that when food safety issues arise, companies at each stage may shift blame, making it difficult to determine responsibility due to the inability to provide valid node signature confirmation evidence. While some solutions introduce timestamps, they fail to implement progressive encryption and chain-like association, failing to form an immutable chain of temporal evidence, thus affecting the authority and legal validity of traceability.

[0014] Therefore, this invention aims to provide a food traceability method based on blockchain technology, which features end-to-end encrypted association, immutable data, and joint confirmation by nodes. Summary of the Invention

[0015] The purpose of this invention is to provide a food traceability method based on blockchain technology, which solves the technical problems existing in the prior art by providing a food traceability method based on blockchain technology with full-link encrypted association, immutable data, and joint confirmation by nodes.

[0016] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:

[0017] A blockchain-based food traceability method includes the following steps:

[0018] S1: Collect production data, generate a unique primary key for the production process data, generate a hash value based on a hash algorithm, and upload the primary key for the production process data and the original production data summary to the blockchain distributed ledger to generate a unique identifier for the production process and establish a binding relationship with the corresponding food batch.

[0019] S2: Read the unique identifier of the food batch's production process and associate it with the primary key of the production process data. Collect the processing process data, perform a secondary hash operation, generate a processing process data chain, and upload it to the blockchain with the verification information of the primary key of the production process data. Generate a unique identifier for the processing process and bind it to the processed food unit.

[0020] S3: The transport carrier identifies the unique identifier of the processing stage and collects the transport stage data. It links the transport stage data with the processing stage data chain, and uploads it to the blockchain after progressive encryption with timestamps, along with the processing stage identifier verification result. It generates a unique identifier for the transport stage and records the handover timestamp.

[0021] S4: Scan the unique identifier of the transportation link, retrieve and pre-verify the full-link data, collect key data of the sales link, establish a closed-loop association between the sales data and the transportation link data chain, encrypt the data and upload it to the blockchain together with the full-link data chain, generate a unique identifier of the sales link, and trigger the node confirmation mechanism of each link of production-processing-transportation-sales.

[0022] S5: The query terminal initiates a query request, the blockchain node parses the traceability path, retrieves the hash value sequence of the corresponding full-link data chain for chain verification, returns the original data summary of each link and the data primary key of the corresponding link, the query terminal confirms the data integrity through local hash operation, and displays the complete traceability link according to the timeline.

[0023] Preferably, the specific process of collecting production data and generating a unique primary key for production process data in step S1 is as follows:

[0024] S11: Deploy IoT sensor groups in food production sites, including planting bases and breeding farms, to collect production data including environmental parameters, production operation records, and raw material traceability information;

[0025] S12: Generate a unique primary key for production process data by combining the three types of collected production data according to the rule of production batch + timestamp + equipment number; the production batch is the unique production identifier of the batch of food; the timestamp is the precise time of data aggregation; the equipment number is the unique code of the collecting equipment; the three are concatenated to form a non-repeating string, which serves as the unique index key for the production process data of the batch of food, i.e., the unique primary key for production process data.

[0026] Preferably, the specific process of generating a hash value based on a hash algorithm in step S1, uploading it to the blockchain distributed ledger along with the primary key of the production process data and the original production data summary, generating a unique identifier for the production process, and establishing a binding relationship with the corresponding food batch is as follows:

[0027] S13: The aggregated production data is hashed and encrypted using the SHA-256 algorithm to generate a 256-bit fixed-length encrypted hash value. At the same time, the original data is compressed using the LZ77 algorithm to generate the original data digest.

[0028] S14: Package the encrypted hash value, the primary key of the production process data, and the original data digest and upload them to the production node of the blockchain; the production node of the blockchain performs format verification on the uploaded information, and writes it into the distributed ledger after the verification is passed, forming the initial block of the production process. The block also records the timestamp of the data upload and the digital signature of the production node.

[0029] S15: Based on the primary key of the production process data, a unique identifier for the production process is generated using the UUIDv4 algorithm. This identifier is a unique 128-bit string, and a summary information of the primary key of the production process data is embedded during generation, so that the identifier and the primary key form a one-to-one mapping relationship.

[0030] S16: Establish the binding relationship between the unique identifier of the production process and the corresponding food batch using an asymmetric encryption algorithm: The production node uses its own private key to encrypt and sign the combined string of "unique identifier of production process + food batch number" to generate a binding signature; the binding signature, the production node's public key, and the plaintext "unique identifier of production process + food batch number" are uploaded to the blockchain.

[0031] Preferably, the specific process of step S2 is as follows:

[0032] S21: The processing equipment reads the unique identifier of the production process, and reads the unique identifier of the production process generated in S1;

[0033] S22: Through the blockchain node interface, the unique identifier of the production process is sent to the processing node of the blockchain: The processing node parses the identifier and extracts the primary key digest of the production process data contained therein;

[0034] Based on the digest, the system retrieves the corresponding primary key of the production process data in the blockchain distributed ledger, and returns the primary key and the associated encrypted hash value of the production process to the processing equipment, thereby realizing the automatic association between the production process data and the processing process.

[0035] S23: Collect processing data including processing process parameters and digital certificate information of processing personnel, and generate a temporary index by processing equipment number + timestamp;

[0036] S24: Encrypt the associated production-processing data combination to form a coherent data chain:

[0037] The SHA-256 algorithm is used to generate hash values ​​for the processed data.

[0038] The encrypted hash value of the production process in S1 is concatenated with the hash value of the above processing data in the order of production hash + processing hash. The concatenated string is then subjected to SHA-256 hash operation again to generate the root hash of the processing process data chain.

[0039] S25: The processing equipment packages and uploads the root hash, the compressed processing data summary, and the verification information of the primary key of the production process data to the processing node of the blockchain;

[0040] S26: Generate a unique identifier for the processing stage and bind it to the food unit: Based on the root hash of the processing stage data chain and the unique identifier for the production stage, generate a unique identifier for the processing stage using the UUIDv4 algorithm; write the unique identifier for the processing stage into the physical carrier, bind the identifier to the processed food unit through asymmetric encryption, and upload the binding record to the blockchain simultaneously.

[0041] Preferably, the specific process of identifying the unique identifier of the processing stage and collecting the transportation stage data in step S3, and linking the transportation stage data with the processing stage data in a chain, is as follows:

[0042] S31: When the processed food unit is loaded onto the transport carrier, read the unique identifier of the processing link and perform format verification to verify the unique identifier structure of the processing link and the embedded hash digest of the processing link data chain root.

[0043] S32: Real-time data collection during the transportation process, including transportation routes, temperature and humidity fluctuation curves, operating status of transportation equipment, and electronic signatures of transportation personnel;

[0044] S33: Encrypt and link the collected transportation data with the processing data chain to form a chain extension from processing to transportation:

[0045] First, the transportation data is grouped and hashed: it is divided into segments according to the collection time, and each segment of data is generated with a hash value using the SHA-256 algorithm.

[0046] Based on the root hash of the data chain in the processing stage of S2, the group hash values ​​of the transportation stage data are used to construct a Merkle tree. The root hash of the processing stage is used as the seed root of the Merkle tree, and the group hash of the transportation data is used as the leaf node. The Merkle tree root of the transportation data is generated by calculating the hash values ​​layer by layer.

[0047] Preferably, in step S3, the process of uploading the data to the blockchain after progressive encryption using timestamps, along with the verification result of the processing stage identifier, generating a unique identifier for the transportation stage, and recording the handover timestamp is as follows:

[0048] S34: Use timestamp-based progressive encryption for transportation process data:

[0049] Starting from the start of transportation, a phased data hash is generated for the transportation process data within a specified time period.

[0050] When generating the phased data hash for the next period, it is necessary to concatenate the phased data hash for the previous period to form a progressive hash chain of "Phase 1 → Phase 2 → ... → Phase N".

[0051] The entire process records the timestamps corresponding to each stage of hashing, and finally associates the complete progressive hash chain with the Merkle root of the transportation data;

[0052] S35: Data is uploaded to the blockchain along with the verification results of the processing stage identifier:

[0053] The terminal system of the transport vehicle packages and uploads the Merkle root, the progressive hash chain, the corresponding timestamp, the transport process data summary, and the transport process data summary to the transport node of the blockchain:

[0054] S36: Based on the Merkel root of the transportation data and the unique identifier of the processing link, a unique identifier for the transportation link is generated using the UUIDv4 algorithm; the handover timestamp between the transportation and processing links is recorded, and the digital signatures of the processing node and the transportation node are associated; the unique identifier for the transportation link is bound to the food unit in transportation by writing it into the RFID tag or QR code of the food unit.

[0055] Preferably, the specific process of scanning the unique identifier of the transportation link, retrieving and pre-verifying the data of the entire chain, and collecting key data of the sales link in step S4 is as follows:

[0056] S41: When a food unit enters the sales terminal, the unique identifier of the transportation link is read; the unique identifier of the transportation link is sent to the blockchain through the blockchain sales node interface, and the production-processing-transportation full-chain data summary corresponding to the food is automatically retrieved.

[0057] S42: Pre-validate the retrieved end-to-end data digest;

[0058] S43: After the pre-verification is passed, collect sales data, including sales terminal qualification code, warehousing and acceptance record, shelf time, and quality inspection report number.

[0059] Preferably, in step S4, the sales data is linked in a closed loop with the transportation data chain. After encryption, it is uploaded to the blockchain along with the entire data chain to generate a unique identifier for the sales link. The specific process of triggering the node confirmation mechanism for each link of production-processing-transportation-sales is as follows:

[0060] S44: Encrypt and link sales data with the transportation data chain to form a closed loop of the entire chain from production to processing to transportation to sales: First, generate sales data hash values ​​using the SHA-256 algorithm; integrate the hash values ​​of the entire chain: including the encrypted hash value of the production chain, the root hash of the processing chain, the Merkle tree root of the transportation data, and the sales data hash value; use these four types of hash values ​​as leaf nodes to construct the final Merkle tree, with the root node being the root of the entire chain hash.

[0061] S45: The information entry device at the sales terminal encrypts the data and then uploads it to the sales node on the blockchain;

[0062] S46: Based on the root node of the final Merkle tree and the unique identifier of the transportation link, a unique identifier for the sales link is generated through the UUIDv4 algorithm; triggering the node confirmation mechanism for each link of production-processing-transportation-sales: the contract sends a notification of the completion of the full-link data loop to the production node, processing node, transportation node, and sales node respectively. Each node confirms receipt of the notification and acknowledges the integrity of the link by signing with its private key, and the signature result is synchronously written to the blockchain.

[0063] Preferably, in step S5, the query terminal initiates a query request, the blockchain node parses the traceability path, and retrieves the hash value sequence of the corresponding full-link data chain for chain verification. The specific process is as follows:

[0064] S51: The query terminal initiates a query request with authorization verification;

[0065] S52: The blockchain query node receives the request, verifies the validity of the terminal authorization certificate, and after the authorization is granted, parses the traceability path in the identifier and returns a path list containing the unique identifier of each link and the corresponding node information.

[0066] S53: Retrieve the hash value sequence of the entire data chain and perform chain verification.

[0067] Preferably, in step S5, the original data summary of each stage and the corresponding primary key of the data are returned. The query terminal confirms the data integrity through local hash calculation, and the specific process of displaying the complete traceability link in timeline is as follows:

[0068] S54: Returns the original data summary for each stage and the corresponding primary key of the data for that stage:

[0069] After the chain verification is successful, the blockchain query node retrieves the original data summary and corresponding primary key of each link from the ledger according to the traceability path. All data is packaged by link, with timestamps of each link attached, and returned to the query terminal.

[0070] S55: The query terminal confirms data integrity through local hash calculation, achieving local verification;

[0071] S56: After local verification is successful, the query terminal integrates and displays the entire link information in chronological order.

[0072] The beneficial effects of the invention include:

[0073] 1. The SHA-256 hash algorithm is used to encrypt data at each stage. Combined with the consensus mechanism of the blockchain distributed ledger, this ensures that data across the entire supply chain—from production and processing to transportation and sales—is immutable once uploaded to the chain. Simultaneously, asymmetric encryption binds identifiers to food units, effectively resisting malicious acts such as data forgery and identifier misuse, ensuring the authenticity of traceability information. Data is transmitted through encrypted channels throughout the entire process. The transportation stage innovatively employs a timestamp-based progressive encryption to form a hash chain, ensuring that data is not intercepted or tampered with during cross-stage transfer. The multi-node storage characteristic of the distributed ledger avoids the risks of data loss or single-point attacks in centralized systems, guaranteeing the persistent security of traceability data.

[0074] 2. Through a chain-like design of primary key data in the production stage, data chain in the processing stage, Merkle tree in the transportation stage, and final Merkle tree in the sales stage, data from each stage forms an inseparable and complete link. The data across the entire link is sequentially linked by timestamps, and combined with the unique identifier of each stage, the flow of food throughout the supply chain can be quickly traced. In the event of a food safety issue, the specific stage at which the problem occurred can be located within minutes.

[0075] 3. During the query, a chain-like verification is performed by retrieving the hash value sequence of each stage to verify the integrity of the data in each stage of the process, ensuring that the received data is consistent with the original data uploaded to the blockchain. After receiving the data, the query terminal can compare the data digest through local hash calculations. It can independently confirm that the data has not been tampered with without relying on the single feedback from blockchain nodes, thereby improving the credibility of the query results and avoiding query distortion caused by node anomalies.

[0076] 4. Each unique identifier at every stage is generated using the UUIDv4 algorithm, embedded with the corresponding stage's data primary key or hash digest, forming a one-to-one encrypted binding relationship with the food unit, eliminating the risk of identifier duplication or replacement. The standardized identifier format facilitates rapid identification and parsing at each stage, reducing the complexity of cross-stage data integration. Transport vehicles and sales terminals can quickly retrieve upstream end-to-end data and complete pre-verification by reading the unique identifier, eliminating the need for manual data entry or cross-system queries. This significantly shortens the information confirmation time during food handover at each stage, improving the overall efficiency of the supply chain. Furthermore, each stage's data upload includes a node digital signature and timestamp; the transportation stage also records the handover timestamp. Combined with a multi-node confirmation mechanism, the responsibilities of each participant are clearly defined. Attached Figure Description

[0077] Figure 1 This is a schematic diagram of the blockchain-based food traceability method of the present invention.

[0078] Figure 2 This is a schematic diagram illustrating the principle of the blockchain-based food traceability method of the present invention. Detailed Implementation

[0079] The following is in conjunction with the appendix Figures 1-2 The present invention will be further described in detail below:

[0080] Example 1

[0081] See appendix Figure 1 and Figure 2 As shown, a blockchain-based food traceability method includes the following steps:

[0082] S1: Data Collection and Chain-Linked On-Chain Linking in Food Production: Through IoT sensor arrays deployed at food production sites, environmental parameters (temperature, humidity, light intensity), production operation records (fertilizer / feeding amount, pesticide type and dosage, harvesting / slaughter time, etc.), and raw material traceability information are collected in real time during the food production process. A unique primary key for the production process is generated based on "production batch + timestamp + equipment number." After hash encryption using the SHA-256 algorithm, the encrypted hash value, the primary key for the production process data, and the compressed original data digest are uploaded to the blockchain distributed ledger. Simultaneously, a unique identifier (UUID) containing the primary key for the production process data is generated, and an asymmetric encryption-based binding relationship is established between this unique identifier and the corresponding food batch.

[0083] S2: Data Association and On-Chain Access in Food Processing: During food processing, the unique identifier of the production process for each food batch is read through the information collection module built into the processing equipment. This is automatically associated with the primary key of the production process data. Processing parameters, including sterilization temperature, processing time, types and amounts of additives, and digital certificate information of processing personnel, are collected simultaneously. A secondary hash operation is performed on the associated production-processing data combination. The encrypted hash value of the production process is concatenated and encrypted with the hash value of the processing data to generate a processing process data chain. When uploaded to the blockchain, the verification information of the primary key of the production process data is carried, generating a unique identifier for the processing process that includes the traceability path of the unique identifier of the production process and binding it to the processed food unit.

[0084] S3: Data Chain Extension and On-Chain Integration in Food Transportation: Utilizing the positioning module and temperature and humidity sensors of the transport vehicle, RFID readers automatically identify the unique identifier of the processing stage during food loading, triggering the data collection process for the transportation stage. Real-time data collection includes the transportation route (GPS coordinate sequence), temperature and humidity fluctuation curves, operating status of transportation equipment, and the electronic signature of the person in charge of transportation. This data is then linked to the processing stage data chain. A Merkle root for the transportation stage data is generated using the hash value of the processing stage. A progressive timestamp encryption method is used, generating a stage data hash every 30 minutes and linking it to the previous stage hash. When uploaded to the blockchain, the integrity verification result of the unique identifier of the processing stage is included, generating a unique identifier for the transportation stage that includes the production-processing traceability chain. The handover timestamp between the transportation and processing stages is automatically recorded via a blockchain smart contract.

[0085] S4: Closed-loop data chain and on-chain data in the food sales process: When food enters the sales terminal, the information entry device of the sales terminal scans the unique identifier of the transportation link, automatically retrieves the full-chain data summary of the food's production-processing-transportation from the blockchain for pre-verification, and records the sales terminal qualification code, warehousing and acceptance record, shelf time and quality inspection report number after verification. The sales data is linked in a closed loop with the transportation link data chain to generate a final Merkle tree containing the hash value of the entire chain. Sensitive information such as the sales price is encrypted using the AES-256 algorithm and uploaded to the blockchain together with the full-chain data chain to generate a unique identifier for the sales link containing a complete traceability path. At the same time, the node confirmation mechanism of each link of production-processing-transportation-sales is triggered through smart contracts.

[0086] S5: Food Full-Chain Traceability Inquiry: The query terminal initiates a permission-verified query request to the blockchain node by scanning the unique identifier of the food sales link or entering the unique identifier of any link. The blockchain node parses the traceability path information contained in the identifier through the smart contract, retrieves the hash value sequence of the corresponding full-chain data chain for chain verification, verifies the correlation between the hash value of each link and the previous link, and returns the original data summary of each link and the data primary key of the corresponding link after the verification is passed. After the query terminal confirms that the data has not been tampered with by comparing it through local hash calculation, it displays the complete traceability link in chronological order, including the handover nodes of each link, the digital certificate of the person in charge of operation, and the equipment calibration information.

[0087] In this embodiment, the specific process of collecting production data and generating a unique primary key for production process data in step S1 is as follows:

[0088] S11: Deploy IoT sensor arrays at food production sites, including planting bases and breeding farms, to collect production data.

[0089] Collect environmental parameters of the food production site, including temperature, humidity, and light intensity;

[0090] Collect food production operation records, including data on fertilization, feeding, medication, harvesting, and slaughtering operations;

[0091] Collect raw material traceability information: retrieve the raw material traceability information that the raw material supplier has uploaded to the blockchain through the preset blockchain cross-link interface or API, including raw material batch number, origin test report hash value, supplier qualification code, and match the raw material traceability information with the raw material input record of the current production batch, such as batch information of seeds for planting and batch information of feed for breeding.

[0092] S12: Generate a unique primary key for the three types of collected production data according to the rule of "production batch + timestamp + equipment number":

[0093] The production batch number is the unique production identifier for that batch of food, such as "20240501-01", which indicates the first batch produced on May 1, 2024.

[0094] The timestamp is the precise time of the data aggregation, such as "20240501103025", accurate to the second;

[0095] The device number is a unique code for the main data acquisition device, such as the environmental sensor number ENV-001;

[0096] The three elements are concatenated to form a unique string, such as "20240501-01_20240501103025_ENV-001", which serves as the unique index key for the production process data of this batch of food, i.e., the unique primary key for the production process data.

[0097] The specific process of generating a unique identifier (UUID) for the production process, which contains the primary key of the production process data, and establishing a binding relationship based on asymmetric encryption with the corresponding food batch through this unique identifier is as follows:

[0098] S13: The aggregated production data (a complete set of environmental parameters, production operation records, and raw material traceability information) is hashed and encrypted using the SHA-256 algorithm to generate a 256-bit fixed-length encrypted hash value. At the same time, the original data is compressed using the LZ77 algorithm to generate an original data digest. The original data digest contains key parameter values, core operation records, key raw material identifiers, etc., and redundant format information is removed for subsequent on-chain storage and query display.

[0099] S14: Package and upload the encrypted hash value, the primary key of the production process data, and the original data digest to the production node of the blockchain. The encrypted hash value is used for subsequent data integrity verification, the primary key of the production process data is used for data indexing, and the original data digest is used for on-chain storage and fast querying.

[0100] The blockchain's production nodes perform format verification on uploaded information, including verification of hash value length and primary key format. Once the verification is successful, the information is written into the distributed ledger, forming the initial block of the production process. The block simultaneously records the timestamp of the data upload and the digital signature of the production node. The blockchain's production nodes can be servers of the production enterprise.

[0101] S15: Based on the primary key of the production process data, a unique identifier for the production process is generated using the UUIDv4 algorithm. This identifier is a unique 128-bit string, and a summary information of the primary key of the production process data is embedded during generation, so that the identifier and the primary key form a one-to-one mapping relationship, ensuring that the corresponding primary key of the production process data can be directly located through the identifier.

[0102] S16: Establish a unique identifier for each production stage and its corresponding food batch using the asymmetric encryption algorithm RSA-2048.

[0103] The production node uses its own private key to encrypt and sign the combined string of "unique identifier of production process + food batch number" to generate a binding signature;

[0104] The binding signature, production node public key, and "unique identifier of production process + food batch number" in plaintext are uploaded to the blockchain to form an immutable binding record;

[0105] Subsequent processes (such as processing and transportation) can verify the authenticity of this binding relationship through the public key of the production node, ensuring the unique correspondence between food batches and production process data.

[0106] Example 2

[0107] Based on Example 1, the specific process of step S2 is as follows:

[0108] S21: Processing equipment reads the unique identifier of the production process:

[0109] When a batch of food (whole batches of harvested vegetables, whole batches of slaughtered meat) enters the processing stage, the information collection module built into the processing equipment, including washing lines, sterilizers, and packaging machines, automatically triggers the identification process. The information collection module can be an integrated RFID reader or a QR code scanner.

[0110] The information collection module scans the physical carriers attached to food batches, such as RFID tags or QR codes that are uniquely identified in the production process, and reads the unique production process identifier (UUID) generated in S1.

[0111] S22: Automatically associate primary key of production process data

[0112] The information acquisition module of the processing equipment sends the unique identifier of the production process to the processing node of the blockchain through the blockchain node interface: the processing node calls the smart contract to parse the identifier and extract the primary key digest of the production process data contained therein, that is, the information embedded in S1 when generating the unique identifier of the production process;

[0113] Based on the digest, the system retrieves the corresponding primary key of the production process data in the blockchain distributed ledger, and returns the primary key and the associated encrypted hash value of the production process to the processing equipment, thus completing the automatic association between the production process data and the processing process.

[0114] S23: While linking production process data, the processing equipment simultaneously collects processing data through built-in sensors and information input terminals:

[0115] Processing parameters are generated in real time by the integrated temperature sensor (collecting sterilization temperature, etc.), timer (recording processing time), and additive metering device (collecting additive types and dosages).

[0116] Processing personnel digital certificate information: Processing personnel log in to the system by swiping a card or using facial recognition at a terminal, which automatically links to their pre-stored digital certificate, containing information such as name, qualification number, and affiliated company, and is certified by a CA authority.

[0117] All data is indexed using "processing equipment number + timestamp", such as "PROC-002_20240501142030", to ensure that the collection timeline is traceable.

[0118] S24: Secondary hash operation generates data chain for processing steps

[0119] The associated "production-processing data combination" is encrypted to form a coherent data chain:

[0120] The SHA-256 algorithm is used to generate hash values ​​for the collected processing data (processing parameters + processing personnel digital certificate information) separately.

[0121] The encrypted hash value of the production stage in S1 is concatenated with the hash value of the above processing data in the order of "production hash + processing hash", such as "Hash production + Hash processing". The concatenated string is then subjected to SHA-256 hash operation again to generate the root hash of the processing stage data chain.

[0122] The root hash simultaneously links data from both the production and processing stages, forming a chain-like encrypted relationship of "production → processing," ensuring that any data tampering at any stage will cause the root hash to become invalid.

[0123] S25: The processing equipment will package and upload the following information to the processing node of the blockchain:

[0124] The root hash of the processing link data chain generated in step S24;

[0125] The compressed processing data summary collected in step S23 includes key process parameters and core information on personnel certificates.

[0126] Verification information for primary keys in the production process: namely, the hash value of the primary key in the production process, which is generated by encrypting the primary key in the production process using SHA-256, and is used by blockchain nodes to verify whether the associated production process data is complete;

[0127] After receiving the data, the blockchain processing node compares the verification information with the primary key hash value of the production process data stored in the blockchain to confirm that the production process data has not been tampered with. Once the verification is successful, the processing process data is written into the distributed ledger to form a new block associated with the production process block.

[0128] S26: Generate a unique identifier for the processing stage and bind it to the food unit:

[0129] Based on the root hash of the processing link data chain and the unique identifier of the production link, a unique identifier for the processing link is generated using the UUIDv4 algorithm. This identifier embeds the complete information of the unique identifier for the production link, such as the concatenation of the digest of "processing UUID + production UUID", which clarifies the traceability path of "production → processing".

[0130] The unique identifier of each processing step is written into a physical carrier, such as an RFID tag or QR code for each processed food unit. The identifier is then bound to the processed food unit using the same asymmetric encryption algorithm RSA-2048 as in S1. The binding, which includes the signature record of the processing node, is synchronously uploaded to the blockchain to ensure that each food unit can be traced back to the corresponding processing step and upstream production step.

[0131] Through the above steps, the data from the processing stage and the production stage form an immutable chain link, providing a traceable foundation for extending the data chain to the subsequent transportation stage.

[0132] The specific process of step S3 is as follows:

[0133] S31: Identify the unique identifier of the transport vehicle during the processing stage and trigger data collection.

[0134] When processed food units (packaged fresh produce, pre-prepared products, etc.) are loaded onto transport vehicles (refrigerated trucks, containers), the RFID readers deployed on the transport vehicles automatically initiate the identification process:

[0135] The reader scans the physical carrier attached to the food unit, such as the RFID tag or QR code bound to S2, and reads the unique identifier of the processing link generated by S2, including the UUID of the unique identifier of the production link and the traceability path.

[0136] After reading, the reader verifies the format of the identifier, checks the UUID structure and the root hash digest of the embedded processing data chain, confirms that the identifier has not been tampered with, and automatically triggers the data acquisition system for the transportation process after the verification is passed, such as sending a start acquisition command to the cold chain monitoring terminal.

[0137] S32: Real-time data collection during transportation:

[0138] Once the transportation data acquisition system is activated, it collects the following data in real time using dedicated equipment on the transport vehicle, forming a complete record of the transportation process:

[0139] Transportation route: The GPS positioning module collects latitude and longitude coordinates every 5 minutes to generate a continuous GPS coordinate sequence and record the transportation trajectory;

[0140] Temperature and humidity fluctuation curve: Data is collected every 10 minutes by temperature and humidity sensors inside the carriage. A continuous curve is generated by data fitting to reflect environmental stability.

[0141] Transportation equipment operating status: The sensors of the cold chain unit collect information such as compressor operating frequency, refrigeration temperature setpoint, and fault codes, and record it every 15 minutes to ensure the normal operation of the equipment;

[0142] Electronic signature of the person in charge of transportation: The person in charge of transportation enters his or her identity information, such as facial recognition or IC card authentication, through the vehicle terminal. The system automatically generates an electronic signature containing his or her digital certificate, which is consistent with the format of the digital certificate of the processing personnel in S2, to confirm the responsible party.

[0143] S33: Chain-like association between transportation data and processing data:

[0144] The collected transportation data is encrypted and linked with the processing data chain generated by S2, forming a chain extension of "processing → transportation":

[0145] First, the transportation data is grouped and hashed: GPS coordinate sequences, temperature and humidity curves, equipment status, electronic signatures and other data are segmented according to the collection time, and each segment of data is generated with a hash value using the SHA-256 algorithm, such as "Track hash 1, Temperature and humidity hash 1, Equipment hash 1".

[0146] Based on the root hash of the processing data chain in S2, i.e., the double hash value of "production hash + processing hash", a Merkle tree is constructed from the grouped hash values ​​of the transportation data. The root hash of the processing stage serves as the seed root of the Merkle tree, and the grouped hashes of the transportation data serve as leaf nodes. The Merkle tree root of the transportation data is generated through layer-by-layer hash calculation. This Merkle tree root contains both the integrity verification information of the transportation data and is bound to the processing data chain through the seed root, forming an inseparable association between the processing data chain and the transportation data.

[0147] S34: To ensure the immutability of data sequence during transportation, time-stamped progressive encryption is used for transportation process data:

[0148] Starting from the start of transportation, a phased data hash is generated every 30 minutes for the transportation process data within that period, using the SHA-256 algorithm, and includes the start / end timestamp of that period;

[0149] When generating the phase data hash for the next period, it is necessary to concatenate the phase data hash of the previous period, such as "Phase 2 hash = SHA-256(Phase 2 data + Phase 1 hash)", forming a progressive hash chain of "Phase 1 → Phase 2 → ... → Phase N".

[0150] The timestamps corresponding to each stage of the hash are recorded throughout the process. Finally, the complete progressive hash chain is associated with the Merkle root of the transportation data generated in step 3 to ensure the temporal continuity and immutability of the transportation data.

[0151] S35: The terminal system of the transport vehicle will package and upload the following information to the transport node of the blockchain:

[0152] Merkle root of the transportation data generated in step S33;

[0153] The progressive hash chain and corresponding timestamp sequence generated in step S34;

[0154] The transportation data summary, after compression, includes key trajectory nodes, extreme temperature and humidity values, and core equipment operating status.

[0155] The integrity verification result of the unique identifier of the processing link: The hash value corresponding to the unique identifier of the processing link stored in S2 is retrieved through the blockchain interface, and compared with the hash of the currently read unique identifier of the processing link to generate a verification pass / fail result. Only the data that passes the verification can be uploaded.

[0156] After receiving the data, the blockchain transportation node verifies that the processing data has not been tampered with, and then writes the transportation data into the distributed ledger to form a new block that is associated with the processing block.

[0157] S36: Generate a unique identifier for the transportation process and record the handover timestamp:

[0158] Based on the Merkel root of the transportation data and the unique identifier of the processing link, a unique identifier for the transportation link is generated using the UUIDv4 algorithm. This identifier embeds a complete traceability path (concatenated by hash digest) of "unique identifier of production link + unique identifier of processing link", clarifying the link relationship of "production → processing → transportation".

[0159] Simultaneously, the blockchain smart contract automatically triggers the handover record: when the transportation data is uploaded for the first time and passes verification, the contract records the handover timestamp between the transportation and processing stages, i.e., the precise time when food loading is completed and transportation begins, such as "20240501164530," and associates it with the digital signatures of the processing and transportation nodes, serving as the basis for the division of responsibilities between the two stages. A unique identifier for the transportation stage is written into the RFID tag or QR code of the food unit (overwriting the original processing stage identifier, or storing it in association with the original identifier), binding it to the food unit during transportation to ensure direct identification in subsequent sales stages.

[0160] Example 3

[0161] Based on Example 1 or Example 2, the specific process of step S4 is as follows:

[0162] S41: The sales terminal identifies the unique identifier in the transportation process and retrieves data from the entire supply chain.

[0163] When food items arrive at the point of sale (supermarket, e-commerce warehouse, farmers' market stall) after being transported, the information entry equipment at the point of sale, such as POS machines with barcode scanning capabilities or smart shelf terminals, initiates the identification process:

[0164] The equipment scans the physical carrier attached to the food unit, such as the RFID tag or QR code bound in S3, and reads the unique identifier of the transportation link generated by S3, which includes the UUID of the traceability path of "production → processing → transportation".

[0165] After identification, the device sends the unique identifier of the transportation link to the blockchain through the blockchain sales node interface, and automatically retrieves the full-chain data summary of the food's production-processing-transportation, including the original data summary of the production link, the processing data summary of the processing link, and the transportation link data summary, in preparation for pre-verification.

[0166] S42: End-to-end data pre-verification:

[0167] The information entry equipment at the sales terminal pre-verifies the retrieved end-to-end data summary to ensure that the upstream data is complete and has not been tampered with.

[0168] Verification logic: The Merkle tree root of the transportation link data chain is parsed through the unique identifier of the transportation link, and then the root hash of the processing link data chain and the encrypted hash value of the production link are traced back in reverse.

[0169] The device compares the retrieved data digests from each stage with their corresponding hash values ​​through local hash calculations. For example, it checks whether the hash of the production data digest is equal to the encrypted hash value of the production stage. At the same time, it verifies the correlation of the unique identifiers of each stage, such as whether the transportation stage identifier contains the processing stage identifier, and whether the processing stage identifier contains the production stage identifier.

[0170] If all comparisons pass, the pre-verification is deemed successful, and the sales data collection process is allowed; if they fail, the device will automatically alarm and record abnormal information, such as a mismatch between the data summary and hash value in the transportation process.

[0171] S43: After the pre-verification is passed, the information entry device of the sales terminal synchronously collects sales data to form a complete terminal record:

[0172] Sales terminal qualification code: The pre-stored qualification code of the terminal is automatically retrieved, such as "Supermarket-001-2024", which includes terminal type, serial number and validity period. This code has been uploaded to the blockchain in advance and associated with the digital certificate of the terminal operator.

[0173] Warehouse acceptance record: Entered by the acceptance personnel through the terminal, including the results of food appearance inspection (e.g., no damage), quantity verification information (e.g., 100 pieces, consistent with the transport document), and acceptance time;

[0174] Shelf placement time: The time when food is placed in the sales area is automatically recorded by the intelligent shelf system, such as 20240502091500;

[0175] Quality Inspection Report Number: Enter the unique number of the sampling inspection report for this batch of food at the sales terminal, such as QR-20240502-003. This report has been uploaded to the blockchain by a third-party testing agency, and the test results can be retrieved by the number.

[0176] S44: Encrypt and link the collected sales data with the transportation data chain generated by S3 to form a closed loop of the entire chain from "production → processing → transportation → sales".

[0177] First, the sales data, including terminal qualification codes, warehousing and acceptance records, shelf placement time, and quality inspection report numbers, are processed using the SHA-256 algorithm to generate sales data hash values.

[0178] Integrate end-to-end hash values: including encrypted hash values ​​in the production process, root hash values ​​in the processing data chain, Merkle root hash values ​​in the transportation process, and hash values ​​in the sales data;

[0179] Using these four types of hash values ​​as leaf nodes, the final Merkle tree is constructed. The root node is the full-link hash root, which contains the integrity information of the sales data and is also bound to the data chain of all upstream links through the leaf nodes, realizing the closed-loop association of full-link data.

[0180] S45: Sensitive Information Encryption and End-to-End Data On-Chain

[0181] After the data is encrypted by the information entry device at the sales terminal, it is uploaded to the sales node on the blockchain.

[0182] Sensitive information encryption: Data involving commercial privacy, such as sales prices and terminal profits, are encrypted using the AES-256 symmetric encryption algorithm. The key is generated by the sales terminal and the blockchain sales node through asymmetric encryption negotiation. After encryption, only authorized nodes (regulatory nodes and terminal operators) can decrypt it.

[0183] Packaging of on-chain data: Integrate and upload the following information: the root node of the final Merkle tree (full-chain hash root), the compressed sales data summary, the encrypted sensitive information, and the pre-verification result;

[0184] After receiving the data, the blockchain sales node verifies the validity of the pre-verification result and confirms the correlation with the upstream data chain. Once verified, the sales data is written into the distributed ledger, forming a new block that is associated with the transportation block, thus completing the closed loop of data on-chain across the entire chain.

[0185] S46: Based on the root node of the final Merkle tree and the unique identifier of the transportation link, a unique identifier for the sales link is generated using the UUIDv4 algorithm. This identifier embeds a complete traceability path (through multi-level hash digest splicing) of "unique identifier for the production link + unique identifier for the processing link + unique identifier for the transportation link", ensuring that the food can be directly traced to all links in the entire life cycle through this identifier.

[0186] Simultaneously, the blockchain smart contract automatically triggers a node confirmation mechanism for each stage of production, processing, transportation, and sales: the contract sends a "full-chain data loop complete" notification to the production, processing, transportation, and sales nodes respectively. Each node confirms receipt of the notification and acknowledges the integrity of the chain by signing with its private key. The signature result is synchronously written to the blockchain as the final confirmation basis for the full-chain data at each stage. The unique identifier for the sales stage is bound to the food unit by printing a new QR code label (overwriting or associating with the original transportation stage identifier), allowing consumers or regulators to query the full-chain traceability information.

[0187] The specific process of step S5 is as follows:

[0188] S51: The query terminal initiates a query request with authorization verification:

[0189] Inquiry terminals, such as consumer mobile apps, regulatory authorities' dedicated terminals, and enterprise traceability systems, can trigger queries in two ways:

[0190] Scan physical identifiers: Scan the unique identifier of the sales link attached to the food unit by the terminal camera or RFID reader, i.e., the QR code or RFID tag generated by S4, and automatically obtain the identifier string;

[0191] Manual input identifier: Users can manually input a unique identifier for food at any stage, such as a unique identifier for the production stage, a unique identifier for the processing stage, or a unique identifier for the transportation stage. The format is the same as that of UUID.

[0192] The terminal packages the acquired identifier with its own device's authorization certificate (e.g., anonymous authorization certificate for consumer terminals and authorization certificate with CA signature for regulatory terminals) and sends a query request with authorization verification to the query node of the blockchain. The request includes "identifier to be queried + terminal authorization certificate + query timestamp".

[0193] S52: After receiving a request, the blockchain query node first verifies the validity of the terminal's authorization certificate, such as by verifying whether the certificate signature is in the authorized list through a smart contract. Once the authorization is granted, the traceability path in the dedicated smart contract is parsed.

[0194] If the query is for the unique identifier of the sales process: the smart contract parsing identifier contains a multi-layer hash digest of the "unique identifier of the production process + unique identifier of the processing process + unique identifier of the transportation process", which restores the complete traceability path of "production → processing → transportation → sales".

[0195] If the query is for a unique identifier of any upstream link (such as a unique identifier of the processing link): the smart contract traces upstream to the production link through the upstream path information contained in the identifier (such as the processing link identifier containing the production link identifier), and links downstream to the transportation and sales links (through the mapping relationship of "link identifier → downstream identifier" in the blockchain ledger), thus completing the complete traceability path.

[0196] After parsing, the smart contract returns a list of paths containing unique identifiers for each stage and corresponding node information (such as production node ID and processing node ID), providing an index for subsequent data retrieval.

[0197] S53: Based on the traceability path parsed in step 2, the blockchain query node retrieves the hash value sequence of the entire data chain from the distributed ledger, including: the encrypted hash value of the production stage (the hash generated in S1); the root hash of the processing stage data chain (the secondary hash of "production hash + processing hash" generated in S2); the Merkle root of the transportation stage data (the Merkle root generated in S3 with the processing root hash as the seed); and the root node of the final Merkle tree in the sales stage (the root of the entire hash chain generated in S4).

[0198] Then, a chain check is performed to verify the correlation of hash values ​​at each stage: check whether the processing root hash contains the encrypted hash of the production stage, that is, whether the processing root hash is generated by concatenating and encrypting "production hash + processing hash";

[0199] Verify whether the transport Merkle tree root uses the processing root hash as the seed root, that is, whether the construction of the transport Merkle tree is related to the processing link data chain.

[0200] Verify whether the final Merkel root of the sales process includes the Merkel root of the transportation process, that is, whether the end-to-end hash root of the sales process includes the hash of the transportation process data in the leaf nodes.

[0201] If all correlation verifications pass, it is determined that the data across the entire chain has not been tampered with; if any verification fails, a "data anomaly" message is returned and the anomaly is recorded.

[0202] S54: Returns the original data summary for each stage and the corresponding primary key of the data for that stage:

[0203] After the chain verification is successful, the blockchain query node retrieves the original data summary and the corresponding primary key of each step from the ledger according to the traceability path:

[0204] Production process: Return the original data summary of S1 (compressed version of environmental parameters, production operation records, and raw material traceability information) and the primary key of the production process data.

[0205] Processing stage: Return the processing data summary of S2 (processing process parameters, core information of processing personnel's digital certificates) and the data primary key corresponding to the processing stage (processing equipment number + timestamp associated with the data primary key of the production stage);

[0206] Transportation process: Return the transportation process data summary of S3 (GPS track nodes, extreme temperature and humidity values, equipment status) and the data primary key corresponding to the transportation process (transport carrier number associated with the processing process identifier + timestamp);

[0207] Sales process: Return the sales data summary from step 5 of S4 (terminal qualification, warehousing and acceptance record, shelf time) and the data primary key corresponding to the sales process (sales terminal number associated with the transportation process + timestamp).

[0208] All data is categorized and packaged according to the process, with timestamps for each process (such as upload time for production data, upload time for processing data, etc.), and returned to the query terminal.

[0209] S55: After receiving the returned data, the query terminal performs a second verification through local hash calculation to ensure that the data has not been tampered with during transmission and on-chain storage.

[0210] The terminal re-executes the SHA-256 hash operation on the original data digests of each stage to generate locally computed hash values. It then compares these locally computed hash values ​​with the hash value sequence of the retrieved end-to-end data chain, such as whether the local hash of the production data digest equals the encrypted hash value of the production stage, and whether the local hash of the processed data digest matches the components of the processing stage data chain. If all comparisons match, it confirms that "the data is complete and has not been tampered with"; if they do not match, the terminal prompts "the data may have been tampered with" and suggests contacting the regulatory node for verification.

[0211] S56: After local verification is successful, the query terminal integrates and displays the entire supply chain information in chronological order (from production to sales), including:

[0212] Handover nodes at each stage: Display the handover record between production and processing (related to the time when the processing stage reads the production identifier in S2), the handover timestamp between processing and transportation (the time recorded by the smart contract), and the handover record between transportation and sales (related to the warehousing and acceptance time of the sales terminal).

[0213] Digital certificate information of the person in charge of operation: Displays the core content of the digital certificates of production operators, processing personnel, transportation managers, and sales and acceptance personnel, such as name, qualification number, and affiliated company, while concealing private information;

[0214] Equipment calibration information: This includes pre-stored calibration records of the data acquisition equipment at each stage, such as the most recent calibration time of IoT sensors in the production stage, the metrological calibration certificate number of the processing equipment, and the calibration status of the GPS module of the transport vehicle, to prove the accuracy of the data acquisition equipment.

[0215] Ultimately, a complete traceability chain is formed, encompassing production, processing, transportation, and sales, allowing users to intuitively view key information throughout the entire lifecycle of food.

Claims

1. A blockchain-based food traceability method, characterized in that, Includes the following steps: S1: Collect production data, generate a unique primary key for the production process data, generate a hash value based on a hash algorithm, and upload the primary key for the production process data and the original production data summary to the blockchain distributed ledger to generate a unique identifier for the production process and establish a binding relationship with the corresponding food batch. S2: Read the unique identifier of the food batch's production process and associate it with the primary key of the production process data. Collect the processing process data, perform a secondary hash operation, generate a processing process data chain, and upload it to the blockchain with the verification information of the primary key of the production process data. Generate a unique identifier for the processing process and bind it to the processed food unit. S3: The transport carrier identifies the unique identifier of the processing stage and collects the transport stage data. It links the transport stage data with the processing stage data chain, and uploads it to the blockchain after progressive encryption with timestamps, along with the processing stage identifier verification result. It generates a unique identifier for the transport stage and records the handover timestamp. S4: Scan the unique identifier of the transportation link, retrieve and pre-verify the full-link data, collect key data of the sales link, establish a closed-loop association between the sales data and the transportation link data chain, encrypt the data and upload it to the blockchain together with the full-link data chain, generate a unique identifier of the sales link, and trigger the node confirmation mechanism of each link of production-processing-transportation-sales. S5: The query terminal initiates a query request, the blockchain node parses the traceability path, retrieves the hash value sequence of the corresponding full-link data chain for chain verification, returns the original data summary of each link and the data primary key of the corresponding link, the query terminal confirms the data integrity through local hash operation, and displays the complete traceability link according to the timeline; The specific process of step S2 is as follows: S21: The processing equipment reads the unique identifier of the production process; S22: Through the blockchain node interface, the unique identifier of the production process is sent to the processing node of the blockchain: The processing node parses the identifier and extracts the primary key digest of the production process data contained therein; Based on the digest, the system retrieves the corresponding primary key of the production process data in the blockchain distributed ledger, and returns the primary key and the associated encrypted hash value of the production process to the processing equipment, thereby realizing the automatic association between the production process data and the processing process. S23: Collect processing data including processing process parameters and digital certificate information of processing personnel, and generate a temporary index by processing equipment number + timestamp; S24: Encrypt the associated production-processing data combination to form a coherent data chain: The SHA-256 algorithm is used to generate hash values ​​for the processed data. The encrypted hash value of the production process is concatenated with the hash value of the processing data in the order of production hash + processing hash. The concatenated string is then hashed again to generate the root hash of the processing data chain. S25: The processing equipment packages and uploads the root hash, the compressed processing data summary, and the verification information of the primary key of the production process data to the processing node of the blockchain; S26: Generate a unique identifier for the processing stage and bind it to the food unit: Based on the root hash of the processing stage data chain and the unique identifier for the production stage, generate a unique identifier for the processing stage using the UUIDv4 algorithm; write the unique identifier for the processing stage into the physical carrier, bind the identifier to the processed food unit through asymmetric encryption, and upload the binding record to the blockchain synchronously.

2. The food traceability method based on blockchain according to claim 1, characterized in that, The specific process of collecting production data and generating a unique primary key for production process data in step S1 is as follows: S11: Collect production data including environmental parameters, production operation records, and raw material traceability information; S12: Generate a unique primary key for production process data by using the rule of production batch + timestamp + equipment number for the three types of collected production data.

3. The food traceability method based on blockchain according to claim 2, characterized in that, In step S1, a hash value is generated based on a hash algorithm, and then uploaded to the blockchain distributed ledger along with the primary key of the production process data and the original production data summary to generate a unique identifier for the production process and establish a binding relationship with the corresponding food batch. The specific process is as follows: S13: The aggregated production data is hashed and encrypted using the SHA-256 algorithm to generate an encrypted hash value. The original data is then compressed to generate a digest of the original data. S14: Package the encrypted hash value, the primary key of the production process data, and the original data digest and upload them to the production node of the blockchain; the production node of the blockchain performs format verification on the uploaded information, and writes it into the distributed ledger after the verification is passed, forming the initial block of the production process. The block records the timestamp of the data upload and the digital signature of the production node at the same time. S15: Based on the primary key of the production process data, generate a unique identifier for the production process. During generation, embed the summary information of the primary key of the production process data to form a one-to-one mapping relationship between the identifier and the primary key. S16: Use an asymmetric encryption algorithm to establish a binding relationship between the unique identifier of the production process and the corresponding food batch: The production node uses its own private key to encrypt and sign the combined string of "unique identifier of production process + food batch number" to generate a binding signature; the binding signature, the production node's public key and the combined string are uploaded to the blockchain.

4. The food traceability method based on blockchain according to claim 1, characterized in that, In step S3, the unique identifier of the transport vehicle for the processing stage is identified, and transport stage data is collected. The specific process of linking the transport stage data with the processing stage data is as follows: S31: When the processed food unit is loaded onto the transport carrier, read the unique identifier of the processing link and perform format verification to verify the unique identifier structure of the processing link and the embedded hash digest of the processing link data chain root. S32: Real-time data collection during the transportation process, including transportation routes, temperature and humidity fluctuation curves, operating status of transportation equipment, and electronic signatures of transportation personnel; S33: Encrypt and link the collected transportation data with the processing data chain: First, the transportation data is grouped and hashed: it is divided into segments according to the collection time, and each segment of data is generated with a hash value using the SHA-256 algorithm. Based on the root hash of the data chain in the processing stage, the group hash values ​​of the data in the transportation stage are used to construct a Merkle tree. The root hash of the processing stage is used as the seed root of the Merkle tree, and the group hash of the transportation data is used as the leaf node. The Merkle tree root of the transportation data is generated by calculating the hash values ​​layer by layer.

5. A food traceability method based on blockchain according to claim 4, characterized in that, In step S3, the data is uploaded to the blockchain using a progressively encrypted timestamp method, along with the verification result of the processing stage identifier. The specific process of generating a unique identifier for the transportation stage and recording the handover timestamp is as follows: S34: Use timestamp-based progressive encryption for transportation process data: Starting from the start of transportation, a phased data hash is generated for the transportation process data within the corresponding time period at specified intervals; When generating the phased data hash of the next period, it is necessary to concatenate the phased data hash of the previous period to form a progressive hash chain of phase 1 → phase 2 → ... → phase N. The entire process records the timestamps corresponding to each stage of hashing, and finally associates the complete progressive hash chain with the Merkle root of the transportation data; S35: Data is uploaded to the blockchain along with the verification results of the processing stage identifier: The terminal system of the transport vehicle packages and uploads the Merkle root, the progressive hash chain, the corresponding timestamp, the transport process data summary, and the transport process data summary to the transport node of the blockchain; S36: Based on the Merkel root of the transportation data and the unique identifier of the processing link, a unique identifier for the transportation link is generated using the UUIDv4 algorithm; the handover timestamp between the transportation and processing links is recorded, and the digital signatures of the processing node and the transportation node are associated; the unique identifier for the transportation link is bound to the food unit in transportation by writing it into the RFID tag or QR code of the food unit.

6. The food traceability method based on blockchain according to claim 1, characterized in that, The specific process of scanning the unique identifier of the transportation link, retrieving and pre-verifying the data of the entire chain, and collecting key data of the sales link in step S4 is as follows: S41: When a food unit enters the sales terminal, the unique identifier of the transportation link is read; the unique identifier of the transportation link is sent to the blockchain through the blockchain sales node interface, and the production-processing-transportation full-chain data summary corresponding to the food is automatically retrieved. S42: Pre-validate the retrieved end-to-end data digest; S43: After the pre-verification is passed, collect sales data, including sales terminal qualification code, warehousing and acceptance record, shelf time, and quality inspection report number.

7. A food traceability method based on blockchain according to claim 6, characterized in that, In step S4, a closed-loop association is established between sales data and the transportation data chain. After encryption, the data is uploaded to the blockchain along with the end-to-end data chain, generating a unique identifier for the sales link. The specific process of triggering the node confirmation mechanism for each link in the production-processing-transportation-sales process is as follows: S44: Encrypt and associate sales data with the transportation data chain to generate a sales data hash value; integrate the hash values ​​across the entire chain: including the encrypted hash value of the production link, the root hash of the processing data chain, the Merkle root of the transportation data, and the sales data hash value; Using these four types of hash values ​​as leaf nodes, construct the final Merkle tree, with the root node being the full-link hash root; S45: The information entry device at the sales terminal encrypts the data and then uploads it to the sales node on the blockchain; S46: Based on the root node of the final Merkle tree and the unique identifier of the transportation link, a unique identifier for the sales link is generated through the UUIDv4 algorithm; triggering the node confirmation mechanism for each link of production-processing-transportation-sales: the contract sends a notification of the completion of the full-link data loop to the production node, processing node, transportation node, and sales node respectively. Each node confirms receipt of the notification and acknowledges the integrity of the link by signing with its private key, and the signature result is synchronously written to the blockchain.

8. The food traceability method based on blockchain according to claim 1, characterized in that, In step S5, the query terminal initiates a query request, the blockchain node parses the traceability path, and retrieves the hash value sequence of the corresponding full-link data chain for chain verification. The specific process is as follows: S51: The query terminal initiates a query request with authorization verification; S52: The blockchain query node receives the request, verifies the validity of the terminal authorization certificate, and after the authorization is granted, parses the traceability path in the identifier and returns a path list containing the unique identifier of each link and the corresponding node information. S53: Retrieve the hash value sequence of the entire data chain and perform chain verification.

9. A food traceability method based on blockchain according to claim 1, characterized in that, In step S5, the original data summary of each stage and the corresponding primary key of the data are returned. The query terminal confirms the data integrity through local hash calculation. The specific process of the complete traceability link is displayed on a timeline as follows: S54: Returns the original data summary for each stage and the corresponding primary key of the data for that stage: After the chain verification is passed, the blockchain query node retrieves the original data summary of each link and the data primary key of the corresponding link from the ledger according to the traceability path. All data is packaged by link, with the timestamp of each link attached, and returned to the query terminal. S55: The query terminal confirms data integrity through local hash calculation, achieving local verification; S56: After local verification is successful, the query terminal integrates and displays the entire link information in chronological order.

Citation Information

Patent Citations

  • Hotpot condiment product traceability method and system based on block chain

    CN116611851A

  • Food production traceability management system based on block chain

    CN120525552A