WO2022205957A1 - 一种基于中继设备跨链中转消息的方法和装置 - Google Patents

一种基于中继设备跨链中转消息的方法和装置 Download PDF

Info

Publication number
WO2022205957A1
WO2022205957A1 PCT/CN2021/133012 CN2021133012W WO2022205957A1 WO 2022205957 A1 WO2022205957 A1 WO 2022205957A1 CN 2021133012 W CN2021133012 W CN 2021133012W WO 2022205957 A1 WO2022205957 A1 WO 2022205957A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
message
blockchain
oracle
relay device
Prior art date
Application number
PCT/CN2021/133012
Other languages
English (en)
French (fr)
Inventor
邱鸿霖
余逸荣
Original Assignee
蚂蚁区块链科技(上海)有限公司
支付宝(杭州)信息技术有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 蚂蚁区块链科技(上海)有限公司, 支付宝(杭州)信息技术有限公司 filed Critical 蚂蚁区块链科技(上海)有限公司
Publication of WO2022205957A1 publication Critical patent/WO2022205957A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures

Definitions

  • the embodiments of this specification relate to the field of blockchain technology, and more particularly, to a method and apparatus for relaying messages across chains based on relay equipment.
  • Blockchain technology also known as distributed ledger technology, is a decentralized distributed database technology characterized by decentralization, openness, transparency, immutability, and trustworthiness. Each transaction of the blockchain will be broadcast to the blockchain nodes of the entire network, and each full node has full and consistent data.
  • many different types of chains have emerged, which are applied in the fields of finance, health care, supply chain, asset management and traceability.
  • most on-chain applications encrypted currencies or smart contracts
  • How to make different types of chains cooperate to realize the circulation of value has become the direction of exploration.
  • the cross-chain message is written into the receipt of the blockchain in the first blockchain, and the relay device under the chain obtains the receipt from the first blockchain and provides the receipt to the first blockchain.
  • the second blockchain can call the message verification contract corresponding to the Spv verification, so as to use the Spv verification method to verify the receipt. The receipt is verified. After the verification is passed, the cross-chain message can be extracted from the receipt and provided to the message receiving account. In this scheme, the verification process of the receipt by the second blockchain is complicated and inefficient.
  • one aspect of this specification provides a method for relaying messages across chains based on a relay device, the relay device is connected to the first blockchain and the second blockchain, and the relay device includes oracle machine, the method is executed by the relay device, and includes: acquiring the first data and its certification data from a first blockchain, wherein the first data includes first message data, and the first A message data includes a receiving chain identifier of the first message data; the first data is verified by the oracle machine using the proof data; in the case of passing the verification, the oracle machine verifies the first data digitally sign a message data; determine that the receiving chain of the first message data is a second blockchain based on the first message data; and provide the first message data and its digital signature to the first 2.
  • the digital signature of the first message data by the oracle machine includes, in the case of passing the verification, the oracle machine converting the first message data The format of the first message is converted into a predetermined format, and the first message data with the predetermined format is digitally signed by the oracle machine.
  • the oracle is a trusted execution environment.
  • a verification algorithm corresponding to the certification data is preset in the trusted execution environment, wherein using the certification data to verify the first data includes executing the verification algorithm by executing the verification algorithm. , and verify the first data using the certification data.
  • the certification data is Spv certification data.
  • the oracle is a relay chain
  • the relay chain includes a plurality of relay nodes, wherein the digital signature includes a digital signature of each relay node.
  • the first data is any of the following data in the first blockchain: block header data, transaction data, receipt data, and account status data.
  • Another aspect of this specification provides a method for receiving messages across chains based on a relay device, the relay device is connected to the first blockchain and the second blockchain, and the relay device includes an oracle, The method is executed by a second blockchain, where the public key of the oracle is pre-stored, and the method includes: acquiring first message data and the oracle from the relay device The digital signature of the first message data by the machine, wherein the first message data is obtained from the first blockchain by the relay device; the digital signature is performed using the public key of the oracle machine verifying; and after the verification is passed, parsing and acquiring the first message from the first message data.
  • the method is performed when a first transaction sent by the relay device is executed in the second blockchain, wherein in the first transaction, the first message and its The message receiving contract is called with the digital signature as an incoming parameter.
  • the method further includes, based on the content of the first message, determining that the receiving account of the first message is the contract account of the first smart contract, and calling the first message as an incoming parameter the first smart contract.
  • Another aspect of this specification provides an apparatus for relaying messages across chains based on a relay device, the relay device is connected to a first blockchain and a second blockchain, and the relay device includes an oracle, so The apparatus is deployed on the relay device, and includes: an acquisition unit configured to acquire the first data and its certification data from a first blockchain, wherein the first data includes first message data, and the The first message data includes a receiving chain identifier of the first message data; the verification unit is configured to use the proof data to verify the first data by the oracle machine; the signature unit is configured to verify In the case of passing, the first message data is digitally signed by the oracle; the determining unit is configured to, based on the first message data, determine that the receiving chain of the first message data is the second blockchain ; and a providing unit configured to provide the first message data and the digital signature thereof to the second blockchain.
  • the signature unit is further configured to, in the case of passing the verification, convert the format of the first message data into a predetermined format, and digitally sign the first message data having the predetermined format.
  • a verification algorithm corresponding to the certification data is preset in the trusted execution environment, wherein the verification unit is further configured to, by executing the verification algorithm, use the certification data to pair The first data is verified.
  • Another aspect of this specification provides an apparatus for receiving messages across chains based on a relay device, the relay device is connected to the first blockchain and the second blockchain, and the relay device includes an oracle, so The device is deployed in the second blockchain, and the public key of the oracle machine is pre-stored in the second blockchain, and the device includes: an acquisition unit configured to acquire from the relay device The first message data and the digital signature of the oracle machine on the first message data, wherein the first message data is obtained from the first blockchain by the relay device; the verification unit is configured to: The digital signature is verified by using the public key of the oracle machine; and a parsing unit is configured to, after the verification is passed, parse and obtain the first message from the first message data.
  • the apparatus is deployed when a first transaction sent by the relay device is executed in the second blockchain, wherein in the first transaction, the first message and its The message receiving contract is called with the digital signature as an incoming parameter.
  • the apparatus further includes a determining unit configured to, based on the content of the first message, determine that the receiving account of the first message is the contract account of the first smart contract, and a calling unit configured to to call the first smart contract with the first message as an incoming parameter.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, when the computer program is executed in a computer, the computer is made to execute any one of the above methods.
  • Another aspect of the present specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and the processor implements any one of the above methods when executing the computer program.
  • the message is verified on the relay device, thereby converting the message verification into a simple verification method, improving the verification efficiency of the message by the blockchain that receives the message, and in addition , in the embodiment of this specification, the data format of the message is converted into a data format friendly to the contract in the relay device, which further improves the efficiency of contract parsing data.
  • FIG. 1 shows a schematic diagram of a cross-chain system according to an embodiment of the present specification
  • FIG. 2 shows a flow chart of a method for inter-chain message transfer according to an embodiment of the present specification
  • Figure 3 shows a schematic diagram of the log generated after executing the message sending contract
  • FIG. 4 shows a flowchart of a method for receiving messages across chains according to an embodiment of the present specification
  • FIG. 5 shows an apparatus 500 for inter-chain message transfer according to an embodiment of the present specification
  • FIG. 6 shows an apparatus 600 for receiving messages across chains according to an embodiment of the present specification.
  • FIG. 1 shows a schematic diagram of a cross-chain system according to an embodiment of the present specification.
  • the cross-chain system includes a first blockchain 11, a relay device 12 and a second blockchain 13, wherein the first blockchain 11 and the second blockchain 13 are respectively connected to the relay Device 12 is connected.
  • a first contract and a message sending contract are deployed in the first blockchain 11
  • a message receiving contract and a fourth contract are deployed in the second blockchain 13
  • the relay device 12 includes an oracle machine
  • the oracle machine has various In the form of, for example, a Trusted Execution Environment (TEE), the TEE has its own hardware private and public keys.
  • the first contract and the fourth contract are, for example, contracts for performing cross-chain transfers.
  • account A in the first blockchain 11 wishes to transfer money to account B in the second blockchain 13, and account A initiates the transfer by sending a transaction that invokes the first contract.
  • the transaction is executed in the first blockchain 11, the first contract is executed, thereby subtracting the number of transfers from the balance of account A, and executing the message sending contract called in the first contract, so that in the first block
  • the chain stores, for example, a receipt m containing a message 1 to be sent to the fourth contract in the second blockchain 13 .
  • the message 1 includes, for example, the identifier of the sending chain, the identifier of the receiving chain (the second block chain 13 ), the sending account, the receiving account (account B), the receiving contract account (the fourth contract account) and the account B of the message 1 The amount of the increase in the balance, etc.
  • the first blockchain 11 and the second blockchain 13 can be any blockchain, such as a Bitcoin chain, an Ethereum chain, a Hyperledger Fabric blockchain (hereinafter referred to as a Fabric chain), and the like.
  • a Fabric chain uses the endorsement node signature method
  • the Ethereum chain uses the Spv proof method.
  • Different blockchains also have different data formats. For example, the data in the block of the Fabric chain has the rotobuf format, and the data in the block of the Ethereum chain has the rlp format.
  • the cross-chain data (eg receipt m in Figure 1) were to be verified by the message receiving contract in the second blockchain 13 as in the prior art, it would be necessary to include multiple verification algorithms for Different proof methods are used for verification, and in addition, multiple parsing methods need to be included to parse data in different formats, and this makes the contract verification efficiency in the second blockchain 13 very low.
  • the data is verified and parsed by a relay device including an oracle machine, so that the verification efficiency in the second blockchain 13 can be greatly accelerated.
  • the relay device 12 can obtain the receipt m and the corresponding Spv from the first blockchain 11 Proof data, where m is the receipt number. After obtaining the receipt m and the Spv proof data, the relay device 12 performs the following steps in the oracle machine: verifies the receipt m through the Spv verification method, after the verification is passed, extracts the data of the message 1 from the receipt m, and converts the message 1 Convert the data format of the message 1 into a contract-friendly data format, and then digitally sign the data of the format-converted message 1.
  • the relay device sends transaction n to the second blockchain 13, and the message receiving contract is called in the transaction n, and the data of message 1 and its digital signature are used as the incoming parameters of the message receiving contract.
  • the digital signature of the data of the message 1 is verified using the public key of the oracle machine pre-written in the message receiving contract.
  • the message 1 is parsed from the data of the message 1.
  • the fourth contract is called with the message 1 as an incoming parameter, thereby passing the message 1 to the fourth contract.
  • the fourth contract increases the balance of the account B in the second blockchain 13 by the amount corresponding to the predetermined number according to the content of the message 1, thereby completing the transfer process.
  • the oracle may have various known forms, not limited to the form of TEE.
  • the first contract and the fourth contract are not limited to contracts for transfer, but may be other contracts.
  • Fig. 2 is a flow chart of a method for relaying messages across chains based on a relay device, the relay device is connected to a first blockchain and a second blockchain, and the relay device includes an oracle, the method Executed by the relay device, including: step S202, obtaining the first data and its certification data from the first blockchain, wherein the first data includes first message data, the first The message data includes the receiving chain identifier of the first message data; step S204, the oracle machine uses the proof data to verify the first data; step S206, in the case of passing the verification, the oracle The computer digitally signs the first message data; step S208, determining the receiving chain of the first message data as the second blockchain based on the first message data; and step S210, converting the first message data and its digital signature is provided to the second blockchain.
  • the relay device in the embodiment of this specification includes an oracle, and the oracle refers to a system that can self-certify its data processing process to ensure that its data processing is authentic and credible or device.
  • the oracle may be, for example, a Trusted Execution Environment (TEE), which is, for example, a TEE generated by technologies such as SGX and Trust Zone.
  • TEE Trusted Execution Environment
  • Any desired party (such as the first blockchain or the second blockchain) can send a verification request to verify the processing of the TEE.
  • the TEE After receiving the verification request, the TEE generates authentication information based on its internal mechanism, and sends the authentication information to the request sender for verification.
  • the authentication information includes, for example, signature information, hardware information, software information, and the like of the TEE.
  • the signature information is generated by, for example, the hardware key of the TEE; the hardware information includes, for example, various hardware indicators, such as CPU frequency, memory capacity, etc.; the software information includes the code hash value of each program , code name, version, run log, etc.
  • a TEE can perform "measurements" of a program running in it through memory hardware, such as obtaining a code hash of the program, a hash of the program's memory occupancy at a particular point of execution, etc.
  • the authentication information includes "measurement" information for the program, which is authentic and credible because the "measurement" information is executed by the TEE's own entity (memory hardware) without involving any software or operating system.
  • the verification request sender can verify the TEE by itself based on the authentication information received from the TEE, or can send the authentication information to the TEE service party to obtain the authentication information through the TEE service party. Verification of the TEE, so that it can be determined whether the TEE is authentic, whether a predetermined program is executed in the TEE, and so on.
  • the oracle machine is not limited to being a TEE, but can be any system or device that complies with the above-mentioned oracle machine function.
  • the oracle may be a relay chain, which includes multiple relay nodes, each relay node has its private key and public key, and each relay node performs the same process on the same data.
  • the multiple relay nodes digitally sign the same results in turn, so as to ensure the data The processing results are credible.
  • TEE as an example of the oracle.
  • step S202 the first data and its certification data are obtained from the first blockchain, wherein the first data includes first message data, and the first message data includes the first message Receive chain identifier for message data.
  • the first blockchain will be described as an example of the Ethereum chain. It can be understood that in the embodiments of this specification, the first blockchain is not limited to the Ethereum chain, but can be any other type of blockchain. blockchain.
  • the first data is, for example, transactions in the block, receipts, or account status, etc.
  • the commonality of these data is that they are all stored in the first block after the consensus of multiple nodes in the first blockchain.
  • the chain and based on the data structure of the block, it can be verified that these data are indeed the data in the first blockchain through the Spv verification method, that is, the first data is verifiable data, that is, the data included in the first data Cross-chain messages are authenticated messages.
  • the message 1 that needs to be sent across the chain can be stored in the blockchain in the form of a receipt m through a message sending contract.
  • the receipt m is a receipt deposited by the transaction that invokes the message sending contract. Therefore, the receipt m includes, for example, a log corresponding to the message sending contract as shown in FIG. 3 .
  • Figure 3 shows a schematic diagram of the log generated after executing the message sending contract.
  • the log (Log) has a predetermined topic (Topic), for example, the topic may be preset as “AM” to indicate that the log is a log for sending messages outside the chain.
  • a "To" field, a "From” field and a "Data” field are included in the log.
  • message 1 may include the following fields: sending chain identifier (ie, the identifier of the first blockchain 11 ), receiving chain identifier (ie, the identifier of the second blockchain 13 ), sending account (ie, account A), receiving account (ie account B), the receiving contract account (ie the account of the fourth contract) and the message content of message 1 (ie the first message).
  • the content corresponding to the above Data field is the data constituting the message 1, which is stored in the blockchain in a predetermined format (such as the rlp format in Ethereum).
  • a predetermined format such as the rlp format in Ethereum.
  • the data used to perform the Spv verification on the first data is the proof data of the first data.
  • the first data is receipt m in block 1
  • the Spv proof data of receipt m includes: the block header hash value of block 1, the root hash value of the receipt tree included in block 1, and the data from the receipt tree in the receipt tree.
  • the relay device 12 can monitor the receipt corresponding to the message sending contract, and whenever it is determined that the receipt generated by the execution of the message sending contract is stored in the first blockchain 11, it can be sent from the first blockchain 11 , and read the receipt's Spv proof data accordingly.
  • the first blockchain 11 can actively push the information, and each time it is determined that the first blockchain 11 stores the receipt generated by the execution of the message sending contract, the receipt and the corresponding Spv proof data are actively pushed to the relay device 12.
  • the first data is not limited to the consensus data stored in the blockchain for executing the message sending contract
  • messages can be sent across chains through any transaction, that is, the first data can be consensus data deposited into the blockchain by executing any transaction.
  • step S204 the first data is verified by the oracle machine using the proof data.
  • the TEE of the relay device 12 is preset with a verification algorithm corresponding to each blockchain.
  • an Spv verification algorithm corresponding to the first blockchain 11 is preset in the TEE, and the Spv verification algorithm includes code and data required for performing Spv verification on data from the first blockchain.
  • the relay device determines that the first data (eg receipt m) comes from the first blockchain 11, it can execute the Spv verification algorithm corresponding to the first blockchain 11 to verify the first data using the Spv proof data.
  • the receipt m obtained by the relay device 12 can be verified by the following steps: calculating the hash value of the obtained receipt m; based on the hash value of each other node in the tree path included in the Spv proof data , calculate the root hash value of the receipt tree in block 1; compare the calculated root hash value with the root hash value of the receipt tree of block 1 included in the Spv proof data to determine whether the receipt m is a block Receipt m in 1; and, based on the Spv proof data including the block header hash value of block 1 and the relevant information of the genesis block of the first blockchain 11 preset in the Spv verification algorithm (for example, the genesis block Hash value) to determine whether block 1 is a block in the first blockchain 11.
  • step S206 if the verification is passed, the first message data is digitally signed by the oracle machine.
  • the receipt m is the receipt m in the block 1 in the first blockchain 11, and is the trusted data through consensus.
  • the TEE in the case where the first data is the above-mentioned receipt m, after the verification is passed, based on the data structure in the receipt m, the TEE can find the log with the subject "AM" from the receipt m, and obtain the log The content of the Data field included in the message 1 is used as the data of the message 1. Then, the TEE uses its private key to digitally sign the data of the message 1, so that the digital signature is used as the proof data of the data of the message 1.
  • the data of message 1 after the TEE obtains the data of message 1 from receipt m, the data of message 1 has the rlp format in the Ethereum chain, which is relatively complex and the parsing process is slow.
  • TEE can use the preset program for format conversion to format the data of message 1, for example, convert its format into contract-friendly data formats such as Json, tlv, etc. After converting the format, digitally sign the data of message 1.
  • the TEE After processing the receipt m, the TEE outputs the data of the message 1 and the digital signature corresponding to the data, wherein the data of the message 1 may be format-converted data.
  • step S208 it is determined based on the first message data that the receiving chain of the first message data is the second blockchain.
  • the relay device 1 After the relay device 1 obtains the receipt m from the first blockchain 11, referring to FIG. 3, it can search for the log for storing the message 1 from the receipt m based on a predetermined identifier (for example, "AM"), and find the log when the log is found. After that, read message 1 from this log. By reading the message 1, based on the content of the receiving chain identification field in the message 1, it can be determined that the receiving chain of the message 1 is the second blockchain 13.
  • a predetermined identifier for example, "AM”
  • step S210 the first message data and its digital signature are provided to the second blockchain.
  • the relay device 12 can determine that the message 1 will be sent to the second blockchain, so that the relay device 12
  • the data of message 1 and its digital signature can be provided to the second blockchain by sending transaction n to the second blockchain.
  • the message receiving contract is called with the data of message 1 and its digital signature as incoming parameters.
  • the transaction n is not limited to providing the data of the message 1 and its digital signature by invoking the message receiving contract, but can be in other forms, as long as there is a specific identifier in the transaction n indicating the data of the message 1 and its digital signature. It is sufficient to instruct the second blockchain 13 to use the digital signature to verify the data of the message 1 for the cross-chain message data and its proof data.
  • Fig. 4 shows a method for receiving messages across chains based on a relay device according to an embodiment of the present specification
  • the relay device is connected with the first blockchain and the second blockchain, and in the relay device Including an oracle machine, the method is performed by a second blockchain, and the second blockchain is pre-stored with the public key of the oracle machine, the method includes, including: Step S402, from the relay device Obtain the first message data and the digital signature of the oracle machine on the first message data, wherein the first message data is obtained from the first blockchain by the relay device; Step S404, using the The digital signature is verified by the public key of the oracle machine; and step S406, after the verification is passed, the first message is obtained by parsing the first message data.
  • step S402 first message data and the digital signature of the oracle machine on the first message data are obtained from the relay device, wherein the first message data is obtained by the relay device from the The first blockchain acquisition.
  • the method shown in FIG. 4 can be executed by any node in the second blockchain 13 .
  • each node in the second blockchain 13 will obtain the transaction n and execute the transaction n, thereby executing the message receiving contract to Perform the method shown in Figure 4.
  • the message receiving contract is executed, the data of message 1 and its digital signature, which is the incoming parameter of the contract, will be obtained from transaction n.
  • transaction n is not limited to invoking the message receiving contract. Therefore, when executing transaction n, it is not limited to executing the method shown in FIG. 4 by executing the message receiving contract.
  • step S404 the digital signature is verified using the public key of the oracle machine.
  • the public key of the above-mentioned TEE is preset in the message receiving contract, and the nodes in the second blockchain 13 use the TEE's public key to verify the digital signature in the incoming parameters when executing the message receiving contract.
  • the specific process of the verification is to calculate the hash value of the message 1, use the public key of the TEE to parse and decrypt the digital signature of the message 1, and compare whether the hash value of the message 1 is the same as the value obtained by the decryption, and if they are the same, It means that the digital signature is indeed a digital signature generated by the private key of the TEE, that is, the data of the message 1 received from the relay device 12 is authentic.
  • the verification process will be much simpler compared to the process of performing, for example, Spv proof through contracts in the prior art.
  • the public key of the oracle includes the public keys of each node in the relay chain
  • the digital signature of message 1 includes the digital signature of each node in the relay chain, so that the digital signature is verified. Including, sequentially verifying each digital signature using each public key in a predetermined order.
  • step S406 after the verification is passed, the first message is obtained by parsing the first message data.
  • a parsing program is also preset in the message receiving contract to parse the data of message 1.
  • the relay device 12 converts the format of the data of the message 1 to, for example, the Json format, so that only the parsing program for the Json format needs to be preset in the message receiving contract, without the need for
  • multiple parsing programs corresponding to various data formats are preset, which greatly reduces the program codes included in the message receiving contract.
  • the Json format is a contract-friendly format, the message receiving contract only needs to parse the Json format, which greatly speeds up data parsing.
  • the message 1 includes its receiving account (for example, the account of the fourth contract), and the message receiving contract includes the code for calling the receiving account contract, so that in the process of executing the message receiving contract, the message 1 is obtained by parsing After that, the account of the fourth contract is obtained from the message 1, and the fourth contract is called with the message 1 as the incoming parameter, so that the message 1 is delivered to the receiving account (that is, the account of the fourth contract).
  • the message receiving contract includes the code for calling the receiving account contract, so that in the process of executing the message receiving contract, the message 1 is obtained by parsing After that, the account of the fourth contract is obtained from the message 1, and the fourth contract is called with the message 1 as the incoming parameter, so that the message 1 is delivered to the receiving account (that is, the account of the fourth contract).
  • FIG. 5 shows an apparatus 500 for relaying messages across chains based on a relay device according to an embodiment of the present specification
  • the relay device is connected to the first blockchain and the second blockchain, and the relay device is It includes an oracle machine, the apparatus is deployed on the relay device, and includes: an acquisition unit 51, configured to acquire the first data and its certification data from the first blockchain, wherein the first data includes the first message data, the first message data includes the receiving chain identifier of the first message data; the verification unit 52 is configured to use the proof data by the oracle to verify the first data; signature;
  • the unit 53 is configured to, in the case of passing the verification, digitally sign the first message data by the oracle machine;
  • the determining unit 54 is configured to determine the first message data based on the first message data
  • the receiving chain is a second blockchain; and a providing unit 55 is configured to provide the first message data and its digital signature to the second blockchain.
  • the signature unit 53 is further configured to, in the case of passing the verification, convert the format of the first message data into a predetermined format, and digitally sign the first message data with the predetermined format.
  • a verification algorithm corresponding to the certification data is preset in the trusted execution environment, wherein the verification unit 52 is further configured to use the certification data by executing the verification algorithm Verify the first data.
  • FIG. 6 shows an apparatus 600 for receiving messages across chains based on a relay device according to an embodiment of the present specification
  • the relay device is connected to the first blockchain and the second blockchain, and the relay device is It includes an oracle, the device is deployed in the second blockchain, and the public key of the oracle is pre-stored in the second blockchain, and the device includes: an acquisition unit 61, configured to: obtaining, by the relay device, first message data and a digital signature of the oracle machine on the first message data, wherein the first message data is obtained by the relay device from the first blockchain;
  • the verification unit 62 is configured to use the public key of the oracle machine to verify the digital signature; and the parsing unit 63 is configured to, after the verification is passed, parse and obtain the first message from the first message data .
  • the apparatus is deployed when a first transaction sent by the relay device is executed in the second blockchain, wherein in the first transaction, the first message and its The message receiving contract is called with the digital signature as an incoming parameter.
  • the apparatus 600 further includes a determining unit 64 configured to, based on the content of the first message, determine that the receiving account of the first message is the contract account of the first smart contract, and a calling unit 65. Configure to call the first smart contract with the first message as an incoming parameter.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, when the computer program is executed in a computer, the computer is made to execute any one of the above methods.
  • Another aspect of the present specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and the processor implements any one of the above methods when executing the computer program.
  • the message verification is performed on the relay device, thereby converting the message verification into a simple verification method, improving the verification efficiency of the message by the blockchain that receives the message, and in addition , in the embodiment of this specification, the data format of the message is converted into a data format friendly to the contract in the relay device, which further improves the efficiency of contract parsing data.
  • a software module can be placed in random access memory (RAM), internal memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other in the technical field. in any other known form of storage medium.
  • RAM random access memory
  • ROM read only memory
  • electrically programmable ROM electrically erasable programmable ROM
  • registers hard disk, removable disk, CD-ROM, or any other in the technical field. in any other known form of storage medium.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • General Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Finance (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Computer And Data Communications (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

本说明书实施例提供一种基于中继设备跨链中转消息的方法和装置,所述中继设备中包括预言机,所述方法由所述中继设备执行,包括:从第一区块链获取所述第一数据及其证明数据,其中,所述第一数据中包括第一消息数据;由所述预言机使用所述证明数据对所述第一数据进行验证;在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名;基于所述第一消息数据确定所述第一消息数据的接收链为第二区块链;以及将所述第一消息数据及对其的数字签名提供给所述第二区块链。

Description

一种基于中继设备跨链中转消息的方法和装置 技术领域
本说明书实施例涉及区块链技术领域,更具体地,涉及一种基于中继设备跨链中转消息的方法和装置。
背景技术
区块链技术也被称之为分布式账本技术,是一种去中心化的分布式数据库技术,其特点是去中心化、公开透明、不可篡改、可信任。区块链的每笔交易,都会广播到全网的区块链节点,每个全节点都有全量的、一致的数据。随着区块链技术的火热,出现了许多不同类型的链,应用在金融、健康医疗、供应链、资产管理和溯源等领域。然而大部分链上应用(加密货币或者智能合约)都无法跨越当前链的边界,不能与其他链协同合作实现价值的流通,从而限制了区块链的发挥空间。如何能让不同类型的链协同合作实现价值的流通成了探索的方向。
在现有的一种跨链技术中,在第一区块链中将跨链消息写入区块链的收据,链下的中继设备从第一区块链获取收据,将收据提供给第二区块链。假设第一区块链中通过简单支付验证(Spv验证)方式对收据进行验证,从而,第二区块链中可通过调用与Spv验证对应的消息验证合约,从而以Spv验证的方式对所述收据进行验证,在验证通过之后,可从收据中取出跨链消息并提供给消息接收账户。在该方案中,第二区块链对收据的验证过程复杂,效率低下。
因此,需要一种更有效的跨链中转消息的方案。
发明内容
本说明书实施例旨在提供一种更有效的跨链中转消息的方案,以解决现有技术中的不足。
为实现上述目的,本说明书一个方面提供一种基于中继设备跨链中转消息的方法,所述中继设备与第一区块链和第二区块链连接,并且所述中继设备中包括预言机,所述方法由所述中继设备执行,包括:从第一区块链获取所述第一数据及其证明数据,其中,所述第一数据中包括第一消息数据,所述第一消息数据中包括该第一消息数据的接收链 标识;由所述预言机使用所述证明数据对所述第一数据进行验证;在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名;基于所述第一消息数据确定所述第一消息数据的接收链为第二区块链;以及将所述第一消息数据及对其的数字签名提供给所述第二区块链。
在一种实施方式中,在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名包括,在验证通过的情况中,由所述预言机将所述第一消息数据的格式转换为预定格式,由所述预言机对具有预定格式的第一消息数据进行数字签名。
在一种实施方式中,所述预言机为可信执行环境。
在一种实施方式中,所述可信执行环境中预先设置有与所述证明数据对应的验证算法,其中,使用所述证明数据对所述第一数据进行验证包括,通过执行所述验证算法,使用所述证明数据对所述第一数据进行验证。
在一种实施方式中,所述证明数据为Spv证明数据。
在一种实施方式中,所述预言机为中继链,所述中继链包括多个中继节点,其中,所述数字签名包括每个中继节点的数字签名。
在一种实施方式中,所述第一数据为所述第一区块链中的以下任一种数据:区块头数据、交易数据、收据数据、账户状态数据。
本说明书另一方面提供一种基于中继设备跨链接收消息的方法,所述中继设备与第一区块链和第二区块链连接,并且,所述中继设备中包括预言机,所述方法由第二区块链执行,所述第二区块链中预先存储有所述预言机的公钥,所述方法包括:从所述中继设备获取第一消息数据及所述预言机对所述第一消息数据的数字签名,其中,所述第一消息数据由所述中继设备从所述第一区块链获取;使用所述预言机的公钥对所述数字签名进行验证;以及在验证通过之后,从所述第一消息数据解析获取所述第一消息。
在一种实施方式中,所述方法在第二区块链中执行由所述中继设备发送的第一交易时执行,其中,在所述第一交易中,以所述第一消息及其数字签名作为传入参数调用消息接收合约。
在一种实施方式中,所述方法还包括,基于所述第一消息内容,确定所述第一消息的接收账户为第一智能合约的合约账户,以所述第一消息作为传入参数调用所述第一智能合约。
本说明书另一方面提供一种基于中继设备跨链中转消息的装置,所述中继设备与第一区块链和第二区块链连接,并且所述中继设备中包括预言机,所述装置部署于所述中继设备,包括:获取单元,配置为,从第一区块链获取所述第一数据及其证明数据,其中,所述第一数据中包括第一消息数据,所述第一消息数据中包括该第一消息数据的接收链标识;验证单元,配置为,由所述预言机使用所述证明数据对所述第一数据进行验证;签名单元,配置为,在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名;确定单元,配置为,基于所述第一消息数据确定所述第一消息数据的接收链为第二区块链;以及提供单元,配置为,将所述第一消息数据及对其的数字签名提供给所述第二区块链。
在一种实施方式中,所述签名单元还配置为,在验证通过的情况中,将所述第一消息数据的格式转换为预定格式,对具有预定格式的第一消息数据进行数字签名。
在一种实施方式中,所述可信执行环境中预先设置有与所述证明数据对应的验证算法,其中,所述验证单元还配置为,通过执行所述验证算法,使用所述证明数据对所述第一数据进行验证。
本说明书另一方面提供一种基于中继设备跨链接收消息的装置,所述中继设备与第一区块链和第二区块链连接,并且所述中继设备中包括预言机,所述装置部署于所述第二区块链中,所述第二区块链中预先存储有所述预言机的公钥,所述装置包括:获取单元,配置为,从所述中继设备获取第一消息数据及所述预言机对所述第一消息数据的数字签名,其中,所述第一消息数据由所述中继设备从所述第一区块链获取;验证单元,配置为,使用所述预言机的公钥对所述数字签名进行验证;以及解析单元,配置为,在验证通过之后,从所述第一消息数据解析获取所述第一消息。
在一种实施方式中,所述装置在第二区块链中执行由所述中继设备发送的第一交易时部署,其中,在所述第一交易中,以所述第一消息及其数字签名作为传入参数调用消息接收合约。
在一种实施方式中,所述装置还包括,确定单元,配置为,基于所述第一消息内容,确定所述第一消息的接收账户为第一智能合约的合约账户,以及调用单元,配置为,以所述第一消息作为传入参数调用所述第一智能合约。
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述任一项方法。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述任一项方法。
通过根据本说明书实施例的跨链中转消息的方案,在中继设备进行对消息的验证,从而将消息验证转化为简单的验证方式,提升了接收消息的区块链对消息的验证效率,另外,在本说明书实施例中,在中继设备将消息的数据格式转换为对合约友好的数据格式,进一步提升了合约解析数据的效率。
附图说明
通过结合附图描述本说明书实施例,可以使得本说明书实施例更加清楚:
图1示出根据本说明书实施例的跨链系统的示意图;
图2示出根据本说明书实施例的一种跨链中转消息的方法流程图;
图3示出了在执行消息发送合约之后生成的日志的示意图;
图4示出根据本说明书实施例的一种跨链接收消息的方法流程图;
图5示出根据本说明书实施例的一种跨链中转消息的装置500;
图6示出根据本说明书实施例的一种跨链接收消息的装置600。
具体实施方式
下面将结合附图描述本说明书实施例。
图1示出根据本说明书实施例的跨链系统的示意图。如图1所示,所述跨链系统包括第一区块链11、中继设备12和第二区块链13,其中,第一区块链11和第二区块链13分别与中继设备12连接。其中,第一区块链11中部署有第一合约和消息发送合约,第二区块链13中部署有消息接收合约和第四合约,中继设备12中包括预言机,预言机具有多种形式,例如其为可信执行环境(TEE),该TEE具有自身的硬件私钥和公钥。其中,所述第一合约和第四合约例如为用于进行跨链转账的合约。第一区块链11中的账户A例如希望给第二区块链13中的账户B进行转账,账户A通过发送调用第一合约的交易而发起转账。当在第一区块链11中执行在该交易时,执行第一合约,从而对账户A的余额减去转账的数目,并执行第一合约中调用的消息发送合约,从而在第一区块链中存入例如收据m,收据m中包括待发送给第二区块链13中的第四合约的消息1。该消息1中例如包括该消息1的发送链标识、接收链(第二区块链13)标识、发送账户、接收账户(账户B)、接收合约账户(第四合约账户)及对账户B的余额增加的数目等 内容。
第一区块链11和第二区块链13可以为任意区块链,如比特币链、以太坊链、Hyperledger Fabric区块链(下文称为Fabric链)等等。不同的区块链具有不同的链上数据证明方式,例如,Fabric链使用背书节点签名的方式,以太坊链使用Spv证明的方式。不同的区块链也具有不同的数据格式,例如,Fabric链的区块中的数据具有rotobuf格式,以太坊链的区块中的数据具有rlp格式。在这种情况下,如果如现有技术那样由第二区块链13中的消息接收合约对跨链数据(例如图1中的收据m)进行验证,将需要包括多种验证算法,以针对不同的证明方式进行验证,另外,也需要包括多种解析方式,以对不同格式的数据进行解析,并且这使得第二区块链13中的合约验证效率非常低。为了克服该问题,在本说明书实施例中,通过包括预言机的中继设备对数据进行验证和解析,从而可大大加快第二区块链13中的验证效率。
具体是,假设第一区块链为以太坊链,在第一区块链11中存入收据m之后,中继设备12可从第一区块链11中获取所述收据m及对应的Spv证明数据,其中m为收据编号。中继设备12在获取收据m和Spv证明数据之后,在预言机中执行以下步骤:通过Spv验证方式对收据m进行验证,在验证通过之后,从收据m中取出消息1的数据,将消息1的数据格式转换为对合约友好的数据格式,然后,对经格式转换的消息1的数据进行数字签名。之后,中继设备向第二区块链13中发送交易n,该交易n中调用消息接收合约,并以消息1的数据及其数字签名作为消息接收合约的传入参数。当第二区块链13中的节点执行交易n时,也即在执行消息接收合约时,使用消息接收合约中预先写入的预言机的公钥对消息1的数据的数字签名进行验证,在验证通过之后,从消息1的数据解析出消息1。之后,基于消息1中的接收合约账户(即第四合约的合约账户),以消息1作为传入参数调用第四合约,从而将消息1传递给第四合约。第四合约在接收到消息1之后,根据消息1的内容将第二区块链13中的账户B的余额增加与预定数目对应的数目,从而完成所述转账过程。
可以理解,上述参考图1的描述只是示意性的,而不是用于限制本说明书实施例。例如,所述预言机可具有已知的各种形式,而不限于TEE的形式。所述第一合约和第四合约不限于为用于转账的合约,而可以为其它合约。
下面将具体描述上述跨链中转消息的过程。
图2一种基于中继设备跨链中转消息的方法流程图,所述中继设备与第一区块链和第二区块链连接,并且所述中继设备中包括预言机,所述方法由所述中继设备执行,包 括:步骤S202,从所述第一区块链获取所述第一数据及其证明数据,其中,所述第一数据中包括第一消息数据,所述第一消息数据中包括该第一消息数据的接收链标识;步骤S204,由所述预言机使用所述证明数据对所述第一数据进行验证;步骤S206,在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名;步骤S208,基于所述第一消息数据确定所述第一消息数据的接收链为第二区块链;以及步骤S210,将所述第一消息数据及对其的数字签名提供给所述第二区块链。
如图1中所示,本说明书实施例中的中继设备中包括预言机,所述预言机是指对其对数据的处理过程可进行自证明以确保其对数据的处理真实可信的系统或装置。所述预言机例如可以为可信计算环境(Trusted Execution Environment,TEE),其例如为通过SGX、Trust Zone等技术生成的TEE。任何需要的一方(例如第一区块链或第二区块链)都可以发送验证请求以对TEE的处理过程进行验证。TEE在接收所述验证请求之后,基于其内部机制生成认证信息,并将该认证信息发送给请求发送方以供其验证。所述认证信息例如包括所述TEE的签名信息、硬件信息和软件信息等。其中,所述签名信息例如通过TEE的硬件密钥生成;所述硬件信息例如包括,各种硬件的指标,比如CPU主频,内存容量等等;所述软件信息包括各个程序的代码哈希值、代码名称、版本、运行日志等。如本领域技术人员所知,TEE可通过内存硬件执行对其中运行程序的“测量”,例如获取该程序的代码哈希值、该程序在特定执行点的内存占有的哈希值等等,并在所述认证信息中包括对所述程序的“测量”信息,由于该“测量”信息由该TEE自身实体(内存硬件)执行,而不涉及任何软件、操作系统,因此是真实可信的。从而验证请求发送方在从TEE接收到认证信息之后,可自身基于从TEE接收的认证信息进行对TEE的验证,或者可将所述认证信息发送给TEE服务方,以通过TEE的服务方获取对该TEE的验证,从而可确定该TEE是否可信,该TEE中是否执行了预定程序,等等。
可以理解,所述预言机不限于为TEE,而可以为任意符合上述预言机功能的系统或装置。例如,所述预言机可以为中继链,该中继链中包括多个中继节点,每个中继节点拥有其私钥和公钥,每个中继节点都对相同的数据进行同样的处理过程,只有在所述多个中继节点达成共识(即确定其对数据的处理结果是一致的)时,所述多个中继节点对相同的结果依次进行数字签名,从而可确保该数据处理结果是可信的。
下文中将以TEE作为预言机的实例进行描述。
首先,在步骤S202,从所述第一区块链获取所述第一数据及其证明数据,其中,所述第一数据中包括第一消息数据,所述第一消息数据中包括该第一消息数据的接收链标 识。
下文中将以第一区块链为以太坊链例进行示例描述,可以理解,在本说明书实施例中,所述第一区块链不限于为以太坊链,而可以为其它任意类型的区块链。所述第一数据例如为区块中的交易、收据,或者为账户状态等等,这些数据的共性为,其都在第一区块链中经过多个节点的共识之后存入第一区块链中,并且,基于区块的数据结构,可通过Spv验证方式验证这些数据确实是第一区块链中的数据,即,第一数据为可认证数据,也即,第一数据中包括的跨链消息是可认证消息。
如图1中所示,在第一区块链中11,可通过消息发送合约将需要跨链发送的消息1以收据m的形式存入区块链中。该收据m为执行调用消息发送合约的交易所存入的收据,从而,该收据m中例如包括如图3所示的与消息发送合约对应的日志。图3示出了在执行消息发送合约之后生成的日志的示意图。如图3所示,该日志(Log)具有预定主题(Topic),例如该主题可以预设为“AM”,以用于指示该日志是用于对链外发送消息的日志。在该日志中包括“To”字段,“From”字段和“Data”字段。其中,“To”字段对应于被调用合约的账户,也即消息发送合约的账户,“From”字段对应于发起调用的合约的账户,也即第一合约的账户,“Data”字段中即第一合约希望跨链发送的消息。其中,消息1可包括以下字段内容:发送链标识(即第一区块链11的标识)、接收链标识(即第二区块链13的标识)、发送账户(即账户A)、接收账户(即账户B)、接收合约账户(即第四合约的账户)及消息1(即第一消息)的消息内容。上述Data字段对应的内容即构成消息1的数据,其以预定格式(如以太坊中的rlp格式存入区块链中)。可以理解,在本说明书实施例中,由于第一数据不限于为上述收据m,也可以为与其它交易相对应的收据,因此,第一数据中的第一消息不限于为上述收据m中的消息1的具体形式,例如,所述第一消息也可以为第一数据自身,或者可以为第一数据中包括的具有预定标识的部分数据,对此不作限定。
在以太坊链中,用于对第一数据进行Spv验证的数据即为第一数据的证明数据。例如,第一数据为区块1中的收据m,收据m的Spv证明数据包括:区块1的区块头哈希值、区块1中包括的收据树根哈希值、收据树中从收据m到根节点的树路径中其它各个节点的哈希值。
从而,中继设备12可对与消息发送合约对应的收据进行监听,每当确定第一区块链11中存入了执行消息发送合约所产生的收据时,即可从第一区块链11中读取该收据,并相应地读取该收据的Spv证明数据。或者,第一区块链11中可主动进行信息推送, 每次在确定第一区块链11中存入了执行消息发送合约所产生的收据时,将该收据及相应的Spv证明数据主动推送给中继设备12。可以理解,在本说明书实施例中,不限于通过调用消息发送合约的方式来跨链发送消息,即,所述第一数据不限于为执行消息发送合约所存入区块链中的共识数据,而是可通过任何交易来跨链发送消息,即,所述第一数据可以为执行任何交易所存入区块链中的共识数据。
在步骤S204,由所述预言机使用所述证明数据对所述第一数据进行验证。
如上文所述,以预言机为TEE为例,中继设备12的TEE中预先设置了与各个区块链分别对应的验证算法。例如,TEE中预设了与第一区块链11对应的Spv验证算法,该Spv验证算法中包括用于对来自第一区块链的数据进行Spv验证所需要的代码及数据等。当中继设备确定第一数据(例如收据m)来自于第一区块链11之后,即可执行与第一区块链11对应的Spv验证算法来使用Spv证明数据对第一数据进行验证。
具体是,在预言机中可通过如下步骤对中继设备12获取的收据m进行验证:计算获取的收据m的哈希值;基于Spv证明数据中包括的树路径中其它各节点的哈希值,计算区块1中收据树的根哈希值;将计算的根哈希值与Spv证明数据中包括的区块1的收据树的根哈希值进行比较,以确定收据m是否为区块1中的收据m;以及,基于Spv证明数据中包括区块1的区块头哈希值、以及Spv验证算法中预先设置的第一区块链11的创世块的相关信息(例如创世块的哈希值),确定区块1是否为第一区块链11中的区块。
在步骤S206,在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名。
在上述验证都通过的情况中,即可验证收据m是第一区块链11中的区块1中的收据m,是经共识的可信数据。
在一种实施方式中,在第一数据为上述收据m的情况中,在验证通过之后,基于收据m中的数据结构,TEE可从收据m中找到具有“AM”主题的日志,获取该日志中包括的Data字段内容作为消息1的数据,然后,TEE使用其私钥对该消息1的数据进行数字签名,从而以该数字签名作为消息1的数据的证明数据。
在一种实施方式中,在TEE从收据m中获取消息1的数据之后,该消息1的数据具有以太坊链中的rlp格式,该格式较为复杂,解析过程较慢,为了进一步加速第二区块链13的消息验证过程,TEE可使用预设的用于进行格式转换的程序对消息1的数据 进行格式转换,例如,将其格式转换为对合约友好的Json、tlv等数据格式,并在转换格式之后,对消息1的数据进行数字签名。
如果上述验证未通过,则证明中继设备12获取的收据m是不可信数据。TEE将停止后续处理过程。
TEE在对收据m进行处理之后,输出消息1的数据及与该数据对应的数字签名,其中,该消息1的数据可以为经格式转换的数据。
在步骤S208,基于所述第一消息数据确定所述第一消息数据的接收链为第二区块链。
中继设备1在从第一区块链11获取收据m之后,参考图3,可基于预定标识(例如“AM”)从收据m中查找用于存储消息1的日志,并在查找到该日志之后,从该日志中读取消息1。通过读取消息1,基于消息1中的接收链标识字段内容,可确定消息1的接收链为第二区块链13。
在步骤S210,将所述第一消息数据及对其的数字签名提供给所述第二区块链。
如图1中所示,中继设备12在获取消息1的数据及其数字签名之后,基于消息1的消息内容,可确定该消息1将发送给第二区块链,从而,中继设备12可通过向第二区块链发送交易n的方式将消息1的数据及其数字签名提供给第二区块链。该交易n中例如以消息1的数据及其数字签名为传入参数调用消息接收合约。可以理解,所述交易n不限于通过调用消息接收合约的方式来提供消息1的数据及其数字签名,而可以为具有其它形式,只要交易n中有特定标识指示消息1的数据及其数字签名为跨链消息数据及其证明数据,从而指示第二区块链13使用数字签名对消息1的数据进行验证即可。
图4示出根据本说明书实施例的一种基于中继设备跨链接收消息的方法,所述中继设备与第一区块链和第二区块链连接,并且,所述中继设备中包括预言机,所述方法由第二区块链执行,所述第二区块链中预先存储有所述预言机的公钥,所述方法包括,包括:步骤S402,从所述中继设备获取第一消息数据及所述预言机对所述第一消息数据的数字签名,其中,所述第一消息数据由所述中继设备从所述第一区块链获取;步骤S404,使用所述预言机的公钥对所述数字签名进行验证;以及步骤S406,在验证通过之后,从所述第一消息数据解析获取所述第一消息。
首先,在步骤S402,从所述中继设备获取第一消息数据及所述预言机对所述第一消息数据的数字签名,其中,所述第一消息数据由所述中继设备从所述第一区块链获取。
图4所示方法可由第二区块链13中的任一节点执行。如上文所述,在中继设备12 向第二区块链13发送交易n之后,第二区块链13中的每个节点都会获取交易n并执行交易n,从而将执行消息接收合约,以执行图4所示方法。在执行消息接收合约时,将从交易n获取其中的作为合约传入参数的消息1的数据及其数字签名。可以理解,如上文所述,交易n不限于调用消息接收合约,因此,在执行交易n时,不限于通过执行消息接收合约来执行图4所示方法。
在步骤S404,使用所述预言机的公钥对所述数字签名进行验证。
消息接收合约中预先设置了上述TEE的公钥,第二区块链13中的节点在执行消息接收合约时,使用TEE的公钥对传入参数中的数字签名进行验证。所述验证的具体过程为,计算消息1的哈希值,使用TEE的公钥对消息1的数字签名解析解密,比较消息1的哈希值与所述解密获取的值是否相同,如果相同,则说明所述数字签名确实是通过TEE的私钥生成的数字签名,即从中继设备12接收的消息1的数据是真实可信的。该验证过程相比于现有技术中的在通过合约进行例如Spv证明的过程将简单得多。
在上述预言机为中继链的情况中,预言机的公钥包括中继链中各个节点的公钥,消息1的数字签名包括中继链各个节点的数字签名,从而,对数字签名进行验证包括,按照预定顺序,使用各个公钥对各个数字签名依次验证。
在步骤S406,在验证通过之后,从所述第一消息数据解析获取所述第一消息。
在上述验证通过之后,消息接收合约中还预设了解析程序,用于对消息1的数据进行解析。在一种实施方式中,如上文所述,中继设备12将消息1的数据的格式转换为例如Json格式,从而在消息接收合约中只需要预设用于Json格式的解析程序,而不需要如现有技术那样预设与各种数据格式分别对应的多种解析程序,这样大大减少了消息接收合约包括的程序代码。并且,由于Json格式为对合约友好的格式,消息接收合约只需要对Json格式进行解析,也大大加快了数据解析速度。
如上文所述,消息1中包括其接收账户(例如第四合约的账户),该消息接收合约中包括调用接收账户合约的代码,从而,在执行消息接收合约的过程中,在解析获取消息1之后,从消息1中获取第四合约的账户,并以消息1为传入参数调用第四合约,从而将消息1传递给接收账户(即第四合约的账户)。
图5示出根据本说明书实施例的一种基于中继设备跨链中转消息的装置500,所述中继设备与第一区块链和第二区块链连接,并且所述中继设备中包括预言机,所述装置部署于所述中继设备,包括:获取单元51,配置为,从第一区块链获取所述第一数据及 其证明数据,其中,所述第一数据中包括第一消息数据,所述第一消息数据中包括该第一消息数据的接收链标识;验证单元52,配置为,由所述预言机使用所述证明数据对所述第一数据进行验证;签名单元53,配置为,在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名;确定单元54,配置为,基于所述第一消息数据确定所述第一消息数据的接收链为第二区块链;以及提供单元55,配置为,将所述第一消息数据及对其的数字签名提供给所述第二区块链。
在一种实施方式中,所述签名单元53还配置为,在验证通过的情况中,将所述第一消息数据的格式转换为预定格式,对具有预定格式的第一消息数据进行数字签名。
在一种实施方式中,所述可信执行环境中预先设置有与所述证明数据对应的验证算法,其中,所述验证单元52还配置为,通过执行所述验证算法,使用所述证明数据对所述第一数据进行验证。
图6示出根据本说明书实施例的一种基于中继设备跨链接收消息的装置600,所述中继设备与第一区块链和第二区块链连接,并且所述中继设备中包括预言机,所述装置部署于所述第二区块链中,所述第二区块链中预先存储有所述预言机的公钥,所述装置包括:获取单元61,配置为,从所述中继设备获取第一消息数据及所述预言机对所述第一消息数据的数字签名,其中,所述第一消息数据由所述中继设备从所述第一区块链获取;验证单元62,配置为,使用所述预言机的公钥对所述数字签名进行验证;以及解析单元63,配置为,在验证通过之后,从所述第一消息数据解析获取所述第一消息。
在一种实施方式中,所述装置在第二区块链中执行由所述中继设备发送的第一交易时部署,其中,在所述第一交易中,以所述第一消息及其数字签名作为传入参数调用消息接收合约。
在一种实施方式中,所述装置600还包括,确定单元64,配置为,基于所述第一消息内容,确定所述第一消息的接收账户为第一智能合约的合约账户,以及调用单元65,配置为,以所述第一消息作为传入参数调用所述第一智能合约。
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述任一项方法。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述任一项方法。
通过根据本说明书实施例的跨链中转消息的方案,在中继设备进行对消息的验证, 从而将消息验证转化为简单的验证方式,提升了接收消息的区块链对消息的验证效率,另外,在本说明书实施例中,在中继设备将消息的数据格式转换为对合约友好的数据格式,进一步提升了合约解析数据的效率。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
本领域普通技术人员应该还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执轨道,取决于技术方案的特定应用和设计约束条件。本领域普通技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
结合本文中所公开的实施例描述的方法或算法的步骤可以用硬件、处理器执轨道的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。
以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (22)

  1. 一种基于中继设备跨链中转消息的方法,所述中继设备与第一区块链和第二区块链连接,并且所述中继设备中包括预言机,所述方法由所述中继设备执行,包括:
    从第一区块链获取所述第一数据及其证明数据,其中,所述第一数据中包括第一消息数据,所述第一消息数据中包括该第一消息数据的接收链标识;
    由所述预言机使用所述证明数据对所述第一数据进行验证;
    在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名;
    基于所述第一消息数据确定所述第一消息数据的接收链为第二区块链;以及
    将所述第一消息数据及对其的数字签名提供给所述第二区块链。
  2. 根据权利要求1所述的方法,其中,在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名包括,在验证通过的情况中,由所述预言机将所述第一消息数据的格式转换为预定格式,以及由所述预言机对具有预定格式的第一消息数据进行数字签名。
  3. 根据权利要求1所述的方法,其中,所述预言机为可信执行环境。
  4. 根据权利要求3所述的方法,所述可信执行环境中预先设置有与所述证明数据对应的验证算法,其中,使用所述证明数据对所述第一数据进行验证包括,通过执行所述验证算法,使用所述证明数据对所述第一数据进行验证。
  5. 根据权利要求1所述的方法,其中,所述证明数据为Spv证明数据。
  6. 根据权利要求1所述的方法,其中,所述预言机为中继链,所述中继链包括多个中继节点,其中,所述数字签名包括每个中继节点的数字签名。
  7. 根据权利要求1所述的方法,所述第一数据为所述第一区块链中的以下任一种数据:区块头数据、交易数据、收据数据、账户状态数据。
  8. 一种基于中继设备跨链接收消息的方法,所述中继设备与第一区块链和第二区块链连接,并且,所述中继设备中包括预言机,所述方法由第二区块链执行,所述第二区块链中预先存储有所述预言机的公钥,所述方法包括:
    从所述中继设备获取第一消息数据及所述预言机对所述第一消息数据的数字签名,其中,所述第一消息数据由所述中继设备从所述第一区块链获取;
    使用所述预言机的公钥对所述数字签名进行验证;以及
    在验证通过之后,从所述第一消息数据解析获取所述第一消息。
  9. 根据权利要求8所述的方法,其中,所述方法在第二区块链中执行由所述中继设备发送的第一交易时执行,其中,在所述第一交易中,以所述第一消息及其数字签名作 为传入参数调用消息接收合约。
  10. 根据权利要求8所述的方法,还包括,基于所述第一消息内容,确定所述第一消息的接收账户为第一智能合约的合约账户,以所述第一消息作为传入参数调用所述第一智能合约。
  11. 一种基于中继设备跨链中转消息的装置,所述中继设备与第一区块链和第二区块链连接,并且所述中继设备中包括预言机,所述装置部署于所述中继设备,包括:
    获取单元,配置为,从第一区块链获取所述第一数据及其证明数据,其中,所述第一数据中包括第一消息数据,所述第一消息数据中包括该第一消息数据的接收链标识;
    验证单元,配置为,由所述预言机使用所述证明数据对所述第一数据进行验证;
    签名单元,配置为,在验证通过的情况中,由所述预言机对所述第一消息数据进行数字签名;
    确定单元,配置为,基于所述第一消息数据确定所述第一消息数据的接收链为第二区块链;以及
    提供单元,配置为,将所述第一消息数据及对其的数字签名提供给所述第二区块链。
  12. 根据权利要求11所述的装置,其中,所述签名单元还配置为,在验证通过的情况中,由所述预言机将所述第一消息数据的格式转换为预定格式,并由所述预言机对具有预定格式的第一消息数据进行数字签名。
  13. 根据权利要求11所述的装置,其中,所述预言机为可信执行环境。
  14. 根据权利要求13所述的装置,所述可信执行环境中预先设置有与所述证明数据对应的验证算法,其中,所述验证单元还配置为,通过执行所述验证算法,使用所述证明数据对所述第一数据进行验证。
  15. 根据权利要求11所述的装置,其中,所述证明数据为Spv证明数据。
  16. 根据权利要求11所述的装置,其中,所述预言机为中继链,所述中继链包括多个中继节点,其中,所述数字签名包括每个中继节点的数字签名。
  17. 根据权利要求11所述的装置,所述第一数据为所述第一区块链中的以下任一种数据:区块头数据、交易数据、收据数据、账户状态数据。
  18. 一种基于中继设备跨链接收消息的装置,所述中继设备与第一区块链和第二区块链连接,并且所述中继设备中包括预言机,所述装置部署于所述第二区块链中,所述第二区块链中预先存储有所述预言机的公钥,所述装置包括:
    获取单元,配置为,从所述中继设备获取第一消息数据及所述预言机对所述第一消息数据的数字签名,其中,所述第一消息数据由所述中继设备从所述第一区块链获取;
    验证单元,配置为,使用所述预言机的公钥对所述数字签名进行验证;以及
    解析单元,配置为,在验证通过之后,从所述第一消息数据解析获取所述第一消息。
  19. 根据权利要求18所述的装置,其中,所述装置在第二区块链中执行由所述中继设备发送的第一交易时部署,其中,在所述第一交易中,以所述第一消息及其数字签名作为传入参数调用消息接收合约。
  20. 根据权利要求18所述的装置,还包括,确定单元,配置为,基于所述第一消息内容,确定所述第一消息的接收账户为第一智能合约的合约账户,以及调用单元,配置为,以所述第一消息作为传入参数调用所述第一智能合约。
  21. 一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行权利要求1-10中任一项的所述的方法。
  22. 一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现权利要求1-10中任一项所述的方法。
PCT/CN2021/133012 2021-03-30 2021-11-25 一种基于中继设备跨链中转消息的方法和装置 WO2022205957A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110339689.0 2021-03-30
CN202110339689.0A CN112804066A (zh) 2021-03-30 2021-03-30 一种基于中继设备跨链中转消息的方法和装置

Publications (1)

Publication Number Publication Date
WO2022205957A1 true WO2022205957A1 (zh) 2022-10-06

Family

ID=75815974

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/133012 WO2022205957A1 (zh) 2021-03-30 2021-11-25 一种基于中继设备跨链中转消息的方法和装置

Country Status (2)

Country Link
CN (1) CN112804066A (zh)
WO (1) WO2022205957A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112804066A (zh) * 2021-03-30 2021-05-14 支付宝(杭州)信息技术有限公司 一种基于中继设备跨链中转消息的方法和装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110430235A (zh) * 2019-06-28 2019-11-08 阿里巴巴集团控股有限公司 基于处理模块跨链发送可认证消息的方法和装置
CN111130800A (zh) * 2019-12-25 2020-05-08 上海沄界信息科技有限公司 一种基于tee的可信预言机实现方法及装置
CN111769957A (zh) * 2020-09-02 2020-10-13 百度在线网络技术(北京)有限公司 区块链跨链查询方法、装置、设备和存储介质
WO2020258846A1 (zh) * 2019-06-28 2020-12-30 创新先进技术有限公司 一种跨链发送可认证消息的方法和装置
CN112804066A (zh) * 2021-03-30 2021-05-14 支付宝(杭州)信息技术有限公司 一种基于中继设备跨链中转消息的方法和装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008686B (zh) * 2018-11-16 2020-12-04 创新先进技术有限公司 跨区块链的数据处理方法、装置、客户端、区块链系统
CN110311790B (zh) * 2019-06-28 2020-07-28 阿里巴巴集团控股有限公司 一种跨链发送可认证消息的方法和装置
CN111445328A (zh) * 2020-03-16 2020-07-24 西安交通大学 一种跨链网关交互系统和方法以及供应链数据管理方法
CN112398853B (zh) * 2020-11-16 2023-04-18 东软集团股份有限公司 一种实现联盟链跨链通信的方法、装置及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110430235A (zh) * 2019-06-28 2019-11-08 阿里巴巴集团控股有限公司 基于处理模块跨链发送可认证消息的方法和装置
WO2020258846A1 (zh) * 2019-06-28 2020-12-30 创新先进技术有限公司 一种跨链发送可认证消息的方法和装置
CN111130800A (zh) * 2019-12-25 2020-05-08 上海沄界信息科技有限公司 一种基于tee的可信预言机实现方法及装置
CN111769957A (zh) * 2020-09-02 2020-10-13 百度在线网络技术(北京)有限公司 区块链跨链查询方法、装置、设备和存储介质
CN112804066A (zh) * 2021-03-30 2021-05-14 支付宝(杭州)信息技术有限公司 一种基于中继设备跨链中转消息的方法和装置

Also Published As

Publication number Publication date
CN112804066A (zh) 2021-05-14

Similar Documents

Publication Publication Date Title
US11842317B2 (en) Blockchain-based authentication and authorization
WO2022205958A1 (zh) 一种基于中继设备网络跨链中转数据的方法和装置
US11949789B2 (en) Blockchain-enabled computing
WO2022095244A1 (zh) 跨链交易方法、系统、装置、设备和存储介质
US7698736B2 (en) Secure delegation using public key authentication
US20210304201A1 (en) Transaction verification method and apparatus, storage medium, and electronic device
US10924281B2 (en) Method and apparatus for inter-blockchain transmission of authenticable message
KR20200096790A (ko) 증명 검증에 기초하여 오프-체인 데이터를 인증하기 위한 시스템 및 방법
WO2020258912A1 (zh) 一种区块链共识方法、装置和系统
US20050138384A1 (en) Attesting to platform configuration
CN112508563B (zh) 跨链交易可信验证方法、装置及计算机设备
JP2024505692A (ja) ブロックチェーンネットワークに基づくデータ処理方法、装置及びコンピュータ機器
CN113095827A (zh) 匿名多重签名方法、计算机设备和存储介质
CN110597836B (zh) 基于区块链网络的信息查询请求响应方法及装置
CN111640018B (zh) 一种区块链交易存在性验证方法及装置
KR101849920B1 (ko) 머클 트리 구조를 사용하여 m of n 다중 서명에 의한 인증서 서비스를 제공하는 방법 및 이를 이용한 서버
KR101890584B1 (ko) m of n 다중 서명에 의한 인증서 서비스를 제공하는 방법 및 이를 이용한 서버
WO2022057106A1 (zh) 数字资产数据包的可信性验证系统
WO2022205957A1 (zh) 一种基于中继设备跨链中转消息的方法和装置
WO2022205960A1 (zh) 跨链数据处理方法和装置
CN114172923B (zh) 数据传输方法、通信系统及通信装置
CN113112269B (zh) 多重签名方法、计算机设备和存储介质
CN112163917B (zh) 基于区块链的票据处理方法、装置、介质及电子设备
Wang et al. Analysis and Design of Identity Authentication for IoT Devices in the Blockchain Using Hashing and Digital Signature Algorithms
KR20180040857A (ko) 머클 트리 구조를 사용하여 m of n 다중 서명에 의한 인증서 서비스를 제공하는 방법 및 이를 이용한 서버

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21934593

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21934593

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 21934593

Country of ref document: EP

Kind code of ref document: A1