Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are illustrative and intended to be illustrative of the invention and are not to be construed as limiting the invention.
Based on the analysis, the confidentiality of the communication of the existing block chain network is not strong, the safety of the communication cannot be guaranteed, and in order to solve the technical problem, the public key certificate technology is introduced, and the public key certificate technology does not need to maintain a directory containing names and public keys, so that the public key distribution mode is safer.
Specifically, the present invention provides an encryption communication system of block chain nodes, as shown in fig. 1, in the encryption communication system of block chain nodes provided by the present invention, a block chain network includes, in addition to nodes with the same status (mining nodes), a supervisor node, which serves as an initiator of the block chain, distributes an encryption private key for security of a new participating node of each block chain, so as to supervise security of all mining nodes, wherein if a new participating node joins successfully, the new mining node is a new mining node.
That is to say, in the embodiment of the present invention, the node of the blockchain is subjected to identity authentication and encrypted transmission of information based on a public key certificate technology, the core of the public key certificate technology is a pair of keys (in the present invention, a first encrypted public key and a first encrypted private key are represented), and the basic principle is as follows: information content encrypted by one key can only be decrypted by another key with which it is paired. The first encryption public key can be widely issued to correspondent, namely the mining node, and the first encryption private key needs to be stored safely. In use, the target node can encrypt the transaction information by using the first signature public key of the participating node and transmit the encrypted transaction information to the participating node, and the participating node can use the first signature private key of the participating node to complete decryption.
An encrypted communication method and system of a blockchain node according to an embodiment of the present invention are described below with reference to the drawings.
In order to make the flow of the encryption communication method of the blockchain node of the embodiment of the present invention clearer for those skilled in the art, the following description focuses on an embodiment of an encryption communication system of blockchain nodes, as shown in fig. 2, the system includes a participatingnode 100, amining node 200, asupervising node 300 and atarget node 210, which join a blockchain network for the first time, where thetarget node 210 is themining node 200 communicating with the participatingnode 100, thesupervising node 300 is usually an initiator of the blockchain, and in many scenarios, such as financial transactions and intra-enterprise communication, the involved encryption must be able to be effectively supervised, and thesupervising node 300 is used as a supervisor to implement a corresponding supervision function, and it can be understood that thesupervising node 300 is higher in level than other nodes.
In the encrypted communication of the block link points, thetarget node 210 is themining node 200 communicating with the participatingnode 100, and the communication flow of thesupervisory node 300 is shown in fig. 3, wherein thetarget node 210 and themining node 200 are identified by using the same main body as that of themining node 200 communicating with the participating node 100:
referring to fig. 3, in the embodiment of the present invention, a participating node that joins in a blockchain network for the first time signs a first user identifier and a first signature public key of the participating node using a first signature private key of the participating node, and sends a first join broadcast message to the blockchain network after a timestamp is stamped by a timestamp server (step 11), a mining node analyzes the first join broadcast message to obtain the first user identifier and the first signature public key, and searches whether a blockchain account book currently stored by a local node has the first user identifier, if it is detected that the first user identifier does not exist, the participating node is signed and verified by the first signature public key, and if the first user identifier does not exist, the participating node is verified to be legitimate, so that the first join broadcast message is written into a new block and then broadcast to the blockchain network (step 12).
And then, the supervision node analyzes the received broadcast message of the new block, acquires a first user identifier and a first signature public key, generates a first encryption public key and a first encryption private key corresponding to the first user identifier, encrypts the first encryption private key by using the first signature public key to generate first encryption data, signs the first encryption data, the first encryption public key and the first user identifier by using the signature private key of the supervision node, and sends a first key configuration broadcast message to the block chain network (step 13).
In step 3, as shown in fig. 3, if the presence of the first subscriber identity is detected, it indicates that the participating node already exists, so as to discard the first join broadcast message. In this embodiment, if two join broadcast messages containing the same user identifier are received, the user identifier with the later timestamp is discarded, so as to avoid the repeated joining of the participating nodes.
The participating node analyzes the received first key configuration broadcast message, acquires first encrypted data and a first encrypted public key corresponding to the first user identifier, and decrypts the first encrypted data by using the first signature private key to acquire a first encrypted private key (step 14).
The target node analyzes the received first key configuration broadcast message, acquires a first encryption public key corresponding to the first user identifier, encrypts first data sent to the participating node by using the first encryption public key to generate first encrypted communication data, signs by using a second signature private key of the target node, and sends the first encrypted communication data to the participating node (step 15).
The participating node analyzes the content of the block chain to obtain a second signature public key corresponding to a second user identifier of the target node, the second signature public key is applied to carry out signature verification on first encrypted communication data sent by the target node, if the verification is passed, the target node is legal, the first encrypted communication data is decrypted by the first encryption private key to obtain first data, and therefore the secure communication between the participating node and the target node is completed based on the first encryption private key and the first encryption public key which are matched with each other (step 16).
In an embodiment of the present invention, in order to more fully embody the operation flow of the system, the following description is focused on a target node side, where, referring to fig. 4, a target node joining in a blockchain network for the first time signs a second user identifier and a second signature public key of the target node with a second signature private key of the target node, sends a second join broadcast message to the blockchain network after stamping a timestamp through a timestamp server (step 21), a mining node analyzes the second join broadcast message sent by the target node joining in the blockchain network for the first time to obtain the second user identifier and the second signature public key, and retrieves whether a blockchain account book currently stored in a local node has the second user identifier, if detecting that the second user identifier does not exist, performs signature verification on the target node through the second signature public key, and if the second user identifier does not exist, the second join broadcast message is written to the new block and broadcast to the blockchain network (step 22).
Similarly, the supervision node analyzes the received broadcast message of the new block, acquires a second user identifier and a second signature public key, generates a second encryption public key and a second encryption private key corresponding to the second user identifier, encrypts the second encryption private key by using the second signature public key to generate second encryption data, signs the second encryption data, the second encryption public key and the second user identifier by using the signature private key of the supervision node, and sends a second key configuration broadcast message to the block chain network (step 23).
The participating node analyzes the second key configuration broadcast message, acquires a second encryption public key corresponding to the second user identifier, encrypts second data sent to the target node by using the second encryption public key to generate second encrypted communication data, signs by using the first signature private key, and sends the second encrypted communication data to the target node (step 24).
And finally, the target node analyzes the block chain content to obtain a first signature public key corresponding to the first user identifier of the participating node, the first signature public key is applied to carry out signature verification on second encrypted communication data sent by the participating node, and if the second encrypted communication data passes the verification, the second encrypted communication data is decrypted by using a second encryption private key configured for the target node by the supervision node to obtain second data (step 25).
Therefore, the encryption communication system of the blockchain node in the embodiment of the invention combines the public key certificate scheme with the blockchain network, ensures the communication safety of the blockchain network, and ensures the operation stability of the blockchain network by carrying out overall supervision based on the supervision node.
In order to describe details of the implementation of the encryption communication system of the blockchain node according to the embodiment of the present invention in more detail, so that those skilled in the art will be clearer about the encryption communication process of the blockchain node according to the present invention, the following description focuses on details of the communication process on the encryption communication method side of the blockchain node.
Fig. 5 is a flowchart of an encrypted communication method of a blockchain node according to an embodiment of the present invention, as shown in fig. 5, the method including:
step 101, joining a participating node of a blockchain network for the first time, signing a first user identifier and a first signature public key of the participating node by using a first signature private key of the participating node, and sending a first joining broadcast message to the blockchain network after a timestamp is printed by a timestamp server.
It can be understood that, due to the application requirements and the development of the blockchain, the nodes in the blockchain network are not fixed, the blockchain network allows new participating nodes to join, and in order to verify the validity of the participating nodes that join for the first time and prevent illegal devices from falsely joining the blockchain network with the participating nodes to intercept related transaction information, in the embodiment of the present invention, the validity is verified based on a public key certificate mechanism.
Specifically, a participating node of the blockchain network is added for the first time, and the first signature private key of the participating node is used to sign the first user identifier and the first signature public key of the participating node, obviously, after receiving the first user identifier and the first signature public key in the first broadcast message, other nodes in the blockchain network can authenticate the identity of the new participating node based on the first signature public key and the first user identifier, and the principle of the identity authentication will be described in the subsequent steps.
The first user identifier may be information that uniquely identifies the participating node, such as a device identifier and a network access permission number of the participating node.
Of course, in order to ensure the validity and security of the participating nodes after being allowed to join the blockchain network in the actual implementation process, the time marking is also performed on the first broadcast message.
In one embodiment of the invention, a timestamp is printed by a timestamp server and a first join broadcast message is sent to a blockchain network, so that if two join broadcast messages containing the same user identification are received by a mining node, the user identification behind the timestamp is discarded, and other illegal nodes are prevented from pretending to be participating nodes to try to join the blockchain network or intercept related transaction information by intercepting the user identification.
It should be noted that, in the embodiment of the present invention, according to the distance between the participating node and the mining node and the difference of the network connection conditions, the manner of sending the first broadcast message by the participating node may be infrared, bluetooth, NFC (near field Communication), WiFi, and the like.
102, the mining node analyzes the first join broadcast message to acquire a first user identifier and a first signature public key, searches whether the block chain account book currently stored by the local node has the first user identifier, if the first user identifier is detected to be absent, performs signature verification on the join node through the first signature public key, and if the first join broadcast message passes the signature verification, writes the first join broadcast message into a new block and broadcasts the new block chain account to the block chain network.
Specifically, the mining node analyzes the first join broadcast message to obtain a first user identifier and a first signature public key, in order to ensure that the join node is a valid and legal node, whether the first user identifier exists in a block chain account book currently stored in the local node is searched, if the first user identifier does not exist, the node is determined as a newly participating node, and therefore signature verification is performed on the join node through the first signature public key, and the join node is prevented from being falsely identified as the join node by other illegal devices.
The first signature public key and the signature are mutually decryption passwords based on a public key certificate technology, only a first signature private key owned by the participating node can correspond to data encrypted by the first signature public key, so that the participating node is signed and verified by the first signature public key, if the verification is passed, the corresponding signature corresponds to the first signature public key, for example, after the first signature public key is sent to the participating node corresponding to the first user identifier, the first signature private key in the participating node is matched with the first signature public key, for example, after the data encrypted by the signature public key is sent to the participating node corresponding to the first user identifier, the first signature private key in the participating node can decrypt the data, therefore, after the verification is passed, the data is broadcasted to the whole network based on an operation mechanism of a block chain network so as to obtain the record of the event by the whole network node, and the mining node writes the first join broadcast message into the new block and broadcasts the new block to the block chain network.
In an embodiment of the present invention, if it is detected that the first subscriber identity exists, the first join broadcast message is discarded, so as to avoid repeated writing of the participating node.
Step 103, the supervision node analyzes the received broadcast message of the new block, obtains the first user identifier and the first signature public key, and generates a first encryption public key and a first encryption private key corresponding to the first user identifier.
After the participating node is successfully written into the block, the participating node is indicated to be successfully accessed into the block chain network as a new mining node, so that in order to enable the participating node to safely communicate with other nodes, the supervision node allocates the corresponding encryption key pair to the node participating in the first time, the participating node can conveniently communicate with other mining nodes based on the encryption key pair allocated by the supervision node, and the communication safety is ensured.
Specifically, the supervision node analyzes the received broadcast message of the new block, acquires a first user identifier and a first signature public key, and generates a first encryption public key and a first encryption private key corresponding to the first user identifier, so as to complete generation of an encryption key pair of the participating node.
In different application scenarios, the manner in which the supervisory node generates the first encryption public key and the first encryption private key includes, but is not limited to, generation using a Certificate Authority (CA), and the like.
And 104, the supervision node encrypts the first encryption private key by using the first signature public key to generate first encryption data, signs the first encryption data, the first encryption public key and the first user identifier by using the signature private key of the supervision node, and then sends a first key configuration broadcast message to the blockchain network.
Specifically, the supervision node encrypts the first encryption private key by using the first signature public key to generate first encryption data, and signs the first encryption data, the first encryption public key and the first user identifier by using the signature private key of the supervision node and then sends a first key configuration broadcast message to the blockchain network, so that although the nodes in the blockchain network can receive the first encryption data, the supervision node encrypts the first encryption private key by using the first signature public key to generate the first encryption data, only a participating node which owns the first signature private key corresponding to the first signature public key can decrypt the corresponding first encryption private key, and the first encryption private key is guaranteed to be uniquely owned by the participating node.
In addition, the first encrypted public key and the first user identification are sent in a broadcast mode, so that the mining node receiving the broadcast message can store the first encrypted public key corresponding to the first user identification conveniently, and a reliable safe channel is provided for the mining node to communicate with the participating nodes. And the signature private key of the supervision node is used for signing the first key configuration information, so that the situation that the illegal terminal pretends that the supervision node distributes false information to influence the communication safety is avoided.
Step 105, the participating node analyzes the received first key configuration broadcast message, obtains first encrypted data and a first encrypted public key corresponding to the first user identifier, and decrypts the first encrypted data by using the first signature private key to obtain the first encrypted private key.
Specifically, the participating node analyzes the received first key configuration broadcast message, and acquires first encrypted data and a first encrypted public key corresponding to the first user identifier, so that the first encrypted data is decrypted by using the first signature private key which is uniquely owned, and the first encrypted private key is acquired.
And 106, the target node analyzes the received first key configuration broadcast message, acquires a first encryption public key corresponding to the first user identifier, encrypts first data sent to the participating node by using the first encryption public key to generate first encrypted communication data, signs by using a second signature private key of the target node, and sends the first encrypted communication data to the participating node.
And 107, the participating node analyzes the block chain content to obtain a second signature public key corresponding to a second user identifier of the target node, applies the second signature public key to perform signature verification on the first encrypted communication data sent by the target node, and if the verification is passed, applies the first encryption private key to decrypt the first encrypted communication data to obtain the first data.
Based on the above analysis, it is obvious that the supervisory node provides a secure channel for communication between nodes by distributing an encryption key pair for each node in the blockchain network, so that the nodes communicate based on a public key certificate mechanism.
Specifically, the target node analyzes the received first key configuration broadcast message, acquires a first encryption public key corresponding to the first user identifier, encrypts first data sent to the participating node by using the first encryption public key to generate first encrypted communication data, and sends the first encrypted communication data to the participating node after signing by using a second signature private key of the target node in order to realize bidirectional security of the secure channel.
Based on a consensus mechanism of the block chain network, a second signature public key generated in advance by a target node is recorded in a generated block chain, so that the participating node analyzes the content of the block chain to obtain a second signature public key corresponding to a second user identifier of the target node, the second signature public key is applied to perform signature verification on first encrypted communication data sent by the target node, if the verification is passed, for example, if the second signature public key corresponds to the second signature private key, the identity verification on the target node is successful, and the first encrypted communication data is decrypted by the first private key to obtain the first data.
In order to more fully describe the method for encrypted communication of a blockchain node according to an embodiment of the present invention, a process of adding a blockchain to a target node is described below with reference to the accompanying drawings.
Fig. 6 is a flowchart of an encrypted communication method of a blockchain node according to another embodiment of the present invention, as shown in fig. 6, before thestep 107, the method further includes:
step 201, a target node of the blockchain network is added for the first time, a second signature private key of the target node is used for signing a second user identifier and a second signature public key of the target node, and a second adding broadcast message is sent to the blockchain network after a timestamp is printed by a timestamp server.
And on the basis of the same mode of accessing the new participating node, the target node of the block chain network is added for the first time, the second signature private key of the target node is adopted to sign the second user identifier and the second signature public key of the target node, and a timestamp is printed by a timestamp server to send a second adding broadcast message to the block chain network, so that the mining node can verify the validity and validity of the target node.
Step 202, the mining node analyzes a second join broadcast message sent by the target node joining the blockchain network for the first time to obtain a second user identifier and a second signature public key, searches whether the blockchain account book currently stored in the local node has the second user identifier, if the second user identifier is detected to be absent, the target node is signed and verified through the second signature public key, and if the second user identifier is verified to be absent, the second join broadcast message is written into a new block and then is broadcasted to the blockchain network.
Specifically, the mining node analyzes a second join broadcast message sent by a target node joining a block chain network for the first time to obtain a second user identifier and a second signature public key, searches whether a block chain account book currently stored by a local node has the second user identifier to determine the validity of the target node, if the second user identifier does not exist, the target node is shown to be absent in the current block chain network and is a new node which can be joined, further, in order to verify the validity of the target node and avoid other illegal devices from falsifying the target node, signature verification is carried out on the target node through the second signature public key, and if the second user identifier passes the verification, the target node is shown to be a legal node, so that the second join broadcast message is written into a new block and then is broadcasted to the block chain network.
With continued reference to fig. 6, the supervising node assigns a pair of encryption keys based on the newly joined target node to ensure that the establishment of a secure channel of communication in the blockchain network is complete. Further, in an embodiment of the present invention, after thestep 202, the method further includes:
step 203, the supervision node analyzes the received broadcast message of the new block, obtains a second user identifier and a second signature public key, and generates a second encryption public key and a second encryption private key corresponding to the second user identifier.
Specifically, the supervision node analyzes the received broadcast message of the new block, acquires a second user identifier and a second signature public key, and generates a second encryption public key and a second encryption private key corresponding to the second user identifier, so as to complete distribution of the block encryption key pair of the target node.
And step 204, the supervision node encrypts the second encryption private key by using the second signature public key to generate second encryption data, signs the second encryption data, the second encryption public key and the second user identifier by using the signature private key of the supervision node, and then sends a second key configuration broadcast message to the blockchain network.
Specifically, the supervision node encrypts the second encryption private key by using the second signature public key to generate second encryption data, so that the second encryption private key can only be obtained by a target node with the second signature private key, directional distribution of the second encryption private key is guaranteed, and in order to further establish a secure communication channel between the target node and other mining nodes, the signature private key of the supervision node is used for signing the second encryption data, the second encryption public key and the second user identifier and then sending a second key configuration broadcast message to the block chain network.
Step 205, the participating node analyzes the second key configuration broadcast message, obtains a second encryption public key corresponding to the second user identifier, encrypts second data sent to the target node by using the second encryption public key to generate second encrypted communication data, signs by using the first signature private key, and sends the second encrypted communication data to the target node.
Specifically, the participating node analyzes the broadcast message configured by the second key, and since the second user identifier and the second encrypted public key are both sent in a broadcast manner, the participating node can obtain the second encrypted public key corresponding to the second user identifier, so that the second encrypted public key is applied to encrypt the second data sent to the target node to generate second encrypted communication data, and the second encrypted communication data is sent to the target node after being signed by the first signature private key, so that only the target node with the second encrypted private key can decrypt the second encrypted communication data, and the communication security is ensured.
And step 206, the target node analyzes the block chain content to obtain a first signature public key corresponding to the first user identifier of the participating node, applies the first signature public key to perform signature verification on second encrypted communication data sent by the participating node, and if the second encrypted communication data passes the signature verification, applies a second encryption private key configured by the supervision node for the target node to decrypt the second encrypted communication data to obtain second data.
Specifically, since the first signature public key of the participating node that has been verified to be legitimate and successfully joins the blockchain network has been written into the previously generated blockchain content, the target node parses the blockchain content to obtain the first signature public key corresponding to the first user identifier of the participating node, applies the first signature public key to perform signature verification on the second encrypted communication data sent by the participating node, and if the verification passes, it is indicated that the participating node is a legitimate node but not disguised by other illegitimate nodes, so that the second encrypted communication data is decrypted by using the second encryption private key configured by the supervisory node for the target node to obtain the second data.
To sum up, the encryption communication method for the blockchain nodes according to the embodiment of the present invention implements authentication of a newly participating node of the blockchain network based on a public key certificate technology, prevents an illegal node from being disguised as a legal node to access the blockchain network, and allocates an encryption key pair to each authenticated node by an introduced supervisory node based on the public key certificate technology, thereby ensuring communication interaction between the nodes based on the encryption key pair, establishing a secure communication channel of node time, and ensuring communication security of the blockchain network.
In order to implement the foregoing embodiments, the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the computer device implements the encryption communication method of the blockchain node as described in the foregoing embodiments.
In order to implement the above embodiments, the present invention also proposes a non-transitory computer-readable storage medium having stored thereon a computer program which, when executed by a processor, is capable of implementing the encrypted communication method of the blockchain node as described in the foregoing embodiments.
In the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present application, "plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing steps of a custom logic function or process, and alternate implementations are included within the scope of the preferred embodiment of the present application in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present application.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present application may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Although embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application, and that variations, modifications, substitutions and alterations may be made to the above embodiments by those of ordinary skill in the art within the scope of the present application.