A block consensus method and device
By introducing an asynchronous execution mechanism in the blockchain system, the random number ciphertext information of the i-th block is obtained through consensus before being rolled on the i-th block, and then decrypted the information after rolling on the i-th block to determine the consensus node, solving the problem of reduced consensus efficiency in the existing alliance chain consensus mode, achieving a more efficient block yield speed.
Patent Information
- Application Number
- CN202111324192.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2041-11-10
AI Technical Summary
In the existing consensus mode of alliance chains, as the number of nodes increases, the consensus efficiency decreases, resulting in slowing down the block production speed. When the prior art solutions reduce the number of consensus nodes, they affect the efficiency of determining consensus nodes.
By introducing an asynchronous execution mechanism in the blockchain system, the random number ciphertext information of the i-th block is obtained through consensus before being rolled on the i-th block, and then the information is decrypted after rolling on the i-th block to determine the consensus node, thereby improving the determination efficiency of the consensus node.
This method effectively reduces the time to determine consensus nodes, improves the efficiency of consensus nodes, and improves the block production efficiency of blockchain systems.
Smart Images

Figure CN114048495B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of financial technology (Fintech), and in particular to a block consensus method and device. Background Art
[0002] With the development of computer technology, more and more technologies (such as blockchain, cloud computing or big data) are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology, and big data technology is no exception. However, due to the security and real-time requirements of the financial and payment industries, higher requirements are also placed on the consensus of blocks in big data technology.
[0003] At present, the consensus method of the alliance chain is that all nodes in the alliance chain participate in the block consensus. As the network expands, the number of nodes gradually increases, and the efficiency of consensus decreases, resulting in the alliance chain producing blocks more and more slowly.
[0004] In order to increase the block generation efficiency of the alliance chain, the existing technical solution is to select consensus nodes participating in block consensus from all the nodes in the alliance chain, thereby reducing the number of consensus nodes and improving the block generation efficiency of the alliance chain.
[0005] However, in the prior art, the consensus node process participating in the block consensus is determined from all the nodes of the alliance chain after the previous block of the consensus block is on the chain, which affects the efficiency of determining the consensus node. That is, it takes a long time to determine the consensus node, which reduces the efficiency of block generation. Summary of the invention
[0006] The embodiments of the present invention provide a block consensus method and device for reducing the time of determining consensus nodes, improving the efficiency of determining consensus nodes, and improving the block generation efficiency of a blockchain system.
[0007] In a first aspect, an embodiment of the present invention provides a block consensus method, including:
[0008] When a node reaches consensus on the i-th block, it obtains the i-th random number ciphertext information corresponding to the i-th block; the i-th random number ciphertext information is obtained based on consensus on the i-th random number ciphertext of each node before consensus on the i-th block;
[0009] The node decrypts each i-th random number ciphertext in the i-th random number ciphertext information based on the i-th decryption public key broadcasted by each node to obtain each i-th random number plaintext; wherein each i-th decryption public key is broadcasted by each node after the i-1th block is on the chain;
[0010] The node determines a consensus node for consensus on the i-th block based on each i-th random number plaintext, thereby achieving consensus on the i-th block based on the consensus node.
[0011] In the above technical scheme, before the i-1th block is put on the chain, the random number ciphertext information for the i-th block is obtained by consensus on the random number ciphertext of each node; after the i-1th block is put on the chain, the consensus node is determined by decrypting the random number ciphertext information for the i-th block, so as to reach a consensus on the i-th block; that is, the process of obtaining the random number ciphertext information for the i-th block and the process of determining the consensus node are executed asynchronously; it is equivalent to dividing the process of determining the consensus node into two parts, one part is for the i-th block, encrypting the random number plaintext of each node, and determining the random number ciphertext information; the other part is for the i-th block, decrypting the random number ciphertext information, and determining the consensus node, and the two parts of the process are performed asynchronously, because the random number ciphertext information of the i-th block is determined before the i-1th block is put on the chain, that is, before the consensus process of the i-th block, thereby reducing the time for determining the consensus node and improving the efficiency of determining the consensus node, thereby improving the block generation efficiency of the blockchain system.
[0012] Optionally, the i-th random number ciphertext information is obtained based on consensus on the i-th random number ciphertext of each node before consensus on the i-th block, including:
[0013] Before reaching consensus on the i-th block, the node generates the i-th random number ciphertext information based on the i-th random number ciphertext broadcast by other nodes and its own i-th random number ciphertext;
[0014] The node determines a first hash value of the i-th random number ciphertext information, and broadcasts the first hash value in the blockchain system;
[0015] The node obtains the second hash value broadcasted by other nodes, and determines that the consensus of the i-th random number ciphertext information is successful when it is determined that the number of second hash values consistent with the first hash value meets the consensus threshold; the second hash value is determined by the other nodes according to their own i-th random number ciphertext information;
[0016] The node stores the i-th random number ciphertext information that successfully reaches consensus on the chain.
[0017] In the above technical solution, before consensus is reached on the i-th block, the i-th random number ciphertext information of the i-th block is determined through a consensus mechanism, so that when consensus is reached on the i-th block, the time for determining the consensus node can be reduced and the efficiency of determining the consensus node can be improved. Therefore, the efficiency of the blockchain system in producing the i-th block is improved, and the security of the random number ciphertext information is guaranteed through the consensus mechanism.
[0018] Optionally, the i-th random number ciphertext is obtained by:
[0019] Before reaching consensus on the i-th block, the node generates the i-th random number plaintext, the i-th encryption private key and the i-th decryption public key of the i-th block based on the block height of the i-th block;
[0020] The node encrypts the i-th random number plaintext according to the i-th encryption private key to determine the i-th random number ciphertext.
[0021] In the above technical solution, the i-th random number ciphertext of any node is used to determine whether the node is a consensus node. By determining the i-th random number ciphertext before consensus on the i-th block, the time for determining the consensus node when consensus on the i-th block is reduced, the efficiency of determining the consensus node is improved, and the efficiency of the blockchain system in producing the i-th block is improved.
[0022] Optionally, the node determines a consensus node for consensus on the i-th block based on each i-th random number plaintext, including:
[0023] The node determines the number of the consensus nodes according to the number of each node in the blockchain system and a preset number rule;
[0024] The node sorts the i-th random number plaintexts according to a preset sorting rule;
[0025] The node determines the consensus node in each i-th random number plaintext after sorting according to the number of the consensus nodes and a preset selection rule.
[0026] In the above technical solution, the unpredictability of the consensus node is ensured by the preset quantity rule and the preset sorting rule, so as to prevent attackers from predicting the consensus node of the consensus block i, thereby ensuring the security of the consensus node.
[0027] Optionally, the number of the consensus nodes is determined according to the following formula (1);
[0028] M = log22N+1 (1);
[0029] Wherein, M is the number of the consensus nodes; N is the number of each node in the blockchain system.
[0030] In the above technical solution, the number of consensus nodes is controlled by a preset number rule. Because the preset number rule is a logarithmic function, when the number of nodes in the blockchain system increases, the increase in the number of consensus nodes fluctuates less. In other words, the increase in the number of nodes in the blockchain system is not proportional to the increase in the number of consensus nodes, thereby ensuring the smooth operation of the blockchain system and avoiding network fluctuations in the blockchain system.
[0031] Optionally, the node determines the consensus node in each i-th random number plaintext after sorting according to the number of the consensus nodes and a preset selection rule, including:
[0032] The node determines an integer quotient L of N / M according to the number M of the consensus nodes and the number N of each node;
[0033] The node selects each node corresponding to the i-th random number plaintext located at the L+1th to the L+Mth position from the sorted i-th random number plaintext as the consensus node.
[0034] In the above technical solution, the unpredictability of determining the consensus nodes is ensured by using preset sorting rules, thereby ensuring the security of determining the consensus nodes.
[0035] Optionally, achieving consensus on the i-th block based on the consensus node includes:
[0036] The consensus nodes reach a consensus on the i-th block according to the PBFT consensus mechanism.
[0037] In a second aspect, an embodiment of the present invention provides a block consensus device, including:
[0038] An acquisition module, used for acquiring the i-th random number ciphertext information corresponding to the i-th block when consensus is reached on the i-th block; the i-th random number ciphertext information is obtained based on consensus on the i-th random number ciphertext of each node before consensus is reached on the i-th block;
[0039] A processing module, configured to decrypt each i-th random number ciphertext in the i-th random number ciphertext information based on the i-th decryption public key broadcasted by each node, to obtain each i-th random number plaintext; wherein each i-th decryption public key is broadcasted by each node after the i-1th block is put on the chain;
[0040] Based on the i-th random number plaintexts, a consensus node for consensus on the i-th block is determined, so that consensus on the i-th block is achieved based on the consensus node.
[0041] Optionally, the processing module is specifically used for:
[0042] Before reaching consensus on the i-th block, based on the i-th random number ciphertext broadcast by each other node and its own i-th random number ciphertext, generate the i-th random number ciphertext information;
[0043] Determine a first hash value of the i-th random number ciphertext information, and broadcast the first hash value in the blockchain system;
[0044] The control acquisition module acquires the second hash value broadcasted by each other node, and determines that the consensus of the i-th random number ciphertext information is successful when it is determined that the number of second hash values consistent with the first hash value meets the consensus threshold; the second hash value is determined by each other node according to its own i-th random number ciphertext information;
[0045] The i-th random number ciphertext information that successfully reaches consensus is stored on the chain.
[0046] Optionally, the processing module is specifically used for:
[0047] Before reaching consensus on the i-th block, generate the i-th random number plaintext, the i-th encryption private key and the i-th decryption public key of the i-th block based on the block height of the i-th block;
[0048] The i-th random number plaintext is encrypted according to the i-th encryption private key to determine the i-th random number ciphertext.
[0049] Optionally, the processing module is specifically used for:
[0050] Determine the number of the consensus nodes according to the number of nodes in the blockchain system and a preset number rule;
[0051] Sorting the i-th random number plaintexts according to a preset sorting rule;
[0052] According to the number of the consensus nodes, the consensus nodes are determined in each i-th random number plaintext after sorting according to the preset selection rules.
[0053] Optionally, the processing module is specifically used for:
[0054] Determine the number of consensus nodes according to the following formula (1);
[0055] M = log22N+1 (1);
[0056] Wherein, M is the number of the consensus nodes; N is the number of each node in the blockchain system.
[0057] Optionally, the processing module is specifically used for:
[0058] Determine an integer quotient L of N / M according to the number M of the consensus nodes and the number N of each node;
[0059] Among the sorted i-th random number plaintexts, each node corresponding to the i-th random number plaintext located at the L+1th to the L+Mth positions is selected as the consensus node.
[0060] Optionally, the processing module is specifically used for:
[0061] A consensus is reached on the i-th block according to the PBFT consensus mechanism.
[0062] In a third aspect, an embodiment of the present invention further provides a computer device, including:
[0063] A memory for storing program instructions;
[0064] The processor is used to call the program instructions stored in the memory and execute the above block consensus method according to the obtained program.
[0065] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned block consensus method. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. 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 paying creative work.
[0067] Figure 1 A schematic diagram of a block consensus provided by an embodiment of the present invention;
[0068] Figure 2 A schematic diagram of a system architecture provided by an embodiment of the present invention;
[0069] Figure 3 A flowchart of a block consensus method provided by an embodiment of the present invention;
[0070] Figure 4 A schematic diagram of a random number ciphertext information stored in an embodiment of the present invention;
[0071] Figure 5 A schematic diagram of a block consensus method provided by an embodiment of the present invention;
[0072] Figure 6 A schematic diagram of the structure of a block consensus device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0073] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0074] In the prior art, the alliance chain consensus adopts the whole network consensus method to produce blocks. For example, FISCO-BCOS adopts PBFT (Practical Byzantine Fault Tolerance) to complete the consensus of transactions between consensus nodes in the blockchain system.
[0075] Figure 1 A schematic diagram of a block consensus is shown as an example. Figure 1 As shown, the client creates a transaction, signs the transaction and then sends it to the blockchain system; the node corresponding to the client is the access node. After obtaining the transaction, the access node verifies the signature of the transaction and broadcasts the transaction after the signature verification is passed; the consensus node in the blockchain system sorts the transactions broadcast in the blockchain system and packages them into blocks, then executes the transactions in the block, broadcasts the block, and reaches consensus with other consensus nodes (such as the PBFT consensus mechanism); after the block consensus is successful, each node in the blockchain system verifies its own transaction, and after the verification is passed, the transaction is packaged into a block and the block is uploaded to the local blockchain.
[0076] In the alliance chain consensus mechanism, all nodes in the blockchain system are consensus nodes. As the blockchain system expands, the number of nodes gradually increases, resulting in a decrease in the consensus efficiency of the block. In the prior art, in order to improve the efficiency of block consensus, a small number of consensus nodes are selected in the blockchain system to reduce the time consumption, complexity and computing power of block consensus. For example, if the blockchain system includes 100 nodes, when reaching consensus on the nth block, 10 nodes are selected from the 100 nodes as consensus nodes.
[0077] However, in the prior art, the process of determining the consensus node is determined when the consensus on the current block is reached. Encryption and other operations are designed in the process of determining the consensus node, which results in a long time spent in determining the consensus node, thereby reducing the consensus efficiency of the blockchain system. Moreover, the number of consensus nodes is currently proportional to the number of nodes in the blockchain system. For example, the number of consensus nodes is 10% of the number of nodes in the blockchain system, resulting in a large increase rate in the number of consensus nodes when the number of nodes in the blockchain system increases, which makes it impossible to balance the security and efficiency of the network, and easily leads to the risk of network fluctuations in the blockchain system.
[0078] Therefore, a block consensus method is needed to reduce the time to determine the consensus nodes, improve the efficiency of determining the consensus nodes, and improve the block production efficiency of the blockchain system.
[0079] In order to better explain the technical solution of the present invention, the following is an explanation of the terms that may appear:
[0080] Consensus node: responsible for block consensus. In each round of consensus, there is only one leader in the consensus node. The leader is used to package transactions into blocks. In order to prevent the leader from forging blocks, the leader will be switched after each round of PBFT consensus.
[0081] Asymmetric encryption algorithm: includes two keys: publickey, i.e. public key; privatekey, i.e. private key; the public key and private key are a pair. If the data is encrypted with the public key, it can only be decrypted with the corresponding private key. Conversely, if the data is encrypted with the private key, it can only be decrypted with the corresponding public key.
[0082] PBFT: Practical Byzantine Fault Tolerant consensus algorithm, which can reach consensus in scenarios where a few nodes act maliciously (such as forging messages). It uses cryptographic algorithms such as signatures, signature verification, and hashing to ensure tamper-proof, anti-forgery, and non-repudiation during message transmission, and reduces the complexity of the Byzantine Fault Tolerant algorithm from exponential to polynomial level. In a system composed of (3*f+1) nodes, as long as there are no less than (2*f+1) non-malicious nodes working normally, the system can reach consensus, where f is the number of nodes allowed to act maliciously.
[0083] Figure 2 A system architecture is provided for an embodiment of the present invention. Figure 2 As shown, the system architecture may include a blockchain 100 and multiple resource-sharing participants 200 (1-n);
[0084] Among them, the participants 200 can be different organizations participating in resource sharing. The multiple participants 200 are located in the same blockchain. When sharing a resource file, one of the participants 200 creates the resource file and uploads it to the blockchain, and then other resource-sharing participants 200 query the resource file from the blockchain.
[0085] The blockchain 100 is composed of multiple blocks and is used to store shared resource files.
[0086] It should be noted that the above Figure 2 The structure shown is only an example and is not limited to this embodiment of the present invention.
[0087] Based on the above description, Figure 3 The flowchart of a block consensus method provided by an embodiment of the present invention is exemplarily shown, and the flowchart can be executed by a block consensus device.
[0088] like Figure 3 As shown in the figure, the process specifically includes:
[0089] Step 310, when the node reaches consensus on the i-th block, it obtains the i-th random number ciphertext information corresponding to the i-th block.
[0090] In the embodiment of the present invention, the i-th random number ciphertext information is obtained based on consensus on the i-th random number ciphertext of each node before consensus on the i-th block.
[0091] In step 320, the node decrypts each i-th random number ciphertext in the i-th random number ciphertext information based on the i-th decryption public key broadcasted by each node to obtain each i-th random number plaintext.
[0092] In the embodiment of the present invention, each i-th decryption public key is broadcast by each node after the i-1-th block is uploaded to the chain.
[0093] In step 330, the node determines a consensus node for consensus on the i-th block based on each i-th random number plaintext, thereby achieving consensus on the i-th block based on the consensus node.
[0094] In an embodiment of the present invention, the consensus node is determined based on a preset sorting rule and a preset quantity rule, wherein the preset quantity rule is a logarithmic function, thereby reducing the increase fluctuation of the number of consensus nodes, ensuring the smooth operation of the blockchain system, and avoiding network fluctuations of the blockchain system.
[0095] In step 310, before consensus is reached on the i-th block, any node obtains the i-th random number ciphertext broadcast by other nodes in the blockchain system, and then each node in the blockchain system reaches a consensus on the i-th random number ciphertext of each node, thereby ensuring the security of the i-th random number ciphertext.
[0096] Specifically, before consensus on the i-th block, the node generates the i-th random number ciphertext information based on the i-th random number ciphertext broadcasted by other nodes and its own i-th random number ciphertext; determines the first hash value of the i-th random number ciphertext information, and broadcasts the first hash value in the blockchain system; obtains the second hash value broadcasted by other nodes, and determines that the i-th random number ciphertext information consensus is successful when it is determined that the number of second hash values consistent with the first hash value meets the consensus threshold; the second hash value is determined by other nodes based on their own i-th random number ciphertext information; and the i-th random number ciphertext information that has successfully reached consensus is stored on the chain.
[0097] In one practicable manner, after any node generates the i-th random number plaintext, it encrypts it through a trusted third party to obtain the i-th random number ciphertext.
[0098] In another practicable manner, after any node generates the i-th random number plaintext, it encrypts it using a symmetric key to obtain the i-th random number ciphertext.
[0099] In the embodiment of the present invention, after any node generates the i-th random number plaintext, it encrypts it using an asymmetric key to obtain the i-th random number ciphertext.
[0100] Specifically, before reaching consensus on the i-th block, the node generates the i-th random number plaintext, the i-th encryption private key and the i-th decryption public key of the i-th block based on the block height of the i-th block;
[0101] The node encrypts the i-th random number plaintext according to the i-th encryption private key to determine the i-th random number ciphertext.
[0102] For example, the blockchain system includes 8 nodes, namely node1, node2, node3, node4, node5, node6, node7, and node8; taking node1 as an example, the i-th random number plaintext R1, the i-th encryption private key Pri1, and the i-th decryption public key Pub1 are generated, and the i-th random number plaintext R1 is encrypted according to the i-th encryption private key Pri1 to obtain the i-th random number ciphertext S1; wherein, i can represent the block height, and for different block heights, the random number plaintext, encryption private key, decryption public key, and random number ciphertext of node1 can be as shown in the following Table 1.
[0103] Table 1
[0104] Block height Random number plaintext Encrypted private key Decrypting the public key Random number ciphertext 1 B1-R1 B1-Pri1 B1-Pub1 B1-S1 2 B2-R1 B2-Pri1 B2-Pub1 B2-S1 …… …… …… …… …… i Bi-R1 Bi-Pri1 Bi-Pub1 Bi-S1
[0105] Based on the random number plaintext, encrypted private key, decrypted public key and random number ciphertext of the above node1, other nodes are described. For example, for the block with block height i, the random number plaintexts of node2 to node8 are Bi-R2, Bi-R3, Bi-R4, Bi-R5, Bi-R6, Bi-R7 and Bi-R8 respectively; the encrypted private keys of node2 to node8 are Bi-Pri2, Bi-Pri3, Bi-Pri4, Bi-Pri5, Bi-Pri6, Bi-Pri7 and Bi-Pri8 respectively; the encrypted public keys of node2 to node8 are Bi-Pub2, Bi-Pub3, Bi-Pub4, Bi-Pub5, Bi-Pub6, Bi-Pub7 and Bi-Pub8 respectively; the random number ciphertexts of node2 to node8 are Bi-S2, Bi-S3, Bi-S4, Bi-S5, Bi-S6, Bi-S7 and Bi-S8 respectively.
[0106] After any node generates a random number ciphertext, it broadcasts the random number ciphertext to the blockchain system, so that each node in the blockchain system generates random number ciphertext information.
[0107] Based on the above node1 as an example, the generated i-th random number ciphertext information is shown in the following Table 2.
[0108] Table 2
[0109] node1 Bi-S1 node2 Bi-S2 node3 Bi-S3 node4 Bi-S4 node5 Bi-S5 node6 Bi-S6 node7 Bi-S7 node8 Bi-S8
[0110] The node node 1 performs a hash operation based on the i-th random number ciphertext information determined by itself to generate a first hash value, and generates a first broadcast message (S-prepared message) based on its own unique identifier "node1" and the first hash value, such as the first broadcast message "node1-Hash_Bi-S"; wherein "Bi-S" is the i-th random number ciphertext information, and "Hash_Bi-S" is the first hash value of the hash operation on the i-th random number ciphertext information.
[0111] The node 1 collects the second broadcast messages generated by other nodes in the blockchain system for their own i-th random number ciphertext information. The second broadcast message includes the unique identifier and the second hash value of other nodes. For example, the second broadcast message of the node 2 is "node2-Hash_Bi-S", which includes the second hash value determined by the node 2 for its own i-th random number ciphertext information.
[0112] Based on the above description, the second broadcast message collected by node 1 is shown in Table 3 below.
[0113] Table 3
[0114]
[0115]
[0116] When the number of second hash values collected by node 1 that are consistent with its own first hash value meets the consensus threshold, it is determined that the consensus of the i-th random number ciphertext information is successful; wherein the consensus threshold is determined according to the number of nodes in the blockchain system. For example, if the number of nodes in the blockchain system is N, the consensus threshold is N / 2 (rounded down) + 1. Specifically, for example, if N = 11, the consensus threshold is 6.
[0117] After any node determines that the i-th random number ciphertext information has been successfully agreed upon, it will store the i-th random number ciphertext information on the chain. Figure 4 An exemplary diagram of a random number ciphertext information storage is shown, Figure 4As shown, the random number ciphertext information corresponding to the block height is stored with the block height as the identifier, where B0-S_list represents the random number ciphertext information with a block height of 0 (including the random number ciphertext of each node); B1-S_list represents the random number ciphertext information with a block height of 1; and so on, Bi-S_list represents the random number ciphertext information with a block height of i.
[0118] In step 320, after the i-1th block is uploaded to the chain, each node in the blockchain system will broadcast the i-th decryption public key for the i-th block, so that others can determine the i-th random number plaintext of the corresponding node.
[0119] Taking the above node1 as an example, after the first block is uploaded to the chain, each node will broadcast the decryption public key B2-Pub for the second block. Any node decrypts the second random number ciphertext according to the corresponding decryption public key B2-Pub to obtain the random number plaintexts of the eight nodes in the blockchain system, namely B2-R1, B2-R2, B2-R3, B2-R4, B2-R5, B2-R6, B2-R7, and B2-R8.
[0120] In step 330, after obtaining the i-th random number plaintext of each node, any node determines whether it is a consensus node by sorting and determining the number of consensus nodes.
[0121] Specifically, the node determines the number of consensus nodes according to the number of nodes in the blockchain system and a preset number rule; sorts each i-th random number plaintext according to a preset sorting rule; and determines the consensus node in each i-th random number plaintext after sorting according to the number of consensus nodes and a preset selection rule.
[0122] Wherein, the preset quantity rule is a preset logarithmic function. Further, the number of the consensus nodes is determined according to the following formula (1);
[0123] M = log22N+1 (1);
[0124] Wherein, M is the number of the consensus nodes; N is the number of each node in the blockchain system.
[0125] Based on the above description, for example, if N is equal to 8, then M=log217, and after rounding down, M=4, that is, the number of consensus nodes is 4; if N is equal to 16, then M=log233, and after rounding down, M=5. The embodiment of the present invention does not specifically limit N and will not be elaborated here.
[0126] In an implementable manner, the preset sorting rule may be to sort the nodes in ascending order or in descending order according to the unique identifiers of the nodes.
[0127] In another practicable manner, the preset sorting rule may be: sorting the nodes in an ascending order or a descending order based on the size of the random number plaintext corresponding to the nodes.
[0128] Among them, the preset selection rule is: the node determines the integer quotient L of N / M based on the number of consensus nodes M and the number of each node N; in each i-th random number plaintext after sorting, select each node corresponding to the i-th random number plaintext located at the L+1th to the L+Mth position as the consensus node.
[0129] Taking the above example of N being 8, M=4, then L=2. If the order of the random number plaintext is: Bi-R1>Bi-R2>Bi-R3>Bi-R4>Bi-R5>Bi-R6>Bi-R7>Bi-R8, then the node corresponding to the random number plaintext of the L+1=3th digit is node3, and the node corresponding to the random number plaintext of the L+M=6th digit is node6. In other words, the consensus nodes are node3, node4, node5 and node6.
[0130] After any node determines the consensus node, it determines whether it is a consensus node based on its own node identifier. If so, it participates in the consensus on the block, otherwise it does not participate in the consensus on the block.
[0131] After the consensus nodes are determined, they reach consensus on the blocks based on the PBFT consensus mechanism.
[0132] In order to better explain the above technical solution, Figure 5 A schematic diagram of a block consensus method is shown as an example. Figure 5 As shown, the embodiment of the present invention is equivalent to dividing the process of determining the consensus node into two parts, one part is for the i-th block, encrypting the random number plaintext of each node, and determining the random number ciphertext information; the other part is for the i-th block, decrypting the random number ciphertext information, and determining the consensus node.
[0133] Specifically, the first layer of consensus is participated by all nodes in the blockchain system, which broadcast the i-th random number ciphertext generated by each node, generate the i-th random number ciphertext information, and reach consensus on the i-th random number ciphertext information, and store the i-th random number ciphertext information after the consensus is successful. It is important that the first layer of consensus occurs before the consensus on the i-th block.
[0134] The second-layer consensus is equivalent to consensus on the i-th block, which occurs when consensus on the i-th block is reached. Specifically, the consensus node for the i-th block is determined based on the i-th random number ciphertext information determined by the first-layer consensus, and then the determined consensus node reaches consensus on the i-th block, thereby reducing the time to determine the consensus node, improving the efficiency of determining the consensus node, and improving the block generation efficiency of the blockchain system.
[0135] Based on the same technical concept, Figure 6 The structure diagram of a block consensus device provided by an embodiment of the present invention is exemplarily shown, and the process that the device can execute.
[0136] like Figure 6 As shown, the device specifically includes:
[0137] The acquisition module 610 is used to acquire the i-th random number ciphertext information corresponding to the i-th block when consensus is reached on the i-th block; the i-th random number ciphertext information is obtained based on consensus on the i-th random number ciphertext of each node before consensus is reached on the i-th block;
[0138] The processing module 620 is used to decrypt each i-th random number ciphertext in the i-th random number ciphertext information based on the i-th decryption public key broadcasted by each node to obtain each i-th random number plaintext; wherein each i-th decryption public key is broadcasted by each node after the i-1th block is on the chain;
[0139] Based on the i-th random number plaintexts, a consensus node for consensus on the i-th block is determined, so that consensus on the i-th block is achieved based on the consensus node.
[0140] Optionally, the processing module 620 is specifically used for:
[0141] Before reaching consensus on the i-th block, based on the i-th random number ciphertext broadcast by each other node and its own i-th random number ciphertext, generate the i-th random number ciphertext information;
[0142] Determine a first hash value of the i-th random number ciphertext information, and broadcast the first hash value in the blockchain system;
[0143] The control acquisition module 610 acquires the second hash value broadcasted by other nodes, and determines that the consensus of the i-th random number ciphertext information is successful when it is determined that the number of second hash values consistent with the first hash value meets the consensus threshold; the second hash value is determined by the other nodes according to their own i-th random number ciphertext information;
[0144] The i-th random number ciphertext information that successfully reaches consensus is stored on the chain.
[0145] Optionally, the processing module 620 is specifically used for:
[0146] Before reaching consensus on the i-th block, generate the i-th random number plaintext, the i-th encryption private key and the i-th decryption public key of the i-th block based on the block height of the i-th block;
[0147] The i-th random number plaintext is encrypted according to the i-th encryption private key to determine the i-th random number ciphertext.
[0148] Optionally, the processing module 620 is specifically used for:
[0149] Determine the number of the consensus nodes according to the number of nodes in the blockchain system and a preset number rule;
[0150] Sorting the i-th random number plaintexts according to a preset sorting rule;
[0151] According to the number of the consensus nodes, the consensus nodes are determined in each i-th random number plaintext after sorting according to the preset selection rules.
[0152] Optionally, the processing module 620 is specifically used for:
[0153] Determine the number of consensus nodes according to the following formula (1);
[0154] M = log22N+1 (1);
[0155] Wherein, M is the number of the consensus nodes; N is the number of each node in the blockchain system.
[0156] Optionally, the processing module 620 is specifically used for:
[0157] Determine an integer quotient L of N / M according to the number M of the consensus nodes and the number N of each node;
[0158] Among the sorted i-th random number plaintexts, each node corresponding to the i-th random number plaintext located at the L+1th to the L+Mth positions is selected as the consensus node.
[0159] Optionally, the processing module 620 is specifically used for:
[0160] A consensus is reached on the i-th block according to the PBFT consensus mechanism.
[0161] Based on the same technical concept, an embodiment of the present invention further provides a computer device, including:
[0162] A memory for storing program instructions;
[0163] The processor is used to call the program instructions stored in the memory and execute the above block consensus method according to the obtained program.
[0164] Based on the same technical concept, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned block consensus method.
[0165] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0166] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 produce 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.
[0167] 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.
[0168] 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 The steps for the functions specified in one or more boxes.
[0169] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A block consensus method, characterized in that: include: When a node reaches consensus on the i-th block, it obtains the i-th random number ciphertext information corresponding to the i-th block; The i-th random number ciphertext information is obtained based on consensus on the i-th random number ciphertext of each node before consensus on the i-th block; The node decrypts each i-th random number ciphertext in the i-th random number ciphertext information based on the i-th decryption public key broadcasted by each node to obtain each i-th random number plaintext; wherein each i-th decryption public key is broadcasted by each node after the i-1th block is on the chain; The node determines a consensus node for consensus on the i-th block based on each i-th random number plaintext, thereby achieving consensus on the i-th block based on the consensus node; The i-th random number ciphertext information is obtained based on consensus on the i-th random number ciphertext of each node before consensus on the i-th block, and includes: Before reaching consensus on the i-th block, the node generates the i-th random number ciphertext information based on the i-th random number ciphertext broadcast by other nodes and its own i-th random number ciphertext; The node determines a first hash value of the i-th random number ciphertext information, and broadcasts the first hash value in the blockchain system; The node obtains the second hash value broadcasted by other nodes, and determines that the consensus of the i-th random number ciphertext information is successful when it is determined that the number of second hash values consistent with the first hash value meets the consensus threshold; the second hash value is determined by the other nodes according to their own i-th random number ciphertext information; The node stores the i-th random number ciphertext information that successfully reaches consensus on the chain.
2. The method according to claim 1, characterized in that The i-th random number ciphertext is obtained by the following method, including: Before reaching consensus on the i-th block, the node generates the i-th random number plaintext, the i-th encryption private key and the i-th decryption public key of the i-th block based on the block height of the i-th block; The node encrypts the i-th random number plaintext according to the i-th encryption private key to determine the i-th random number ciphertext.
3. The method according to claim 1, characterized in that The node determines a consensus node for consensus on the i-th block based on each i-th random number plaintext, including: The node determines the number of the consensus nodes according to the number of each node in the blockchain system and a preset number rule; The node sorts the i-th random number plaintexts according to a preset sorting rule; The node determines the consensus node in each i-th random number plaintext after sorting according to the number of the consensus nodes and a preset selection rule.
4. The method according to claim 3, characterized in that Determine the number of consensus nodes according to the following formula (1); M = log22N+1 (1); Wherein, M is the number of the consensus nodes; N is the number of each node in the blockchain system.
5. The method according to claim 4, characterized in that The node determines the consensus node in each i-th random number plaintext after sorting according to the number of the consensus nodes and the preset selection rule, including: The node determines an integer quotient L of N / M according to the number M of the consensus nodes and the number N of each node; The node selects each node corresponding to the i-th random number plaintext located at the L+1th to the L+Mth position from the sorted i-th random number plaintext as the consensus node.
6. The method according to claim 1, characterized in that Achieving consensus on the i-th block based on the consensus node includes: The consensus nodes reach a consensus on the i-th block according to the PBFT consensus mechanism.
7. A block consensus device, characterized in that: include: An acquisition module, used for acquiring the i-th random number ciphertext information corresponding to the i-th block when consensus is reached on the i-th block; The i-th random number ciphertext information is obtained based on consensus on the i-th random number ciphertext of each node before consensus on the i-th block; A processing module, configured to decrypt each i-th random number ciphertext in the i-th random number ciphertext information based on the i-th decryption public key broadcasted by each node, to obtain each i-th random number plaintext; wherein each i-th decryption public key is broadcasted by each node after the i-1th block is put on the chain; Based on the i-th random number plaintexts, a consensus node for consensus on the i-th block is determined, so as to achieve consensus on the i-th block based on the consensus node; The processing module is specifically used to generate an i-th random number ciphertext information based on the i-th random number ciphertext broadcasted by each other node and its own i-th random number ciphertext before consensus on the i-th block; determine a first hash value of the i-th random number ciphertext information, and broadcast the first hash value in the blockchain system; control the acquisition module to obtain the second hash value broadcasted by other nodes, and determine that the i-th random number ciphertext information consensus is successful when it is determined that the number of second hash values consistent with the first hash value meets the consensus threshold; the second hash value is determined by the other nodes according to their own i-th random number ciphertext information; and store the i-th random number ciphertext information with successful consensus on the chain.
8. A computer device, characterized in that: include: A memory for storing program instructions; A processor, configured to call the program instructions stored in the memory, and execute the method according to any one of claims 1 to 6 according to the obtained program.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Consensus system and method of block chain
CN112734576A