The scheme is a divisional application taking a patent application with an application number of 201811128351.5, an application date of 2018, 9 and 27 as a parent, and named as 'a heterogeneous consensus method and terminal of block chains'.
Detailed Description
In order to explain technical contents, objects and effects of the present invention in detail, the following detailed description is given with reference to the accompanying drawings in conjunction with the embodiments.
Referring to fig. 1, the present invention provides a block chain heterogeneous consensus method with high security, comprising the following steps:
s1: screening out a unique node as a decision node of a block in each round of consensus process;
s2: receiving the sub-message block sent by each fragment through the decision node, and respectively verifying the sub-message block sent by each fragment;
s3: merging the sub-message blocks which pass the verification to obtain a merged message block;
s4: respectively sending the message blocks to the decision nodes of each segment through the decision nodes of the block;
s5: if first signature information sent back by the fragmentation decision node exceeding a preset number threshold is received, judging that the message block passes verification; and the first signature information is the signature information which is sent back after the decision node of the fragment verifies the message block and passes the verification.
From the above description, it can be seen that the present invention provides a block chain heterogeneous consensus method with high security, in each round of consensus process, a unique node is selected as a decision node for a block, sub-message blocks sent by the decision node of each segment are verified by the decision node, the sub-message blocks that pass verification are merged to obtain merged message blocks, the message blocks are sent to the decision node corresponding to each segment for verification, when the number that passes verification is greater than a preset number threshold, the message block is indicated to pass verification, and the message block can be broadcasted; by the method, a new decision node of the block is selected in each round of consensus process, so that an attacker cannot judge a leader of the decision, the whole consensus process cannot be controlled, the consensus algorithm adopted by each fragment is different, the attacker cannot control all the fragments through one attack strategy, the whole consensus process cannot be controlled, the attacker wants to control most nodes of a system in the consensus process, the attack difficulty is increased undoubtedly, the problem that the key fault of the block decision is caused by the fact that a hacker attacks one fragment node in a block chain is solved, and the safety of the block chain is improved.
Further, S1 specifically is:
in each round of consensus process, calculating a competition value corresponding to each node to be selected through a preset first formula to obtain a plurality of competition values; each node to be selected is a decision node corresponding to each fragment;
screening out competition values meeting preset conditions from the competition values to obtain a plurality of first competition values;
publishing a node corresponding to each first competition value and a public key used by the node for data decryption;
within a preset time, obtaining the minimum value of all published first competition values to obtain a first minimum competition value;
and screening the node corresponding to the first minimum competition value as a decision node of the block.
As can be seen from the above description, by the above method, in each round of consensus process, the node corresponding to the minimum competition value is screened out as the decision node of the block, so that an attacker cannot determine the decision node in the round of consensus process in advance, and the security in the block chain consensus process is improved; the node corresponding to each competition value and the public key used by the node for data decryption are published, so that the fragmented decision nodes can conveniently verify the signature information of the sub-message blocks through the public key.
Further, the first formula specifically is:
wherein, the C
i The sk is the competition value of the ith node to be selected
i Representing the private key used for encrypting data on the node to be selected, r representing the number of rounds of the current consensus process, Q
r A random number corresponding to the r-th round of consensus process is represented (i.e. a random number is generated in each round of consensus process),
representation using the private key sk
i For r and Q
r Carry out data signature H
1 Is a hash function.
As can be seen from the above description, by the above method, the calculated corresponding competition values are different for each node to be selected in each round of consensus process, so that the fragmented decision nodes obtained in each round of consensus process are randomly generated, and the probability that the fragmented decision nodes are attacked can be greatly reduced.
Further, S2 specifically is:
receiving, by a decision node of the block, a sub-message block sent by each tile;
the block is composed of a plurality of fragmented sub-message blocks.
Verifying the correctness of the signature information of the sub message blocks sent by the corresponding fragment decision nodes through the public key of the decision node of each fragment; the signature information is obtained by the decision node of the fragment through signature by a private key stored on the decision node.
According to the description, by the method, the sub-message blocks sent by the decision node of each fragment can be effectively verified, and the safety of the consensus process is improved; meanwhile, the public key of the decision node of each fragment can be obtained through the published node and the public key for data decryption on the node;
further, S4 specifically is:
and the decision node controlling the block respectively sends the message block to the decision node of each fragment through a practical Byzantine fault-tolerant algorithm.
From the above description, it can be ensured that the message block is sent to the decision node of the first segment, and the fault tolerance of the system is improved.
Further, the block chain heterogeneous consensus method with high safety further includes:
distributing the newly added nodes to corresponding fragments through a preset second formula;
the second formula is x = sToi (add)i ) % n, wherein i is the serial number of the node, x is the serial number of the fragment to be distributed by the node i, addi represents the address of the node i, and sToi represents a function of converting the address sequence into an integer; specifically, the function that converts the address sequence into integers uses the strtol function in the C-standard library.
Further, the block chain heterogeneous consensus method with high safety further includes:
preset consensus set Co = { Co = } Co1 ,Co2 ,…,Com I.e. preset m consensus algorithms, where Cok K =1,2,.., m, representing a consensus algorithm with a rank number k;
if a new fragment is generated in the block chain, the sequence number of the consensus algorithm adopted by the new fragment is
Wherein said g represents the sequence number of a new fragment, said->
And expressing a hash value corresponding to the new fragmentation decision node, wherein the hash value is calculated through a first formula, and the percentage expresses remainder operation.
Referring to fig. 2, the block chain heterogeneous common-knowledge terminal with high security provided by the present invention includes a memory 1, a processor 2 and a computer program stored in the memory 1 and capable of running on the processor 2, wherein the processor 2 implements the following steps when executing the program:
s1: screening out a unique node as a decision node of a block in each round of consensus process;
s2: receiving the sub-message block sent by each fragment through the decision node, and respectively verifying the sub-message block sent by each fragment;
s3: merging the sub-message blocks which pass the verification to obtain a merged message block;
s4: respectively sending the message blocks to the decision nodes of each segment through the decision nodes of the block;
s5: if first signature information sent back by the fragmentation decision node exceeding a preset number threshold is received, judging that the message block passes verification; and the first signature information is the signature information corresponding to the verification passing after the verification of the message block is passed by the fragmented decision node.
Further, the block chain heterogeneous consensus terminal with high security includes that S1 specifically:
in each round of consensus process, calculating a competition value corresponding to each node to be selected through a preset first formula to obtain a plurality of competition values; each node to be selected is a decision node corresponding to each fragment;
screening out competition values meeting preset conditions from the competition values to obtain a plurality of first competition values;
publishing a node corresponding to each first competition value and a public key used by the node for data decryption;
within a preset time, acquiring the minimum value of all published first competition values to obtain a first minimum competition value;
and screening the node corresponding to the first minimum competition value as a decision node of the block.
Further, the block chain heterogeneous consensus terminal with high security specifically includes:
wherein, the C
i The sk is the competition value of the ith node to be selected
i Representing a private key used for encrypting data on the node to be selected, r representing the number of rounds of the current consensus process, Q
r Represents the random number corresponding to the r-th consensus process,
representation with the private key sk
i For r and Q
r Carry out data signature H
1 Is a hash function.
Further, the block chain heterogeneous consensus terminal with high security, where S2 specifically is:
receiving, by a decision node of the block, a sub-message block sent by each tile;
verifying the correctness of the signature information of the sub message blocks sent by the corresponding fragmentation decision nodes through the public key of the decision node of each fragmentation; the signature information is obtained by the decision node of the fragment through signature by a private key stored on the decision node.
Further, the block chain heterogeneous consensus terminal with high security includes that S4:
and controlling the decision node of the block to respectively send the message block to the decision node of each fragment through a practical Byzantine fault-tolerant algorithm.
Further, the block chain heterogeneous consensus method with high safety further includes:
distributing the newly added nodes to corresponding fragments through a preset second formula;
the second formula is x = sToi (add)i ) % n, wherein i is the serial number of the node, x is the serial number of the fragment to be distributed by the node i, addi represents the address of the node i, and sToi represents a function of converting the address sequence into an integer; specifically, the function that converts the address sequence into integers uses the strtol function in the C-standard library.
Further, the block chain heterogeneous consensus method with high safety further includes:
preset consensus set Co = { Co = } Co1 ,Co2 ,…,Com I.e. preset m consensus algorithms), where Cok K =1, 2.. Multidot.m, representing a consensus algorithm with rank number k;
if a new fragment is generated in the block chain, the sequence number of the consensus algorithm adopted by the new fragment is
Wherein g denotes the sequence number of a new slice, which &>
And the hash value corresponding to the new fragmentation decision node is represented, and the percentage represents the remainder operation.
Referring to fig. 1, a first embodiment of the present invention is:
the invention provides a block chain heterogeneous consensus method with high safety, which comprises the following steps:
distributing the newly added nodes to corresponding fragments through a preset formula;
the formula is x = sToi (add)i ) % n, wherein i is the serial number of the node, x is the serial number of the fragment to be distributed by the node i, addi represents the address of the node i, and sToi represents a function for converting the address sequence into an integer; specifically, the function that converts the address sequence into integers uses the strtol function in the C-standard library.
Preset consensus algorithm set Co = { Co =1 ,Co2 ,…,Com I.e. preset m consensus algorithms, where Cok K =1, 2.. Multidot.m, representing a consensus algorithm with rank number k;
if a new fragment is generated in the block chain, the sequence number of the consensus algorithm adopted by the new fragment is
Wherein g denotes the sequence number of a new slice, which &>
And the hash value corresponding to the new fragmentation decision node is represented, and the percentage represents the remainder operation.
Screening out a unique node as a decision node of a block in each round of consensus process;
in each round of consensus process, screening out a unique node as a decision node of a block, specifically:
in each round of consensus process, calculating a competition value corresponding to each node to be selected through a preset first formula to obtain a plurality of competition values; each node to be selected is a decision node corresponding to each fragment; screening out a competition value meeting a preset condition from the plurality of competition values (namely screening out a competition value smaller than a preset competition value threshold value, wherein the selection of the threshold value is related to the number of the nodes to be selected participating in competition and the number of the nodes to be selected which need to be selected and taken out, and can be set according to actual requirements), and obtaining a plurality of first competition values;
publishing a node corresponding to each first competition value and a public key used for data decryption by the node;
within a preset time, acquiring the minimum value of all published first competition values to obtain a first minimum competition value;
and screening the node corresponding to the first minimum competition value as a decision node of the block.
Wherein the first formula specifically is:
wherein, the C
i The sk is a competition value of the ith node to be selected
i Representing a private key used for encrypting data on the node to be selected, r representing the number of rounds of the current consensus process, Q
r A random number corresponding to the r-th round of consensus process is represented,
representation with the private key sk
i To r and Q
r Carry out data signature H
1 Performing hash operation on the signed data for a hash function;
calculating a competition value corresponding to each node to be selected through a preset first formula to obtain a plurality of competition values, specifically:
and calculating to obtain a hash value corresponding to each node to be selected through a first formula, and converting the hash value into a two-system number to obtain a plurality of binary numbers, wherein the binary numbers are the competition values, and each competition value corresponds to a node to be selected.
Receiving the sub-message block sent by each fragment through the decision node, and respectively verifying the sub-message block sent by each fragment;
the method comprises the following steps that a decision node receives a sub-message block sent by each fragment, and verifies the sub-message block sent by each fragment respectively, wherein the decision node specifically comprises the following steps:
receiving, by a decision node of the block, a sub-message block sent by each tile; the sub-message block is a block generated in each fragment, and the block contains a plurality of messages as the concept of the block on a common block chain;
the decision nodes of the control block verify the correctness of the signature information of the sub message block sent by the corresponding fragment decision node through the public key of the decision node of each fragment; the signature information is obtained by the decision node of the fragment through signature by a private key stored on the decision node.
Merging the sub-message blocks which pass the verification to obtain a merged message block;
respectively sending the message blocks to the decision nodes of each segment through the decision nodes of the block;
the sending of the message block to the decision node of each segment by the decision node of the block specifically includes:
and the decision node controlling the block respectively sends the message block to the decision node of each fragment through a practical Byzantine fault-tolerant algorithm.
If the fragmented decision nodes receive first signature information sent back by the fragmented decision nodes exceeding a preset number threshold, judging that the message block passes verification; after the verification is passed, the message block is broadcasted to the network; after the decision node with the first signature information as the fragment verifies the message block (the verification is to verify the signature data contained in the message block and verify the message format in the message block), the returned verification passes through the corresponding signature information; wherein the number threshold is the product of the number of all fragmentation decision nodes and 2/3.
Referring to fig. 2, the second embodiment of the present invention is:
the invention provides a high-safety block chain heterogeneous consensus terminal, which comprises a memory 1, a processor 2 and a computer program which is stored in the memory 1 and can run on the processor 2, wherein all the steps of the first embodiment are realized when the processor 2 executes the program.
In conclusion, the invention provides a block chain heterogeneous consensus method and a terminal with high safety, wherein in each round of consensus process, a unique node is selected as a decision node of a block, a sub-message block sent by the decision node of each fragment is verified through the decision node, the sub-message blocks passing the verification are combined to obtain a combined message block, the message block is respectively sent to the decision node corresponding to each fragment for verification, when the number passing the verification is greater than the preset number threshold value, the message block is indicated to pass the verification, and the message block can be broadcasted; by the method, a new decision node of the block is selected in each round of consensus process, so that an attacker cannot judge a leader of the decision, the whole consensus process cannot be controlled, the consensus algorithm adopted by each fragment is different, the attacker cannot control all the fragments through one attack strategy, the whole consensus process cannot be controlled, the attacker wants to control most nodes of a system in the consensus process, the attack difficulty is increased undoubtedly, the problem that the key fault of the block decision is caused by the fact that a hacker attacks one fragment node in a block chain is solved, and the safety of the block chain is improved.
The above description is only an embodiment of the present invention, and is not intended to limit the scope of the present invention, and all equivalent modifications made by the present invention and the contents of the accompanying drawings, which are directly or indirectly applied to other related technical fields, are included in the scope of the present invention.