CN111464536A - A blockchain cross-chain method and device - Google Patents
A blockchain cross-chain method and device Download PDFInfo
- Publication number
- CN111464536A CN111464536A CN202010245077.0A CN202010245077A CN111464536A CN 111464536 A CN111464536 A CN 111464536A CN 202010245077 A CN202010245077 A CN 202010245077A CN 111464536 A CN111464536 A CN 111464536A
- Authority
- CN
- China
- Prior art keywords
- user
- asset
- blockchain
- message
- locking
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/08—Network architectures or network communication protocols for network security for authentication of entities
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
- H04L9/0643—Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords
- H04L9/0869—Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/50—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Business, Economics & Management (AREA)
- Computer Security & Cryptography (AREA)
- Finance (AREA)
- Accounting & Taxation (AREA)
- Computer Hardware Design (AREA)
- Strategic Management (AREA)
- Computing Systems (AREA)
- Power Engineering (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Marketing (AREA)
- General Engineering & Computer Science (AREA)
- Technology Law (AREA)
- Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
Abstract
本发明公开了一种区块链跨链方法及装置,属于通信技术领域。该区块链跨链方法包括:第一用户向第二用户发送资产锁定消息;其中,第一用户为第一区块链的用户,第二用户为第二区块链的用户,且第一区块链与第二区块链具有一个或多个共同节点;根据资产锁定消息中的资产锁定时间点和资产锁定时长锁定第一用户的资产;向第二用户发送验证随机数,以使第二用户验证资产锁定消息的准确性,并根据资产锁定消息的准确性验证结果执行资产转移操作,可以不引入第三方交易平台等会生成新中心化节点的机构,从而实现安全、可靠和高效的链上资产转移,提升用户体验。
The invention discloses a blockchain cross-chain method and device, belonging to the technical field of communication. The blockchain cross-chain method includes: a first user sends an asset locking message to a second user; wherein the first user is a user of the first blockchain, the second user is a user of the second blockchain, and the first user is a user of the second blockchain. The blockchain and the second blockchain have one or more common nodes; the first user's assets are locked according to the asset locking time point and asset locking duration in the asset locking message; the verification random number is sent to the second user to enable the first user The second user verifies the accuracy of the asset lock message, and executes the asset transfer operation according to the accuracy verification result of the asset lock message. It is not necessary to introduce institutions such as third-party trading platforms that will generate new centralized nodes, so as to achieve a safe, reliable and efficient system. On-chain asset transfer to improve user experience.
Description
技术领域technical field
本发明涉及通信技术领域,具体涉及一种区块链跨链方法及装置。The present invention relates to the field of communication technologies, in particular to a method and device for cross-chain blockchain.
背景技术Background technique
中本聪第一次提出区块链的概念,并且在随后的几年中,区块链作为所有交易的公共账簿,成为了电子货币比特币的核心组成部分。从本质上讲,区块链是一个共享数据库,存储于其中的数据或信息不可篡改,具有去中心化、不可篡改、全程留痕、可以追溯、集体维护、公开透明等特征。基于这些特征,区块链技术奠定了坚实的“信任”基础,创造了可靠的“合作”机制,因此具有广阔的运用前景。随着区块链技术及应用的快速发展,当前已经出现了各种各样的相互独立的区块链网络,而实现跨区链的交易已经成为当前区块链应用的迫切需求。跨链技术是相互独立的区块链之间实现连通的桥梁。现有的跨链技术中,实现不同区块链项目间资产的转移与交换主要通过第三方交易平台来实现。但是,引入第三方交易平台会带来新的中心化节点,因此,不可避免地存在威胁资产安全性和可信性的问题。The concept of blockchain was first proposed by Satoshi Nakamoto, and in the years that followed, the blockchain became a core component of the electronic currency Bitcoin as a public ledger of all transactions. In essence, the blockchain is a shared database, the data or information stored in it cannot be tampered with, and has the characteristics of decentralization, non-tampering, full traces, traceability, collective maintenance, openness and transparency, etc. Based on these characteristics, blockchain technology has laid a solid "trust" foundation and created a reliable "cooperation" mechanism, so it has broad application prospects. With the rapid development of blockchain technology and applications, various independent blockchain networks have emerged, and the realization of cross-chain transactions has become an urgent need for current blockchain applications. Cross-chain technology is a bridge to achieve connectivity between independent blockchains. In the existing cross-chain technology, the transfer and exchange of assets between different blockchain projects is mainly realized through a third-party trading platform. However, the introduction of third-party trading platforms will bring new centralized nodes, therefore, there are inevitably problems that threaten the security and credibility of assets.
有鉴于此,本发明提供一种区块链跨链方法,可以不引入第三方交易平台等会生成新中心化节点的机构,从而实现安全、可靠和高效的链上资产转移,提升用户体验。In view of this, the present invention provides a blockchain cross-chain method, which can not introduce institutions such as third-party trading platforms that generate new centralized nodes, thereby realizing safe, reliable and efficient on-chain asset transfer and improving user experience.
发明内容SUMMARY OF THE INVENTION
为此,本发明提供一种区块链跨链方法及装置,以解决跨链交易时引入第三方交易平台会产生新的中心化节点,从而威胁资产安全性和可信性的问题。Therefore, the present invention provides a blockchain cross-chain method and device to solve the problem that the introduction of a third-party trading platform during cross-chain transactions will generate new centralized nodes, thereby threatening the security and credibility of assets.
为了实现上述目的,本发明第一方面提供一种区块链跨链方法,应用于第一用户,包括:In order to achieve the above purpose, the first aspect of the present invention provides a blockchain cross-chain method, which is applied to the first user, including:
向第二用户发送资产锁定消息;其中,所述资产锁定消息包括哈希值、所述第二用户的区块链标识、资产锁定时间点和资产锁定时长,所述哈希值为所述第一用户生成的随机数对应的哈希值;所述第一用户为第一区块链的用户,所述第二用户为第二区块链的用户,且所述第一区块链与所述第二区块链具有一个或多个共同节点;Send an asset locking message to the second user; wherein the asset locking message includes a hash value, the second user's blockchain identifier, an asset locking time point and an asset locking duration, and the hash value is the first A hash value corresponding to a random number generated by a user; the first user is a user of the first blockchain, the second user is a user of the second blockchain, and the first blockchain is associated with all said second blockchain has one or more common nodes;
根据所述资产锁定消息中的所述资产锁定时间点和所述资产锁定时长锁定所述第一用户的资产;Lock the asset of the first user according to the asset locking time point and the asset locking duration in the asset locking message;
向所述第二用户发送验证随机数,以使所述第二用户验证所述资产锁定消息的准确性,并根据所述资产锁定消息的准确性验证结果执行资产转移操作。A verification random number is sent to the second user, so that the second user verifies the accuracy of the asset locking message, and performs an asset transfer operation according to the verification result of the accuracy of the asset locking message.
进一步地,所述向第二用户发送资产锁定消息之前,还包括:Further, before the sending the asset locking message to the second user, the method further includes:
所述第一用户与所述第二用户签订智能合约;其中,所述智能合约约定所述第一用户与所述第二用户之间进行资产转移和退回的细则。The first user signs a smart contract with the second user; wherein, the smart contract stipulates detailed rules for asset transfer and return between the first user and the second user.
进一步地,所述向第二用户发送资产锁定消息,包括:Further, the sending an asset locking message to the second user includes:
向所述第一区块链广播所述资产锁定消息,以使所述共同节点接收所述资产锁定消息;broadcasting the asset lock message to the first blockchain for the common node to receive the asset lock message;
所述共同节点将所述资产锁定消息在所述第二区块链广播,使得所述第二用户接收所述资产广播消息。The common node broadcasts the asset lock message on the second blockchain, so that the second user receives the asset broadcast message.
进一步地,所述向所述第二用户发送验证随机数之后,还包括:Further, after sending the verification random number to the second user, the method further includes:
若所述第二用户对所述资产锁定消息的准确性验证通过后,接收所述第二用户转移的所述第二用户的资产;If the second user passes the accuracy verification of the asset lock message, receiving the asset of the second user transferred by the second user;
若在预设时间间隔内收到所述第二用户返回的所述验证随机数,将所述第二用户的资产转回至所述第二用户。If the verification random number returned by the second user is received within a preset time interval, the assets of the second user are transferred back to the second user.
为了实现上述目的,本发明第二方面提供一种区块链跨链方法,应用于第二用户,包括:In order to achieve the above purpose, a second aspect of the present invention provides a blockchain cross-chain method, which is applied to a second user, including:
接收第一用户发送的资产锁定消息;其中,所述资产锁定消息包括哈希值、所述第二用户的区块链标识、资产锁定时间点和资产锁定时长,所述哈希值为所述第一用户生成的随机数对应的哈希值;所述第一用户为第一区块链的用户,所述第二用户为第二区块链的用户,且所述第一区块链与所述第二区块链具有一个或多个共同节点;Receive an asset locking message sent by the first user; wherein the asset locking message includes a hash value, the blockchain identifier of the second user, an asset locking time point and an asset locking duration, and the hash value is the The hash value corresponding to the random number generated by the first user; the first user is a user of the first blockchain, the second user is a user of the second blockchain, and the first blockchain is the same as the second blockchain has one or more common nodes;
根据所述资产锁定消息中的所述资产锁定时间点和所述资产锁定时长锁定所述第二用户的资产;Lock the asset of the second user according to the asset locking time point and the asset locking duration in the asset locking message;
接收所述第一用户发送的验证随机数,并基于所述验证随机数验证所述资产锁定消息的准确性;Receive the verification random number sent by the first user, and verify the accuracy of the asset lock message based on the verification random number;
当所述资产锁定消息的准确性验证通过后,将所述第二用户的资产转移至所述第一用户。After the accuracy verification of the asset locking message is passed, the assets of the second user are transferred to the first user.
进一步地,所述接收第一用户发送的资产锁定消息,包括:Further, the receiving an asset locking message sent by the first user includes:
所述第二区块链接收所述共同节点广播的所述资产锁定消息,并在所述第二区块链中广播;其中,所述资产锁定消息为所述第一用户在所述第一区块链广播,并被所述共同节点接收后在所述第二区块链中广播的消息;The second blockchain receives the asset lock message broadcast by the common node, and broadcasts it in the second blockchain; wherein, the asset lock message is the first user in the first A message broadcast by the blockchain and broadcast in the second blockchain after being received by the common node;
接收所述共同节点在所述第二区块链广播的所述资产锁定消息。Receive the asset lock message broadcast by the common node on the second blockchain.
进一步地,所述接收第一用户发送的资产锁定消息之后,所述根据所述资产锁定消息中的所述资产锁定时间点和资产锁定时长锁定所述第二用户的资产之前,还包括:Further, after receiving the asset locking message sent by the first user, before locking the assets of the second user according to the asset locking time point and asset locking duration in the asset locking message, the method further includes:
对所述资产锁定消息进行签名验证。Signature verification is performed on the asset lock message.
进一步地,所述基于所述验证随机数验证所述资产锁定消息的准确性,包括:Further, the verification of the accuracy of the asset lock message based on the verification random number includes:
计算所述验证随机数对应的验证哈希值;Calculate the verification hash value corresponding to the verification random number;
比较所述验证哈希值与所述资产锁定消息中的哈希值是否一致;comparing whether the verification hash value is consistent with the hash value in the asset lock message;
若所述验证哈希值与所述资产锁定消息中的哈希值一致,则所述资产锁定消息的准确性验证通过。If the verification hash value is consistent with the hash value in the asset locking message, the accuracy verification of the asset locking message passes.
进一步地,若所述第二用户在预设时间间隔向所述第一用户返回所述验证随机数,则接收所述第一用户转回的所述第二用户的资产。Further, if the second user returns the verification random number to the first user at a preset time interval, the assets of the second user transferred back by the first user are received.
为了实现上述目的,本发明第三方面提供一种区块链跨链装置,应用于第一用户,包括:In order to achieve the above purpose, a third aspect of the present invention provides a blockchain cross-chain device, which is applied to the first user, including:
第一发送模块,用于向第二用户发送资产锁定消息;其中,所述资产锁定消息包括哈希值、所述第二用户的区块链标识、资产锁定时间点和资产锁定时长,所述哈希值为所述第一用户生成的随机数对应的哈希值;所述第一用户为第一区块链的用户,所述第二用户为第二区块链的用户,且所述第一区块链与所述第二区块链具有一个或多个共同节点;The first sending module is configured to send an asset locking message to the second user; wherein, the asset locking message includes a hash value, a blockchain identifier of the second user, an asset locking time point and an asset locking duration, and the The hash value is the hash value corresponding to the random number generated by the first user; the first user is a user of the first blockchain, the second user is a user of the second blockchain, and the The first blockchain and the second blockchain have one or more common nodes;
锁定模块,用于根据所述资产锁定消息中的所述资产锁定时间点和资产锁定时长锁定所述第一用户的资产;a locking module, configured to lock the assets of the first user according to the asset locking time point and the asset locking duration in the asset locking message;
第二发送模块,用于向所述第二用户发送验证随机数,以使所述第二用户验证所述资产锁定消息的准确性,并根据所述资产锁定消息的准确性验证结果执行资产转移操作。A second sending module, configured to send a verification random number to the second user, so that the second user can verify the accuracy of the asset lock message, and execute asset transfer according to the verification result of the asset lock message accuracy operate.
本发明具有如下优点:The present invention has the following advantages:
本发明提供的区块链跨链方法,由第一用户向第二用户发送资产锁定消息;其中,资产锁定消息包括哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长,哈希值为第一用户生成的随机数对应的哈希值;第一用户为第一区块链的用户,第二用户为第二区块链的用户,且第一区块链与第二区块链具有一个或多个共同节点;In the blockchain cross-chain method provided by the present invention, a first user sends an asset locking message to a second user; wherein, the asset locking message includes a hash value, the second user's blockchain identification, the asset locking time point and the asset locking duration, the hash value is the hash value corresponding to the random number generated by the first user; the first user is a user of the first blockchain, the second user is a user of the second blockchain, and the first blockchain is the same as the user of the second blockchain. The second blockchain has one or more common nodes;
第一用户根据资产锁定消息中的资产锁定时间点和资产锁定时长锁定第一用户的资产,并向第二用户发送验证随机数,以使第二用户验证资产锁定消息的准确性,并根据资产锁定消息的准确性验证结果执行资产转移操作,从而可以不引入第三方交易平台等会生成新中心化节点的机构,实现安全、可靠和高效的链上资产转移,提升用户体验。The first user locks the assets of the first user according to the asset locking time point and the asset locking duration in the asset locking message, and sends a verification random number to the second user, so that the second user can verify the accuracy of the asset locking message. The asset transfer operation is performed on the result of the accuracy verification of the locked message, thereby avoiding the introduction of third-party trading platforms and other institutions that generate new centralized nodes, realizing safe, reliable and efficient on-chain asset transfer and improving user experience.
附图说明Description of drawings
附图是用来提供对本发明的进一步理解,并且构成说明书的一部分,与下面的具体实施方式一起用于解释本发明,但并不构成对本发明的限制。The accompanying drawings are used to provide a further understanding of the present invention, and constitute a part of the specification, and together with the following specific embodiments, are used to explain the present invention, but do not constitute a limitation to the present invention.
图1为本发明第一实施例提供的一种区块链跨链方法的流程图;FIG. 1 is a flowchart of a blockchain cross-chain method provided by the first embodiment of the present invention;
图2为本发明第二实施例提供的一种区块链跨链方法的流程图;FIG. 2 is a flowchart of a blockchain cross-chain method provided by the second embodiment of the present invention;
图3为本发明第三实施例提供的一种区块链跨链方法的流程图;FIG. 3 is a flowchart of a method for cross-chain blockchain provided by the third embodiment of the present invention;
图4为本发明第四实施例提供的一种区块链跨链方法的流程图;FIG. 4 is a flowchart of a method for cross-chain blockchain provided by the fourth embodiment of the present invention;
图5为本发明第五实施例提供的一种区块链跨链装置的原理框图。FIG. 5 is a schematic block diagram of a blockchain cross-chain device provided by a fifth embodiment of the present invention.
具体实施方式Detailed ways
以下结合附图对本发明的具体实施方式进行详细说明。应当理解的是,此处所描述的具体实施方式仅用于说明和解释本发明,并不用于限制本发明。The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present invention, but not to limit the present invention.
本发明实施例提供的区块链跨链方法,考虑到通过第三方交易平台实现不同区块链项目间资产的转移与交换的区块链跨链技术中,引入第三方交易平台会带来新的中心化节点,从而不可避免地存在威胁资产安全性和可信性的问题,提出一种新的区块链跨链方法,可以不引入第三方交易平台等会生成新中心化节点的机构,实现安全、可靠和高效的链上资产转移,提升用户体验。The blockchain cross-chain method provided by the embodiments of the present invention takes into account that in the blockchain cross-chain technology that realizes the transfer and exchange of assets between different blockchain projects through a third-party trading platform, the introduction of a third-party trading platform will bring new Therefore, there will inevitably be problems that threaten the security and credibility of assets. A new blockchain cross-chain method is proposed, which can avoid the introduction of third-party trading platforms and other institutions that will generate new centralized nodes. Realize safe, reliable and efficient on-chain asset transfer and improve user experience.
图1是本发明第一实施例提供的一种区块链跨链方法的流程图,应用于第一用户。如图1所示,该区块链跨链方法可包括如下步骤:FIG. 1 is a flowchart of a blockchain cross-chain method provided by the first embodiment of the present invention, which is applied to a first user. As shown in Figure 1, the blockchain cross-chain method may include the following steps:
步骤S101,向第二用户发送资产锁定消息。Step S101, sending an asset lock message to the second user.
其中,资产锁定消息包括哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长,哈希值为第一用户生成的随机数对应的哈希值;第一用户为第一区块链的用户,第二用户为第二区块链的用户,且第一区块链与第二区块链具有一个或多个共同节点。The asset lock message includes the hash value, the second user's blockchain identifier, the asset locking time point and the asset locking duration, and the hash value is the hash value corresponding to the random number generated by the first user; the first user is the first user's A user of one blockchain, the second user is a user of the second blockchain, and the first blockchain and the second blockchain have one or more common nodes.
现有的部分区块链跨链技术中,实现不同区块链项目间资产的转移与交换需要通过引入第三方交易平台,并为第三方交易平台创建相应中心化节点,从而实现跨链的资产转移与交换。但是,引入第三方交易平台中心化节点,会不可避免地威胁资产的安全性和可信性。因此,本发明实施例通过第一用户向第二用户发送资产锁定消息,并基于该资产锁定消息实现跨链用户间的资产转移与交换,而不需要引入第三方交易平台,从而可以安全、可靠和高效的实现链上资产转移,提升用户体验。In some existing blockchain cross-chain technologies, the transfer and exchange of assets between different blockchain projects requires the introduction of a third-party trading platform and the creation of corresponding centralized nodes for the third-party trading platform, so as to realize cross-chain assets. transfer and exchange. However, the introduction of centralized nodes on third-party trading platforms will inevitably threaten the security and credibility of assets. Therefore, in the embodiment of the present invention, the first user sends an asset lock message to the second user, and based on the asset lock message, the asset transfer and exchange between cross-chain users is realized without introducing a third-party trading platform, so it can be safe and reliable. And efficiently realize the transfer of assets on the chain to improve the user experience.
需要说明的是,在第一用户向第二用户发送资产锁定消息之前,第一用户与第二用户已经签订智能合约。其中,智能合约的内容约定了第一用户与第二用户之间进行资产转移和退回的细则,且智能合约的签订方式包括链上签订和链下签订。It should be noted that before the first user sends the asset lock message to the second user, the first user and the second user have signed a smart contract. Among them, the content of the smart contract stipulates the detailed rules for asset transfer and return between the first user and the second user, and the signing method of the smart contract includes on-chain signing and off-chain signing.
在一个实施方式中,假设存在两条具有不同的共识机制和创始人的区块链,分别是第一区块链和第二区块链,且第一区块链和第二区块链具有一个或若干个共同节点。共同节点为同时属于第一区块链和第二区块链的节点,共同节点在第一区块链和第二区块链中分别具有对应的区块链标识和区块链公私钥对。如,节点A为第一区块链和第二区块链的共同节点,节点A在第一区块链中具有其对应的第一区块链标识ID-a1、第一区块链公钥key-ag1和第一区块链私钥key-as1,同样的,节点A在第二区块链中具有其对应的第二区块链标识ID-a2、第二区块链公钥key-ag2和第二区块链私钥key-as2。第一用户为第一区块链的用户,第二用户为第二区块链的用户,且第一用户与第二用户通过链下方式签订了一份智能合约。智能合约约定了第一用户与第二用户之间进行资产转移和退回的细则,具体内容为:第一用户向第二用户发送资产锁定消息,其中,资产锁定消息包括随机数对应的哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长等;第一用户与第二用户按照资产锁定消息的内容锁定各自的资产;如果第二用户在规定的时间间隔内收到第一用户发送的正确的随机数,智能合约自动执行将第二用户的资产转移至第一用户的操作;如果第一用户收到第二用户的资产并在规定的时间间隔内收到第二用户转回的正确的随机数,则智能合约将第一用户收到的第二用户的资产返还给第二用户。按照智能合约的内容,第一用户生成随机数,在本地计算该随机数对应的哈希值,并向第二用户发送资产锁定消息。其中,资产锁定消息包括哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长。In one embodiment, it is assumed that there are two blockchains with different consensus mechanisms and founders, namely a first blockchain and a second blockchain, and the first blockchain and the second blockchain have One or several common nodes. The common node is a node belonging to both the first blockchain and the second blockchain, and the common node has a corresponding blockchain identifier and a blockchain public-private key pair in the first blockchain and the second blockchain, respectively. For example, node A is a common node of the first blockchain and the second blockchain, and node A has its corresponding first blockchain ID-a1 and first blockchain public key in the first blockchain key-ag1 and the first blockchain private key key-as1, similarly, node A has its corresponding second blockchain ID-a2, second blockchain public key key- ag2 and the second blockchain private key key-as2. The first user is a user of the first blockchain, the second user is a user of the second blockchain, and the first user and the second user have signed a smart contract off-chain. The smart contract stipulates the detailed rules for asset transfer and return between the first user and the second user. The specific content is: the first user sends an asset lock message to the second user, wherein the asset lock message includes the hash value corresponding to the random number. , the second user's blockchain identification, asset locking time point and asset locking duration, etc.; the first user and the second user lock their respective assets according to the content of the asset locking message; if the second user receives within the specified time interval The correct random number sent by the first user, the smart contract automatically executes the operation of transferring the assets of the second user to the first user; if the first user receives the assets of the second user and receives the second user's assets within a specified time interval If the user returns the correct random number, the smart contract returns the second user's assets received by the first user to the second user. According to the content of the smart contract, the first user generates a random number, calculates the hash value corresponding to the random number locally, and sends an asset lock message to the second user. The asset locking message includes the hash value, the blockchain identifier of the second user, the asset locking time point and the asset locking duration.
在一个实施例中,第一用户向第二用户发送资产锁定消息,包括:In one embodiment, the first user sends an asset lock message to the second user, including:
第一用户使用第一用户的区块链私钥对资产锁定消息签名后,在第一区块链广播该资产锁定消息。第一区块链的所有节点均收到资产锁定消息,其中,任意一个共同节点收到资产锁定消息后,通过第一用户的区块链标识查询第一区块链的账本,获得第一用户的区块链公钥,基于第一用户的区块链公钥对资产锁定消息进行签名验证。如果资产锁定消息签名验证通过后,共同节点使用共同节点的第二区块链私钥对资产锁定消息进行二次签名,并将二次签名后的资产锁定消息在第二区块链中广播。第二用户收到共同节点在第二区块链广播的资产锁定消息。After the first user signs the asset lock message with the first user's blockchain private key, the asset lock message is broadcast on the first blockchain. All nodes of the first blockchain receive the asset lock message, and after any common node receives the asset lock message, it queries the ledger of the first blockchain through the first user's blockchain ID, and obtains the first user Based on the blockchain public key of the first user, the signature verification of the asset lock message is performed. If the signature verification of the asset lock message passes, the common node uses the second blockchain private key of the common node to re-sign the asset lock message, and broadcasts the re-signed asset lock message on the second blockchain. The second user receives the asset lock message broadcast by the common node on the second blockchain.
步骤S102,根据资产锁定消息中的资产锁定时间点和资产锁定时长锁定第一用户的资产。Step S102, lock the asset of the first user according to the asset locking time point and the asset locking duration in the asset locking message.
锁定第一用户的资产可以防止黑客对第一用户的资产进行非法转移等操作。Locking the assets of the first user can prevent hackers from illegally transferring the assets of the first user.
在一个实施方式中,第一用户向第二用户发送资产锁定消息后,按照资产锁定消息中的资产锁定时间点和资产锁定时长,在到达资产锁定时间点后锁定第一用户的资产,且锁定时长为资产锁定消息中的资产锁定时长。In one embodiment, after the first user sends an asset lock message to the second user, according to the asset lock time point and asset lock duration in the asset lock message, the first user's assets are locked after the asset lock time point is reached, and the lock is performed. The duration is the asset lock duration in the asset lock message.
如,资产锁定消息中的资产锁定时间点为2020年1月1日00点00分00秒,锁定时长为则20分钟,则在第一区块链的系统时间到达2020年1月1日00点00分00秒后,将第一用户的资产锁定,锁定时长为20分钟。For example, the asset lock time point in the asset lock message is 00:00:00 on January 1, 2020, and the lock time is 20 minutes, then the system time of the first blockchain reaches 00 on January 1, 2020. After 00:00:00, the assets of the first user will be locked for 20 minutes.
步骤S103,向第二用户发送验证随机数,以使第二用户验证资产锁定消息的准确性,并根据资产锁定消息的准确性验证结果执行资产转移操作。Step S103, sending a verification random number to the second user, so that the second user verifies the accuracy of the asset locking message, and executes the asset transfer operation according to the accuracy verification result of the asset locking message.
其中,验证随机数与资产锁定消息中的随机数的数值是相同的。The verification random number is the same as the random number in the asset lock message.
需要说明的是,第一用户向第二用户发送验证随机数的方式包括链上发送方式和链下发送方式,其中链下发送方式包括通过p2p(peer-to-peer,点对点)或者移动交换网进行发送。一般情况下,为保证第二用户接收信息的准确性,采用链下方式向第二用户发送验证随机数,这样可以校验通过链上方式接收的资产锁定消息是否被非法篡改,从而可以在一定程度上保证接收信息的准确性。可以理解的是,无论验证随机数采用何种发送方式,其均为第一用户与第二用户事先约定好的发送方式。It should be noted that the methods for the first user to send the verification random number to the second user include on-chain sending and off-chain sending, wherein off-chain sending includes p2p (peer-to-peer, peer-to-peer) or mobile switching network to send. Under normal circumstances, in order to ensure the accuracy of the information received by the second user, a verification random number is sent to the second user in an off-chain way, so as to verify whether the asset lock message received through the on-chain way has been illegally tampered with, so that it can be verified within a certain period of time. To a certain extent, the accuracy of the received information is guaranteed. It can be understood that, no matter what sending method is adopted for the verification random number, it is the sending method agreed in advance between the first user and the second user.
在一个实施方式中,第一用户通过短信方式向第二用户发送验证随机数。第二用户收到第一用户发送的短信后,获取验证随机数,并计算验证随机数对应的哈希值,获得验证哈希值。第二用户比较验证哈希值与资产锁定消息中的哈希值是否一致。当验证哈希值与资产锁定消息中的哈希值一致时,说明资产锁定消息的准确性验证通过,第二用户按照智能合约的内容将其资产转移至第一用户。In one embodiment, the first user sends the verification random number to the second user by means of a short message. After receiving the short message sent by the first user, the second user obtains the verification random number, and calculates the hash value corresponding to the verification random number to obtain the verification hash value. The second user compares and verifies whether the hash value is consistent with the hash value in the asset lock message. When the verification hash value is consistent with the hash value in the asset lock message, it means that the accuracy verification of the asset lock message has passed, and the second user transfers his assets to the first user according to the content of the smart contract.
图2是本发明第二实施例提供的一种区块链跨链方法的流程图,应用于第一用户,与本发明第一实施例基本相同,区别之处在于:在向第二用户发送验证随机数之后,还接收第二用户的撤销资产转移。如图2所示,该区块链跨链方法可包括如下步骤:Fig. 2 is a flowchart of a blockchain cross-chain method provided by the second embodiment of the present invention, which is applied to the first user and is basically the same as the first embodiment of the present invention, except that: when sending to the second user After verifying the random number, the second user's revocation of the transfer of assets is also received. As shown in Figure 2, the blockchain cross-chain method may include the following steps:
步骤S201,向第二用户发送资产锁定消息。Step S201, sending an asset locking message to the second user.
本实施例中的步骤S201与本发明第一实施例中步骤S101的内容相同,在此不再赘述。The content of step S201 in this embodiment is the same as that of step S101 in the first embodiment of the present invention, and details are not repeated here.
步骤S202,根据资产锁定消息中的资产锁定时间点和资产锁定时长锁定第一用户的资产。Step S202, lock the asset of the first user according to the asset locking time point and the asset locking duration in the asset locking message.
本实施例中的步骤S202与本发明第一实施例中步骤S102的内容相同,在此不再赘述。The content of step S202 in this embodiment is the same as that of step S102 in the first embodiment of the present invention, and details are not repeated here.
步骤S203,向第二用户发送验证随机数,以使第二用户验证资产锁定消息的准确性,并根据资产锁定消息的准确性验证结果执行资产转移操作。Step S203, sending a verification random number to the second user, so that the second user verifies the accuracy of the asset locking message, and executes the asset transfer operation according to the accuracy verification result of the asset locking message.
本实施例中的步骤S203与本发明第一实施例中步骤S103的内容相同,在此不再赘述。The content of step S203 in this embodiment is the same as that of step S103 in the first embodiment of the present invention, and details are not repeated here.
步骤S204,若第二用户对资产锁定消息的准确性验证通过后,接收第二用户转移的第二用户的资产。Step S204, if the second user passes the accuracy verification of the asset locking message, the second user's assets transferred by the second user are received.
第二用户基于验证随机数验证资产锁定消息的准确性,并在资产锁定消息准确性验证通过后,按照智能合约将第二用户的资产转移至第一用户。对于第一用户来说,其在资产锁定消息的准确性验证通过后,接收第二用户转移的第二用户的资产。The second user verifies the accuracy of the asset lock message based on the verification random number, and transfers the second user's assets to the first user according to the smart contract after the accuracy of the asset lock message is verified. For the first user, after the accuracy verification of the asset locking message is passed, the second user's assets transferred by the second user are received.
步骤S205,若在预设时间间隔内收到第二用户返回的验证随机数,将第二用户的资产转回至第二用户。Step S205, if the verification random number returned by the second user is received within the preset time interval, the assets of the second user are transferred back to the second user.
在实际使用中发现,存在第二用户将其资产转移至第一用户后,需撤回其资产转移的需求。因此,为提升用户使用体验,允许第二用户撤回其资产转移操作。In actual use, it is found that after the second user transfers his assets to the first user, he needs to withdraw his asset transfer. Therefore, in order to improve the user experience, the second user is allowed to withdraw his asset transfer operation.
在一个实施方式中,第二用户将其资产转移至第一用户后,第二用户想执行资产转移撤回操作。因此,第二用户在预设的时间间隔内向第一用户返回验证随机数。对于第一用户来说,其在预设时间间隔内收到第二用户返回的验证随机数后,即获知第二用户想撤回第二用户转移至第一用户的资产,所以第一用户将第二用户的资产转回至第二用户。In one embodiment, after the second user transfers his assets to the first user, the second user wants to perform an asset transfer withdrawal operation. Therefore, the second user returns the verification random number to the first user within a preset time interval. For the first user, after receiving the verification random number returned by the second user within the preset time interval, he knows that the second user wants to withdraw the assets transferred by the second user to the first user, so the first user will The assets of the second user are transferred back to the second user.
图3是本发明第三实施例提供的一种区块链跨链方法的流程图,应用于第二用户。如图3所示,该区块链跨链方法可包括如下步骤:FIG. 3 is a flowchart of a method for cross-chain blockchain provided by the third embodiment of the present invention, which is applied to a second user. As shown in Figure 3, the blockchain cross-chain method may include the following steps:
步骤S301,接收第一用户发送的资产锁定消息。Step S301, receiving an asset locking message sent by a first user.
其中,资产锁定消息包括哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长,哈希值为第一用户生成的随机数对应的哈希值;第一用户为第一区块链的用户,第二用户为第二区块链的用户,且第一区块链与第二区块链具有一个或多个共同节点。The asset lock message includes the hash value, the second user's blockchain identifier, the asset locking time point and the asset locking duration, and the hash value is the hash value corresponding to the random number generated by the first user; the first user is the first user's A user of one blockchain, the second user is a user of the second blockchain, and the first blockchain and the second blockchain have one or more common nodes.
需要说明的是,在第二用户接收第一用户发送的资产锁定消息之前,第一用户与第二用户已经签订智能合约。其中,智能合约的内容约定了第一用户与第二用户之间进行资产转移和退回的细则,且智能合约的签订方式包括链上签订和链下签订。It should be noted that, before the second user receives the asset lock message sent by the first user, the first user and the second user have signed a smart contract. Among them, the content of the smart contract stipulates the detailed rules for asset transfer and return between the first user and the second user, and the signing method of the smart contract includes on-chain signing and off-chain signing.
在一个实施方式中,假设存在两条具有不同的共识机制和创始人的区块链,分别是第一区块链和第二区块链,且第一区块链和第二区块链具有一个或若干个共同节点。共同节点为同时属于第一区块链和第二区块链的节点,共同节点在第一区块链和第二区块链中分别具有对应的区块链标识和区块链公私钥对。如,节点A为第一区块链和第二区块链的共同节点,节点A在第一区块链中具有其对应的第一区块链标识ID-a1、第一区块链公钥key-ag1和第一区块链私钥key-as1,同样的,节点A在第二区块链中具有其对应的第二区块链标识ID-a2、第二区块链公钥key-ag2和第二区块链私钥key-as2。第一用户为第一区块链的用户,第二用户为第二区块链的用户,且第一用户与第二用户通过链下方式签订了一份智能合约。智能合约约定了第一用户与第二用户之间进行资产转移和退回的细则,具体内容为:第一用户向第二用户发送资产锁定消息,其中,资产锁定消息包括随机数对应的哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长等;第一用户与第二用户按照资产锁定消息的内容锁定各自的资产;如果第二用户在规定的时间间隔内收到第一用户发送的正确的随机数,智能合约自动执行将第二用户的资产转移至第一用户的操作;如果第一用户收到第二用户的资产并在规定的时间间隔内收到第二用户转回的正确的随机数,则智能合约将第一用户收到的第二用户的资产返还给第二用户。按照智能合约的内容,第一用户生成随机数,在本地计算该随机数对应的哈希值,并向第二用户发送资产锁定消息。其中,资产锁定消息包括哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长。第二用户接收第一用户发送的资产锁定消息。In one embodiment, it is assumed that there are two blockchains with different consensus mechanisms and founders, namely a first blockchain and a second blockchain, and the first blockchain and the second blockchain have One or several common nodes. The common node is a node belonging to both the first blockchain and the second blockchain, and the common node has a corresponding blockchain identifier and a blockchain public-private key pair in the first blockchain and the second blockchain, respectively. For example, node A is a common node of the first blockchain and the second blockchain, and node A has its corresponding first blockchain ID-a1 and first blockchain public key in the first blockchain key-ag1 and the first blockchain private key key-as1, similarly, node A has its corresponding second blockchain ID-a2, second blockchain public key key- ag2 and the second blockchain private key key-as2. The first user is a user of the first blockchain, the second user is a user of the second blockchain, and the first user and the second user have signed a smart contract off-chain. The smart contract stipulates the detailed rules for asset transfer and return between the first user and the second user. The specific content is: the first user sends an asset lock message to the second user, wherein the asset lock message includes the hash value corresponding to the random number. , the second user's blockchain identification, asset locking time point and asset locking duration, etc.; the first user and the second user lock their respective assets according to the content of the asset locking message; if the second user receives within the specified time interval The correct random number sent by the first user, the smart contract automatically executes the operation of transferring the assets of the second user to the first user; if the first user receives the assets of the second user and receives the second user's assets within a specified time interval If the user returns the correct random number, the smart contract returns the second user's assets received by the first user to the second user. According to the content of the smart contract, the first user generates a random number, calculates the hash value corresponding to the random number locally, and sends an asset lock message to the second user. The asset locking message includes the hash value, the blockchain identifier of the second user, the asset locking time point and the asset locking duration. The second user receives the asset lock message sent by the first user.
在一个实施例中,第二用户接收第一用户发送的资产锁定消息,包括:In one embodiment, the second user receives an asset lock message sent by the first user, including:
第一用户生成随机数,并在本地计算随机数对应的哈希值,并基于哈希值、第二用户区块链标识、资产锁定时间点和资产锁定时长生成资产锁定消息,然后使用第一用户的区块链私钥对资产锁定消息进行签名,并在私钥签名后在第一区块链广播该资产锁定消息。第一区块链的所有节点均收到资产锁定消息,其中,任意一个共同节点收到资产锁定消息后,通过第一用户的区块链标识查询第一区块链的账本,获得第一用户的区块链公钥,基于第一用户的区块链公钥对资产锁定消息进行签名验证。如果资产锁定消息签名验证通过后,共同节点使用共同节点的第二区块链私钥对资产锁定消息进行二次签名,并将二次签名后的资产锁定消息在第二区块链中广播。第二用户收到共同节点在第二区块链广播的资产锁定消息。The first user generates a random number, calculates the hash value corresponding to the random number locally, and generates an asset lock message based on the hash value, the second user's blockchain ID, asset lock time point and asset lock duration, and then uses the first user to generate a random number. The user's blockchain private key signs the asset lock message, and after the private key is signed, the asset lock message is broadcast on the first blockchain. All nodes of the first blockchain receive the asset lock message, and after any common node receives the asset lock message, it queries the ledger of the first blockchain through the first user's blockchain ID, and obtains the first user Based on the blockchain public key of the first user, the signature verification of the asset lock message is performed. If the signature verification of the asset lock message passes, the common node uses the second blockchain private key of the common node to re-sign the asset lock message, and broadcasts the re-signed asset lock message on the second blockchain. The second user receives the asset lock message broadcast by the common node on the second blockchain.
可以理解的是,在第二用户收到共同节点在第二区块链广播的资产锁定消息之后,为保证接收的资产锁定消息的合法性,第二用户需要对资产锁定消息进行签名验证。签名验证的过程包括:第二用户通过发送资产锁定消息的共同节点对应的第二区块链标识,查找第二区块链的账本,获得共同节点的第二区块链公钥,然后利用共同节点的第二区块链公钥对资产锁定消息进行签名验证。It can be understood that after the second user receives the asset locking message broadcast by the common node on the second blockchain, in order to ensure the legitimacy of the received asset locking message, the second user needs to perform signature verification on the asset locking message. The process of signature verification includes: the second user searches the ledger of the second blockchain through the identifier of the second blockchain corresponding to the common node that sends the asset lock message, obtains the public key of the second blockchain of the common node, and then uses the common node to obtain the public key of the second blockchain. The second blockchain public key of the node verifies the signature of the asset lock message.
步骤S302,根据资产锁定消息中的资产锁定时间点和资产锁定时长锁定第二用户的资产。Step S302, lock the asset of the second user according to the asset locking time point and the asset locking duration in the asset locking message.
锁定第一用户的资产可以防止黑客对第一用户的资产进行非法转移等操作。Locking the assets of the first user can prevent hackers from illegally transferring the assets of the first user.
在一个实施方式中,第二用户收到第一用户发送资产锁定消息后,第二用户按照资产锁定消息中的资产锁定时间点和资产锁定时长,在到达资产锁定时间点后锁定第二用户的资产,且锁定时长为资产锁定消息中的资产锁定时长。In one embodiment, after the second user receives the asset locking message sent by the first user, the second user locks the second user's assets according to the asset locking time point and asset locking duration in the asset locking message after reaching the asset locking time point. assets, and the lock duration is the asset lock duration in the asset lock message.
如,资产锁定消息中的资产锁定时间点为2020年1月1日00点00分00秒,锁定时长为则20分钟,则在第二区块链的系统时间到达2020年1月1日00点00分00秒后,将第二用户的资产锁定,锁定时长为20分钟。For example, if the asset lock time point in the asset lock message is 00:00:00 on January 1, 2020, and the lock time is 20 minutes, then the system time of the second blockchain reaches 00 on January 1, 2020. After 00:00:00, the assets of the second user will be locked for 20 minutes.
步骤S303,接收第一用户发送的验证随机数,并基于验证随机数验证资产锁定消息的准确性。Step S303: Receive the verification random number sent by the first user, and verify the accuracy of the asset locking message based on the verification random number.
其中,验证随机数与资产锁定消息中的随机数的数值是相同的。The verification random number is the same as the random number in the asset lock message.
需要说明的是,第一用户向第二用户发送验证随机数的方式包括链上发送方式和链下发送方式,其中链下发送方式包括通过p2p(peer-to-peer,点对点)或者移动交换网进行发送。一般情况下,为保证第二用户接收信息的准确性,采用链下方式向第二用户发送验证随机数,这样可以校验通过链上方式接收的资产锁定消息是否被非法篡改,从而可以在一定程度上保证接收信息的准确性。可以理解的是,无论验证随机数采用何种发送方式,其均为第一用户与第二用户事先约定好的发送方式。It should be noted that the methods for the first user to send the verification random number to the second user include on-chain sending and off-chain sending, wherein off-chain sending includes p2p (peer-to-peer, peer-to-peer) or mobile switching network to send. Under normal circumstances, in order to ensure the accuracy of the information received by the second user, a verification random number is sent to the second user in an off-chain way, so as to verify whether the asset lock message received through the on-chain way has been illegally tampered with, so that it can be verified within a certain period of time. To a certain extent, the accuracy of the received information is guaranteed. It can be understood that, no matter what sending method is adopted for the verification random number, it is the sending method agreed in advance between the first user and the second user.
在一个实施方式中,第一用户通过短信方式向第二用户发送验证随机数。第二用户收到第一用户发送的短信后,获取验证随机数,并对资产锁定消息的准确性进行验证。具体的准确性验证过程包括:计算验证随机数对应的哈希值,获得验证哈希值,然后比较验证哈希值与资产锁定消息中的哈希值是否一致。当验证哈希值与资产锁定消息中的哈希值一致时,说明资产锁定消息的准确性验证通过;当验证哈希值与资产锁定消息中的哈希值不一致时,说明资产锁定消息的准确性验证未通过。In one embodiment, the first user sends the verification random number to the second user by means of a short message. After receiving the short message sent by the first user, the second user obtains the verification random number, and verifies the accuracy of the asset locking message. The specific accuracy verification process includes: calculating the hash value corresponding to the verification random number, obtaining the verification hash value, and then comparing whether the verification hash value is consistent with the hash value in the asset lock message. When the verification hash value is consistent with the hash value in the asset locking message, it indicates that the accuracy of the asset locking message is verified; when the verification hash value is inconsistent with the hash value in the asset locking message, it indicates that the asset locking message is accurate Sexual verification failed.
步骤S304,当资产锁定消息的准确性验证通过后,将第二用户的资产转移至第一用户。Step S304, after the accuracy verification of the asset locking message is passed, transfer the assets of the second user to the first user.
当第二用户验证收到的资产锁定消息的准确性通过后,第二用户即判定可以执行与第一用户的交易,因此,第二用户将其资产转移至第一用户。After the second user verifies the accuracy of the received asset locking message, the second user determines that the transaction with the first user can be executed, and therefore, the second user transfers his assets to the first user.
图4是本发明第四实施例提供的一种区块链跨链方法的流程图,应用于第二用户,与本发明第三实施例基本相同,区别之处在于:在向第一用户转移资产后,还包括执行资产转移撤销操作。如图4所示,该区块链跨链方法可包括如下步骤:FIG. 4 is a flowchart of a blockchain cross-chain method provided by the fourth embodiment of the present invention, which is applied to a second user, and is basically the same as the third embodiment of the present invention, except that: when transferring to the first user After the asset, it also includes performing the asset transfer undo operation. As shown in Figure 4, the blockchain cross-chain method may include the following steps:
步骤S401,接收第一用户发送的资产锁定消息。Step S401, receiving an asset locking message sent by a first user.
本实施例中的步骤S401与本发明第一实施例中步骤S301的内容相同,在此不再赘述。The content of step S401 in this embodiment is the same as that of step S301 in the first embodiment of the present invention, and details are not repeated here.
步骤S402,根据资产锁定消息中的资产锁定时间点和资产锁定时长锁定第二用户的资产。Step S402, lock the asset of the second user according to the asset locking time point and the asset locking duration in the asset locking message.
本实施例中的步骤S402与本发明第一实施例中步骤S302的内容相同,在此不再赘述。The content of step S402 in this embodiment is the same as that of step S302 in the first embodiment of the present invention, and details are not repeated here.
步骤S403,接收第一用户发送的验证随机数,并基于验证随机数验证资产锁定消息的准确性。Step S403: Receive the verification random number sent by the first user, and verify the accuracy of the asset locking message based on the verification random number.
本实施例中的步骤S403与本发明第一实施例中步骤S303的内容相同,在此不再赘述。The content of step S403 in this embodiment is the same as that of step S303 in the first embodiment of the present invention, and details are not repeated here.
步骤S404,当资产锁定消息的准确性验证通过后,将第二用户的资产转移至第一用户。Step S404, after the accuracy verification of the asset locking message is passed, transfer the assets of the second user to the first user.
本实施例中的步骤S404与本发明第一实施例中步骤S304的内容相同,在此不再赘述。The content of step S404 in this embodiment is the same as that of step S304 in the first embodiment of the present invention, and details are not repeated here.
步骤S405,若在预设时间间隔向第一用户返回验证随机数,则接收第一用户转回的第二用户的资产。Step S405, if the verification random number is returned to the first user within the preset time interval, the assets of the second user transferred back by the first user are received.
在实际使用中发现,第二用户将其资产转移至第一用户后,存在撤回其资产转移的需求。因此,为提升用户使用体验,允许第二用户撤回其资产转移操作。In actual use, it is found that after the second user transfers his assets to the first user, there is a need to withdraw his asset transfer. Therefore, in order to improve the user experience, the second user is allowed to withdraw his asset transfer operation.
在一个实施方式中,第二用户将其资产转移至第一用户后,若想执行资产转移撤销操作,第二用户即在预设的时间间隔内向第一用户返回验证随机数。对于第一用户来说,其在预设时间间隔内收到第二用户返回的验证随机数后,即获知第二用户想撤回第二用户转移至第一用户的资产,所以第一用户将第二用户的资产转回至第二用户。第二用户即收到第一用户返回的第二用户的资产,从而实现资产转移撤销。In one embodiment, after the second user transfers his assets to the first user, if he wants to perform the asset transfer revocation operation, the second user returns a verification random number to the first user within a preset time interval. For the first user, after receiving the verification random number returned by the second user within the preset time interval, he knows that the second user wants to withdraw the assets transferred by the second user to the first user, so the first user will The assets of the second user are transferred back to the second user. That is, the second user receives the assets of the second user returned by the first user, thereby realizing the revocation of the asset transfer.
上面各种方法的步骤划分,只是为了描述清楚,实现时可以合并为一个步骤或者对某些步骤进行拆分,分解为多个步骤,只要包括相同的逻辑关系,都在本专利的保护范围内;对算法中或者流程中添加无关紧要的修改或者引入无关紧要的设计,但不改变其算法和流程的核心设计都在该专利的保护范围内。The steps of the above various methods are divided only for the purpose of describing clearly. During implementation, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as the same logical relationship is included, they are all within the protection scope of this patent. ;Adding insignificant modifications to the algorithm or process or introducing insignificant designs, but not changing the core design of the algorithm and process are all within the scope of protection of this patent.
图5是本发明第五实施例提供的一种区块链跨链装置的原理框图,应用于第一用户。如图5所示,该区块链跨链装置包括:第一发送模块501、锁定模块502和第二发送模块503。FIG. 5 is a functional block diagram of a blockchain cross-chain device provided by a fifth embodiment of the present invention, which is applied to a first user. As shown in FIG. 5 , the blockchain cross-chain device includes: a
第一发送模块501,用于向第二用户发送资产锁定消息。The
其中,资产锁定消息包括哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长,哈希值为第一用户生成的随机数对应的哈希值;第一用户为第一区块链的用户,第二用户为第二区块链的用户,且第一区块链与第二区块链具有一个或多个共同节点。The asset lock message includes the hash value, the second user's blockchain identifier, the asset locking time point and the asset locking duration, and the hash value is the hash value corresponding to the random number generated by the first user; the first user is the first user's A user of one blockchain, the second user is a user of the second blockchain, and the first blockchain and the second blockchain have one or more common nodes.
现有的部分区块链跨链技术中,实现不同区块链项目间资产的转移与交换需要通过引入第三方交易平台,并为第三方交易平台创建相应中心化节点,从而实现跨链的资产转移与交换。但是,引入第三方交易平台中心化节点,会不可避免地威胁资产的安全性和可信性。因此,本发明实施例通过第一用户向第二用户发送资产锁定消息,并基于该资产锁定消息实现跨链用户间的资产转移与交换,而不需要引入第三方交易平台,从而可以安全、可靠和高效的实现链上资产转移,提升用户体验。In some existing blockchain cross-chain technologies, the transfer and exchange of assets between different blockchain projects requires the introduction of a third-party trading platform and the creation of corresponding centralized nodes for the third-party trading platform, so as to realize cross-chain assets. transfer and exchange. However, the introduction of centralized nodes on third-party trading platforms will inevitably threaten the security and credibility of assets. Therefore, in the embodiment of the present invention, the first user sends an asset lock message to the second user, and based on the asset lock message, the asset transfer and exchange between cross-chain users is realized without introducing a third-party trading platform, so it can be safe and reliable. And efficiently realize the transfer of assets on the chain to improve the user experience.
需要说明的是,在第一用户向第二用户发送资产锁定消息之前,第一用户与第二用户已经签订智能合约。其中,智能合约的内容约定了第一用户与第二用户之间进行资产转移和退回的细则,且智能合约的签订方式包括链上签订和链下签订。It should be noted that before the first user sends the asset lock message to the second user, the first user and the second user have signed a smart contract. Among them, the content of the smart contract stipulates the detailed rules for asset transfer and return between the first user and the second user, and the signing method of the smart contract includes on-chain signing and off-chain signing.
在一个实施方式中,假设存在两条具有不同的共识机制和创始人的区块链,分别是第一区块链和第二区块链,且第一区块链和第二区块链具有一个或若干个共同节点。共同节点为同时属于第一区块链和第二区块链的节点,共同节点在第一区块链和第二区块链中分别具有对应的区块链标识和区块链公私钥对。第一用户为第一区块链的用户,第二用户为第二区块链的用户,且第一用户与第二用户通过链下方式签订了一份智能合约。智能合约约定了第一用户与第二用户之间进行资产转移和退回的细则,具体内容为:第一用户向第二用户发送资产锁定消息,其中,资产锁定消息包括随机数对应的哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长等;第一用户与第二用户按照资产锁定消息的内容锁定各自的资产;如果第二用户在规定的时间间隔内收到第一用户发送的正确的随机数,智能合约自动执行将第二用户的资产转移至第一用户的操作;如果第一用户收到第二用户的资产并在规定的时间间隔内收到第二用户转回的正确的随机数,则智能合约将第一用户收到的第二用户的资产返还给第二用户。按照智能合约的内容,第一用户生成随机数,在本地计算该随机数对应的哈希值,并通过第一发送模块501向第二用户发送资产锁定消息。其中,资产锁定消息包括哈希值、第二用户的区块链标识、资产锁定时间点和资产锁定时长。In one embodiment, it is assumed that there are two blockchains with different consensus mechanisms and founders, namely a first blockchain and a second blockchain, and the first blockchain and the second blockchain have One or several common nodes. The common node is a node belonging to both the first blockchain and the second blockchain, and the common node has a corresponding blockchain identifier and a blockchain public-private key pair in the first blockchain and the second blockchain, respectively. The first user is a user of the first blockchain, the second user is a user of the second blockchain, and the first user and the second user have signed a smart contract off-chain. The smart contract stipulates the detailed rules for asset transfer and return between the first user and the second user. The specific content is: the first user sends an asset lock message to the second user, wherein the asset lock message includes the hash value corresponding to the random number. , the second user's blockchain identification, asset locking time point and asset locking duration, etc.; the first user and the second user lock their respective assets according to the content of the asset locking message; if the second user receives within the specified time interval The correct random number sent by the first user, the smart contract automatically executes the operation of transferring the assets of the second user to the first user; if the first user receives the assets of the second user and receives the second user's assets within a specified time interval If the user returns the correct random number, the smart contract returns the second user's assets received by the first user to the second user. According to the content of the smart contract, the first user generates a random number, locally calculates the hash value corresponding to the random number, and sends an asset lock message to the second user through the
在一个实施例中,第一用户通过第一发送模块501向第二用户发送资产锁定消息,包括:In one embodiment, the first user sends an asset lock message to the second user through the
第一用户使用第一用户的区块链私钥对资产锁定消息签名后,在第一区块链广播该资产锁定消息。第一区块链的所有节点均收到资产锁定消息,其中,任意一个共同节点收到资产锁定消息后,通过第一用户的区块链标识查询第一区块链的账本,获得第一用户的区块链公钥,基于第一用户的区块链公钥对资产锁定消息进行签名验证。如果资产锁定消息签名验证通过后,共同节点使用共同节点的第二区块链私钥对资产锁定消息进行二次签名,并将二次签名后的资产锁定消息在第二区块链中广播。第二用户收到共同节点在第二区块链广播的资产锁定消息。After the first user signs the asset lock message with the first user's blockchain private key, the asset lock message is broadcast on the first blockchain. All nodes of the first blockchain receive the asset lock message, and after any common node receives the asset lock message, it queries the ledger of the first blockchain through the first user's blockchain ID, and obtains the first user Based on the blockchain public key of the first user, the signature verification of the asset lock message is performed. If the signature verification of the asset lock message passes, the common node uses the second blockchain private key of the common node to re-sign the asset lock message, and broadcasts the re-signed asset lock message on the second blockchain. The second user receives the asset lock message broadcast by the common node on the second blockchain.
锁定模块502,用于根据资产锁定消息中的资产锁定时间点和资产锁定时长锁定第一用户的资产。The
锁定第一用户的资产可以防止黑客对第一用户的资产进行非法转移等操作。Locking the assets of the first user can prevent hackers from illegally transferring the assets of the first user.
在一个实施方式中,第一用户向第二用户发送资产锁定消息后,锁定模块502按照资产锁定消息中的资产锁定时间点和资产锁定时长,在到达资产锁定时间点后锁定第一用户的资产,且锁定时长为资产锁定消息中的资产锁定时长。In one embodiment, after the first user sends the asset locking message to the second user, the
如,资产锁定消息中的资产锁定时间点为2020年1月1日00点00分00秒,锁定时长为则20分钟,则在第一区块链的系统时间到达2020年1月1日00点00分00秒后,锁定模块502将第一用户的资产锁定,锁定时长为20分钟。For example, the asset lock time point in the asset lock message is 00:00:00 on January 1, 2020, and the lock time is 20 minutes, then the system time of the first blockchain reaches 00 on January 1, 2020. After 00:00:00, the
第二发送模块503,用于向第二用户发送验证随机数,以使第二用户验证资产锁定消息的准确性,并根据资产锁定消息的准确性验证结果执行资产转移操作。The
其中,验证随机数与资产锁定消息中的随机数的数值是相同的。The verification random number is the same as the random number in the asset lock message.
需要说明的是,第一用户向第二用户发送验证随机数的方式包括链上发送方式和链下发送方式,其中链下发送方式包括通过p2p(peer-to-peer,点对点)或者移动交换网进行发送。一般情况下,为保证第二用户接收信息的准确性,采用链下方式向第二用户发送验证随机数,这样可以校验通过链上方式接收的资产锁定消息是否被非法篡改,从而可以在一定程度上保证接收信息的准确性。可以理解的是,无论验证随机数采用何种发送方式,其均为第一用户与第二用户事先约定好的发送方式。It should be noted that the methods for the first user to send the verification random number to the second user include on-chain sending and off-chain sending, wherein off-chain sending includes p2p (peer-to-peer, peer-to-peer) or mobile switching network to send. Under normal circumstances, in order to ensure the accuracy of the information received by the second user, a verification random number is sent to the second user in an off-chain way, so as to verify whether the asset lock message received through the on-chain way has been illegally tampered with, so that it can be verified within a certain period of time. To a certain extent, the accuracy of the received information is guaranteed. It can be understood that, no matter what sending method is adopted for the verification random number, it is the sending method agreed in advance between the first user and the second user.
在一个实施方式中,第一用户通过短信方式向第二用户发送验证随机数。第二用户收到第一用户发送的短信后,获取验证随机数,并计算验证随机数对应的哈希值,获得验证哈希值。第二用户比较验证哈希值与资产锁定消息中的哈希值是否一致。当验证哈希值与资产锁定消息中的哈希值一致时,说明资产锁定消息的准确性验证通过,第二用户按照智能合约的内容将其资产转移至第一用户。In one embodiment, the first user sends the verification random number to the second user by means of a short message. After receiving the short message sent by the first user, the second user obtains the verification random number, and calculates the hash value corresponding to the verification random number to obtain the verification hash value. The second user compares and verifies whether the hash value is consistent with the hash value in the asset lock message. When the verification hash value is consistent with the hash value in the asset lock message, it means that the accuracy verification of the asset lock message has passed, and the second user transfers his assets to the first user according to the content of the smart contract.
值得一提的是,本实施方式中所涉及到的各模块均为逻辑模块,在实际应用中,一个逻辑单元可以是一个物理单元,也可以是一个物理单元的一部分,还可以以多个物理单元的组合实现。此外,为了突出本发明的创新部分,本实施方式中并没有将与解决本发明所提出的技术问题关系不太密切的单元引入,但这并不表明本实施方式中不存在其它的单元。It is worth mentioning that each module involved in this embodiment is a logical module. In practical applications, a logical unit may be a physical unit, a part of a physical unit, or multiple physical units. A composite implementation of the unit. In addition, in order to highlight the innovative part of the present invention, this embodiment does not introduce units that are not closely related to solving the technical problem proposed by the present invention, but this does not mean that there are no other units in this embodiment.
可以理解的是,以上实施方式仅仅是为了说明本发明的原理而采用的示例性实施方式,然而本发明并不局限于此。对于本领域内的普通技术人员而言,在不脱离本发明的精神和实质的情况下,可以做出各种变型和改进,这些变型和改进也视为本发明的保护范围。It can be understood that the above embodiments are only exemplary embodiments adopted to illustrate the principle of the present invention, but the present invention is not limited thereto. For those skilled in the art, without departing from the spirit and essence of the present invention, various modifications and improvements can be made, and these modifications and improvements are also regarded as the protection scope of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010245077.0A CN111464536B (en) | 2020-03-31 | 2020-03-31 | Block chain cross-chain method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010245077.0A CN111464536B (en) | 2020-03-31 | 2020-03-31 | Block chain cross-chain method and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN111464536A true CN111464536A (en) | 2020-07-28 |
| CN111464536B CN111464536B (en) | 2022-06-07 |
Family
ID=71680933
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010245077.0A Active CN111464536B (en) | 2020-03-31 | 2020-03-31 | Block chain cross-chain method and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111464536B (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112104701A (en) * | 2020-08-13 | 2020-12-18 | 北京新盛云佳科技有限公司 | Cross-link communication method, device, network node and storage medium |
| CN112104607A (en) * | 2020-08-13 | 2020-12-18 | 北京新盛云佳科技有限公司 | Method, device, network node and storage medium for cross-link communication |
| CN112118292A (en) * | 2020-08-13 | 2020-12-22 | 北京新盛云佳科技有限公司 | Method, apparatus, network node and storage medium for cross-link communication |
| US20210342940A1 (en) * | 2020-08-31 | 2021-11-04 | Polymath Inc. | Method, system, and medium for blockchain-enabled atomic settlement |
Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170046664A1 (en) * | 2015-08-13 | 2017-02-16 | The Toronto-Dominion Bank | Systems and methods for tracking and transferring ownership of connected devices using blockchain ledgers |
| CN106899698A (en) * | 2017-04-11 | 2017-06-27 | 张铮文 | A kind of across chain mutual operation method between block chain |
| US20170366357A1 (en) * | 2016-06-16 | 2017-12-21 | The Bank Of New York Mellon | Distributed, centrally authored block chain network |
| CN108629583A (en) * | 2018-04-16 | 2018-10-09 | 上海分赋信息科技有限公司 | Mapped system and correlation method of the digital asset on mapping chain are realized based on distributed computing technology |
| CN108900585A (en) * | 2018-06-15 | 2018-11-27 | 浙江华信区块链科技服务有限公司 | Across chain transaction consistency implementation method |
| CN109685489A (en) * | 2018-12-28 | 2019-04-26 | 杭州云象网络技术有限公司 | A kind of assets across chain method of commerce between block chain |
| CN110096903A (en) * | 2019-03-26 | 2019-08-06 | 罗克佳华科技集团股份有限公司 | Assets verification method and block chain network system based on block chain |
| CN110288344A (en) * | 2019-06-25 | 2019-09-27 | 中国工商银行股份有限公司 | The assets transfer method and device of transregional piece of chain |
| CN110555765A (en) * | 2018-06-01 | 2019-12-10 | 厦门本能管家科技有限公司 | A method and system for asset circulation between multiple blockchains |
-
2020
- 2020-03-31 CN CN202010245077.0A patent/CN111464536B/en active Active
Patent Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170046664A1 (en) * | 2015-08-13 | 2017-02-16 | The Toronto-Dominion Bank | Systems and methods for tracking and transferring ownership of connected devices using blockchain ledgers |
| US20170366357A1 (en) * | 2016-06-16 | 2017-12-21 | The Bank Of New York Mellon | Distributed, centrally authored block chain network |
| CN106899698A (en) * | 2017-04-11 | 2017-06-27 | 张铮文 | A kind of across chain mutual operation method between block chain |
| CN108629583A (en) * | 2018-04-16 | 2018-10-09 | 上海分赋信息科技有限公司 | Mapped system and correlation method of the digital asset on mapping chain are realized based on distributed computing technology |
| CN110555765A (en) * | 2018-06-01 | 2019-12-10 | 厦门本能管家科技有限公司 | A method and system for asset circulation between multiple blockchains |
| CN108900585A (en) * | 2018-06-15 | 2018-11-27 | 浙江华信区块链科技服务有限公司 | Across chain transaction consistency implementation method |
| CN109685489A (en) * | 2018-12-28 | 2019-04-26 | 杭州云象网络技术有限公司 | A kind of assets across chain method of commerce between block chain |
| CN110096903A (en) * | 2019-03-26 | 2019-08-06 | 罗克佳华科技集团股份有限公司 | Assets verification method and block chain network system based on block chain |
| CN110288344A (en) * | 2019-06-25 | 2019-09-27 | 中国工商银行股份有限公司 | The assets transfer method and device of transregional piece of chain |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112104701A (en) * | 2020-08-13 | 2020-12-18 | 北京新盛云佳科技有限公司 | Cross-link communication method, device, network node and storage medium |
| CN112104607A (en) * | 2020-08-13 | 2020-12-18 | 北京新盛云佳科技有限公司 | Method, device, network node and storage medium for cross-link communication |
| CN112118292A (en) * | 2020-08-13 | 2020-12-22 | 北京新盛云佳科技有限公司 | Method, apparatus, network node and storage medium for cross-link communication |
| CN112104701B (en) * | 2020-08-13 | 2024-04-19 | 河南中新国创商业运营管理有限公司 | Method, device, network node and storage medium for cross-link communication |
| US20210342940A1 (en) * | 2020-08-31 | 2021-11-04 | Polymath Inc. | Method, system, and medium for blockchain-enabled atomic settlement |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111464536B (en) | 2022-06-07 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Chattaraj et al. | Block-CLAP: Blockchain-assisted certificateless key agreement protocol for Internet of Vehicles in smart transportation | |
| Zhaofeng et al. | Blockchain-based decentralized authentication modeling scheme in edge and IoT environment | |
| CN112311530B (en) | Block chain-based alliance trust distributed identity certificate management authentication method | |
| CN113824563B (en) | Cross-domain identity authentication method based on block chain certificate | |
| Zhang et al. | BTCAS: A blockchain-based thoroughly cross-domain authentication scheme | |
| CN111464536B (en) | Block chain cross-chain method and device | |
| CN106789090B (en) | Blockchain-based public key infrastructure system and semi-random joint certificate signature method | |
| CN110958110A (en) | A method and system for blockchain privacy data management based on zero-knowledge proof | |
| CN113328997B (en) | Alliance chain crossing system and method | |
| Liu et al. | A blockchain-based cross-domain authentication management system for IoT devices | |
| CN112583596A (en) | Complete cross-domain identity authentication method based on block chain technology | |
| CN111010376A (en) | IoT authentication system and method based on master-slave chain | |
| CN112583917A (en) | CSCP-based hybrid chain construction method | |
| CN110930153B (en) | Block chain privacy data management method and system based on hidden third party account | |
| CN113746858A (en) | Cross-chain communication method based on verifiable random function | |
| CN112396421A (en) | Identity authentication system and method based on block chaining-through card | |
| CN111818056A (en) | A blockchain-based industrial Internet identity authentication method | |
| CN112567706A (en) | Accumulator protocol based computer implemented system and method for task allocation across a computer network | |
| CN111582843A (en) | Block chain privacy transaction method based on aggregated signature | |
| Zhang et al. | Anonymous authentication and information sharing scheme based on blockchain and zero knowledge proof for VANETs | |
| CN115913575A (en) | A lightweight and robust cross-domain identity authentication method based on master-slave blockchain | |
| CN114186288A (en) | PKI certificate system model based on block chain and certificate management method | |
| CN117459539A (en) | A cross-chain data trusted interaction method and system that supports integrity auditing | |
| Mosakheil et al. | PKChain: Compromise-Tolerant and Verifiable Public Key Management System | |
| CN112968779B (en) | Security authentication and authorization control method, control system and program storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |