Data processing method and device, computer readable storage medium and electronic equipment
By performing security verification of both blockchains and the use of hash time lock contracts in cross-blockchain transactions, the problem of low reliability of value transfer between blockchains in micro-payment systems is solved, and higher transaction security and transparency are achieved.
Patent Information
- Application Number
- CN202411696590.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-25
AI Technical Summary
When the existing micropayment system transfers value between different blockchain networks, there is a problem of low reliability and no effective solution has been found.
By receiving user information from both blockchains, generating and verifying zero-knowledge proofs, ensuring the credibility of the blockchain. Then, a hash time lock contract is created on the first blockchain, and the secure locking and transfer of assets is achieved based on the target hash value and transaction data.
Improve the reliability of cross-blockchain transactions, avoid the situation of double payment, and ensure the security and transparency of transactions through multiple authentication and the use of hash time lock contracts.
Smart Images

Figure CN119579314A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain, and in particular to a data processing method, device, computer-readable storage medium and electronic device. Background Art
[0002] With the continuous development of blockchain technology and the expansion of its application scope, micropayments (i.e. small payments) are becoming increasingly important in various digital services. Micropayments allow users to make transactions of extremely small amounts, which has broad application potential in scenarios such as content payment, communication between IoT devices, decentralized applications (DApps), and in-game purchases in online games. In existing micropayment systems, especially when transferring value between different blockchain networks, assets are transferred directly on different chains, resulting in low reliability.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] Embodiments of the present invention provide a data processing method, device, computer-readable storage medium, and electronic device to at least solve the technical problem of low reliability of cross-blockchain transactions in related technologies.
[0005] According to one aspect of an embodiment of the present invention, a data processing method is provided, including: receiving user information of a first user sent by a first blockchain, and receiving user information of a second user sent by a second blockchain, wherein the first user is to pay assets to the second user, the first blockchain is the blockchain where the assets of the first user are located, and the second blockchain is the blockchain where the assets of the second user are located; generating a first zero-knowledge proof based on the user information of the first user, generating a second zero-knowledge proof based on the user information of the second user, and verifying the credibility of the first blockchain based on the first zero-knowledge proof, and verifying the credibility of the second blockchain based on the second zero-knowledge proof; when the first blockchain and the second blockchain are verified, creating a hash time lock contract on the first blockchain, wherein the hash time lock contract is at least used to lock the assets of the first user; generating a target hash value based on the target value and the transaction data on the first blockchain, and receiving the first hash value sent by the second blockchain, and when the target hash value is the same as the first hash value, sending target information to the first blockchain, wherein the target information is used to instruct the first blockchain to transfer the locked assets in the first blockchain to the second blockchain.
[0006] Furthermore, the data processing method also includes: sending the first zero-knowledge proof and the second zero-knowledge proof to the relay chain, wherein the relay chain is used to verify the credibility of the first blockchain based on the first zero-knowledge proof, and to verify the credibility of the second blockchain based on the second zero-knowledge proof; receiving the verification results fed back by the relay chain, and determining whether the first blockchain and the second blockchain have passed the verification based on the verification results.
[0007] Furthermore, the data processing method also includes: before receiving the first hash value sent by the second blockchain, generating a random number based on a pseudo-random number generator, and determining the random number as a target value; and sending the target value to the second user via an off-chain method.
[0008] Furthermore, the hash time lock contract includes a first condition, which represents that the asset is unlocked when the hash value sent by the second blockchain is the same as the target hash value. The data processing method also includes: after sending the target information to the first blockchain, the first blockchain transfers the locked assets in the first blockchain to the relay chain when receiving the target information, wherein a hash time lock contract is created on the relay chain; receiving the second hash value sent by the second blockchain through the relay chain, and unlocking the locked assets in the relay chain when the second hash value is the same as the target hash value, and transferring the unlocked assets to the second blockchain.
[0009] Furthermore, the data processing method also includes: after transferring the unlocked assets to the second blockchain, receiving the transaction status change data sent by the first blockchain to obtain the first data; receiving the transaction status change data sent by the second blockchain to obtain the second data; uploading the first data, the second data and the transaction data to the relay chain, and publishing the first data, the second data and the transaction data in the relay chain.
[0010] Furthermore, the hash time lock contract also includes a second condition, which represents that the locked assets are not transferred to the second blockchain within a preset time range, and the assets are unlocked when the hash value generated by the first blockchain is the same as the target hash value, wherein the data processing method also includes: after sending the target information to the first blockchain, if the relay chain does not transfer the locked assets to the second blockchain within the preset time range, if a third hash value sent by the first blockchain is received, then compare whether the third hash value and the target hash value are the same; when the third hash value is the same as the target hash value, the locked assets in the relay chain are unlocked through the relay chain, and the unlocked assets are transferred to the first blockchain.
[0011] Furthermore, the data processing method also includes: after verifying the credibility of the first blockchain based on the first zero-knowledge proof and verifying the credibility of the second blockchain based on the second zero-knowledge proof, if the verification of the first blockchain and the second blockchain fails, prohibiting the creation of a hash time lock contract on the first blockchain.
[0012] According to another aspect of an embodiment of the present invention, a data processing device is also provided, including: a first receiving module, used to receive user information of a first user sent by a first blockchain, and to receive user information of a second user sent by a second blockchain, wherein the first user is to pay assets to the second user, the first blockchain is the blockchain where the assets of the first user are located, and the second blockchain is the blockchain where the assets of the second user are located; a verification module, used to generate a first zero-knowledge proof based on the user information of the first user, generate a second zero-knowledge proof based on the user information of the second user, and verify the credibility of the first blockchain based on the first zero-knowledge proof, and verify the credibility of the second blockchain based on the second zero-knowledge proof; a creation module, used to create a hash time lock contract on the first blockchain when the first blockchain and the second blockchain are verified, wherein the hash time lock contract is at least used to lock the assets of the first user; a first sending module, used to generate a target hash value based on the target value and the transaction data on the first blockchain, and receive the first hash value sent by the second blockchain, and when the target hash value is the same as the first hash value, send target information to the first blockchain, wherein the target information is used to instruct the first blockchain to transfer the locked assets in the first blockchain to the second blockchain.
[0013] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned data processing method when running.
[0014] According to another aspect of an embodiment of the present invention, an electronic device is also provided, which includes one or more processors; a memory for storing one or more programs, so that when the one or more programs are executed by the one or more processors, the one or more processors are implemented to run the programs, wherein the programs are configured to execute the above-mentioned data processing method when running.
[0015] In an embodiment of the present invention, a method of performing security verification on both blockchains during a cross-blockchain transaction is adopted, by receiving the user information of the first user sent by the first blockchain, and receiving the user information of the second user sent by the second blockchain, then generating a first zero-knowledge proof based on the user information of the first user, generating a second zero-knowledge proof based on the user information of the second user, and verifying the credibility of the first blockchain based on the first zero-knowledge proof, and verifying the credibility of the second blockchain based on the second zero-knowledge proof, and then creating a hash time lock contract on the first blockchain when the first blockchain and the second blockchain are verified, thereby generating a target hash value based on the target value and the transaction data on the first blockchain, and receiving the first hash value sent by the second blockchain, and sending the target information to the first blockchain when the target hash value is the same as the first hash value. Among them, the first user is to pay the asset to the second user, the first blockchain is the blockchain where the asset of the first user is located, the second blockchain is the blockchain where the asset of the second user is located, the hash time lock contract is at least used to lock the asset of the first user, and the target information is used to instruct the first blockchain to transfer the locked asset in the first blockchain to the second blockchain.
[0016] In the above process, the credibility of the first blockchain is verified based on the first zero-knowledge proof, and the credibility of the second blockchain is verified based on the second zero-knowledge proof, so as to realize the identity authentication of the first blockchain and the second blockchain. By creating a hash time lock contract on the first blockchain when the first blockchain and the second blockchain are verified, the assets to be transferred by the first user are securely locked, and the occurrence of double payment is avoided. By instructing the first blockchain to transfer the locked assets in the first blockchain to the second blockchain when the first hash value sent by the second blockchain is the same as the target hash value, the second blockchain is verified twice, and the first user is allowed to pay assets to the second user when the secondary verification is passed, thereby effectively improving the reliability of cross-blockchain transactions.
[0017] It can be seen that the solution provided in this application achieves the purpose of performing security verification on the blockchains of both parties during cross-blockchain transactions, thereby achieving the technical effect of improving the reliability of cross-blockchain transactions, and further solving the technical problem of low reliability of cross-blockchain transactions in related technologies. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0019] Figure 1 is a flow chart of an optional data processing method according to an embodiment of the present invention;
[0020] Figure 2 is a schematic diagram of an optional target processing system according to an embodiment of the present invention;
[0021] Figure 3 is a schematic diagram of an optional data processing device according to an embodiment of the present invention;
[0022] Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards in the relevant regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0026] Example 1
[0027] According to an embodiment of the present invention, an embodiment of a data processing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0028] Figure 1 is a flow chart of an optional data processing method according to an embodiment of the present invention. Figure 1 As shown, the method is applied to a target processing system and comprises the following steps:
[0029] Step S101, receiving user information of a first user sent by a first blockchain, and receiving user information of a second user sent by a second blockchain, wherein the first user has assets to be paid to the second user, the first blockchain is the blockchain where the assets of the first user are located, and the second blockchain is the blockchain where the assets of the second user are located.
[0030] Optional, Figure 2 is a schematic diagram of an optional target processing system according to an embodiment of the present invention. Figure 2 As shown, the target processing system may include a verification module, a generation module, a chain module, and a rollback module. The target processing system may execute the data processing method in this embodiment based on the verification module, the generation module, the chain module, and the rollback module.
[0031] Optionally, the data processing method in this embodiment is applied to online payment scenarios, specifically, to scenarios where a user pays another user, and the first user is to pay assets to the second user, that is, the first user is equivalent to the asset payer, and the second user is equivalent to the asset recipient. The first user and the second user can be individual users, merchants, or other types of users.
[0032] Optional, such as Figure 2 As shown, when an online payment transaction is generated between a first user and a second user, the first user can send the user information of the first user to the target processing system through the first blockchain, and the second user can send the user information of the second user to the target processing system through the second blockchain. Optionally, the user information of the first user is stored on the first blockchain, and the user information of the second user is stored on the second blockchain. The user information at least includes the transaction number of the payment transaction corresponding to the user (i.e., the aforementioned first user or second user), the user's identity information (such as a user unique identifier, etc.) and the user's transaction identifier, and the transaction identifier includes the asset payer identifier and the asset receiver identifier.
[0033] Optionally, the target processing system may receive user information of the first user sent by the first blockchain, and receive user information of the second user sent by the second blockchain, and match the first user and the second user belonging to the same payment transaction according to the transaction number in the user information.
[0034] Step S102: Generate a first zero-knowledge proof based on the user information of the first user, generate a second zero-knowledge proof based on the user information of the second user, and verify the credibility of the first blockchain based on the first zero-knowledge proof, and verify the credibility of the second blockchain based on the second zero-knowledge proof.
[0035] Optionally, the first zero-knowledge proof and the second zero-knowledge proof may be generated by a verification module in the target processing system, wherein the verification module may generate the zero-knowledge proof using ZK-STARKs (Zero-Knowledge Scalable Transparent Argument of Knowledge), which is a zero-knowledge proof scheme.
[0036] like Figure 2 As shown, after generating the first zero-knowledge proof and the second zero-knowledge proof, the target processing system can send the first zero-knowledge proof and the second zero-knowledge proof to the relay chain to verify the credibility of the first blockchain based on the first zero-knowledge proof through the relay chain, and verify the credibility of the second blockchain based on the second zero-knowledge proof. Optionally, the relay chain is at least used to realize communication and data transmission between different chains.
[0037] Step S103: When the first blockchain and the second blockchain are verified, a hash time lock contract is created on the first blockchain, wherein the hash time lock contract is at least used to lock the assets of the first user.
[0038] Optionally, when the first blockchain and the second blockchain are verified, the target processing system can create Hash Time-Locked Contracts (HTLCs) on the first blockchain. HTLCs are a special type of smart contract that combines the hash lock and time lock mechanisms to ensure the atomicity and security of the transaction.
[0039] Optionally, the hash time lock contract is used at least to lock the assets of the first user, the assets locked by the hash time lock contract are the assets to be paid by the first user to the second user, and the hash time lock contract allows the assets of the first user to be unlocked when specific conditions are met.
[0040] Step S104, generating a target hash value based on the target value and the transaction data on the first blockchain, and receiving the first hash value sent by the second blockchain. When the target hash value is the same as the first hash value, sending target information to the first blockchain, wherein the target information is used to instruct the first blockchain to transfer the locked assets in the first blockchain to the second blockchain.
[0041] Optionally, the transaction data includes at least the payment information of the first user and the identity of the second user. The payment information includes but is not limited to the payment amount, payment time, order number (ie, transaction number), etc.
[0042] Optionally, a target hash value may be generated by a generation module in the target processing system based on the target value and the transaction data on the first blockchain, wherein the target value may be a preset value or a random number randomly generated by the generation module.
[0043] Optionally, the target processing system can send the target value to the second user in an off-chain manner so that the second user can obtain the target value. After obtaining the target value, the second user can generate a hash value based on the target value and transaction data through the second blockchain, and send the generated hash value to the target processing system, and the target processing system determines the received hash value sent by the second blockchain as the first hash value. When an online payment transaction occurs between the first user and the second user, the second user can obtain the aforementioned transaction data.
[0044] Optionally, the generation module is responsible for receiving the first hash value sent by the second blockchain, and comparing the received first hash value with the target hash value to see if they are the same, so that if the target hash value and the first hash value are the same, it is determined that the second blockchain passes the secondary verification, in which case the target information is sent to the first blockchain. Optionally, after receiving the target information, the first blockchain transfers the locked assets to the second blockchain.
[0045] Based on the scheme defined in the above steps S101 to S104, it can be known that in the embodiment of the present invention, a method of performing security verification on both blockchains during a cross-blockchain transaction is adopted, by receiving the user information of the first user sent by the first blockchain, and receiving the user information of the second user sent by the second blockchain, then generating a first zero-knowledge proof based on the user information of the first user, generating a second zero-knowledge proof based on the user information of the second user, and verifying the credibility of the first blockchain based on the first zero-knowledge proof, and verifying the credibility of the second blockchain based on the second zero-knowledge proof, and then creating a hash time lock contract on the first blockchain when the first blockchain and the second blockchain are verified, thereby generating a target hash value based on the target value and the transaction data on the first blockchain, and receiving the first hash value sent by the second blockchain, and sending the target information to the first blockchain when the target hash value is the same as the first hash value. Among them, the first user is to pay the asset to the second user, the first blockchain is the blockchain where the asset of the first user is located, the second blockchain is the blockchain where the asset of the second user is located, the hash time lock contract is at least used to lock the asset of the first user, and the target information is used to instruct the first blockchain to transfer the locked asset in the first blockchain to the second blockchain.
[0046] It is easy to notice that in the above process, the credibility of the first blockchain is verified based on the first zero-knowledge proof, and the credibility of the second blockchain is verified based on the second zero-knowledge proof, so as to realize the identity authentication of the first blockchain and the second blockchain. By creating a hash time lock contract on the first blockchain when the first blockchain and the second blockchain are verified, the assets to be transferred by the first user are securely locked, and double payment is avoided. By instructing the first blockchain to transfer the locked assets in the first blockchain to the second blockchain when the first hash value sent by the second blockchain is the same as the target hash value, the second blockchain is verified twice, and the first user is allowed to pay assets to the second user when the secondary verification is passed, thereby effectively improving the reliability of cross-blockchain transactions.
[0047] It can be seen that the solution provided in this application achieves the purpose of performing security verification on the blockchains of both parties during cross-blockchain transactions, thereby achieving the technical effect of improving the reliability of cross-blockchain transactions, and further solving the technical problem of low reliability of cross-blockchain transactions in related technologies.
[0048] In an optional embodiment, in the process of verifying the credibility of the first blockchain based on the first zero-knowledge proof and verifying the credibility of the second blockchain based on the second zero-knowledge proof, the target processing system may send the first zero-knowledge proof and the second zero-knowledge proof to the relay chain, thereby receiving the verification result fed back by the relay chain, and determining whether the first blockchain and the second blockchain pass the verification based on the verification result, wherein the relay chain is used to verify the credibility of the first blockchain based on the first zero-knowledge proof and verify the credibility of the second blockchain based on the second zero-knowledge proof.
[0049] Optionally, after generating the first zero-knowledge proof and the second zero-knowledge proof, the verification module in the target processing system may send the first zero-knowledge proof and the second zero-knowledge proof to the relay chain. After receiving the first zero-knowledge proof and the second zero-knowledge proof, the relay chain may verify the first zero-knowledge proof and the second zero-knowledge proof using a pre-set verification algorithm to obtain a verification result. The verification algorithm is implemented based on the mathematical principle of ZK-STARKs.
[0050] Optionally, the verification result is used to characterize whether the first blockchain and the second blockchain have passed the verification. The verification module receives the verification result fed back by the relay chain, and determines that the first blockchain and the second blockchain have passed the verification if the verification result characterizes that the first blockchain and the second blockchain have passed the verification.
[0051] It should be noted that the verification of zero-knowledge proof through the relay chain improves the security and privacy of cross-chain transactions, while the transparency and traceability of transactions are maintained through distributed ledger technology, thereby improving the reliability of cross-chain transactions.
[0052] In an optional embodiment, before receiving the first hash value sent by the second blockchain, the target processing system may generate a random number based on a pseudo-random number generator, determine the random number as a target value, and send the target value to the second user via an off-chain method.
[0053] Optionally, the generation module can use a secure pseudo-random number generator to generate a 32-byte random number (i.e., the aforementioned target value), and send the random number to the second user in an off-chain manner, and the generation module can use the random number to generate a ciphertext hash (i.e., the target hash value) through the SHA256 algorithm according to the transaction data on the first blockchain.
[0054] Optionally, after receiving the random number, the second user can generate a hash value based on the random number and transaction data through the second blockchain using the SHA256 algorithm, and send the hash value to the target processing system so that the generation module can determine the received hash value as the first hash value and compare it with the target hash value.
[0055] It should be noted that by determining the randomly generated random number as the target value, the randomness of the target value is improved, thereby improving the reliability of verifying the identity of the second blockchain. By sending the target value to the second user, it is convenient for the second user to generate the first hash value.
[0056] In an optional embodiment, the hash time lock contract includes a first condition, which represents unlocking the asset when the hash value sent by the second blockchain is the same as the target hash value, wherein after sending the target information to the first blockchain, the first blockchain transfers the locked assets in the first blockchain to the relay chain when receiving the target information, receives the second hash value sent by the second blockchain through the relay chain, and unlocks the locked assets in the relay chain when the second hash value is the same as the target hash value, and transfers the unlocked assets to the second blockchain, wherein a hash time lock contract is created on the relay chain.
[0057] Optional, such as Figure 2 As shown, when the first blockchain receives the target information, it can transfer the locked assets to the relay chain, and a hash time lock contract is also created on the relay chain. The hash time lock contract on the relay chain is used to lock the assets transferred from the first blockchain to the relay chain.
[0058] Optionally, when the target processing system sends the target information to the first blockchain, it can also send the target information to the second blockchain to prompt the second blockchain to trade with the first blockchain. When the second blockchain receives the target information, it generates a hash value based on the target value and transaction data again, and Figure 2 As shown, the generated hash value is sent to the relay chain, and the relay chain determines the received hash value sent by the second blockchain as the second hash value. The aforementioned first hash values may be the same or different. For example, if the transaction data is tampered with, or the target value is tampered with, the first hash value is different from the second hash value. For another example, if the second hash value is tampered with during the transmission process, the first hash value is different from the second hash value.
[0059] Optionally, after receiving the second hash value, the relay chain compares the second hash value with the target hash value, and determines that the first condition in the hash time lock contract is satisfied when the second hash value is the same as the target hash value, and then in this case, Figure 2 As shown, the locked assets in the relay chain are unlocked and the unlocked assets are transferred to the second blockchain. The relay chain can obtain the target hash value from the target processing system. Optionally, if the second hash value is different from the target hash value, unlocking the locked assets in the relay chain is prohibited.
[0060] It should be noted that through the above process, the third identity authentication of the second blockchain during the transaction process is achieved through the relay chain, which can further improve the reliability of cross-chain transactions.
[0061] In an optional embodiment, after the unlocked assets are transferred to the second blockchain, the target processing system can receive the transaction status change data sent by the first blockchain to obtain the first data, receive the transaction status change data sent by the second blockchain to obtain the second data, thereby uploading the first data, the second data and the transaction data to the relay chain, and publishing the first data, the second data and the transaction data in the relay chain.
[0062] Optionally, after transferring the unlocked assets to the second blockchain, the first blockchain and the second blockchain may send their respective transaction status change data to the target processing system. For example, the transaction status change data of the first blockchain may include the time of locking the assets, the time of transferring the assets to the relay chain, the time of transferring the assets back from the relay chain, etc., and the transaction status change data of the second blockchain may include the time of obtaining the assets from the relay chain, etc.
[0063] Optionally, the uplink module in the target processing system may upload the acquired first data, second data and the aforementioned transaction data to the relay chain, and publish the first data, second data and transaction data in the relay chain.
[0064] In some embodiments, the on-chain module includes a transaction detail recording unit, a state change recording unit, a timestamp recording unit, a ledger storage unit, and an access control unit, wherein the transaction detail recording unit is used to record the specific information of each transaction in detail, the state change recording unit is used to record the change history of the transaction status on the target processing system side (such as the time when the zero-knowledge verification passed or failed, the time when the hash comparison succeeded or failed), the timestamp recording unit is used to add a timestamp to each transaction step to ensure the accuracy of the time sequence, the ledger storage unit is used to store transaction records, the access control unit is used to manage access rights to the ledger data, and ensure that only authorized parties can access the transaction records. The verification unit is used to provide a verification function for the transaction records to ensure the consistency and integrity of the data. Optionally, in the process of uploading the first data, the second data, and the transaction data to the relay chain, the target processing system can also upload the transaction records generated by the on-chain module itself to the relay chain.
[0065] In some embodiments, regardless of whether the transaction succeeds or fails, the on-chain module will upload the transaction-related data to the relay chain and publish it. That is, in some embodiments, the target processing system can receive the transaction status change data sent by the first blockchain and the transaction status change data sent by the second blockchain in real time, and then count and upload them to the relay chain, and publish them in the blockchain.
[0066] It should be noted that by uploading the first data, the second data and the transaction data to the relay chain and publishing them, the first blockchain and the second blockchain can obtain these data from the relay chain, thereby ensuring the transparency and traceability of the transaction and improving the reliability of the transaction.
[0067] In an optional embodiment, the hash time lock contract also includes a second condition, which represents that the locked assets are not transferred to the second blockchain within a preset time range, and the assets are unlocked when the hash value generated by the first blockchain is the same as the target hash value. After sending the target information to the first blockchain, if the relay chain does not transfer the locked assets to the second blockchain within the preset time range, if a third hash value sent by the first blockchain is received, the third hash value is compared with the target hash value to see if they are the same. If the third hash value is the same as the target hash value, the locked assets in the relay chain are unlocked through the relay chain, and the unlocked assets are transferred to the first blockchain.
[0068] Optionally, the second condition is a time lock timeout condition in a hash time lock contract. If the locked assets are not transferred to the second blockchain within the preset time range, it is determined that the time lock timeout condition is triggered. In this case, the first blockchain can generate a hash value based on the transaction data and the target value, and send the generated hash value to the relay chain, so that the relay chain determines the received hash value sent by the first blockchain as the third hash value. The first blockchain can obtain the target value from the rollback module at the target processing system, and the aforementioned preset time range starts at the time point of locking the assets, and the length of the preset time range is a fixed value.
[0069] Optional, such as Figure 2 As shown, the relay chain can unlock the locked assets in the relay chain and transfer the unlocked assets to the first blockchain when the third hash value is the same as the target hash value. Optionally, if the third hash value is different from the target hash value, unlocking the locked assets in the relay chain is prohibited.
[0070] In some embodiments, before transferring the locked assets in the first blockchain to the relay chain, if it is determined that the locked assets have not been transferred to the second blockchain within a preset time range, a hash value is generated based on the target value and the transaction data to unlock the locked assets in the first blockchain.
[0071] It should be noted that through the above process, in the event of a transaction failure, the assets can be unlocked and retained in the first blockchain, thereby ensuring the security and integrity of the transaction and improving the reliability of cross-chain transactions.
[0072] In an optional embodiment, after verifying the credibility of the first blockchain based on the first zero-knowledge proof and verifying the credibility of the second blockchain based on the second zero-knowledge proof, the target processing system may prohibit the creation of a hash time lock contract on the first blockchain if the verification of the first blockchain and the second blockchain fails.
[0073] Optionally, when the verification between the first blockchain and the second blockchain fails, it is prohibited to create a hash time lock contract on the first blockchain, that is, cross-chain transactions between the first blockchain and the second blockchain are prohibited.
[0074] Optionally, when the target hash value is different from the first hash value, it is also prohibited to create a hash time lock contract on the first blockchain, that is, cross-chain transactions between the first blockchain and the second blockchain are prohibited.
[0075] It should be noted that through the above process, the conditions for cross-chain transactions between the first blockchain and the second blockchain are effectively limited, thereby effectively improving transaction reliability.
[0076] It can be seen that the solution provided in this application achieves the purpose of performing security verification on the blockchains of both parties during cross-blockchain transactions, thereby achieving the technical effect of improving the reliability of cross-blockchain transactions, and further solving the technical problem of low reliability of cross-blockchain transactions in related technologies.
[0077] Example 2
[0078] According to an embodiment of the present invention, an embodiment of a data processing device is provided, wherein: Figure 3 is a schematic diagram of an optional data processing device according to an embodiment of the present invention. Figure 3 As shown, the device comprises:
[0079] The first receiving module 301 is used to receive user information of a first user sent by a first blockchain, and receive user information of a second user sent by a second blockchain, wherein the first user is to pay assets to the second user, the first blockchain is the blockchain where the assets of the first user are located, and the second blockchain is the blockchain where the assets of the second user are located;
[0080] A verification module 302, configured to generate a first zero-knowledge proof based on the user information of the first user, generate a second zero-knowledge proof based on the user information of the second user, and verify the credibility of the first blockchain based on the first zero-knowledge proof, and verify the credibility of the second blockchain based on the second zero-knowledge proof;
[0081] A creation module 303 is used to create a hash time lock contract on the first blockchain when the first blockchain and the second blockchain are verified, wherein the hash time lock contract is at least used to lock the assets of the first user;
[0082] The first sending module 304 is used to generate a target hash value based on the target value and the transaction data on the first blockchain, and receive the first hash value sent by the second blockchain. When the target hash value is the same as the first hash value, the target information is sent to the first blockchain, wherein the target information is used to instruct the first blockchain to transfer the locked assets in the first blockchain to the second blockchain.
[0083] It should be noted that the above-mentioned first receiving module 301, verification module 302, creation module 303 and first sending module 304 correspond to steps S101 to S104 in the above-mentioned embodiment, and the examples and application scenarios implemented by the four modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment 1.
[0084] Optionally, the verification module also includes: a sending submodule, used to send the first zero-knowledge proof and the second zero-knowledge proof to the relay chain, wherein the relay chain is used to verify the credibility of the first blockchain based on the first zero-knowledge proof, and to verify the credibility of the second blockchain based on the second zero-knowledge proof; a determination submodule, used to receive the verification results fed back by the relay chain, and determine whether the first blockchain and the second blockchain have passed the verification based on the verification results.
[0085] Optionally, the data processing device also includes: a generation module, used to generate a random number based on a pseudo-random number generator, and determine the random number as a target value; a second sending module, used to send the target value to the second user in an off-chain manner.
[0086] Optionally, the data processing device also includes: a first processing module, used for the first blockchain to transfer the locked assets in the first blockchain to the relay chain when receiving the target information, wherein a hash time lock contract is created on the relay chain; a second processing module, used for receiving the second hash value sent by the second blockchain through the relay chain, and when the second hash value is the same as the target hash value, unlocking the locked assets in the relay chain, and transferring the unlocked assets to the second blockchain.
[0087] Optionally, the data processing device also includes: a second receiving module, used to receive transaction status change data sent by the first blockchain to obtain first data; a third receiving module, used to receive transaction status change data sent by the second blockchain to obtain second data; a third processing module, used to upload the first data, the second data and the transaction data to the relay chain, and publish the first data, the second data and the transaction data in the relay chain.
[0088] Optionally, the data processing device also includes: a comparison module, which is used to compare whether the third hash value sent by the first blockchain is the same if the third hash value is received when the relay chain fails to transfer the locked assets to the second blockchain within a preset time range; and a fourth processing module, which is used to unlock the locked assets in the relay chain through the relay chain when the third hash value is the same as the target hash value, and transfer the unlocked assets to the first blockchain.
[0089] Optionally, the data processing device also includes: a fifth processing module, used to prohibit the creation of a hash time lock contract on the first blockchain when the verification between the first blockchain and the second blockchain fails.
[0090] Example 3
[0091] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned data processing method when running.
[0092] Example 4
[0093] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, wherein: Figure 4 is a schematic diagram of an optional electronic device according to an embodiment of the present invention, such as Figure 4 As shown, the electronic device includes one or more processors; a memory for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the above-mentioned data processing method when running.
[0094] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0095] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0096] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0097] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0098] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0099] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0100] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A data processing method, characterized in that: Applied to a target processing system, the method comprises: Receiving user information of a first user sent by a first blockchain, and receiving user information of a second user sent by a second blockchain, wherein the first user is to pay assets to the second user, the first blockchain is the blockchain where the assets of the first user are located, and the second blockchain is the blockchain where the assets of the second user are located; Generate a first zero-knowledge proof based on the user information of the first user, generate a second zero-knowledge proof based on the user information of the second user, and verify the credibility of the first blockchain based on the first zero-knowledge proof, and verify the credibility of the second blockchain based on the second zero-knowledge proof; When the first blockchain and the second blockchain are verified, a hash time lock contract is created on the first blockchain, wherein the hash time lock contract is at least used to lock the assets of the first user; A target hash value is generated based on the target value and the transaction data on the first blockchain, and the first hash value sent by the second blockchain is received. When the target hash value is the same as the first hash value, target information is sent to the first blockchain, wherein the target information is used to instruct the first blockchain to transfer the locked assets in the first blockchain to the second blockchain.
2. The method according to claim 1, characterized in that Verifying the credibility of the first blockchain based on the first zero-knowledge proof, and verifying the credibility of the second blockchain based on the second zero-knowledge proof, including: Sending the first zero-knowledge proof and the second zero-knowledge proof to a relay chain, wherein the relay chain is used to verify the credibility of the first blockchain based on the first zero-knowledge proof, and to verify the credibility of the second blockchain based on the second zero-knowledge proof; Receive the verification result fed back by the relay chain, and determine whether the first blockchain and the second blockchain pass the verification according to the verification result.
3. The method according to claim 1, characterized in that Before receiving the first hash value sent by the second blockchain, the method further includes: Generate a random number based on a pseudo-random number generator, and determine the random number as the target value; The target value is sent to the second user off-chain.
4. The method according to claim 1, characterized in that: The hash time lock contract includes a first condition, wherein the first condition represents unlocking the asset when the hash value sent by the second blockchain is the same as the target hash value, wherein after sending the target information to the first blockchain, the method further includes: Upon receiving the target information, the first blockchain transfers the locked assets in the first blockchain to the relay chain, wherein the hash time lock contract is created on the relay chain; The second hash value sent by the second blockchain is received through the relay chain, and when the second hash value is the same as the target hash value, the locked assets in the relay chain are unlocked, and the unlocked assets are transferred to the second blockchain.
5. The method according to claim 4, characterized in that After transferring the unlocked assets to the second blockchain, the method further includes: Receiving transaction status change data sent by the first blockchain to obtain first data; Receiving transaction status change data sent by the second blockchain to obtain second data; The first data, the second data, and the transaction data are uploaded to the relay chain, and the first data, the second data, and the transaction data are published in the relay chain.
6. The method according to claim 4, characterized in that The hash time lock contract further includes a second condition, wherein the second condition indicates that the locked asset is not transferred to the second blockchain within a preset time range, and the asset is unlocked when the hash value generated by the first blockchain is the same as the target hash value, wherein after sending the target information to the first blockchain, the method further includes: If the relay chain fails to transfer the locked assets to the second blockchain within a preset time range, if the relay chain receives the third hash value sent by the first blockchain, it compares the third hash value with the target hash value to see if they are the same; When the third hash value is the same as the target hash value, the locked assets in the relay chain are unlocked through the relay chain, and the unlocked assets are transferred to the first blockchain.
7. The method according to claim 1, characterized in that After verifying the credibility of the first blockchain based on the first zero-knowledge proof and verifying the credibility of the second blockchain based on the second zero-knowledge proof, the method further includes: If the verification of the first blockchain and the second blockchain fails, it is prohibited to create the hash time lock contract on the first blockchain.
8. A data processing device, characterized in that: Applied to a target processing system, the device comprises: A first receiving module is configured to receive user information of a first user sent by a first blockchain, and receive user information of a second user sent by a second blockchain, wherein the first user is to pay assets to the second user, the first blockchain is the blockchain where the assets of the first user are located, and the second blockchain is the blockchain where the assets of the second user are located; a verification module, configured to generate a first zero-knowledge proof based on the user information of the first user, generate a second zero-knowledge proof based on the user information of the second user, and verify the credibility of the first blockchain based on the first zero-knowledge proof, and verify the credibility of the second blockchain based on the second zero-knowledge proof; A creation module, configured to create a hash time lock contract on the first blockchain when the first blockchain and the second blockchain are verified, wherein the hash time lock contract is at least used to lock the assets of the first user; The first sending module is used to generate a target hash value based on a target value and transaction data on the first blockchain, and receive the first hash value sent by the second blockchain. When the target hash value is the same as the first hash value, the first sending module sends target information to the first blockchain, wherein the target information is used to instruct the first blockchain to transfer the locked assets in the first blockchain to the second blockchain.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the data processing method described in any one of claims 1 to 7 when executed.
10. An electronic device, characterized in that: The electronic device includes one or more processors; A memory for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the data processing method described in any one of claims 1 to 7 when running.
Citation Information
Patent Citations
MethodS, system and apparatus for managing transactions in multiple blockchain networks
CN113568946A
Power data uploading system and method based on zero-knowledge proof
CN113660092A
Cross-chain asset transfer method, computer equipment and storage medium
CN114386967A
Data processing method, device and equipment based on block chain and readable storage medium
CN116488818A
Regional equity transaction evidence storage cross-chain consensus method and system
CN116781337A
