An agricultural product traceability method and system based on internet of things technology
By automatically collecting and encrypting agricultural product traceability data through IoT devices, and combining it with blockchain notarization technology to generate a unique traceability identifier, the problem of low data collection efficiency and low credibility in traditional agricultural product traceability is solved, and data security and reliable verification are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- DA NONG TECH CO LTD
- Filing Date
- 2026-01-08
- Publication Date
- 2026-04-10
AI Technical Summary
Existing agricultural product traceability technologies suffer from low data collection efficiency, poor real-time performance, susceptibility to human interference, unreliable data storage, reliance on centralized platforms for query results, and difficulty in verifying authenticity.
IoT devices are used to automatically collect traceability data, which is then encrypted and uploaded to the blockchain network for storage. A unique traceability identifier is generated by combining the device identifier with the data. Users can query the encrypted traceability data and decrypt it to obtain the original data.
It improves the accuracy and real-time nature of traceability data, ensures data security and credibility, and allows users to easily verify the authenticity of agricultural product information, thus standardizing supply chain management.
Smart Images

Figure CN121481575B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of agricultural product traceability, and in particular to an agricultural product traceability method and system based on Internet of Things technology. BACKGROUND
[0002] At present, agricultural product traceability technology mainly develops around the three core links of "data collection-storage-inquiry". In the data collection link, traditional technology mainly relies on manual recording (such as paper account book, manual input of electronic system) or single simple equipment (such as ordinary temperature and humidity recorder), which has the problems of low data collection efficiency, poor real-time performance, and easy human interference; in the data storage link, the mainstream way is centralized server storage, and any subject in the supply chain can modify the traceability data of its own management node through technical means, which leads to the problem that the data credibility cannot be guaranteed; in the data inquiry link, the traditional system mainly adopts local link inquiry (such as only covering the production or sales link), and the inquiry result depends on the centralized platform for publishing, so it is difficult for consumers to verify the authenticity of the data. SUMMARY
[0003] In order to help improve the credibility and authenticity of agricultural product traceability information, the present application provides an agricultural product traceability method and system based on Internet of Things technology.
[0004] In the first aspect, the present application provides an agricultural product traceability method based on Internet of Things technology, which adopts the following technical scheme:
[0005] An agricultural product traceability method based on Internet of Things technology, comprising:
[0006] obtaining traceability full-link nodes of agricultural products;
[0007] collecting agricultural product traceability data of each node based on Internet of Things collection equipment pre-set at each node;
[0008] performing first re-encryption processing on the collected agricultural product traceability data to generate encrypted traceability data;
[0009] uploading the encrypted traceability data to a block chain network for storage and generating a block chain storage hash value;
[0010] obtaining device identifiers of the Internet of Things collection equipment corresponding to each node;
[0011] generating an agricultural product unique traceability identifier based on the block chain storage hash value and the device identifier;
[0012] receiving a traceability inquiry request of a user, the traceability inquiry request carrying the agricultural product unique traceability identifier;
[0013] retrieve corresponding encrypted traceability data from the blockchain network based on the unique traceability identifier of the agricultural product;
[0014] decrypt the retrieved encrypted traceability data and obtain decrypted agricultural product traceability data.
[0015] Optionally, the first re-encryption processing of the collected agricultural product traceability data to generate encrypted traceability data includes:
[0016] obtain a device key of each Internet of Things collection device;
[0017] encrypt the collected agricultural product traceability data using the device key as an encryption key to generate primary encrypted data;
[0018] obtain a node public key of a blockchain network;
[0019] perform secondary encryption processing on the primary encrypted data and the corresponding device key digest using the node public key as an encryption key to generate the encrypted traceability data.
[0020] Optionally, the uploading of the encrypted traceability data to the blockchain network for notarization and the generation of a blockchain notarization hash value include:
[0021] block the encrypted traceability data according to a preset time interval to generate a plurality of traceability data blocks;
[0022] obtain a node identifier based on the traceability full-link node;
[0023] add a timestamp and a node identifier to each of the traceability data blocks, and then upload the traceability data blocks to each consensus node of the blockchain network;
[0024] control the consensus nodes to verify the traceability data blocks, and write the traceability data blocks into a blockchain block after verification;
[0025] perform double hash calculation on the traceability data blocks written into the blockchain block to generate the blockchain notarization hash value.
[0026] Optionally, the generation of the unique traceability identifier of the agricultural product based on the blockchain notarization hash value and the device identifier includes:
[0027] obtain an initial code of the agricultural product;
[0028] splice the blockchain notarization hash value, the device identifier of each node, and the initial code to generate an original traceability identifier;
[0029] perform encoding processing on the original traceability identifier to generate the unique traceability identifier of the agricultural product.
[0030] Optionally, the decryption processing of the decrypted traceability data includes:
[0031] Obtaining a node private key of the blockchain network;
[0032] Taking the node private key as a decryption key, the encrypted traceability data is decrypted for the first time, and a primary encrypted data and a device key digest are obtained;
[0033] Based on the device identifier of each node, the corresponding device key is matched;
[0034] The matched device key is hashed to generate a key verification digest;
[0035] The key verification digest is compared with the device key digest, if they are consistent, the device key is taken as a decryption key, the primary encrypted data is decrypted for the second time, and the agricultural product traceability data is obtained.
[0036] Optionally, the device key of each Internet of Things collection device includes:
[0037] Collecting the hardware feature information of the Internet of Things collection device;
[0038] The hardware feature information is standardized to generate a hardware feature string;
[0039] The hardware feature string is hashed to obtain a device base key;
[0040] The device base key and the device first networking timestamp are XORed to generate an initial device key;
[0041] The initial device key and the node identifier are associated and bound to generate an identifier device key;
[0042] Based on the preset key update period, the identifier device key is dynamically updated to generate the current effective device key.
[0043] Optionally, the initial device key and the node identifier are associated and bound to generate an identifier device key, including:
[0044] Obtaining the hash value of the node identifier;
[0045] The initial device key is segmented and divided into several key segments according to the preset length;
[0046] The hash value of the node identifier is inserted between each key segment to form a key-identifier mixed string;
[0047] Hash computing is performed on the key-identity mixed string to generate a first binding check value;
[0048] The identity device key is generated based on the first binding check value and the key-identity mixed string.
[0049] Optionally, the identity device key is generated based on the first binding check value and the key-identity mixed string, comprising:
[0050] Obtaining the data features corresponding to the key-identity mixed string;
[0051] The first binding check value is logically split according to the data features to obtain the key check sub-item corresponding to the key segment and the identity check sub-item corresponding to the node identity;
[0052] A key-identity association mapping model is established, the key segment is dynamically bound with the key check sub-item, and the node identity is feature-matched with the identity check sub-item to form a bidirectional check link;
[0053] Based on the bidirectional check link, the key-identity mixed string is structurally reorganized;
[0054] The reorganized mixed string is processed through a preset key fusion algorithm to generate an identity device key.
[0055] In a second aspect, the present application also discloses a farm product traceability system based on an Internet of Things technology, which adopts the following technical scheme:
[0056] A farm product traceability system based on an Internet of Things technology, comprising:
[0057] A node acquisition module is configured to acquire a traceability full-link node of a farm product;
[0058] A data acquisition module is configured to acquire farm product traceability data of each node based on an Internet of Things acquisition device preset at each node;
[0059] A data encryption module is configured to perform first re-encryption processing on the acquired farm product traceability data to generate encrypted traceability data;
[0060] A block chain storage module is configured to upload the encrypted traceability data to a block chain network for storage and to generate a block chain storage hash value;
[0061] A device identity acquisition module is configured to acquire a device identity of an Internet of Things acquisition device corresponding to each node;
[0062] A traceability identity generation module is configured to generate a unique farm product traceability identity based on the block chain storage hash value and the device identity;
[0063] The request receiving module is configured to receive a traceability query request of a user, wherein the traceability query request carries the unique traceability identifier of the agricultural product;
[0064] The data retrieving module is configured to retrieve corresponding encrypted traceability data from the blockchain network based on the unique traceability identifier of the agricultural product;
[0065] The decryption module is configured to perform decryption processing on the retrieved encrypted traceability data and obtain decrypted agricultural product traceability data.
[0066] In summary, the present application has the following beneficial technical effects:
[0067] Through automatic data collection by Internet of Things devices, errors and human interference in manual recording are avoided, and the accuracy and real-time performance of traceability data are improved; with the dual protection of encryption processing and blockchain storage, data theft and tampering are prevented, and the security and credibility of traceability information are ensured; relying on the unique traceability identifier, full-link data query is realized, and users can conveniently verify the authenticity of agricultural product information, effectively solving the problems of low data credibility and incomplete query in traditional traceability systems, protecting consumer rights and interests and standardizing agricultural product supply chain management. BRIEF DESCRIPTION OF DRAWINGS
[0068] Figure 1 is the main flowchart of an agricultural product traceability method based on Internet of Things technology according to an embodiment of the present application;
[0069] Figure 2 is a step flowchart for generating encrypted traceability data;
[0070] Figure 3 is a step flowchart for generating a blockchain storage hash value;
[0071] Figure 4 is a step flowchart for generating a unique traceability identifier of an agricultural product;
[0072] Figure 5 is a step flowchart for performing decryption processing on the retrieved encrypted traceability data;
[0073] Figure 6 is a step flowchart for obtaining each Internet of Things collection device;
[0074] Figure 7 is a step flowchart for associating and binding an initial device key with a node identifier to generate an identifier device key;
[0075] Figure 8 is a step flowchart for generating an identifier device key based on a first binding verification value and a key-identifier mixed string;
[0076] Figure 9is a module diagram of an agricultural product traceability system based on Internet of Things technology according to an embodiment of the present application.
[0077] attached Figure 9 Label Description:
[0078] 1, node acquisition module; 2, data acquisition module; 3, data encryption module; 4, block chain storage module; 5, device identification acquisition module; 6, traceability identification generation module; 7, request receiving module; 8, data retrieval module; 9, decryption module. DETAILED DESCRIPTION
[0079] In a first aspect, the present application discloses an agricultural product traceability method based on Internet of Things technology.
[0080] Referring to Figure 1 An agricultural product traceability method based on Internet of Things technology, comprising steps S101 to S109:
[0081] Step S101: Obtain the traceability full-link nodes of agricultural products.
[0082] Specifically, the traceability full-link nodes refer to the collection of all key links in the complete process of agricultural products from production to consumption, including planting links (fields), processing links (factories), warehousing links (cold storage), transportation links (logistics vehicles), and sales links (supermarkets / e-commerce warehouses), etc. In this embodiment, by analyzing the agricultural product supply chain, the responsible subjects (such as farmers, processing plants, logistics companies) and geographical locations of each link are determined, the key nodes that need to collect data are determined, and a complete traceability link list is formed.
[0083] Step S102: Collect agricultural product traceability data of each node based on the Internet of Things collection devices preset at each node.
[0084] Specifically, the Internet of Things collection device refers to a hardware device with data collection and networking functions, such as temperature and humidity sensors, GPS locators, weight sensors, cameras, etc. Agricultural product traceability data refers to information that can reflect the quality and flow of agricultural products, including soil humidity / fertilization records during planting, sterilization temperature / time during processing, vehicle temperature / location during transportation, and storage time during sales, etc. In this embodiment, corresponding Internet of Things devices are installed at each traceability node, such as soil temperature and humidity sensors in the field and GPS and temperature sensors in the logistics vehicle. Data is collected in real time through the devices and automatically uploaded to the data platform through a wireless network (such as 4G / 5G / LoRa), avoiding errors and tampering of manual records.
[0085] Step S103: Perform first re-encryption processing on the collected agricultural product traceability data to generate encrypted traceability data.
[0086] Specifically, the first re-encryption processing refers to the first security protection operation on the original data, and the purpose is to prevent the data from being stolen or tampered with during transmission or storage; the encrypted traceability data refers to the traceability data that cannot be directly read after encryption processing, and the original information can be recovered by decryption through a specific key. In this embodiment, a symmetric encryption algorithm (such as AES algorithm) is used to encrypt the collected original traceability data using a preset key, and the plaintext data (which can be directly read) is converted into ciphertext data (in the form of random codes) to generate encrypted traceability data.
[0087] Step S104: uploading the encrypted traceability data to the blockchain network for storage and generating a blockchain storage hash value.
[0088] Specifically, the blockchain storage hash value refers to a 32-bit string obtained by performing hash calculation (such as SHA-256) on the encrypted traceability data, which uniquely corresponds to the batch data and can be used to verify the data integrity; in this embodiment, the encrypted traceability data is uploaded to the consensus node (such as a regulatory node) of the blockchain network. After the consensus node verifies the legality of the data through the consensus mechanism (such as PoS), the data is written into the blockchain block; the encrypted data written is subjected to SHA-256 hash calculation to generate a unique storage hash value and store it.
[0089] Step S105: obtaining the device identifier of the Internet of Things collection device corresponding to each node.
[0090] Specifically, the device identifier refers to the unique digital identity card of the Internet of Things device, which is usually the SN code (serial number) or MAC address of the device when it is manufactured, and is used to distinguish different collection devices; in this embodiment, the SN code of each node collection device is called from the device management module of the cloud data platform to form a node-device identifier correspondence table.
[0091] Step S106: generating a unique agricultural product traceability identifier based on the blockchain storage hash value and the device identifier.
[0092] Specifically, the unique agricultural product traceability identifier refers to a special code for querying agricultural product traceability information, which is usually in the form of a two-dimensional code or a bar code and contains information such as data location and device source; in this embodiment, the blockchain storage hash value, the device identifier of each node, and the initial code of the agricultural product are spliced, and the spliced string is subjected to Base64 encoding to generate a unique traceability identifier, which is converted into a two-dimensional code and attached to the packaging of the agricultural product.
[0093] Step S107: receiving a traceability query request of a user, the traceability query request carrying the unique traceability identifier of the agricultural product.
[0094] Specifically, the traceability query request refers to an operation instruction of a user (such as a consumer) for querying agricultural product information, and the unique traceability identifier needs to be provided to trigger the query; in this embodiment, the user scans the traceability QR code on the package through a mobile terminal, and the system receives the query request carrying the unique identifier (such as a "Base64 encoded string") and uploads it to the traceability platform.
[0095] Step S108: Based on the unique traceability identifier of the agricultural product, the corresponding encrypted traceability data is retrieved from the blockchain network.
[0096] Specifically, in this embodiment, the system decodes the unique traceability identifier, extracts the blockchain storage hash value therein, and uses the hash value as an index to match the corresponding block in the blockchain network, and retrieve the stored encrypted traceability data.
[0097] Step S109: The retrieved encrypted traceability data is decrypted and processed, and the decrypted agricultural product traceability data is obtained.
[0098] Specifically, in this embodiment, the preliminary encrypted data is obtained by using the blockchain node private key to decrypt, and the original traceability data is finally obtained by using the Internet of Things device key to decrypt the preliminary data, and is displayed to the user.
[0099] The agricultural product traceability method based on the Internet of Things technology provided in this embodiment first sorts the traceability full-link nodes of the agricultural product from production to sales, collects the traceability data in real time through the Internet of Things collection device preset in each node, performs first encryption processing on the collected data to generate encrypted traceability data, uploads the encrypted traceability data to the blockchain network for storage and generates a blockchain storage hash value, and then generates a unique traceability identifier of the agricultural product in combination with the device identifier of each node Internet of Things collection device; when receiving the query request of the user carrying the unique traceability identifier, the corresponding encrypted traceability data is retrieved from the blockchain network, and the original traceability data is provided to the user after decryption processing.
[0100] The data is automatically collected by the Internet of Things device, avoiding errors and human interference in manual recording, improving the accuracy and real-time performance of the traceability data; with the double protection of encryption processing and blockchain storage, the data is prevented from being stolen and tampered with, ensuring the security and credibility of the traceability information; relying on the unique traceability identifier to realize full-link data query, the user can conveniently verify the authenticity of the agricultural product information, effectively solving the problems of low data credibility and incomplete query in the traditional traceability system, protecting the consumer rights and interests and standardizing the agricultural product supply chain management.
[0101] Reference Figure 2 In one of the embodiments of the present embodiment, step S103 performs first encryption processing on the collected agricultural product traceability data to generate encrypted traceability data, including steps S201 to S204:
[0102] Step S201: Obtain the device key of each Internet of Things collection device.
[0103] Specifically, the device key is a unique encryption key assigned to each Internet of Things device and stored in the device security chip, which is only readable by the device and the system. In this embodiment, the system sends a key request instruction to each node's Internet of Things collection device through the MQTTs security protocol, and the Internet of Things collection device reads the key from the security chip and feeds it back to the system.
[0104] Step S202: Encrypt the collected agricultural product traceability data using the device key as the encryption key to generate primary encrypted data.
[0105] Specifically, the primary encrypted data refers to the intermediate ciphertext encrypted using the device key, which is the first result of double encryption; in this embodiment, the original traceability data is encrypted using the device key through the AES-256 algorithm to generate the primary encrypted data.
[0106] Step S203: Obtain the node public key of the blockchain network.
[0107] Specifically, the node public key refers to the public key in the asymmetric encryption key pair of the blockchain node, which can be distributed externally and used to encrypt data (only the corresponding private key can decrypt); in this embodiment, the public key of the supervisory node responsible for storing the batch of data is retrieved from the node list of the blockchain network, which is publicly available in the network.
[0108] Step S204: Perform secondary encryption processing on the primary encrypted data and the corresponding device key digest using the node public key as the encryption key to generate encrypted traceability data.
[0109] Specifically, the device key digest refers to a fixed-length string obtained by SHA-256 hashing of the device key, which is used to verify the integrity of the key and does not contain the key itself; the secondary encryption processing refers to re-encrypting "primary encrypted data + device key digest" using the node public key to form double protection; in this embodiment, the device key is calculated using SHA-256 to obtain the device key digest, and then the primary encrypted data and the digest are concatenated, and the concatenated string is encrypted using the RSA algorithm with the node public key as the key to generate the final encrypted traceability data.
[0110] The agricultural product traceability method based on Internet of Things technology provided in this embodiment first obtains the device key of each Internet of Things collection device, encrypts the collected agricultural product traceability data using the device key as the encryption key to generate primary encrypted data, then obtains the node public key of the blockchain network, and performs secondary encryption on the primary encrypted data and the corresponding device key digest using the node public key as the encryption key to finally generate encrypted traceability data.
[0111] The double encryption mode of combining the device key and the blockchain node public key ensures the safety of the data collection source through the device key and guarantees the safety of the data transmission and the evidence storage process through the blockchain node public key, so that the traceability data is prevented from being stolen or tampered in the encryption, transmission and storage links, and the security protection level of the agricultural product traceability data is further improved.
[0112] With reference to Figure 3 In one of the embodiments of the present embodiment, the step S104 includes steps S301 to S305 of uploading the encrypted traceability data to the blockchain network for evidence storage and generating a blockchain evidence hash value.
[0113] Step S301: The encrypted traceability data is processed by block according to a preset time interval, and a plurality of traceability data blocks are generated.
[0114] Specifically, the block processing refers to splitting the large-capacity encrypted data according to the preset time interval (such as 1 hour / block) for the operation of uploading and storing; in the present embodiment, if the encrypted data is “transportation temperature data from 8:00 to 12:00 on November 5th”, the data is processed by block according to the 1-hour interval, and 4 traceability data blocks (8:00-9:00 block, 9:00-10:00 block, etc.) are generated.
[0115] Step S302: Based on the traceability full-link node, the node identifier is obtained.
[0116] Specifically, the node identifier refers to the unique code allocated to each traceability full-link node, which is used to mark the data source node; in the present embodiment, the unique identifier of each node is extracted from the node list.
[0117] Step S303: After adding the time stamp and the node identifier to each traceability data block, the traceability data block is uploaded to each consensus node of the blockchain network.
[0118] Specifically, the time stamp refers to a digital seal recording the generation time of the data block (such as “2024-11-05 08:00:00”), which ensures the time sequence of the data is traceable; the consensus node refers to the node participating in the data verification in the blockchain network (such as the enterprise node and the regulatory node), which needs to reach a consensus to write data; in the present embodiment, the time stamp and the corresponding node identifier are added to each data block, and the marked data block is synchronized to more than three consensus nodes of the blockchain through the P2P network.
[0119] Step S304: The consensus nodes verify the traceability data block, and write the traceability data block to the blockchain block after the verification is passed.
[0120] Specifically, in this embodiment, the consensus node checks whether the timestamp of the data block is reasonable, whether the node identifier is in the link list, and whether the encryption format is correct, etc. After more than 50% of the nodes are verified, the data block is written into the newly generated blockchain block and associated with the hash value of the previous block.
[0121] Step S305: Double hash calculation is performed on the traceability data block written into the blockchain block to generate a blockchain storage hash value.
[0122] Specifically, double hash calculation refers to first performing SHA-256 calculation on a single data block, and then performing second SHA-256 calculation on the hash values of all data blocks to ensure the integrity of the overall data. In this embodiment, the SHA-256 hash value of each data block written into the block is calculated separately, all single hash values are spliced, and the SHA-256 hash value is calculated again to generate the final blockchain storage hash value.
[0123] The agricultural product traceability method based on the Internet of Things technology provided by the present embodiment first divides the encrypted traceability data into several traceability data blocks at a predetermined time interval, obtains node identifiers based on traceability full-link nodes, adds timestamps and node identifiers to each traceability data block, and uploads them to each consensus node of the blockchain network. The consensus nodes are controlled to verify the traceability data blocks, and the verified data blocks are written into the blockchain block. Finally, double hash calculation is performed on the traceability data blocks written into the block to generate a blockchain storage hash value.
[0124] The block processing improves the uploading and storage efficiency of the encrypted traceability data. The timestamps and node identifiers give the data clear timing and source traceability. The consensus node verification ensures the legality of the data. The tamper-proof nature of the blockchain ensures the security of data storage. The storage hash value generated by double hash calculation further strengthens the data integrity check, and the safety, effectiveness and traceability of the traceability data storage are comprehensively ensured.
[0125] Reference Figure 4 In one embodiment of the present embodiment, step S106 generates a unique agricultural product traceability identifier based on the blockchain storage hash value and the device identifier, including steps S401 to S403:
[0126] Step S401: Obtain the initial code of the agricultural product.
[0127] Specifically, the initial code refers to the basic code of the agricultural product when it leaves the factory, which contains product category, production date and batch information (such as "wheat20241105batch01" representing 01 batch of wheat on November 5, 2024); in this embodiment, the initial code of the batch of agricultural products is retrieved from the ERP system of the agricultural product production enterprise to ensure that the code is unique and contains basic information.
[0128] Step S402: splice the blockchain storage hash value, the device identifier of each node and the initial code to generate an original traceability identifier.
[0129] Specifically, the splicing process refers to combining multiple key information into a string in a fixed order to ensure that the original identifier contains data location, device source and basic information; in this embodiment, the original traceability identifier is generated by splicing in the order of "initial code + device identifier + storage hash value".
[0130] Step S403: encoding processing is performed on the original traceability identifier to generate a unique traceability identifier of the agricultural product.
[0131] Specifically, the encoding processing refers to converting the original identifier in the form of a long string into a compact and easy-to-scan code (such as Base64 + two-dimensional code) to facilitate user query; in this embodiment, the original traceability identifier is Base64 encoded to shorten the string length, and then the encoded string is converted into a two-dimensional code and printed on the packaging of the agricultural product to form a unique traceability identifier.
[0132] The agricultural product traceability method based on the Internet of Things technology provided in this embodiment acquires the initial code of the agricultural product, splices the blockchain storage hash value, the device identifier of the Internet of Things collection device of each node and the initial code to generate an original traceability identifier, and then performs encoding processing on the original traceability identifier to finally generate a unique traceability identifier of the agricultural product; by fusing the basic information of the agricultural product (initial code), the core information of data storage (blockchain storage hash value) and the source information of data collection (device identifier) to generate a unique traceability identifier, the uniqueness and exclusivity of the identifier are ensured, and the precise association between the traceability identifier and the full-link data is realized, so that the user can quickly retrieve complete traceability information through a single identifier, which simplifies the query process and further enhances the traceability and association of the traceability information.
[0133] Reference Figure 5 In one of the embodiments of the present embodiment, the decryption processing of the retrieved encrypted traceability data in step S109 includes steps S501 to S505:
[0134] Step S501: acquire the node private key of the blockchain network.
[0135] Specifically, the node private key refers to the private key in the asymmetric encryption key pair of the blockchain node, which is only held by the node itself and is used to decrypt the data encrypted by the public key, and needs to be strictly kept secret; in this embodiment, the system retrieves the private key (such as "SK2024001...") of the corresponding node from the encrypted database storing the node private key through a hardware security module (HSM) without storing on the ground.
[0136] Step S502: First decryption of the encrypted traceability data is performed by taking the node private key as the decryption key, and the primary encrypted data and the device key digest are obtained.
[0137] Specifically, in the embodiment, the encrypted traceability data is decrypted by taking the node private key as the decryption key through the RSA algorithm, and the "primary encrypted data + device key digest" spliced in step S204 is restored, and the two parts of content are split, wherein the decryption key is a digital key paired with the encryption key, and is specially used to restore the encrypted ciphertext data to readable plaintext data.
[0138] Step S503: The corresponding device key is matched based on the device identifier of each node.
[0139] Specifically, in the embodiment, the device key corresponding to the device is matched according to the device identifier from the node-device identifier correspondence table.
[0140] Step S504: The device key matched is subjected to hash calculation to generate a key verification digest.
[0141] Specifically, in the embodiment, the SHA-256 hash calculation is performed on the matched device key to generate the key verification digest.
[0142] Step S505: The key verification digest and the device key digest are compared, and if they are consistent, the device key is taken as the decryption key to perform the second decryption of the primary encrypted data to obtain the agricultural product traceability data.
[0143] Specifically, in the embodiment, the key verification digest and the device key digest are compared, and if they are consistent, it indicates that the device key has not been tampered with, and the data source is legal. The device key is taken as the decryption key to decrypt the primary encrypted data through the AES-256 algorithm to obtain the readable original traceability data.
[0144] The agricultural product traceability method based on the Internet of Things technology provided by the embodiment is to first obtain the node private key of the blockchain network, take the node private key as the decryption key to perform the first decryption of the encrypted traceability data, obtain the primary encrypted data and the device key digest, then match the corresponding device key based on the Internet of Things collection device identifier of each node, perform the hash calculation on the matched device key to generate the key verification digest, compare the key verification digest and the device key digest, if they are consistent, take the device key as the decryption key to perform the second decryption of the primary encrypted data, and finally obtain the agricultural product traceability data.
[0145] The double decryption mechanism of "node private key + device key" is adopted, and the device key digest is compared and verified, which not only ensures the security of the decryption process and avoids illegal cracking of encrypted data, but also verifies the legality and integrity of the device key through the digest verification, guarantees the authenticity and accuracy of the traceability data after decryption, and makes the traceability information obtained by the user reliable and tamper-proof.
[0146] Reference Figure 6 In one of the embodiments of the present embodiment, the step S201 of obtaining the device key of each Internet of Things collection device includes steps S601 to S606:
[0147] Step S601: Collect the hardware feature information of the Internet of Things collection device.
[0148] Specifically, the hardware feature information refers to the unique properties of the Internet of Things device hardware, such as CPU serial number, memory MAC address, and security chip ID, which cannot be tampered with and is used to generate a device base key; in the present embodiment, the system collects the hardware information such as CPU serial number and security chip ID of the device through a device management protocol (such as TR-069).
[0149] Step S602: Standardize the hardware feature information to generate a hardware feature string.
[0150] Specifically, standardization refers to converting hardware information of different formats into a unified format to avoid format confusion; in the present embodiment, special symbols (such as "-" and "_") in the hardware feature information are removed and converted into a unified format of lowercase letters + numbers, for example, "CPU2024-001-005" and "SE2024_001_005" are processed into "cpu2024001005se2024001005" to generate a hardware feature string in a unified format.
[0151] Step S603: Hash calculation is performed on the hardware feature string to obtain a device base key.
[0152] Specifically, the device base key refers to an initial key generated based on the hardware features, which is the core basis of the device key and has uniqueness due to the uniqueness of the hardware features; in the present embodiment, SHA-512 hash algorithm is used to calculate the standardized hardware feature string to obtain a 64-bit fixed-length hash value as the device base key.
[0153] Step S604: XOR operation is performed on the device base key and the device first networking timestamp to generate an initial device key.
[0154] Specifically, the first networking timestamp refers to the time record when the device accesses the traceability system for the first time (such as "2024-11-0108:30:00" converted into Unix timestamp "1730401800"); the XOR operation is a binary logical operation, and the result is 0 if the corresponding bits of two binary numbers are the same, and 1 if they are different, which is used to enhance the randomness of the key; the initial device key is an initial digital key generated based on the device hardware features and the first networking information, which is the source of generating the identification device key and dynamically updating the key; in this embodiment, the device base key (hexadecimal) is converted into binary format, the first networking Unix timestamp is also converted into binary format, and then the XOR operation is performed on the two binary data to obtain new binary data, and finally the operation result is converted into a hexadecimal string to generate the initial device key.
[0155] Step S605: associating and binding the initial device key with the node identifier to generate an identification device key.
[0156] Specifically, the identification device key refers to the initial device key bound with the node identifier, which not only retains the uniqueness of the device but also associates the data source node for easy traceability and verification; in this embodiment, the initial device key is bound with the identifier of the corresponding node through the process of "key segmentation-identifier insertion-hash verification" to generate the identification device key.
[0157] Step S606: dynamically updating the identification device key based on a preset key update period to generate a currently valid device key.
[0158] Specifically, the key update period refers to the system preset key replacement time interval (such as 30 days / time), which is used to reduce the risk of key leakage and improve security; in this embodiment, the system records the generation time of the identification device key, triggers the update according to the preset period (such as 30 days), and then performs the XOR operation based on the original identification device key combined with the current update timestamp to generate a new identification device key, and finally synchronizes the new key to the device security chip through the security protocol to replace the old key, ensuring that the currently used device key is always valid and up-to-date.
[0159] The agricultural product traceability method based on the Internet of Things technology provided by the embodiment comprises the following steps: first, collecting the hardware feature information of the Internet of Things collection device, standardizing the hardware feature information to generate a hardware feature string, performing hash calculation on the hardware feature string to obtain a device base key, performing XOR operation on the device base key and the device first networking timestamp to generate an initial device key, then associating and binding the initial device key with the node identifier to generate an identification device key, and finally dynamically updating the identification device key based on a preset key update period to generate a currently valid device key.
[0160] The key is generated based on the unique hardware features of the device, ensuring the uniqueness and non-falsifiability of the device key, enhancing the security of the key through XOR operation and node identification binding, and further reducing the risk of key leakage through preset periodic dynamic updating, thereby comprehensively constructing a high-security level device key system and providing reliable key support for the encryption of traceability data, and ensuring the safety of traceability data from the source.
[0161] Reference Figure 7 In one of the embodiments of the present embodiment, step S605 associates and binds the initial device key with the node identification to generate an identification device key including steps S701 to S705:
[0162] Step S701: Obtain the hash value of the node identification.
[0163] Specifically, in the present embodiment, SHA-256 hash calculation is performed on the node identification to obtain a 32-bit hash value as the encrypted representation of the node identification.
[0164] Step S702: Segment the initial device key and divide it into several key segments according to a preset length.
[0165] Specifically, key segmentation refers to splitting the initial device key in the form of a long string into segments of a fixed length (e.g., 8 bits / segment) to facilitate the insertion of the node identification hash value; in the present embodiment, the preset segment length is 8 bits, and the initial device key (e.g., "d4f8a2c6e0b391758d3e2f1a0b4c6d7e") is split into several segments, such as "d4f8a2c6", "e0b39175", "8d3e2f1a", "0b4c6d7e".
[0166] Step S703: Insert the hash value of the node identification between each key segment to form a key-identification hybrid string.
[0167] Specifically, the key-identification hybrid string refers to a string that combines key segments and node identification hash values, achieving preliminary binding of the key and node identification; in the present embodiment, it is inserted according to the rule "key segment 1 + node identification hash value segment 1 + key segment 2 + node identification hash value segment 2 +...", for example, the node identification hash value "3e8a7d9b2f5c1046" is split into "3e8a", "7d9b", "2f5c", and "1046", and inserted between the four key segments to form the hybrid string "d4f8a2c63e8ae0b391757d9b8d3e2f1a2f5c0b4c6d7e1046".
[0168] Step S704: Perform hash calculation on the key-identification hybrid string to generate a first binding verification value.
[0169] Specifically, in this embodiment, the first binding verification value refers to a hash value for verifying the integrity of the binding of the key and the node identifier, ensuring that the mixed string is not tampered with.
[0170] Specifically, the SHA-384 hash calculation is performed on the key-identifier mixed string to obtain a 48-bit hash value (such as “9b2d7f4a8c1e305f6d8b1a2c3e4f506a7b8c9d0e1f2a3b4c...”), which is used as the first binding verification value.
[0171] Step S705: generating an identifier device key based on the first binding verification value and the key-identifier mixed string.
[0172] Specifically, in this embodiment, the first binding verification value and the key-identifier mixed string are combined to generate the final identifier device key through the process of “data feature extraction-verification value splitting-association binding-reorganization fusion”.
[0173] The agricultural product traceability method based on the Internet of Things technology provided by the embodiment first acquires a hash value of a node identifier, performs segmented processing on an initial device key and divides the initial device key into a plurality of key segments according to a preset length, inserts the hash value of the node identifier between the key segments to form a key-identifier mixed string, performs hash calculation on the mixed string to generate a first binding verification value, and finally generates an identifier device key based on the first binding verification value and the key-identifier mixed string.
[0174] By deeply binding the node identifier and the initial device key, the device key is strongly associated with the traceability node, which not only ensures the uniqueness and exclusive association of the key, but also strengthens the integrity and security of the key binding through the hash verification of the mixed string, avoids illegal replacement or tampering of the key, and provides a high-security key that is accurately matched with the node for traceability data encryption, further strengthening the security defense line of traceability data.
[0175] Reference Figure 8 In one of the embodiments of the present embodiment, step S705 of generating an identifier device key based on the first binding verification value and the key-identifier mixed string includes steps S801 to S805:
[0176] Step S801: acquiring data features corresponding to the key-identifier mixed string.
[0177] Specifically, the data features refer to the intrinsic properties of the mixed string, including segment length, character distribution, hash value check bit, etc., which are used for splitting and binding verification; in this embodiment, the system extracts the key features of the mixed string (such as the number of key segments (4 segments), the length of each segment (8 bits), the number of node identifier hash value segments (4 segments), and the total length of the mixed string (such as 64 bits)), to form a data feature list.
[0178] Step S802: logically split the first binding check value according to data characteristics to obtain key check sub-items corresponding to key segments and identification check sub-items corresponding to node identifications.
[0179] Specifically, the key check sub-item refers to a check segment corresponding to each key segment, which is used to verify the integrity of the key segment; the identification check sub-item refers to a check segment corresponding to each node identification hash segment, which is used to verify the integrity of the node identification; in this embodiment, according to the data characteristics of “key segment number = 4, identification segment number = 4”, the 48-bit first binding check value is split into 8 sub-items (4 key check sub-items + 4 identification check sub-items), each sub-item is 6 bits, for example, the key check sub-items “9b2d7f” “4a8c1e” “305f6d” “8b1a2c” and the identification check sub-items “3e4f50” “6a7b8c” “9d0e1f” “2a3b4c” are obtained after splitting.
[0180] Step S803: establish a key-identification association mapping model, dynamically bind the key segments with the key check sub-items, and feature match the node identifications with the identification check sub-items to form a bidirectional check link.
[0181] Specifically, the association mapping model refers to an algorithm model for establishing the corresponding relationship between the key segments and the check sub-items, and the node identifications and the check sub-items; the bidirectional check link refers to a link that simultaneously verifies “key-key check sub-item” and “node identification-identification check sub-item”, which ensures that the binding relationship cannot be tampered with; in this embodiment, the mapping model is established to bind four key segments with four key check sub-items (such as “d4f8a2c6→9b2d7f” “e0b39175→4a8c1e”) respectively, and simultaneously match four node identification hash segments with four identification check sub-items (such as “3e8a→3e4f50” “7d9b→6a7b8c”) respectively, to form the bidirectional check link of “key segment→key check sub-item” and “node identification segment→identification check sub-item”, and if any link does not match, the binding fails.
[0182] Step S804: based on the bidirectional check link, structurally recombine the key-identification mixed string.
[0183] Specifically, the structural recombination refers to rearranging the character order of the mixed string according to the binding relationship of the bidirectional check link to form a structured data with check logic; in this embodiment, the original mixed string is recombined in the order of “key segment 1 + corresponding key check sub-item + node identification segment 1 + corresponding identification check sub-item + key segment 2 +...”, for example, the recombined result is “d4f8a2c69b2d7f3e8a3e4f50e0b391754a8c1e7d9b6a7b8c...”, which ensures that each segment carries the corresponding check sub-item.
[0184] Step S805: The reorganized mixed string is processed by a preset key fusion algorithm to generate an identification device key.
[0185] Specifically, the key fusion algorithm refers to an encryption algorithm specially used for integrating structured reorganized data (such as a self-defined fusion algorithm based on the SM4 algorithm), and finally outputs a fixed-length key; in this embodiment, the structured reorganized mixed string is input into the preset key fusion algorithm, and a 64-bit fixed-length hexadecimal string (such as “8c2d7e9f3a4b610e5f7d8c9a0b1c2d3e4f5a6b7c8d9e0f1a...”) is generated through “character confusion-logical operation-length compression” processing, which is used as the final identification device key.
[0186] The method for tracing agricultural products based on the Internet of Things provided by the embodiment comprises the following steps: first, data features corresponding to a key-identification mixed string are acquired; second, a first binding check value is logically split according to the data features to obtain key check sub-items corresponding to key segments and identification check sub-items corresponding to node identifications; third, a key-identification association mapping model is established; fourth, key segments are dynamically bound with key check sub-items, and node identifications are matched with identification check sub-item features to form a bidirectional check link; fifth, the key-identification mixed string is structured and reorganized based on the bidirectional check link; and finally, a preset key fusion algorithm is used to process the reorganized mixed string to generate an identification device key.
[0187] Through data feature extraction, check sub-item splitting and bidirectional check link construction, deep binding and double-checking of the key and the node identification are achieved. The structured reorganization makes the key logic more rigorous, and the key fusion algorithm further strengthens the uniqueness and security of the key, effectively avoiding key tampering, replacement or forgery, providing high-reliability and strong-association security key support for traceability data encryption, and guaranteeing the integrity and credibility of the traceability data from the key level.
[0188] In a second aspect, the present application further discloses a system for tracing agricultural products based on the Internet of Things.
[0189] Reference Figure 9 A system for tracing agricultural products based on the Internet of Things, comprising:
[0190] A node acquisition module is configured to acquire traceability link nodes of agricultural products.
[0191] A data acquisition module is configured to acquire traceability data of agricultural products at each node based on Internet of Things acquisition devices preset at each node.
[0192] A data encryption module is configured to perform first re-encryption processing on the acquired traceability data of agricultural products to generate encrypted traceability data.
[0193] A blockchain storage module is configured to upload the encrypted traceability data to a blockchain network for storage, and generate a blockchain storage hash value;
[0194] A device identification acquisition module is configured to acquire device identification of the Internet of Things collection device corresponding to each node;
[0195] A traceability identification generation module is configured to generate a unique traceability identification of the agricultural product based on the blockchain storage hash value and the device identification;
[0196] A request receiving module is configured to receive a traceability query request of a user, the traceability query request carrying the unique traceability identification of the agricultural product;
[0197] A data calling module is configured to call the corresponding encrypted traceability data from the blockchain network based on the unique traceability identification of the agricultural product;
[0198] A decryption module is configured to decrypt the called encrypted traceability data, and acquire the decrypted traceability data of the agricultural product.
[0199] The above are preferred embodiments of the present application, and are not intended to limit the protection scope of the present application, therefore: any equivalent changes made on the structure, shape, principle of the present application shall be covered within the protection scope of the present application.
Claims
1. An agricultural product traceability method based on Internet of Things technology, characterized in that, The method comprises the following steps: acquiring a traceability full-link node of agricultural products; collecting agricultural product traceability data of each node based on an Internet of Things collection device preset at each node; performing first re-encryption processing on the collected agricultural product traceability data to generate encrypted traceability data; uploading the encrypted traceability data to a blockchain network for storage and generating a blockchain storage hash value; acquiring a device identifier of the Internet of Things collection device corresponding to each node; generating an agricultural product unique traceability identifier based on the blockchain storage hash value and the device identifier; receiving a traceability query request of a user, the traceability query request carrying the agricultural product unique traceability identifier; based on the agricultural product unique traceability identifier, calling corresponding encrypted traceability data from the blockchain network; decrypting the called encrypted traceability data and acquiring decrypted agricultural product traceability data; wherein the first re-encryption processing on the collected agricultural product traceability data to generate encrypted traceability data comprises: acquiring a device key of each Internet of Things collection device; encrypting the collected agricultural product traceability data using the device key as an encryption key to generate primary encrypted data; acquiring a node public key of the blockchain network; performing secondary encryption processing on the primary encrypted data and the corresponding device key digest using the node public key as an encryption key to generate the encrypted traceability data; the acquiring of the device key of each Internet of Things collection device comprises: collecting hardware feature information of the Internet of Things collection device; standardizing the hardware feature information to generate a hardware feature string; performing hash calculation on the hardware feature string to obtain a device base key; performing XOR operation on the device base key and a device first networking timestamp to generate an initial device key; associating and binding the initial device key and a node identifier to generate an identifier device key; based on a preset key update period, dynamically updating the identifier device key to generate a currently valid device key. 2.The agricultural product traceability method based on the Internet of Things technology according to claim 1, characterized in that, the uploading of the encrypted traceability data to the blockchain network for storage and the generation of a blockchain storage hash value comprises: performing block processing on the encrypted traceability data at a preset time interval to generate a plurality of traceability data blocks; acquiring a node identifier based on the traceability full-link node; adding a timestamp and a node identifier to each traceability data block, and uploading the traceability data block to each consensus node of the blockchain network; controlling the consensus nodes to verify the traceability data block, and writing the traceability data block into a blockchain block after verification; performing double hash calculation on the traceability data block written into the blockchain block to generate the blockchain storage hash value. 3.The agricultural product traceability method based on the Internet of Things technology according to claim 1, characterized in that, the generation of an agricultural product unique traceability identifier based on the blockchain storage hash value and the device identifier comprises: acquiring an initial code of the agricultural product; splicing the blockchain storage hash value, the device identifier of each node, and the initial code to generate an original traceability identifier; performing encoding processing on the original traceability identifier to generate the agricultural product unique traceability identifier. 4.The agricultural product traceability method based on the Internet of Things technology according to claim 1, characterized in that, the decryption processing on the called encrypted traceability data comprises: Obtaining a node private key of a blockchain network; Firstly decrypting the encrypted traceability data by taking the node private key as a decryption key, and obtaining primary encrypted data and a device key digest; Matching a corresponding device key based on a device identifier of each node; Hashing the matched device key to generate a key verification digest; Comparing the key verification digest with the device key digest, and if they are consistent, secondly decrypting the primary encrypted data by taking the device key as a decryption key to obtain the agricultural product traceability data. 5.The agricultural product traceability method based on the Internet of Things technology according to claim 1, characterized in that, The associating and binding the initial device key with the node identifier to generate an identifier device key comprises: Obtaining a hash value of the node identifier; Segmenting the initial device key and dividing it into a plurality of key segments according to a preset length; Inserting the hash value of the node identifier between each key segment to form a key-identifier mixed string; Hashing the key-identifier mixed string to generate a first binding verification value; Generating the identifier device key based on the first binding verification value and the key-identifier mixed string. 6.The agricultural product traceability method based on the Internet of Things technology according to claim 5, characterized in that, The generating the identifier device key based on the first binding verification value and the key-identifier mixed string comprises: Obtaining a data feature corresponding to the key-identifier mixed string; Logically splitting the first binding verification value according to the data feature to obtain a key verification sub-item corresponding to the key segment and an identifier verification sub-item corresponding to the node identifier; Establishing a key-identifier association mapping model, dynamically binding the key segment with the key verification sub-item, and feature matching the node identifier with the identifier verification sub-item to form a bidirectional verification link; Structurizing and recombining the key-identifier mixed string based on the bidirectional verification link; Processing the recombined mixed string through a preset key fusion algorithm to generate the identifier device key.
7. An agricultural product traceability system based on Internet of Things technology, used to execute the method of any one of claims 1 to 6, characterized in that, It comprises: A node obtaining module for obtaining traceability full-link nodes of agricultural products; A data acquisition module for acquiring agricultural product traceability data of each node based on Internet of Things acquisition devices preset at each node; A data encryption module for first re-encrypting the acquired agricultural product traceability data to generate encrypted traceability data; A blockchain storage module for uploading the encrypted traceability data to a blockchain network for storage and generating a blockchain storage hash value; A device identifier obtaining module for obtaining device identifiers of Internet of Things acquisition devices corresponding to each node; A traceability identifier generating module for generating an agricultural product unique traceability identifier based on the blockchain storage hash value and the device identifier; A request receiving module for receiving a traceability query request of a user, the traceability query request carrying the agricultural product unique traceability identifier; A data retrieval module for retrieving corresponding encrypted traceability data from the blockchain network based on the agricultural product unique traceability identifier; A decryption module for decrypting the retrieved encrypted traceability data and obtaining decrypted agricultural product traceability data.
Citation Information
Patent Citations
Agricultural product traceability information sharing-privacy protection method and system
CN111859446A
Agricultural product supply chain information tracing method and system
CN120297999A
Food traceability method based on block chain
CN121146796A