Food information tracing method and system based on laser code spraying
By using blockchain evidence storage and multi-dimensional data packets to generate product keys in food production, traceability information encryption and laser printing, the problem of insufficient security, reliability and convenience of food information traceability methods in the existing technology is solved, and the efficient, safe and convenient traceability of information is achieved.
Patent Information
- Application Number
- CN202510324512.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2045-03-19
AI Technical Summary
The existing food information traceability method based on laser inkjet has the problems of information being easily tampered with, easy to copy, and insufficient convenience for consumer query.
By obtaining information related to food production, conducting blockchain on-chain evidence storage, and generating multi-dimensional data packets, using hash value and product unique serial number to generate product keys, encrypting traceability information, generating encrypted micro dot matrix diagrams for laser printing, and consumers decoding through mobile APPs to obtain traceability information.
It realizes the immutability and traceability of information, enhances the security and convenience of traceability information, and ensures that consumers can quickly and reliably obtain traceability information of food.
Smart Images

Figure CN119963220A_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 also been further developed, and traceability solutions based on RFID, NFC, blockchain and other technologies have emerged. Laser coding technology has gradually become an important technical means in the field of food traceability due to its high precision, permanence and difficulty in tampering.
[0003] The existing food information traceability method based on laser coding usually encodes product information into a QR code or barcode, and then uses a laser coding machine to print the code on the product packaging. Consumers can obtain product information by scanning the code. However, this method has the following three main disadvantages: 1. Traceability information is easy to be tampered with: Traditional laser coding traceability solutions usually use static QR codes or barcodes, and their 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 wrong. In addition, simple QR codes or barcodes are easy to copy, and the codes of genuine products can be easily copied and pasted on counterfeit and shoddy products; 2. Traceability information is easy to copy and forge: Traditional QR codes and barcodes have low technical barriers and are easy to copy and forge; 3. Insufficient convenience for consumers to query: Traditional laser coding traceability methods usually require consumers to visit specific websites or platforms to query product information. This requires consumers to connect to the Internet and relies on the stability of the server. In the case of poor network conditions or server failure, consumers may not be able to obtain traceability information in a timely manner. Summary of the invention
[0004] 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.
[0005] To achieve the above purpose, a food information traceability method based on laser coding includes the following steps: 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 multidimensional data packet to obtain the hash value of the multidimensional data packet; obtaining the unique serial number of the product; using the preset master key to generate a seed key for 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 the product key; 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; 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 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 decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task.
[0006] The present invention collects data in real time through sensors and combines it with a timestamp to ensure the accuracy and integrity of the data. Blockchain technology is used for data storage, which realizes 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 using AES encryption and HKDF key derivation functions, the uniqueness and unpredictability of each product key are guaranteed, counterfeiting and tampering are effectively prevented, and the security of traceability information is enhanced. 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 be tampered with or removed. 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 networking, 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.
[0007] Preferably, step S1 comprises 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.
[0008] The present invention realizes the automatic collection of production information by deploying sensors in various links of the production process and collecting data in real time, avoids the errors and omissions that may be caused by manual records, improves the efficiency and accuracy of data collection, and provides a reliable data source for subsequent traceability information. The continuous data stream and time stamp records can fully reflect the dynamic changes of the production process and provide more detailed information for product quality control and problem tracing. The original sensor data is preprocessed, including operations such as format unification, outlier removal, missing value filling and data normalization, which effectively improves the quality and reliability of the data. Noise and outliers are removed to avoid interference of these data on subsequent analysis and ensure the accuracy of traceability information. Data preprocessing also lays a good foundation for subsequent data analysis and processing. The preprocessed key sensor data is uploaded to the blockchain, and the decentralized and tamper-proof characteristics of the blockchain are used to ensure the authenticity and integrity of the data, prevent the data from being maliciously tampered with, and enhance consumers' trust in traceability information. The blockchain chain records also provide a reliable basis for subsequent data tracing and verification. The records on the blockchain are associated and integrated with other production-related information to form a complete data chain, connecting the originally scattered data, achieving the comprehensiveness and traceability of the data, enabling consumers to understand the full life cycle information of the product from raw materials to production, and further enhancing the reliability and transparency of the traceability information. The integrated data is encapsulated into a multi-dimensional data packet (MD-Packet), which provides a structured data organization method to facilitate data storage, transmission and processing. MD-Packet contains rich product information, providing a complete data foundation for subsequent encryption and traceability, and also providing consumers with more comprehensive product information. The standardized data format also facilitates data exchange and sharing between different systems.
[0009] Preferably, step S13 comprises 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, creating a blockchain transaction 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.
[0010] The present invention removes redundant information, reduces the cost of data storage and processing, improves efficiency, and makes subsequent blockchain on-chain operations more efficient by screening out key data, such as core parameters such as origin, time, and temperature, from a large amount of sensor data. It also helps to protect the security of core traceability information. The key data set is constructed into a JSON data structure, making the data more standardized and easy to process. The JSON format has good readability and compatibility, facilitates the storage, transmission and parsing of data, and is also convenient for data exchange with other systems, providing convenience for subsequent signature and on-chain operations. The JSON data structure is signed using a private key to ensure the non-repudiation and integrity of the data. The signature mechanism can prevent data from being tampered with, ensure the authenticity and source of the on-chain data, and enhance the security of traceability information. The signed data is created as a blockchain transaction, which is ready for data on-chain. The structured format of blockchain transactions contains necessary information such as transaction data, type, and target address, making transaction processing more standardized and efficient. The blockchain transaction is broadcast to the alliance chain network, and after verification and confirmation by multiple nodes, the data is finally written into the blockchain, realizing the permanent preservation and non-tamperability of the data. The alliance chain mechanism ensures the decentralization and transparency of data, 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 a strong proof of the authenticity and integrity of the data.
[0011] Preferably, step S2 comprises 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 a preset master key to obtain a seed key; Step S24: Perform a key derivation function calculation on the seed key to obtain a product key.
[0012] The present invention can convert complex, variable-length data packets into fixed-length hash values by performing hash calculation on multidimensional data packets, thereby simplifying the subsequent key generation process and improving the calculation efficiency. The hash value can also be used to verify the integrity of the data packet to ensure that the data has not been tampered with during transmission and storage. The unique serial number of the product is obtained, and a unique identity is established for each product, which is the key to achieving accurate traceability. The unique serial number can associate the product with its corresponding production data to prevent information confusion and improve the accuracy and reliability of traceability. The seed key is generated using the master key, the multidimensional data packet hash value and the product unique serial number, ensuring the security of the seed key and making it difficult to be directly guessed or cracked. The seed key generation mechanism combined with product-specific information (serial number and data packet hash value) makes the seed key of each product unique, further improving the security. The seed key is expanded using key derivation functions such as HKDF to generate the final product key, which can enhance the security of the key. Even if part of the seed key information is leaked, it is difficult to derive the final product key, thereby improving the system's anti-attack capability. 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 the traceability information.
[0013] Preferably, step S3 comprises 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: Generate micro-dot pattern parameters according to the encrypted traceability information to obtain micro-dot pattern 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.
[0014] The present invention forms a concise core traceability information string by extracting core traceability information, such as key data such as origin, date, batch number, etc., from a multidimensional data packet, which helps to improve the efficiency of subsequent encryption and encoding and reduce the storage space occupied. Extracting core information also allows consumers to quickly obtain the most critical product traceability information. The core traceability information is encrypted using a product key to ensure the security of the traceability information and prevent information leakage and tampering. The encrypted information can only be decrypted by users with the corresponding key, which effectively protects the traceability information of the product and safeguards the rights and interests of manufacturers and consumers. According to the encrypted traceability information, the micro-dot matrix parameters can be generated, and the complexity of the micro-dot matrix, such as the number, density, and arrangement of micro-dots, can be dynamically adjusted according to the amount of information, thereby improving the efficiency and flexibility of encoding. This makes the design of the micro-dot matrix more flexible and can adapt to different application scenarios and data volumes. Encoding the encrypted information into the properties of the micro-dots, such as shape, size, direction, etc., realizes the hiding and anti-counterfeiting of information. It is difficult for the naked eye to directly read the information contained in the micro-dots, and it can only be obtained through a specific decoding algorithm and key, which increases the difficulty of forgery and improves the security of the traceability information. The micro-dot matrix is drawn according to the parameter and attribute information, and the abstract data is converted into a visual graphic, which provides direct input for laser printing. The generated micro-dot matrix contains encrypted traceability information and is difficult to be recognized and copied by the naked eye, thus realizing the safe storage and transmission of information.
[0015] Preferably, step S33 includes the following steps: Step S331: Analyze the encrypted information attributes of the encrypted traceability information to obtain the encrypted information length size 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 according to the encrypted traceability information and the preset micro-dot shape types to obtain micro-dot shape coding rules; Step S334: generating micro-dot direction coding rules according to the encrypted traceability information and the preset discrete direction information to obtain micro-dot direction coding rules; Step S335: generating a micro-dot density coding rule according to 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 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.
[0016] By analyzing the properties of the encrypted traceability information such as the length and size, the present invention can provide basic data for the subsequent generation of micro-dot array parameters, such as determining the required number of micro-dots, so that the design of the micro-dot array is more scientific and reasonable, and the coding efficiency is improved. Understanding the properties of the encrypted information is also helpful in selecting a suitable coding strategy. According to the encrypted information length size parameters and the preset micro-dot basic property range, micro-dot basic property parameters that meet actual needs can be generated, such as micro-dot diameter, color, optional shape, etc. This ensures that the generated micro-dot array can accommodate all encrypted information and can be clearly printed in a specified area, and takes into account anti-counterfeiting performance and recognition efficiency. Generating micro-dot shape coding rules according to the encrypted traceability information can increase the complexity and security of the coding, making the micro-dot array more difficult to be cracked or forged. The dynamically generated coding rules also increase the difficulty of analysis and cracking by attackers. Similar to shape coding, generating micro-dot direction coding rules according to the encrypted traceability information further improves the complexity and security of the coding, makes information hiding more concealed, increases the difficulty of forgery, and further improves the anti-counterfeiting performance. Generating microdot density coding rules based on encrypted traceability information can more effectively utilize the area of the microdot array, improve information density, and store more information in a limited area. Dynamic density coding rules also increase the difficulty of cracking. Generating microdot position parameters based on microdot basic attribute parameters ensures the reasonable distribution of microdots in the array area, avoids microdot overlap or excessive sparseness, ensures the quality and recognizability of the microdot array, and provides accurate coordinate data for subsequent laser printing. All microdot-related parameters are integrated together to form complete microdot array parameters, which provide necessary parameter information for subsequent microdot array drawing and laser printing, ensuring the unity and consistency of the entire process. The integrated parameters also facilitate subsequent management and maintenance.
[0017] Preferably, step S4 comprises 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: positioning the encrypted micro-dot array image to obtain the positioned micro-dot array image data; Step S43: performing laser printing according to the located micro-dot matrix image data and laser coding parameters to obtain a product with a micro-dot matrix mark.
[0018] The present invention can improve the adhesion of the laser on the packaging material, ensure the quality of the printing, make the micro dots clear and durable, and reduce the printing errors by pre-treating the printing area, such as cleaning and applying a laser sensitive coating. The laser parameters are set according to the characteristics of the encrypted micro-dot array image, which can ensure the accuracy and clarity of the micro-dot array image while avoiding damage to the packaging material. The printing position of the micro-dot array image is accurately positioned by positioning marks and image recognition algorithms, which ensures the accuracy and consistency of the micro-dot array image printing and avoids decoding errors caused by positioning deviations. Accurate positioning also allows the micro-dot array image to be reliably identified and decoded, even when there is slight deformation or contamination on the packaging surface. Laser printing is performed according to the positioned data and laser parameters, and the encrypted micro-dot array image can be printed on the product packaging with high precision, realizing physical binding of information, making it difficult for the information to be tampered with or removed. High-precision printing also ensures the readability of the micro-dot array image and the reliability of decoding, and ultimately achieves product anti-counterfeiting and traceability.
[0019] Preferably, step S5 comprises the following steps: Step S51: collecting micro-dot matrix images of products with micro-dot matrix labels to obtain micro-dot matrix images; Step S52: Decode the micro-dot matrix image to obtain decoded data and part of the product serial number information; Step S53: completing the product serial number on the partial information of the product serial number to obtain a 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.
[0020] The present invention collects micro-dot pattern images through a smartphone camera, providing consumers with a convenient way to obtain traceability information. The APP's autofocus and image stabilization technology, as well as user interaction guidance, improve the quality of image acquisition and provide clear image data for the subsequent decoding process. The collected images are preprocessed and decoded to extract the encrypted traceability information and part of the product serial number, providing necessary data for subsequent information decryption and verification. Image preprocessing steps, such as grayscale, binarization and denoising, improve the accuracy of micro-dot detection, and can effectively decode 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 a complete serial number, realizing the combination of user participation and information verification, improving security, and ensuring that only users with genuine products can obtain complete traceability information. The product key is reconstructed locally and the traceability information is decrypted, which can be completed without networking, ensuring the rapidity of the query and offline availability, and improving the user experience. At the same time, since the decryption process is completed on the user's mobile phone, the user's data privacy and security are also protected. This mechanism also avoids dependence on centralized servers and improves the stability and reliability of the system.
[0021] Preferably, 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 parameter to obtain a reconstructed seed key; Step S543: Perform local key derivation calculation using the reconstructed seed key to obtain a 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.
[0022] The present invention extracts the parameters required for key derivation from the decoded data, such as the hash value of the multidimensional data packet, and prepares the necessary parameter information for the subsequent key reconstruction process. This ensures the integrity and accuracy of the key reconstruction process and lays the foundation for finally obtaining the correct traceability information. The seed key is reconstructed using the master key, the complete product serial number and the key derivation parameter, so that the seed key can be safely reconstructed at the user end, and the transmission of sensitive information in the network is avoided, thereby improving the security of the system. This process also ensures that only users with the complete product serial number and the correct decoded data can reconstruct the seed key, thereby preventing forgery and tampering. The reconstructed seed key is used to perform local key derivation calculation to generate the same product key as that during encryption, thereby realizing the localized generation of the key, avoiding the security risks that may exist in the key during network transmission, and further ensuring the security of the traceability information. The encrypted traceability information is decrypted using the reconstructed product key, and the traceability information of the product is finally obtained, completing the entire traceability process. The decryption operation is performed locally, thereby ensuring the privacy of user data, and there is no need to rely on network connection, thereby improving the query speed and efficiency, and providing users with a convenient traceability experience.
[0023] 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, and 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 of 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; The dynamic key generation module is used to perform hash calculation on the multidimensional data packet to obtain the hash value of the multidimensional data packet; obtain the unique serial number of the product; use the preset master key to generate a seed key for the hash value of the multidimensional data packet and the unique serial number of the product, and perform a key derivation function calculation to obtain the 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; 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; A laser micro-dot matrix printing module is used to perform laser micro-dot matrix printing on product packaging using an encrypted micro-dot matrix image to obtain a product with a micro-dot matrix mark; The mobile terminal decryption module is used to decode the micro-dot matrix image of the product with 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, complete product serial number and decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the decoded data for traceability information to obtain the decrypted traceability information, so as to realize the food information traceability task. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 The figure is a schematic diagram of the steps of a food information traceability method based on laser coding; Figure 2 Detailed implementation flow chart of step S1 in the present invention; Figure 3 It is a schematic diagram of the detailed implementation steps of step S3 in the present invention.
[0025] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0026] The technical method of the present invention is described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by technicians in this field without creative work are within the scope of protection of the present invention.
[0027] In addition, the accompanying drawings are only schematic illustrations of the present invention and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. The functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor methods and / or microcontroller methods.
[0028] It should be understood that, although the terms "first", "second", etc. may be used herein to describe various units, these units should not be limited by these terms. These terms are used only to distinguish one unit from another unit. For example, without departing from the scope of the exemplary embodiments, the first unit may be referred to as the second unit, and similarly the second unit may be referred to as the first unit. The term "and / or" used herein includes any and all combinations of one or more of the listed associated items.
[0029] To achieve this, please refer to Figures 1 to 3, a food information traceability method based on laser coding, comprising the following steps: 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 multidimensional data packet to obtain the hash value of the multidimensional data packet; obtaining the unique serial number of the product; using the preset master key to generate a seed key for 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 the product key; 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; 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 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 decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task.
[0030] In the embodiment of the present invention, reference Figure 1 FIG. 1 is a schematic diagram 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: 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; In the embodiment of the present invention, taking milk powder production as an example, all parameters from the origin of the milk source, collection time, 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 timestamped. After the collected data is preprocessed 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 to obtain an unalterable blockchain record. Finally, the hash value of the blockchain record is integrated with other production-related information to generate a multidimensional data packet (MD-Packet), providing a complete data foundation for subsequent steps; Step S2: performing hash calculation on the multidimensional data packet to obtain the hash value of the multidimensional data packet; obtaining the unique serial number of the product; using the preset master key to generate a seed key for 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 the product key; In the 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 package is obtained. After the hash value and the serial number are concatenated, a seed key is generated using a preset master key and an 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 of each product is unique, and it is difficult to forge the key even if part of the information is leaked; 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; In the embodiment of the present invention, the core traceability information, such as the place of origin, production date, shelf life, etc., is first extracted from the multidimensional data packet, and the product key generated in step S2 is used for AES-128 encryption. Then, according to the length of the encrypted information and the preset parameters, the parameters of the micro-dot array are generated, including the number, diameter, shape, color, position and arrangement of the micro-dots. Using these parameters, the encrypted information is encoded into the properties of the micro-dots, and finally an encrypted micro-dot array that is difficult to identify by the naked eye is generated; 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; In an embodiment of the present invention, the printing area on the packaging surface is pre-processed, such as cleaning and applying a laser-sensitive coating. Then, according to the characteristics of the packaging material and the micro-dot pattern, the parameters of the laser inkjet printer, such as laser power, frequency, scanning speed, etc., are set. A high-precision industrial camera and image recognition algorithm are used to accurately locate the printing area and print the encrypted micro-dot pattern to the specified position. 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; Step S5: Decode the micro-dot matrix image of the product with 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 decoded data to obtain the decrypted traceability information, so as to realize the food information traceability task.
[0031] 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. Then, the APP 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 displays the result to the consumer. The entire decryption process is completed offline on the mobile phone, ensuring the speed and convenience of the query.
[0032] Preferably, step S1 comprises 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.
[0033] As an example of the present invention, refer to Figure 2 As shown, in this example, step S1 includes: Step S11: Acquire production-related information; collect data on the food production process through sensors to obtain sensor data streams; 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 through the wireless network to form a time series data stream, which is stored in the database. Each data point is timestamped; Step S12: performing data preprocessing on the sensor data stream to obtain preprocessed sensor data; In an embodiment of the present invention, the sensor data stream is read from the 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 converted to convert the original coordinates into 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 are arranged in chronological order and stored in the database in JSON format; Step S13: storing the pre-processed sensor data on the blockchain to obtain a blockchain record; 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. Record the transaction hash value and chain timestamp, and store this information in the database; Step S14: perform data association and integration on the blockchain records and production-related information to obtain information integration data; In the embodiment of the present invention, the transaction hash value and the chain timestamp saved in step S13 are read from the database. The corresponding blockchain 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, and store it in the database; Step S15: Generate a multi-dimensional data packet for the information integration data to obtain a multi-dimensional data packet.
[0034] In the 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 is stored in the form of a key-value pair) and a data check digit (generated by performing a hash calculation on 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.
[0035] Preferably, step S13 comprises 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, creating a blockchain transaction 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.
[0036] In the embodiment 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, bottle cap batch number, etc. 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 a 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.
[0037] 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 key - value pairs. For example: `{"Longitude of Apple Origin": "116.397428", "Latitude of Apple Origin": "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 complies with the standard specification.
[0038] 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.
[0039] 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.
[0040] The signed transaction proposal generated in step S134 is sent to the pre-selected sorting node of the Hyperledger Fabric consortium chain network. The sorting node sorts the transaction proposals and packages them into blocks. The block is then distributed to the peer node in the consortium chain network for verification and confirmation. The peer node verifies the signature and data integrity of the transaction and submits the transaction to the ledger. After the transaction is successfully uploaded to the chain, the transaction hash value is returned as the certificate of the blockchain on-chain record. The transaction hash value, block height and timestamp and other information are stored in the database for subsequent query and verification.
[0041] Preferably, step S2 comprises 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 a preset master key to obtain a seed key; Step S24: Perform a key derivation function calculation on the seed key to obtain a product key.
[0042] In the embodiment of the present invention, the multidimensional data packet (MD-Packet) JSON format data of the boxed milk generated in step S15 is read from the database. The complete content of the MD-Packet is calculated using the SHA-256 hash algorithm to obtain a 256-bit hash value, which is represented in the form of a hexadecimal string. The hash value is stored in a temporary variable for key generation in subsequent steps.
[0043] Each carton of milk is printed with a 128-bit unique serial number generated by laser etching, which consists of numbers and uppercase letters. A high-speed industrial camera is used to photograph the serial number area on the box, and optical character recognition (OCR) technology is used to identify the serial number. The recognition result is converted into 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 entered manually.
[0044] The 256-bit multidimensional data packet hash value obtained in step S21 and the 128-bit product unique serial number obtained in step S22 are concatenated to form a 384-bit string. The 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 and the master key as the encryption key. The first 256 bits of the encryption result are used as the seed key and stored in hexadecimal string format.
[0045] Use the HKDF key derivation function to expand the 256-bit seed key generated in step S23. Set the salt value of HKDF to the UTF-8 encoded value of "Milk Traceability System" and the information parameter to be empty. Use SHA-256 as the hash algorithm for HKDF. Derive a 128-bit product key from the seed key, expressed in hexadecimal string format, for subsequent traceability information encryption.
[0046] Preferably, step S3 comprises 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: Generate micro-dot pattern parameters according to the encrypted traceability information to obtain micro-dot pattern 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.
[0047] As an example of the present invention, refer to Figure 3 As shown, in this example, step S3 includes: Step S31: extracting core traceability information from the multi-dimensional data packet to obtain a core traceability information string; 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; Step S32: Encrypt the core traceability information string using the product key to obtain encrypted traceability information; In the embodiment of the present invention, the 128-bit product key generated in step S24 is used to encrypt the core traceability information string obtained in step S31 using the AES-128-CBC encryption mode. The UTF-8 encoding of the fixed value "WaterBottleTrace" is used as the initial vector (IV). The encrypted data is encoded using Base64 to obtain the final encrypted traceability information string; Step S33: Generate micro-dot pattern parameters according to the encrypted traceability information to obtain micro-dot pattern parameters; In the embodiment of the present invention, the number of micro dots required is calculated according to 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. According to the number of microdots and the area size, the coordinates of each microdot are calculated using a uniform distribution algorithm to ensure that the minimum spacing between microdots is 100 microns to avoid overlap. The information such as the number of microdots, diameter, color and coordinates is stored as microdot array parameters in JSON format; Step S34: assigning micro-dot attributes according to the micro-dot array parameters and the encrypted traceability information to obtain micro-dot attribute information; 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), and 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 backup and are not used for the time being. 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; 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.
[0048] In the embodiment of the present invention, according to the micro-dot array parameters generated in step S33 and the micro-dot attribute information generated in step S34, a Python image processing library (such as Pillow) is used to draw a micro-dot array on a 5mm×5mm electronic canvas. The corresponding micro-dots are drawn according to the coordinates, shape and size information of each micro-dot, and the color is set to black. The generated micro-dot array is saved in a bitmap format with a resolution of 1000dpi to ensure sufficient accuracy.
[0049] Preferably, step S33 includes the following steps: Step S331: Analyze the encrypted information attributes of the encrypted traceability information to obtain the encrypted information length size 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 according to the encrypted traceability information and the preset micro-dot shape types to obtain micro-dot shape coding rules; Step S334: generating micro-dot direction coding rules according to the encrypted traceability information and the preset discrete direction information to obtain micro-dot direction coding rules; Step S335: generating a micro-dot density coding rule according to 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 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.
[0050] In the embodiment of the present invention, the Base64-encoded encrypted traceability information string generated in step S32 is obtained. The length of the string is calculated, for example, the string length is 256 characters. The string length is recorded as the encrypted information length size parameter in bytes. In addition, the SHA-256 hash value of the encrypted information is calculated for subsequent integrity verification.
[0051] According to the encrypted information length size parameter (e.g., 256 bytes) obtained in step S331, the required number of micro dots is calculated. It is preset that each micro dot can carry 6 bits of information. Therefore, at least (256*8) / 6=341.33 micro dots are required. Round up to get 342 micro dots. The preset micro dot basic attribute range is: diameter 40-80 microns, color: black, shape: round, square, triangle, pentagon. The calculated number of micro dots 342, as well as the preset diameter range, color and shape information are recorded as micro dot basic attribute parameters and saved in JSON format.
[0052] The preset micro-dot shape types include circle, square, triangle and pentagon. Generate the micro-dot shape encoding rules based on the first 4 digits of the SHA-256 hash value of the encrypted traceability information. For example, if the first 4 digits of the hash value are "1011", the circle is encoded as "1011", the square is encoded as "1110", the triangle is encoded as "1001", and the pentagon is encoded as "0110". Save the shape encoding rules in JSON format.
[0053] The preset discrete direction information is 0 degrees, 45 degrees, 90 degrees, and 135 degrees. Generate the micro-point direction encoding rules based on the 5th to 8th bits of the SHA-256 hash value of the encrypted traceability information. For example, if the 5th to 8th bits 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". Save the direction encoding rules in JSON format.
[0054] Divide the micro-dot matrix area into 10×10 coding units. Generate micro-dot density coding rules based on the 9th to 16th bits of the SHA-256 hash value of the encrypted traceability information. For example, if the 9th to 16th bits of the hash value are "11001001", the 8-bit binary number is converted to a decimal number to determine the range of micro-dots in each coding unit. Save the density coding rules in JSON format.
[0055] According to the micro-dot basic attribute parameters generated in step S332, especially the number of micro-dots (for example, 342), the Poisson Disc Sampling algorithm is used to generate random coordinates of 342 micro-dots in the micro-dot array area of 5mm×5mm, ensuring that the minimum spacing between micro-dots is 60 microns. The coordinates (x, y) of each micro-dot are saved in JSON format to form micro-dot position parameters.
[0056] 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.
[0057] Preferably, step S4 comprises 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: positioning the encrypted micro-dot array image to obtain the positioned micro-dot array image data; Step S43: performing laser printing according to the located micro-dot matrix image data and laser coding parameters to obtain a product with a micro-dot matrix mark.
[0058] 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 to 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 matrix 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.
[0059] Print a cross-shaped positioning mark on the predetermined printing area of the coffee powder tank. Use a high-precision industrial camera to capture an image of the 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 matrix on the surface of the tank, and perform a corresponding translation transformation on the coordinate data of the micro-dot matrix to ensure that the center of the micro-dot matrix is aligned with the center of the positioning mark. Save the micro-dot matrix coordinate data after the translation transformation in JSON format as the micro-dot matrix data after positioning.
[0060] Control the 1064nm fiber laser inkjet printer with a galvanometer scanning system to perform laser printing on the surface of the coffee powder can according to the positioned micro-dot pattern data obtained in step S42 and the laser printing parameters set in step S41. The laser inkjet printer performs laser pulse irradiation in sequence according to the coordinate position of each micro-dot in the micro-dot pattern data to form 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 the printing is completed, a coffee powder can with a micro-dot matrix logo, that is, a micro-dot matrix logo product, is obtained.
[0061] Preferably, step S5 comprises the following steps: Step S51: collecting micro-dot matrix images of products with micro-dot matrix labels to obtain micro-dot matrix images; Step S52: Decode the micro-dot matrix image to obtain decoded data and part of the product serial number information; Step S53: completing the product serial number on the partial information of the product serial number to obtain a 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.
[0062] In the embodiment of the present invention, the consumer uses a smartphone to open the built-in traceability APP and points the camera at the laser-printed micro-dot pattern area on the potato chip packaging bag. The APP uses autofocus and image stabilization technology to obtain a clear micro-dot pattern image. In order to improve the image quality, the APP will prompt the user to adjust the shooting angle and distance until an image that meets the requirements is obtained. The captured image resolution is 4096×3072 pixels and is saved in JPEG format.
[0063] APP decodes the micro-dot matrix 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 microdots from the background. Next, image morphological operations, such as erosion and dilation, are used to remove noise and noise. The Hough circle transform is used to detect the microdots in the image, and the center coordinates, diameter, and shape features of each microdot are extracted. According to the encoding rules defined in step S33, the shape, diameter, and color information of the microdots are decoded into a bit stream to obtain decoded data. The decoded data contains encrypted core traceability information and 64-bit partial product serial number information.
[0064] The APP displays the 64-bit product serial number information decoded in step S52 on the screen. The user manually enters the remaining 64-bit product serial number information printed on the packaging bag. The APP splices the two parts of the serial number information to obtain a complete 128-bit product serial number. The APP verifies the complete product serial number to ensure that its format and length meet the preset specifications.
[0065] The APP reads the preset 256-bit master key from the secure storage area. Use the complete 128-bit product serial number obtained in step S53 and the same algorithm in step S2, combined with the multi-dimensional data packet hash value extracted from the decoded data, to regenerate the 128-bit product key. Use the reconstructed product key and the AES-128-CBC decryption algorithm to decrypt the encrypted core traceability information in the decoded data obtained in step S52 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.
[0066] Preferably, 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 parameter to obtain a reconstructed seed key; Step S543: Perform local key derivation calculation using the reconstructed seed key to obtain a 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.
[0067] In the 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, which contains encrypted core traceability information, part of the product serial number, and parameters for key derivation, such as the hash value of the multidimensional data packet (256-bit hexadecimal string). The extracted multidimensional data packet hash value is used as a key derivation parameter and stored in a variable.
[0068] Read the preset 256-bit master key from the secure storage area of the APP. Concatenate the complete 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 step S23, using the master key as the encryption key, to encrypt the 384-bit string. The first 256 bits of the encryption result are the reconstructed seed key, which is saved in hexadecimal string format.
[0069] The 256-bit seed key reconstructed in step S542 is expanded using the HKDF key derivation function. The salt value is set to the UTF-8 encoded value of "HoneyTraceabilitySystem" and the information parameter is set to empty. SHA-256 is used as the hash algorithm for HKDF. A 128-bit reconstructed product key is derived from the seed key, expressed in hexadecimal string format.
[0070] 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 to decrypt the encrypted core traceability information using the AES-128-CBC decryption mode. The initial vector (IV) uses the same UTF-8 encoding of the fixed value "WaterBottleTrace" as that 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.
[0071] 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, and 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 of 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; The dynamic key generation module is used to perform hash calculation on the multidimensional data packet to obtain the hash value of the multidimensional data packet; obtain the unique serial number of the product; use the preset master key to generate a seed key for the hash value of the multidimensional data packet and the unique serial number of the product, and perform a key derivation function calculation to obtain the 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; 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; A laser micro-dot matrix printing module is used to perform laser micro-dot matrix printing on product packaging using an encrypted micro-dot matrix image to obtain a product with a micro-dot matrix mark; The mobile terminal decryption module is used to decode the micro-dot matrix image of the product with 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, complete product serial number and decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the decoded data for traceability information to obtain the decrypted traceability information, so as to realize the food information traceability task.
[0072] Therefore, the embodiments should be regarded as illustrative and non-restrictive from all points, and the scope of the present invention is limited by the appended claims rather than the above description, and it is therefore intended that all changes falling within the meaning and range of equivalent elements of the application documents are included in the present invention.
[0073] The above description is only a specific embodiment of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be 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 will not be limited to the embodiments shown herein, but should conform to the widest scope consistent with the principles and novel features invented 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 unique serial number of the product; use the preset master key to generate a seed key for the multi-dimensional data packet hash value and the unique serial number of the product, 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 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 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 is 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 is 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, creating a blockchain transaction 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 a preset master key to obtain a seed key; Step S24: Perform a key derivation function calculation on the seed key to obtain a 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: Generate micro-dot pattern parameters according to the encrypted traceability information to obtain micro-dot pattern 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 is 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 size 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 according to the encrypted traceability information and the preset micro-dot shape types to obtain micro-dot shape coding rules; Step S334: generating micro-dot direction coding rules according to the encrypted traceability information and the preset discrete direction information to obtain micro-dot direction coding rules; Step S335: generating a micro-dot density coding rule according to 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 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: positioning the encrypted micro-dot array image to obtain the positioned micro-dot array image data; Step S43: performing laser printing according to the located 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 micro-dot matrix images of products with micro-dot matrix labels to obtain micro-dot matrix images; Step S52: Decode the micro-dot matrix image to obtain decoded data and part of the product serial number information; Step S53: completing the product serial number on the partial information of the product serial number to obtain a 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 parameter to obtain a reconstructed seed key; Step S543: Perform local key derivation calculation using the reconstructed seed key to obtain a 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 of 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; The dynamic key generation module is used to perform hash calculation on the multidimensional data packet to obtain the hash value of the multidimensional data packet; obtain the unique serial number of the product; use the preset master key to generate a seed key for the hash value of the multidimensional data packet and the unique serial number of the product, and perform a key derivation function calculation to obtain the 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; 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; A laser micro-dot matrix printing module is used to perform laser micro-dot matrix printing on product packaging using an encrypted micro-dot matrix image to obtain a product with a micro-dot matrix mark; The mobile terminal decryption module is used to decode the micro-dot matrix image of the product with 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, complete product serial number and decoded data to obtain the reconstructed product key; use the reconstructed product key to decrypt the decoded data for traceability information 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
Invisible anti-counterfeiting technology based on glass material
CN119035784A
Method, device and equipment for controlling display terminal through dynamic code matching and storage medium
CN119094237A
Cited By
Production date anti-counterfeiting tracing system based on font encryption
CN120672357A
Commodity traceability management intelligent anti-counterfeiting method and system based on Internet of Things
CN121391301A
Vehicle-specification-level online and offline dual-mode key management method, terminal, medium and product
CN121442333A
Agricultural product tracing method and system based on Internet of Things technology
CN121481575A