Digital transaction method and device for protecting user privacy
By using zero-knowledge proof technology and Merkle trees in the semi-centralized trading market to protect user privacy and verify the legality of transactions, the problem of user privacy leakage in the semi-centralized trading market is solved, and safe and fair digital assets are realized. trade.
Patent Information
- Application Number
- CN202410780027.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-10-01
AI Technical Summary
Semi-centralized trading markets cannot fully protect user privacy. Once transaction information is completed through smart contracts, anyone can see it, leading to user privacy leaks.
Zero-knowledge proof technology is used to protect user privacy in the semi-centralized trading market. The virtual identity information and random numbers randomly generated by the seller and buyer users are used to generate usable proofs. After verification, the digital asset transaction is transferred, and the virtual identity information is combined with Digital asset information is associated and stored in a Merkle tree, ensuring that only trading users know the transaction information.
It effectively protects the user's order privacy information and transaction process, ensuring that the flow of digital assets is only known between trading users. It ensures the legality and security of the transaction through verification of zero-knowledge proof, while ensuring the fairness of the transaction.
Smart Images

Figure CN118735522A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of digital transaction technology, and in particular to a digital transaction method and device for protecting user privacy. Background Art
[0002] The semi-centralized trading market neutralizes the centralized market and the decentralized market. The way the semi-centralized trading market handles orders is to store and match users' orders on a decentralized server, and submit the matching orders to the transaction processing smart contract. The transaction processing smart contract will check whether the user's order complies with the specifications and whether it matches. The orders that pass the check and match will eventually realize the transfer of digital collections and digital assets.
[0003] However, the semi-centralized trading market solution still cannot completely protect the privacy of users. Although only the centralized trading market platform knows when the buyer submits the buy order and the seller submits the sell order, once the transaction is completed through the smart contract, anyone can also see the transaction information of the transaction. Therefore, the semi-centralized trading market has the problem of user privacy leakage. Summary of the invention
[0004] The embodiments of the present application provide a digital transaction method and device for protecting user privacy, which are used to protect user privacy information during digital asset transactions to improve transaction security.
[0005] In a first aspect, the embodiments of the present application provide a digital transaction method for protecting user privacy, which is applied to a semi-centralized transaction market, including:
[0006] Receive a selling order from a seller user and a buying order from a buyer user; the selling order includes a transaction identifier for indicating a transaction subject, a first virtual identity information, and a first usability certificate, and the buying order includes a transaction identifier for indicating a transaction subject, a second virtual identity information, and a second usability certificate; the first virtual identity information is obtained by a first random number randomly generated by the seller user; the second virtual identity information is obtained by a second random number randomly generated by the buyer user; the first usability certificate is a zero-knowledge proof generated for a first digital asset based on the first random number provided by the seller user after the first virtual identity information is verified; the second usability certificate is a zero-knowledge proof generated for a second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified; the first digital asset represents a transaction subject owned by the seller user, and the second digital asset represents a transaction subject owned by the buyer user;
[0007] If the buy order and the sell order point to the same transaction identifier, verify the first usability certificate and the second usability certificate respectively;
[0008] If the verification is successful, the first digital asset and the second digital asset are traded and transferred.
[0009] This application builds a semi-centralized trading market and uses zero-knowledge proof to protect the user's order privacy information and transaction process, so that the circulation of digital assets is only known to the trading users themselves, and the buyers and sellers do not know each other. The legality and matching of the order are guaranteed by verifying the zero-knowledge proof, further ensuring the security of the transaction.
[0010] In addition, since the semi-centralized trading market constructed by this application is completely decentralized, all orders are submitted directly by users and stored in the trading smart contract of the semi-centralized trading market, and continue to be matched according to the order in which the buy and sell orders are created to ensure fairness for trading users.
[0011] Optionally, receiving a first pledge request triggered by the seller user, wherein the first pledge request includes a transaction identifier and first virtual identity information;
[0012] Verifying whether the seller user has ownership of the first digital asset indicated by the transaction identifier;
[0013] Verifying whether the first virtual identity information has been used for transactions;
[0014] If the seller user has ownership of the first digital asset and the first virtual identity information has not been traded, the address information of the first digital asset is transferred to the first pledge address.
[0015] Optionally, receiving a second pledge request from the buyer user, wherein the second pledge request includes a second digital asset and a second virtual identity information;
[0016] Verifying whether the buyer user has digital assets no less than the second digital asset;
[0017] Verifying whether the second virtual identity information has been used for transactions;
[0018] If the buyer user has digital assets that are no less than the second digital asset and the second virtual identity information has not been traded, the address information corresponding to the second digital asset owned by the buyer user is transferred to the second pledge address.
[0019] Optionally, after transferring the address information of the first digital asset to the first pledge address and before receiving the sell order from the seller user, the method further includes:
[0020] Adding the first digital asset information to the first leaf node of the first Merkle tree, where the first leaf node is any unoccupied leaf node of the first Merkle tree; the first digital asset information includes the first pledge address and the transaction identifier, and the first digital asset information is associated with the first virtual identity information;
[0021] After transferring the address information corresponding to the second digital asset owned by the buyer user to the second pledge address and before receiving the buyer user's purchase order, the method further includes:
[0022] Receive the second digital asset information of the buyer user, and add the second digital asset information to the second leaf node of the second Merkle tree, where the second leaf node is any unoccupied leaf node of the second Merkle tree; the second digital asset information includes the second pledge address and the second digital asset, and the second digital asset information is associated with the second virtual identity information.
[0023] By associating the virtual identity information created by the user with the corresponding digital asset information, the corresponding digital asset information can be obtained based on the virtual identity information while ensuring the privacy information of both parties in the transaction in the transaction smart contract.
[0024] Optionally, before generating a zero-knowledge proof for the first digital asset based on the first random number, the method further includes:
[0025] Verify whether the root value of the first Merkle tree can be calculated by the path value of the first leaf node, the sibling node value on the path of the first leaf node, the first random number, the depth of the first Merkle tree, and the content of the first leaf node;
[0026] Before generating a zero-knowledge proof for the second digital asset based on the second random number, the method further includes:
[0027] Verify whether the root value of the second Merkle tree can be calculated by the path value of the second leaf node, the sibling node value on the path of the second leaf node, the second random number, the depth of the second Merkle tree and the content of the second leaf node.
[0028] Optionally, the first usability proof is a zero-knowledge proof generated for the first digital asset based on the first random number provided by the seller user after the first virtual identity information is verified, including:
[0029] Verifying the first virtual identity information by using the first random number provided by the seller user;
[0030] If the verification is successful, the first usability certificate is generated through zero-knowledge proof based on the first secret information and the first public information; the first secret information includes the path value of the first leaf node, the sibling node value on the path of the first leaf node and the first random number provided by the seller user, and the first public information includes the depth of the first Merkle tree and the content of the first leaf node;
[0031] The second usability proof is a zero-knowledge proof generated for the second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified, and includes:
[0032] Verifying the second virtual identity information by using the second random number provided by the buyer user;
[0033] If the verification passes, the second usable proof is generated through zero-knowledge proof based on the second secret information and the second public information; the second secret information includes the path value of the second leaf node, the sibling node value on the path of the second leaf node and the second random number, and the second public information includes the depth of the second Merkle tree and the content of the second leaf node.
[0034] Optionally, the selling order further includes third virtual identity information, and the third virtual identity information is obtained based on a third random number randomly generated by the seller user; the buying order further includes fourth virtual identity information, and the fourth virtual identity information is obtained based on a fourth random number randomly generated by the buyer user;
[0035] The transaction transfer of the first digital asset and the second digital asset includes:
[0036] Associating the first digital asset information with the fourth virtual identity information, and adding the information to a third leaf node of the first Merkle tree, where the third leaf node is any unoccupied leaf node of the first Merkle tree;
[0037] The second digital asset information is associated with the third virtual identity information, and added to the fourth leaf node of the second Merkle tree, where the fourth leaf node is any unoccupied leaf node of the second Merkle tree.
[0038] Optionally, the second digital asset is greater than the transaction amount corresponding to the transaction identifier;
[0039] The purchase order further includes fifth virtual identity information and the transaction amount, wherein the fifth virtual identity information is obtained based on a fifth random number randomly generated by the buyer user;
[0040] The third digital asset information is added to the fifth leaf node of the second Merkle tree and associated with the fifth virtual identity information, where the fifth leaf node is any unoccupied leaf node of the second Merkle tree; the third digital asset information includes the difference between the second digital asset and the transaction amount and the second pledge address.
[0041] Optionally, after adding to the third leaf node of the first Merkle tree, the method further includes:
[0042] A third usability proof is calculated based on the path value of the third leaf node, the sibling node value on the path of the third leaf node, a sixth random number, the depth of the first Merkle tree and the content of the third leaf node, wherein the sixth random number is randomly generated by the buyer user;
[0043] The third usability certificate is verified, and if the verification is passed, the address information corresponding to the first digital asset is transferred to the address of the buyer user to complete the withdrawal of the first digital asset by the buyer user.
[0044] Optionally, after adding to the fourth leaf node of the second Merkle tree, the method further includes:
[0045] A fourth usability proof is calculated based on the path value of the fourth leaf node, the sibling node value on the path of the fourth leaf node, a seventh random number, the depth of the second Merkle tree, and the content of the fourth leaf node, wherein the seventh random number is randomly generated by the seller user;
[0046] The fourth usable proof is verified, and if the verification is passed, the address information corresponding to the second digital asset is transferred to the address of the seller user to complete the withdrawal of the second digital asset by the seller user.
[0047] Optionally, before the transaction transfer of the first digital asset and the second digital asset, the method further includes:
[0048] Verifying whether the fourth virtual identity information, the third virtual identity information, and the fifth virtual identity information have been traded;
[0049] If no transaction has been conducted, verify that the second digital asset is greater than or equal to the transaction amount.
[0050] In a second aspect, the present application provides a digital transaction device for protecting user privacy, comprising:
[0051] A receiving module, used for receiving a selling order of a seller user and a buying order of a buyer user; the selling order includes a transaction identifier for indicating a transaction subject, a first virtual identity information and a first usability certificate, and the buying order includes a transaction identifier for indicating a transaction subject, a second virtual identity information and a second usability certificate; the first virtual identity information is obtained by a first random number randomly generated by the seller user; the second virtual identity information is obtained by a second random number randomly generated by the buyer user; the first usability certificate is a zero-knowledge proof generated for a first digital asset based on the first random number provided by the seller user after the first virtual identity information is verified; the second usability certificate is a zero-knowledge proof generated for a second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified; the first digital asset represents a transaction subject owned by the seller user, and the second digital asset represents a transaction subject owned by the buyer user;
[0052] A verification module, configured to verify the first usability certificate and the second usability certificate respectively if the buy order and the sell order point to the same transaction identifier;
[0053] The processing module is used to perform a transaction transfer on the first digital asset and the second digital asset if the verification is passed.
[0054] This application builds a semi-centralized trading market and uses zero-knowledge proof to protect the user's order privacy information and transaction process, so that the circulation of digital assets is only known to the trading users themselves, and the buyers and sellers do not know each other. The legality and matching of the order are guaranteed by verifying the zero-knowledge proof, further ensuring the security of the transaction.
[0055] In addition, since the semi-centralized trading market constructed by this application is completely decentralized, all orders are submitted directly by users and stored in the trading smart contract of the semi-centralized trading market, and continue to be matched according to the order in which the buy and sell orders are created to ensure fairness for trading users.
[0056] Optionally, the processing module is specifically used for:
[0057] Adding the first digital asset information to the first leaf node of the first Merkle tree, where the first leaf node is any unoccupied leaf node of the first Merkle tree; the first digital asset information includes the first pledge address and the transaction identifier, and the first digital asset information is associated with the first virtual identity information;
[0058] After transferring the address information corresponding to the second digital asset owned by the buyer user to the second pledge address and before receiving the buyer user's purchase order, the method further includes:
[0059] Receive the second digital asset information of the buyer user, and add the second digital asset information to the second leaf node of the second Merkle tree, where the second leaf node is any unoccupied leaf node of the second Merkle tree; the second digital asset information includes the second pledge address and the second digital asset, and the second digital asset information is associated with the second virtual identity information.
[0060] By associating the virtual identity information created by the user with the corresponding digital asset information, the corresponding digital asset information can be obtained based on the virtual identity information while ensuring the privacy information of both parties in the transaction in the transaction smart contract.
[0061] Optionally, the verification module is specifically used to:
[0062] Verify whether the root value of the first Merkle tree can be calculated by the path value of the first leaf node, the sibling node value on the path of the first leaf node, the first random number, the depth of the first Merkle tree, and the content of the first leaf node;
[0063] Before generating a zero-knowledge proof for the second digital asset based on the second random number, the method further includes:
[0064] Verify whether the root value of the second Merkle tree can be calculated by the path value of the second leaf node, the sibling node value on the path of the second leaf node, the second random number, the depth of the second Merkle tree and the content of the second leaf node.
[0065] Optionally, the verification module is specifically used to:
[0066] Verifying the first virtual identity information by using the first random number provided by the seller user;
[0067] If the verification is successful, the first usability certificate is generated through zero-knowledge proof based on the first secret information and the first public information; the first secret information includes the path value of the first leaf node, the sibling node value on the path of the first leaf node and the first random number provided by the seller user, and the first public information includes the depth of the first Merkle tree and the content of the first leaf node;
[0068] The second usability proof is a zero-knowledge proof generated for the second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified, and includes:
[0069] Verifying the second virtual identity information by using the second random number provided by the buyer user;
[0070] If the verification passes, the second usable proof is generated through zero-knowledge proof based on the second secret information and the second public information; the second secret information includes the path value of the second leaf node, the sibling node value on the path of the second leaf node and the second random number, and the second public information includes the depth of the second Merkle tree and the content of the second leaf node.
[0071] Optionally, the processing module is specifically used for:
[0072] The selling order further includes third virtual identity information, which is obtained based on a third random number randomly generated by the seller user; the buying order further includes fourth virtual identity information, which is obtained based on a fourth random number randomly generated by the buyer user;
[0073] The transaction transfer of the first digital asset and the second digital asset includes:
[0074] Associating the first digital asset information with the fourth virtual identity information, and adding the information to a third leaf node of the first Merkle tree, where the third leaf node is any unoccupied leaf node of the first Merkle tree;
[0075] The second digital asset information is associated with the third virtual identity information, and added to the fourth leaf node of the second Merkle tree, where the fourth leaf node is any unoccupied leaf node of the second Merkle tree.
[0076] Optionally, the processing module is specifically used for:
[0077] The second digital asset is greater than the transaction amount corresponding to the transaction identifier;
[0078] The purchase order further includes fifth virtual identity information and the transaction amount, wherein the fifth virtual identity information is obtained based on a fifth random number randomly generated by the buyer user;
[0079] The third digital asset information is added to the fifth leaf node of the second Merkle tree and associated with the fifth virtual identity information, where the fifth leaf node is any unoccupied leaf node of the second Merkle tree; the third digital asset information includes the difference between the second digital asset and the transaction amount and the second pledge address.
[0080] Optionally, the processing module is specifically used for:
[0081] A third usability proof is calculated based on the path value of the third leaf node, the sibling node value on the path of the third leaf node, a sixth random number, the depth of the first Merkle tree and the content of the third leaf node, wherein the sixth random number is randomly generated by the buyer user;
[0082] The third usability certificate is verified, and if the verification is passed, the address information corresponding to the first digital asset is transferred to the address of the buyer user to complete the withdrawal of the first digital asset by the buyer user.
[0083] Optionally, the processing module is specifically used for:
[0084] A fourth usability proof is calculated based on the path value of the fourth leaf node, the sibling node value on the path of the fourth leaf node, a seventh random number, the depth of the second Merkle tree, and the content of the fourth leaf node, wherein the seventh random number is randomly generated by the seller user;
[0085] The fourth usable proof is verified, and if the verification is passed, the address information corresponding to the second digital asset is transferred to the address of the seller user to complete the withdrawal of the second digital asset by the seller user.
[0086] Optionally, the verification module is specifically used to:
[0087] Verifying whether the fourth virtual identity information, the third virtual identity information, and the fifth virtual identity information have been traded;
[0088] If no transaction has been conducted, verify that the second digital asset is greater than or equal to the transaction amount.
[0089] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes any of the digital transaction methods for protecting user privacy described in the first aspect above.
[0090] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program executable by a computer device. When the program runs on the computer device, the computer device executes any digital transaction method for protecting user privacy as described in the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS
[0091] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0092] Figure 1 A schematic diagram of the architecture of a semi-centralized trading market for protecting user privacy provided in an embodiment of the present application;
[0093] Figure 2 A flowchart of a digital transaction method for protecting user privacy provided in an embodiment of the present application;
[0094] Figure 3 A schematic diagram of the structure of a first Merkle tree provided in an embodiment of the present application;
[0095] Figure 4 A schematic diagram of the structure of a second Merkle tree provided in an embodiment of the present application;
[0096] Figure 5 A schematic diagram of the structure of a first Merkle tree provided in an embodiment of the present application;
[0097] Figure 6 A schematic diagram of the structure of a second Merkle tree provided in an embodiment of the present application;
[0098] Figure 7 A schematic diagram of the structure of a digital transaction device for protecting user privacy provided in an embodiment of the present application;
[0099] Figure 8 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0100] In order to make the purpose, technical solution and beneficial effects of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0101] For ease of understanding, the terms involved in the embodiments of the present invention are explained below.
[0102] Smart contract: It is a piece of custom code that runs on a blockchain system. Anyone can create a smart contract (written in a special programming language) on a blockchain system. Once created, the smart contract will automatically execute the preset code logic (needs to be triggered by the outside world). For example, a function in the smart contract can be called through blockchain instructions. The execution process and results are transparent and determined, and cannot be modified by anyone.
[0103] Digital collection smart contract: It is a kind of common smart contract in the industry. It uses different token_ids to represent different digital collections and records the relevant information of each digital collection, including the owner's address. The content of the smart contract mainly includes a data list (recording the owner's address of each digital collection corresponding to token_id) and methods related to asset transfer: transferFrom(int256 token_id, address from, address to) is used to transfer the digital collection with the number token_id owned by address from to address to.
[0104] Digital asset smart contract: It is a kind of smart contract commonly used in the industry. All digital assets in the same digital asset smart contract are exactly the same and equivalent. The digital asset smart contract records the number of digital assets owned by each user address. For example, airline membership points can be managed using digital asset smart contracts. The content of the smart contract mainly includes a data list (recording the number of digital assets corresponding to each user address) and asset transfer (for example, transferring 10 digital assets from user A to user B, which is represented in the smart contract as the number of digital assets corresponding to user A's address minus 10, and the number of digital assets corresponding to user B's address plus 10). The related method is used: transferFrom(int256 amount, address from, address to) is used to transfer the amount of digital assets owned by address from to address to.
[0105] A decentralized market refers to an application that runs on the blockchain and uses smart contracts to implement the logic of buying and selling digital collections. The main difference from the traditional centralized market is that decentralized markets use smart contracts to ensure fair and transparent transactions. Specifically, in centralized markets, user orders are stored and matched by the market operator on a centralized server. In order to increase transaction volume data, there are a lot of false orders and insider trading, which makes supervision difficult. In a decentralized market, all user order data is stored in smart contracts, and the matching between orders is guaranteed by smart contracts. The entire transaction process is completely open, automatic and fair, and no one can interfere. However, this also brings about user privacy issues, and all user operations will be seen.
[0106] Zero-Knowledge Proof: refers to a cryptographic tool that allows two communicating parties who do not trust each other to prove the validity of a proposition without revealing any additional information.
[0107] like Figure 1 As shown in the figure, a semi-centralized trading market that can protect user privacy is provided by the present application. The semi-centralized trading market includes two modules, a proof generator module 101 and a transaction processing smart contract 102, wherein the proof generator is a cloud service or terminal running a zero-knowledge proof system prover, which is used to generate zero-knowledge proofs (in the present invention, prover generates two types of proofs, namely, a first usable proof proof dc and second proof of usability da . The construction of prover can be realized by writing a circuit. Among them, the transaction processing smart contract 102 includes three submodules: the user's digital asset management module 103, the user order management module 104 and the zero-knowledge proof verification module 105. The user's digital asset management module 103 is used to manage the digital assets pledged by the user in the transaction processing smart contract (mainly including two Merkle trees and a hash list), the user order management module 104 is used to manage the encrypted user orders and matching orders (mainly including the buy order list and the sell order list), and the zero-knowledge proof verification module 105 is used to verify the zero-knowledge proof submitted by the user (the verification method verifier corresponding to the zero-knowledge proof system prover).
[0108] like Figure 2 As shown, a digital transaction method for protecting user privacy provided by this application is applied to a semi-centralized transaction market, which specifically includes the following steps:
[0109] Step S201, receiving a sell order from a seller user and a buy order from a buyer user; the sell order includes a transaction identifier for indicating a transaction subject, a first virtual identity information and a first usability certificate, and the buy order includes a transaction identifier for indicating a transaction subject, a second virtual identity information and a second usability certificate; the first virtual identity information is obtained by a first random number randomly generated by the seller user; the second virtual identity information is obtained by a second random number randomly generated by the buyer user; the first usability certificate is a zero-knowledge proof generated for a first digital asset based on the first random number provided by the seller user after the first virtual identity information is verified; the second usability certificate is a zero-knowledge proof generated for a second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified; the first digital asset represents a transaction subject owned by the seller user, and the second digital asset represents a transaction subject owned by the buyer user.
[0110] Specifically, the user order management module of the transaction processing smart contract in the semi-centralized trading market manages the sell order list and the buy order list, which respectively store the sell order submitted by at least one seller user and the buy order submitted by at least one buyer user. Each sell order has a transaction identifier indicating the transaction subject, which is used to point to the first digital asset owned by the seller user, and the seller user uses the first digital asset as the transaction subject for trading; the first virtual identity information is used for the seller user to hide the real identity in the semi-centralized trading market. After the seller user randomly generates the first random number, the first random number is converted or encrypted to generate the corresponding first virtual identity information, so only the seller user knows the first random number corresponding to the first virtual identity information; the first usability certificate is used to prove that the seller user has the authority to trade the first digital asset. The first usability certificate is generated by the proof generator module of the semi-centralized trading market based on the first random number provided by the seller user after the first virtual identity information is verified.
[0111] Similarly, each purchase order contains a transaction identifier indicating the transaction subject, which is used to point to the second digital asset owned by the buyer user. The buyer user uses the second digital asset as the transaction subject for trading; the second virtual identity information is used for the buyer user to hide the real identity in the semi-centralized trading market. After the buyer user randomly generates a second random number, the second random number is converted or encrypted to generate the corresponding second virtual identity information. Therefore, only the buyer user knows the second random number corresponding to the second virtual identity information; the second proof of usability is used to prove that the buyer user has the authority to trade the second digital asset. The second proof of usability is generated by the proof generator module of the semi-centralized trading market based on the second random number provided by the buyer user after the second virtual identity information is verified.
[0112] For example, the seller user Alice owns the first digital asset, which is a digital collection with a token_id of n. Alice wants to sell this digital collection and specifies a price of 10 digital assets. The buyer user Bob owns the second digital asset, which is 100 digital assets. He sees that the user with the first virtual identity information has placed an order for the digital collection with a token_id of n on the semi-centralized trading market. He likes it very much and thinks the price is acceptable. The buyer user Bob wants to buy the digital collection and pays 10 digital assets.
[0113] On the seller's selling order, there is a first random number randomly generated by Alice, denoted as nf dc , for the first random number nf dc Convert or encrypt to generate the corresponding first virtual identity information; if the first random number nf dc Perform hash conversion to obtain the first virtual identity information, which is recorded as hash dc , the first virtual identity information hash dc After verification, the first random number is recorded as nf dc Generate the first usable proof dc On the buyer's order, there is a second random number randomly generated by Bob, denoted as nf da , for the second random number nf da Convert or encrypt to generate the corresponding second virtual identity information; if the second random number nf da Perform hash conversion to obtain the second virtual identity information, which is recorded as hash da , the second virtual identity information hash da After verification, the second random number is recorded as nf da Generate a second proof da .
[0114] Step S202: If the buy order and the sell order point to the same transaction identifier, the first usability certificate and the second usability certificate are verified respectively.
[0115] Specifically, as described in the above example, if the seller user Alice owns the first digital asset, the first digital asset is a digital collection with a number tokenId of n, Alice wants to sell the digital collection, and the specified price is 10 digital assets. The buyer user Bob owns the second digital asset, the second digital asset is 100 digital assets, and the buyer user Bob wants to purchase the digital collection and pay 10 digital assets. In the purchase order submitted by the buyer user Bob, it will be specified that the digital collection with a number tokenId of n is to be purchased, and the number of the digital collection is considered to be the transaction identifier of the transaction. In other embodiments, the transaction identifier may also be in other forms, which will not be described in detail here.
[0116] Step S203: If the verification is successful, the first digital asset and the second digital asset are traded and transferred.
[0117] Specifically, the first proof can be used dc It is used to prove that the seller has the authority to trade the first digital asset. The second proof can be used da It is used to prove that the buyer has the right to trade the second digital asset. dc and second proof of usability da If both are successfully verified, the first digital asset and the second digital asset are traded and transferred.
[0118] This application builds a semi-centralized trading market and uses zero-knowledge proof to protect the user's order privacy information and transaction process, so that the circulation of digital assets is only known to the trading users themselves, and the buyers and sellers do not know each other. The legality and matching of the order are guaranteed by verifying the zero-knowledge proof, further ensuring the security of the transaction.
[0119] In addition, since the semi-centralized trading market constructed by this application is completely decentralized, all orders are submitted directly by users and stored in the trading smart contract of the semi-centralized trading market, and continue to be matched according to the order in which the buy and sell orders are created to ensure fairness for trading users.
[0120] Before receiving the seller user's sell order and the buyer user's buy order in step S201, if the seller user wants to participate in the semi-centralized trading market, he needs to pledge the first digital asset to the transaction processing smart contract. The transaction processing smart contract receives the first pledge request triggered by the seller user, and the first pledge request includes a transaction identifier and a first virtual identity information; verifies whether the seller user has ownership of the first digital asset indicated by the transaction identifier; verifies whether the first virtual identity information has been traded; if the seller user has ownership of the first digital asset and the first virtual identity information has not been traded, the address information of the first digital asset is transferred to the first pledge address.
[0121] For example, the seller user Alice owns a digital collection with the first digital asset number tokenId n. If Alice wants to sell this digital collection, she needs to pledge this digital collection to the transaction processing smart contract. Alice first generates a first random number nf dc , then calculate the first random number nf dc hash value dc , the seller user Alice triggers the first pledge request, that is, calling the transaction processing smart contract depositDC (dcAddress, tokenId, hash dc ) method, the first pledge request includes a transaction identifier tokenId and a first virtual identity information hash dc , depositDC verifies whether the digital collection of tokenId is owned by Alice and whether it has been pledged; verifies hash dc Has it appeared in the hash list? If the digital collection with tokenId n has not been pledged, and there is no hash in the hash list dc , indicating that the first virtual identity information has not been traded, and the verification has passed; calling the transferFrom method of the digital collection smart contract will transfer the digital collection from Alice's address (dcAddress) to the first pledge address of the transaction processing smart contract. Among them, the hash list in the transaction smart contract is used to store each used virtual identity information. The virtual identity information stored in the hash list represents that the virtual identity information has been associated or traded.
[0122] After transferring the address information of the first digital asset to the first pledge address and before receiving the sell order of the seller user, it also includes: adding the first digital asset information to the first leaf node of the first Merkle tree, the first leaf node is any unoccupied leaf node of the first Merkle tree; the first digital asset information includes the first pledge address and the transaction identifier, and the first digital asset information is associated with the first virtual identity information.
[0123] Specifically, there are two Merkle trees in the digital asset management module of the user in the transaction processing smart contract, the first Merkle tree and the second Merkle tree. The first Merkle tree is used to store the selling order information of the seller user. Each leaf node of the first Merkle tree is used to store a digital asset and related digital asset information. Figure 3 The first Merkle tree shown is also a digital collection Merkle tree, Root dc is the root node value of the first Merkle tree, L1 dc and L2 dc It is the first-level parent leaf node. C1, C2, C3, and C4 are leaf nodes. The transaction processing smart contract adds Alice’s digital collection (identified by dcAddress+tokenId) to the first leaf node of the first Merkle tree, and associates the first leaf node with the first virtual identity information hash. dc For example, add Alice's digital collection to the first Merkle tree. Assume that C1 and C2 of the first Merkle tree have been occupied by other digital collections, and C3 and C4 are empty. Alice's digital collection is added to the C3 leaf node of the first Merkle tree. At this time, the root value of the first Merkle tree is Root dc , from this Merkle tree, other people cannot judge who the digital collection belongs to from the information in the leaf node, only the owner knows. In this way, the digital collection is hashed with the first virtual identity information. dc Binding, since the hash cannot be reversed, only Alice can know the hash dc The corresponding original value is nf dc , which means that only Alice can use this encrypted digital collection.
[0124] By associating the virtual identity information created by the user with the corresponding digital asset information, the corresponding digital asset information can be obtained based on the virtual identity information while ensuring the privacy information of both parties in the transaction in the transaction smart contract.
[0125] Before receiving the seller user's sell order and the buyer user's buy order in step S201, if the buyer user wants to participate in the semi-centralized trading market, the second digital asset needs to be pledged to the transaction processing smart contract. The transaction processing smart contract receives the buyer user's second pledge request, which includes the second digital asset and the second virtual identity information; verifies whether the buyer user has digital assets no less than the second digital asset; verifies whether the second virtual identity information has been traded; if the buyer user has digital assets no less than the second digital asset and the second virtual identity information has not been traded, the address information corresponding to the second digital asset owned by the buyer user is transferred to the second pledge address.
[0126] For example, the buyer user Bob has a second digital asset, which is 100 digital assets. The buyer user Bob wants to buy the digital collection and pay 10 digital assets. Then Bob needs to pledge the second digital asset of 100 digital assets to the transaction processing smart contract. Bob first generates a second random number nf da , then calculate the second random number nf da hash value da The buyer triggers the second pledge request, which calls the depositDC(daAddress, amount, hash) of the transaction processing smart contract. da ) method, depositDC verifies whether Bob has a digital asset greater than or equal to the specified amount; verifies the hash da Has it already appeared in the hash list? da The hash information of the second virtual identity appears in the hash list da If a transaction has been made, Bob cannot pledge the second digital asset. If Bob has a digital asset greater than or equal to the specified amount and the hash has not appeared in the hash list da , the verification passes, and the transferFrom method of the digital asset smart contract is called to transfer the amount of digital assets at Bob's address (daAddress) to the address of the transaction processing smart contract.
[0127] After transferring the address information corresponding to the second digital asset owned by the buyer user to the second pledge address and before receiving the buyer user's purchase order, it also includes: receiving the second digital asset information of the buyer user, adding the second digital asset information to the second leaf node of the second Merkle tree, and the second leaf node is any unoccupied leaf node of the second Merkle tree; the second digital asset information includes the second pledge address and the second digital asset, and the second digital asset information is associated with the second virtual identity information.
[0128] Specifically, the second Merkle tree is used to store the purchase order information of the buyer user, and each leaf node of the second Merkle tree is used to store a digital asset and related digital asset information. Figure 4 The second Merkle tree shown is also a digital asset Merkle tree, Root da is the root node value of the second Merkle tree, L1 da and L2 daIt is the first-layer parent leaf node. C1, C2, C3, and C4 are leaf nodes. The transaction processing smart contract adds Bob’s digital assets (identified by dcAddress+amount) to the second leaf node of the second Merkle tree, and associates the second leaf node with the second virtual identity information hash. da For example, add the digital asset owned by Bob to the second Merkle tree. Assume that C1 of the second Merkle tree has been occupied by other digital assets, and C2, C3, and C4 are empty. Add Bob's digital asset to the C2 leaf node of the second Merkle tree. At this time, the root value of the second Merkle tree is Root da From this Merkle tree, other people cannot tell who the digital asset belongs to from the information in the leaf node. Only the owner knows. In this way, the digital asset is hashed with the second virtual identity information. da Binding, since the hash cannot be reversed, only Bob can know the hash da The corresponding original value is nf da , which means that only Bob can spend this digital asset.
[0129] Before generating a zero-knowledge proof for the first digital asset based on the first random number, it also includes: verifying whether the root value of the first Merkle tree can be calculated through the path value of the first leaf node, the value of the brother node on the path of the first leaf node, the first random number, the depth of the first Merkle tree and the content of the first leaf node. The first virtual identity information is verified by the first random number provided by the seller user; if the verification is successful, the first usable proof is generated through zero-knowledge proof based on the first secret information and the first public information; the first secret information includes the path value of the first leaf node provided by the seller user, the value of the brother node on the path of the first leaf node and the first random number, and the first public information includes the depth of the first Merkle tree and the content of the first leaf node.
[0130] Specifically, generating a zero-knowledge proof requires secret parameters w and public parameters x dc , the secret parameter is the path address_bits = (1, 0) of the C3 leaf of the digital collection Merkle tree, such as Figure 3 The path of the first Merkle tree C3 leaf shown starts from the root node and goes right to L2 dc , and then go left to C3 leaf, where the right is 1 and the left is 0; the sibling node value path on the path = (C4, L1 dc ), on the path to C3 leaf, C4 is the sibling node of C3, L1 dc For L2 dc Brother node; Alice generates a random number nf when staking dc , the required common parameter xdc Contains the known tree depth depth = 2, Merkle tree root root dc and the contents of C3 leaf. Prover will verify the Merkle tree root dc Can it be calculated from address_bits, path, depth and the contents of the C3 leaf?
[0131] Similarly, before generating a zero-knowledge proof for the second digital asset based on the second random number, it also includes: verifying whether the root value of the second Merkle tree can be calculated through the path value of the second leaf node, the value of the sibling node on the path of the second leaf node, the second random number, the depth of the second Merkle tree and the content of the second leaf node. The second virtual identity information is verified through the second random number provided by the buyer user; if the verification is successful, the second usability certificate is generated through zero-knowledge proof based on the second secret information and the second public information; the second secret information includes the path value of the second leaf node, the value of the sibling node on the path of the second leaf node and the second random number, and the second public information includes the depth of the second Merkle tree and the content of the second leaf node.
[0132] Specifically, generating a proof requires secret parameters w and public parameters x da The secret parameter is the path address_bits=(0,1) of the C2 leaf of the second Merkle tree, and the sibling node value path=(C1, L2 da ) and Bob generates a random number nf when staking da , the required common parameter x da Contains the known tree depth depth = 2, Merkle tree root root da and the contents of the C2 leaf. Prover verifies the Merkle tree root da Can it be calculated from address_bits, path, depth and the contents of the C2 leaf?
[0133] The sell order also includes a third virtual identity information, which is obtained based on a third random number randomly generated by the seller user; the buy order also includes a fourth virtual identity information, which is obtained based on a fourth random number randomly generated by the buyer user; the first digital asset information is associated with the fourth virtual identity information and added to the third leaf node of the first Merkel tree, and the third leaf node is any unoccupied leaf node of the first Merkel tree; the second digital asset information is associated with the third virtual identity information and added to the fourth leaf node of the second Merkel tree, and the fourth leaf node is any unoccupied leaf node of the second Merkel tree.
[0134] Specifically, if the transaction is successful, the seller user needs to generate a third random number to obtain the third virtual identity information, and associate the second digital asset obtained from the buyer with the third virtual identity information, so that only the seller user can use the second digital asset. Similarly, if the transaction is successful, the buyer user needs to generate a fourth random number to obtain the fourth virtual identity information, and associate the first digital asset obtained from the seller with the fourth virtual identity information, so that only the buyer user can use the first digital asset.
[0135] Using the above example to illustrate, Alice generates a new random number Then calculate Hash value The purpose of generating this random number and hash value is that if Alice successfully sells her digital collection, her counterparty Bob will pay the corresponding amount of digital assets to a leaf node on a new digital asset Merkle tree and associate this hash value. Finally, only Alice can spend this digital asset. Then, Alice finally calls the sellDc(dcAddress, tokenId, hash) of the transaction processing smart contract. dc , amount sell , proof dc , x dc ) method, the sell order is stored in the sell order list of the transaction processing smart contract waiting to be traded, but no one can see who placed the sell order.
[0136] Bob then generates a new random number Then calculate Hash value The purpose of generating this random number and hash value is that if Bob successfully buys the digital collection, the counterparty Alice will pay the corresponding digital collection to a leaf node on the new digital collection Merkle tree and associate this hash value. Ultimately, only Bob can use this digital collection.
[0137] If the second digital asset is greater than the transaction amount corresponding to the transaction identifier; the purchase order also includes the fifth virtual identity information and the transaction amount, and the fifth virtual identity information is obtained based on the fifth random number randomly generated by the buyer user; the third digital asset information is added to the fifth leaf node of the second Merkle tree and associated with the fifth virtual identity information, and the fifth leaf node is any unoccupied leaf node of the second Merkle tree; the third digital asset information includes the difference information between the second digital asset and the transaction amount and the second pledge address.
[0138] Specifically, when the second digital asset is greater than the transaction amount, the buyer user has remaining digital assets after the transaction, which are recorded as the third digital asset. Then the third digital asset needs to be stored in a leaf node on a new digital asset Merkle tree for the buyer to use in the next transaction. Therefore, the buyer user needs to randomly generate a fifth random number, convert the fifth random number to obtain the fifth virtual identity information, add the third digital asset information to the fifth leaf node of the second Merkle tree and associate it with the fifth virtual identity information.
[0139] For example, Bob generates a new random number Then calculate Hash value The purpose of generating this random number and hash value is that the amount of digital assets that Bob previously pledged may be greater than the amount of digital assets that Bob needs to spend to purchase digital collections, so the remaining digital assets must also be added to a leaf node on a new digital asset Merkle tree and associated with this hash value. In the end, only Bob can spend this digital asset. Then, Bob finally calls the buyDc(dcAddress, tokenId, hash) function of the transaction processing smart contract. dc , amount sell , proof dc , x da ) method to store the buy order in the buy order list of the transaction processing smart contract.
[0140] Since there is an order to sell the digital asset in the sell order list in the transaction smart contract and the price is the same, the transaction processing smart contract's match verification method verify(dcAddress, tokenId, hash dc , amount sell , proof dc , x dc , hash da , proof dc , x da ).
[0141] Before the first digital asset and the second digital asset are traded and transferred, the method further includes: verifying whether the fourth virtual identity information, the third virtual identity information and the fifth virtual identity information have been traded; if none of them have been traded, verifying that the second digital asset is greater than or equal to the transaction amount.
[0142] Specifically, the matching verification and processing of sell orders and buy orders is divided into the following three verification processes:
[0143] (1) According to the principle of zero-knowledge proof system, the matching verification method of transaction processing smart contract verifies {proof dc , x dc} and {proof dc , x da} for verification. If the verification is successful, it means that the seller has the authority to sell the C3 digital collection on the digital collection Merkle tree, and the buyer has the authority to spend the C2 digital asset on the digital asset Merkle tree.
[0144] (2) Verify the sell order Has it appeared in the hash list? and Whether it has already appeared in the hash list.
[0145] (3) Verify whether the amount of C2 digital assets in the Merkle tree of the digital assets used for the purchase order is greater than or equal to amount sell .
[0146] Only if all the above checks are passed can the order be processed. Otherwise, the transaction is terminated and the order remains in the sell order and buy order list. If all the checks are passed, the transaction processing smart contract will hash dc and hash da Store in the hash list, indicating that the two hashes, i.e. the corresponding Merkle tree leaf nodes, can no longer be used. Then add this digital collection (identified by dcAddress+tokenId) to the digital collection Merkle tree, becoming a new leaf node C4 of the Merkle tree, and associate the hash value And update the value of the digital collection Merkle tree response node, such as Figure 5 The updated Merkle tree of the digital collection is shown, and the balance amount of the digital asset used to buy the digital collection is calculated. left =amount-amount sell , put two digital assets (daAddress+amount sell ) and (daAddress+amount left ) are added to the digital asset Merkle tree, becoming two new leaf nodes C3 and C4 of the Merkle tree, and are associated with hash values respectively. and like Figure 6 The updated Merkle tree of digital assets is shown below. In addition, if Bob wants to sell the digital collection after obtaining it, he still creates a sell order through the above steps and waits for the buyer.
[0147] If the buyer user wants to extract the first digital asset from the semi-centralized trading market after obtaining the first digital asset, then after adding it to the third leaf node of the first Merkle tree, it also includes: calculating a third usability certificate according to the path value of the third leaf node, the sibling node value on the path of the third leaf node, the sixth random number, the depth of the first Merkle tree and the content of the third leaf node, where the sixth random number is randomly generated by the buyer user; verifying the third usability certificate, and if the verification is passed, transferring the address information corresponding to the first digital asset to the buyer user's address to complete the buyer user's extraction of the first digital asset.
[0148] For example, if the buyer user Bob no longer wants to sell the digital collection, he can withdraw it from the trading platform. Bob needs to call the zero-knowledge proof system prover to create a proof that the digital collection can be used. According to the previous introduction to zero-knowledge proof, generating proof requires secret parameter w and public parameter The secret parameter is the path address_bits=(1,1) of the C4 leaf of the digital collection Merkle tree, and the sibling node value path=(C3, L1 dc ) and Bob generates a random number when purchasing Required public parameters Contains the known tree depth depth = 2, Merkle tree root and the contents of leaf C3. Prover verifies the Merkle tree root Can it be calculated from address_bits, path, depth and the content of C3 leaf to verify the hash value? Whether it corresponds to the original value Then, the digital collection usability certificate is generated based on the verification calculation process.
[0149] Bob finally calls the transaction processing smart contract withdrawDc(dcAddress, tokenId, ) method, transaction processing smart contract verification proof If the verification fails, the withdrawal is terminated. If the verification passes, the transferFrom method of the digital collection smart contract is called to transfer the digital collection from the address of the transaction processing smart contract to Bob's address. Store in hash list and the extraction is completed.
[0150] Similarly, after obtaining the second digital asset, if the seller user wants to extract the second digital asset from the semi-centralized trading market, then after adding it to the fourth leaf node of the second Merkle tree, it also includes: calculating a fourth usability certificate according to the path value of the fourth leaf node, the sibling node value on the path of the fourth leaf node, the seventh random number, the depth of the second Merkle tree and the content of the fourth leaf node, where the seventh random number is randomly generated by the seller user; verifying the fourth usability certificate, and if the verification is passed, transferring the address information corresponding to the second digital asset to the seller user's address to complete the seller user's extraction of the second digital asset.
[0151] For example, Alice needs to call the zero-knowledge proof system prover to create a digital asset usable proof According to the previous introduction to zero-knowledge proof, generating proof requires secret parameter w and public parameter The secret parameter is the path address_bits=(1,0) of the C3 leaf of the digital asset Merkle tree, and the sibling node value path=(C4, L1 da ) and Alice generates a random number when creating a sell order Required public parameters Contains the known tree depth depth = 2, Merkle tree root and the contents of leaf C3. Prover verifies the Merkle tree root Can it be calculated from address_bits, path, depth and the content of C3 leaf to verify the hash value? Whether it corresponds to the original value Then, a proof of usability of digital assets is generated based on the verification calculation process.
[0152] Alice finally calls the transaction processing smart contract withdrawDa(dcAddress, amount sell , ) method, transaction processing smart contract verification proof If the verification fails, the withdrawal is terminated. If the verification passes, the transferFrom method of the digital asset smart contract is called to add the amount to the address of the transaction processing smart contract. sell The amount of digital assets is transferred to Alice's address. Store in hash list and the extraction is completed.
[0153] like Figure 7 As shown, the present application provides a digital transaction device 700 for protecting user privacy, including:
[0154] The receiving module 701 is used to receive a selling order of a seller user and a buying order of a buyer user; the selling order includes a transaction identifier for indicating a transaction subject, a first virtual identity information and a first usability certificate, and the buying order includes a transaction identifier for indicating a transaction subject, a second virtual identity information and a second usability certificate; the first virtual identity information is obtained by a first random number randomly generated by the seller user; the second virtual identity information is obtained by a second random number randomly generated by the buyer user; the first usability certificate is a zero-knowledge proof generated for a first digital asset based on the first random number provided by the seller user after the first virtual identity information is verified; the second usability certificate is a zero-knowledge proof generated for a second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified; the first digital asset represents a transaction subject owned by the seller user, and the second digital asset represents a transaction subject owned by the buyer user;
[0155] A verification module 702, configured to verify the first usability certificate and the second usability certificate respectively if the buy order and the sell order point to the same transaction identifier;
[0156] The processing module 703 is used to perform a transaction transfer on the first digital asset and the second digital asset if the verification is passed.
[0157] This application builds a semi-centralized trading market and uses zero-knowledge proof to protect the user's order privacy information and transaction process, so that the circulation of digital assets is only known to the trading users themselves, and the buyers and sellers do not know each other. The legality and matching of the order are guaranteed by verifying the zero-knowledge proof, further ensuring the security of the transaction.
[0158] In addition, since the semi-centralized trading market constructed by this application is completely decentralized, all orders are submitted directly by users and stored in the trading smart contract of the semi-centralized trading market, and continue to be matched according to the order in which the buy and sell orders are created to ensure fairness for trading users.
[0159] Optionally, the processing module 703 is specifically configured to:
[0160] Adding the first digital asset information to the first leaf node of the first Merkle tree, where the first leaf node is any unoccupied leaf node of the first Merkle tree; the first digital asset information includes the first pledge address and the transaction identifier, and the first digital asset information is associated with the first virtual identity information;
[0161] After transferring the address information corresponding to the second digital asset owned by the buyer user to the second pledge address and before receiving the buyer user's purchase order, the method further includes:
[0162] Receive the second digital asset information of the buyer user, and add the second digital asset information to the second leaf node of the second Merkle tree, where the second leaf node is any unoccupied leaf node of the second Merkle tree; the second digital asset information includes the second pledge address and the second digital asset, and the second digital asset information is associated with the second virtual identity information.
[0163] By associating the virtual identity information created by the user with the corresponding digital asset information, the corresponding digital asset information can be obtained based on the virtual identity information while ensuring the privacy information of both parties in the transaction in the transaction smart contract.
[0164] Optionally, the verification module 702 is specifically used for:
[0165] Verify whether the root value of the first Merkle tree can be calculated by the path value of the first leaf node, the sibling node value on the path of the first leaf node, the first random number, the depth of the first Merkle tree, and the content of the first leaf node;
[0166] Before generating a zero-knowledge proof for the second digital asset based on the second random number, the method further includes:
[0167] Verify whether the root value of the second Merkle tree can be calculated by the path value of the second leaf node, the sibling node value on the path of the second leaf node, the second random number, the depth of the second Merkle tree and the content of the second leaf node.
[0168] Optionally, the verification module 702 is specifically used for:
[0169] Verifying the first virtual identity information by using the first random number provided by the seller user;
[0170] If the verification is successful, the first usability certificate is generated through zero-knowledge proof based on the first secret information and the first public information; the first secret information includes the path value of the first leaf node, the sibling node value on the path of the first leaf node and the first random number provided by the seller user, and the first public information includes the depth of the first Merkle tree and the content of the first leaf node;
[0171] The second usability proof is a zero-knowledge proof generated for the second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified, and includes:
[0172] Verifying the second virtual identity information by using the second random number provided by the buyer user;
[0173] If the verification passes, the second usable proof is generated through zero-knowledge proof based on the second secret information and the second public information; the second secret information includes the path value of the second leaf node, the sibling node value on the path of the second leaf node and the second random number, and the second public information includes the depth of the second Merkle tree and the content of the second leaf node.
[0174] Optionally, the processing module 703 is specifically configured to:
[0175] The selling order further includes third virtual identity information, which is obtained based on a third random number randomly generated by the seller user; the buying order further includes fourth virtual identity information, which is obtained based on a fourth random number randomly generated by the buyer user;
[0176] The transaction transfer of the first digital asset and the second digital asset includes:
[0177] Associating the first digital asset information with the fourth virtual identity information, and adding the information to a third leaf node of the first Merkle tree, where the third leaf node is any unoccupied leaf node of the first Merkle tree;
[0178] The second digital asset information is associated with the third virtual identity information, and added to the fourth leaf node of the second Merkle tree, where the fourth leaf node is any unoccupied leaf node of the second Merkle tree.
[0179] Optionally, the processing module 703 is specifically configured to:
[0180] The second digital asset is greater than the transaction amount corresponding to the transaction identifier;
[0181] The purchase order further includes fifth virtual identity information and the transaction amount, wherein the fifth virtual identity information is obtained based on a fifth random number randomly generated by the buyer user;
[0182] The third digital asset information is added to the fifth leaf node of the second Merkle tree and associated with the fifth virtual identity information, where the fifth leaf node is any unoccupied leaf node of the second Merkle tree; the third digital asset information includes the difference between the second digital asset and the transaction amount and the second pledge address.
[0183] Optionally, the processing module 703 is specifically configured to:
[0184] A third usability proof is calculated based on the path value of the third leaf node, the sibling node value on the path of the third leaf node, a sixth random number, the depth of the first Merkle tree and the content of the third leaf node, wherein the sixth random number is randomly generated by the buyer user;
[0185] The third usability certificate is verified, and if the verification is passed, the address information corresponding to the first digital asset is transferred to the address of the buyer user to complete the withdrawal of the first digital asset by the buyer user.
[0186] Optionally, the processing module 703 is specifically configured to:
[0187] A fourth usability proof is calculated based on the path value of the fourth leaf node, the sibling node value on the path of the fourth leaf node, a seventh random number, the depth of the second Merkle tree, and the content of the fourth leaf node, wherein the seventh random number is randomly generated by the seller user;
[0188] The fourth usable proof is verified, and if the verification is passed, the address information corresponding to the second digital asset is transferred to the address of the seller user to complete the withdrawal of the second digital asset by the seller user.
[0189] Optionally, the verification module 702 is specifically used for:
[0190] Verifying whether the fourth virtual identity information, the third virtual identity information, and the fifth virtual identity information have been traded;
[0191] If no transaction has been conducted, verify that the second digital asset is greater than or equal to the transaction amount.
[0192] Based on the same technical concept, the embodiment of the present application provides a computer device, such as Figure 8 As shown, it includes at least one processor 801 and a memory 802 connected to the at least one processor. The specific connection medium between the processor 801 and the memory 802 is not limited in the embodiment of the present application. Figure 8 For example, the processor 801 and the memory 802 are connected via a bus. The bus can be divided into an address bus, a data bus, a control bus, etc.
[0193] In an embodiment of the present application, the memory 802 stores instructions that can be executed by at least one processor 801. The at least one processor 801 can execute the steps of the above-mentioned digital transaction method for protecting user privacy by executing the instructions stored in the memory 802.
[0194] Among them, the processor 801 is the control center of the computer device, which can use various interfaces and lines to connect various parts of the computer device, and trade the buy orders and sell orders matched in the transaction smart contract by running or executing instructions stored in the memory 802 and calling the data stored in the memory 802. Optionally, the processor 801 may include one or more processing units, and the processor 801 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 801. In some embodiments, the processor 801 and the memory 802 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.
[0195] Processor 801 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware processor for execution, or can be executed by a combination of hardware and software modules in the processor.
[0196] The memory 802 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 802 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 802 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer device, but is not limited thereto. The memory 802 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0197] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program that can be executed by a computer device. When the program runs on the computer device, the computer device executes the steps of the above-mentioned digital transaction method for protecting user privacy.
[0198] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0199] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0200] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0201] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0202] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A digital transaction method for protecting user privacy, characterized in that: Applied to semi-centralized trading markets, including: Receive a selling order from a seller user and a buying order from a buyer user; the selling order includes a transaction identifier for indicating a transaction subject, a first virtual identity information, and a first usability certificate, and the buying order includes a transaction identifier for indicating a transaction subject, a second virtual identity information, and a second usability certificate; the first virtual identity information is obtained by a first random number randomly generated by the seller user; the second virtual identity information is obtained by a second random number randomly generated by the buyer user; the first usability certificate is a zero-knowledge proof generated for a first digital asset based on the first random number provided by the seller user after the first virtual identity information is verified; the second usability certificate is a zero-knowledge proof generated for a second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified; the first digital asset represents a transaction subject owned by the seller user, and the second digital asset represents a transaction subject owned by the buyer user; If the buy order and the sell order point to the same transaction identifier, verify the first usability certificate and the second usability certificate respectively; If the verification is successful, the first digital asset and the second digital asset are traded and transferred.
2. The method according to claim 1, characterized in that Before receiving the selling order of the seller user and the buying order of the buyer user, the method further includes: Receiving a first pledge request triggered by the seller user, wherein the first pledge request includes a transaction identifier and first virtual identity information; Verifying whether the seller user has ownership of the first digital asset indicated by the transaction identifier; Verifying whether the first virtual identity information has been used for transactions; If the seller user has ownership of the first digital asset and the first virtual identity information has not been traded, the address information of the first digital asset is transferred to the first pledge address.
3. The method according to claim 1, characterized in that Before receiving the selling order of the seller user and the buying order of the buyer user, the method further includes: Receiving a second pledge request from the buyer user, wherein the second pledge request includes a second digital asset and second virtual identity information; Verifying whether the buyer user has digital assets no less than the second digital asset; Verifying whether the second virtual identity information has been used for transactions; If the buyer user has digital assets that are no less than the second digital asset and the second virtual identity information has not been traded, the address information corresponding to the second digital asset owned by the buyer user is transferred to the second pledge address.
4. The method according to claim 2 or 3, characterized in that After transferring the address information of the first digital asset to the first pledge address and before receiving the selling order of the seller user, the method further includes: Adding the first digital asset information to the first leaf node of the first Merkle tree, where the first leaf node is any unoccupied leaf node of the first Merkle tree; the first digital asset information includes the first pledge address and the transaction identifier, and the first digital asset information is associated with the first virtual identity information; After transferring the address information corresponding to the second digital asset owned by the buyer user to the second pledge address and before receiving the buyer user's purchase order, the method further includes: Receive the second digital asset information of the buyer user, and add the second digital asset information to the second leaf node of the second Merkle tree, where the second leaf node is any unoccupied leaf node of the second Merkle tree; the second digital asset information includes the second pledge address and the second digital asset, and the second digital asset information is associated with the second virtual identity information.
5. The method according to claim 4, characterized in that Before generating a zero-knowledge proof for the first digital asset based on the first random number, the method further includes: Verify whether the root value of the first Merkle tree can be calculated by the path value of the first leaf node, the sibling node value on the path of the first leaf node, the first random number, the depth of the first Merkle tree, and the content of the first leaf node; Before generating a zero-knowledge proof for the second digital asset based on the second random number, the method further includes: Verify whether the root value of the second Merkle tree can be calculated by the path value of the second leaf node, the sibling node value on the path of the second leaf node, the second random number, the depth of the second Merkle tree and the content of the second leaf node.
6. The method according to claim 4, characterized in that The first usability proof is a zero-knowledge proof generated for the first digital asset based on the first random number provided by the seller user after the first virtual identity information is verified, and includes: Verifying the first virtual identity information by using the first random number provided by the seller user; If the verification is successful, the first usability certificate is generated through zero-knowledge proof based on the first secret information and the first public information; the first secret information includes the path value of the first leaf node, the sibling node value on the path of the first leaf node and the first random number provided by the seller user, and the first public information includes the depth of the first Merkle tree and the content of the first leaf node; The second usability proof is a zero-knowledge proof generated for the second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified, and includes: Verifying the second virtual identity information by using the second random number provided by the buyer user; If the verification passes, the second usable proof is generated through zero-knowledge proof based on the second secret information and the second public information; the second secret information includes the path value of the second leaf node, the sibling node value on the path of the second leaf node and the second random number, and the second public information includes the depth of the second Merkle tree and the content of the second leaf node.
7. The method according to claim 4, characterized in that The selling order further includes third virtual identity information, which is obtained based on a third random number randomly generated by the seller user; the buying order further includes fourth virtual identity information, which is obtained based on a fourth random number randomly generated by the buyer user; The transaction transfer of the first digital asset and the second digital asset includes: Associating the first digital asset information with the fourth virtual identity information, and adding the information to a third leaf node of the first Merkle tree, where the third leaf node is any unoccupied leaf node of the first Merkle tree; The second digital asset information is associated with the third virtual identity information, and added to the fourth leaf node of the second Merkle tree, where the fourth leaf node is any unoccupied leaf node of the second Merkle tree.
8. The method according to claim 7, characterized in that The second digital asset is greater than the transaction amount corresponding to the transaction identifier; The purchase order further includes fifth virtual identity information and the transaction amount, wherein the fifth virtual identity information is obtained based on a fifth random number randomly generated by the buyer user; The third digital asset information is added to the fifth leaf node of the second Merkle tree and associated with the fifth virtual identity information, where the fifth leaf node is any unoccupied leaf node of the second Merkle tree; the third digital asset information includes the difference between the second digital asset and the transaction amount and the second pledge address.
9. The method according to claim 7, characterized in that After adding to the third leaf node of the first Merkle tree, the method further includes: A third usability proof is calculated based on the path value of the third leaf node, the sibling node value on the path of the third leaf node, a sixth random number, the depth of the first Merkle tree and the content of the third leaf node, wherein the sixth random number is randomly generated by the buyer user; The third usability certificate is verified, and if the verification is passed, the address information corresponding to the first digital asset is transferred to the address of the buyer user to complete the withdrawal of the first digital asset by the buyer user.
10. The method according to claim 7, characterized in that After adding to the fourth leaf node of the second Merkle tree, the method further includes: A fourth usability proof is calculated based on the path value of the fourth leaf node, the sibling node value on the path of the fourth leaf node, a seventh random number, the depth of the second Merkle tree, and the content of the fourth leaf node, wherein the seventh random number is randomly generated by the seller user; The fourth usable proof is verified, and if the verification is passed, the address information corresponding to the second digital asset is transferred to the address of the seller user to complete the withdrawal of the second digital asset by the seller user.
11. The method according to claim 8, characterized in that Before the transaction transfer of the first digital asset and the second digital asset, the method further includes: Verifying whether the fourth virtual identity information, the third virtual identity information, and the fifth virtual identity information have been traded; If no transaction has been conducted, verify that the second digital asset is greater than or equal to the transaction amount.
12. A digital transaction device for protecting user privacy, characterized in that: include: A receiving module, used to receive a selling order of a seller user and a buying order of a buyer user; the selling order includes a transaction identifier for indicating a transaction subject, first virtual identity information and a first usability certificate, and the buying order includes a transaction identifier for indicating a transaction subject, second virtual identity information and a second usability certificate; the first virtual identity information is obtained by a first random number randomly generated by the seller user; The second virtual identity information is obtained by a second random number randomly generated by the buyer user; The first usability proof is a zero-knowledge proof generated for the first digital asset based on the first random number provided by the seller user after the first virtual identity information is verified; The second usability proof is a zero-knowledge proof generated for the second digital asset based on the second random number provided by the buyer user after the second virtual identity information is verified; the first digital asset represents the transaction subject of the seller user, and the second digital asset represents the transaction subject of the buyer user; A verification module, configured to verify the first usability certificate and the second usability certificate respectively if the buy order and the sell order point to the same transaction identifier; The processing module is used to perform a transaction transfer on the first digital asset and the second digital asset if the verification is passed.
13. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of any one of the methods of claims 1 to 11 are implemented.
14. A computer-readable storage medium, characterized in that: It stores a computer program executable by a computer device. When the program is run on the computer device, the computer device executes the steps of any method described in claims 1 to 11.
