Disclosure of Invention
An object of the present disclosure is to provide a method, apparatus, storage medium and electronic device for blockchain to solve the above related technical problems.
To achieve the above object, according to a first aspect of embodiments of the present disclosure, there is provided a method for blockchain applied to a first node, the first node being a node in a node intersection, the node intersection being an intersection of a node in a first blockchain network and a node in a second blockchain network, the method comprising:
Transmitting a backup request to a second node in the second blockchain network, the backup request including blockhead information corresponding to a first blockchain of the first blockchain network;
Determining that the block header information of the first block chain is successfully backed up in response to receiving a backup success notification message sent by the second node, wherein the backup success notification message is generated by the second node after the block header information is successfully stored in the second block chain network;
and backing up the block data corresponding to the first block chain to a target storage space.
Optionally, the method further comprises:
Sending a backup recovery request to a third node in a second blockchain network, wherein the backup recovery request comprises the identity information of the first node;
receiving block header information sent by the third node;
Restoring the first blockchain according to the blockhead information and the blockdata corresponding to the target storage space;
the first blockchain is broadcast to other nodes in the node intersection.
Optionally, before the sending the backup request to the second node in the second blockchain network, the method further includes:
initiating a transaction blocking event in the first blockchain network;
and writing backup record information in the first blockchain.
Optionally, the first node is operated with an intelligent contract apparatus isolated from the first node system, and the method includes:
The first node performs the following operations by the smart contract device:
Transmitting a configuration information backup request to a fourth node in the second blockchain network, wherein the configuration information backup request comprises an encryption configuration information set and hash values of configuration information of target nodes, the target nodes comprise each node in the node intersection, and the encryption configuration information set comprises encryption configuration information obtained by encrypting the configuration information of each target node;
And in response to receiving a configuration information backup success notification message sent by the fourth node, determining that the configuration information backup is successful, wherein the configuration information backup success notification message is generated after the fourth node successfully saves the hash value of the configuration information of the encrypted configuration information set and the configuration information of each target node in the second blockchain network.
Optionally, the operations further comprise:
acquiring configuration information of each target node;
Generating an encryption key corresponding to each of the target nodes;
encrypting the configuration information of each target node through an encryption key corresponding to the target node to obtain the encryption configuration information of the target node;
performing key confusion on each encryption key to generate a confusion key corresponding to each target node;
and sending each confusion key to a target node corresponding to the confusion key.
Optionally, the performing key confusion on each encryption key to generate a confusion key corresponding to each target node includes:
dividing each encryption key into a target number of key segments, wherein the target number is the number of target nodes;
The obfuscation key is generated by the following formula:
I={(i,1),(i+1,2)...,(n,n-i+1),...(n-i,n-1),(n-i+1,n)}
Wherein I is a confusion key of the ith target node, the confusion key I includes n key segments, n is the number of the target nodes, (I, x) is an xth key segment obtained by dividing an encryption key of the ith target node, I e [1, n ], x e [1, n ], I and x are positive integers.
Optionally, the operations further comprise:
transmitting a configuration information recovery request to a fifth node in the second blockchain network;
receiving the encryption configuration information set and hash values of the configuration information sent by the fifth node;
obtaining a confusion secret key of each target node, wherein the confusion secret key is generated by carrying out secret key confusion on an encryption secret key corresponding to each target node, and the encryption secret key is a secret key used for encrypting configuration information corresponding to the target node;
determining an encryption key for each of the target nodes based on each of the confusion keys;
Decrypting the encrypted configuration information set through each encryption key to obtain configuration information of each target node;
verifying each piece of configuration information obtained through decryption through the hash value;
and recovering the node configuration of each target node based on each configuration information when the verification is successful.
According to a second aspect of embodiments of the present disclosure, there is provided a method for a blockchain, for use with a node in a second blockchain network, the method comprising:
Receiving a backup request sent by a first node, wherein the first node is a node in a node intersection set, the node intersection set is an intersection set of a node in a first blockchain network and a node in a second blockchain network, and the backup request comprises block header information of a first blockchain corresponding to the first blockchain network;
checking the block header information;
When the verification is successful, the block header information is stored in the second block chain network;
and sending a backup success notification message to the first node.
Optionally, the method further comprises:
receiving a backup recovery request sent by the first node;
verifying the identity information of the first node in the backup recovery request;
And when the verification is successful, the block header information is sent to the first node.
Optionally, the method further comprises:
Receiving a configuration information backup request sent by an intelligent contract device in the first node, wherein the configuration information backup request comprises an encryption configuration information set and hash values of configuration information of a target node, the encryption configuration information set comprises encryption configuration information obtained by encrypting the configuration information of the target node, the target node comprises each node in the node intersection, and the intelligent contract device is systematically isolated from the first node;
Storing the hash value of the encrypted configuration information set and the configuration information of the target node in the second blockchain network;
And sending a configuration information backup success notification message to the first node.
Optionally, the method further comprises:
receiving a configuration information recovery request sent by an intelligent contract device in the first node;
and sending the hash value of the encryption configuration information set and the configuration information of the target node to the intelligent contract device.
According to a third aspect of embodiments of the present disclosure, there is provided an apparatus for blockchain applied to a first node, the first node being a node in an intersection of a node in a first blockchain network and a node in a second blockchain network, the apparatus comprising:
a first sending module configured to send a backup request to a second node in the second blockchain network, the backup request including blockhead information of a first blockchain corresponding to the first blockchain network;
The first determining module is used for determining that the block header information of the first block chain is successfully backed up in response to receiving a backup success notification message sent by the second node, wherein the backup success notification message is generated by the second node after the block header information is successfully stored in the second block chain network;
and the execution module is used for backing up the block data corresponding to the first block chain to a target storage space.
Optionally, the apparatus further comprises:
a third sending module, configured to send a backup recovery request to a third node in a second blockchain network, where the backup recovery request includes identity information of the first node;
the second receiving module is used for receiving the block header information sent by the third node;
a first recovery module, configured to recover the first blockchain according to the blockhead information and the blockdata corresponding to the target storage space;
and the broadcasting module is used for broadcasting the first block chain to other nodes in the node intersection.
Optionally, the apparatus further comprises:
a transaction blocking initiating module for initiating a transaction blocking event in the first blockchain network before the first sending module sends a backup request to a second node in a second blockchain network;
and the writing module is used for writing backup record information in the first blockchain.
Optionally, the apparatus is isolated from the first node system, the apparatus further comprising:
A fourth sending module, configured to send a configuration information backup request to a fourth node in the second blockchain network, where the configuration information backup request includes an encrypted configuration information set and a hash value of configuration information of a target node, where the target node includes each node in the node intersection, and the encrypted configuration information set includes encrypted configuration information obtained by encrypting the configuration information of each target node;
And the second determining module is used for determining that the configuration information backup is successful in response to receiving a configuration information backup success notification message sent by the fourth node, wherein the configuration information backup success notification message is generated after the fourth node successfully saves the hash values of the configuration information of the encrypted configuration information set and the configuration information of each target node in the second blockchain network.
Optionally, the apparatus further comprises:
the first acquisition module is used for acquiring configuration information of each target node;
a first generation module for generating an encryption key corresponding to each of the target nodes;
The first encryption module is used for encrypting the configuration information of each target node through an encryption key corresponding to the target node to obtain the encryption configuration information of the target node;
The key confusion module is used for carrying out key confusion on each encryption key and generating a confusion key corresponding to each target node;
And a fifth sending module, configured to send each confusion key to a target node corresponding to the confusion key.
Optionally, the key confusion module includes:
A key segmentation sub-module, configured to segment each encryption key into a target number of key segments, where the target number is the number of target nodes;
a confusion key generation sub-module, configured to generate the confusion key according to the following formula:
I={(i,1),(i+1,2)...,(n,n-i+1),...(n-i,n-1),(n-i+1,n)}
Wherein I is a confusion key of the ith target node, the confusion key I includes n key segments, n is the number of the target nodes, (I, x) is an xth key segment obtained by dividing an encryption key of the ith target node, I e [1, n ], x e [1, n ], I and x are positive integers.
Optionally, the apparatus further comprises:
a sixth sending module, configured to send a configuration information recovery request to a fifth node in the second blockchain network;
a third receiving module, configured to receive the encrypted configuration information set and hash values of the configuration information sent by the fifth node;
The second obtaining module is used for obtaining the confusion secret key of each target node, wherein the confusion secret key is generated by carrying out secret key confusion on the encryption secret key corresponding to each target node, and the encryption secret key is the secret key used for encrypting the configuration information corresponding to the target node;
a third determining module, configured to determine an encryption key of each target node based on each confusion key;
The decryption module is used for decrypting the encryption configuration information set through each encryption key to obtain the configuration information of each target node;
The second checking module is used for checking each piece of configuration information obtained through decryption through the hash value;
And the second recovery module is used for recovering the node configuration of each target node based on each configuration information when the verification is successful.
According to a fourth aspect of embodiments of the present disclosure, there is provided an apparatus for a blockchain, for use with a node in a second blockchain network, the apparatus comprising:
the first receiving module is used for receiving a backup request sent by a first node, wherein the first node is a node in a node intersection set, the node intersection set is an intersection set of a node in a first blockchain network and a node in a second blockchain network, and the backup request comprises block header information of a first blockchain corresponding to the first blockchain network;
the first verification module is used for verifying the block header information;
the first storage module is used for storing the block header information in the second block chain network when the first verification module is successful in verification;
And the second sending module is used for sending a backup success notification message to the first node.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method of any of the first aspects described above.
According to a sixth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method of any of the second aspects described above.
According to a seventh aspect of embodiments of the present disclosure, there is provided an electronic device, comprising:
a memory having a computer program stored thereon;
A processor for executing the computer program in the memory to implement the steps of the method of any of the above first aspects.
According to an eighth aspect of embodiments of the present disclosure, there is provided an electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the method of any of the second aspects above.
In the above technical solution, the first node in the first blockchain network may interact with the second node in the second blockchain network, so as to store the blockhead data of the first blockchain in the first blockchain network in the second blockchain network, and back up the blockhead data of the first blockchain in the target storage space. Therefore, even if the first blockchain network is damaged, the second blockchain network can acquire the block header data of the first blockchain, so that account book recovery can be performed based on the block header data and the block data in the target storage space, and the accuracy of the account book data is ensured. And because the nodes in the node intersection are simultaneously in the first block chain network and the second block chain network, other nodes in the node intersection can acquire the block head data of the first block chain through the second block chain network, so that the sharing communication among the nodes can be maintained in the data backup and recovery process in the mode, and node disputes are reduced.
Additional features and advantages of the present disclosure will be set forth in the detailed description which follows.
Detailed Description
Specific embodiments of the present disclosure are described in detail below with reference to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating and illustrating the disclosure, are not intended to limit the disclosure.
Before introducing the method, the device, the storage medium and the electronic equipment for blockchain provided by the disclosure, an application scenario of the disclosure is first described. Embodiments provided by the present disclosure may be applied to a blockchain network backup scenario, which may be, for example, a federated chain, a public chain, and so forth.
Referring to a backup schematic diagram of a federated chain network shown in fig. 1, in a related scenario, a peer node may read configuration information of a blockchain ledger and its own node during a federated chain backup, and store the data in a storage medium. During recovery, the peer node reads the backup data in the storage medium, and rebuilds the blockchain network according to the backup data, so that other peer nodes can be added into the alliance chain network again to finish recovery.
Applicants have found that the ledger chain network has a tamper-proof nature when running. However, after the peer node stores the data in the local storage medium, other nodes cannot verify the data in any form, so that the node performing backup can tamper the data at will, upload the tampered account book when the network is restored, and finally threaten the security of the network. In addition, when the plurality of nodes are backed up separately, if the backup data of the plurality of nodes are inconsistent, in this case, the correct backup data cannot be determined from the plurality of backup data, which causes disputes between the nodes.
In addition, considering the security of the node configuration information, other nodes in the alliance chain have difficulty in sending the configuration information to a certain peer node for backup, so that the node configuration information is difficult to be effectively backed up. Meanwhile, under the condition that the configuration information is lost, the authority configuration of the node is automatically described by the peer node which rejoins the network, and the reliability is low.
To this end, the present disclosure provides a method for a blockchain, for use with a first node, with reference to a flowchart of a method for a blockchain shown in fig. 2, the method comprising:
in step S21, a backup request is sent to a second node in a second blockchain network, the backup request including blockhead information corresponding to a first blockchain of the first blockchain network.
The first node is a node in the node intersection, and the second node may or may not be a node in the node intersection. The node intersection is an intersection of a node in a first blockchain network and a node in a second blockchain network, the node intersection may include all or part of the nodes in the first blockchain network, and the node intersection may also include part or all of the nodes in the second blockchain network.
The first node may be any node in the node intersection, and may further store, by sending a backup request to a second node in the second blockchain network, blockhead information of a first blockchain in the backup request in the second blockchain network through the second node.
Of course, in some possible implementations, the steps regarding the first node in the embodiments provided by the present application may also be completed by deploying a smart contract. For example, the nodes in the node intersection may deploy backup smart contracts, and then the first node corresponding to the backup smart contracts or the smart contract devices in the first node perform relevant steps in the backup process. The smart contract device may be, for example, a contract container mounted by the first node.
For the block header information, the block header information may be, for example, the block header information of each block of the first blockchain or the block header information of a part of the block segments in the first blockchain according to different backup application scenarios.
Furthermore, in some embodiments, before the sending the backup request to the second node in the second blockchain network, the method further includes:
A transaction blocking event is initiated in the first blockchain network. For example, the first node may invoke a delay function in the associated smart contract to maintain a state in the first blockchain network in a transaction ongoing state. In this case, other transactions cannot be submitted and agreed, so that the service in the first blockchain network can be suspended, and the phenomenon that new transaction data are not backed up in the backup process is avoided continuously. In addition, the first node can write backup record information in the first blockchain so as to trace back the backup process.
Of course, in some embodiments, the backup request may also be sent separately from the block header information. Referring to a block chain data backup flow diagram shown in fig. 3, the first node may initiate transaction blocking after sending a backup request, and then send the first block chain block header data to the second node (this step is not shown).
In step S22, in response to receiving the backup success notification message sent by the second node, it is determined that the backup of the block header information of the first blockchain is successful.
The backup success notification message is generated by the second node after the block header information is successfully stored in the second blockchain network. For the manner of storing the block header information, in some implementation scenarios, the second node may store the block header information in a second blockchain corresponding to the second blockchain network. In other implementation scenarios, the second node may also store the hash value of the block header information in a second blockchain corresponding to the second blockchain network, which is not limited in this disclosure.
In step S23, the block data corresponding to the first blockchain is backed up to the target storage space. For example, the first node may backup the first blockchain data locally or in an associated storage space available for retrieval by the method shown in fig. 1.
That is, a first node in a first blockchain network may store blockhead data of a first blockchain in the first blockchain network in a second blockchain network by interacting with a second node in the second blockchain network and backing up the blockhead data of the first blockchain in a target storage space.
Therefore, even if the first blockchain network is damaged, the second blockchain network can acquire the block header data of the first blockchain, so that account book recovery can be performed based on the block header data and the block data in the target storage space, and the accuracy of the account book data is ensured. And because the nodes in the node intersection are simultaneously in the first block chain network and the second block chain network, other nodes in the node intersection can acquire the block head data of the first block chain through the second block chain network, so that the sharing communication among the nodes can be maintained in the data backup and recovery process in the mode, and node disputes are reduced.
After the block header information of the first block chain is saved through the second block chain network, the first block chain can be restored according to the saved block header information when the first block chain network is damaged. In this case, the method further comprises:
And sending a backup recovery request to a third node in the second blockchain network. The third node and the second node may be the same node or different nodes. It should be appreciated that after the block header information of the first blockchain is written into the second blockchain by the second node, the associated node in the second blockchain network may also save the block that includes the block header information. Thus, the third node may be another node than the second node. The backup recovery request may further include identity information of the first node, where the third node is configured to verify the identity of the first node according to the identity information. Of course, referring to a first blockchain recovery flowchart shown in fig. 4, the backup recovery request and the identity information may also be sent separately, which is not limited in this disclosure.
The third node may transmit block header information to the first node after the authentication of the identity information is passed. The first node, after receiving the block header information, may restore the first blockchain according to the block header information and the block data corresponding to the target storage space.
For example, the first node may sort the block data in the target storage space according to the sequence of the time stamps, and verify the block sorting according to the time stamp, the last block hash, the present block hash, and other information in the block header information, so as to restore the first block chain. Or as shown in fig. 4, the first node may also write the block data in the target storage space in sequence according to the block header information, so as to recover the first blockchain.
Further, the first node may also broadcast the first blockchain to other nodes in the node intersection to facilitate the other nodes in the node intersection to recover the first blockchain. Referring to fig. 4, in some implementations, after the first node recovers the first blockchain data, the first node may further send backup recovery record information to the third node, so as to verify and trace back the backup recovery information.
In this way, when the blockchain data is restored, the backup data can be verified according to the blockhead data acquired from the second blockchain network, so that the authenticity of the restored blockchain ledger is ensured.
In a possible embodiment, the first node runs a smart contract device isolated from the first node system, and the smart contract device may be, for example, a contract container mounted by a node or an execution carrier of a related smart contract, and the method includes:
The first node performs the following operations by the smart contract device:
And sending a configuration information backup request to a fourth node in the second blockchain network. The configuration information backup request comprises an encryption configuration information set and a hash value of the configuration information of the target node. The target node comprises each node in the node intersection, and the encryption configuration information set comprises encryption configuration information obtained by encrypting the configuration information of each target node. The configuration information may include, for example, organization members, keys, certificates, etc. to which the node corresponds. The fourth node may be the same node as the second node or may be a different node.
And responding to the received configuration information backup success notification message sent by the fourth node, and determining that the configuration information backup is successful. The configuration information backup success notification message may be generated by the fourth node after the encrypted configuration information set and hash values of configuration information of each target node are successfully stored in the second blockchain network.
By adopting the technical scheme, the intelligent contract device in the first node in the first blockchain network can interact with the fourth node in the second blockchain network, so that the hash value of the configuration information of the target node and the encryption configuration information set is stored in the second blockchain network. In this way, even if the first blockchain network is damaged, the hash value of the encrypted configuration information set and the configuration information of the target node can be obtained through the second blockchain network, so that the configuration of each node can be restored. In addition, because the intelligent contract device is isolated from the first node system, configuration information of each node in the backup process can be prevented from being leaked, and safety is improved.
Optionally, the operations further comprise:
And acquiring configuration information of each target node, and generating an encryption key corresponding to each target node. The encryption key may be generated randomly, for example, referring to a backup schematic diagram of one configuration information shown in fig. 5 (in the figure, the backup schematic diagram is shown by sending a configuration information backup request and an encryption configuration information set respectively), after generating the encryption key corresponding to each target node, the encryption key corresponding to the target node may be used to encrypt the configuration information of each target node, so as to obtain the encryption configuration information of the target node.
For example, fig. 6 is an encryption diagram of configuration information according to an exemplary embodiment of the disclosure, where the target node includes a node a, b, c, d, and the smart contract device may generate keys a-d corresponding to the target node a, b, c, d. In this way, the configuration information of the nodes a-d can be encrypted through the keys a-d, and the encrypted configuration information a-d is obtained. In addition, the smart contract device may, for example, further combine (e.g., arrange according to a node order) the encryption configuration information a to d to obtain an encryption configuration information set.
In some implementations, to maintain consistency of each node in a set of nodes, the smart contract device may also send (e.g., broadcast) the set of encrypted configuration information to other nodes in the set of nodes, thereby enabling secret sharing of configuration information.
Thus, after encryption is completed, the smart contract device may further perform key confusion on each of the encryption keys to generate a confusion key corresponding to each of the target nodes.
For example, in some embodiments, the obfuscation key may be obtained by:
Dividing each encryption key into a target number of key segments, wherein the target number is the number of target nodes. Along the line of a key confusion diagram shown in fig. 7 and using the above example, each key may be divided into 4 key segments for keys a-d.
After deriving the key segment, the obfuscated key may be generated by the following formula:
I={(i,1),(i+1,2)...,(n,n-i+1),...(n-i,n-1),(n-i+1,n)}
wherein I is a confusion key of the ith target node, the confusion key I includes n key segments, n is the number of the target nodes, (I, x) is an xth key segment obtained by dividing an encryption key of the ith target node, I e [1, n ], x e [1, n ], I and x are positive integers. Taking the 1 st to 4 th target nodes as the target nodes a to d, the confusion secret key of the target node a is:
I={(1,1),(2,2),(3,3),(4,4)}
namely, the confusion key a' of the target node a is a1, b2, c3, d4.
It should be noted that, as will be understood by those skilled in the art, the formula for obtaining the confusion key may also be changed correspondingly according to the division and the number of the key segments. Within the scope of the technical idea of the present disclosure, there may be a plurality of simple variants of the formula, which all fall within the protection scope of the present disclosure.
Further, after obtaining the confusion key of each target node, each confusion key may be sent to the target node corresponding to the confusion key.
That is, each target node may obtain a corresponding confusion key after performing configuration information backup through the smart contract device. The obfuscation key includes a portion of the encryption key of the configuration information of each target node, so each target node cannot individually decrypt the set of encrypted configuration information. By adopting the mode, the effect of recovering the configuration information of the alliance chain under the condition that all participating members agree can be realized, so that the consensus mechanism can be maintained unchanged, and the configuration information is prevented from being counterfeited.
After the hash values of the encryption configuration information set and the configuration information are stored through the second blockchain network, when the first blockchain network is damaged, the configuration of each target node can be restored according to the stored hash values of the encryption configuration information set and the configuration information. In this case, the operations further include:
And sending a configuration information recovery request to a fifth node in the second blockchain network. For example, referring to a recovery flow chart of configuration information shown in fig. 8, the first node may reconstruct the first blockchain network from local backup data, build an infrastructure of the first blockchain network, and configure the smart contract device to enable each target node in the node intersection to join the reconstructed first blockchain network. After the target node joins the rebuilt first blockchain network, the smart contract device may send a configuration information recovery request to a fifth node in the second blockchain network, and receive the encrypted configuration information set and the hash value of each configuration information sent by the fifth node.
The smart contract device may also obtain a confusion key for each of the target nodes and determine an encryption key for each of the target nodes based on each of the confusion keys. The confusion secret key is generated by carrying out secret key confusion on the encryption secret key corresponding to each target node, and the encryption secret key is the secret key used when the configuration information corresponding to the target node is encrypted. With the examples of fig. 6 and 7, after obtaining the confusion key of each target node, each key segment belonging to the same encryption key in each confusion key may be combined in the division order, for example, the key segments a1, a2, a3, a4 obtained by dividing the encryption key a (corresponding to the target node a) may be combined, thereby obtaining the encryption key a.
In this way, the encryption configuration information set can be decrypted through each encryption key to obtain the configuration information of each target node, and each configuration information obtained through decryption is verified through the hash value. For example, the hash value of the configuration information may be obtained by calculating and decrypting the corresponding hash function, and the hash value may be compared with the hash value of the configuration information of each target node stored in the second blockchain network. If the two are the same, then a successful verification can be determined.
Further, when the verification is successful, the node configuration of each target node can be restored based on each configuration information.
By the mode, backup and recovery of configuration information can be completed, and disaster recovery capacity of the blockchain network is improved.
It should be noted that, in the foregoing embodiments, in order to describe each embodiment of the method for blockchain, descriptions are provided for the second node, the third node, the fourth node, the fifth node, and so on. Those skilled in the art will appreciate that in the implementation, the second node, the third node, the fourth node, and the fifth node may be the same node in the second blockchain network or different nodes in the second blockchain network, which is not limited in this disclosure.
Fig. 9 is a flowchart illustrating a method for a blockchain, for example, that may be applied to a node in a second blockchain network in the above-described embodiments, in accordance with an exemplary embodiment of the present disclosure, and with reference to fig. 9, the method includes:
in step S91, a backup request sent by the first node is received.
The first node is a node in a node intersection set, the node intersection set is an intersection set of a node in a first blockchain network and a node in a second blockchain network, and the backup request comprises block header information of a first blockchain corresponding to the first blockchain network.
In step S92, the block header information is checked.
In some embodiments, the subject of the method steps illustrated in fig. 9 may be, for example, a second node in a second blockchain network, which may be, for example, a node in the node intersection, in which case the second node may also store the related data of the first blockchain. Thus, the second node can compare the block header information with the block header information of the first block chain stored by itself, thereby completing the verification.
In other embodiments, the first node may also provide a related data interface, so that the second node may obtain the block header information of the first block chain according to the data interface, and further verify the block header information sent by the first node.
In step S93, when the verification is successful, the block header information is stored in the second blockchain network. For example, the second node may store the block header information in a second blockchain corresponding to the second blockchain network. The second node may also store the hash value of the block header information in a second blockchain corresponding to the second blockchain network, which is not limited in the disclosure.
In step S94, a backup success notification message is sent to the first node.
That is, a first node in a first blockchain network may store blockhead data of a first blockchain in the first blockchain network in a second blockchain network by interacting with a second node in the second blockchain network and backing up the blockhead data of the first blockchain in a target storage space.
Therefore, even if the first blockchain network is damaged, the second blockchain network can acquire the block header data of the first blockchain, so that account book recovery can be performed based on the block header data and the block data in the target storage space, and the accuracy of the account book data is ensured. And because the nodes in the node intersection are simultaneously in the first block chain network and the second block chain network, other nodes in the node intersection can acquire the block head data of the first block chain through the second block chain network, so that the sharing communication among the nodes can be maintained in the data backup and recovery process in the mode, and node disputes are reduced.
Alternatively, referring to fig. 4, the execution body of the method steps shown in fig. 9 may also be the third node in the foregoing embodiment, and the method further includes:
receiving a backup recovery request sent by the first node;
verifying the identity information of the first node in the backup recovery request;
And when the verification is successful, the block header information is sent to the first node.
In this way, when the blockchain data is restored, the backup data can be verified according to the blockhead data acquired from the second blockchain network, so that the authenticity of the restored blockchain ledger is ensured.
In some scenarios, the first node may also send backup recovery record information to the third node after recovering the first blockchain data. In this case, the third node may further store the backup restoration record information in the second blockchain in response to receiving the backup restoration record information, so as to document and trace the backup restoration information.
Optionally, the method further comprises:
And receiving a configuration information backup request sent by the intelligent contract device in the first node. The configuration information backup request comprises an encryption configuration information set and hash values of configuration information of a target node, the encryption configuration information set comprises encryption configuration information obtained by encrypting the configuration information of the target node, the target node comprises each node in the node intersection, and the intelligent contract device is systematically isolated from the first node.
Storing the hash value of the encrypted configuration information set and the configuration information of the target node in the second blockchain network;
And sending a configuration information backup success notification message to the first node.
By adopting the technical scheme, the intelligent contract device in the first node in the first blockchain network can interact with the fourth node in the second blockchain network, so that the hash value of the configuration information of the target node and the encryption configuration information set is stored in the second blockchain network. In this way, even if the first blockchain network is damaged, the hash value of the encrypted configuration information set and the configuration information of the target node can be obtained through the second blockchain network, so that the configuration of each node can be restored. In addition, because the intelligent contract device is isolated from the first node system, configuration information of each node in the backup process can be prevented from being leaked, and safety is improved.
In one possible embodiment, the method further comprises:
receiving a configuration information recovery request sent by an intelligent contract device in the first node;
and sending the hash value of the encryption configuration information set and the configuration information of the target node to the intelligent contract device.
By the mode, backup and recovery of configuration information can be completed, and disaster recovery capacity of the blockchain network is improved.
Based on the same inventive concept, the present disclosure further provides an apparatus for a blockchain, and fig. 10 is a block diagram of an apparatus for a blockchain, which is shown in an exemplary embodiment of the present disclosure, and the apparatus may be applied to a first node, where the first node is a node in a node intersection, and the node intersection is an intersection of a node in a first blockchain network and a node in a second blockchain network, and the apparatus 1000 includes:
A first sending module 1001, configured to send a backup request to a second node in the second blockchain network, where the backup request includes blockhead information corresponding to a first blockchain of the first blockchain network;
A first determining module 1002, configured to determine that the block header information of the first blockchain is successfully backed up in response to receiving a backup success notification message sent by the second node, where the backup success notification message is generated by the second node after the block header information is successfully stored in the second blockchain network;
and an execution module 1003, configured to backup the block data corresponding to the first blockchain to a target storage space.
In the above technical solution, the first node in the first blockchain network may interact with the second node in the second blockchain network, so as to store the blockhead data of the first blockchain in the first blockchain network in the second blockchain network. Therefore, even if the first blockchain network is damaged, the block head data of the first blockchain can be acquired through the second blockchain network, so that account book recovery can be performed based on the block head data, and the accuracy of the account book data is ensured. And because the nodes in the node intersection are simultaneously in the first block chain network and the second block chain network, other nodes in the node intersection can acquire the block head data of the first block chain through the second block chain network, so that the sharing communication among the nodes can be maintained in the data backup and recovery process in the mode, and node disputes are reduced.
Optionally, the apparatus 1000 further includes:
a third sending module, configured to send a backup recovery request to a third node in a second blockchain network, where the backup recovery request includes identity information of the first node;
the second receiving module is used for receiving the block header information sent by the third node;
a first recovery module, configured to recover the first blockchain according to the blockhead information and the blockdata corresponding to the target storage space;
and the broadcasting module is used for broadcasting the first block chain to other nodes in the node intersection.
Optionally, the apparatus 1000 further includes:
a transaction blocking initiating module for initiating a transaction blocking event in the first blockchain network before the first sending module sends a backup request to a second node in a second blockchain network;
and the writing module is used for writing backup record information in the first blockchain.
Optionally, the apparatus 1000 is isolated from the first node system, and the apparatus 1000 further comprises:
A fourth sending module, configured to send a configuration information backup request to a fourth node in the second blockchain network, where the configuration information backup request includes an encrypted configuration information set and a hash value of configuration information of a target node, where the target node includes each node in the node intersection, and the encrypted configuration information set includes encrypted configuration information obtained by encrypting the configuration information of each target node;
And the second determining module is used for determining that the configuration information backup is successful in response to receiving a configuration information backup success notification message sent by the fourth node, wherein the configuration information backup success notification message is generated after the fourth node successfully saves the hash values of the configuration information of the encrypted configuration information set and the configuration information of each target node in the second blockchain network.
Optionally, the apparatus 1000 further includes:
the first acquisition module is used for acquiring configuration information of each target node;
a first generation module for generating an encryption key corresponding to each of the target nodes;
The first encryption module is used for encrypting the configuration information of each target node through an encryption key corresponding to the target node to obtain the encryption configuration information of the target node;
The key confusion module is used for carrying out key confusion on each encryption key and generating a confusion key corresponding to each target node;
And a fifth sending module, configured to send each confusion key to a target node corresponding to the confusion key.
Optionally, the key confusion module includes:
A key segmentation sub-module, configured to segment each encryption key into a target number of key segments, where the target number is the number of target nodes;
a confusion key generation sub-module, configured to generate the confusion key according to the following formula:
I={(i,1),(i+1,2)...,(n,n-i+1),...(n-i,n-1),(n-i+1,n)}
Wherein I is a confusion key of the ith target node, the confusion key I includes n key segments, n is the number of the target nodes, (I, x) is an xth key segment obtained by dividing an encryption key of the ith target node, I e [1, n ], x e [1, n ], I and x are positive integers.
Optionally, the apparatus 1000 further includes:
a sixth sending module, configured to send a configuration information recovery request to a fifth node in the second blockchain network;
a third receiving module, configured to receive the encrypted configuration information set and hash values of the configuration information sent by the fifth node;
The second obtaining module is used for obtaining the confusion secret key of each target node, wherein the confusion secret key is generated by carrying out secret key confusion on the encryption secret key corresponding to each target node, and the encryption secret key is the secret key used for encrypting the configuration information corresponding to the target node;
a third determining module, configured to determine an encryption key of each target node based on each confusion key;
The decryption module is used for decrypting the encryption configuration information set through each encryption key to obtain the configuration information of each target node;
The second checking module is used for checking each piece of configuration information obtained through decryption through the hash value;
And the second recovery module is used for recovering the node configuration of each target node based on each configuration information when the verification is successful.
The present disclosure also provides an apparatus for a blockchain, for use with a node in a second blockchain network, with reference to a block diagram of an apparatus for a blockchain shown in fig. 11, the apparatus 11 comprising:
A first receiving module 1101, configured to receive a backup request sent by a first node, where the first node is a node in a node intersection, and the node intersection is an intersection between a node in a first blockchain network and a node in the second blockchain network, and the backup request includes blockhead information corresponding to a first blockchain of the first blockchain network;
a first verification module 1102, configured to verify the block header information;
A first storage module 1103, configured to store the block header information in the second blockchain network when the first verification module is successful;
a second sending module 1104 is configured to send a backup success notification message to the first node.
Optionally, the apparatus 1100 further includes:
a fourth receiving module, configured to receive a backup recovery request sent by the first node;
A third verification module, configured to verify identity information of the first node in the backup recovery request;
and the seventh sending module is used for sending the block header information to the first node when the third checking module is successful in checking.
Optionally, the apparatus 1100 further includes:
A fifth receiving module, configured to receive a configuration information backup request sent by an intelligent contract device in the first node, where the configuration information backup request includes an encrypted configuration information set and a hash value of configuration information of a target node, the encrypted configuration information set includes encrypted configuration information obtained by encrypting configuration information of the target node, the target node includes each node in the node intersection, and the intelligent contract device is systematically isolated from the first node;
The second storage module is used for storing the hash value of the encryption configuration information set and the configuration information of the target node in the second blockchain network;
and the eighth sending module is used for sending a configuration information backup success notification message to the first node.
Optionally, the apparatus 1100 further includes:
a sixth receiving module, configured to receive a configuration information recovery request sent by an intelligent contract device in the first node;
and a ninth sending module, configured to send the hash value of the encrypted configuration information set and the configuration information of the target node to the smart contract device.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
The present disclosure also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor implements the steps of the method for blockchain for a first node provided by the present disclosure.
The present disclosure also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor implements the steps of the method for blockchain for nodes in a second blockchain network provided by the present disclosure.
The present disclosure also provides an electronic device, including:
a memory having a computer program stored thereon;
A processor for executing the computer program in the memory to implement the steps of the method for blockchain for the first node provided by the present disclosure.
Fig. 12 is a block diagram of an electronic device 1200, according to an example embodiment. As shown in fig. 12, the electronic device 1200 may include a processor 1201 and a memory 1202. The electronic device 1200 may also include one or more of a multimedia component 1203, an input/output (I/O) interface 1204, and a communications component 1205.
Wherein the processor 1201 is configured to control the overall operation of the electronic device 1200 to perform all or part of the steps in the method for blockchain for the first node described above. The memory 1202 is used to store various types of data to support operations on the electronic device 1200, which may include, for example, instructions for any application or method operating on the electronic device 1200, as well as application-related data, such as messages, pictures, audio, video, block data, certificates, and the like. The Memory 1202 may be implemented by any type or combination of volatile or non-volatile Memory devices, such as static random access Memory (Static Random Access Memory, SRAM for short), electrically erasable programmable Read-Only Memory (ELECTRICALLY ERASABLE PROGRAMMABLE READ-Only Memory, EEPROM for short), erasable programmable Read-Only Memory (Erasable Programmable Read-Only Memory, EPROM for short), programmable Read-Only Memory (Programmable Read-Only Memory, PROM for short), read-Only Memory (ROM for short), magnetic Memory, flash Memory, magnetic disk, or optical disk. The multimedia component 1203 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen, the audio component being for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in the memory 1202 or transmitted through the communication component 1205. The audio assembly further comprises at least one speaker for outputting audio signals. The I/O interface 1204 provides an interface between the processor 1201 and other interface modules, which may be a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 1205 is used for wired or wireless communication between the electronic device 1200 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, near Field Communication (NFC) for short, 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or one or a combination of more of them, is not limited herein. The communication component 1205 may accordingly include a Wi-Fi module, a bluetooth module, an NFC module, etc.
In an exemplary embodiment, the electronic device 1200 may be implemented by one or more Application-specific integrated circuits (ASICs), digital signal processors (DIGITAL SIGNAL processors, DSPs), digital signal processing devices (DIGITAL SIGNAL Processing Device, DSPDs), programmable logic devices (Programmable Logic Device, PLDs), field programmable gate arrays (Field Programmable GATE ARRAY, FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above-described method for a blockchain for a first node.
In another exemplary embodiment, a computer readable storage medium is also provided comprising program instructions which, when executed by a processor, implement the steps of the method for blockchain for a first node described above. For example, the computer readable storage medium may be the memory 1202 described above including program instructions executable by the processor 1201 of the electronic device 1200 to perform the method for blockchain for the first node described above.
The present disclosure also provides an electronic device, including:
a memory having a computer program stored thereon;
A processor for executing the computer program in the memory to implement the steps of the method for blockchain for nodes in the second blockchain network provided by the present disclosure.
Fig. 13 is a block diagram of an electronic device 1300, according to an example embodiment. As shown in fig. 13, the electronic device 1300 may include a processor 1301 and a memory 1302. The electronic device 1300 may also include one or more of a multimedia component 1303, an input/output (I/O) interface 1304, and a communication component 1305.
Wherein the processor 1301 is configured to control the overall operation of the electronic apparatus 1300 to perform all or part of the steps in the method for blockchain for a node in the second blockchain network described above. The memory 1302 is used to store various types of data to support operations at the electronic device 1300, which may include, for example, instructions for any application or method operating on the electronic device 1300, as well as application-related data, such as messages, pictures, audio, video, block data, certificates, and the like. The Memory 1302 may be implemented by any type or combination of volatile or non-volatile Memory devices, such as static random access Memory (Static Random Access Memory, SRAM for short), electrically erasable programmable Read-Only Memory (ELECTRICALLY ERASABLE PROGRAMMABLE READ-Only Memory, EEPROM for short), erasable programmable Read-Only Memory (Erasable Programmable Read-Only Memory, EPROM for short), programmable Read-Only Memory (Programmable Read-Only Memory, PROM for short), read-Only Memory (ROM for short), magnetic Memory, flash Memory, magnetic disk, or optical disk. The multimedia component 1303 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen, the audio component being for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in the memory 1302 or transmitted through the communication component 1305. The audio assembly further comprises at least one speaker for outputting audio signals. The I/O interface 1304 provides an interface between the processor 1301 and other interface modules, which may be a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 1305 is used for wired or wireless communication between the electronic device 1300 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, near Field Communication (NFC) for short, 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or one or a combination of more of them, is not limited herein. Accordingly, the communication component 1305 may include a Wi-Fi module, a bluetooth module, an NFC module, etc.
In an exemplary embodiment, the electronic device 1300 may be implemented by one or more Application-specific integrated circuits (ASICs), digital signal processors (DIGITAL SIGNAL processors, DSPs), digital signal processing devices (DIGITAL SIGNAL Processing Device, DSPDs), programmable logic devices (Programmable Logic Device, PLDs), field programmable gate arrays (Field Programmable GATE ARRAY, FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above-described methods for blockchains for nodes in a second blockchain network.
In another exemplary embodiment, a computer readable storage medium is also provided comprising program instructions which, when executed by a processor, implement the steps of the method for blockchains for a node in a second blockchain network as described above. For example, the computer readable storage medium may be the memory 1302 including program instructions described above that are executable by the processor 1301 of the electronic apparatus 1300 to perform the method for blockchain for a node in the second blockchain network described above.
In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable apparatus, the computer program having code portions for performing the above-described method for a first node for a blockchain when executed by the programmable apparatus.
In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable apparatus, the computer program having code portions for performing the above-described method for blockchain for a node in a second blockchain network when executed by the programmable apparatus.
The preferred embodiments of the present disclosure have been described in detail above with reference to the accompanying drawings, but the present disclosure is not limited to the specific details of the embodiments described above, and various simple modifications may be made to the technical solutions of the present disclosure within the scope of the technical concept of the present disclosure, and all the simple modifications belong to the protection scope of the present disclosure.
In addition, the specific features described in the foregoing embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, the present disclosure does not further describe various possible combinations.
Moreover, any combination between the various embodiments of the present disclosure is possible as long as it does not depart from the spirit of the present disclosure, which should also be construed as the disclosure of the present disclosure.