Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to illustrate the technical scheme of the invention, the following description is made by specific examples.
First embodiment
Fig. 1 is a system architecture to which the cross-chain communication method of the present invention can be applied.
As shown in fig. 1, the system architecture 100 is a peer-to-peer network, also referred to as a P2P network, formed by a plurality of terminal devices 101, 102, 103, 104, 105, 106 interconnected by a network 107.
The network 107 is a communication link that interconnects the terminal devices 101, 102, 103, 104, 105, and 106, the network 107 may be an application, an algorithm, etc. that implements the communication link, and the network 107 may also be a device such as a network cable, an optical fiber, a router, a switch, etc., or the network 107 may be any combination of the above.
In practical applications, the number of terminal devices in the peer-to-peer network may be much larger than that shown in fig. 1, i.e. not limited to the above-mentioned terminal devices 101, 102, 103, 104, 105 and 106. And the terminal device 101, 102, 103, 104, 105 or 106 may specifically comprise hardware, software or a combination of both. For example, when the terminal device 101, 102, 103, 104, 105 or 106 is hardware, it may be specifically a computer, a server, a gateway, a smart phone, a smart wearable device, or the like; when the terminal device 101, 102, 103, 104, 105, or 106 is software, it may be specifically an application or a computer program or the like installed on the hardware; of course, the terminal device 101, 102, 103, 104, 105 or 106 may also be a combination of the above software and hardware.
In this embodiment, the system architecture is applied to the network base of the blockchain technology, so as to implement cross-chain communication between different blockchains.
Illustratively, assuming that a first blockchain is running in the peer-to-peer network while a second blockchain is also running in the peer-to-peer network, then a user logs in the first blockchain on any of the terminal devices 101, 102, 103, 104, 105 or 106 in the peer-to-peer network and then initiates a cross-chain communication based message to the second blockchain; at the same time, any on-line node of the second blockchain may receive the message. The implementation of the security of the message in the cross-link communication process can be described by the following specific embodiments.
Specifically, based on the blockchain technology, taking the first blockchain as an example, any one of the terminal devices 101, 102, 103, 104, 105 or 106 in the peer-to-peer network may install a first blockchain application or log on the first blockchain, when a user accesses the first blockchain on the terminal device, the terminal device is one of online nodes of the first blockchain, and if the node generates information under the first blockchain, the information is synchronously copied to other nodes of the first blockchain based on the peer-to-peer network.
It should be appreciated that any of the end devices 101, 102, 103, 104, 105, or 106 in the peer-to-peer network described above may be either a node of the first blockchain or a node of the second blockchain. That is, in the peer-to-peer network shown in fig. 1, more than one blockchain system may be running, or alternatively, any of the terminal devices 101, 102, 103, 104, 105 or 106 may access different blockchains, or multiple different blockchain applications simultaneously, etc.
In some embodiments, as shown in connection with fig. 1, the terminal device 101, 102, 103, 104, 105 or 106 may be a network node accessing the first blockchain or/and the second blockchain, and the network node may include a memory and a processor, where the memory stores a computer program executable on the processor, and the computer program implements the steps of the method for cross-chain communication provided in the following embodiments when the computer program is executed by the processor.
Based on the same inventive concept as the above-described embodiments, in some embodiments, a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of the cross-chain communication method provided in the following embodiments may also be provided.
Second embodiment
In this embodiment, the cross-link communication method of the present invention will be described in more detail according to the application example of the first embodiment described above.
Fig. 2 is a flowchart of a method of cross-link communication provided in an embodiment of the present invention.
In this embodiment, the cross-chain communication method is used to implement cross-chain communication between different blockchains, for example, a user sends information to a second blockchain on any network node of the first blockchain. The main execution body of the above-mentioned cross-chain communication method may be any node in the peer-to-peer network where the first blockchain or/and the second blockchain operates, for example, any terminal device 101, 102, 103, 104, 105 or 106 in the peer-to-peer network shown in fig. 1.
As shown in fig. 2, the above-mentioned cross-link communication method includes the following steps:
S210: when a first node accessing a first blockchain acquires first information of a user initiating a cross-chain request to a second blockchain on the first blockchain, determining whether the first node is a trusted node of the first blockchain selected by the user.
Specifically, the first node refers to a main body capable of executing the cross-chain communication method, and is a relative referent object, which can be specifically any node accessing the first blockchain. For example, each terminal device in the peer-to-peer network shown in fig. 1 has access to a first zone cross-link, then the first node may be any of said terminal devices 101, 102, 103, 104, 105 or 106. In addition, the first node may not be the point where the user initiates the cross-chain communication, i.e., there is a user initiating the cross-chain communication based first information on other nodes accessing the first blockchain, and all nodes on the first blockchain may receive the first information. Obviously, the first node may also be the node that initiates the first information.
In addition, because the first area cross-link access equipment does not all require real-time online, in the first blockchain network, if the first area cross-link access equipment is offline, only online nodes can process related data or information if the cross-link information is performed at the moment, and when the number of online nodes is low, the safety of data transmission is difficult to ensure. Based on the above, in this embodiment, when the first node obtains the first information initiated by the user, it is verified whether the current first node is the trusted node selected by the user when initiating the cross-link communication and recorded in the first information, and if so, it is authorized to continue to perform the cross-link communication. That is, the first information includes trusted node information selected by a user when initiating cross-chain communication on the first blockchain and recorded in the first information, and the trusted node is at least a trusted node of the first blockchain.
Specifically, a trusted node refers to a node that is approved or authenticated by the first blockchain. The trusted node is also a node in the first blockchain, and is different from the common node in that the trusted node is a node approved by all nodes or most nodes, and has higher reliability. In general, a voting scheme may be employed to select a certain number of trusted nodes on a first blockchain. For example, taking a federation chain as an example, an account number that can be recognized by more than 2/3 of the nodes within the federation can become a trusted node (account number).
In particular, the trusted node may be added by the blockchain at startup, or at run-time.
S220: if so, verifying whether the first node is a trusted node of the second blockchain.
Specifically, in the case that the first node is the trusted node selected by the user, this step continues to verify whether the first node is a trusted node of the second blockchain. That is, the cross-chain communication method is allowed to be performed only if the first node is a trusted node of both the first blockchain and the second blockchain.
The function is as follows: the user can select the trusted node from the intersection set of the trusted node set of the first blockchain and the trusted node set of the second blockchain to execute the cross-link communication, so that on one hand, the reliability of the node can be ensured, and on the other hand, the selected trusted node is required to be online, and the real-time performance of the cross-link communication is ensured.
In addition, as can be seen from the above description about the trusted node, the second area cross-chain trusted node is known, and for this reason, the confirmation can be implemented on a single node, which is not described herein.
S230: and if the first node is a trusted node of the second blockchain, verifying the validity of a first signature in the first information, wherein the first information comprises the first signature of the user.
Specifically, to implement cross-link communication, the first information may include the following contents:
initiating user information, which is marked as u;
first blockchain information, denoted a;
second blockchain information, denoted B;
Information transferred from the first blockchain to the second blockchain is denoted as msg;
initiating a trusted node selected by a user, and marking the trusted node as b;
And the signature of the initiating user on the above information, i.e., the first signature, is noted usign. It can be seen that the content included in the first information can be expressed as: ((u, A, B, msg, B), usign).
Illustratively, the initiating user information u may be a user ID; the first blockchain information A and the second blockchain information B can be respectively a chain ID of a cross-chain communication starting blockchain and a chain ID of a target blockchain; the information msg transferred from the first blockchain to the second blockchain can be transaction information and the like; the trusted node b selected by the initiating user can be selected from a trusted node intersection set of a first blockchain and a second blockchain; the first signature usign may be specifically a hash value obtained by performing hash calculation on the initiating user information u, the first blockchain information a, the second blockchain information B, and the information msg transferred from the first blockchain to the second blockchain, or based on an asymmetric encryption algorithm, encrypt the hash value by using a user private key to obtain encrypted data, or the like.
From the above, verifying the validity of the first signature can confirm whether the user has tampered with the content (u, a, B, msg, B) in the first information based on the cross-chain communication. Thereby ensuring the reliability and safety of the data in the link.
For example, assume that the first signature is a hash of content (u, a, B, msg, B) to obtain a first hash value. Then, verifying the signature at the first node, only performing hash calculation on the content (u, a, B, msg, B) to obtain a second hash value, and comparing whether the second hash value is consistent with the first hash value: if so, it can be confirmed that the content (u, A, B, msg, B) is not modified; otherwise, the content (u, a, B, msg, B) is modified. Since signature and signature verification are basic knowledge of blockchain technology, they are not described in detail herein.
It should be noted that, in the first blockchain, when a node that is not a trusted node acquires the first information, no further processing will be performed on the first information, so that the processing case for the node that is not a trusted node is omitted here, and because this case is not a contribution of the present invention to the prior art, a detailed discussion will not be made here.
S240: and if the first information is legal, the first node signs the first information to generate second information at least comprising the first information and the second signature.
Specifically, under the condition that the first information is legal, the first node signs the first information again, so that the reliability of the first information in the link can be further ensured.
Illustratively, as shown above, the content of the first information is: ((u, a, B, msg, B), usign), then the signature of the first information by the first node may be noted bsign. For this purpose, the content of the second information may be noted as: (((u, A, B, msg, B), usign), bsign).
S250: and sending the second information to a second blockchain.
According to the embodiment, when the cross-link communication is initiated to the second blockchain, the trusted nodes which are simultaneously approved by the first blockchain and the second blockchain are selected and recorded in the first information, so that the first information can only be used for executing the cross-link task by the selected trusted nodes, the selected trusted nodes can be ensured to be online nodes, the safety of the data cross-link communication is ensured, and the real-time performance of the cross-link calculation is ensured.
As can be seen from the above description, the above cross-chain communication scheme is illustrated from the first blockchain side. On the basis of the technical scheme, the technical scheme of the invention is further described from the second blockchain side.
Fig. 3 is a flow chart of a method of cross-chain communication provided in another embodiment of the present invention.
As shown in fig. 3, the cross-link communication method may further include the following steps S310 to S340:
S310: and when a second node accessing at least a second blockchain receives the second information, verifying whether the first node is a trusted node of the second blockchain.
Specifically, the second node is a node accessing to the second blockchain, and similarly, the second node may be any node in the peer-to-peer network where the second blockchain is running as shown in fig. 1. It should be understood that the second node and the first node may be two different nodes in the peer-to-peer network, that is, the two nodes are sequentially connected to a single blockchain and a second blockchain; furthermore, the second node and the first node may also be the same node in the peer-to-peer network, i.e. the node accesses both the first and second blockchains.
Any node in the second blockchain network can receive the second information sent by the first node on the first blockchain. Because the second information contains the trusted node b selected by the initiating user, the second node can verify whether the trusted node b selected by the user is the trusted node of the second blockchain according to the second information, so that the credibility of the executing node is ensured.
S320: if yes, determining the validity of the second information.
In some embodiments, the first signature and the second signature are included in the second information. For this purpose, determining the validity of the second information comprises the following steps:
s410: verifying the validity of the second signature;
S420: if so, then verifying whether the first signature is legal:
S430: if yes, determining that the second information is legal.
Wherein if the second signature is verified or the first signature is not legal, the second information will not be processed at this time. In particular implementations, the invention is not limited herein to processing mechanisms that do not pass signature verification. Exemplary processing mechanisms that do not pass signature verification may include stopping execution, discarding the second information, etc., and are not described in detail herein
In addition, based on the above description, the verification of the second signature and the first signature is the prior art, so the description is not repeated here.
S330: and if the second information is legal, recording the second information on the second block chain.
Specifically, recording the second information on the second blockchain may include recording information msg in the second information transferred from the first blockchain to the second blockchain on the second blockchain, thereby completing the cross-chain communication. For example, the second information is recorded on a block under the second node.
In addition, the recording of the second information on the second blockchain may also include receiving, on the second blockchain, information msg sent by the user on the first blockchain across chains, so as to complete the across-chain communication. For example, assuming that the information msg is "send 100 money to B", this action of sending money is performed in response to the information msg to complete the cross-link communication.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present invention.
Third embodiment
Based on the same general inventive concept as the second embodiment, correspondingly, the present embodiment further provides a cross-link communication device. Since the technical problems to be solved by the cross-link communication device and the cross-link communication method, the adopted technical scheme and the expected technical effects are the same, the present embodiment will be briefly described below, and if a clearer and complete technical scheme is to be understood, reference may be made to the above second embodiment.
Fig. 4 is a schematic diagram of a cross-link communication device according to an embodiment of the present invention.
Specifically, the illustrated cross-chain communication device is configured to be disposed on any node in a peer-to-peer network where the first blockchain or/and the second blockchain operates, as shown in fig. 4, the cross-chain communication device 400 includes: the cross-chain detection module 401 is configured to determine whether a first node accessing a first blockchain is a trusted node of the first blockchain selected by a user when the first node obtains first information of a cross-chain request initiated by the user to a second blockchain; a first trusted node verification module 402 configured to verify if the first node is a trusted node of the second blockchain if it is; a first signature verification module 403 configured to verify the validity of a first signature in the first information if the first node is a trusted node of the second blockchain, wherein the first information includes the first signature of the user; a signature module 404 configured to, if legal, sign the first information by the first node and generate second information at least including the first information and a second signature; the cross-chain sending module 405 is configured to send the second information to a second blockchain.
In some embodiments, the cross-chain communication device further comprises: a second trusted node verification module configured to verify whether the first node is a trusted node of a second blockchain when at least a second node accessing the second blockchain receives the second information; the second signature verification module is configured to determine the validity of the second information if yes; and the cross-chain response module is configured to record the second information on the second block chain if the second information is legal.
In some embodiments, the second trusted node verification module specifically includes: a first signature verification unit configured to verify the validity of the second signature; a second signature verification unit configured to re-verify whether the first signature is legitimate if it is legitimate: and the legal confirmation unit is configured to determine that the second information is legal if the second information is legal.
Specifically, the first information at least includes: initiating user information; first blockchain information; second blockchain information; information transferred by the first blockchain to the second blockchain; initiating a trusted node selected by a user; a first signature of the user to the above information is initiated.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention.