Byzantine consensus method and device in blockchain
By introducing the Byzantine consensus method of transaction message broadcasting, input message generation and diffusion/termination message processing in the blockchain, the problems of high time complexity and small throughput in the prior art are solved, and efficient transaction delivery and high throughput are achieved.
Patent Information
- Application Number
- CN202411878054.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-19
AI Technical Summary
When the prior art realizes the Byzantine consensus in blockchain, there are problems of high time complexity and small throughput, especially in the presence of malicious nodes, the transaction delivery delay is large.
A Byzantine consensus method in blockchain is proposed. By generating transaction messages in each round and broadcasting them to all nodes, receiving and buffering transaction messages, determining block values and generating input messages, and then generating diffusion messages or termination messages, entering a loop based on the preliminary voting value, updating the preliminary voting value to determine the multi-value negotiation value, and finally delivering the transaction request contained in the block.
In the absence of malicious nodes, a transaction can be delivered in only two steps, significantly reducing time complexity and each node can send transaction messages, improving throughput.
Smart Images

Figure CN119342058B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed technology, and in particular to a Byzantine consensus method and device in a blockchain. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by inclusion in this section.
[0003] The error models in blockchain mainly include downtime errors and arbitrary errors. Downtime errors refer to the fact that the participants of the blockchain will execute according to the protocol requirements, but may crash at a certain moment and no longer resume work after the crash; arbitrary errors refer to the fact that the wrong participants of the blockchain may not execute according to the protocol and can perform any behavior that is not controlled by the protocol, including downtime, malicious attacks, software and hardware errors, etc. Arbitrary errors are also called Byzantine errors. In blockchain, Byzantine errors are regarded as a Byzantine adversary controlling all the wrong participants. Byzantine consensus is to achieve consensus in the presence of Byzantine adversaries.
[0004] In the Byzantine consensus, in the presence of malicious nodes, the delay in delivering a transaction is determined by the method currently used by most synchronous Byzantine consensus. The time complexity is , and the existing synchronous Byzantine consensus only supports a single node proposing transactions in each round, with low throughput.
[0005] Therefore, there is a need for a Byzantine consensus solution with low time complexity and in which all nodes can propose transactions in each round. Summary of the invention
[0006] The embodiment of the present invention provides a Byzantine consensus method in a blockchain, which is used to achieve the Byzantine consensus in the blockchain, has high throughput and low time complexity. The method is applied to any node in the blockchain, and the method includes:
[0007] After entering this round, a transaction message is generated according to the transaction requests in the waiting queue maintained by the node, and broadcasted to all nodes, wherein the transaction requests in the waiting queue are sent by the client;
[0008] Add the received transaction message to the buffer queue corresponding to the node where the transaction message comes from; determine the block value of this round based on all transaction requests in the buffer queue of the master node; generate input messages based on the block value of this round and broadcast them to all nodes;
[0009] Generate a diffusion message or a termination message based on the received input message and broadcast it to all nodes;
[0010] Determine the preliminary voting value according to the received diffusion message, initialize the current cycle number to 1; determine the cycle point and enter the cycle, in which the multi-value negotiation value is determined according to the preliminary voting value, and enter the cycle point by updating the next preliminary voting value in this round; or determine the multi-value negotiation value according to the termination message;
[0011] After the multi-value negotiation value is determined, all transaction requests contained in the block corresponding to the determined multi-value negotiation value are delivered and the next round begins.
[0012] The embodiment of the present invention also provides a Byzantine consensus device in a blockchain, which is used to implement the Byzantine consensus in the blockchain, has high throughput and low time complexity, and is applied to any node in the blockchain. The device includes:
[0013] A transaction message broadcast module is used to generate a transaction message according to the transaction requests in the waiting queue maintained by the node after entering the current round, and broadcast it to all nodes, wherein the transaction requests in the waiting queue are sent by the client;
[0014] The input message broadcast module is used to add the received transaction message to the buffer queue corresponding to the transaction message source node; determine the block value of this round according to all transaction requests in the buffer queue of the master node; generate the input message according to the block value of this round and broadcast it to all nodes;
[0015] The input message processing module is used to generate a diffusion message or a termination message according to the received input message and broadcast it to all nodes;
[0016] The loop processing module is used to determine the preliminary voting value according to the received diffusion message, initialize the current loop number to 1; determine the loop point and enter the loop, in which the multi-value negotiation value is determined according to the preliminary voting value, and enter the loop point by updating the next preliminary voting value in this round; or, determine the multi-value negotiation value according to the termination message; after determining the multi-value negotiation value, deliver all transaction requests contained in the block corresponding to the determined multi-value negotiation value, and enter the next round.
[0017] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned Byzantine consensus method in the blockchain when executing the computer program.
[0018] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the Byzantine consensus method in the above-mentioned blockchain is implemented.
[0019] An embodiment of the present invention also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the Byzantine consensus method in the above-mentioned blockchain.
[0020] In an embodiment of the present invention, after entering the current round, a transaction message is generated based on the transaction requests in the waiting queue maintained by the node, and broadcast to all nodes, wherein the transaction requests in the waiting queue are sent by the client; the received transaction message is added to the buffer queue corresponding to the source node of the transaction message; the block value of this round is determined based on all transaction requests in the buffer queue of the master node; an input message is generated based on the block value of this round, and broadcast to all nodes; a diffusion message or a termination message is generated based on the received input message, and broadcast to all nodes; a preliminary voting value is determined based on the received diffusion message, and the current number of loops is initialized to 1; a loop point is determined and a loop is entered, in which a multi-value negotiation value is determined based on the preliminary voting value, and in this round, the loop point is entered by updating the next preliminary voting value; or, a multi-value negotiation value is determined based on the termination message; after determining the multi-value negotiation value, all transaction requests contained in the block corresponding to the determined multi-value negotiation value are delivered, and the next round is entered. In the prior art, the synchronous Byzantine consensus adopts a deterministic method, which requires The time complexity of the embodiment of the present invention is 2-step, and the solution proposed in the embodiment of the present invention can deliver a transaction in only two steps in the absence of malicious nodes. Specifically, through the above-mentioned input message, diffusion message, termination message, preliminary voting value, and finally the multi-value negotiation value is determined through a loop. After the preliminary voting value is updated during the loop, the loop point is entered, so that the preliminary voting value of the next round is continuously updated to ensure that the multi-value negotiation value is determined, and the implementation is realized. The expected time complexity is ; or the multi-value negotiation value can be determined according to the termination message; finally, after the multi-value negotiation value is determined, all transaction requests contained in the block corresponding to the determined multi-value negotiation value are delivered, thereby achieving Byzantine consensus; during the whole process, each node can send transaction messages, and the throughput is large. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0022] Figure 1 This is a flow chart of the Byzantine consensus method in the blockchain in an embodiment of the present invention;
[0023] Figure 2 A flow chart of determining multi-value negotiation values by looping in the implementation of the present invention;
[0024] Figure 3 A flow chart of determining a multi-value negotiation value according to a final voting message in the implementation of the present invention;
[0025] Figure 4 Schematic diagram of a Byzantine consensus device in a blockchain according to an embodiment of the present invention;
[0026] Figure 5 Schematic diagram of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0027] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0028] The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0029] In the embodiment of the present invention, the Byzantine consensus in the blockchain is defined as follows:
[0030] Byzantine consensus is for blockchains, which include n nodes, each of which receives transactions (i.e., information of any length and content) proposed by clients as input. Each node executes in rounds, and each node inputs transactions and reaches consensus in each round, and finally delivers transactions that are consistent after consensus. Byzantine consensus can achieve the following two properties when the Byzantine adversary controls f participants as malicious participants and n≥3f+1:
[0031] (1) Safety: If an honest node in a blockchain first delivers one transaction, called transaction one, and then delivers another transaction, called transaction two, then no honest node will deliver transaction two before delivering transaction one.
[0032] (2) Liveness: If the client proposes a transaction to send to all nodes, all honest nodes will eventually deliver the transaction.
[0033] The adversary model of blockchain includes static adversary and adaptive adversary. Static adversary refers to the adversary being able to select a group of participants as malicious participants before the protocol runs; adaptive adversary refers to the adversary being able to dynamically select participants as wrong participants based on the information it obtains during the protocol run, which simulates the scenario where the adversary gradually captures the blockchain. In this scheme, the adversary model is an adaptive adversary, and the scheme has higher security.
[0034] The embodiment of the present invention utilizes digital signatures, hash functions, threshold signatures, and threshold random number generation protocols as cryptographic components. The above cryptographic components can be instantiated through any corresponding security scheme.
[0035] Figure 1 Flow chart of the Byzantine consensus method in the blockchain in an embodiment of the present invention, the method is applied to any node in the blockchain, and the method includes:
[0036] Step 101, after entering this round, a transaction message is generated according to the transaction requests in the waiting queue maintained by the node, and broadcasted to all nodes, wherein the transaction requests in the waiting queue are sent by the client;
[0037] Step 102, adding the received transaction message to the buffer queue corresponding to the transaction message source node; determining the block value of this round according to all transaction requests in the buffer queue of the master node; generating an input message according to the block value of this round, and broadcasting it to all nodes; starting the second timer;
[0038] Step 103, generating a diffusion message or a termination message according to the received input message, broadcasting it to all nodes, and starting a third timer;
[0039] Step 104, determine the preliminary voting value according to the received diffusion message, initialize the current cycle number to 1; determine the cycle point and enter the cycle, in the cycle, determine the multi-value negotiation value according to the preliminary voting value, and enter the cycle point by updating the next preliminary voting value in this round; or, determine the multi-value negotiation value according to the termination message;
[0040] Step 105, after the multi-value negotiation value is determined, all transaction requests contained in the block corresponding to the determined multi-value negotiation value are delivered, and the next round is entered.
[0041] In the embodiment of the present invention, the synchronous Byzantine consensus in the prior art adopts a deterministic method, which requires The time complexity of the embodiment of the present invention is 2-step, and the solution proposed in the embodiment of the present invention can deliver a transaction in only two steps in the absence of malicious nodes. Specifically, through the above-mentioned input message, diffusion message, termination message, preliminary voting value, and finally the multi-value negotiation value is determined through a loop. After the preliminary voting value is updated during the loop, the loop point is entered, so that the preliminary voting value of the next round is continuously updated to ensure that the multi-value negotiation value is determined, and the implementation is realized. The expected time complexity is ; or the multi-value negotiation value can be determined according to the termination message; finally, after the multi-value negotiation value is determined, all transaction requests contained in the block corresponding to the determined multi-value negotiation value are delivered, thereby achieving Byzantine consensus; during the whole process, each node can send transaction messages, and the throughput is large.
[0042] Each step is described in detail below. The method of the embodiment of the present invention is for any node, that is, all nodes execute steps 101 to 105. The scheme proposed in the embodiment of the present invention is executed in rounds, each round includes a number of loop steps, and the next round is entered after the loop step is executed, and the loop step starts from the loop point.
[0043] In addition, the client can send a transaction request to the node at any time. After receiving the transaction request, each node will add the transaction to the waiting queue maintained by the node.
[0044] The event for entering step 101 is when the previous round is completed (if it is the first round, when the blockchain is started).
[0045] In step 101, after entering this round, a transaction message is generated according to the transaction requests in the waiting queue maintained by the node, and broadcasted to all nodes;
[0046] In a specific embodiment, after generating a transaction message and broadcasting it to all nodes, the method further includes: starting a first timer. The first timer waits for a Δ time;
[0047] In one embodiment, generating a transaction message according to the transaction request in the waiting queue maintained by the node includes:
[0048] If the waiting queue of the node is not empty, the first transaction request in the waiting queue is taken out as a transaction message;
[0049] If the waiting queue of the node is empty, the empty symbol is used as the transaction message.
[0050] Specifically, the empty symbol can be represented as ⊥.
[0051] The event for entering step 102 is when step 101 is completed, after the first timer has finished timing.
[0052] In step 102, the received transaction message is added to the buffer queue corresponding to the transaction message source node; the block value of this round is determined according to all transaction requests in the buffer queue of the master node; according to the block value of this round, an input message is generated and broadcasted to all nodes;
[0053] In a specific embodiment, after an input message is generated and broadcast to all nodes, a second timer is started; the second timer waits for a time Δ;
[0054] Specifically, each node adds the received transaction message to the buffer queue corresponding to the source node of the transaction message. For example, node 1 adds the received transaction message sent by node 2 to the buffer queue corresponding to node 2.
[0055] In one embodiment, determining the block value of this round according to all transaction requests in the buffer queue of the master node includes:
[0056] All transaction requests in the buffer queue of the master node are used as the blocks of this round; the master node is the node corresponding to the public random number, and the public random number is the random number selected by all nodes calling the threshold random number generation protocol together;
[0057] Calculate the hash value of the block as the block value of this round.
[0058] For example, if the public random number is 3, then to determine node 3 as the master node, other nodes need to use all transaction requests in the buffer queue of node 3 as blocks for this round.
[0059] In one embodiment, the input message includes the block value and threshold signature of this round, and a first threshold signature share, where the first threshold signature share is obtained by performing a threshold signature on the block value.
[0060] Specifically, generating an input message means that the block value, the threshold signature, and the first threshold signature share are collectively used as the input message.
[0061] The event for entering step 103 is when step 102 is completed and the second timer is finished.
[0062] In step 103, after the second timer is finished, a diffusion message or a termination message is generated according to the received input message and broadcasted to all nodes;
[0063] In a specific implementation, after a diffusion message or a termination message is generated and broadcast to all nodes, a third timer is started to wait for a Δ time;
[0064] In one embodiment, generating a diffusion message or a termination message according to a received input message includes:
[0065] After the threshold signature of the received input message is verified, the block value in the input message is added to the block value set;
[0066] If the received input message meets the first condition, the block value of the input message meeting the first condition is set to the termination value, and a termination message is formed and broadcast to all nodes; the multi-value negotiation value is determined according to the termination value; the first condition is that a first number n of matching input messages are received, and the block value of the input message is in the block value set;
[0067] If the received input message meets the second condition, the block value of the input message meeting the second condition is used as the diffusion value, and the first threshold signature share in the input message meeting the second condition is combined into a first threshold signature; the diffusion value and the corresponding threshold signature and the first threshold signature are used as the diffusion message; the second condition is that a second number f+1 of matching input messages are received, and the block value of the input message is in the block value set;
[0068] If the received diffusion message does not meet the first condition and the second condition, the empty symbol is used as the diffusion message.
[0069] In the above embodiment, if the verification fails, the input message is discarded. The block value set includes multiple block values. The multi-value negotiation value is determined according to the termination value, that is, the termination value is used as the determined multi-value negotiation value, and all transactions contained in the block corresponding to the multi-value negotiation value are delivered. When the first threshold signature is combined, the threshold signature share combination algorithm can be used.
[0070] The event for entering step 104 is when step 103 is completed and the third timer is finished.
[0071] In step 104, a preliminary voting value is determined according to the received diffusion message, and the current cycle number is initialized to 1; a cycle point is determined and a cycle is entered, in which a multi-value negotiation value is determined according to the preliminary voting value, and in this round, the cycle point is entered by updating the next preliminary voting value; or, a multi-value negotiation value is determined according to a termination message;
[0072] In one embodiment, determining the multi-value negotiation value according to the termination message includes:
[0073] If the received termination message satisfies the third condition, the termination value in the termination message satisfying the third condition is used as the termination message of the node and broadcasted to all nodes, wherein the third condition is that the second number f+1 of matching termination messages are received and the node has not sent a termination message;
[0074] If the received termination message satisfies the fourth condition and the node has not determined the multi-value negotiation value, the multi-value negotiation value is determined according to the termination value in the termination message that satisfies the fourth condition, all transaction requests contained in the block corresponding to the multi-value negotiation value are delivered, and the execution of this round is terminated, and the fourth condition is that the first number n of matching termination messages are received.
[0075] Specifically, the multi-value negotiation value is determined according to the termination value in the termination message that satisfies the fourth condition, that is, the termination value in the termination message that satisfies the fourth condition is used as the determined multi-value negotiation value, and all transaction requests contained in the block corresponding to the multi-value negotiation value are delivered.
[0076] In one embodiment, determining a preliminary voting value according to the received diffusion message includes:
[0077] After the threshold signature of the received diffusion message and the first threshold signature are verified, the diffusion value in the diffusion message and the corresponding threshold signature are added to the multi-value set;
[0078] If the received diffusion message meets the fifth condition, the diffusion value of the diffusion message that meets the first condition is used as the multi-value negotiation value, and 1 is determined as the preliminary voting value, the hash value of the diffusion value is used as the auxiliary value, and the threshold signature of the diffusion value is used as the auxiliary signature; the fifth condition is that the third number nf of matching diffusion messages are received, and the diffusion value of the diffusion message and its corresponding threshold signature are in the multi-value set, and the multi-value set has only one set of diffusion values and corresponding threshold signatures;
[0079] If the received diffusion message does not satisfy the fifth condition, 0 is determined as the preliminary voting value.
[0080] Specifically, the multi-value set includes multiple groups of multi-values, each group of multi-values includes a diffusion value and a corresponding threshold signature. If the above verification fails, the diffusion message is discarded. When the current loop number is initialized to 1, this point is determined to be a loop point and enters the loop.
[0081] See also Figure 2 The flowchart of determining the multi-value negotiation value by loop in the implementation of the present invention, in one embodiment, in the loop, the multi-value negotiation value is determined according to the preliminary voting value, and the loop point is entered by updating the next preliminary voting value in the current round, including:
[0082] Step 201, in the current cycle, according to the preliminary voting value and the number of cycles, a preliminary voting message is generated, broadcasted to all nodes, and the fourth timer is started;
[0083] Specifically, the current loop is determined according to the current loop number. For example, when entering the loop for the first time, the loop number is 1.
[0084] In one embodiment, generating a preliminary voting message according to the preliminary voting value and the number of cycles includes:
[0085] Perform threshold signature on the preliminary voting value and the number of cycles to obtain the second threshold signature share;
[0086] If the number of cycles is 1 and the initial voting value is 1, the initial voting value, auxiliary value, auxiliary signature and second threshold signature share are used as the initial voting message;
[0087] If the cycle number is not 1 or the preliminary voting value is not 1, the preliminary voting value and the second threshold signature share are used as the preliminary voting message.
[0088] Step 202: after the fourth timer has finished timing, a final voting message is generated according to the received preliminary voting message, and is broadcast to all nodes, and a fifth timer is started;
[0089] In one embodiment, generating a final voting message according to the received preliminary voting message includes:
[0090] After verifying the auxiliary signature and the second threshold signature share of the received preliminary voting message, if the received preliminary voting message satisfies the sixth condition, the preliminary voting value in the preliminary voting message that satisfies the sixth condition is used as the final voting value, the second threshold signature shares in the second number f+1 of matching preliminary voting messages are combined into a second threshold signature, and the final voting value and the second threshold signature are used as the final voting message, and the sixth condition is that the second number of matching preliminary voting messages are received;
[0091] If the received preliminary voting message does not satisfy the sixth condition, the empty symbol is used as the final voting message.
[0092] Specifically, the combination into the second threshold signature can be performed through the threshold signature share combination algorithm. When the above verification fails, the received preliminary voting message is discarded.
[0093] Step 203: After the fifth timer is finished, the multi-value negotiation value is determined according to the received final voting message, and the cycle point is entered by updating the next preliminary voting value in this round.
[0094] See also Figure 3 The flowchart of determining the multi-value negotiation value according to the final voting message in the implementation of the present invention, in one embodiment, the multi-value negotiation value is determined according to the received final voting message, and the cycle point is entered by updating the next preliminary voting value in this round, including:
[0095] Step 301, after the second threshold signature of the received final voting message is verified, the final voting value and the second threshold signature in the final voting message are added to a binary value set, and the binary value counter corresponding to the final voting value is increased by one, wherein the binary value set includes a plurality of binary values, wherein each final voting value in the final voting message and the corresponding second threshold signature form a binary value;
[0096] If the above verification fails, the received final voting message is discarded;
[0097] Step 302, if the cycle number is 1, determine the public coin toss value to be 1;
[0098] Step 303, if the number of cycles is not 1, use the binary random number selected by all nodes as the public coin tossing value;
[0099] Step 304, based on the public coin value and the binary value set, the multi-value negotiation value is determined according to the received final voting message, and the cycle point is entered by updating the next preliminary voting value in this round.
[0100] In one embodiment, a multi-value negotiation value is determined based on a public coin flip value and a binary value set, and a loop point is entered by updating the next preliminary voting value in this round, including:
[0101] If the binary value set satisfies the seventh condition, the unique final voting value in the binary value set is used as the Boolean negotiation value, and the seventh condition is that the binary value set only contains a tuple consisting of the unique final voting value and the second threshold signature, and the value of the binary value counter corresponding to the unique final voting value is not less than the second number f+1;
[0102] If the Boolean negotiation value is equal to the public coin toss value, determining the Boolean negotiation value;
[0103] If the determined Boolean negotiation value is 1, determine the multi-value negotiation value; use the determined Boolean negotiation value as the preliminary voting value for the next cycle and jump to the cycle point; and use the determined Boolean negotiation value as a binary termination message and broadcast it to all nodes;
[0104] If the Boolean negotiation value is not equal to the public coin toss value, the current cycle number is increased by 1, and only the Boolean negotiation value is used as the preliminary voting value for the next cycle, and the process jumps to the cycle point;
[0105] If the binary value set does not satisfy the seventh condition, add 1 to the current loop number, use the public coin toss value as the preliminary voting value for the next loop, and jump to the loop point.
[0106] In one embodiment, the method further comprises:
[0107] determining in real time whether a second number of matching binary termination messages are received;
[0108] If yes, broadcast the Boolean negotiation value as a binary termination message to all nodes, and determine the Boolean negotiation value corresponding to the binary termination message;
[0109] If the determined Boolean negotiation value is 1, the multi-value negotiation value is determined.
[0110] Specifically, each node performs real-time judgment in each round to determine the multi-value negotiation value.
[0111] In step 105, after the multi-value negotiation value is determined, all transaction requests included in the block corresponding to the determined multi-value negotiation value are delivered and the next round is entered.
[0112] The embodiment of the present invention also proposes a Byzantine consensus device in a blockchain, the principle of which is similar to the Byzantine consensus in a blockchain, and will not be repeated here.
[0113] Figure 4This is a schematic diagram of the structure of a Byzantine consensus device in a blockchain in an embodiment of the present invention, which is applied to any node in a blockchain. The device includes:
[0114] The transaction message broadcast module 401 is used to generate a transaction message according to the transaction requests in the waiting queue maintained by the node after entering the current round, and broadcast it to all nodes, wherein the transaction requests in the waiting queue are sent by the client;
[0115] The input message broadcast module 402 is used to add the received transaction message to the buffer queue corresponding to the transaction message source node; determine the block value of this round according to all transaction requests in the buffer queue of the master node; generate the input message according to the block value of this round, and broadcast it to all nodes;
[0116] An input message processing module 403 is used to generate a diffusion message or a termination message according to the received input message, and broadcast it to all nodes;
[0117] The loop processing module 404 is used to determine the preliminary voting value according to the received diffusion message, initialize the current loop number to 1; determine the loop point and enter the loop, in which the multi-value negotiation value is determined according to the preliminary voting value, and enter the loop point by updating the next preliminary voting value in this round; or, determine the multi-value negotiation value according to the termination message; after determining the multi-value negotiation value, deliver all transaction requests contained in the block corresponding to the determined multi-value negotiation value, and enter the next round.
[0118] In one embodiment, the transaction message broadcast module is used to:
[0119] If the waiting queue of the node is not empty, the first transaction request in the waiting queue is taken out as a transaction message;
[0120] If the waiting queue of the node is empty, the empty symbol is used as the transaction message.
[0121] In one embodiment, the input message broadcast module is used to:
[0122] According to all transaction requests in the master node's buffer queue, the block value of this round is determined, including:
[0123] All transaction requests in the buffer queue of the master node are used as the blocks of this round; the master node is the node corresponding to the public random number, and the public random number is the random number selected by all nodes calling the threshold random number generation protocol together;
[0124] Calculate the hash value of the block as the block value of this round.
[0125] In one embodiment, the input message includes the block value and threshold signature of this round, and a first threshold signature share, where the first threshold signature share is obtained by performing a threshold signature on the block value.
[0126] In one embodiment, the input message processing module is used to:
[0127] After the threshold signature of the received input message is verified, the block value in the input message is added to the block value set;
[0128] If the received input message meets the first condition, the block value of the input message meeting the first condition is set to the termination value, and a termination message is formed and broadcast to all nodes; the multi-value negotiation value is determined according to the termination value; the first condition is that a first number n of matching input messages are received, and the block value of the input message is in the block value set;
[0129] If the received input message meets the second condition, the block value of the input message meeting the second condition is used as the diffusion value, and the first threshold signature share in the input message meeting the second condition is combined into a first threshold signature; the diffusion value and the corresponding threshold signature and the first threshold signature are used as the diffusion message; the second condition is that a second number f+1 of matching input messages are received, and the block value of the input message is in the block value set;
[0130] If the received diffusion message does not meet the first condition and the second condition, the empty symbol is used as the diffusion message.
[0131] In one embodiment, the loop processing module is used to:
[0132] If the received termination message satisfies a third condition, using the termination value in the termination message satisfying the third condition as the termination message of the node, and broadcasting it to all nodes, wherein the third condition is that a second number of matching termination messages are received and the node has not sent a termination message;
[0133] If the received termination message satisfies the fourth condition and the node has not determined the multi-value negotiation value, the multi-value negotiation value is determined according to the termination value in the termination message that satisfies the fourth condition, all transaction requests contained in the block corresponding to the multi-value negotiation value are delivered, and the execution of this round is terminated, and the fourth condition is that the first number of matching termination messages are received.
[0134] In one embodiment, the loop processing module is used to:
[0135] After the threshold signature of the received diffusion message and the first threshold signature are verified, the diffusion value in the diffusion message and the corresponding threshold signature are added to the multi-value set;
[0136] If the received diffusion message meets the fifth condition, the diffusion value of the diffusion message that meets the first condition is used as the multi-value negotiation value, and 1 is determined as the preliminary voting value, the hash value of the diffusion value is used as the auxiliary value, and the threshold signature of the diffusion value is used as the auxiliary signature; the fifth condition is that the third number nf of matching diffusion messages are received, and the diffusion value of the diffusion message and its corresponding threshold signature are in the multi-value set, and the multi-value set has only one set of diffusion values and corresponding threshold signatures;
[0137] If the received diffusion message does not satisfy the fifth condition, 0 is determined as the preliminary voting value.
[0138] In one embodiment, the loop processing module is used to:
[0139] In the current cycle, a preliminary voting message is generated according to the preliminary voting value and the number of cycles, and broadcasted to all nodes, and the fourth timer is started;
[0140] After the fourth timer is finished, a final voting message is generated based on the received preliminary voting message, and broadcasted to all nodes, and the fifth timer is started;
[0141] After the fifth timer is completed, the multi-value negotiation value is determined according to the received final voting message, and the loop point is entered by updating the next preliminary voting value in this round.
[0142] In one embodiment, the loop processing module is used to:
[0143] Perform threshold signature on the preliminary voting value and the number of cycles to obtain the second threshold signature share;
[0144] If the number of cycles is 1 and the initial voting value is 1, the initial voting value, auxiliary value, auxiliary signature and second threshold signature share are used as the initial voting message;
[0145] If the cycle number is not 1 or the preliminary voting value is not 1, the preliminary voting value and the second threshold signature share are used as the preliminary voting message.
[0146] In one embodiment, the loop processing module is used to:
[0147] After verifying the auxiliary signature and the second threshold signature share of the received preliminary voting message, if the received preliminary voting message satisfies the sixth condition, the preliminary voting value in the preliminary voting message that satisfies the sixth condition is used as the final voting value, the second threshold signature shares in the second number of matching preliminary voting messages are combined into a second threshold signature, and the final voting value and the second threshold signature are used as the final voting message, and the sixth condition is that the second number of matching preliminary voting messages are received;
[0148] If the received preliminary voting message does not satisfy the sixth condition, the empty symbol is used as the final voting message.
[0149] In one embodiment, the loop processing module is used to:
[0150] After the second threshold signature of the received final voting message is verified, the final voting value and the second threshold signature in the final voting message are added to a binary value set, and the binary value counter corresponding to the final voting value is increased by one, the binary value set includes a plurality of binary values, wherein each final voting value in the final voting message and the corresponding second threshold signature form a binary value, the binary value set includes a plurality of binary values, wherein each final voting value in the final voting message and the corresponding second threshold signature form a binary value;
[0151] If the number of cycles is 1, determine the public coin value to be 1;
[0152] If the number of cycles is not 1, the binary random number selected by all nodes is used as the public coin toss value;
[0153] Based on the public coin value and the binary value set, the multi-value negotiation value is determined according to the final voting message received, and the cycle point is entered by updating the next preliminary voting value in this round.
[0154] In one embodiment, the loop processing module is used to:
[0155] If the binary value set satisfies the seventh condition, the unique final voting value in the binary value set is used as the Boolean negotiation value, and the seventh condition is that the binary value set only contains a tuple consisting of the unique final voting value and the second threshold signature, and the value of the binary value counter corresponding to the unique final voting value is not less than the second number;
[0156] If the Boolean negotiation value is equal to the public coin toss value, determining the Boolean negotiation value;
[0157] If the determined Boolean negotiation value is 1, determine the multi-value negotiation value; use the determined Boolean negotiation value as the preliminary voting value for the next cycle and jump to the cycle point; and use the determined Boolean negotiation value as a binary termination message and broadcast it to all nodes;
[0158] If the Boolean negotiation value is not equal to the public coin toss value, the current cycle number is increased by 1, and only the Boolean negotiation value is used as the preliminary voting value for the next cycle, and the process jumps to the cycle point;
[0159] If the binary value set does not satisfy the seventh condition, add 1 to the current loop number, use the public coin toss value as the preliminary voting value for the next loop, and jump to the loop point.
[0160] In one embodiment, the loop processing module is used to:
[0161] determining in real time whether a second number of matching binary termination messages are received;
[0162] If yes, broadcast the Boolean negotiation value as a binary termination message to all nodes, and determine the Boolean negotiation value corresponding to the binary termination message;
[0163] If the determined Boolean negotiation value is 1, the multi-value negotiation value is determined.
[0164] In summary, in the method and device proposed in the embodiment of the present invention, after entering the current round, a transaction message is generated according to the transaction requests in the waiting queue maintained by the node, and broadcast to all nodes, wherein the transaction request in the waiting queue is sent by the client; the received transaction message is added to the buffer queue corresponding to the source node of the transaction message; the block value of this round is determined according to all transaction requests in the buffer queue of the master node; according to the block value of this round, an input message is generated, and broadcast to all nodes; according to the received input message, a diffusion message or a termination message is generated, and broadcast to all nodes; according to the received diffusion message, a preliminary voting value is determined, and the current number of loops is initialized to 1; the loop point is determined and the loop is entered, in which the multi-value negotiation value is determined according to the preliminary voting value, and the loop point is entered in this round by updating the next preliminary voting value; or, the multi-value negotiation value is determined according to the termination message; after determining the multi-value negotiation value, all transaction requests contained in the block corresponding to the determined multi-value negotiation value are delivered, and the next round is entered. In the prior art, the synchronous Byzantine consensus adopts a deterministic method, which requires The time complexity of the embodiment of the present invention is 2-step, and the solution proposed in the embodiment of the present invention can deliver a transaction in only two steps in the absence of malicious nodes. Specifically, through the above-mentioned input message, diffusion message, termination message, preliminary voting value, and finally the multi-value negotiation value is determined through a loop. After the preliminary voting value is updated during the loop, the loop point is entered, so that the preliminary voting value of the next round is continuously updated to ensure that the multi-value negotiation value is determined, and the implementation is realized. The expected time complexity is ; or the multi-value negotiation value can be determined according to the termination message; finally, after the multi-value negotiation value is determined, all transaction requests contained in the block corresponding to the determined multi-value negotiation value are delivered, thereby achieving Byzantine consensus; during the whole process, each node can send transaction messages, and the throughput is large.
[0165] An embodiment of the present invention further provides a computer device, Figure 5 Schematic diagram of a computer device in an embodiment of the present invention. The computer device 500 includes a memory 510, a processor 520, and a computer program 530 stored in the memory 510 and executable on the processor 520. When the processor 520 executes the computer program 530, the Byzantine consensus method in the above-mentioned blockchain is implemented.
[0166] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the Byzantine consensus method in the above-mentioned blockchain is implemented.
[0167] An embodiment of the present invention also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the Byzantine consensus method in the above-mentioned blockchain.
[0168] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0169] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0170] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0171] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0172] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A Byzantine consensus method in a blockchain, characterized in that: Applied to any node in a blockchain under a synchronous network, the method includes: After entering this round, a transaction message is generated according to the transaction requests in the waiting queue maintained by the node, and broadcasted to all nodes, wherein the transaction requests in the waiting queue are sent by the client; Add the received transaction message to the buffer queue corresponding to the node where the transaction message comes from; determine the block value of this round based on all transaction requests in the buffer queue of the master node; generate input messages based on the block value of this round and broadcast them to all nodes; Generate a diffusion message or a termination message based on the received input message and broadcast it to all nodes; Determine the preliminary voting value according to the received diffusion message, initialize the current cycle number to 1; determine the cycle point and enter the cycle, in which the multi-value negotiation value is determined according to the preliminary voting value, and enter the cycle point by updating the next preliminary voting value in this round; or determine the multi-value negotiation value according to the termination message; After the multi-value negotiation value is determined, all transaction requests contained in the block corresponding to the determined multi-value negotiation value are delivered and the next round begins; After generating the transaction message and broadcasting it to all nodes, the method further includes: starting a first timer; after the first timer has finished timing, adding the received transaction message to a buffer queue corresponding to the transaction message source node; After the input message is generated and broadcasted to all nodes, the method further includes: starting a second timer; after the second timer is completed, generating a diffusion message or a termination message according to the received input message; After the diffusion message or termination message is generated and broadcasted to all nodes, the method further includes: starting a third timer; after the third timer is completed, determining a preliminary voting value according to the received diffusion message, and initializing the current cycle number to 1; Determining a multi-value negotiation value according to a termination message includes: if a received termination message satisfies a third condition, using the termination value in the termination message satisfying the third condition as the termination message of the node, and broadcasting it to all nodes, wherein the third condition is that a second number of matching termination messages are received, and the node has not sent a termination message; if the received termination message satisfies a fourth condition and the node has not determined the multi-value negotiation value, determining the multi-value negotiation value according to the termination value in the termination message satisfying the fourth condition, delivering all transaction requests contained in the block corresponding to the multi-value negotiation value, and terminating the execution of this round, wherein the fourth condition is that a first number of matching termination messages are received.
2. The method according to claim 1, characterized in that Generate a transaction message according to the transaction request in the waiting queue maintained by the node, including: If the waiting queue of the node is not empty, the first transaction request in the waiting queue is taken out as a transaction message; If the waiting queue of the node is empty, the empty symbol is used as the transaction message.
3. The method according to claim 1, characterized in that According to all transaction requests in the master node's buffer queue, the block value of this round is determined, including: All transaction requests in the buffer queue of the master node are used as the blocks of this round; the master node is the node corresponding to the public random number, and the public random number is the random number selected by all nodes calling the threshold random number generation protocol together; Calculate the hash value of the block as the block value of this round.
4. The method according to claim 1, characterized in that The input message includes the block value and threshold signature of this round, and the first threshold signature share, where the first threshold signature share is obtained by performing a threshold signature on the block value.
5. The method according to claim 1, characterized in that Generate a diffusion message or a termination message based on the received input message, including: After the threshold signature of the received input message is verified, the block value in the input message is added to the block value set; If the received input message meets the first condition, the block value of the input message meeting the first condition is set to the termination value, and a termination message is formed and broadcast to all nodes; the multi-value negotiation value is determined according to the termination value; the first condition is that a first number of matching input messages are received, and the block value of the input message is in the block value set; If the received input message meets the second condition, the block value of the input message meeting the second condition is used as the diffusion value, and the first threshold signature share in the input message meeting the second condition is combined into a first threshold signature; the diffusion value and the corresponding threshold signature and the first threshold signature are used as the diffusion message; the second condition is that a second number of matching input messages are received, and the block value of the input message is in the block value set; If the received diffusion message does not meet the first condition and the second condition, the empty symbol is used as the diffusion message.
6. The method according to claim 1, characterized in that Based on the received diffusion message, determine the preliminary voting value, including: After the threshold signature of the received diffusion message and the first threshold signature are verified, the diffusion value in the diffusion message and the corresponding threshold signature are added to the multi-value set; If the received diffusion message meets the fifth condition, the diffusion value of the diffusion message that meets the first condition is used as the multi-value negotiation value, and 1 is determined as the preliminary voting value, the hash value of the diffusion value is used as the auxiliary value, and the threshold signature of the diffusion value is used as the auxiliary signature; the fifth condition is that a third number of matching diffusion messages are received, and the diffusion value of the diffusion message and its corresponding threshold signature are in the multi-value set, and the multi-value set has only one set of diffusion value and corresponding threshold signature; If the received diffusion message does not satisfy the fifth condition, 0 is determined as the preliminary voting value.
7. The method according to claim 1, characterized in that In the cycle, the multi-value negotiation value is determined based on the preliminary voting value, and the cycle point is entered by updating the next preliminary voting value in this round, including: In the current cycle, a preliminary voting message is generated according to the preliminary voting value and the number of cycles, and broadcasted to all nodes, and the fourth timer is started; After the fourth timer is finished, a final voting message is generated based on the received preliminary voting message, and broadcasted to all nodes, and the fifth timer is started; After the fifth timer is completed, the multi-value negotiation value is determined according to the received final voting message, and the loop point is entered by updating the next preliminary voting value in this round.
8. The method according to claim 7, characterized in that Generate a preliminary voting message based on the preliminary voting value and the number of cycles, including: Perform threshold signature on the preliminary voting value and the number of cycles to obtain the second threshold signature share; If the number of cycles is 1 and the initial voting value is 1, the initial voting value, auxiliary value, auxiliary signature and second threshold signature share are used as the initial voting message; If the cycle number is not 1 or the preliminary voting value is not 1, the preliminary voting value and the second threshold signature share are used as the preliminary voting message.
9. The method according to claim 7, characterized in that Based on the received preliminary voting message, a final voting message is generated, including: After verifying the auxiliary signature and the second threshold signature share of the received preliminary voting message, if the received preliminary voting message satisfies the sixth condition, the preliminary voting value in the preliminary voting message that satisfies the sixth condition is used as the final voting value, the second threshold signature shares in the second number of matching preliminary voting messages are combined into a second threshold signature, and the final voting value and the second threshold signature are used as the final voting message, and the sixth condition is that the second number of matching preliminary voting messages are received; If the received preliminary voting message does not satisfy the sixth condition, the empty symbol is used as the final voting message.
10. The method according to claim 7, characterized in that Based on the received final voting message, the multi-value negotiation value is determined, and the cycle point is entered by updating the next preliminary voting value in this round, including: After the second threshold signature of the received final voting message is verified, the final voting value and the second threshold signature in the final voting message are added to a binary value set, and a binary value counter corresponding to the final voting value is incremented by one, wherein the binary value set includes a plurality of binary values, wherein each final voting value in the final voting message and the corresponding second threshold signature form a binary value; If the number of cycles is 1, determine the public coin value to be 1; If the number of cycles is not 1, the binary random number selected by all nodes is used as the public coin toss value; Based on the public coin value and the binary value set, the multi-value negotiation value is determined according to the final voting message received, and the cycle point is entered by updating the next preliminary voting value in this round.
11. The method according to claim 10, characterized in that The multi-value negotiation value is determined based on the public coin value and the binary value set, and the cycle point is entered by updating the next preliminary voting value in this round, including: If the binary value set satisfies the seventh condition, the unique final voting value in the binary value set is used as the Boolean negotiation value, and the seventh condition is that the binary value set only contains a tuple consisting of the unique final voting value and the second threshold signature, and the value of the binary value counter corresponding to the unique final voting value is not less than the second number; If the Boolean negotiation value is equal to the public coin toss value, determining the Boolean negotiation value; If the determined Boolean negotiation value is 1, determine the multi-value negotiation value; use the determined Boolean negotiation value as the preliminary voting value for the next cycle and jump to the cycle point; and use the determined Boolean negotiation value as a binary termination message and broadcast it to all nodes; If the Boolean negotiation value is not equal to the public coin toss value, the current cycle number is increased by 1, and only the Boolean negotiation value is used as the preliminary voting value for the next cycle, and the process jumps to the cycle point; If the binary value set does not satisfy the seventh condition, add 1 to the current loop number, use the public coin toss value as the preliminary voting value for the next loop, and jump to the loop point.
12. The method according to claim 11, characterized in that Also includes: determining in real time whether a second number of matching binary termination messages are received; If yes, broadcast the Boolean negotiation value as a binary termination message to all nodes, and determine the Boolean negotiation value corresponding to the binary termination message; If the determined Boolean negotiation value is 1, the multi-value negotiation value is determined.
13. A Byzantine consensus device in a blockchain, characterized in that: Applied to any node in a blockchain under a synchronous network, the device comprises: A transaction message broadcast module is used to generate a transaction message according to the transaction requests in the waiting queue maintained by the node after entering the current round, and broadcast it to all nodes, wherein the transaction requests in the waiting queue are sent by the client; The input message broadcast module is used to add the received transaction message to the buffer queue corresponding to the transaction message source node; determine the block value of this round according to all transaction requests in the buffer queue of the master node; generate the input message according to the block value of this round and broadcast it to all nodes; The input message processing module is used to generate a diffusion message or a termination message according to the received input message and broadcast it to all nodes; The loop processing module is used to determine the preliminary voting value according to the received diffusion message, initialize the current loop number to 1; determine the loop point and enter the loop, in the loop, determine the multi-value negotiation value according to the preliminary voting value, and enter the loop point by updating the next preliminary voting value in this round; or, determine the multi-value negotiation value according to the termination message; after determining the multi-value negotiation value, deliver all transaction requests contained in the block corresponding to the determined multi-value negotiation value, and enter the next round; After generating the transaction message and broadcasting it to all nodes, the method further includes: starting a first timer; after the first timer has finished timing, adding the received transaction message to a buffer queue corresponding to the transaction message source node; After the input message is generated and broadcasted to all nodes, the method further includes: starting a second timer; after the second timer is completed, generating a diffusion message or a termination message according to the received input message; After the diffusion message or termination message is generated and broadcasted to all nodes, the method further includes: starting a third timer; after the third timer is completed, determining a preliminary voting value according to the received diffusion message, and initializing the current cycle number to 1; Determining a multi-value negotiation value according to a termination message includes: if a received termination message satisfies a third condition, using the termination value in the termination message satisfying the third condition as the termination message of the node, and broadcasting it to all nodes, wherein the third condition is that a second number of matching termination messages are received, and the node has not sent a termination message; if the received termination message satisfies a fourth condition and the node has not determined the multi-value negotiation value, determining the multi-value negotiation value according to the termination value in the termination message satisfying the fourth condition, delivering all transaction requests contained in the block corresponding to the multi-value negotiation value, and terminating the execution of this round, wherein the fourth condition is that a first number of matching termination messages are received.
14. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 12 is implemented.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
16. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Asynchronous consensus method and system adaptive to dynamic change of transaction volume
CN114928473A