A food information traceability method and system based on laser coding
By collecting data in real time and storing evidence in the food production process, encrypting and printing it into the micro dot matrix diagram, the problem of easy tampering and copying of existing food traceability methods is solved, and the safety and convenience of food traceability information is achieved. Consumers can quickly obtain accurate traceability information offline.
Patent Information
- Application Number
- CN202510324512.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-03-19
AI Technical Summary
The existing food traceability methods based on laser inkjet have the problem that traceability information is easily tampered with, copied and forged, and the convenience of consumer query is insufficient.
By deploying sensors in the food production process to collect data in real time and conduct blockchain on-chain verification, generating multi-dimensional data packets, using hash computing and key generation mechanisms to encrypt information, and encode the encrypted traceability information into the micro dot matrix diagram, and using high-precision laser printing technology to generate micro dot matrix identifiers that are difficult to tamper with and copy on the product packaging, consumers decrypt offline through mobile APPs to obtain traceability information.
It realizes the immutability, security and convenience of food traceability information. Consumers can quickly obtain accurate traceability information without connecting to the Internet, enhance the reliability and anti-counterfeiting capabilities of traceability information, and protect user data privacy.
Smart Images

Figure CN119963220B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of food information traceability, and in particular to a food information traceability method and system based on laser coding. Background Art
[0002] In recent years, food traceability technology has further developed, with the emergence of traceability solutions based on technologies such as RFID, NFC, and blockchain. Laser coding technology, due to its high precision, permanence, and difficulty in tampering, has also gradually become an important technical means in the field of food traceability.
[0003] Existing food information traceability methods based on laser coding typically encode product information into a QR code or barcode, which is then printed on the product packaging using a laser printer. Consumers can obtain product information by scanning the code. However, this method has the following three major drawbacks:
[0004] 1. Traceability information is easily tampered with: Traditional laser coding traceability solutions typically use static QR codes or barcodes, whose information cannot be changed once printed. This means that if the corresponding information in the database is tampered with, the information scanned by consumers will also be incorrect. In addition, simple QR codes or barcodes are easy to copy, and the code of genuine products can be easily copied and affixed to counterfeit and inferior products.
[0005] 2. Traceability information is easy to copy and forge: Traditional QR codes and barcodes have low technical barriers to entry and are easy to copy and forge;
[0006] 3. Inconvenient consumer querying: Traditional laser coding traceability methods typically require consumers to visit specific websites or platforms to query product information. This requires online access and relies on server stability. In the event of poor network conditions or server failures, consumers may not be able to obtain traceability information in a timely manner. Summary of the Invention
[0007] Based on this, it is necessary to provide a food information traceability method and system based on laser coding to solve at least one of the above technical problems.
[0008] To achieve the above purpose, a food information traceability method based on laser coding includes the following steps:
[0009] Step S1: Obtain production-related information; collect production data of the food production process and store it on the blockchain to obtain blockchain records; associate and integrate the blockchain records and production-related information, and generate a multidimensional data package to obtain a multidimensional data package;
[0010] Step S2: performing a hash calculation on the multidimensional data packet to obtain a hash value of the multidimensional data packet; obtaining a unique serial number of the product; using a preset master key to generate a seed key from the hash value of the multidimensional data packet and the unique serial number of the product, and performing a key derivation function calculation to obtain a product key;
[0011] Step S3: Encrypting the traceability information according to the multidimensional data packet and the product key to obtain encrypted traceability information; generating micro-dot matrix parameters according to the encrypted traceability information to obtain micro-dot matrix parameters; generating an encrypted micro-dot matrix according to the micro-dot matrix parameters and the encrypted traceability information to obtain an encrypted micro-dot matrix;
[0012] Step S4: Using the encrypted micro-dot pattern to perform laser micro-dot printing on the product packaging to obtain a product with a micro-dot pattern mark;
[0013] Step S5: Decode the micro-dot matrix image of the product with the micro-dot matrix mark and complete the product serial number to obtain the complete product serial number and decoded data; reconstruct the product key according to the preset master key, the complete product serial number and the decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the traceability information of the decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task.
[0014] The present invention collects data in real time through sensors and combines it with timestamps to ensure the accuracy and integrity of the data. Blockchain technology is used for data storage, which achieves the immutability and traceability of the data and enhances consumers' trust in traceability information. The multidimensional data packet finally generated contains the complete life cycle data from raw materials to production, providing a reliable data basis for subsequent traceability and anti-counterfeiting. By combining the hash value of the multidimensional data packet, the unique serial number of the product and the preset master key, and applying AES encryption and HKDF key derivation function, the uniqueness and unpredictability of each product key are guaranteed, effectively preventing forgery and tampering and enhancing the security of traceability information. By encrypting the core traceability information with the product key and encoding it into the micro-dot matrix, effective hiding and protection of the information is achieved. The microscopic characteristics and random distribution of the micro-dot matrix make it difficult to be identified and copied by the naked eye, effectively improving the anti-counterfeiting ability and ensuring the security of the traceability information. The digitized micro-dot matrix is physically bound to the product packaging to make the information difficult to tamper with or remove. High-precision laser printing technology ensures the quality and durability of the micro-dot pattern, providing consumers with a reliable anti-counterfeiting verification method. Consumers only need to use a mobile phone APP to scan the micro-dot pattern to obtain the traceability information of the product. The local reconstruction and decryption process of the product key can be completed without the need for an Internet connection, ensuring the rapidity and offline availability of the query while protecting the user's data privacy. Therefore, the present invention provides a food information traceability method based on laser coding, which effectively solves the deficiencies in security, reliability and convenience of the existing food information traceability method based on laser coding, and provides consumers with a safer, more reliable and convenient food traceability experience.
[0015] Preferably, step S1 includes the following steps:
[0016] Step S11: Acquire production-related information; collect data on the food production process through sensors to obtain sensor data streams;
[0017] Step S12: performing data preprocessing on the sensor data stream to obtain preprocessed sensor data;
[0018] Step S13: storing the pre-processed sensor data on the blockchain to obtain a blockchain record;
[0019] Step S14: perform data association and integration on the blockchain records and production-related information to obtain information integration data;
[0020] Step S15: Generate a multi-dimensional data packet for the information integration data to obtain a multi-dimensional data packet.
[0021] By deploying sensors at every stage of the production process and collecting data in real time, this method automates the collection of production information, avoiding the potential errors and omissions associated with manual recording, improving the efficiency and accuracy of data collection, and providing a reliable data source for subsequent traceability. The continuous data stream and timestamp recording fully reflect the dynamic changes in the production process, providing more detailed information for product quality control and problem tracing. Preprocessing the raw sensor data, including formatting, outlier removal, missing value filling, and data normalization, effectively improves data quality and reliability. Removing noise and outliers prevents these data from interfering with subsequent analysis and ensures the accuracy of traceability information. Data preprocessing also lays a solid foundation for subsequent data analysis and processing. Uploading the preprocessed key sensor data to the blockchain leverages the blockchain's decentralized and tamper-proof nature to ensure data authenticity and integrity, prevent malicious tampering, and enhance consumer trust in traceability information. The blockchain records also provide a reliable basis for subsequent data tracing and verification. By associating and integrating blockchain records with other production-related information, a complete data chain is formed. This connects previously fragmented data, ensuring comprehensiveness and traceability, allowing consumers to understand the entire product lifecycle, from raw materials to production, further enhancing the reliability and transparency of traceability information. The integrated data is encapsulated into multi-dimensional data packets (MD-Packets), providing a structured data organization method that facilitates data storage, transmission, and processing. MD-Packets contain rich product information, providing a complete data foundation for subsequent encryption and traceability, and providing consumers with more comprehensive product information. The standardized data format also facilitates data exchange and sharing between different systems.
[0022] Preferably, step S13 includes the following steps:
[0023] Step S131: screening the pre-processed sensor data for key data to obtain a key data set;
[0024] Step S132: constructing a data structure for the key data set to obtain a JSON data structure;
[0025] Step S133: Sign the JSON data structure with a private key to obtain signed data;
[0026] Step S134: Using the signed data as transaction data, a blockchain transaction is created to obtain a blockchain transaction;
[0027] Step S135: Broadcast the blockchain transaction to the pre-selected alliance chain network, confirm the transaction, and obtain the blockchain record.
[0028] This invention filters critical data, such as core parameters like origin, time, and temperature, from large amounts of sensor data. This eliminates redundant information, reduces data storage and processing costs, improves efficiency, and makes subsequent blockchain onboarding more efficient. It also helps protect the security of core traceability information. Key data sets are structured as JSON data structures, making the data more standardized and easier to process. The JSON format offers excellent readability and compatibility, facilitating data storage, transmission, and parsing, as well as data exchange with other systems, facilitating subsequent signing and onboarding operations. Signing the JSON data structure with a private key ensures data non-repudiation and integrity. This signature mechanism prevents data tampering, ensures the authenticity and trusted source of on-chain data, and enhances the security of traceability information. Signed data is created as a blockchain transaction, preparing it for on-chain onboarding. The structured format of blockchain transactions, which includes essential information such as transaction data, type, and destination address, makes transaction processing more standardized and efficient. Blockchain transactions are broadcast to the consortium blockchain network and, after verification and validation by multiple nodes, are ultimately written to the blockchain, ensuring permanent and tamper-proof data storage. The consortium chain mechanism ensures data decentralization and transparency, enhances the credibility of traceability information, and makes it easier for consumers to trust and accept it. The records obtained on the blockchain can serve as strong proof of the authenticity and integrity of the data.
[0029] Preferably, step S2 includes the following steps:
[0030] Step S21: performing hash calculation on the multi-dimensional data packet to obtain a hash value of the multi-dimensional data packet;
[0031] Step S22: Obtain the unique serial number of the product;
[0032] Step S23: Generate a seed key from the multi-dimensional data packet hash value and the product unique serial number using the preset master key to obtain a seed key;
[0033] Step S24: Perform a key derivation function calculation on the seed key to obtain the product key.
[0034] By performing a hash calculation on multidimensional data packets, the present invention can convert complex, variable-length data packets into fixed-length hash values, simplifying the subsequent key generation process and improving computational efficiency. The hash value can also be used to verify the integrity of the data packet, ensuring that the data has not been tampered with during transmission and storage. Obtaining a unique product serial number establishes a unique identity for each product, which is key to achieving accurate traceability. This unique serial number can link the product with its corresponding production data, preventing information confusion and improving the accuracy and reliability of traceability. The seed key is generated using a master key, the multidimensional data packet hash value, and the product's unique serial number, ensuring its security and making it difficult to directly guess or crack. The seed key generation mechanism, which combines product-specific information (serial number and data packet hash value), ensures that each product's seed key is unique, further enhancing security. Using a key derivation function such as HKDF to expand the seed key to generate the final product key enhances key security. Even if part of the seed key is leaked, it is difficult to derive the final product key, thus improving the system's anti-attack capabilities. The characteristics of the HKDF function ensure that the generated product key has sufficient entropy and randomness, making it more difficult to crack, thereby better protecting traceability information.
[0035] Preferably, step S3 includes the following steps:
[0036] Step S31: extracting core traceability information from the multi-dimensional data packet to obtain a core traceability information string;
[0037] Step S32: Encrypt the core traceability information string using the product key to obtain encrypted traceability information;
[0038] Step S33: generating micro dot matrix parameters according to the encrypted traceability information to obtain micro dot matrix parameters;
[0039] Step S34: assigning micro-dot attributes according to the micro-dot array parameters and the encrypted traceability information to obtain micro-dot attribute information;
[0040] Step S35: Drawing the micro-dot array image according to the micro-dot array image parameters and the micro-dot attribute information to obtain an encrypted micro-dot array image.
[0041] The present invention extracts core traceability information, such as origin, date, and batch number, from a multidimensional data packet to create a concise core traceability information string. This helps improve the efficiency of subsequent encryption and encoding and reduces storage space usage. Extracting this core information also allows consumers to quickly access the most critical product traceability information. The core traceability information is encrypted using a product key, ensuring its security and preventing information leakage and tampering. The encrypted information can only be decrypted by users with the corresponding key, effectively protecting product traceability information and safeguarding the rights and interests of both manufacturers and consumers. By generating microdot pattern parameters based on the encrypted traceability information, the complexity of the microdot pattern, such as the number, density, and arrangement of microdots, can be dynamically adjusted based on the amount of information, thereby improving encoding efficiency and flexibility. This makes the microdot pattern design more flexible and adaptable to different application scenarios and data volumes. Encoding the encrypted information into the microdot properties, such as shape, size, and orientation, achieves information concealment and anti-counterfeiting. The information contained in the microdots is difficult to read directly by the naked eye and can only be obtained through a specific decoding algorithm and key, making forgery more difficult and enhancing the security of the traceability information. Based on parameter and attribute information, a micro-dot pattern is created, converting abstract data into a visual graphic, providing direct input for laser printing. The generated micro-dot pattern contains encrypted traceability information and is difficult to identify and copy with the naked eye, thus ensuring secure storage and transmission of information.
[0042] Preferably, step S33 includes the following steps:
[0043] Step S331: Analyze the encrypted information attributes of the encrypted traceability information to obtain the encrypted information length parameter;
[0044] Step S332: generating micro-dot basic attribute parameters according to the encrypted information length size parameter and the preset micro-dot basic attribute range to obtain the micro-dot basic attribute parameters;
[0045] Step S333: generating micro-dot shape coding rules based on the encrypted traceability information and the preset micro-dot shape types to obtain the micro-dot shape coding rules;
[0046] Step S334: generating a micro-dot direction coding rule based on the encrypted traceability information and the preset discrete direction information to obtain a micro-dot direction coding rule;
[0047] Step S335: Generate a micro-dot density coding rule based on the encrypted traceability information to obtain a micro-dot density coding rule;
[0048] Step S336: generating micro-dot position parameters according to the micro-dot basic attribute parameters to obtain the micro-dot position parameters;
[0049] Step S337: integrating the micro-dot basic attribute parameters, micro-dot shape coding rules, micro-dot direction coding rules, micro-dot density coding rules and micro-dot position parameters to obtain micro-dot array parameters.
[0050] By analyzing properties such as the length and size of encrypted traceability information, the present invention can provide basic data for subsequent microdot pattern parameter generation, such as determining the required number of microdots. This allows for more scientific and rational microdot pattern design and improves encoding efficiency. Understanding the properties of encrypted information also facilitates the selection of appropriate encoding strategies. Based on the encrypted information's length and size parameters and a preset range of microdot basic properties, microdot basic property parameters, such as microdot diameter, color, and optional shapes, can be generated to meet actual requirements. This ensures that the generated microdot pattern can accommodate all encrypted information while being clearly printed within a designated area, while also balancing anti-counterfeiting performance and recognition efficiency. Generating microdot shape coding rules based on the encrypted traceability information can increase the complexity and security of the encoding, making the microdot pattern more difficult to crack or forge. Dynamically generated coding rules also increase the difficulty for attackers to analyze and crack the pattern. Similar to shape coding, generating microdot direction coding rules based on the encrypted traceability information further increases the complexity and security of the encoding, making information hiding more concealed, increasing the difficulty of forgery, and further enhancing anti-counterfeiting performance. Generating microdot density encoding rules based on encrypted traceability information allows for more efficient utilization of the microdot array area, increasing information density and enabling the storage of more information within a limited area. Dynamic density encoding rules also increase the difficulty of cracking. Generating microdot position parameters based on microdot basic attribute parameters ensures the proper distribution of microdots within the array area, preventing overlap or excessive sparseness. This ensures the quality and recognizability of the microdot array and provides precise coordinate data for subsequent laser printing. Integrating all microdot-related parameters into a complete microdot array parameter set provides the necessary parameter information for subsequent microdot array drawing and laser printing, ensuring uniformity and consistency throughout the entire process. The integrated parameters also facilitate subsequent management and maintenance.
[0051] Preferably, step S4 includes the following steps:
[0052] Step S41: pre-processing the printing area of the product packaging, and setting the laser parameters according to the encrypted micro-dot pattern to obtain the laser coding parameters;
[0053] Step S42: performing micro-dot array positioning on the encrypted micro-dot array to obtain positioned micro-dot array data;
[0054] Step S43: performing laser printing according to the positioned micro-dot matrix image data and laser coding parameters to obtain a product with a micro-dot matrix mark.
[0055] The present invention can improve the adhesion of the laser on the packaging material, ensure the quality of the printing, make the microdots clear and durable, and reduce printing errors by pre-treating the printing area, such as cleaning and applying a laser-sensitive coating. By setting the laser parameters according to the characteristics of the encrypted micro-dot array pattern, the accuracy and clarity of the micro-dot array pattern can be ensured while avoiding damage to the packaging material. The printing position of the micro-dot array pattern is accurately positioned through positioning marks and image recognition algorithms, ensuring the accuracy and consistency of the micro-dot array pattern printing and avoiding decoding errors caused by positioning deviations. Precise positioning also allows the micro-dot array pattern to be reliably identified and decoded, even in the case of slight deformation or contamination on the packaging surface. By performing laser printing based on the positioned data and laser parameters, the encrypted micro-dot array pattern can be printed on the product packaging with high precision, realizing physical binding of the information, making it difficult to tamper with or remove the information. High-precision printing also ensures the readability of the micro-dot array pattern and the reliability of decoding, ultimately achieving product anti-counterfeiting and traceability.
[0056] Preferably, step S5 includes the following steps:
[0057] Step S51: collecting a micro-dot matrix image of a product marked with a micro-dot matrix to obtain a micro-dot matrix image;
[0058] Step S52: decoding the micro-dot matrix image to obtain decoded data and partial product serial number information;
[0059] Step S53: completing the product serial number on the partial information of the product serial number to obtain the complete product serial number;
[0060] Step S54: reconstruct the product key according to the preset master key, the complete product serial number and the decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the decoded data to obtain the decrypted traceability information.
[0061] This invention uses a smartphone camera to capture micro-dot pattern images, providing consumers with a convenient way to obtain traceability information. The app's autofocus and image stabilization technologies, along with user interaction guidance, improve image acquisition quality, providing clear image data for the subsequent decoding process. The captured image is preprocessed and decoded to extract encrypted traceability information and a portion of the product serial number, providing the necessary data for subsequent information decryption and verification. Image preprocessing steps, such as grayscaling, binarization, and denoising, improve the accuracy of micro-dot detection, enabling effective decoding even in poor lighting conditions or when the packaging surface is contaminated. The user manually enters the remaining product serial number information, which is combined with the decoded partial information to form the complete serial number. This combines user participation with information verification, improves security, and ensures that only users with authentic products can obtain complete traceability information. Local reconstruction of the product key and decryption of the traceability information can be completed without an internet connection, ensuring rapid query speed and offline availability, enhancing the user experience. Furthermore, since the decryption process is completed on the user's phone, user data privacy and security are protected. This mechanism also avoids reliance on centralized servers, improving system stability and reliability.
[0062] Preferably, step S54 includes the following steps:
[0063] Step S541: extracting information required for key derivation from the decoded data to obtain key derivation parameters;
[0064] Step S542: using the master key and the complete product serial number to perform reverse calculation of the seed key, and reconstructing the seed key according to the key derivation parameters to obtain a reconstructed seed key;
[0065] Step S543: Perform local key derivation calculation using the reconstructed seed key to obtain the reconstructed product key;
[0066] Step S544: extract the encrypted traceability information from the decoded data, and use the reconstructed product key to perform a decryption operation on the traceability information to obtain the decrypted traceability information.
[0067] By extracting the parameters required for key derivation from the decoded data, such as the hash value of the multidimensional data packet, the present invention prepares the necessary parameter information for the subsequent key reconstruction process. This ensures the integrity and accuracy of the key reconstruction process, laying the foundation for ultimately obtaining correct traceability information. Using the master key, the complete product serial number, and key derivation parameters to reconstruct the seed key securely on the user side, it avoids the transmission of sensitive information across the network and improves system security. This process also ensures that only users with the complete product serial number and correctly decoded data can reconstruct the seed key, preventing forgery and tampering. Using the reconstructed seed key for local key derivation calculations, a product key identical to the one used during encryption is generated. This localized key generation avoids potential security risks associated with network transmission of the key and further ensures the security of the traceability information. The encrypted traceability information is then decrypted using the reconstructed product key to obtain the product's traceability information, completing the entire traceability process. Performing the decryption locally ensures user data privacy and eliminates the need for a network connection, improving query speed and efficiency and providing users with a convenient traceability experience.
[0068] Preferably, the present invention further provides a food information traceability system based on laser coding, which is used to execute the food information traceability method based on laser coding as described above. The food information traceability system based on laser coding comprises:
[0069] The multi-dimensional data acquisition module is used to obtain production-related information; collect production data from the food production process and store it on the blockchain to obtain blockchain records; associate and integrate blockchain records and production-related information, and generate multi-dimensional data packets to obtain multi-dimensional data packets;
[0070] A dynamic key generation module is used to perform hash calculations on a multidimensional data packet to obtain a hash value of the multidimensional data packet; obtain a unique product serial number; use a preset master key to generate a seed key from the hash value of the multidimensional data packet and the unique product serial number, and perform a key derivation function calculation to obtain a product key;
[0071] The micro-dot matrix encoding module is used to encrypt the traceability information according to the multi-dimensional data packet and the product key to obtain the encrypted traceability information; generate micro-dot matrix parameters according to the encrypted traceability information to obtain the micro-dot matrix parameters; and generate an encrypted micro-dot matrix according to the micro-dot matrix parameters and the encrypted traceability information to obtain the encrypted micro-dot matrix.
[0072] Laser micro-dot matrix printing module, used to use encrypted micro-dot matrix pattern to perform laser micro-dot matrix printing on product packaging to obtain micro-dot matrix marked products;
[0073] The mobile terminal decryption module is used to decode the micro-dot matrix image of products with micro-dot matrix labels and complete the product serial number to obtain the complete product serial number and decoded data; reconstruct the product key based on the preset master key, complete product serial number and decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] Figure 1 The figure is a flowchart of a food information traceability method based on laser coding;
[0075] Figure 2 Detailed implementation flow chart of step S1 in the present invention;
[0076] Figure 3 3 is a flowchart of the detailed implementation steps of step S3 in the present invention.
[0077] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0078] The following is a clear and complete description of the technical method of the present invention in conjunction with the accompanying drawings. It is obvious that the embodiments described are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making any creative efforts are within the scope of protection of the present invention.
[0079] In addition, the accompanying drawings are merely schematic illustrations of the present invention and are not necessarily drawn to scale. Identical reference numerals in the figures denote identical or similar parts, and thus repetitive descriptions thereof will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor and / or microcontroller approaches.
[0080] It should be understood that although the terms "first," "second," and the like may be used herein to describe various elements, these elements should not be limited by these terms. These terms are used solely to distinguish one element from another. For example, a first element may be referred to as a second element, and similarly, a second element may be referred to as a first element, without departing from the scope of the exemplary embodiments. The term "and / or" as used herein includes any and all combinations of one or more of the listed associated items.
[0081] To achieve this, please refer to Figures 1 to 3 , a food information traceability method based on laser coding, comprising the following steps:
[0082] Step S1: Obtain production-related information; collect production data of the food production process and store it on the blockchain to obtain blockchain records; associate and integrate the blockchain records and production-related information, and generate a multidimensional data package to obtain a multidimensional data package;
[0083] Step S2: performing a hash calculation on the multidimensional data packet to obtain a hash value of the multidimensional data packet; obtaining a unique serial number of the product; using a preset master key to generate a seed key from the hash value of the multidimensional data packet and the unique serial number of the product, and performing a key derivation function calculation to obtain a product key;
[0084] Step S3: Encrypting the traceability information according to the multidimensional data packet and the product key to obtain encrypted traceability information; generating micro-dot matrix parameters according to the encrypted traceability information to obtain micro-dot matrix parameters; generating an encrypted micro-dot matrix according to the micro-dot matrix parameters and the encrypted traceability information to obtain an encrypted micro-dot matrix;
[0085] Step S4: Using the encrypted micro-dot pattern to perform laser micro-dot printing on the product packaging to obtain a product with a micro-dot pattern mark;
[0086] Step S5: Decode the micro-dot matrix image of the product with the micro-dot matrix mark and complete the product serial number to obtain the complete product serial number and decoded data; reconstruct the product key according to the preset master key, the complete product serial number and the decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the traceability information of the decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task.
[0087] In the embodiment of the present invention, reference Figure 1 FIG. 1 is a flow chart of the steps of the food information traceability method based on laser coding of the present invention. In this example, the food information traceability method based on laser coding includes the following steps:
[0088] Step S1: Obtain production-related information; collect production data of the food production process and store it on the blockchain to obtain blockchain records; associate and integrate the blockchain records and production-related information, and generate a multidimensional data package to obtain a multidimensional data package;
[0089] In the embodiment of the present invention, taking milk powder production as an example, all information, from the origin of the milk source, the collection time, the transportation process, to the temperature, humidity, pressure and other parameters in the production process, as well as the packaging information of the final product, are collected in real time by sensors and recorded with a timestamp. After the collected data is pre-processed and cleaned, the key data will be screened out and constructed into a JSON data structure, and then signed with a private key, and finally uploaded to the Hyperledger Fabric consortium chain for evidence storage, obtaining an unalterable blockchain record. Finally, the hash value of the blockchain record is integrated with other production-related information to generate a multi-dimensional data packet (MD-Packet), providing a complete data foundation for subsequent steps;
[0090] Step S2: performing a hash calculation on the multidimensional data packet to obtain a hash value of the multidimensional data packet; obtaining a unique serial number of the product; using a preset master key to generate a seed key from the hash value of the multidimensional data packet and the unique serial number of the product, and performing a key derivation function calculation to obtain a product key;
[0091] In this embodiment of the present invention, a SHA-256 hash calculation is performed on the multidimensional data packet generated in step S1. Then, the unique serial number laser-etched on each product packaging is obtained. After the hash value and serial number are concatenated, a seed key is generated using a preset master key and the AES-256 encryption algorithm. Finally, the seed key is expanded using the HKDF key derivation function to generate the final 128-bit product key. This dynamic key generation mechanism ensures that the key for each product is unique, making it difficult to forge the key even if some information is leaked.
[0092] Step S3: Encrypting the traceability information according to the multidimensional data packet and the product key to obtain encrypted traceability information; generating micro-dot matrix parameters according to the encrypted traceability information to obtain micro-dot matrix parameters; generating an encrypted micro-dot matrix according to the micro-dot matrix parameters and the encrypted traceability information to obtain an encrypted micro-dot matrix;
[0093] In this embodiment of the present invention, core traceability information, such as origin, production date, and expiration date, is first extracted from the multidimensional data packet and encrypted using AES-128 encryption using the product key generated in step S2. Then, based on the length of the encrypted information and preset parameters, the parameters of the microdot pattern are generated, including the number, diameter, shape, color, position, and arrangement of the microdots. Using these parameters, the encrypted information is encoded into the microdot properties, ultimately generating an encrypted microdot pattern that is difficult to discern with the naked eye.
[0094] Step S4: Using the encrypted micro-dot pattern to perform laser micro-dot printing on the product packaging to obtain a product with a micro-dot pattern mark;
[0095] In an embodiment of the present invention, the printing area on the packaging surface is pre-treated, such as by cleaning and applying a laser-sensitive coating. The laser printer parameters, such as laser power, frequency, and scanning speed, are then set based on the packaging material and the characteristics of the micro-dot pattern. A high-precision industrial camera and image recognition algorithm are used to precisely locate the printing area and print the encrypted micro-dot pattern to the designated location. The printing process requires precise control of laser parameters to ensure the quality and accuracy of the micro-dot pattern while avoiding damage to the packaging material.
[0096] Step S5: Decode the micro-dot matrix image of the product with the micro-dot matrix mark and complete the product serial number to obtain the complete product serial number and decoded data; reconstruct the product key according to the preset master key, the complete product serial number and the decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the traceability information of the decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task.
[0097] In an embodiment of the present invention, the consumer uses an app to scan the micro-dot pattern on the product packaging. After pre-processing the image, the app extracts the micro-dot information and decodes the encrypted traceability information and part of the product serial number. The consumer manually enters the remaining serial number information, and the app splices the two parts of the serial number into a complete serial number. The app then uses the preset master key, the complete serial number, and the decoded data to reconstruct the product key locally. Finally, the app uses the reconstructed key to decrypt the traceability information and display the result to the consumer. The entire decryption process is completed offline on the mobile phone, ensuring the speed and convenience of the query.
[0098] Preferably, step S1 includes the following steps:
[0099] Step S11: Acquire production-related information; collect data on the food production process through sensors to obtain sensor data streams;
[0100] Step S12: performing data preprocessing on the sensor data stream to obtain preprocessed sensor data;
[0101] Step S13: storing the pre-processed sensor data on the blockchain to obtain a blockchain record;
[0102] Step S14: perform data association and integration on the blockchain records and production-related information to obtain information integration data;
[0103] Step S15: Generate a multi-dimensional data packet for the information integration data to obtain a multi-dimensional data packet.
[0104] As an example of the present invention, refer to Figure 2 As shown, in this example, step S1 includes:
[0105] Step S11: Acquire production-related information; collect data on the food production process through sensors to obtain sensor data streams;
[0106] In an embodiment of the present invention, during the rice field planting stage, GPS positioning sensors are deployed to record the geographical location of the rice fields, soil moisture sensors record soil moisture, and meteorological stations collect environmental data such as temperature, rainfall, and sunshine duration. When harvesting rice, the yield sensor on the combine harvester is used to record the yield data, and the unique identification of each batch of rice is recorded through an RFID tag. During the rice processing stage, temperature sensors and humidity sensors are used to monitor the drying process, and pressure sensors and vibration sensors are used to monitor the operating status of the equipment during the rice milling process. All sensor data is collected every 1 minute and transmitted to the data acquisition server in real time via a wireless network to form a time series data stream, which is stored in the database, and each data point is timestamped;
[0107] Step S12: performing data preprocessing on the sensor data stream to obtain preprocessed sensor data;
[0108] In an embodiment of the present invention, a sensor data stream is read from a database. First, the data integrity is checked. If data is missing, linear interpolation is used to fill it. Then, the 3-sigma criterion is used to detect and remove outliers from the data of each sensor. The GPS data is coordinate-converted to the standard WGS84 coordinate system. Kalman filtering is performed on environmental data such as temperature and humidity to remove noise interference. Finally, all pre-processed data is arranged in chronological order and stored in the database in JSON format.
[0109] Step S13: storing the pre-processed sensor data on the blockchain to obtain a blockchain record;
[0110] In an embodiment of the present invention, pre-processed sensor data is read from a database. Key data, such as rice field location, planting time, harvesting time, yield, drying temperature, drying time, rice milling pressure, product batch number, etc., are extracted to form a key data set. The key data set is converted into a JSON format string. The JSON string is digitally signed using a private key based on an elliptic curve encryption algorithm to generate signed data. The signed data is used as the transaction content to create a new blockchain transaction. The transaction is broadcast to a consortium chain network based on the Hyperledger Fabric architecture. After verification and confirmation, the transaction is packaged into a new block to form an unalterable blockchain record. The transaction hash value and chain timestamp are recorded, and this information is stored in the database;
[0111] Step S14: perform data association and integration on the blockchain records and production-related information to obtain information integration data;
[0112] In this embodiment of the present invention, the transaction hash value and the on-chain timestamp saved in step S13 are read from the database. The corresponding blockchain on-chain record is retrieved from the blockchain, and the key data set is parsed. At the same time, other production-related information of the batch of rice is obtained from the enterprise resource planning (ERP) system, such as fertilizer usage, pesticide usage, processing plant information, quality inspection information, etc. The transaction hash value is used as the association key to associate and integrate the blockchain data and the ERP data to form complete information integration data, which is then stored in the database;
[0113] Step S15: Generate a multi-dimensional data packet for the information integration data to obtain a multi-dimensional data packet.
[0114] In this embodiment of the present invention, the information integration data generated in step S14 is read from the database. The information integration data is encapsulated into a multidimensional data packet (MD-Packet) according to a predefined format. The data structure of the MD-Packet includes a data header (version number, generation timestamp), a data body (the data integrated in step S14, stored as a key-value pair), and a data check digit (generated by hashing the data body using the SHA-256 algorithm). The generated MD-Packet is stored in the database in JSON format for use in subsequent steps, and the generation time and file size of the MD-Packet are recorded.
[0115] Preferably, step S13 includes the following steps:
[0116] Step S131: screening the pre-processed sensor data for key data to obtain a key data set;
[0117] Step S132: constructing a data structure for the key data set to obtain a JSON data structure;
[0118] Step S133: Sign the JSON data structure with a private key to obtain signed data;
[0119] Step S134: Using the signed data as transaction data, a blockchain transaction is created to obtain a blockchain transaction;
[0120] Step S135: Broadcast the blockchain transaction to the pre-selected alliance chain network, confirm the transaction, and obtain the blockchain record.
[0121] In the embodiments of the present invention, the pre - processed apple juice production sensor data generated in step S12 is read from the database, which includes information such as the GPS coordinates of the apple origin, soil humidity, fertilization date and dosage, pesticide usage, apple picking date, apple variety, water quality data for cleaning, juicing temperature, pasteurization temperature and time, bottling date, and cap batch number. For each case of apple juice, the following key data is extracted: the longitude and latitude of the apple origin (WGS84 coordinate system), apple picking date, apple variety, juicing temperature, pasteurization temperature, pasteurization time, bottling date, and product batch number, forming the key data set for this case of apple juice, and saving it in the CSV file format, with each data field separated by a comma.
[0122] Read the key data set in CSV format generated in step S131. Use a Python script to convert the data in the CSV file into a JSON data structure. The JSON data structure is organized in the form of key - value pairs, for example: `{"Apple Origin Longitude": "116.397428", "Apple Origin Latitude": "39.90923", "Apple Picking Date": "2024 - 08 - 15", "Apple Variety": "Fuji", "Juicing Temperature": "25°C", "Pasteurization Temperature": "85°C", "Pasteurization Time": "30s", "Bottling Date": "2024 - 08 - 16", "Product Batch Number": "20240816001"}`. All numerical data is converted to string type, and special characters are escaped to ensure that the generated JSON data conforms to the standard specification.
[0123] Use the pre - generated ECDSA private key to sign the JSON data structure generated in step S132. First, calculate the hash value of the JSON data using the SHA - 256 algorithm. Then, sign this hash value with the private key to generate a digital signature. Combine the JSON data structure and the digital signature into a new JSON object, for example: `{"data": <JSON data structure>, "signature": <digital signature>}`. Finally, encode this JSON object using Base64 encoding to generate the final signed data string.
[0124] Use the Base64 - encoded signed data generated in step S133 as the transaction data. Set the transaction type to "Apple Juice Production Record". Use the Hyperledger Fabric SDK to create a new transaction proposal, and add the transaction data, transaction type, and target smart contract address (for example, `0x123456789abcdef`) to the transaction proposal. Finally, sign this transaction proposal with the enterprise's private key to generate a signed transaction proposal.
[0125] The signed transaction proposal generated in step S134 is sent to a pre-selected ordering node in the Hyperledger Fabric consortium chain network. The ordering node sorts the transaction proposals and packages them into blocks. These blocks are then distributed to peer nodes in the consortium chain network for verification and confirmation. The peer nodes verify the transaction signature and data integrity and submit the transaction to the ledger. After the transaction is successfully uploaded to the blockchain, a transaction hash value is returned as proof of the blockchain entry. Information such as the transaction hash value, block height, and timestamp is stored in a database for subsequent query and verification.
[0126] Preferably, step S2 includes the following steps:
[0127] Step S21: performing hash calculation on the multi-dimensional data packet to obtain a hash value of the multi-dimensional data packet;
[0128] Step S22: Obtain the unique serial number of the product;
[0129] Step S23: Generate a seed key from the multi-dimensional data packet hash value and the product unique serial number using the preset master key to obtain a seed key;
[0130] Step S24: Perform a key derivation function calculation on the seed key to obtain the product key.
[0131] In this embodiment of the present invention, the multidimensional data packet (MD-Packet) in JSON format generated in step S15 is read from the database. The complete contents of the MD-Packet are calculated using the SHA-256 hash algorithm to obtain a 256-bit hash value, represented as a hexadecimal string. This hash value is stored in a temporary variable for use in key generation in subsequent steps.
[0132] Each milk carton is printed with a unique 128-bit laser-etched serial number consisting of numbers and uppercase letters. A high-speed industrial camera captures the serial number area on the carton and uses optical character recognition (OCR) technology to identify the serial number. The result is converted to a 128-bit string format and verified to ensure the validity and integrity of the serial number. If OCR recognition fails, the serial number is manually entered.
[0133] The 256-bit multidimensional data packet hash value obtained in step S21 and the 128-bit unique product serial number obtained in step S22 are concatenated to form a 384-bit string. A preset 256-bit master key is read from the secure key storage device. The 384-bit string is encrypted using the AES-256 encryption algorithm, using the master key as the encryption key. The first 256 bits of the encrypted result are used as the seed key and stored in hexadecimal string format.
[0134] Use the HKDF key derivation function to expand the 256-bit seed key generated in step S23. Set the HKDF salt value to the UTF-8 encoded value of "Milk Traceability System" and leave the information parameter empty. Use SHA-256 as the HKDF hash algorithm. Derive a 128-bit product key from the seed key, expressed as a hexadecimal string, for subsequent traceability information encryption.
[0135] Preferably, step S3 includes the following steps:
[0136] Step S31: extracting core traceability information from the multi-dimensional data packet to obtain a core traceability information string;
[0137] Step S32: Encrypt the core traceability information string using the product key to obtain encrypted traceability information;
[0138] Step S33: generating micro dot matrix parameters according to the encrypted traceability information to obtain micro dot matrix parameters;
[0139] Step S34: assigning micro-dot attributes according to the micro-dot array parameters and the encrypted traceability information to obtain micro-dot attribute information;
[0140] Step S35: Drawing the micro-dot array image according to the micro-dot array image parameters and the micro-dot attribute information to obtain an encrypted micro-dot array image.
[0141] As an example of the present invention, refer to Figure 3 As shown, in this example, step S3 includes:
[0142] Step S31: extracting core traceability information from the multi-dimensional data packet to obtain a core traceability information string;
[0143] In an embodiment of the present invention, the multi-dimensional data packet (MD-Packet) JSON format data of the bottled mineral water generated in step S15 is read from the database. The following core traceability information is extracted from the MD-Packet: GPS coordinates of the water source (WGS84 format longitude and latitude, for example, "116.397428, 39.90923"), filling date (YYYY-MM-DD format, for example, "2024-09-01"), product batch number (for example, "20240901001"), and quality inspection report number (for example, "QS20240901001"). This information is concatenated into a string and encoded using UTF-8, for example: "116.397428, 39.90923|2024-09-01|20240901001|QS20240901001", as the core traceability information string;
[0144] Step S32: Encrypt the core traceability information string using the product key to obtain encrypted traceability information;
[0145] In this embodiment of the present invention, the core traceability information string obtained in step S31 is encrypted using the 128-bit product key generated in step S24 using the AES-128-CBC encryption mode. The UTF-8 encoding of the fixed value "WaterBottleTrace" is used as the initialization vector (IV). The encrypted data is encoded using Base64 to obtain the final encrypted traceability information string.
[0146] Step S33: generating micro dot matrix parameters according to the encrypted traceability information to obtain micro dot matrix parameters;
[0147] In this embodiment of the present invention, the number of micro dots required is calculated based on the length of the encrypted traceability information generated in step S32 (the length after Base64 encoding). Each micro dot represents 6 bits of information (encoded by the shape, size, and color combination of the micro dot). The micro dot pattern area is set to 5mm 5mm square. The microdot diameter is set to 50 microns. The microdot color is black. Based on the number of microdots and the area size, the coordinates of each microdot are calculated using a uniform distribution algorithm, ensuring a minimum spacing of 100 microns between microdots to avoid overlap. The microdot number, diameter, color, and coordinates are stored as microdot array parameters in JSON format.
[0148] Step S34: assigning micro-dot attributes according to the micro-dot array parameters and the encrypted traceability information to obtain micro-dot attribute information;
[0149] In an embodiment of the present invention, the Base64-encoded encrypted traceability information generated in step S32 is converted into a bit stream. According to the rule that each micro-dot represents 6 bits set in the micro-dot array parameters, the bit stream is allocated to each micro-dot in turn. The first 2 bits determine the shape of the micro-dot (00: circle, 01: square, 10: triangle, 11: pentagon), the next 2 bits determine the size of the micro-dot (00: 50μm, 01: 60μm, 10: 70μm, 11: 80μm, although the basic diameter is set to 50μm, slight changes are allowed here to increase the coding capacity), and the last 2 bits are reserved for use and are not used temporarily. The shape and size information of each micro-dot is stored together with its coordinates to form micro-dot attribute information, and saved in JSON format;
[0150] Step S35: Drawing the micro-dot array image according to the micro-dot array image parameters and the micro-dot attribute information to obtain an encrypted micro-dot array image.
[0151] In this embodiment of the present invention, a microdot pattern is drawn on a 5 mm x 5 mm electronic canvas using a Python image processing library (e.g., Pillow) based on the microdot pattern parameters generated in step S33 and the microdot attribute information generated in step S34. Each microdot is drawn according to its coordinates, shape, and size, and the color is set to black. The generated microdot pattern is saved in bitmap format with a resolution of 1000 dpi to ensure sufficient accuracy.
[0152] Preferably, step S33 includes the following steps:
[0153] Step S331: Analyze the encrypted information attributes of the encrypted traceability information to obtain the encrypted information length parameter;
[0154] Step S332: generating micro-dot basic attribute parameters according to the encrypted information length size parameter and the preset micro-dot basic attribute range to obtain the micro-dot basic attribute parameters;
[0155] Step S333: generating micro-dot shape coding rules based on the encrypted traceability information and the preset micro-dot shape types to obtain the micro-dot shape coding rules;
[0156] Step S334: generating a micro-dot direction coding rule based on the encrypted traceability information and the preset discrete direction information to obtain a micro-dot direction coding rule;
[0157] Step S335: Generate a micro-dot density coding rule based on the encrypted traceability information to obtain a micro-dot density coding rule;
[0158] Step S336: generating micro-dot position parameters according to the micro-dot basic attribute parameters to obtain the micro-dot position parameters;
[0159] Step S337: integrating the micro-dot basic attribute parameters, micro-dot shape coding rules, micro-dot direction coding rules, micro-dot density coding rules and micro-dot position parameters to obtain micro-dot array parameters.
[0160] In this embodiment of the present invention, obtain the Base64-encoded encrypted traceability information string generated in step S32. Calculate the length of the string. For example, if the string length is 256 characters, record the string length in bytes as the encrypted information length parameter. Furthermore, calculate the SHA-256 hash value of the encrypted information for subsequent integrity verification.
[0161] Based on the encrypted information length parameter obtained in step S331 (e.g., 256 bytes), calculate the required number of microdots. Each microdot is assumed to carry 6 bits of information. Therefore, at least (256 * 8) / 6 = 341.33 microdots are required. Round up to the nearest integer, resulting in 342 microdots. The preset microdot basic attribute range is: diameter 40-80 microns, color: black, and shape: round, square, triangle, pentagon. The calculated number of microdots (342), along with the preset diameter range, color, and shape information, are recorded as the microdot basic attribute parameters and saved in JSON format.
[0162] The preset micro-dot shapes include circle, square, triangle, and pentagon. A micro-dot shape encoding rule is generated based on the first four digits of the SHA-256 hash value of the encrypted traceability information. For example, if the first four digits of the hash value are "1011," the circle is encoded as "1011," the square as "1110," the triangle as "1001," and the pentagon as "0110." The shape encoding rule is saved in JSON format.
[0163] The preset discrete direction information is 0 degrees, 45 degrees, 90 degrees, and 135 degrees. A micro-dot direction encoding rule is generated based on bits 5-8 of the SHA-256 hash value of the encrypted traceability information. For example, if bits 5-8 of the hash value are "0110," 0 degrees is encoded as "0110," 45 degrees is encoded as "1001," 90 degrees is encoded as "0100," and 135 degrees is encoded as "1101." The direction encoding rule is saved in JSON format.
[0164] Divide the microdot pattern area into 10×10 coding units. Generate a microdot density encoding rule based on bits 9-16 of the SHA-256 hash value of the encrypted traceability information. For example, if bits 9-16 of the hash value are "11001001," convert this 8-bit binary number to decimal and use it to determine the microdot number range for each coding unit. Save the density encoding rule in JSON format.
[0165] Based on the basic microdot property parameters generated in step S332, specifically the number of microdots (e.g., 342), a Poisson Disc Sampling algorithm is used to generate random coordinates for the 342 microdots within a 5 mm × 5 mm microdot pattern, ensuring a minimum spacing of 60 microns between microdots. The coordinates (x, y) of each microdot are saved in JSON format to form the microdot position parameters.
[0166] The micro-dot basic attribute parameters, micro-dot shape coding rules, micro-dot direction coding rules, micro-dot density coding rules and micro-dot position parameters generated in steps S332 to S336 are integrated into a JSON data structure to form the final micro-dot array parameters.
[0167] Preferably, step S4 includes the following steps:
[0168] Step S41: pre-processing the printing area of the product packaging, and setting the laser parameters according to the encrypted micro-dot pattern to obtain the laser coding parameters;
[0169] Step S42: performing micro-dot array positioning on the encrypted micro-dot array to obtain positioned micro-dot array data;
[0170] Step S43: performing laser printing according to the positioned micro-dot matrix image data and laser coding parameters to obtain a product with a micro-dot matrix mark.
[0171] In an embodiment of the present invention, industrial alcohol is used to clean the predetermined printing area of the metal can of coffee powder to remove impurities such as oil and dust, and ensure that the laser action area is clean. After drying, a 1064nm fiber laser is used for printing. The parameters of the laser are set according to the size (e.g., 5mm×5mm) and micro-dot diameter (e.g., 50 microns) of the encrypted micro-dot array generated in step S35. The laser power is set to 10W, the frequency is set to 50kHz, the scanning speed is set to 200mm / s, and the spot diameter is set to 45 microns. Parameters such as laser power, frequency, scanning speed, and spot diameter are saved in JSON format as laser coding parameters.
[0172] Print a cross-shaped positioning mark on the designated printing area of the coffee powder can. Use a high-precision industrial camera to capture an image of this area. Use an image recognition algorithm to identify the center coordinates of the cross-shaped positioning mark. Based on the identified center coordinates, calculate the precise position of the encrypted micro-dot pattern on the can surface. Perform a corresponding translation transformation on the micro-dot pattern coordinate data to ensure that the center of the micro-dot pattern aligns with the center of the positioning mark. Save the translated micro-dot pattern coordinate data in JSON format as the positioned micro-dot pattern data.
[0173] A 1064nm fiber laser printer with a galvanometer scanning system is controlled to perform laser printing on the surface of the coffee powder can according to the positioned micro-dot pattern data acquired in step S42 and the laser marking parameters set in step S41. The laser printer sequentially applies laser pulses according to the coordinate position of each micro-dot in the micro-dot pattern data, forming micro-dots. The laser irradiation time is determined by the set laser power, frequency, and scanning speed parameters to ensure that the size and depth of each micro-dot meet the preset requirements. After printing is completed, the coffee powder can is labeled with a micro-dot pattern, i.e., a micro-dot-marked product.
[0174] Preferably, step S5 includes the following steps:
[0175] Step S51: collecting a micro-dot matrix image of a product marked with a micro-dot matrix to obtain a micro-dot matrix image;
[0176] Step S52: decoding the micro-dot matrix image to obtain decoded data and partial product serial number information;
[0177] Step S53: completing the product serial number on the partial information of the product serial number to obtain the complete product serial number;
[0178] Step S54: reconstruct the product key according to the preset master key, the complete product serial number and the decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the decoded data to obtain the decrypted traceability information.
[0179] In this embodiment of the present invention, consumers use a smartphone to open the built-in traceability app and aim their camera at the laser-printed microdot pattern on the potato chip bag. The app uses autofocus and image stabilization technology to capture a clear image of the microdot pattern. To improve image quality, the app prompts the user to adjust the shooting angle and distance until a satisfactory image is captured. The captured image has a resolution of 4096 × 3072 pixels and is saved in JPEG format.
[0180] The APP decodes the micro-dot array image in JPEG format obtained in step S51. First, the image is converted into a grayscale image. Then, the image is binarized using an adaptive threshold algorithm to separate the micro-dots from the background. Next, image morphological operations, such as erosion and dilation, are used to remove noise and debris. The Hough circle transform is used to detect micro-dots in the image, and the center coordinates, diameter, and shape features of each micro-dot are extracted. According to the encoding rules defined in step S33, the shape, diameter, and color information of the micro-dots are decoded into a bit stream to obtain decoded data. The decoded data contains encrypted core traceability information and 64-bit product serial number information.
[0181] The app displays the 64-bit portion of the product serial number decoded in step S52 on the screen. The user manually enters the remaining 64-bit serial number printed on the packaging bag. The app concatenates the two parts of the serial number to obtain the complete 128-bit product serial number. The app verifies the complete product serial number to ensure that its format and length meet preset specifications.
[0182] The app reads the preset 256-bit master key from the secure storage area. Using the full 128-bit product serial number obtained in step S53 and the same algorithm as in step S2, combined with the multi-dimensional data packet hash value extracted from the decoded data, the 128-bit product key is regenerated. Using this reconstructed product key and the AES-128-CBC decryption algorithm, the encrypted core traceability information in the decoded data obtained in step S52 is decrypted to obtain the plaintext traceability information. The decrypted traceability information, such as production date, place of origin, batch number, etc., is displayed on the app interface in a user-friendly manner.
[0183] Preferably, step S54 includes the following steps:
[0184] Step S541: extracting information required for key derivation from the decoded data to obtain key derivation parameters;
[0185] Step S542: using the master key and the complete product serial number to perform reverse calculation of the seed key, and reconstructing the seed key according to the key derivation parameters to obtain a reconstructed seed key;
[0186] Step S543: Perform local key derivation calculation using the reconstructed seed key to obtain the reconstructed product key;
[0187] Step S544: extract the encrypted traceability information from the decoded data, and use the reconstructed product key to perform a decryption operation on the traceability information to obtain the decrypted traceability information.
[0188] In this embodiment of the present invention, the information required for key derivation is extracted from the decoded data obtained in step S52. The decoded data is stored in JSON format and contains encrypted core traceability information, a portion of the product serial number, and parameters used for key derivation, such as the hash value of the multidimensional data packet (a 256-bit hexadecimal string). The extracted multidimensional data packet hash value is used as the key derivation parameter and stored in a variable.
[0189] Read the preset 256-bit master key from the app's secure storage area. Concatenate the full 128-bit product serial number obtained in step S53 with the 256-bit multidimensional data packet hash value extracted in step S541 to obtain a 384-bit string. Use the same AES-256 encryption algorithm as in step S23, using the master key as the encryption key, to encrypt the 384-bit string. The first 256 bits of the encrypted result are the reconstructed seed key, which is saved in hexadecimal string format.
[0190] Use the HKDF key derivation function to expand the 256-bit seed key reconstructed in step S542. Set the salt value to the UTF-8 encoded value of "HoneyTraceabilitySystem" and leave the message parameter empty. Use SHA-256 as the HKDF hash algorithm. Derive a 128-bit reconstructed product key from the seed key, expressed as a hexadecimal string.
[0191] Extract the encrypted core traceability information from the decoded data obtained in step S52, which is encoded in Base64. Use the 128-bit reconstructed product key generated in step S543 and the AES-128-CBC decryption mode to decrypt the encrypted core traceability information. The initial vector (IV) uses the same UTF-8 encoding of the fixed value "WaterBottleTrace" as used in step S32 encryption. The decrypted data is a UTF-8-encoded traceability information string, which contains information such as the origin of the honey, honey collection date, filling date, batch number, etc. The decrypted traceability information is displayed on the APP interface in an easy-to-read manner.
[0192] Preferably, the present invention further provides a food information traceability system based on laser coding, which is used to execute the food information traceability method based on laser coding as described above. The food information traceability system based on laser coding comprises:
[0193] The multi-dimensional data acquisition module is used to obtain production-related information; collect production data from the food production process and store it on the blockchain to obtain blockchain records; associate and integrate blockchain records and production-related information, and generate multi-dimensional data packets to obtain multi-dimensional data packets;
[0194] A dynamic key generation module is used to perform hash calculations on a multidimensional data packet to obtain a hash value of the multidimensional data packet; obtain a unique product serial number; use a preset master key to generate a seed key from the hash value of the multidimensional data packet and the unique product serial number, and perform a key derivation function calculation to obtain a product key;
[0195] The micro-dot matrix encoding module is used to encrypt the traceability information according to the multi-dimensional data packet and the product key to obtain the encrypted traceability information; generate micro-dot matrix parameters according to the encrypted traceability information to obtain the micro-dot matrix parameters; and generate an encrypted micro-dot matrix according to the micro-dot matrix parameters and the encrypted traceability information to obtain the encrypted micro-dot matrix.
[0196] Laser micro-dot matrix printing module, used to use encrypted micro-dot matrix pattern to perform laser micro-dot matrix printing on product packaging to obtain micro-dot matrix marked products;
[0197] The mobile terminal decryption module is used to decode the micro-dot matrix image of products with micro-dot matrix labels and complete the product serial number to obtain the complete product serial number and decoded data; reconstruct the product key based on the preset master key, complete product serial number and decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task.
[0198] The present invention is therefore intended to be illustrative and non-restrictive in all respects, with the scope of the invention being defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the application documents are intended to be embraced therein.
[0199] The foregoing description is intended only to provide specific embodiments of the present invention, which will enable those skilled in the art to understand and implement the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not intended to be limited to the embodiments shown herein, but is to be construed in the widest possible manner consistent with the principles and novel features disclosed herein.
Claims
1. A food information traceability method based on laser coding, characterized in that: The following steps are involved: Step S1: Obtain production-related information; collect production data of the food production process and store it on the blockchain to obtain blockchain records; associate and integrate the blockchain records and production-related information, and generate a multidimensional data package to obtain a multidimensional data package; Step S2: performing hash calculation on the multi-dimensional data packet to obtain a hash value of the multi-dimensional data packet; Obtain the product's unique serial number; use the preset master key to generate a seed key for the multi-dimensional data packet hash value and the product's unique serial number, and perform a key derivation function calculation to obtain the product key; Step S3: Encrypting the traceability information according to the multi-dimensional data packet and the product key to obtain encrypted traceability information; Generate micro dot matrix parameters according to the encrypted traceability information to obtain micro dot matrix parameters; Generate an encrypted micro dot matrix image according to the micro dot matrix image parameters and the encrypted traceability information to obtain an encrypted micro dot matrix image; Step S4: Using the encrypted micro-dot pattern to perform laser micro-dot printing on the product packaging to obtain a product with a micro-dot pattern mark; Step S5: Decode the micro-dot matrix image of the product with the micro-dot matrix mark and complete the product serial number to obtain the complete product serial number and decoded data; reconstruct the product key according to the preset master key, the complete product serial number and the decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the traceability information of the decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task.
2. The food information traceability method based on laser coding according to claim 1, characterized in that: Step S1 includes the following steps: Step S11: Acquire production-related information; collect data on the food production process through sensors to obtain sensor data streams; Step S12: performing data preprocessing on the sensor data stream to obtain preprocessed sensor data; Step S13: storing the pre-processed sensor data on the blockchain to obtain a blockchain record; Step S14: perform data association and integration on the blockchain records and production-related information to obtain information integration data; Step S15: Generate a multi-dimensional data packet for the information integration data to obtain a multi-dimensional data packet.
3. The food information traceability method based on laser coding according to claim 2, characterized in that: Step S13 includes the following steps: Step S131: screening the pre-processed sensor data for key data to obtain a key data set; Step S132: constructing a data structure for the key data set to obtain a JSON data structure; Step S133: Sign the JSON data structure with a private key to obtain signed data; Step S134: Using the signed data as transaction data, a blockchain transaction is created to obtain a blockchain transaction; Step S135: Broadcast the blockchain transaction to the pre-selected alliance chain network, confirm the transaction, and obtain the blockchain record.
4. The food information traceability method based on laser coding according to claim 1, characterized in that: Step S2 includes the following steps: Step S21: performing hash calculation on the multi-dimensional data packet to obtain a hash value of the multi-dimensional data packet; Step S22: Obtain the unique serial number of the product; Step S23: Generate a seed key from the multi-dimensional data packet hash value and the product unique serial number using the preset master key to obtain a seed key; Step S24: Perform a key derivation function calculation on the seed key to obtain the product key.
5. The food information traceability method based on laser coding according to claim 1, characterized in that: Step S3 includes the following steps: Step S31: extracting core traceability information from the multi-dimensional data packet to obtain a core traceability information string; Step S32: Encrypt the core traceability information string using the product key to obtain encrypted traceability information; Step S33: generating micro dot matrix parameters according to the encrypted traceability information to obtain micro dot matrix parameters; Step S34: assigning micro-dot attributes according to the micro-dot array parameters and the encrypted traceability information to obtain micro-dot attribute information; Step S35: Drawing the micro-dot array image according to the micro-dot array image parameters and the micro-dot attribute information to obtain an encrypted micro-dot array image.
6. The food information traceability method based on laser coding according to claim 5, characterized in that: Step S33 includes the following steps: Step S331: Analyze the encrypted information attributes of the encrypted traceability information to obtain the encrypted information length parameter; Step S332: generating micro-dot basic attribute parameters according to the encrypted information length size parameter and the preset micro-dot basic attribute range to obtain the micro-dot basic attribute parameters; Step S333: generating micro-dot shape coding rules based on the encrypted traceability information and the preset micro-dot shape types to obtain the micro-dot shape coding rules; Step S334: generating a micro-dot direction coding rule based on the encrypted traceability information and the preset discrete direction information to obtain a micro-dot direction coding rule; Step S335: Generate a micro-dot density coding rule based on the encrypted traceability information to obtain a micro-dot density coding rule; Step S336: generating micro-dot position parameters according to the micro-dot basic attribute parameters to obtain the micro-dot position parameters; Step S337: integrating the micro-dot basic attribute parameters, micro-dot shape coding rules, micro-dot direction coding rules, micro-dot density coding rules and micro-dot position parameters to obtain micro-dot array parameters.
7. The food information traceability method based on laser coding according to claim 1, characterized in that: Step S4 includes the following steps: Step S41: pre-processing the printing area of the product packaging, and setting the laser parameters according to the encrypted micro-dot pattern to obtain the laser coding parameters; Step S42: performing micro-dot array positioning on the encrypted micro-dot array to obtain positioned micro-dot array data; Step S43: performing laser printing according to the positioned micro-dot matrix image data and laser coding parameters to obtain a product with a micro-dot matrix mark.
8. The food information traceability method based on laser coding according to claim 1, characterized in that: Step S5 includes the following steps: Step S51: collecting a micro-dot matrix image of a product marked with a micro-dot matrix to obtain a micro-dot matrix image; Step S52: decoding the micro-dot matrix image to obtain decoded data and partial product serial number information; Step S53: completing the product serial number on the partial information of the product serial number to obtain the complete product serial number; Step S54: reconstruct the product key according to the preset master key, the complete product serial number and the decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the decoded data to obtain the decrypted traceability information.
9. The food information traceability method based on laser coding according to claim 8, characterized in that: Step S54 includes the following steps: Step S541: extracting information required for key derivation from the decoded data to obtain key derivation parameters; Step S542: using the master key and the complete product serial number to perform reverse calculation of the seed key, and reconstructing the seed key according to the key derivation parameters to obtain a reconstructed seed key; Step S543: Perform local key derivation calculation using the reconstructed seed key to obtain the reconstructed product key; Step S544: extract the encrypted traceability information from the decoded data, and use the reconstructed product key to perform a decryption operation on the traceability information to obtain the decrypted traceability information.
10. A food information traceability system based on laser coding, characterized in that: Used to execute the food information traceability method based on laser coding as claimed in claim 1, the food information traceability system based on laser coding comprises: The multi-dimensional data acquisition module is used to obtain production-related information; collect production data from the food production process and store it on the blockchain to obtain blockchain records; associate and integrate blockchain records and production-related information, and generate multi-dimensional data packets to obtain multi-dimensional data packets; A dynamic key generation module is used to perform hash calculations on a multidimensional data packet to obtain a hash value of the multidimensional data packet; obtain a unique product serial number; use a preset master key to generate a seed key from the hash value of the multidimensional data packet and the unique product serial number, and perform a key derivation function calculation to obtain a product key; The micro-dot matrix encoding module is used to encrypt the traceability information according to the multi-dimensional data packet and the product key to obtain the encrypted traceability information; generate micro-dot matrix parameters according to the encrypted traceability information to obtain the micro-dot matrix parameters; and generate an encrypted micro-dot matrix according to the micro-dot matrix parameters and the encrypted traceability information to obtain the encrypted micro-dot matrix. Laser micro-dot matrix printing module, used to use encrypted micro-dot matrix pattern to perform laser micro-dot matrix printing on product packaging to obtain micro-dot matrix marked products; The mobile terminal decryption module is used to decode the micro-dot matrix image of products with micro-dot matrix labels and complete the product serial number to obtain the complete product serial number and decoded data; reconstruct the product key based on the preset master key, complete product serial number and decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task.
Citation Information
Patent Citations
Intelligent anti-counterfeiting traceable drug packing box
CN104766109A
Medical logistics data tracing method based on block chain
CN117150564A