Cross-chain data processing method and device
By generating self-describing data and analyzing and verifying it on the receiver, the problem of data differences between blockchains is solved, and the unified processing and verification of cross-chain data is realized, which improves the convenience of cross-chain communication.
Patent Information
- Application Number
- CN202110998401.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-30
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-03-30
AI Technical Summary
Due to the differences in data structure, data format, data semantics and verification trust roots, it is difficult to achieve effective processing and collaborative cooperation among different types of blockchains.
By generating self-describing data with a predetermined data structure, including chain identification, data and related information, the data receiver determines the corresponding data parser and validator based on this information, and parses and verifies the cross-chain data.
It realizes unified analysis and verification of different cross-chain data, reduces the amount of data that the data recipient needs to preset, improves the convenience of cross-chain communication, and supports data processing of multi-chain clients and smart contracts.
Smart Images

Figure CN113673991B_ABST
Abstract
Description
[0001] This application is a divisional application of the invention patent application with application number 202110340165.3 filed on March 30, 2021, and entitled “Cross-chain Data Processing Method and Device”. Technical Field
[0002] The embodiments of this specification relate to the field of blockchain technology, and more specifically, to a cross-chain data processing method and device. Background Art
[0003] Blockchain technology, also known as distributed ledger technology, is a decentralized distributed database technology that is characterized by decentralization, openness, transparency, immutability, and trustworthiness. Every piece of data in the blockchain will be broadcast to all blockchain nodes in the network, and each full node has full and consistent data. With the popularity of blockchain technology, many different types of chains have emerged, which are applied in finance, health care, supply chain, asset management, and traceability. However, most on-chain applications (cryptocurrency or smart contracts) cannot cross the boundaries of the current chain and cannot collaborate with other chains to achieve the circulation of value, thus limiting the space for blockchain to play. How to enable different types of chains to collaborate and achieve the circulation of value has become a direction of exploration.
[0004] The data structure, data format, data semantics, on-chain proof and verification trust root of the ledger data of different types of blockchains are all different. Taking the Ethereum chain and Hyperledger Fabric chain as examples, the field definitions in the data structure of the two are different, and the data format of the Ethereum chain type blockchain is rlp encoding, the data format of the Fabric chain type blockchain is protobuf encoding, the proof data of the Ethereum chain is Spv proof data, the proof data of the Fabric chain is the signature of multiple endorsement nodes, the verification root of the Ethereum chain is the genesis block data, and the verification root of the Fabric chain is the public key of multiple endorsement nodes. Therefore, in cross-chain and multi-chain applications, there is a problem of processing differentiated data.
[0005] Therefore, a more efficient cross-chain data processing solution is needed. Summary of the invention
[0006] The embodiments of this specification are intended to provide a more effective cross-chain data processing solution to address the deficiencies in the prior art.
[0007] To achieve the above objectives, this specification provides, in one aspect, a cross-chain data processing method, which is executed by a data provider device and includes:
[0008] Obtain first data from a first blockchain;
[0009] Generate second data, where the second data has a predetermined data structure and includes: a chain identifier of the first blockchain, the first data, and related information of the first data, wherein the related information of the first data includes the chain type of the first blockchain;
[0010] The second data is provided to a data receiving device.
[0011] In one implementation, the related information of the first data also includes the data structure type of the first data.
[0012] In one implementation, the data structure type of the first data is one of the following types: block header type, transaction type, account status type, and receipt type.
[0013] In one embodiment, obtaining the first data from the first blockchain includes obtaining the first data and its proof data from the first blockchain, and the second data also includes the proof data.
[0014] In one implementation, the second data also includes relevant information of the proof data, and the relevant information of the proof data includes at least one of the following: the type of the proof data, the data structure type of the proof data, the hash value of the proof data, and the verification root of the proof data.
[0015] In one implementation, the type of the certification data is one of the following types: Spv certification data type, multi-signature certification data type.
[0016] In one embodiment, the type of the first blockchain is one of the following types: Bitcoin chain type, Ethereum chain type, Hyperledger Fabric chain type.
[0017] On the other hand, this specification provides a cross-chain data processing method, which is executed by a data receiving device, including:
[0018] Receive second data from a data provider device, where the second data has a predetermined data structure and includes: a chain identifier of a first blockchain, first data, and related information of the first data, wherein the related information of the first data includes a chain type of the first blockchain;
[0019] Determine a data parser corresponding to the first data based on relevant information of the first data;
[0020] The first data is parsed by a data parser.
[0021] In one embodiment, the relevant information of the first data also includes a data structure type of the first data, wherein determining a data parser corresponding to the first data based on the relevant information of the first data includes determining the data parser corresponding to the first data based on the type of the first blockchain and the data structure type of the first data.
[0022] In one implementation, the data receiving device is preset with a correspondence between the chain identifier of the first blockchain and the first verification root of the first blockchain, the second data also includes proof data of the first data, and the method further includes:
[0023] Determining a certification data parser and a verifier corresponding to the certification data;
[0024] parsing the certification data by the certification data parser;
[0025] The first data is verified by the verifier based on the first verification root and the certification data.
[0026] In one embodiment, determining a proof data parser and a verifier corresponding to the proof data includes determining a proof data parser and a verifier corresponding to the proof data based on a type of the first blockchain and a data structure type of the first data.
[0027] In one embodiment, the second data also includes the type of the proof data and the data structure type of the proof data, wherein determining the proof data parser and the verifier corresponding to the proof data includes determining the proof data parser and the verifier corresponding to the proof data based on the type of the proof data and the data structure type of the proof data.
[0028] In one embodiment, the second data also includes a second verification root of the first blockchain, wherein the first data is verified by the verifier based on the first verification root and the proof data, and the second verification root is verified by the verifier based on the first verification root, and after the verification is passed, the first data is verified by the verifier based on the second verification root and the proof data.
[0029] On the other hand, the present specification provides a cross-chain data processing device, which is deployed on a data provider device and includes:
[0030] An acquisition unit, configured to acquire first data from a first blockchain;
[0031] A generating unit is configured to generate second data, wherein the second data has a predetermined data structure, and the second data includes: a chain identifier of a first blockchain, first data, and related information of the first data, wherein the related information of the first data includes a chain type of the first blockchain;
[0032] The providing unit is configured to provide the second data to a data receiving device.
[0033] In one embodiment, the acquisition unit is further configured to acquire first data and proof data thereof from the first blockchain, and the second data also includes the proof data.
[0034] On the other hand, the present specification provides a cross-chain data processing device, which is deployed on a data receiving device, including:
[0035] A receiving unit is configured to receive second data from a data provider device, wherein the second data has a predetermined data structure, and the second data includes: a chain identifier of a first blockchain, first data, and related information of the first data, wherein the related information of the first data includes a chain type of the first blockchain;
[0036] A first determining unit, configured to determine a data parser corresponding to the first data based on relevant information of the first data;
[0037] The first parsing unit is configured to parse the first data through a data parser.
[0038] In one embodiment, the relevant information of the first data also includes a data structure type of the first data, wherein the first determination unit is further configured to determine a data parser corresponding to the first data based on the type of the first blockchain and the data structure type of the first data.
[0039] In one implementation, the data receiving device is preset with a correspondence between the chain identifier of the first blockchain and the first verification root of the first blockchain, the second data also includes proof data of the first data, and the apparatus further includes:
[0040] A second determining unit is configured to determine a proof data parser and a verifier corresponding to the proof data;
[0041] a second parsing unit, configured to parse the certification data by the certification data parser;
[0042] A verification unit is configured to verify the first data based on the first verification root and the certification data through the verifier.
[0043] In one embodiment, the second determination unit is further configured to determine a proof data parser and a verifier corresponding to the proof data based on the type of the first blockchain and the data structure type of the first data.
[0044] In one embodiment, the second data also includes the type of the proof data and the data structure type of the proof data, wherein the second determination unit is further configured to determine a proof data parser and a verifier corresponding to the proof data based on the type of the proof data and the data structure type of the proof data.
[0045] In one embodiment, the second data also includes a second verification root of the first blockchain, wherein the verification unit includes a first verification subunit configured to verify the second verification root based on the first verification root through the verifier, and a second verification subunit configured to verify the first data based on the second verification root and the proof data through the verifier after the verification is passed.
[0046] On the other hand, the present specification provides a computer-readable storage medium having a computer program or instruction stored thereon, which, when executed in a computer, causes the computer to execute any one of the above methods.
[0047] Another aspect of the present specification provides a computing device, including a memory and a processor, wherein the memory stores a computer program or instructions, and the processor implements any of the above methods when executing the computer program or instructions.
[0048] Through the data processing scheme for cross-chain data according to the embodiments of this specification, different cross-chain data can be converted into a unified data structure, so that the data recipient only needs to preset less data locally to realize the parsing and proof process of different cross-chain data, thereby realizing a multi-chain client with a small amount of data, or a multi-chain data processing smart contract, etc., which improves the convenience of cross-chain communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The embodiments of this specification are described in conjunction with the accompanying drawings to make the embodiments of this specification clearer:
[0050] Figure 1 A schematic diagram showing a cross-chain system according to an embodiment of the present specification;
[0051] Figure 2 A flow chart of a cross-chain data processing method according to an embodiment of this specification is shown;
[0052] Figure 3 A data structure of self-describing cross-chain data is schematically shown;
[0053] Figure 4 A data structure of self-describing cross-chain data is schematically shown;
[0054] Figure 5 A data structure of self-describing cross-chain data is schematically shown;
[0055] Figure 6 A data structure of self-describing cross-chain data is schematically shown;
[0056] Figure 7 A data structure of self-describing cross-chain data is schematically shown;
[0057] Figure 8 A flow chart of a cross-chain data processing method according to an embodiment of this specification is shown;
[0058] Fig. 9 A cross-chain data processing device 900 according to an embodiment of this specification is shown;
[0059] Fig.10 A cross-chain data processing device 1000 according to an embodiment of this specification is shown. DETAILED DESCRIPTION
[0060] The embodiments of this specification will be described below with reference to the accompanying drawings.
[0061] Figure 1 A schematic diagram of a cross-chain system according to an embodiment of this specification is shown. Figure 1 As shown, the cross-chain system includes a first blockchain 11, an off-chain network 12, and a second blockchain 13. The first blockchain 11 and the second blockchain 13 are, for example, different types of blockchains, for example, the first blockchain 11 is an Ethereum chain, and the second blockchain 13 is a Fabric chain. The first blockchain 11 includes a node 1, the second blockchain 13 includes a node 2, and the off-chain network 12 includes a first relay device 121 and a second relay device 122. In this cross-chain system, node 1, node 2, the first relay device 121, and the second relay device 122 can all correspond to specific computing devices, each of which has its own connection address, so that they can be connected to each other through the connection address, and send and receive data to each other, for example, Figure 1As shown in , node 1 and node 2 may be connected to each other, node 1 may be connected to the first relay device 121, node 2 may be connected to the second relay device 122, and the first relay device 121 and the second relay device 122 may be connected directly or indirectly. Thus, for example, node 1 may read the ledger data in the first blockchain 11 locally and provide the data to the first relay device 121 or node 2, or the second relay device 122 may connect to node 2 and read the ledger data in the second blockchain 13 from the ledger data of node 2, and provide the data to the first relay device 121 or node 1, and so on.
[0062] Since the first blockchain 11 and the second blockchain 13 are different blockchains, when the first relay device 121 receives the account data from the first blockchain 11 and the second blockchain 13, different parsing methods will be used to parse the data, and different verification methods will be used to verify the data. For example, a multi-chain client is installed in the first relay device 121, and the domain name and verification root of each blockchain, as well as the parsing algorithm and verification algorithm corresponding to each chain type are pre-set in the multi-chain client. In order to parse and verify the received data by using the multi-chain client, the data provider needs to configure the self-description data based on the blockchain account data in advance, and provide the self-description data to the data receiver (such as the first relay device 121). Therefore, after the first relay device 121 receives the above self-description data, the blockchain domain name, data structure type, etc. corresponding to the account data included in the self-description data can be read from the self-description data through the multi-chain client, so that the corresponding parsing algorithm and verification algorithm can be determined based on the read content, and finally the verified account data can be obtained.
[0063] It is understandable that the above reference Figure 1 The description is only an example description of the embodiments of this specification and is not intended to limit the scope of the embodiments of this specification. For example, in addition to being a blockchain node and a repeater, the data provider can also be a blockchain proxy node. In addition to being a blockchain node and a relay device, the data recipient can also be a blockchain proxy node. The data recipient is not limited to processing the received blockchain data through a multi-chain client. For example, the data recipient can also process the received blockchain data by executing a predetermined smart contract. Accordingly, the domain name and verification root of each blockchain, as well as the parsing algorithm and verification algorithm corresponding to each chain type, etc. can be preset in the predetermined smart contract.
[0064] The data processing process at the data provider and the data receiver will be described in detail below.
[0065] Figure 2 A flow chart of a cross-chain data processing method according to an embodiment of this specification is shown, and the method is executed by a data provider device, including:
[0066] Step S202, obtaining first data from the first blockchain;
[0067] Step S204, generating second data, wherein the second data has a predetermined data structure, and the second data includes: a chain identifier of the first blockchain, the first data, and related information of the first data, wherein the related information of the first data includes the chain type of the first blockchain;
[0068] Step S206: providing the second data to a data receiving device.
[0069] As described above, the data provider here can be a blockchain node, a proxy node, an off-chain relay device, etc. The data receiver can be a blockchain node, a proxy node, an off-chain relay device, etc., which can receive data through a multi-chain client, or the blockchain node can receive data through a predetermined smart contract. In the following, the description will be given by way of example with node 1 as the data provider and the first relay device 121 as the data receiver.
[0070] First, in step S202, first data is obtained from the first blockchain.
[0071] In one embodiment, the first data may be any data in the first blockchain 11, and the node 1 may directly read the first data from the locally stored account data. In the node 1, the first data may be read locally through the client of the first blockchain 11 set therein.
[0072] In one embodiment, node 1 can read the first data and its Spv proof data locally through its client. In this case, the first data can be block header data, transaction data, receipt data, account status data, and these data can be verified by simple payment verification (Spv) proof data to be the consensus data stored in the blockchain ledger data. For example, if the first data is receipt 1 in block 1 in the first blockchain 11, the corresponding Spv proof data includes: the block header hash value of block 1, the receipt tree root hash value included in block 1, and the hash values of other nodes in the tree path from receipt 1 to the root node in the receipt tree.
[0073] It can be understood that since node 1 obtains the data of the first blockchain 11 locally, and the first blockchain 11 is an Ethereum blockchain type blockchain, the proof data of the first data is Spv data. Different types of blockchains have different types of proof data. For example, if the first data is data in the second blockchain 13, and the second blockchain 13 is a Fabric chain, the proof data of the first data is the digital signature of the first data by each of the predetermined number of endorsement nodes in the second blockchain 13.
[0074] In step S204, second data is generated, the second data has a predetermined data structure, and the second data includes: a chain identifier of the first blockchain, first data, and related information of the first data, wherein the related information of the first data includes the chain type of the first blockchain.
[0075] After node 1 reads the data locally, in order to facilitate cross-chain communication, it can configure self-describing cross-chain data based on the read data. The self-describing cross-chain data has a predetermined data structure, that is, it includes a predetermined field arrangement to facilitate reading by the data receiving device.
[0076] Figure 3 The following diagram shows a data structure of self-describing cross-chain data. Figure 3 As shown, the data structure includes three fields: chain identifier, data element and data element information. Among them, the chain identifier is an identifier that uniquely identifies the blockchain instance and uniquely corresponds to the blockchain instance. The chain identifier is, for example, the domain name of the blockchain. In order to uniquely identify each blockchain (i.e., blockchain instance) in the cross-chain field, for example, a unique chain domain name can be assigned to each blockchain. Similar to the website domain name, the chain domain name is readable and easy to identify, so it has stronger operability. It can be understood that the chain identifier is not limited to the chain domain name, but can also be other unique identifiers of the blockchain instance, such as the verification root of the blockchain.
[0077] The data element field is the cross-chain data to be transmitted across the chain, such as the first data. The data element information is the information used to parse the first data. In one embodiment, the data element information includes a chain type, and the chain type refers to the blockchain type of the blockchain instance, such as Ethereum chain type, Bitcoin chain type, Hyperledger Fabric chain type, etc. In one embodiment, the data element information includes a chain type and a data structure type of the data element. As described above, the first data can be block header data, transaction data, receipt data, account status data, etc. in the blockchain. Correspondingly, the first data has different data structure types when it is different data. Therefore, the data structure type of the data element includes, for example, a block header type, a transaction type, an account status type, a receipt type, etc.
[0078] Figure 4 A data structure of self-describing cross-chain data is schematically shown. In one embodiment, the data metadata includes Figure 4 The three fields shown in are: chain type, data structure type, and hash value. The hash value field is the hash value of the cross-chain data, which is used to verify the hash value of the cross-chain data.
[0079] Figure 5The diagram shows a data structure of self-describing cross-chain data. Figure 3 The data structure shown, Figure 5 The data structure in also includes a proof meta field, which is the proof data used to verify the cross-chain data. The proof data has different forms depending on the type of specific chain. For example, in the Ethereum chain type blockchain, the proof data is the Spv proof data, and in the Fabric type blockchain, the proof data is the digital signature of the endorsement node on the data element. Among them, in the Ethereum chain type blockchain, as mentioned above, the provable data includes block header data, receipt data, transaction data and account status data. Therefore, in Figure 5 In the data structure shown, the data meta information should include at least the chain type and the data structure type, so as to determine which type of provable data the self-describing cross-chain data specifically corresponds to, so as to facilitate the data recipient to parse the provable data.
[0080] Figure 6 The diagram shows a data structure of self-describing cross-chain data. Figure 5 The data structure shown, Figure 6 The data structure in also includes a proof meta information field, which includes information for parsing and verifying the proof data. In one embodiment, the proof meta information field may include a proof type field. In one embodiment, the proof meta information field may include a proof type field and a data structure type field, where the data structure type field is the data structure type of the proof data, such as the data structure type corresponding to the Spv proof data, the data structure type corresponding to the multi-signature proof data, etc.
[0081] Figure 7 A data structure of self-describing cross-chain data is schematically shown. In the data structure, it is schematically shown that the proof meta-information field includes: proof type field, data structure type field, hash value field, and verification root field. Among them, the hash value field is the hash value of the proof data, which is used to verify the proof data, and the verification root field is the verification root of the proof data, that is, the verification root in the corresponding blockchain instance, which is used to verify the cross-chain data in combination with the proof data.
[0082] In one embodiment, after reading the first data, node 1 can Figure 3 or Figure 4 The data structure of the self-describing cross-chain data is configured based on the first data to obtain the second data. For example, the client configuration of the first blockchain 11 in node 1 has Figure 3The self-describing cross-chain data of the data structure shown in the figure has the chain identifier of the first blockchain 11 (e.g., "Chain1") and the chain type of the first blockchain 11 (i.e., the Ethereum chain type) pre-set in the client, so that "Chain1" is filled in the client. Figure 3 The chain identification field in the Figure 3 In the data metadata field, fill in the "Ethereum chain type" Figure 3 The neuron information field in the is used to obtain the self-describing cross-chain data corresponding to the first data.
[0083] In one embodiment, the first data is, for example, receipt 1. After node 1 reads receipt 1 and its Spv certification data, it can Figure 5-Figure 7 The self-describing cross-chain data corresponding to any data structure configuration in is used as the second data. For example, the client of node 1 pre-sets the chain identifier of blockchain 11, the chain type, the four data structure types in the first blockchain 11 (i.e., block header data type, transaction data type, receipt data type, account status data type), the proof type (i.e., Spv proof type), the data structure type of the proof data (i.e., the data structure type of the Spv proof), and the verification root, and the client is also provided with a hash value calculation unit. After reading receipt 1 and its proof, the client of node 1 determines that the data structure type of receipt 1 is a receipt data type, calculates the respective hash values of receipt 1 and its proof through the hash value calculation unit, and fills the above items, receipt 1, its proof and their respective hash values into Figure 7 In the data structure shown, self-describing cross-chain data corresponding to receipt 1 and its proof data is obtained.
[0084] It can be understood that, as a data provider, the client of node 1 in the first blockchain 11 only needs to pre-set various parameters related to the first blockchain 11 as described above, and in the case where the first relay device 121 is a data provider, it is connected to multiple blockchains, for example, and it may read data from each blockchain to which it is connected and convert it into self-describing cross-chain data. In this case, the parameters related to each blockchain need to be pre-set in the first relay device 121. For example, various parameters related to the first blockchain 11 and various parameters related to the second blockchain 12 need to be pre-set in the multi-chain client of the first relay device 121, so that the first relay device 121 can read data from the first blockchain 11 and the second blockchain 12 respectively and convert them into self-describing cross-chain data respectively.
[0085] In step S206, the second data is provided to a data receiving device.
[0086] In one implementation, after acquiring the second data, the node 1 may directly send the second data to the device of the first relay device 121 .
[0087] In the case where the data provider is the first relay device 121 and the data recipient is node 2, the first relay device 121 can provide the second data to node 2 by sending a transaction to node 2, in which a predetermined contract in the second blockchain 13 is called with the second data as an input parameter, thereby providing the second data to node 2.
[0088] Figure 8 A flow chart of a cross-chain data processing method according to an embodiment of this specification is shown, and the method is executed by a data receiving device, including:
[0089] Step S802: receiving second data from a data provider device, where the second data has a predetermined data structure and includes: a chain identifier of a first blockchain, first data, and related information of the first data, wherein the related information of the first data includes a chain type of the first blockchain;
[0090] Step S804, determining a data parser corresponding to the first data based on relevant information of the first data;
[0091] Step S806: parse the first data by a data parser.
[0092] As described above, the data receiver can be a blockchain node, a proxy node, an off-chain relay device, etc., which can receive data through a multi-chain client, or the blockchain node can receive data through a predetermined smart contract. Hereinafter, the description will be made by taking node 1 as the data provider and the first relay device 121 as the data receiver.
[0093] In step S802, second data is received from a data provider device, where the second data has a predetermined data structure and includes: a chain identifier of a first blockchain, first data, and related information of the first data, wherein the related information of the first data includes the chain type of the first blockchain.
[0094] As described above, the second data may have Figure 3-Figure 7 The data structure shown in any one of the above. The data element information and the proof element information may also include different field configurations as described above. For example, the second data may include the following fields: chain identification, data element, chain type, or the second data may include the following fields: chain identification, data element, chain type, data structure type, or the second data may include the following fields: chain identification, data element, chain type, data structure type, hash value, etc.
[0095] In step S804, a data parser corresponding to the first data is determined based on the relevant information of the first data. In step S806, the first data is parsed by the data parser.
[0096] Since the first relay device 121 and node 1 have pre-negotiated the data structure of the self-describing cross-chain data to be adopted, the first relay device 121 can parse the self-describing data based on the data structure, thereby reading the data of each field in the self-describing data, thereby obtaining the relevant information of the first data therein, and can determine the parser used to parse the first data based on the relevant information, which refers to a parsing algorithm.
[0097] The multi-chain client in the first relay device 121 may preset parsers corresponding to each blockchain type. Since each blockchain type adopts a different data format, for example, as described above, the data format of the Ethereum chain type blockchain is rlp encoding, and the data format of the Fabric chain type blockchain is protobuf encoding. Therefore, the parsers corresponding to each blockchain type are used to decode different data formats.
[0098] Parsers corresponding to different data structures in the blockchain may also be preset in the multi-chain client in the first relay device 121, and the parsers corresponding to different data structures are used to parse data based on different data structures. For example, in an Ethereum chain type blockchain, assuming that the type of the first data is a receipt, after decoding the first data through the above parser, the first data is also parsed through the parser corresponding to the receipt to obtain the content of the first data.
[0099] Therefore, after obtaining the relevant information of the first data, the multi-chain client of the first relay device 121 can select the corresponding parser based on the relevant information of the first data to parse the first data. For example, the relevant information of the first data includes the Ethereum chain type, so the multi-chain client in the first relay device 121 selects the parser for decoding the rlp code to parse the first data. For example, the relevant information of the first data includes: Ethereum chain type, receipt type, so the multi-chain client in the first relay device 121 first selects the parser for decoding the rlp code to parse the first data, and then selects the parser for reading the receipt to further read the first data, so that the content of the first data can be obtained.
[0100] In one embodiment, Figure 4 As shown, the data meta information also includes a hash value of the first data. Therefore, before parsing the first data, the hash value of the first data can be calculated and compared with the hash value in the data meta information to determine whether the first data is the original data provided by the data provider.
[0101] In one implementation, the second data also includes certification data of the first data. After receiving the second data, the data recipient may further perform the following steps to verify the first data included in the second data:
[0102] Step S808, determining a proof data parser and a verifier corresponding to the proof data;
[0103] Step S810, parsing the certification data by the certification data parser;
[0104] Step S812: Verify the first data using the certification data through the verifier.
[0105] First, in step S808, the proof data parser and verifier corresponding to the proof data are determined.
[0106] The multi-chain client of the first relay device 121 is preset with proof data parsers and verifiers corresponding to various chain types. For example, the multi-chain client includes a Spv proof data parser (i.e., a parsing algorithm) corresponding to the Ethereum chain type, and a verifier (i.e., a verification algorithm) for verification using Spv proof data. In addition, the multi-chain client also includes a multi-signature proof data parser corresponding to the Fabric chain type, and a verifier for verification using multi-signature proof data.
[0107] In one embodiment, the second data has Figure 5 The data structure shown, the multi-chain client determines the parser for parsing the Spv proof data of the receipt in the Ethereum chain type blockchain based on the chain type (Ethereum chain type) in the data meta information and the data structure type (receipt type) in the data meta information, and determines the verifier for verification using the Spv proof data.
[0108] In one embodiment, the second data has Figure 6 or Figure 7 The data structure shown, the multi-chain client can directly determine the corresponding parser and validator based on the proof type and data structure type in the second data.
[0109] Step S810: parsing the certification data by the certification data parser. The parsing process is similar to the parsing process of the first data described above, including a decoding process of the data format and a reading process of the data structure, which will not be described in detail here.
[0110] In step S812, the first data is verified by the verifier using the certification data.
[0111] As described above, the validator means the verification algorithm preset in the multi-chain client. In addition, the multi-chain client also presets the chain identifier and the minimum verification root of each blockchain. Based on the chain identifier of the first blockchain 11 in the second data, the multi-chain client can obtain the minimum verification root preset therein corresponding to the first blockchain 11, such as the hash value of the genesis block of the first blockchain 11.
[0112] For example, the first data is receipt 1, and the proof data is correspondingly the Spv proof data of receipt 1. The multi-chain client can verify receipt 1 by the following steps: calculating the hash value of receipt 1; calculating the root hash value of the receipt tree in block 1 based on the hash values of other nodes in the tree path included in the Spv proof data; comparing 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 receipt 1 is receipt 1 in block 1; and, determining whether block 1 is a block in the first blockchain 11 based on the block header hash value of block 1 included in the Spv proof data and the minimum verification root of the first blockchain 11 pre-set in the multi-chain client.
[0113] In one embodiment, Figure 7 As shown, the proof meta-information also includes a verification root. For example, the verification root may include more verification root information than the minimum verification root preset in the multi-chain client, for example, it may include block information of the genesis block, the longest chain information of block 1 in the blockchain, etc. Thus, the multi-chain client can use the minimum verification root to verify the verification root in the second data, and after the verification is passed, the receipt 1 can be verified based on the verification root and the Spv proof data. The verification root included in the proof meta-information may also be the minimum verification root.
[0114] In one embodiment, Figure 7 As shown, the proof meta-information also includes the hash value of the proof data. Therefore, before using the proof data for verification, the hash value of the proof data can be calculated and compared with the hash value in the proof meta-information to determine whether the proof data is the original data provided by the data provider.
[0115] Fig. 9 A cross-chain data processing device 900 according to an embodiment of this specification is shown, and the device is deployed on a data provider device, including:
[0116] An acquisition unit 91 is configured to acquire first data from a first blockchain;
[0117] The generating unit 92 is configured to generate second data, wherein the second data has a predetermined data structure, and the second data includes: a chain identifier of the first blockchain, the first data, and related information of the first data, wherein the related information of the first data includes the chain type of the first blockchain;
[0118] The providing unit 93 is configured to provide the second data to a data receiving device.
[0119] In one embodiment, the acquisition unit 91 is further configured to acquire first data and its proof data from the first blockchain, and the second data also includes the proof data.
[0120] Fig.10 A cross-chain data processing device 1000 according to an embodiment of this specification is shown, and the device is deployed on a data receiving device, including:
[0121] The receiving unit 101 is configured to receive second data from a data provider device, where the second data has a predetermined data structure and includes: a chain identifier of a first blockchain, first data, and related information of the first data, wherein the related information of the first data includes a chain type of the first blockchain;
[0122] A first determining unit 102 is configured to determine a data parser corresponding to the first data based on relevant information of the first data;
[0123] The first parsing unit 103 is configured to parse the first data through a data parser.
[0124] In one embodiment, the relevant information of the first data also includes a data structure type of the first data, wherein the first determination unit 102 is further configured to determine a data parser corresponding to the first data based on the type of the first blockchain and the data structure type of the first data.
[0125] In one implementation, the data receiving device is preset with a correspondence between the chain identifier of the first blockchain and the first verification root of the first blockchain, the second data also includes proof data of the first data, and the apparatus 1000 further includes:
[0126] A second determining unit 104 is configured to determine a proof data parser and a verifier corresponding to the proof data;
[0127] A second parsing unit 105 is configured to parse the certification data through the certification data parser;
[0128] The verification unit 106 is configured to verify the first data based on the first verification root and the certification data through the verifier.
[0129] In one implementation, the second determination unit 104 is further configured to determine a proof data parser and a verifier corresponding to the proof data based on the type of the first blockchain and the data structure type of the first data.
[0130] In one embodiment, the second data also includes the type of the proof data and the data structure type of the proof data, wherein the second determination unit 104 is further configured to determine a proof data parser and a verifier corresponding to the proof data based on the type of the proof data and the data structure type of the proof data.
[0131] In one embodiment, the second data also includes a second verification root of the first blockchain, wherein the verification unit 106 includes a first verification subunit 1061 configured to verify the second verification root based on the first verification root through the verifier, and a second verification subunit 1062 configured to verify the first data based on the second verification root and the proof data through the verifier after the verification is passed.
[0132] On the other hand, the present specification provides a computer-readable storage medium having a computer program or instruction stored thereon, which, when executed in a computer, causes the computer to execute any one of the above methods.
[0133] Another aspect of the present specification provides a computing device, including a memory and a processor, wherein the memory stores a computer program or instructions, and the processor implements any of the above methods when executing the computer program or instructions.
[0134] Through the data processing scheme for cross-chain data according to the embodiments of this specification, different cross-chain data can be converted into a unified data structure, so that the data recipient only needs to preset less data locally to realize the parsing and proof process of different cross-chain data, thereby realizing a multi-chain client with a small amount of data, or a multi-chain data processing smart contract, etc., which improves the convenience of cross-chain communication.
[0135] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0136] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0137] Those of ordinary skill in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those of ordinary skill in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0138] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented by hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0139] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A cross-chain data processing method, the method being executed by a data provider device, include: Obtain first data from a first blockchain; Generate second data, where the second data includes: a chain identifier of the first blockchain, the first data, and related information of the first data, wherein the related information of the first data includes the chain type of the first blockchain; The second data is provided to a data receiving device.
2. The method according to claim 1, in, The relevant information of the first data also includes the data structure type of the first data.
3. The method according to claim 2, in, The data structure type of the first data is one of the following types: block header type, transaction type, account status type, and receipt type.
4. The method according to claim 1, in, Obtaining the first data from the first blockchain includes obtaining the first data and its proof data from the first blockchain, and the second data also includes the proof data.
5. The method according to claim 4, in, The second data also includes relevant information of the proof data, and the relevant information of the proof data includes at least one of the following: the type of the proof data, the data structure type of the proof data, the hash value of the proof data, and the verification root of the proof data.
6. The method according to claim 5, in, The type of the certification data is one of the following types: Spv certification data type, multi-signature certification data type.
7. The method according to claim 1, in, The type of the first blockchain is one of the following types: Bitcoin chain type, Ethereum chain type, and Hyperledger Fabric chain type.
8. A cross-chain data processing device, the device is deployed on a data provider device, include: An acquisition unit, configured to acquire first data from a first blockchain; A generating unit is configured to generate second data, wherein the second data includes: a chain identifier of a first blockchain, first data, and related information of the first data, wherein the related information of the first data includes a chain type of the first blockchain; The providing unit is configured to provide the second data to a data receiving device.
9. The device according to claim 8, in, The relevant information of the first data also includes the data structure type of the first data.
10. The device according to claim 9, in, The data structure type of the first data is one of the following types: block header type, transaction type, account status type, and receipt type.
11. The device according to claim 8, in, The acquisition unit is further configured to acquire first data and proof data thereof from the first blockchain, wherein the second data also includes the proof data.
12. The device according to claim 11, in, The second data also includes relevant information of the proof data, and the relevant information of the proof data includes at least one of the following: the type of the proof data, the data structure type of the proof data, the hash value of the proof data, and the verification root of the proof data.
13. The device according to claim 12, in, The type of the certification data is one of the following types: Spv certification data type, multi-signature certification data type.
14. The device according to claim 8, in, The type of the first blockchain is one of the following types: Bitcoin chain type, Ethereum chain type, and Hyperledger Fabric chain type.
15. A computer-readable storage medium having a computer program or instruction stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 7.
16. A computing device, comprising a memory and a processor, wherein the memory stores a computer program or an instruction, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program or the instruction.
