The application is a divisional application of an invention patent application with the application number of 202110339804.4, which is filed on 30.3.2021 and is named as a method and a device for transferring data across links based on a relay device network.
Disclosure of Invention
The embodiments of the present disclosure aim to provide a more effective scheme for transferring data across links, so as to solve the deficiencies in the prior art.
In order to achieve the above object, an aspect of the present specification provides a method for transferring data across a link based on a relay device network, where the relay device network includes a first relay device and a second relay device, the first relay device is connected to a first block chain and stores a lookup table, the lookup table records block chains to which a predetermined number of relay devices are respectively connected, a connection address of the predetermined number of relay devices is also recorded in the first relay device, and the second relay device is connected to a second block chain, where the method is executed by the first relay device, and the method includes:
acquiring cross-chain data from the first block chain, wherein the cross-chain data comprises a receiving chain identifier of the cross-chain data;
determining a receive chain of the cross-chain data to be a second blockchain based on the cross-chain data;
determining whether a local connection is made with the second blockchain;
in an instance in which it is determined that the second blockchain is not locally connected, transmitting the cross-link data to at least one relay device of the predetermined number of relay devices for transmitting the cross-link data to the second relay device based on the lookup table.
In one embodiment, the second relay device is included in the predetermined number of relay devices, wherein transmitting the cross-link data to at least one relay device of the predetermined number of relay devices based on the lookup table includes transmitting the cross-link data to the second relay device based on the lookup table.
In one embodiment, the second relay device is not included in the predetermined number of relay devices, wherein transmitting the cross-link data to at least one relay device of the predetermined number of relay devices based on the lookup table includes transmitting the cross-link data to a third relay device of the predetermined number of relay devices based on the lookup table for transmitting the cross-link data to the second relay device.
In one embodiment, the method further comprises, in the event that a local connection to the second blockchain is determined, providing the cross-chain data to the second blockchain.
In one embodiment, the cross-chain data includes the first data and its attestation data.
In one embodiment, the first data is any one of the following data in the first block chain: transaction data, receipt data, account status data, block header data.
Another aspect of the present specification provides a method for transferring a message across a link based on a relay device network, where the relay device network includes a first relay device and a second relay device, the first relay device is connected to a first blockchain, and stores a lookup table, where the lookup table records blockchains to which a predetermined number of relay devices are respectively connected, and the first relay device also records connection addresses of the predetermined number of relay devices, and the first relay device includes a talker, and the second relay device is connected to a second blockchain, where the method is performed by the first relay device, and includes:
acquiring first data and certification data thereof from the first block chain, wherein the first data comprises first message data, and the first message data comprises a receiving chain identifier of the first message data;
verifying, by the prophetic machine, the first data using the attestation data;
in the case of passing the verification, digitally signing the first message data by the predicting machine;
determining a receive chain of the first message data to be a second block chain based on the first message data;
determining whether a local connection is made with the second blockchain;
in an instance in which it is determined that the second blockchain is not locally connected, sending the first message data and the digital signature therefor to at least one relay device of a predetermined number of relay devices based on the lookup table for sending the first message data and the digital signature therefor to the second relay device.
In one embodiment, digitally signing the first message data in the event of verification pass includes, in the event of verification pass, converting the format of the first message data to a predetermined format, digitally signing the first message data having the predetermined format.
Another aspect of the present specification provides an apparatus for transferring data across links based on a relay device network, where the relay device network includes a first relay device and a second relay device, the first relay device is connected to a first blockchain and stores a lookup table, the lookup table records blockchains to which a predetermined number of relay devices are respectively connected, the first relay device also records connection addresses of the predetermined number of relay devices, the second relay device is connected to a second blockchain, and the apparatus is deployed in the first relay device, and includes:
an obtaining unit, configured to obtain cross-chain data from the first blockchain, where the cross-chain data includes a receive chain identifier of the cross-chain data;
a first determining unit configured to determine, based on the cross-chain data, that a receive chain of the cross-chain data is a second blockchain;
a second determining unit configured to determine whether the second blockchain is locally connected;
a transmitting unit configured to transmit the cross-link data to at least one relay device of the predetermined number of relay devices based on the lookup table for transmitting the cross-link data to the second relay device in a case where it is determined that the second blockchain is not locally connected.
In an embodiment, the second relay device is included in the predetermined number of relay devices, and the transmitting unit is further configured to transmit the cross-link data to the second relay device based on the lookup table.
In one embodiment, the second relay device is not included in the predetermined number of relay devices, and the transmitting unit is further configured to transmit the chain cross data to a third relay device of the predetermined number of relay devices based on the look-up table, so as to transmit the chain cross data to the second relay device.
Another aspect of the present specification provides an apparatus for transferring a message across a chain based on a relay device network, where the relay device network includes a first relay device and a second relay device, the first relay device is connected to a first blockchain, and stores a lookup table, where the lookup table records blockchains to which a predetermined number of relay devices are respectively connected, and the first relay device also records connection addresses of the predetermined number of relay devices, and the first relay device includes a predictive engine, and the second relay device is connected to a second blockchain, where the apparatus is deployed in the first relay device, and the apparatus includes:
an obtaining unit, configured to obtain first data and certification data thereof from the first blockchain, where the first data includes first message data, and the first message data includes a receive chain identifier of the first message data;
a verification unit configured to verify, by the predictive machine, the first data using the attestation data;
a signature unit configured to digitally sign the first message data by the predicting machine in case of passing the verification;
a first determining unit configured to determine, based on the first message data, that a receive chain of the first message data is a second block chain;
a second determining unit configured to determine whether the second blockchain is locally connected;
a sending unit configured to send the first message data and the digital signature thereto to at least one relay device of a predetermined number of relay devices based on the lookup table for sending the first message data and the digital signature thereto to the second relay device in case it is determined that the second blockchain is not locally connected.
In one embodiment, the signing unit includes a conversion subunit configured to convert the format of the first message data into a predetermined format in case of passing the verification, and a signing subunit configured to digitally sign the first message data having the predetermined format.
Another aspect of the present specification provides a computer readable storage medium having stored thereon a computer program or instructions which, when executed in a computer, cause the computer to perform any of the above methods.
Another aspect of the present specification provides a computing device comprising a memory having stored therein a computer program or instructions, and a processor that, when executed, implements any of the above methods.
By the scheme of forwarding the message in the cross-link according to the embodiment of the present specification, the relay device network supporting the routing can be implemented under the link of the blockchain, so that a cross-link network topology can be formed based on the relay device network, and the cross-link network topology supports large-scale cross-link network connection.
Detailed Description
The embodiments of the present specification will be described below with reference to the accompanying drawings.
FIG. 1 shows a schematic diagram of a cross-chain system in accordance with an embodiment of the present description. As shown in fig. 1, the inter-chain system includes a first block chain 11, a relay device network 12, and a second block chain 13. Wherein, the relay device network 12 includes a plurality of relay devices having a predetermined connection relationship, fig. 1 only schematically illustrates the first relay device 121 and the second relay device 122, wherein clouds shown by dotted lines indicate that the first relay device 121 and the second relay device 122 may be directly connected or may be connected through other relay devices. Each relay device in the relay device network 12 is connected to at least one blockchain, and each relay device stores therein a lookup table that records correspondence between a predetermined number of relay devices and the blockchains to which it is connected, so that the relay device network can be connected to more blockchains through the plurality of relay devices in the relay device network 12. Fig. 1 schematically shows that the first block chain 11 is connected to a first relay device 121 and the second block chain 13 is connected to a second relay device 122.
The first block chain 11 has a first contract and a message sending contract deployed therein, and the second block chain 13 has a message receiving contract and a fourth contract deployed therein. Wherein the first contract and the fourth contract are for example contracts for performing a cross-chain transfer. Account a in the first blockchain 11 wishes to transfer, for example, to account B in the second blockchain 13, account a initiating the transfer by sending a transaction invoking the first contract. When executing the transaction in the first blockchain 11, a first contract is executed whereby the balance of the account a is subtracted by the number of transfers and a messaging contract invoked in the first contract is executed whereby e.g. a receipt m is deposited in the first blockchain, where m is the receipt number and the receipt m includes a message to be sent to a fourth contract in the second blockchain 13. The message includes, for example, the transmission chain (first block chain 11) identifier, the reception chain (second block chain 13) identifier, the reception contract (fourth contract) account, the transmission account (account a), the reception account (account B), the number of balance increases for account B, and the like of the message.
Assuming that the first blockchain is an ethernet blockchain, after the receipt m is stored in the first blockchain 11, the first relay device 121 may obtain the receipt m and corresponding simple payment verification (Spv) certification data from the first blockchain 11. The first relay device 121 may determine that the receive chain of the message is the second blockchain 13 based on the content of the message in the receipt m, the first relay device 121 determines whether it is connected to the second blockchain 13, and if connected to the second blockchain 13, the first relay device 121 may directly provide the receipt m and its Spv attestation data to the second blockchain 13 (in this case not shown in fig. 1). If the first relay device 121 determines that it is not connected to the second blockchain 13, a routing path to the second blockchain 13 may be determined by reading the lookup table, as shown in fig. 1, so that the first relay device 121 may send the receipt m and its Spv certification data into the relay device network 12 for eventual transmission to the second relay device 122.
The second relay device 122, after receiving the receipt m and its Spv certification data, may send a transaction n to the second blockchain 13, where n is the transaction number, in which a message receipt contract is invoked with the receipt m and its Spv certification number as incoming parameters. When a node in the second blockchain 13 executes a transaction n, i.e. when executing a message receipt contract, the receipt m is verified using Spv attestation data to verify whether the receipt m is indeed a receipt in the first blockchain 11. After the verification is passed, the message is parsed from its data. Thereafter, based on the received contract account in the message (i.e., the contract account for the fourth contract), the fourth contract is invoked with the message as an incoming argument, passing the message to the fourth contract. The fourth contract, after receiving the message, increases the balance of the account B in the second blockchain 13 by an amount corresponding to the predetermined amount according to the content of the message, thereby completing the transfer process.
It will be appreciated that the above description with reference to fig. 1 is intended to be illustrative only and is not intended to limit the scope of embodiments of the present description. For example, the relay apparatus is not limited to the form shown in fig. 1, the first contract and the fourth contract are not limited to contracts for transfer, and so on.
The above process of transferring data across links will be described in detail below.
Fig. 2 is a flowchart illustrating a method for transferring data across a link based on a relay device network according to an embodiment of the present disclosure, where the relay device network includes a first relay device and a second relay device, the first relay device is connected to a first block chain and stores a lookup table, the lookup table records block chains to which a predetermined number of relay devices are respectively connected, connection addresses of the predetermined number of relay devices are also recorded in the first relay device, and the second relay device is connected to a second block chain, where the method is performed by the first relay device, and the method includes:
step S202, cross-chain data is obtained from the first block chain, and the cross-chain data comprises a receiving chain identifier of the cross-chain data;
step S204, determining a receiving chain of the cross-chain data as a second block chain based on the cross-chain data;
step S206, determining whether the local area is connected with the second block chain;
step S208, in a case that it is determined that the local area is not connected to the second blockchain, sending the cross-link data to at least one relay device of the predetermined number of relay devices based on the lookup table, so as to send the cross-link data to the second relay device.
In the embodiment of the present disclosure, the first blockchain 11 and the second blockchain 13 may be any blockchain, such as bitcoin chain, ethernet chain, superhedger Fabric blockchain (hereinafter referred to as Fabric chain), and so on. Different blockchains have different ways of data attestation on the chain, e.g., Fabric chain uses endorsement node signatures, ether house chain uses Spv attestation. The first block chain 11 will be described as an example of an ether house chain. The first relay apparatus is, for example, the first relay apparatus 121 shown in fig. 1. The second relay device is, for example, the second relay device 122 in fig. 1.
First, in step S202, cross-chain data is obtained from the first blockchain, where the cross-chain data includes a receive chain identifier of the cross-chain data.
The cross-link data may be any data that the first blockchain wishes to be sent to other chains (e.g., the second blockchain) across the chain, and the cross-link data includes the receive chain identification thereof for use in routing the send path during sending. For example, the cross-chain data may be the first data and its attestation data. The first data is, for example, a transaction, a receipt, or an account status in a block, and the like, and the common property of these data is that they are all stored in the first blockchain after being identified by multiple nodes in the first blockchain, and based on the data structure of the block, it can be verified by Spv verification that these data are indeed data in the first blockchain, that is, the first data is authenticable data, and for example, the first blockchain includes a cross-chain message that the first blockchain wishes to send across chains, that is, the cross-chain message included in the first data is an authenticable message.
As shown in fig. 1, in a first blockchain 11, messages that need to be sent across the chain may be deposited in the blockchain in the form of receipts m by a messaging contract. The receipt m is a receipt deposited for a transaction that executed a call to a message-sending contract, and thus, for example, a log corresponding to the message-sending contract as shown in fig. 3 is included in the receipt m. FIG. 3 shows a schematic diagram of a log generated after executing a messaging contract. As shown in fig. 3, the Log (Log) has a predetermined Topic (Topic), for example, the Topic may be preset to "AM" for indicating that the Log is a Log for out-of-chain sent messages. In the log, a "To" field, a "From" field, and a "Data" field are included. Where the "To" field corresponds To the account of the invoked contract, i.e., the account of the messaging contract, the "From" field corresponds To the account of the contract initiating the invocation, i.e., the account of the first contract, and the "Data" field, i.e., the message that the first contract wishes To send across the chain. Wherein, the message may include the following field contents: a transmit chain identification (i.e., identification of the first blockchain 11), a receive chain identification (i.e., identification of the second blockchain 13), a transmit account (i.e., account a), a receive account (i.e., account B), a receive contract (fourth contract) account, and message content of the message. The content corresponding to the Data field is the Data constituting the message, which is stored in a predetermined format (e.g., rlp format in etherhouses) in the block chain. It is to be understood that, in the embodiment of the present specification, since the first data is not limited to the receipt m described above, the message in the first data is not limited to the specific form of the message in the receipt m described above, and for example, the message may also be the first data itself, or may be partial data with a predetermined identifier included in the first data, which is not limited thereto.
In the ether house chain, the data for Spv verification of the first data is the certification data of the first data. For example, the first data is a receipt m in block 1, and Spv certification data of the receipt m includes: a chunk header hash value of chunk 1, a receipt tree root hash value included in chunk 1, hash values of other respective nodes in a tree path from the receipt m to the root node in the receipt tree.
Thus, the first relay device 121 can listen for a receipt corresponding to the message transmission contract, and each time it is determined that a receipt generated by executing the message transmission contract is stored in the first block chain 11, the receipt can be read from the first block chain 11, and Spv certification data of the receipt can be read accordingly. Or, the first blockchain 11 may actively push information, and each time a receipt generated by executing a message sending contract is determined to be stored in the first blockchain 11, the receipt and corresponding Spv certification data are actively pushed to the first relay device 121. It will be appreciated that in embodiments of the present description, the message is not limited to being sent across chains by invoking a messaging contract, i.e. the first data is not limited to consensus data deposited into a blockchain for executing a messaging contract, but may be sent across chains by any transaction, i.e. the first data may be consensus data deposited into a blockchain for executing any transaction.
In step S204, it is determined that the receive chain of the cross-chain data is the second blockchain based on the cross-chain data.
Since the receive chain identification is included in the cross-chain data, the receive chain of the cross-chain data can be determined by reading the receive chain identification in the cross-chain data. For example, after acquiring the receipt m from the first blockchain 11, referring to fig. 3, the first relay device 121 may search a log for storing a message from the receipt m based on a predetermined identifier (e.g., "AM"), and read the message from the log after searching the log. By reading the message, the receive chain of the message may be determined to be the second blockchain 13 based on the receive chain identification field content in the message.
In step S206, it is determined whether the second blockchain is locally connected.
As described above, the first relay device 121 is connected to a predetermined number of block chains, and the first relay device 121 locally records a data table as shown in table 1 in which connection addresses of the block chains connected thereto are recorded.
TABLE 1
Block chain ID
|
Connection ofAddress
|
Block chain ID1
|
IP Address 1, Port/IP Address 2, Port/…
|
Block chain ID2
|
IP Address 3, Port/IP Address 4, Port/…
|
…
|
… |
In table 1, the block chain ID on the left side is an identifier of each block chain to which the first relay device 121 is connected, and the connection address on the right side is a connection address of at least one node in the corresponding block chain.
The first relay apparatus 121 can determine whether or not the block chain identification (block chain ID) of the second block chain 13 is recorded in table 1 by referring to table 1, and if so, can connect the node corresponding to the connection address in the second block chain 13 based on any one of the connection addresses corresponding to the second block chain 13 in table 1. If the block chain ID of the second block chain 13 is not recorded in table 1, it indicates that the first relay device 121 is not directly connected to the second block chain 13, and thus needs to establish a connection with the second block chain through the relay of the down-link relay device as described below.
In step S208, in the case that it is determined that the second blockchain is not locally connected, the cross-link data is sent to at least one relay device of the predetermined number of relay devices based on the lookup table for sending the cross-link data to the second relay device.
In one embodiment, the number of relay devices and blockchains is small, so that the correspondence between all relay devices and their respective connected blockchains can be recorded in one look-up table. Thus, the same look-up table may be stored in each relay device in the network of relay devices. Table 2 schematically shows a look-up table according to this embodiment.
TABLE 2
Assuming that the blockchain identification of the second blockchain 13 is blockchain ID2 in table 2, the first relay device 121, after looking up table 2, may determine that the second blockchain 13 is connected to the second relay device 122. The first relay device 121 may further record the connection address of each relay device in table 2, or the first relay device 121 may record the connection address of each relay device in another table, so that the first relay device 121 may obtain the connection address of the second relay device 122 from the local after determining that the second blockchain 13 is connected to the second relay device 122, and connect the second relay device 122, thereby transmitting the receipt m and Spv certification data thereof to the second relay device 122.
In one embodiment, the number of blockchains is large, as well as the number of relay devices in the relay device network, in which case each relay device is not necessarily connected to each of the other relay devices in the relay device network, e.g., the first relay device 121 is not directly connected to the second relay device 122, and thus the first relay device 121 needs to be indirectly connected to the second relay device 122 through the relay of the other relay devices. That is, each relay apparatus is connected only to a predetermined number of relay apparatuses in the relay apparatus network, and only the connection relationship between the relay apparatus to which the relay apparatus is connected and the block chain is recorded in the lookup table stored in each relay apparatus, and therefore, the lookup tables of the respective relay apparatuses are different tables. Assuming that the first relay device 121 is connected with the relay device ID3 and the relay device ID4, and the relay device ID3 is connected with the second relay device 122 and the relay device ID5, table 3 schematically shows a lookup table in the first relay device 121 according to this embodiment. Table 4 schematically shows a lookup table in the relay device ID3 according to this embodiment:
TABLE 3
TABLE 4
The first relay device 121, after reading the local lookup table (table 3), may transmit the receipt m and its Spv certification data to at least one relay device connected thereto based on a predetermined routing algorithm, thereby finally transmitting the receipt m and its Spv certification data to the second relay device 122 through relay of other relay devices in the relay device network.
For example, tables 3 and 4 may be distributed hash tables (DHT tables), in this case, the relay device IDs and the blockchain IDs in tables 3 and 4 may be isomorphic, for example, each relay device ID is a different first value obtained by hashing each relay device number, the plurality of first values form a plurality of uniform value ranges, each blockchain ID is a different second value obtained by hashing a blockchain domain name, the plurality of second values are distributed in the plurality of value ranges, and it is determined, based on the distributed value ranges, to which relay device the blockchain corresponding to the blockchain ID is connected. For example, if the relay device ID of the second relay device 122 is the relay device ID2, the block chain corresponding to the block chain ID distributed in the predetermined range centered on the relay device ID2 is determined as being connected to the second relay device 122. Thus, the first relay device 121 can calculate a routing path based on the DHT algorithm so that the receipt m and Spv thereof are transmitted to the second relay device 122 with the least number of relay times.
For example, referring to table 3 and table 4, it may be determined that the routing path relay ID3 → relay ID2 is the optimal path, and thus, the first relay device 121 transmits the receipt m and Spv thereof to the relay ID3 based on the connection address of the relay ID3 stored locally. Relay ID3, after parsing receipt m, determines that the receive chain of the message therein is second blockchain 13, relay ID3 determines that its connected second relay 122 is connected to second blockchain 13 by looking up its local look-up table (table 4), and relay ID3 sends receipt m and its Spv directly to second relay 122.
Fig. 4 is a flowchart illustrating a method for transferring data across a link based on a relay device network according to an embodiment of the present disclosure, where the relay device network includes a second relay device, the second relay device is connected to a second blockchain, and the relay device network is connected to a first blockchain, and the method is performed by the second relay device, and includes:
step S402, receiving cross-link data from the relay device network, where the cross-link data is obtained from the first blockchain by the relay device network, and the cross-link data includes a receive link identifier of the cross-link data;
step S404, determining a receiving chain of the cross-chain data as a second block chain based on the cross-chain data;
step S406, providing the cross-chain data to the second blockchain.
First, in step S402, cross-link data is received from the relay device network, where the cross-link data is obtained from the first blockchain by the relay device network, and the cross-link data includes a receive-link identifier of the cross-link data.
Referring to the above description, based on different forms of the lookup table of the relay device in the relay device network or different connection relationships of the respective relay devices in the relay device network, the second relay device 122 may be directly connected with the first relay device 121 so as to receive the cross-link data from the first relay device 121, or the second relay device 122 may not be directly connected with the first relay device 121 but connected with the first relay device 121 through at least one other relay device (e.g., relay device ID3), so that the second relay device 122 may receive the cross-link data from the relay device ID3 in the relay device network.
Step S404 may refer to the above description of step S204, and is not described herein again.
In step S406, the cross-chain data is provided to the second blockchain.
As shown in fig. 1, second relay device 122, after receiving the cross-link data, may determine that the message is to be sent to second blockchain 13 based on the message content of the message therein. Second relay device 122 may determine from a locally stored data table similar to table 1 that the second blockchain 13 is locally connected to, and may retrieve the connection address of the second blockchain 13 from, the data table, and thus, as shown in fig. 1, second relay device 122 may provide cross-chain data to second blockchain 13 by sending transaction n to second blockchain 13 in which a message receipt contract is invoked with receipt m and its Spv attestation data as incoming parameters. It will be appreciated that the transaction n is not limited to providing cross-chain data to the second blockchain 13 by invoking a message receipt contract, but may have other forms as long as there is a specific identifier in the transaction n indicating that the data therein includes cross-chain data, thereby indicating that the second blockchain 13 receives the cross-chain data.
Fig. 5 is a flowchart illustrating a method for transferring a message across a link based on a network of relay devices according to another embodiment of the present specification, where the network of relay devices includes a first relay device and a second relay device, the first relay device is connected to a first blockchain, and stores a lookup table, where the lookup table records blockchains to which a predetermined number of relay devices are respectively connected, connection addresses of the predetermined number of relay devices are also recorded in the first relay device, and the first relay device includes a talker, and the second relay device is connected to a second blockchain, where the method is performed by the first relay device and includes:
step S502, obtaining first data and certification data thereof from the first blockchain, where the first data includes first message data, and the first message data includes a receive chain identifier of the first message data;
step S504, the dialer uses the certification data to verify the first data;
step S506, in the case of passing the verification, the predicting machine carries out digital signature on the first message data;
step S508, determining a receive chain of the first message data as a second block chain based on the first message data;
step S510, determining whether the local area is connected to the second blockchain;
step S512, in a case that it is determined that the second blockchain is not locally connected, sending the first message data and the digital signature thereto to at least one relay device of a predetermined number of relay devices based on the lookup table, for sending the first message data and the digital signature thereto to the second relay device.
In this embodiment, unlike the relay device shown in fig. 1, a prolog machine is included in each relay device in the relay device network, and the prolog machine refers to a system or a device for which the processing procedure of data can be self-certified to ensure that the processing of data is authentic and credible. The prediction machine may be, for example, a Trusted Execution Environment (TEE), which is, for example, a TEE generated by SGX, Trust Zone, or the like. Any party that needs, such as the first blockchain or the second blockchain, may send a verification request to verify the handling of the TEE. The TEE, after receiving the verification request, generates authentication information based on its internal mechanism and sends the authentication information to the requesting sender for verification. The authentication information includes, for example, signature information, hardware information, software information, and the like of the TEE. Wherein the signature information is generated, for example, by a hardware key of the TEE; the hardware information includes, for example, indicators of various hardware, such as CPU host frequency, memory capacity, and the like; the software information includes a code hash value, a code name, a version, an operation log, etc. of each program. As known to those skilled in the art, a TEE may perform a "measurement" of the program running therein through memory hardware, such as obtaining a code hash value of the program, a hash value of the memory occupancy of the program at a particular execution point, etc., and include in the authentication information "measurement" information for the program, which is authentic because the "measurement" information is executed by the TEE's own entity (memory hardware) without involving any software, operating system, etc. Thus, the authentication request sender may, after receiving the authentication information from the TEE, itself perform authentication of the TEE based on the authentication information received from the TEE, or may send the authentication information to the TEE server to obtain authentication of the TEE by the TEE server, so that it can be determined whether the TEE is authentic, whether a predetermined procedure is performed in the TEE, and so on.
It will be appreciated that the propheter is not limited to being a TEE, but may be any system or device that conforms to the functions of the propheter described above. For example, the oracle may be a relay chain, where the relay chain includes a plurality of relay nodes, each relay node possesses its private key and public key, each relay node performs the same processing procedure on the same data, and only when the relay nodes agree (that is, it is determined that the processing results of the data are consistent), the relay nodes digitally sign the same results in turn, so as to ensure that the data processing results are authentic.
TEE will be described below as an example of a prophetic machine.
In the method according to this embodiment, step S502 may refer to the above description of step S202, and is not described herein again.
In step S504, the proof data is used by the prophetic to verify the first data.
As described above, taking the predictive equipment as the TEE as an example, the TEE of the first relay device 121 is preset with the verification algorithms corresponding to the block chains respectively. For example, the TEE presets an Spv verification algorithm corresponding to the first blockchain 11, where the Spv verification algorithm includes codes and data required for Spv verification of data from the first blockchain. After the first relay device 121 determines that the first data (e.g., receipt m) is from the first blockchain 11, the Spv verification algorithm corresponding to the first blockchain 11 may be executed to verify the first data using the Spv attestation data.
Specifically, the receipt m acquired by the first relay device 121 can be verified in the prediction machine by: calculating the hash value of the acquired receipt m; calculating a root hash value of the receipt tree in the block 1 based on hash values of other nodes in the tree path included in the Spv certification data; comparing the calculated root hash value with a root hash value of a receipt tree of block 1 included in Spv certification data to determine whether the receipt m is the receipt m in block 1; and determining whether the block 1 is the block in the first blockchain 11 based on the Spv certification data including the block header hash value of the block 1 and information (e.g., the created block hash value) about the created block of the first blockchain 11 preset in the Spv verification algorithm.
In step S506, in case the verification is passed, the first message data is digitally signed by the predicting machine.
In the case where the above-mentioned verifications are all passed, i.e., the verifiable receipt m is the receipt m in tile 1 in the first blockchain 11, and is the recognized authentic data.
In one embodiment, in the case that the first Data is the receipt m, after the verification passes, based on the Data structure in the receipt m, the TEE may find a log with an "AM" subject from the receipt m, obtain the Data field content included in the log as the Data of the message, and then digitally sign the Data of the message using its private key, thereby digitally signing the Data as the proof Data of the message.
In one embodiment, after the TEE retrieves the data of the message from the receipt m, the data of the message has rlp format in etherhouse chain, the format is complex, the parsing process is slow, and in order to further speed up the message verification process of the second blockchain 13, the TEE may use a preset program for format conversion to format the data of the message, for example, convert the format of the data of the message into a data format such as Json, tlv and the like which is friendly to contract, and digitally sign the data of the message after converting the format.
If the above verification is not passed, the receipt m acquired by the first relay device 121 is certified as untrusted data. The TEE will stop the subsequent processing.
The TEE, after processing the receipt m, outputs data of the message, which may be format-converted data, and a digital signature corresponding to the data.
Step S508 and step S510 may refer to the description of step S204 and step S206, and are not described herein again.
Step S512 is substantially the same as step S208 described above, except that in step S512, the first message data and the digital signature thereof are transmitted into the relay device network, that is, the certification data of the first message is converted by the first relay device 121, and the data format of the first message is converted, so that the second blockchain 13 can perform data verification and data parsing more quickly and easily after receiving the first message data and the digital signature thereof.
Fig. 6 is a flowchart illustrating a method for transferring a message across a link based on a relay device network according to an embodiment of the present specification, where the relay device network includes a second relay device, the second relay device is connected to a second blockchain, a first relay device in the relay device network is connected to a first blockchain, and the method is performed by the second relay device, and includes:
step S602, receiving first message data and a digital signature thereof from the relay device network, where the first message data is obtained from the first blockchain by the first relay device, and the first message data includes a receive chain identifier of the first message data, and the digital signature is a digital signature of the first relay device on the first message data;
step S604, determining a receive chain of the first message data as a second block chain based on the first message data;
step S606, providing the first message data and the digital signature thereof to the second blockchain.
First, in step S602, first message data and a digital signature thereof are received from the relay device network, where the first message data is obtained by the first relay device from the first blockchain, and the first message data includes a receive chain identifier of the first message data, and the digital signature is a digital signature of the first relay device on the first message data.
Referring to the above description, based on different forms of the lookup table of the relay device in the relay device network or different connection relationships of the respective relay devices in the relay device network, the second relay device 122 may be directly connected with the first relay device 121 so as to receive the relay data from the first relay device 121, or the second relay device 122 may not be directly connected with the first relay device 121 but connected with the first relay device 121 through at least one other relay device (e.g., relay device ID3), so that the second relay device 122 may receive the first message data and its digital signature from the relay device ID3 in the relay device network. As described above, the digital signature is a digital signature of the first message data by the first relay device 121 in the relay device network.
Step S604 may refer to the above description of step S204, and is not described herein again.
In step S606, the first message data and its digital signature are provided to the second blockchain.
As shown in fig. 1, second relay device 122, after receiving the first message data (i.e., the data of the message) and its digital signature, may determine that the message is to be sent to second blockchain 13 based on the message content of the message therein. The second relay device 122 may determine that the second blockchain 13 is locally connected from a locally stored data table similar to table 1 and may retrieve the connection address of the second blockchain 13 from the data table, so that, as shown in fig. 1, the second relay device 122 may provide the data of the message and its digital signature to the second blockchain 13 by sending a transaction n to the second blockchain 13. For example, a message receipt contract may be invoked in this transaction n with the data of the message and its digital signature as incoming parameters.
Fig. 7 shows an apparatus 700 for transferring data across links based on a relay device network according to an embodiment of the present disclosure, where the relay device network includes a first relay device and a second relay device, the first relay device is connected to a first block chain and stores a lookup table, the lookup table records block chains to which a predetermined number of relay devices are respectively connected, the first relay device also records connection addresses of the predetermined number of relay devices, and the second relay device is connected to a second block chain, and the apparatus is deployed in the first relay device, and includes:
an obtaining unit 71, configured to obtain cross-chain data from the first blockchain, where the cross-chain data includes a receive chain identifier of the cross-chain data;
a first determining unit 72 configured to determine, based on the cross-chain data, that a receive chain of the cross-chain data is a second block chain;
a second determining unit 73 configured to determine whether the second blockchain is locally connected;
a sending unit 74 configured to send the cross-link data to at least one relay device of the predetermined number of relay devices based on the lookup table for sending the cross-link data to the second relay device in case that it is determined that the second blockchain is not locally connected.
In an embodiment, the second relay device is included in the predetermined number of relay devices, wherein the transmitting unit 74 is further configured to transmit the cross-link data to the second relay device based on the look-up table.
In one embodiment, the second relay device is not included in the predetermined number of relay devices, and the transmitting unit 74 is further configured to transmit the chain crossing data to a third relay device of the predetermined number of relay devices based on the look-up table, so as to transmit the chain crossing data to the second relay device.
In an embodiment, the apparatus 700 further includes a providing unit 75 configured to provide the cross-link data to the second blockchain in case that it is determined that the second blockchain is locally connected.
Fig. 8 shows an apparatus 800 for transferring data across a link based on a relay device network according to an embodiment of the present specification, where the relay device network includes a second relay device, the second relay device is connected to a second blockchain, the relay device network is connected to a first blockchain, and the apparatus is deployed in the second relay device, and includes:
a receiving unit 81 configured to receive cross-link data from the relay device network, wherein the cross-link data is acquired from the first blockchain by the relay device network;
a determining unit 82 configured to determine, based on the cross-chain data, that a receive chain of the cross-chain data is a second blockchain;
a providing unit 83 configured to provide the cross-chain data to the second blockchain.
Fig. 9 shows an apparatus 900 for transferring a message across a chain based on a network of relay devices according to another embodiment of the present specification, where the network of relay devices includes a first relay device and a second relay device, the first relay device is connected to a first blockchain, and stores a lookup table, where the lookup table records blockchains to which a predetermined number of relay devices are respectively connected, the first relay device also records connection addresses of the predetermined number of relay devices, and the first relay device includes a prediction machine, and the second relay device is connected to a second blockchain, where the apparatus is deployed in the first relay device, and includes:
an obtaining unit 91, configured to obtain first data and certification data thereof from the first blockchain, where the first data includes first message data, and the first message data includes a receive chain identifier of the first message data;
a verification unit 92 configured to verify, by the predictive machine, the first data using the attestation data;
a signature unit 93 configured to digitally sign the first message data by the predicting machine in a case where the verification is passed;
a first determining unit 94 configured to determine, based on the first message data, that a receive chain of the first message data is a second block chain;
a second determining unit 95 configured to determine whether the second blockchain is locally connected;
a sending unit 96 configured to send the first message data and the digital signature thereto to at least one relay device of a predetermined number of relay devices based on the lookup table for sending the first message data and the digital signature thereto to the second relay device in case it is determined that the second blockchain is not locally connected.
In one embodiment, the signing unit 93 includes a converting subunit 931 configured to convert the format of the first message data into a predetermined format in case of passing the verification, and a signing subunit 932 configured to digitally sign the first message data having the predetermined format.
Fig. 10 shows an apparatus 1000 for relaying a message across a chain based on a relay device network according to another embodiment of the present specification, where the relay device network includes a second relay device, the second relay device is connected to a second blockchain, a first relay device in the relay device network is connected to a first blockchain, and the apparatus is deployed in the second relay device, and includes:
a receiving unit 101, configured to receive first message data and a digital signature thereof from the relay device network, where the first message data is obtained by the first relay device from the first blockchain, and the first message data includes a receive chain identifier of the first message data, and the digital signature is a digital signature of the first relay device on the first message data;
a determining unit 102 configured to determine, based on the first message data, that a receive chain of the first message data is a second block chain;
a providing unit 103 configured to provide the first message data and its digital signature to the second blockchain.
Another aspect of the present specification provides a computer readable storage medium having stored thereon a computer program or instructions which, when executed in a computer, cause the computer to perform any of the above methods.
Another aspect of the present specification provides a computing device comprising a memory having stored therein a computer program or instructions, and a processor that, when executed, implements any of the above methods.
By the scheme of forwarding the message in the cross-link according to the embodiment of the present specification, the relay device network supporting the routing can be implemented under the link of the blockchain, so that a cross-link network topology can be formed based on the relay device network, and the cross-link network topology supports large-scale cross-link network connection.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
It will be further appreciated by those of ordinary skill in the art that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether these functions are performed in hardware or software depends on the particular application of the solution and design constraints. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied in hardware, a software module executed by a processor, or a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.