A traceability system and method for agricultural products
By constructing an enhanced Merkle tree and generating differentiated traceability codes, the cost contradictions and data tampering issues in the distribution of high-end agricultural products have been resolved, achieving efficient and secure traceability of agricultural products.
Patent Information
- Application Number
- CN202611331177.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-10
AI Technical Summary
Existing technologies face challenges such as soaring costs and data tampering when dealing with the mixed distribution of landmark high-end agricultural products between primary production wholesale markets and multi-level large retailers. They are unable to meet the needs of high-end consumers for brand premium verification and cannot guarantee the safety of agricultural products in complex circulation scenarios.
An enhanced Merkle tree is used to build an agricultural product traceability system. An enhanced root hash is generated through a set of hash values, and commercial value-added data is stored in layers and differentiated traceability codes are generated to ensure data integrity and security.
It reduces the waste of storage and transaction resources, ensures that high-end consumers can access high-value brand information on demand, prevents shippers from tampering with original records, and improves the data integrity and security of agricultural products in multi-level splitting and circulation scenarios.
Smart Images

Figure CN123070977A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of agricultural product traceability technology, and more specifically, to an agricultural product traceability system and method. Background Technology
[0002] As an important means to ensure food safety and enhance brand trust, agricultural product traceability technology has been widely used in the field of agricultural informatization in recent years. Its core concept is to use information technology to record and track the information of agricultural products throughout their entire life cycle, from production, processing, logistics to sales, so as to achieve traceability of origin, destination, and accountability. With the development of blockchain technology, due to its decentralized, tamper-proof, and timestamping characteristics, it has been gradually introduced into the agricultural product traceability system as an underlying evidence storage technology to ensure the authenticity and non-repudiation of traceability data.
[0003] Existing technologies have limitations in handling the complex situation of mixed distribution between primary wholesale markets and multi-tiered large retailers for landmark high-end agricultural products. In reality, large batches of agricultural products, numbering in the thousands, often face diversion at primary wholesale markets. Bulk distribution channels only need to focus on authenticity and testing reports, while high-end gift box channels have a strong demand for high-value brand information from monitoring video streams of the planting process. Current technologies typically couple basic compliance data with commercial value-added data. If full data is uploaded to the blockchain or synchronized, secondary distributors will face soaring printing costs due to the large amount of index data carried by QR codes when splitting and selling smaller batches. Furthermore, the on-chain storage... Bandwidth resources are also subject to significant waste. If the uploading of video streams monitoring the planting process is reduced in order to control costs, it will be impossible to meet the verification needs of high-end consumers for brand premiums, making it difficult for high-value-added agricultural products to achieve premium prices and creating cost contradictions in large-scale applications. In addition, existing technologies often focus on verifying single-point data in multi-level splitting and circulation processes, making it difficult to reverse and lock the integrity of the overall data of the parent batch. There is a risk that the shipper may maliciously delete or modify the original excessive records and then split and sell them, leading to the problem of source data being tampered with. This cannot effectively guarantee the security of agricultural products in complex circulation scenarios. Therefore, we provide an agricultural product traceability system and method. Summary of the Invention
[0004] The purpose of this invention is to provide an agricultural product traceability system and method to solve the problems mentioned in the background art.
[0005] To achieve the above objectives, one objective of this invention is to provide an agricultural product traceability system, comprising:
[0006] An enhanced construction module is used to obtain basic compliance data of large batches of agricultural products and generate corresponding hash value sets. Based on the hash value sets, state commitment leaf node hash values are generated according to preset data leaf node sorting rules. Then, the hash value sets and the state commitment leaf node hash values are used as inputs at the same level to jointly participate in the recursive hash construction of the parent batch enhanced Merkle tree to generate the enhanced root hash.
[0007] The hierarchical storage module is used to divide the acquired agricultural product traceability data into basic compliance data and commercial value-added data; construct blockchain transaction data containing enhanced root hashes and write it into the consortium blockchain network for notarization; upload commercial value-added data to the IPFS network and generate fixed-length content identifiers as indexes to be stored in the traceability data metadata database.
[0008] The verification generation module is used to extract the hash value of the leaf node of the target data and calculate the minimum Merkel proof path, and then encapsulate the hash value of the leaf node of the target data and the minimum Merkel proof path in a structured manner to generate batch aggregated verification values.
[0009] The traceability code encoding module is used to generate complete or lightweight traceability codes based on batch aggregated verification values and fixed-length content identifiers, respectively.
[0010] As a further improvement to this technical solution, the generation of the state commitment leaf node hash value in the enhanced construction module includes the following steps:
[0011] Each independent piece of basic compliance data is treated as an independent data leaf node, and a corresponding data leaf node hash value is generated.
[0012] A hash value set is formed based on the hash values of the data leaf nodes, and then the hash value set is sorted according to the preset data leaf node sorting rules to obtain the sorted order;
[0013] The hash values of the data leaf nodes in the hash value set are concatenated in the sorted order to form a full data sequence. Then, a hash digest calculation is performed on the full data sequence to generate the hash value of the state commitment leaf node.
[0014] As a further improvement to this technical solution, the hierarchical storage module further includes the following steps:
[0015] Acquire the full amount of agricultural product traceability data to be stored, and divide the full amount of agricultural product traceability data into two categories according to data attributes: basic compliant data and commercial value-added data;
[0016] Based on basic compliance data, blockchain transaction data containing enhanced root hashes is constructed and broadcast to the consortium blockchain network. After verification by a preset consensus mechanism, the blockchain transaction data is written into a new blockchain block.
[0017] Batch upload of commercial value-added data to the IPFS client interface The network generates a unique fixed-length content identifier.
[0018] As a further improvement to this technical solution, the minimum Merkel proof path in the verification generation module includes the following method steps:
[0019] Starting from the target data leaf node hash value, traverse upwards layer by layer along the hierarchical structure of the parent batch enhanced Merkle tree until the enhanced root node corresponding to the enhanced root hash is reached;
[0020] At each level during the traversal, extract the hash value of the sibling node corresponding to the current node in the calculation of its parent node; concatenate the sibling node with the current node and perform a hash operation to generate the hash value of the parent node at the next higher level;
[0021] The hash values of the sibling nodes extracted during the traversal are arranged in order from low level to high level to form the minimum Merkel proof path.
[0022] As a further improvement to this technical solution, the generation of complete traceability code in the traceability code encoding module includes the following steps:
[0023] use The QR code encoding format encodes the batch aggregated verification value together with the fixed-length content identifier pre-stored in the traceability data element database to generate a complete traceability code; wherein, the batch aggregated verification value and the fixed-length content identifier are structured and merged and then encoded into a QR code image.
[0024] As a further improvement to this technical solution, the traceability code encoding module includes the following steps:
[0025] Obtain the high added value and current circulation level of agricultural product categories and determine whether to assign high-value data tags;
[0026] If the agricultural product category belongs to the high value-added category list and the current circulation level is the retail terminal level, then the batch aggregate verification value and the fixed-length content identifier will be merged and encoded into a complete traceability code; otherwise, only the batch aggregate verification value will be encoded to generate a lightweight traceability code.
[0027] As a further improvement to this technical solution, a local verification module is also included, which is used to parse batch aggregate verification values from complete traceability code or lightweight traceability code, extract the target data leaf node hash value and the minimum Merkel proof path and perform layer-by-layer recursive calculation to generate a local enhanced root hash; compare the local enhanced root hash with the enhanced root hash in the consortium blockchain network to see if they are consistent, and if they are consistent, generate a basic traceability information display page.
[0028] As a further improvement to this technical solution, the local enhanced root hash in the local verification module includes the following method steps:
[0029] The current calculated hash is initialized to the hash value of the target data leaf node, where the current calculated hash represents the hash value of the current level node during the recursive calculation process;
[0030] Iterate through the hash values of each sibling node in the path to the minimum Merkel proof, concatenate the currently calculated hash with the hash value of the sibling node, and then execute the operation. Perform a hash operation, and then update the calculated hash with the result.
[0031] When all sibling node hashes in the minimum Merkel proof path have been traversed, the current calculated hash after the traversal is completed is the locally generated enhanced root hash of the client.
[0032] The second objective of this invention is to provide a method for operating an agricultural product traceability system including any one of the above-described methods, comprising the following steps:
[0033] S1 is used to obtain basic compliance data for large batches of agricultural products and generate a set of hash values. It generates hash values for state commitment leaf nodes according to the preset data leaf node sorting rules. It is used as input at the same level as the set of hash values to participate in the recursive hash construction of the parent batch enhanced Merkle tree and generate an enhanced root hash.
[0034] S2 is used to divide the acquired agricultural product traceability data into basic compliance data and commercial value-added data; construct blockchain transaction data containing enhanced root hashes, write it into the consortium blockchain network for notarization, upload the commercial value-added data to the IPFS network, and generate fixed-length content identifiers to be stored in the traceability data metadata database.
[0035] S3 is used to extract the hash value of the leaf node of the target data and calculate the minimum Merkel proof path. Then, the hash value of the leaf node of the target data and the minimum Merkel proof path are encapsulated in a structured manner to generate batch aggregate verification value.
[0036] S4 is used to generate complete traceability codes or lightweight traceability codes based on batch aggregated verification values and fixed-length content identifiers, respectively.
[0037] S5 is used to parse batch aggregated verification values from complete or lightweight traceability codes, and extract the target data leaf node hash values and the minimum Merkel proof path accordingly; and generate local enhanced root hashes by recursively calculating layer by layer locally.
[0038] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0039] 1. In this agricultural product traceability system and method, commercial value-added data is uploaded in batches to the IPFS network to generate fixed-length content identifiers. These fixed-length content identifiers are used as indexes pointing to the corresponding commercial value-added data and saved in the traceability data metadata database. Simultaneously, only the enhanced root hash is written to the consortium blockchain network for notarization. Then, based on the high added value of the agricultural product category and the current circulation level, it is determined whether to set a high-value data identifier, thereby generating a differentiated traceability code: if it belongs to a high-value-added category and the current circulation level is the retail terminal level, the batch aggregate verification value and the fixed-length content identifier are merged and encoded into a complete traceability code; otherwise, only the batch aggregate verification value is encoded to generate a lightweight traceability code. This avoids the resource waste and cost surge caused by directly uploading the monitoring video stream of the planting process to the blockchain, while ensuring that high-end consumers can obtain high-value brand information as needed. This reduces the overall storage burden and on-chain transaction resources, significantly reduces the cost of QR code printing, and solves the cost contradiction in large-scale applications while ensuring that high-value-added agricultural products achieve brand premium.
[0040] 2. In this agricultural product traceability system and method, a hash set is generated by acquiring basic compliance data of a large batch of agricultural products, and a state commitment leaf node hash value is generated according to a preset data leaf node sorting rule. Subsequently, the hash value set and the state commitment leaf node hash value are used as inputs at the same level to participate in recursive hash construction, generating an enhanced root hash. This locks the overall data status of the parent batch in the verification root of the child batch, so that the verification logic is no longer limited to single-point data. Through the enhanced root hash, the integrity of the full basic compliance data of the parent batch of agricultural products can be traced back and confirmed. This effectively prevents fraudulent behavior such as the distributor deleting and modifying the original non-compliant records and then splitting and selling them. It solves the trust problem of malicious tampering of source data in the splitting and circulation process, and improves the integrity and security of source data of agricultural products in multi-level splitting and circulation scenarios. Attached Figure Description
[0041] Figure 1 This is a flowchart summarizing the specification of the present invention;
[0042] Figure 2 This is a block diagram showing the unit frame association of the present invention;
[0043] Figure 3 This is a block diagram of the overall method of the present invention. Detailed Implementation
[0044] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0045] Example 1
[0046] Please see Figures 1-3 As shown, one of the objectives of this embodiment is to provide an agricultural product traceability system, including:
[0047] Enhanced construction module 1 is used to acquire basic compliance data of large batches of agricultural products and generate corresponding hash value sets; based on the hash value sets, it generates state commitment leaf node hash values according to preset data leaf node sorting rules, and then uses the hash value sets and the state commitment leaf node hash values as inputs at the same level to jointly participate in the recursive hash construction of the parent batch enhanced Merkle tree to generate enhanced root hash; hierarchical storage module 2 is used to divide the acquired agricultural product traceability data into basic compliance data and commercial value-added data; construct blockchain transaction data containing enhanced root hashes and write them into the consortium blockchain network for notarization; upload commercial value-added data to the IPFS network, generate fixed-length content identifiers as indexes and store them in the traceability data metadata database; and verify... The generation module 3 is used to extract the hash value of the leaf node of the target data and calculate the minimum Merkel proof path, and then encapsulate the hash value of the leaf node of the target data and the minimum Merkel proof path in a structured manner to generate the batch aggregate verification value; the traceability code encoding module 4 is used to generate a complete traceability code or a lightweight traceability code based on the batch aggregate verification value and the fixed-length content identifier respectively; the local verification module 5 is used to parse the batch aggregate verification value from the complete traceability code or the lightweight traceability code, extract the hash value of the leaf node of the target data and the minimum Merkel proof path and perform layer-by-layer recursive calculation to generate a local enhanced root hash; the local enhanced root hash is compared with the enhanced root hash in the consortium blockchain network to see if they are consistent. If they are consistent, a basic traceability information display page is generated.
[0048] The following is a detailed explanation of the above modules;
[0049] In Enhanced Module 1, basic compliance data for large batches of agricultural products is obtained, and hash processing is performed on the basic compliance data to generate a corresponding set of hash values. Subsequently, a state commitment leaf node is constructed based on the hash value set, and this state commitment leaf node, along with all data leaf nodes, is used as the same level input to the parent batch enhanced Merkle tree to perform recursive hash calculation, ultimately generating a unique enhanced root hash. Specifically:
[0050] Enhanced building module 1 includes a leaf node generation unit 11, a commitment leaf node unit 12, and an enhanced root hash unit 13;
[0051] Leaf node generation unit 11 obtains the basic compliance data corresponding to the parent batch of agricultural products. This basic compliance data includes the GS1 code of the place of origin, the digital digest of the pesticide residue test report, and the batch registration timestamp. The basic compliance data is the legally essential verification information for agricultural products entering the market. The completeness of the basic compliance data directly affects the results of subsequent verification of the legality of sub-batch attribution and the integrity of the parent batch's hash value set. The amount of basic compliance data is relatively small, typically consisting of text strings or fixed-length hash values. The specific steps include the following:
[0052] The GS1 code for origin reads the string information contained in the Global Trade Item Code barcode of the agricultural product's origin by calling the original database interface, and uses this string information as the raw data. GS1 coding is a globally unified identification system developed by the International Article Numbering Organization, used to uniquely identify the origin information of agricultural products; the digital summary of pesticide residue test reports is obtained by receiving the full-text pesticide residue test report file uploaded by a third-party testing institution and performing [the following steps] on the full-text pesticide residue test report file. Hash calculation extracts a fixed-length hash digest as the original data. ;use The algorithm's rationale lies in the collision resistance of the full-text pesticide residue test report. This means that in actual computation, no two different inputs can produce the same hash digest. Therefore, the hash digest uniquely represents the content of the full-text pesticide residue test report, and any modification to the full-text report will change the calculated hash digest. The batch registration timestamp obtains the time when the batch data is packaged and uploaded to the blockchain using the block time of the synchronized blockchain network as the original data. ;
[0053] After acquiring the basic compliance data, record the acquisition time and record each individual piece of basic compliance data. Each is treated as an independent data leaf node, where For data sequence number, , This represents the total number of basic compliant data; to facilitate the subsequent construction of the parent batch enhanced Merkle tree, a hash operation is performed on each data leaf node to generate the corresponding data leaf node hash value. ,in, This represents the standard hash function, i.e. algorithm; Indicates the first The raw data for basic compliance data; Indicates the first The output contains the hash values of the leaf nodes and has a length of [number]. Bits, through node generation unit 11, uniformly convert structured or unstructured basic compliance data into fixed-length hash value representations, providing standardized input data for subsequent generation of state commitment leaf nodes and recursive construction of parent batch enhanced Merkle trees;
[0054] After generating the hash values of all data leaf nodes in leaf node generation unit 11, commitment leaf node unit 12 is executed. After receiving the hash values of the data leaf nodes in leaf node generation unit 11, commitment leaf node unit 12 generates a state commitment leaf node that can describe the overall state of all basic compliant data sets in the parent batch. Specifically, it includes the following sub-steps:
[0055] Sub-step 121: Construct a hash value set based on the hash values of all data leaf nodes. Then, according to the preset data leaf node sorting rules, the hash value set is sorted to obtain the sorted order. The preset data leaf node sorting rules are set to be arranged in ascending order according to the time of acquisition of basic compliance data. The purpose of the preset data leaf node sorting rules is that for the same hash value set, as long as the preset data leaf node sorting rules are consistent on different processing nodes, the generated sorting result is unique and definite, thereby ensuring the reproducibility of the hash values of the state commitment leaf nodes.
[0056] Sub-step 122: Concatenate the hash values of the leaf nodes in the hash value set in the sorted order to form a complete data sequence. ;in, This represents the string concatenation operator, which directly joins the beginning and end of two consecutive byte strings. to This is the sorted sequence of hash values for the leaf nodes of the data.
[0057] Sub-step 123: Perform hash digest calculation on the entire data sequence to generate the hash value of the state commitment leaf node. ; where subscript This means that the node is a state commitment node; the hash value length of the state commitment leaf node is... Bit; The hash value of the state commitment leaf node has the following characteristics: First, one-wayness, meaning that the specific content of the full data sequence cannot be derived from the hash value of the state commitment leaf node; Second, collision resistance, meaning that no two different full data sequences can produce the same hash value of the state commitment leaf node; Third, global state sensitivity, meaning that the addition, deletion, or modification of any one or more data leaf node hash values in the hash value set will cause the full data sequence to change, resulting in the recalculated hash value of the state commitment leaf node being inconsistent with the original hash value of the state commitment leaf node; Therefore, the hash value of the state commitment leaf node can uniquely describe the state of the hash value set of the parent batch at the current moment, constituting the cryptographic fingerprint of the integrity of the parent batch data;
[0058] After generating the hash values of the state commitment leaf nodes in commitment leaf node unit 12, the enhanced root hash unit 13 is executed. Enhanced root hash unit 13 receives the hash value set and the state commitment leaf node hash values from commitment leaf node unit 12 and then performs recursive hashing to construct the parent batch enhanced Merkle tree; specifically, it includes the following sub-steps:
[0059] Sub-step 131: Use the hash value set and the hash value of the state commitment leaf node as the current level node set. Record the number of nodes at the current level, and then use all the nodes in the current level node set as input at the same level to construct the parent batch enhanced Merkle tree through recursive hashing;
[0060] Sub-step 132: Check if the number of nodes in the current level is even. If the number of nodes is odd, copy the last node of the current level as a supplementary node and add it to the end of the current level node set to make the number of nodes even, so as to ensure the smooth progress of subsequent pairwise calculations. If the number of nodes is even, no processing is required.
[0061] Sub-step 133: From left to right, take two adjacent nodes as a pair, concatenate the hash values of the two nodes, and perform a hash operation to generate the hash value of the parent node at the next higher level; The hash values of two adjacent nodes in the layer and For example, generate the hash value of the parent node at the next higher level. ;in, This represents the string concatenation operator;
[0062] Sub-step 134: Use all parent node hash values as the new current level, and repeat sub-steps 132 to 134 until only one node remains in the current level. The hash value corresponding to that node is the enhanced root hash. Among them, the record of the enhanced root hash The bit hash string, the enhanced root hash, depends on the following simultaneously on the data leaf node hash value or the state commitment leaf node hash value: each independent piece of basic compliance data is passed down layer by layer to the enhanced root node through the data leaf node hash value; the overall state of the entire hash value set is passed down layer by layer to the enhanced root node through the state commitment leaf node hash value; any addition, deletion, or modification to the basic compliance data will result in a change in the data leaf node hash value and the state commitment leaf node hash value, and the two together cause a change in the enhanced root hash; thus, the enhanced root hash constitutes a unified cryptographic commitment to the integrity of the parent batch of basic compliance data and hash value set.
[0063] After the enhanced root hash is generated in Enhanced Construction Module 1, Hierarchical Storage Module 2 is executed. Hierarchical Storage Module 2 receives the enhanced root hash from Enhanced Construction Module 1, acquires the full amount of agricultural product traceability data, and delineates commercial value-added data. Based on the basic compliance data, it constructs blockchain transaction data containing the enhanced root hash, and after synchronous confirmation by the consortium blockchain network, it stores the commercial value-added data in IPFS and generates a fixed-length content identifier to ensure the credibility of the evidence while achieving persistent data storage and on-demand retrieval. Specifically:
[0064] The hierarchical storage module 2 includes a blockchain construction unit 21 and an identifier unit 22;
[0065] After the enhanced root hash in enhanced root hash unit 13 is generated, blockchain construction unit 21 is executed. Blockchain construction unit 21 receives the batch registration timestamp from leaf node generation unit 11 and the 256-bit hash string from enhanced root hash unit 13, and then constructs blockchain transaction data containing the enhanced root hash. The specific steps include the following:
[0066] The entire agricultural product traceability data to be stored is acquired and divided into two categories based on data attributes: basic compliance data and commercial value-added data. The complete agricultural product traceability data refers to the sum of all traceability information related to the current parent batch of agricultural products that needs to be stored. Data attributes refer to the functional and storage characteristics of each piece of agricultural product traceability data, used as the basis for classification. Commercial value-added data is extended data that does not participate in compliance verification but is only used to enhance consumer trust and display additional information about agricultural products, including: video streams monitoring the planting process, audio data from farmer interviews, and scanned copies of organic certification certificates. Commercial value-added data is generally large in volume; in typical scenarios, a single monitoring video stream can reach hundreds of megabytes. In scenarios involving large-scale batch splitting and dynamic circulation of agricultural products, there is only a need to display commercial value-added data through specific channels (such as retail terminals).
[0067] Construct blockchain transaction data containing an enhanced root hash; the blockchain transaction data includes a transaction initiator field, a transaction timestamp field, and a transaction data payload field, wherein the transaction initiator field is the blockchain account address of the parent batch registration entity; the transaction timestamp field is the original data. The batch registration timestamp; the value of the transaction data payload field is the enhanced root hash. The hash string is generated; subsequently, the completed blockchain transaction data is broadcast to the consortium blockchain network; the consensus nodes of the consortium blockchain network are jointly maintained by regulatory agency nodes, wholesale market nodes, and large retailer nodes; the blockchain transaction data is processed by regulatory agency nodes, wholesale market nodes, and large retailer nodes according to a preset consensus mechanism (e.g., using a practical Byzantine fault-tolerant algorithm). After verification using an equivalent consensus algorithm, the blockchain transaction data is written into a new blockchain block. Once the new blockchain block is simultaneously confirmed by regulatory agency nodes, wholesale market nodes, and large retailer nodes, the blockchain transaction data is permanently recorded in the blockchain distributed ledger, and all participants can obtain the same enhanced root hash. By utilizing the chain-like data structure and pre-set consensus mechanism of the blockchain distributed ledger, the enhanced root hash stored on the consortium blockchain network cannot be modified or deleted by any single party after being written into a new blockchain block.
[0068] Once the blockchain transaction data in blockchain module 21 is permanently recorded in the blockchain distributed ledger, identifier unit 22 is executed. Identifier unit 22 receives the commercial value-added data in blockchain module 21 and generates a unique fixed-length content identifier; specifically, the following method steps are included:
[0069] Commercial value-added data, including video streams monitoring the planting process, audio data from farmer interviews, and scanned copies of organic certification certificates, will be uploaded in batches via the IPFS client interface. Network; among which, Refers to the InterPlanetary File System (IPS). After receiving commercial value-added data, the network performs a hash calculation on the data in each commercial value-added data, generating a unique fixed-length content identifier for each commercial value-added data. Fixed-length content identifiers are generated based on data in the commercial value-added data. Any modification to the data in the commercial value-added data will result in a different fixed-length content identifier, thus ensuring that the fixed-length content identifier uniquely identifies the corresponding commercial value-added data. The generated fixed-length content identifier is then used as an index pointing to the corresponding commercial value-added data and saved to the traceability data metadata database. The traceability data metadata database is an internally maintained key-value storage structure used to record the mapping relationship between the enhanced root hash and the fixed-length content identifier of the commercial value-added data. Only the hierarchical storage module 2 stores... After the enhanced root hash of the bit hash string is written into a new blockchain block, it avoids the expansion of the consortium blockchain network's storage space and the increase in transaction fees caused by directly uploading large volumes of commercial value-added data to the chain; it stores large volumes of commercial value-added data in... ,use Distributed characteristics (referring to) As a distributed peer-to-peer file storage system) and content addressing mechanism (referring to...) This approach, which locates and retrieves data based on file content rather than storage location, achieves persistent data preservation and on-demand retrieval at a lower storage cost, thus striking a balance between the credibility of evidence preservation and the economics of storage.
[0070] After the hierarchical storage module 2 generates a unique fixed-length content identifier, the verification generation module 3 is executed. The verification generation module 3 receives the enhanced root hash from the enhanced construction module 1, locates the data leaf nodes according to the obtained splitting instructions, calculates the minimum Merkle proof path containing the hash values of the state commitment leaf nodes, and encapsulates the minimum Merkle proof path into a batch aggregated verification value with fixed-length characteristics. This achieves lightweight verification without downloading the entire blockchain data. Specifically:
[0071] Verification generation module 3 includes proof path unit 31 and aggregated verification value unit 32;
[0072] After the fixed-length content identifier is generated in the identifier unit 22 and stored in the traceability data element database, the proof path unit 31 is executed. The proof path unit 31 receives the enhanced root hash from the enhanced root hash unit 13 and the state commitment leaf node hash value from the commitment leaf node unit 12, and then calculates the minimum Merkel proof path. The specific steps include the following:
[0073] Obtain the splitting instruction for the large batch of agricultural products. The splitting instruction contains a unique index identifier for the target small batch. The unique index identifier is used to locate the data leaf node corresponding to the target small batch in the parent batch's enhanced Merkle tree. Based on the unique index identifier, locate and extract the hash value of the data leaf node corresponding to the target small batch from the parent batch's enhanced Merkle tree. This hash value is denoted as the target data leaf node hash value. ; Obtain the hash value of the leaf node of the target data Then, based on the standard Merkel proof path generation algorithm, the hash value of the leaf node of the target data is calculated. The minimum Merkle proof path required to trace back to the enhanced root hash Specifically, it includes the following steps:
[0074] From the target data leaf node hash value Starting from the beginning, traverse upwards level by level along the hierarchical structure of the parent batch enhanced Merkle tree until the enhanced root node corresponding to the enhanced root hash is reached. At each level during the traversal, extract the hash value of the sibling node corresponding to the current node in the calculation of its parent node. Concatenate the sibling node with the current node and perform a hash operation to generate the hash value of the parent node at the next higher level. Arrange all the sibling node hash values extracted during the traversal in order from the lower level to the higher level to form the minimum Merkle proof path. ;in, This represents the hash value of the sibling node at level j. The range of values is to ; This represents the total number of sibling nodes in the minimum Merkel proof path. The total number of sibling nodes in the minimum Merkel proof path is equal to the height of the parent batch enhanced Merkel tree. It is independent of the total number n of basic compliance data contained in the parent batch and is only related to the structural depth of the parent batch enhanced Merkel tree.
[0075] Because the state commitment leaf node is treated as a special leaf node, at the same level as all data leaf nodes, and participates in the recursive construction of the parent batch enhanced Merkle tree, regardless of which data leaf node the target mini-batch corresponds to, the hash value of the target data leaf node is used to determine the process. During the recursive calculation to the enhanced root hash, the hash values of sibling nodes passed up the branch containing the hash value of the state commitment leaf node will inevitably be involved at some level. Correspondingly, the calculated minimum Merkel proof path will necessarily contain the hash values of sibling nodes related to the state commitment leaf node's participation in the enhanced root hash calculation. The sibling node hash value may be the hash value of the state commitment leaf node itself (when the hash value of the target data leaf node and the hash value of the state commitment leaf node are adjacent and paired at the leaf level), or it may be the hash value of the sibling node of the intermediate parent node generated during the upward transmission of the state commitment leaf node hash value. This ensures that in subsequent client verification, the local recursive calculation process must verify the integrity of the hash value set. Any addition, deletion, or modification to the hash value set will result in a change of the relevant sibling node hash values in the minimum Merkel proof path, leading to verification failure.
[0076] After the minimum Merkel proof path in proof path unit 31 is calculated, the aggregation verification value unit 32 is executed. After receiving the target data leaf node hash value and the minimum Merkel proof path from proof path unit 31, aggregation verification value unit 32 calculates the batch aggregation verification value and the total bit length of the batch aggregation verification value, specifically including the following method steps:
[0077] Hash value of the leaf node of the target data After encapsulating the minimum Merkel proof path, the batch aggregate verification value of the target mini-batch is generated. The target data leaf node hash value serves as the starting input value for the client-side local recursive verification calculation; the minimum Merkel proof path serves as an auxiliary parameter for the client-side local recursive verification calculation.
[0078] The batch aggregated verification value has a fixed-length property independent of the total amount of underlying compliance data (meaning the total bit length of the batch aggregated verification value does not increase linearly with the total amount of underlying compliance data contained in the parent batch, but remains within a small and basically fixed range determined by the height of the parent batch's enhanced Merkle tree). The calculation formula is: ;in, The standard output length for each hash value; The minimum Merkel proof path contains the number of sibling node hashes, which is equal to the height of the parent batch-enhanced Merkel tree.
[0079] Explanation of the total bit length value: When the parent batch contains When processing basic compliance data, the number of leaf nodes in the parent batch enhanced Merkle tree is: The height of the parent batch of enhanced Merkel trees Approximately Layers, total bit length approximately Bit (approximately) bytes); when the parent batch contains When dealing with 10,000 basic compliance data entries, the height of the parent batch enhanced Merkle tree is approximately... Layers, total bit length approximately Bit (approximately) (bytes); Thus, it can be seen that the total bit length increases slowly in a logarithmic manner with the total amount of basic compliant data, always remaining within a small and basically fixed range; based on the fixed-length characteristic, the batch aggregated verification value can adapt to the storage requirements of the QR code's limited capacity carrier; the client can independently complete the recursive verification calculation of the integrity of the target small batch relationship and the hash value set of the parent batch by only obtaining the batch aggregated verification value, without downloading the full blockchain data or accessing the original database, thus achieving data lightweighting of the verification process while ensuring the credibility of the verification; among them, the full blockchain data refers to all block data stored in the consortium blockchain network from the genesis block to the latest block; the original database refers to the backend database that stores all the original data of agricultural product traceability.
[0080] After the batch aggregated verification value is generated in the verification generation module 3, the traceability code encoding module 4 is executed. The traceability code encoding module 4 receives the batch aggregated verification value from the verification generation module 3 and the fixed-length content identifier from the hierarchical storage module 2, and generates either a complete traceability code or a lightweight traceability code, respectively. Specifically:
[0081] The traceability code encoding module 4 includes a high-value identification unit 41 and a traceability code generation unit 42;
[0082] After the batch aggregated verification value in the aggregated verification value unit 32 is generated, the high-value identification unit 41 is executed. After receiving the basic compliance data in the leaf node generation unit 11, the high-value identification unit 41 determines that the data identification field is set to high-value data identification; specifically, the following method steps are included:
[0083] First, the target small batch attribute parameters, including agricultural product category information, historical transaction price information, and current circulation level information, are obtained. The agricultural product category information is directly extracted from the basic compliance data corresponding to the target small batch; the GS1 code for the place of origin contains a category identifier field, which can be used to determine the specific agricultural product category. Historical transaction price information is retrieved from the transaction records already stored in the consortium blockchain network. These transaction records are on-chain transaction data of agricultural products of the same category within a preset time range (on-chain transaction data refers to data stored on the blockchain), used to help determine the market added value level of the category. Current circulation level information is read from the smart contract status deployed on the consortium blockchain network by the current splitting and circulation entity. The current circulation level identifies the current supply chain stage of the agricultural product, such as the wholesale market level, distribution level, or retail terminal level. The retail terminal level is a level in the agricultural product circulation process, indicating that the agricultural product has reached the final sales stage directly facing consumers.
[0084] Secondly, the list of high-value-added product categories is dynamically maintained. Updates to this list are achieved by calling pre-deployed smart contracts on the consortium blockchain network. The specific maintenance logic is as follows:
[0085] Using the calendar month as a preset time period, the smart contract obtains publicly traded agricultural product price data from major wholesale markets across the country uploaded by on-chain oracles (standardized service components deployed in a consortium blockchain network that provide external data feeds for smart contracts), and calculates the monthly average transaction price for each product category. ,in The product category number is indicated; simultaneously, the smart contract calculates the overall monthly average transaction price for all monitored agricultural product categories during the current period. The threshold for determining high added value is dynamically calculated based on the overall monthly average transaction price. Among them, the coefficient The basis for the value is: agricultural products whose publicly traded prices reach more than twice the overall monthly average price are usually high-value-added categories such as organic certification and geographical indication brands;
[0086] For each category, if the monthly average transaction price of each category meets the criteria of being greater than or equal to the high added value judgment threshold, then each category will be included in the high added value category list. The smart contract will automatically execute the calculation of the high added value judgment threshold and update the high added value category list. The updated high added value category list will be stored in the state database of the smart contract. The state database is a dedicated storage area for the smart contract on the consortium blockchain network.
[0087] Finally, the system uses the agricultural product category, high-value-added category list, current distribution level, and retail terminal level corresponding to the target small batch to determine whether the data identifier field of the target small batch contains high-value data identifiers. Specifically, this includes the following situations:
[0088] If the agricultural product category corresponding to the target small batch belongs to the high value-added category list, and the current circulation level is the retail terminal level, the data identifier field is set to include the high-value data identifier; otherwise, the data identifier field is set to not include the high-value data identifier. The high-value data identifier is a binary identifier field used to mark whether the agricultural product category corresponding to the target small batch meets the requirement of displaying commercial value-added data to consumers. When set, it indicates that the traceability code needs to include a commercial value-added data index; when not set, it indicates that the traceability code does not need to include a commercial value-added data index. The significance of this judgment logic is that a commercial value-added data index is only included in the traceability code under the dual conditions that the agricultural product reaches the retail terminal, is directly faced by consumers, and the agricultural product category itself has high added value. For batches in the wholesale or distribution intermediate links or belonging to ordinary agricultural product categories, the commercial value-added data index is not activated to avoid wasting traceability code capacity and retrieving irrelevant data.
[0089] After the high-value identification unit 41 determines that the data identification field is set to high-value data identification, the traceability code generation unit 42 is executed. The traceability code generation unit 42 receives the high-value identification unit 41 and determines whether it contains high-value data identification or not, and then generates a complete traceability code or a lightweight traceability code. The specific steps include the following:
[0090] When the traceability code generation unit 42 receives a high-value data identifier from the high-value identifier unit 41, the traceability code generation unit 42 obtains a batch aggregated verification value from the aggregated verification value unit 32; it then encodes the batch aggregated verification value together with a fixed-length content identifier pre-stored in the traceability data element database to generate a complete traceability code; the complete traceability code uses... QR code encoding format; batch aggregated verification values and fixed-length content identifiers are structured and merged into a QR code image, with the total data capacity of the QR code image adapted. The maximum capacity limit of the QR code; if the consumer scans the complete traceability code, the terminal device can parse out the fixed-length content identifier, retrieve the corresponding commercial value-added data through the IPFS network, and complete the display of differentiated traceability information;
[0091] When the traceability code generation unit 42 receives a high-value identifier from the high-value identifier unit 41 that does not contain a high-value data identifier, the traceability code generation unit 42 obtains the batch aggregated verification value from the aggregated verification value unit 32; it only encodes the batch aggregated verification value to generate a lightweight traceability code; the data content of the lightweight traceability code only contains the batch aggregated verification value and does not carry a fixed-length content identifier index pointing to commercial value-added data; compared with the complete traceability code, the lightweight traceability code has a smaller data volume and lower resource consumption in the QR code printing and labeling process.
[0092] After the complete or lightweight traceability code is generated in the traceability code encoding module 4, the local verification module 5 is executed. The local verification module 5 receives the complete or lightweight traceability code from the traceability code encoding module 4, calculates the local enhanced root hash, and compares it with the enhanced root hash in the consortium blockchain network. If the verification passes, a basic or complete traceability information display page is finally generated. Specifically:
[0093] The local verification module 5 includes a parsing calculation unit 51, a comparison and verification unit 52, and a loading condition unit 53;
[0094] After the complete or lightweight traceability code is generated in the traceability code generation unit 42, the parsing calculation unit 51 is executed. After receiving the complete or lightweight traceability code from the traceability code generation unit 42, the parsing calculation unit 51 calculates the local enhanced root hash; specifically, the following method steps are included:
[0095] Consumers can scan the full traceability code or lightweight traceability code on agricultural product packaging using a terminal device, and then use a client to parse the full traceability code or lightweight traceability code.
[0096] If it is a complete traceability code, the batch aggregate verification value and the fixed-length content identifier of the commercial value-added data are parsed out. After parsing, the client extracts the target data leaf node hash value and the minimum Merkel proof path from the batch aggregate verification value for subsequent on-demand retrieval of commercial value-added data. If it is a lightweight traceability code, the batch aggregate verification value is parsed out. After parsing, the client extracts the target data leaf node hash value and the minimum Merkel proof path from the batch aggregate verification value for subsequent on-demand retrieval of commercial value-added data.
[0097] Client calls locally The algorithm recursively calculates a locally enhanced root hash by performing layer-by-layer upward computation based on the hash values of the leaf nodes of the target data and the minimum Merkel proof path. Specifically, it includes the following sub-steps:
[0098] Sub-step 511: Calculate the current hash Initialize to the hash value of the target data's leaf node, i.e. The current hash value represents the hash value of the current level node during the recursive calculation process, and it is updated as the calculation level progresses.
[0099] Sub-step 512: Traverse the hash value of each sibling node in the minimum Merkel proof path. Perform the following operations in sequence: concatenate the currently calculated hash with the hash value of the sibling node, and then execute the concatenation result. Perform a hash operation, obtain the result, and update the current hash value accordingly. The two 256-bit hash values are concatenated end-to-end in sequence to form a 512-bit concatenated string, which is then used as the input to the hash function.
[0100] Sub-step 513: Repeat sub-step 512 until all sibling node hash values in the minimum Merkel proof path have been traversed. The current calculated hash after traversal is the locally enhanced root hash generated by the client.
[0101] The principle behind the recursive computation process is that the minimum Merkle proof path provides the sibling node hashes at each level of the path from the target data leaf node to the enhanced root node. Using these sibling node hashes, the client can compute the result without obtaining the complete structure of the parent batch's enhanced Merkle tree, simply by accessing the minimum Merkle proof path. The next hash operation restores the enhanced root hash layer by layer upwards;
[0102] After the local enhanced root hash in the parsing calculation unit 51 is calculated, the comparison and verification unit 52 is executed. After receiving the local enhanced root hash from the parsing calculation unit 51, the comparison and verification unit 52 generates a basic traceability information display page; specifically, the following method steps are included:
[0103] The client initiates a query request to any node in the consortium blockchain network through the P2P network to obtain the enhanced root hash stored in the consortium blockchain network. The client then performs a bit-by-bit comparison between its local enhanced root hash and the enhanced root hash, specifically including the following comparison steps:
[0104] Scenario 1: If the local enhanced root hash is completely identical to the enhanced root hash, then two verifications are completed simultaneously: First, confirming the legitimacy of the target sub-batch belonging to the corresponding parent batch, that is, the target data leaf node hash value does indeed exist in the parent batch's enhanced Merkle tree, excluding the case of a false affiliated batch; Second, confirming that the basic compliance data of the parent batch has not been tampered with or deleted after the construction of the enhanced Merkle tree; The reason why the second verification is valid simultaneously is that the state commitment leaf node hash value participates in the construction of the parent batch's enhanced Merkle tree, and the minimum Merkle proof path must contain the sibling node hash value passed upward from the branch where the state commitment leaf node hash value is located; Any addition, deletion, or modification to the hash value set will cause the state commitment leaf node hash value to change, and then be passed to the hash value of the local enhanced root hash through the relevant sibling node hash value in the minimum Merkle proof path, making the local enhanced root hash inconsistent with the enhanced root hash in the consortium blockchain network; After both verifications are passed, the client obtains the corresponding basic compliance data from the consortium blockchain network and generates a basic traceability information display page;
[0105] Scenario 2: If the local enhanced root hash is inconsistent with the enhanced root hash, the verification failure result will be output, prompting the consumer that the current basic traceability information is unreliable and terminating the subsequent display process;
[0106] After the basic traceability information in the comparison and verification unit 52 is generated, the loading condition unit 53 is executed. The loading condition unit 53 receives the basic traceability information in the comparison and verification unit 52 and the commercial value-added data in the blockchain construction module 21, as well as the basic compliance data in the leaf node generation unit 11 and the index fixed-length content identifier in the parsing and calculation unit 51. Then, it further determines whether the preset data loading conditions are met, which includes the following method steps:
[0107] Once verification is successful and the source code is complete, the client further determines whether the preset data loading conditions are met. Meeting any one of the following conditions will trigger the loading and display of commercial value-added data:
[0108] Condition 1: The client's current network connection bandwidth is not lower than the preset bandwidth threshold; the preset bandwidth threshold is... The preset bandwidth threshold value is determined based on: The minimum stable bandwidth required for smooth playback of a high-resolution video stream monitoring the planting process is approximately If the current network connection bandwidth is lower than the preset bandwidth threshold, commercial value-added data such as the planting process monitoring video stream will not be loaded temporarily to avoid playback lag on consumers' terminal devices due to insufficient network conditions.
[0109] Condition 2: The user account that initiates the request has completed real-name authentication; the default viewing permission level is real-name authenticated users. Users who have not completed real-name authentication can only view basic compliance data and cannot obtain commercial value-added data.
[0110] When any of the above conditions are met, it is determined that the preset data loading conditions are met. The client uses the parsed index fixed-length content identifier to retrieve the corresponding commercial value-added data from the distributed nodes through the P2P protocol of the IPFS network. After retrieval, the client renders and displays the commercial value-added data in the extended information area of the traceability results page, which together with the basic compliance data constitutes a complete traceability information display page.
[0111] If none of the above conditions are met, the preset data loading conditions are deemed unmet, and the client only displays basic compliance data. The extended information area of the traceability results page displays a message stating, "Commercial value-added data needs to be viewed under a better network environment or after completing real-name authentication." By placing the recursive verification calculation entirely on the client's local machine, the entire verification process only requires obtaining one [database name] from the consortium blockchain network. Bit's enhanced root hash eliminates the need to synchronize the entire blockchain distributed ledger data or access centralized servers, achieving data lightweighting and decentralization of the verification process while ensuring the cryptographic credibility of the verification results.
[0112] The second objective of this invention is to provide a method for operating the aforementioned agricultural product traceability system, comprising the following steps:
[0113] S1 is used to obtain basic compliance data for large batches of agricultural products and generate a set of hash values. It generates hash values for state commitment leaf nodes according to the preset data leaf node sorting rules. It is used as input at the same level as the set of hash values to participate in the recursive hash construction of the parent batch enhanced Merkle tree and generate an enhanced root hash.
[0114] S2 is used to divide the acquired agricultural product traceability data into basic compliance data and commercial value-added data; construct blockchain transaction data containing enhanced root hashes, write it into the consortium blockchain network for notarization, upload the commercial value-added data to the IPFS network, and generate fixed-length content identifiers to be stored in the traceability data metadata database.
[0115] S3 is used to extract the hash value of the leaf node of the target data and calculate the minimum Merkel proof path. Then, the hash value of the leaf node of the target data and the minimum Merkel proof path are encapsulated in a structured manner to generate batch aggregate verification value.
[0116] S4 is used to generate complete traceability codes or lightweight traceability codes based on batch aggregated verification values and fixed-length content identifiers, respectively.
[0117] S5 is used to parse batch aggregated verification values from complete or lightweight traceability codes, and extract the target data leaf node hash values and the minimum Merkel proof path accordingly; and generate local enhanced root hashes by recursively calculating layer by layer locally.
[0118] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely preferred examples and are not intended to limit the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of the present invention is defined by the appended claims and their equivalents.
Claims
1. An agricultural product traceability system, characterized in that, include: Enhanced building module (1) is used to obtain basic compliance data of large batches of agricultural products and generate corresponding hash value sets; Based on the hash value set, state commitment leaf node hash values are generated according to the preset data leaf node sorting rules. Then, the hash value set and the state commitment leaf node hash values are used as inputs at the same level to jointly participate in the recursive hash construction of the parent batch enhanced Merkle tree to generate the enhanced root hash. The hierarchical storage module (2) is used to divide the acquired agricultural product traceability data into basic compliance data and commercial value-added data; construct blockchain transaction data containing enhanced root hash and write it into the consortium blockchain network for storage; Upload commercial value-added data to the IPFS network and generate fixed-length content identifiers as indexes to store in the traceability data metadata database; The verification generation module (3) is used to extract the hash value of the leaf node of the target data and calculate the minimum Merkel proof path, and then encapsulate the hash value of the leaf node of the target data and the minimum Merkel proof path in a structured manner to generate batch aggregate verification values. The traceability code encoding module (4) is used to generate complete traceability codes or lightweight traceability codes based on the batch aggregate verification value and the fixed-length content identifier, respectively.
2. The agricultural product traceability system according to claim 1, characterized in that, The process of generating the hash value of the state commitment leaf node in the enhanced building module (1) includes the following steps: Each independent piece of basic compliance data is treated as an independent data leaf node, and a corresponding data leaf node hash value is generated. A hash value set is formed based on the hash values of the data leaf nodes, and then the hash value set is sorted according to the preset data leaf node sorting rules to obtain the sorted order; The hash values of the data leaf nodes in the hash value set are concatenated in the sorted order to form a full data sequence. Then, a hash digest calculation is performed on the full data sequence to generate the hash value of the state commitment leaf node.
3. The agricultural product traceability system according to claim 1, characterized in that, The hierarchical storage module (2) further includes the following steps: Acquire the full amount of agricultural product traceability data to be stored, and divide the full amount of agricultural product traceability data into two categories according to data attributes: basic compliant data and commercial value-added data; Based on basic compliance data, blockchain transaction data containing enhanced root hashes is constructed and broadcast to the consortium blockchain network. After verification by a preset consensus mechanism, the blockchain transaction data is written into a new blockchain block. Batch upload of commercial value-added data to the IPFS client interface The network generates a unique fixed-length content identifier.
4. The agricultural product traceability system according to claim 1, characterized in that, The minimum Merkel proof path in the verification generation module (3) includes the following steps: Starting from the target data leaf node hash value, traverse upwards layer by layer along the hierarchical structure of the parent batch enhanced Merkle tree until the enhanced root node corresponding to the enhanced root hash is reached; At each level during the traversal, extract the hash value of the sibling node corresponding to the current node in the calculation process of its parent node; The hash value of the parent node at the next higher level is generated by concatenating the sibling node with the current node and performing a hash operation. The hash values of the sibling nodes extracted during the traversal are arranged in order from low level to high level to form the minimum Merkel proof path.
5. The agricultural product traceability system according to claim 1, characterized in that, The process of generating a complete traceability code in the traceability code encoding module (4) includes the following steps: use The QR code encoding format encodes the batch aggregated verification value together with the fixed-length content identifier pre-stored in the traceability data element database to generate a complete traceability code; wherein, the batch aggregated verification value and the fixed-length content identifier are structured and merged and then encoded into a QR code image.
6. The agricultural product traceability system according to claim 1, characterized in that, The traceability code encoding module (4) includes the following steps: Obtain the high added value and current circulation level of agricultural product categories and determine whether to assign high-value data tags; If the agricultural product category belongs to the high value-added category list and the current circulation level is the retail terminal level, then the batch aggregate verification value and the fixed-length content identifier will be merged and encoded into a complete traceability code; otherwise, only the batch aggregate verification value will be encoded to generate a lightweight traceability code.
7. The agricultural product traceability system according to claim 1, characterized in that, It also includes a local verification module (5), which is used to parse batch aggregate verification values from complete traceability code or lightweight traceability code, extract the target data leaf node hash value and the minimum Merkel proof path and perform layer-by-layer recursive calculation to generate a local enhanced root hash; compare the local enhanced root hash with the enhanced root hash in the consortium blockchain network to see if they are consistent, and if they are consistent, generate a basic traceability information display page.
8. The agricultural product traceability system according to claim 7, characterized in that, The local enhanced root hash in the local verification module (5) includes the following method steps: The current calculated hash is initialized to the hash value of the target data leaf node, where the current calculated hash represents the hash value of the current level node during the recursive calculation process; Iterate through the hash values of each sibling node in the path to the minimum Merkel proof, concatenate the currently calculated hash with the hash value of the sibling node, and then execute the operation. Perform a hash operation, and then update the calculated hash with the result. When all sibling node hashes in the minimum Merkel proof path have been traversed, the current calculated hash after the traversal is completed is the locally generated enhanced root hash of the client.
9. A method for operating an agricultural product traceability system comprising any one of claims 1-8, characterized in that: The methods and steps include the following: S1 is used to obtain basic compliance data for large batches of agricultural products and generate a set of hash values. It generates hash values for state commitment leaf nodes according to the preset data leaf node sorting rules. It is used as input at the same level as the set of hash values to participate in the recursive hash construction of the parent batch enhanced Merkle tree and generate an enhanced root hash. S2 is used to divide the acquired agricultural product traceability data into basic compliance data and commercial value-added data; construct blockchain transaction data containing enhanced root hashes, write it into the consortium blockchain network for notarization, upload the commercial value-added data to the IPFS network, and generate fixed-length content identifiers to be stored in the traceability data metadata database. S3 is used to extract the hash value of the leaf node of the target data and calculate the minimum Merkel proof path. Then, the hash value of the leaf node of the target data and the minimum Merkel proof path are encapsulated in a structured manner to generate batch aggregate verification value. S4 is used to generate complete traceability codes or lightweight traceability codes based on batch aggregated verification values and fixed-length content identifiers, respectively. S5 is used to parse batch aggregated verification values from complete or lightweight traceability codes, and extract the target data leaf node hash values and the minimum Merkel proof path accordingly; and generate local enhanced root hashes by recursively calculating layer by layer locally.
