Warehouse receipt management method and system based on sparse Merkle tree
By adopting sparse Merkel tree and zero-knowledge proof technology in warehouse receipt management, the problem of difficulty in guaranteeing authenticity and security in traditional warehouse receipt verification is solved, and efficient management of warehouse receipts and the safety and efficiency of goods transactions are achieved.
Patent Information
- Application Number
- CN202211432371.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2042-11-15
AI Technical Summary
During the traditional warehouse receipt verification process, the authenticity and non-forgery of warehouse receipts are difficult to effectively protect, resulting in an increase in the risk of goods being breached. At the same time, strict technical process verification will make it more difficult for picking up agents to prove and the process time is too long.
The warehouse receipt management method based on sparse Merkel trees is adopted, and the warehouse receipt information is stored in the sparse Merkel tree through hashing operations and uploaded to the blockchain. The zero-knowledge proof mechanism is used to generate pickup certificates to ensure the binding of the number of pickup times and the warehouse receipt information, and the security and efficiency of pickup verification are achieved.
Ensure the authenticity and safety of warehouse receipts, improve the certification efficiency of warehouse and customer parties, shorten the time of goods transactions, and reduce the risk of goods being breached.
Smart Images

Figure CN115829460B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of blockchain, and particularly relates to a warehouse receipt management method and system based on a sparse Merkle tree. Background Art
[0002] In blockchain technology, the immutability and anonymity of information can be regarded as its important features. Whenever information is uploaded to a brand-new block, it will be recorded in the entire blockchain network. Through the protection of Byzantine fault tolerance, as long as more than 2 / 3 of the nodes are not controlled simultaneously, its security can be guaranteed.
[0003] As a technology associated with blockchain, the main purpose of the Merkle tree is to achieve fast data query. Usually, information is stored separately on the leaf nodes (leaves) of the Merkle tree, and then the hash calculation is performed on two leaf nodes to obtain intermediate nodes. Then, the above hash calculation is continued on the intermediate nodes, and finally a hash value is obtained, which is called the root of the Merkle tree.
[0004] In the traditional Merkle tree, only the existence of a certain element can be checked, and the lack of checking for non-existent elements leads to ambiguity about whether the completed data should continue to be stored on the Merkle tree. The present invention adopts a variant of the sparse Merkle tree. The sparse Merkle tree stores all data in the Merkle tree according to a certain rule. If the data itself does not exist, the corresponding leaf is set to empty. When it is necessary to verify whether the leaf data at the corresponding position does not exist, the null value can be directly substituted for the verification of the Merkle tree. If the results are the same, it can be proved that the data sought does not exist.
[0005] In the traditional warehouse receipt verification process, the authenticity and non-forgery of the warehouse receipt are particularly important. In the case where the two parties do not know each other well, a reliable and authentic warehouse receipt is essential in the transaction process, but there is a lack of powerful tools for protecting and supervising its characteristics.
[0006] In the traditional goods trading process, it is necessary to verify various information of the customer. Among them, personal information is easy to forge and leak, resulting in an increased risk of goods being misappropriated. Similarly, if strict technical processes are used for verification, it will increase the difficulty of proving the pick-up agent and the overall process time will be too long. Summary of the Invention
[0007] Based on the above background and the problems existing in the prior art, the present invention intends to design a warehouse receipt management method and system based on a sparse Merkle tree, which can ensure the authenticity and security of the warehouse receipt. Another object of the present invention is to improve the authentication efficiency of the warehouse side and the customer side through the method of zero-knowledge proof, so as to safely conduct goods transactions.
[0008] To achieve these objects and other advantages of the present invention, there is provided a warehouse receipt management method based on a sparse Merkle tree, including the following steps:
[0009] Based on the information of the warehouse, the warehouse receipt information generation module stores the warehouse receipt information in the sparse Merkle tree after hash operation and uploads it to the blockchain;
[0010] When a customer makes a purchase, the customer purchase module generates a delivery proof by using the zero-knowledge proof mechanism for the customer purchase information and the warehouse receipt information;
[0011] After the purchase is completed, the warehouse receipt information update module binds the number of times the customer has taken delivery with the warehouse receipt stored in the sparse Merkle tree after calculation;
[0012] When the person picking up the goods initiates the pick-up, the pick-up verification module verifies the pick-up proof, and after the warehouse verifies it correctly, the goods are delivered according to the number of times of pick-up in the sparse Merkle tree.
[0013] Further, in the warehouse receipt information generation module, it is necessary to encrypt the plaintext information of the warehouse receipt to generate a warehouse receipt hash value, and then upload the warehouse receipt hash value to the blockchain, including:
[0014] The information uploaded for the warehouse receipt can be arbitrarily selected by the warehouse. Among them, the publicly available information is hashed and encrypted to generate a warehouse receipt hash value;
[0015] The warehouse receipt hash value and the plaintext information of the warehouse receipt are sent to the blockchain system. Among them, the warehouse receipt hash value is sent to the sparse Merkle tree;
[0016] The warehouse receipt hash value is publicly announced and forms a one-to-one relationship with the warehouse receipt.
[0017] Further, in the storage of the warehouse receipt hash value in the warehouse receipt information generation module, the sparse Merkle tree generation method is adopted, and two leaf nodes with the same intermediate node are used as the left leaf and the right leaf respectively, including:
[0018] Each warehouse receipt occupies 2 leaf positions in the sparse Merkle tree;
[0019] The left leaf part stores the warehouse receipt hash value; the right leaf part is left empty.
[0020] Further, when a customer makes a purchase, the necessary information of the customer is collected in the customer purchase module, including the real identity information of the customer;
[0021] The corresponding warehouse receipt hash value;
[0022] The secret password of the customer;
[0023] The secret password of the warehouse.
[0024] Further, after the necessary information of the customer is collected in the customer purchase module, the smart contract generates a proof of taking delivery by combining the transaction information of both parties with the passwords of both parties. During the zero-knowledge proof process:
[0025] First, calculate the hash of the passwords of both parties and the transaction information;
[0026] Deposit this hash value and the encrypted information automatically generated by the smart contract into the verification Merkle tree;
[0027] Generate a proof of taking delivery of the above information through zero-knowledge proof.
[0028] Further, after the warehouse receipt is purchased, the customer can customize the number of times of taking delivery. Among them, the number of times of taking delivery is a positive integer. Among them, the warehouse receipt information update module is used to synchronously update the number of times of taking delivery to the sparse Merkle tree. Among them, according to the warehouse receipt hash value, the right leaf of the corresponding warehouse receipt is updated to the specific number of times of taking delivery.
[0029] Further, when the person taking delivery comes to take delivery, the taking delivery verification module is used, and the proof of taking delivery; the warehouse receipt hash value; and the number of times of taking delivery need to be provided.
[0030] Further, verify according to the information provided by the person taking delivery, including:
[0031] Verify the proof of taking delivery;
[0032] Verify the specific warehouse receipt hash value and the available number of times of taking delivery in the sparse Merkle tree with the warehouse receipt information as the left leaf and the number of times of taking delivery as the right leaf.
[0033] Among them, only when the proof of taking delivery is verified correctly can the verification of the sparse Merkle tree be carried out. Among them, there are multiple results for the verification. According to the types of the results, the following answers can be obtained:
[0034] If the right leaf in the sparse Merkle tree is 0, it means the goods have been delivered;
[0035] If the right leaf in the sparse Merkle tree is empty, it means the order does not exist;
[0036] If the right leaf in the sparse Merkle tree is not equal to the input number of times, taking delivery is not allowed;
[0037] If the right leaf in the sparse Merkle tree is equal to the input number of times, subtract 1 from the number of right leaves and update the sparse Merkle tree, and then the goods can be delivered. Use the number of times of taking delivery after subtracting 1 as the next number of times of taking delivery;
[0038] Among them, the specific calculation logic is that the system automatically substitutes null values and 0 values first, and judges whether the root of the sparse Merkle tree is correct to determine whether it has been purchased or delivered. Then judge whether it is correct by substituting the remaining number of times of taking delivery submitted by the person taking delivery, so as to determine whether the goods can be shipped.
[0039] The present invention also provides a warehouse receipt management system based on a sparse Merkle tree, including a warehouse receipt information generation module, a customer purchase module, a warehouse receipt information update module, and a delivery verification module:
[0040] The warehouse receipt information generation module stores the warehouse receipt hash value generated by performing a hash operation on the warehouse receipt information in the sparse Merkle tree and uploads it to the blockchain;
[0041] The customer purchase module generates a delivery proof by using a zero-knowledge proof mechanism for the customer purchase information and the warehouse receipt information;
[0042] The warehouse receipt information update module binds the customer's delivery times to the warehouse receipt hash value stored in the sparse Merkle tree.
[0043] The present invention has at least the following beneficial effects:
[0044] 1. Facilitate warehouse receipt management: By using a sparse Merkle tree, the status of the warehouse receipt can be judged by determining the value of the right leaf. This system can not only positively judge whether the warehouse receipt exists, but also inversely judge whether the warehouse receipt does not exist, providing a new logic for warehouse receipt management.
[0045] 2. Protect the privacy of the purchaser and the goods information: After the purchaser makes a purchase, all identities, goods information, and transaction details are stored in an immutable Merkle tree. Compared with the traditional purchase process, personal information and transaction details will be greatly protected.
[0046] 3. Ensure the security during delivery: During delivery, the zero-knowledge proof mode is adopted, enabling secure transactions between unfamiliar trading parties without exposing their identity information. If the delivery person and the recipient change, only the delivery proof needs to be provided, and the identity of the agent can conduct secure transactions confidentially. At the same time, the transaction efficiency is improved, and the difficulty of mutual identity verification is shortened.
[0047] Other advantages, objectives, and features of the present invention will be partially reflected by the following description and partially understood by those skilled in the art through the research and practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0049] Figure 1It is a flowchart of a warehouse receipt management method based on a sparse Merkle tree provided by an embodiment of the present invention;
[0050] Figure 2 It is a flowchart of a warehouse receipt information generation module;
[0051] Figure 3 It is a schematic diagram of the improved sparse Merkle tree provided by an embodiment of the present invention;
[0052] Figure 4 It is a schematic diagram of a verification Merkle tree provided by an embodiment of the present invention;
[0053] Figure 5 It is a flowchart of goods pickup and warehouse receipt verification provided by an embodiment of the present invention. Detailed implementation manners
[0054] To clearly elaborate the present invention and make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following combines the accompanying drawings in the embodiments of the present invention and describes the technical solutions in the embodiments of the present invention clearly and completely, so that those skilled in the art can implement according to the description in the specification. The following will elaborate on the technology of the present invention in combination with specific implementation manners.
[0055] Embodiment 1:
[0056] Figure 1 It shows an implementation form according to the present invention. A warehouse receipt management method based on a sparse Merkle tree includes: the warehouse party uses a warehouse receipt information generation module to store the warehouse receipt information in the sparse Merkle tree after hash operation and then upload it to the blockchain; when a customer makes a purchase, the customer purchase module generates a goods pickup proof by using the zero-knowledge proof mechanism for the customer purchase information and the warehouse receipt information; after the purchase is completed, the warehouse receipt information update module binds the customer's goods pickup times to the warehouse receipt stored in the sparse Merkle tree; when the goods picker initiates goods pickup, the goods pickup module verifies the goods pickup proof, and after the warehouse party verifies it correctly, it delivers the goods according to the goods pickup times in the sparse Merkle tree.
[0057] (1) S10 Warehouse receipt information generation module: As Figure 2 shown, step S11 is the warehouse receipt information generation module, and the warehouse receipt upload information can be arbitrarily selected by the warehouse party. Among them, step S12 selects some public information for hash encryption. The following is a simplified warehouse receipt:
[0058] Depositor Variety of the stored goods Quantity Quality Number of packages Zhang San Mineral water 300x12 Excellent 300
[0059] Step S13 generates encrypted information for all the information therein through a hashing algorithm: 58c1a3d6461793bfa7c03e0932a54d8c5ec373a02f1fe5c7b90a84f423c572a3. In the example, the SHA256 encryption algorithm is used, and the algorithm can be replaced according to specific circumstances). Step S14 stores this hash value as the hash value of the warehouse receipt in the sparse Merkle tree as Figure 3 .
[0060] The sparse Merkle tree described here has been modified on the original basis. During the process of entering the hash value of the warehouse receipt, the two leaf nodes with the same intermediate node are used as the left leaf and the right leaf. Each warehouse receipt occupies 2 leaf positions in the sparse Merkle tree. The left leaf part stores the hash value of the warehouse receipt, and the right leaf part is left empty.
[0061] (2) S20 Customer Purchase Module: When the customer initiates a purchase request, it will collect the necessary information of both trading parties, including:
[0062] The customer's real identity information; the corresponding warehouse receipt hash value; the customer's secret password; the warehouse party's secret password. And submit them to the smart contract. Among them, the warehouse receipt information in the smart contract is used as public input, and the passwords of the warehouse party and the customer are used as private input to generate a proof of taking delivery through zero-knowledge proof. Among them, the zero-knowledge proof method can adopt the Poseidon encryption method, or use encryption technologies such as MIMC and SHA256 for calculation, and then store the encrypted information in Figure 4 the verification Merkle tree of
[0063] (3) S30 Warehouse Receipt Information Update Module: After the customer's purchase is completed, the number of times of taking delivery is agreed with the warehouse party. After that, the customer obtains the proof of taking delivery, and the warehouse party updates the corresponding right leaf of the sparse Merkle tree to the number of times of taking delivery according to the agreed number of times of taking delivery. Mark the quantity of each delivery under the supervision of the customer.
[0064] (4) S40 Taking Delivery Verification Module: As Figure 5 shown, when the person taking delivery comes to take delivery, they need to provide the necessary information: the proof of taking delivery, the warehouse receipt hash value, and the number of times of taking delivery. First, verify the proof of taking delivery of the person taking delivery. Only when the proof of taking delivery is verified successfully can the corresponding warehouse receipt be searched and judged in the sparse Merkle tree. Among them, the specific calculation logic is to first automatically substitute null values and 0 values by the system to judge whether the root of the sparse Merkle tree is correct to determine whether it has been purchased or delivered. Then, substitute the remaining number of times of taking delivery submitted by the person taking delivery to judge whether it is correct, so as to determine whether delivery can be made. The specific situation is as follows:
[0065] If the right leaf in the sparse Merkle tree is 0, it means the goods have been delivered;
[0066] If the right leaf in the sparse Merkle tree is empty, it means that the order does not exist;
[0067] If the right leaf in the sparse Merkle tree is not equal to the number of inputs, the goods cannot be picked up;
[0068] If the number of right leaves in the sparse Merkle tree is equal to the input number, the number of right leaves is reduced by 1 and the sparse Merkle tree is updated. Then the goods can be delivered, and the number of pickups after reduction by 1 is used as the number of next pickups.
[0069] Embodiment 2:
[0070] The present invention also provides a warehouse receipt management system based on a sparse Merkle tree, which is characterized by including a warehouse receipt information generation module, a customer purchase module, a warehouse receipt information update module and a delivery verification module.
[0071] Warehouse receipt information generation module: First, the warehouse receipt information is partially disclosed through the warehouse receipt information generation module, and the warehouse receipt information is hashed and encrypted, and the encrypted information is passed into the sparse Merkle tree. Then the root of the Merkle tree and the public information of the warehouse receipt are uploaded to the two block networks.
[0072] Customer purchase module: When a customer purchases, the purchase information provided by the customer and the encrypted information of the warehouse receipt will be used together to generate a delivery certificate through zero-knowledge proof. Among them, the customer needs to provide real identity information for identity verification, and the identity information will be protected by zero-knowledge proof.
[0073] Warehouse receipt information update module: After the customer purchases, the sparse Merkle tree must be updated at the right (second) leaf of the sparse Merkle tree corresponding to the purchased warehouse receipt, and the number of pickup times must be updated and checked at the corresponding position.
[0074] Pickup verification module: When picking up the goods, the consignee needs to provide proof of pick-up, the goods number, and the number of pick-ups. The warehouse will verify the information provided in the blockchain network, and the goods can only be delivered after it is correct.
[0075] The above description of the embodiments is to facilitate the understanding and application of the present invention by those skilled in the art. It is obvious that those skilled in the art can easily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without creative work. Therefore, the present invention is not limited to the above embodiments, and improvements and modifications made to the present invention by those skilled in the art based on the disclosure of the present invention should be within the scope of protection of the present invention.
Claims
1. A warehouse receipt management method based on a sparse Merkle tree, characterized in that It includes the following steps: The warehouse receipt hash value generated by the warehouse receipt information generation module after hashing the warehouse receipt information is stored in the sparse Merkle tree and uploaded to the blockchain; The customer purchase module uses the zero-knowledge proof mechanism to generate a delivery proof from the customer purchase information and the warehouse receipt information; The warehouse receipt information update module binds the customer's delivery times to the warehouse receipt hash value stored in the sparse Merkle tree; The delivery verification module verifies the delivery proof, and after verification, delivers the goods according to the delivery times in the sparse Merkle tree.
2. The method for managing warehouse receipts based on a sparse Merkle tree according to claim 1, wherein The warehouse receipt hash value generated by the warehouse receipt information generation module after hashing the warehouse receipt information is stored in the sparse Merkle tree. Among them, the sparse Merkle tree, as a data structure in the blockchain, is used to compress data and reduce the pressure of storing data. The storage process includes the following steps: Arbitrarily select the upload information of the warehouse receipt. The upload information includes public plaintext information, and the public plaintext information is hashed and encrypted to generate a warehouse receipt hash value; The warehouse receipt hash value and the warehouse receipt plaintext information are sent to the blockchain, and the warehouse receipt hash value is stored in the sparse Merkle tree; The warehouse receipt hash value is publicly announced and forms a one-to-one relationship with the warehouse receipt.
3. The method for managing warehouse receipts based on a sparse Merkle tree according to claim 2, wherein Storing the warehouse receipt hash value in the sparse Merkle tree includes the following steps: Taking the two leaf nodes with the same intermediate node as the left leaf and the right leaf respectively, each warehouse receipt occupies 2 leaf positions in the sparse Merkle tree; The left leaf part stores the warehouse receipt hash value, and the right leaf part is left empty.
4. The method for managing warehouse receipts based on a sparse Merkle tree according to claim 1, wherein, The customer purchase information includes the customer's real identity information, the corresponding warehouse receipt hash value, the customer's secret password, and the warehouse party's secret password.
5. The method for managing warehouse receipts based on a sparse Merkle tree according to claim 4, characterized in that, After the purchase information is submitted, the smart contract generates a delivery proof from the transaction information of both parties and the passwords of both parties. In the zero-knowledge proof process: First, hash the passwords of both parties and the transaction information to generate a hash value; This hash value is automatically generated by the smart contract into encrypted information and stored in the verification Merkle tree; Through zero-knowledge proof, this hash value and the position information in the verification Merkle tree are used to generate a delivery proof.
6. The method for managing warehouse receipts based on a sparse Merkle tree according to claim 1, wherein After the warehouse receipt information is purchased, the customer needs to set the delivery times by himself, and the delivery times are all positive integers. The warehouse receipt information update module synchronously updates the delivery times to the sparse Merkle tree. According to the warehouse receipt hash value, the right leaf of the corresponding warehouse receipt is updated to the specific delivery times.
7. The method for warehouse receipt management based on a sparse Merkle tree according to claim 1, wherein In the delivery verification module, the verification process needs to obtain the delivery proof, the warehouse receipt hash value, and the delivery times provided by the person picking up the goods.
8. A method for warehouse receipt management based on a sparse Merkle tree according to claim 1 or 5 or 7, characterized in that Verifying the delivery information of the person picking up the goods in the delivery verification module includes: Verifying the delivery proof; Verifying the warehouse receipt hash value and the available delivery times in the sparse Merkle tree with the warehouse receipt information as the left leaf and the delivery times as the right leaf; Only when the delivery proof is verified correctly, the sparse Merkle tree is verified and the verification result is obtained.
9. The method for managing warehouse receipts based on a sparse Merkle tree according to claim 8, characterized in that, The verification results include: If the right leaf in the sparse Merkle tree is 0, it means the goods have been delivered; If the right leaf in the sparse Merkle tree is empty, it means the order does not exist; If the right leaf in the sparse Merkle tree is not equal to the input times, the goods cannot be picked up; If the right leaf in the sparse Merkle tree is equal to the input times, subtract 1 from the number of right leaves and update the sparse Merkle tree, then delivery can be made, and the remaining pickup times after subtracting 1 are used as the next pickup times; Among them, for the input null value and 0 value, determine whether to purchase or have been delivered by judging whether the root of the sparse Merkle tree is correct, and then obtain the remaining pickup times submitted by the picker to judge whether it is correct, so as to determine whether to ship.
10. A warehouse receipt management system based on a sparse Merkle tree, characterized in that, It includes a warehouse receipt information generation module, a customer purchase module, a warehouse receipt information update module, and a pickup verification module: The warehouse receipt information generation module stores the warehouse receipt hash value generated by hashing the warehouse receipt information in the sparse Merkle tree and uploads it to the blockchain; The customer purchase module generates a pickup proof for the customer purchase information and the warehouse receipt information through the zero-knowledge proof mechanism; The warehouse receipt information update module binds the customer's pickup times to the warehouse receipt hash value stored in the sparse Merkle tree; The pickup verification module verifies the pickup proof and makes delivery through the pickup times in the sparse Merkle tree after verification.
Citation Information
Patent Citations
Electronic warehouse receipt generation method and system based on blockchain multi-role evidence storage verification
CN112199739A
Electronic evidence storage and verification method and device based on block chain
CN113129145A