Blockchain consensus node dynamic updating method and system based on verifiable random number

By using a dynamic update method based on verifiable random numbers to dynamically select consensus nodes, the unfairness and security threats of fixed consensus nodes in blockchain systems are resolved, and the stable operation of a large number of nodes is achieved.

CN116436928BActive Publication Date: 2026-07-31LINGSHU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
LINGSHU TECH CO LTD
Filing Date
2023-04-14
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

The fixed consensus nodes in existing blockchain systems suffer from unfairness, security threats, and malicious behavior, which are particularly difficult to resolve effectively in large-scale node scenarios.

Method used

A dynamic update method based on verifiable random numbers is adopted. By dividing dynasties, generating and verifying random numbers and proof data, and using smart contracts to verify the legitimacy of consensus nodes, unpredictable and uncontrollable consensus nodes are dynamically selected.

Benefits of technology

It achieves fairness and security for consensus nodes in the blockchain system, avoids performance regression caused by DDoS attacks and Byzantine nodes, and supports the stable operation of large-scale nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116436928B_ABST
    Figure CN116436928B_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for dynamically updating blockchain consensus nodes based on verifiable random numbers. The method includes: dividing all blocks into multiple groups, each group corresponding to a dynasty; determining the consensus nodes for the current dynasty based on the distributed random number of the current dynasty and consensus node determination rules; wherein the distributed random number for the first dynasty is configured by the system; generating unverified random numbers and proof data for all consensus nodes of the current dynasty; submitting these to a smart contract; verifying and retaining the unverified random numbers corresponding to each consensus node of the current dynasty through smart contract verification conditions; calculating the distributed random number for the next dynasty based on the verified unverified random number of the current dynasty; and determining the consensus nodes for the next dynasty based on the distributed random number of the next dynasty and consensus node determination rules. This method can dynamically select consensus nodes and ensures that the selection process is uncontrollable and the selection result is unpredictable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain technology, and more specifically, to a method and system for dynamically updating blockchain consensus nodes based on verifiable random numbers. Background Technology

[0002] Blockchain is built on a network of interconnected computer nodes, abstracting a distributed public ledger for upper-layer decentralized applications. Applications can be simple decentralized payments, storing payment records on the ledger; or more general decentralized computing, storing computation commands on the ledger. From the perspective of decentralized applications, there is only one public ledger, although in reality this ledger is replicated across different nodes. If the nodes are error-free and the network is reliable, implementing a public ledger is easy, but such conditions are overly idealistic and lack practical significance. In reality, nodes can crash, act maliciously, or collude; the network can experience packet loss, disconnections, and latency fluctuations, making maintaining the public ledger extremely challenging.

[0003] As the core module of blockchain, consensus algorithms are mainly responsible for maintaining the consistency of the public ledger under the above-mentioned abnormal situations. Common consensus algorithms mainly include: (1) Nakamoto-type consensus algorithms, which are suitable for open systems that do not require node admission control. The number of nodes can reach the scale of the Internet, but their throughput is low, latency is high, and the maintenance cost of ledger consistency is high. For example, PoW consensus wastes a lot of electricity; (2) BFT consensus algorithms, which have high throughput, low latency, and lower maintenance cost of ledger consistency, making them more suitable for consortium blockchain systems.

[0004] The Blockchain-Focused Strike-Flight (BFT) consensus algorithm has been widely studied since the 1970s, and research on it has flourished since the rise of blockchain. However, to this day, BFT consensus still supports a relatively small number of nodes, with most supporting only a few dozen. The fundamental reason for this is its communication complexity. Even though recent research has reduced the communication complexity to linear, at least one node is still required to send and receive messages from all other nodes and perform signature verification. This makes the system unsuitable for scenarios requiring a large number of blockchain nodes.

[0005] To enable blockchain systems to support a larger number of nodes, a common approach is to allow only a subset of nodes to participate in consensus and maintain the ledger, while other nodes synchronize the ledger. This method cleverly bypasses the limitation on the number of nodes imposed by the communication complexity of the BFT algorithm based on a special mechanism, but it does not fundamentally solve the problem. In addition, this "fixed consensus node" mechanism still has the following drawbacks in actual production environments: (1) It is centralized, which is unfair to other nodes; (2) Consensus nodes may be subject to security threats, such as DDoS attacks; (3) Consensus nodes may engage in malicious behavior, such as deliberately delaying and reducing system throughput.

[0006] There is currently no effective solution to the above problems. Summary of the Invention

[0007] This invention provides a method for dynamically updating blockchain consensus nodes based on verifiable random numbers, in order to address the issues of unfairness, potential security threats, and malicious behavior associated with fixed consensus nodes in existing technologies.

[0008] To achieve the above objectives, on the one hand, the present invention provides a method for dynamically updating blockchain consensus nodes based on verifiable random numbers. The method includes: S1, dividing all blocks into multiple groups, each group corresponding to a dynasty; determining the consensus nodes of the current dynasty based on the distributed random number of the current dynasty and the consensus node determination rules; wherein the distributed random number of the first dynasty is configured by the system; S2, generating unverified random numbers corresponding to each consensus node for all consensus nodes of the current dynasty based on a verifiable random number hash calculation method; generating proof data corresponding to each consensus node for all consensus nodes of the current dynasty based on a verifiable random number proof calculation method; and submitting the unverified random numbers and proof data to a smart contract; S3, verifying the validity of the unverified random numbers corresponding to each consensus node of the current dynasty through smart contract verification conditions; if valid, retaining the verified unverified random numbers; otherwise, removing the unverified unverified random numbers; S4, calculating the distributed random number of the next dynasty based on the verified unverified random numbers of the current dynasty; and determining the consensus nodes of the next dynasty based on the distributed random number of the next dynasty and the consensus node determination rules.

[0009] Optionally, the consensus node determination rule is determined as follows: the index of all nodes is compared with SHA256(R... i )%n、SHA256(SHA256(R i ))%n、SHA256(SHA256(SHA256(R i )))%n……A consistent node is identified and used as a consensus node, until t consensus nodes are found;

[0010] Where n is the total number of nodes, R i t represents the distributed random number for the current dynasty, SHA256 is the cryptographic hash function, and t is the preset number of consensus nodes.

[0011] Optionally, the random number to be verified corresponding to each consensus node is calculated according to the following formula:

[0012] r_j = VRF.Hash(epoch_i, sk_j)

[0013] Where r_j is the random number to be verified corresponding to the j-th consensus node; j = 0, 1, ..., t-1; t is the total number of consensus nodes; VRF.Hash is the hash function for verifiable random numbers; epoch_i is the given message of the current dynasty; and sk_j is the private key of the j-th consensus node.

[0014] Optionally, the proof data corresponding to each consensus node is calculated according to the following formula:

[0015] proof_j=VRF.Proof(epoch_i,sk_j)

[0016] Where proof_j is the proof data corresponding to the j-th consensus node; j = 0, 1, ..., t-1; t is the total number of consensus nodes; VRF.Proof is the verifiable random number proof function; epoch_i is the given message of the current dynasty; and sk_j is the private key of the j-th consensus node.

[0017] Optionally, the smart contract verification conditions include:

[0018] Check if VRF.P2H(proof_j) = r_j is satisfied;

[0019] Verify whether VRF.Verify(pk_j, epoch_i, proof_j) = True;

[0020] Wherein, VRF.P2H is the verifiable random number proof-to-hash function, proof_j is the proof data corresponding to the j-th consensus node; r_j is the random number to be verified corresponding to the j-th consensus node; j = 0, 1, ..., t-1; t is the total number of consensus nodes; VRF.Verify is the verification function for the random number, pk_j is the public key of the j-th consensus node, j = 0, 1, ..., t-1; t is the total number of consensus nodes; epoch_i is the given message of the current dynasty, True means correct.

[0021] Optionally, the distributed random number for the next dynasty is calculated according to the following formula:

[0022] R i+1=SHA256(r_0||r_1||…||r_())

[0023] Among them, R i+1 is the distributed random number for the next dynasty, SHA256 is the cryptographic hash function, r_0 is the random number to be verified corresponding to the 0th consensus node that has passed the verification, r_1 is the random number to be verified corresponding to the 1st consensus node that has passed the verification, r_l is the random number to be verified corresponding to the lth consensus node that has passed the verification, and l+1 is the number of random numbers to be verified that have passed the verification for the current dynasty.

[0024] On the other hand, this invention provides a blockchain consensus node dynamic update system based on verifiable random numbers. The system includes: a consensus node determination unit for the current dynasty, used to divide all blocks into multiple groups, each group corresponding to a dynasty; determining the consensus node for the current dynasty based on the distributed random number of the current dynasty and consensus node determination rules; wherein the distributed random number of the first dynasty is configured by the system; and a generation unit, used to generate unverified random numbers corresponding to each consensus node for all consensus nodes of the current dynasty based on a verifiable random number hash calculation method; and to update the consensus nodes of the current dynasty based on the verifiable random number hash calculation method. The method generates proof data corresponding to each consensus node and submits the random number to be verified and the proof data to a smart contract. A verification unit checks the validity of the random number to be verified corresponding to each consensus node in the current dynasty using the smart contract verification conditions. If valid, the verified random number is retained; otherwise, the invalid random number is removed. A consensus node determination unit for the next dynasty calculates the distributed random number for the next dynasty based on the verified random number for the current dynasty and determines the consensus node for the next dynasty based on the distributed random number and the consensus node determination rules.

[0025] Optionally, the consensus node determination rule is determined as follows:

[0026] Mix the indices of all nodes with SHA256(R) i )%n、SHA256(SHA256(R i ))%n、SHA256(SHA256(SHA256(R i )))%n……A consistent node is identified and used as a consensus node, until t consensus nodes are found;

[0027] Where n is the total number of nodes, R i t represents the distributed random number for the current dynasty, SHA256 is the cryptographic hash function, and t is the preset number of consensus nodes.

[0028] Optionally, the smart contract verification conditions include:

[0029] Check if VRF.P2H(proof_j) = r_j is satisfied;

[0030] Verify whether VRF.Verify(pk_j, epoch_i, proof_j) = True;

[0031] Wherein, VRF.P2H is the verifiable random number proof-to-hash function, proof_j is the proof data corresponding to the j-th consensus node; r_j is the random number to be verified corresponding to the j-th consensus node; j = 0, 1, ..., t-1; t is the total number of consensus nodes; VRF.Verify is the verification function for the random number, pk_j is the public key of the j-th consensus node, j = 0, 1, ..., t-1; t is the total number of consensus nodes; epoch_i is the given message of the current dynasty, True means correct.

[0032] Optionally, the distributed random number for the next dynasty is calculated according to the following formula:

[0033] R i+1 =SHA256(r_0||r_1||…||r_l)

[0034] Among them, R i+1 is the distributed random number for the next dynasty, SHA256 is the cryptographic hash function, r_0 is the random number to be verified corresponding to the 0th consensus node that has passed the verification, r_1 is the random number to be verified corresponding to the 1st consensus node that has passed the verification, r_l is the random number to be verified corresponding to the lth consensus node that has passed the verification, and l+1 is the number of random numbers to be verified that have passed the verification for the current dynasty.

[0035] The beneficial effects of this invention are:

[0036] This invention provides a method and system for dynamically updating blockchain consensus nodes based on verifiable random numbers. This method and system can dynamically select consensus nodes and ensure that the selection process is uncontrollable and the selection result is unpredictable. It solves the problems of centralization, DDoS attacks, and performance regression caused by Byzantine nodes in the "fixed consensus node" mechanism of blockchain systems, making large-scale blockchain nodes run more stably in production environments. Attached Figure Description

[0037] Figure 1 This is a flowchart of a method for dynamically updating blockchain consensus nodes based on verifiable random numbers, provided by an embodiment of the present invention.

[0038] Figure 2 This is a schematic diagram of the structure of a blockchain consensus node dynamic update system based on verifiable random numbers, provided by an embodiment of the present invention. Detailed Implementation

[0039] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0040] To enable blockchain systems to support a larger number of nodes, a common approach is to allow only a subset of nodes to participate in consensus and maintain the ledger, while other nodes synchronize the ledger. This method cleverly bypasses the limitation on the number of nodes imposed by the communication complexity of the BFT algorithm based on a special mechanism, but it does not fundamentally solve the problem. In addition, this "fixed consensus node" mechanism still has the following drawbacks in actual production environments: (1) It is centralized, which is unfair to other nodes; (2) Consensus nodes may be subject to security threats, such as DDoS attacks; (3) Consensus nodes may engage in malicious behavior, such as deliberately delaying and reducing system throughput.

[0041] Therefore, to solve the above problems, the applicant of this invention has discovered through research that consensus nodes can be dynamically selected and the selection process can be made uncontrollable and the selection results unpredictable. This effectively solves the problems of centralization, DDoS attacks, and performance regression caused by Byzantine nodes in the "fixed consensus node" mechanism of the blockchain system, making the operation of large-scale blockchain nodes in the production environment more stable.

[0042] This invention provides a method for dynamically updating blockchain consensus nodes based on verifiable random numbers. This method makes the distributed random numbers used to determine consensus nodes fair, unpredictable, and uncontrollable. Figure 1 This is a flowchart of a method for dynamically updating blockchain consensus nodes based on verifiable random numbers, provided by an embodiment of the present invention. Figure 1 As shown, the method includes:

[0043] S1. Divide all blocks into multiple groups, each group corresponding to a dynasty; determine the consensus node of the current dynasty based on the distributed random number of the current dynasty and the consensus node determination rules; wherein, the distributed random number of the first dynasty is configured by the system.

[0044] Specifically, all blocks are arranged in chronological order and divided into multiple groups according to a preset threshold, with each group corresponding to a dynasty. Assuming there are 1,000 blocks and 200 blocks per dynasty, then blocks 1-200 are the first dynasty, 201-400 are the second dynasty, 401-600 are the third dynasty, 601-800 are the fourth dynasty, and 801-1000 are the fifth dynasty.

[0045] Assuming there are a total of 1000 nodes, 100 consensus nodes need to be selected; the distributed random number for the first dynasty is configured by the system and is R0. The consensus nodes for the first dynasty are determined based on the distributed random number R0 for the first dynasty and the consensus node determination rules.

[0046] The consensus node determination rule is as follows:

[0047] Mix the indices of all nodes with SHA256(R) i )%n、SHA256(SHA256(R i ))%n、SHA256(SHA256(SHA256(R i )))%n……A consistent node is identified and used as a consensus node, until t consensus nodes are found;

[0048] Where n is the total number of nodes, R i t represents the distributed random number for the current dynasty, SHA256 is the cryptographic hash function, and t is the preset number of consensus nodes.

[0049] Specifically, the indices of the 1000 nodes are [0,1,2,…,999]. In the first dynasty, the first consensus node is the node whose index matches (is equal to) SHA256(R0)%1000, the second consensus node is the node whose index matches SHA256(SHA256(R0))%1000, the third consensus node is the node whose index matches SHA256(SHA256(SHA256(R0)))%1000, and so on, until 100 consensus nodes are determined.

[0050] S2. Generate a random number to be verified for each consensus node of the current dynasty based on a verifiable random number hash calculation method; generate proof data for each consensus node based on a verifiable random number proof calculation method; and submit the random number to be verified and the proof data to the smart contract.

[0051] Specifically, if the current dynasty is the first dynasty, the 100 consensus nodes of the first dynasty will each generate a corresponding unverified random number based on a verifiable random number hash calculation method. The specific formula is as follows:

[0052] r_j = VRF.Hash(epoch_i, sk_j)

[0053] Where r_j is the random number to be verified corresponding to the j-th consensus node; j = 0, 1, ..., t-1 (specifically, t is 100 in the above example); t is the total number of consensus nodes; VRF.Hash is the hash function for verifiable random numbers; epoch_i is the given message of the current dynasty (specifically, epoch_0 is the given message of the first dynasty); and sk_j is the private key of the j-th consensus node (each node generates a pair of public and private keys).

[0054] The 100 consensus nodes of the first dynasty each generate proof data corresponding to their respective consensus nodes based on a verifiable random number proof calculation method. The specific formula is as follows:

[0055] proof_j=VRF.Proof(epoch_i,sk_j)

[0056] Where, proof_j is the proof data corresponding to the j-th consensus node; j = 0, 1, ..., t-1 (specifically, t is 100 in the above example); t is the total number of consensus nodes; VRF.Proof is the verifiable random number proof function; epoch_i is the given message of the current dynasty (specifically, epoch_0 is the given message of the first dynasty); and sk_j is the private key of the j-th consensus node.

[0057] In this invention, epoch_0 is the given message of the first dynasty, epoch_1 is the given message of the second dynasty, epoch_2 is the given message of the third dynasty, epoch_3 is the given message of the fourth dynasty, and epoch_4 is the given message of the fifth dynasty.

[0058] All generated random numbers to be verified and proof data are submitted to the smart contract.

[0059] S3. Verify the validity of the random numbers to be verified corresponding to each consensus node of the current dynasty through the smart contract verification condition check. If they are valid, retain the random numbers to be verified that have passed the verification; otherwise, remove the random numbers to be verified that have not passed the verification.

[0060] Specifically, the smart contract verification conditions include:

[0061] Check if VRF.P2H(proof_j) = r_j is satisfied;

[0062] Verify whether VRF.Verify(pk_j, epoch_i, proof_j) = True;

[0063] Wherein, VRF.P2H is the verifiable random number proof-to-hash function, proof_j is the proof data corresponding to the j-th consensus node; r_j is the random number to be verified corresponding to the j-th consensus node; j = 0, 1, ..., t-1 (specifically, in the above example, t is 100); t is the total number of consensus nodes; VRF.Verify is the verification random number verification function, pk_j is the public key of the j-th consensus node, j = 0, 1, ..., t-1; t is the total number of consensus nodes; epoch_i is the given message of the current dynasty, True means correct.

[0064] In this invention, VRF.P2H is the verification of VRF hash by VRF proof, and VRF.Verify is the verification of VRF proof by public key. That is, the public key is used to verify whether the proof data is a proof generated based on a given message. If it is, it is considered valid and the verification passes; otherwise, the verification fails.

[0065] Retain the random numbers that pass the verification. Assume that the first dynasty retained l+1 random numbers to be verified.

[0066] S4. Calculate the distributed random number of the next dynasty based on the verified random number of the current dynasty; determine the consensus node of the next dynasty based on the distributed random number of the next dynasty and the consensus node determination rules.

[0067] Specifically, the distributed random number for the second dynasty is calculated based on the l+1 random numbers to be verified in the first dynasty. The calculation formula is as follows:

[0068] R i+1 =SHA256(r_0||r_1||…||r_l)

[0069] Among them, R i+1 For the next dynasty (specifically the second dynasty), SHA256 is the cryptographic hash function, r_0 is the random number to be verified corresponding to the 0th consensus node that has passed the verification, r_1 is the random number to be verified corresponding to the 1st consensus node that has passed the verification, r_l is the random number to be verified corresponding to the 1st consensus node that has passed the verification, and l+1 is the number of random numbers to be verified that have passed the verification in the current dynasty (the first dynasty).

[0070] The consensus nodes for the second dynasty are determined based on the distributed random number (R1) and consensus node determination rules of the second dynasty.

[0071] Specifically, the indices of the 1000 nodes are [0,1,2,…,999]. In the second generation, the first consensus node is the node whose index matches (is equal to) SHA256(R1)%1000, the second consensus node is the node whose index matches SHA256(SHA256(R1))%1000, the third consensus node is the node whose index matches SHA256(SHA256(SHA256(R1)))%1000, and so on, until 100 consensus nodes are determined.

[0072] Repeating operations S2-S4, we can obtain the distributed random number of the third dynasty based on the 100 consensus nodes of the second dynasty, and then obtain the 100 consensus nodes of the third dynasty; based on the 100 consensus nodes of the third dynasty, we can obtain the distributed random number of the fourth dynasty, and then obtain the 100 consensus nodes of the fourth dynasty; based on the 100 consensus nodes of the fourth dynasty, we can obtain the distributed random number of the fifth dynasty, and then obtain the 100 consensus nodes of the fifth dynasty.

[0073] Figure 2 This is a schematic diagram of the structure of a blockchain consensus node dynamic update system based on verifiable random numbers provided in an embodiment of the present invention, as shown below. Figure 2 As shown, the system includes:

[0074] The current dynasty consensus node determination unit 201 is used to divide all blocks into multiple groups, each group corresponding to a dynasty; the consensus node of the current dynasty is determined according to the distributed random number of the current dynasty and the consensus node determination rules; wherein, the distributed random number of the first dynasty is configured by the system.

[0075] Specifically, all blocks are arranged in chronological order and divided into multiple groups according to a preset threshold, with each group corresponding to a dynasty. Assuming there are 1,000 blocks and 200 blocks per dynasty, then blocks 1-200 are the first dynasty, 201-400 are the second dynasty, 401-600 are the third dynasty, 601-800 are the fourth dynasty, and 801-1000 are the fifth dynasty.

[0076] Assuming there are a total of 1000 nodes, 100 consensus nodes need to be selected; the distributed random number for the first dynasty is configured by the system and is R0. The consensus nodes for the first dynasty are determined based on the distributed random number R0 for the first dynasty and the consensus node determination rules.

[0077] The consensus node determination rule is as follows:

[0078] Mix the indices of all nodes with SHA256(R) i )%n、SHA256(SHA256(R i))%n、SHA256(SHA256(SHA256(R i )))%n……A consistent node is identified and used as a consensus node, until t consensus nodes are found;

[0079] Where n is the total number of nodes, R i t represents the distributed random number for the current dynasty, SHA256 is the cryptographic hash function, and t is the preset number of consensus nodes.

[0080] Specifically, the indices of the 1000 nodes are [0,1,2,…,999]. In the first dynasty, the first consensus node is the node whose index matches (is equal to) SHA256(R0)%1000, the second consensus node is the node whose index matches SHA256(SHA256(R0))%1000, the third consensus node is the node whose index matches SHA256(SHA256(SHA256(R0)))%1000, and so on, until 100 consensus nodes are determined.

[0081] The generation unit 202 is used to generate unverified random numbers corresponding to each consensus node for all consensus nodes of the current dynasty based on the verifiable random number hash calculation method; generate proof data corresponding to each consensus node for all consensus nodes of the current dynasty based on the verifiable random number proof calculation method; and submit the unverified random numbers and proof data to the smart contract.

[0082] Specifically, if the current dynasty is the first dynasty, the 100 consensus nodes of the first dynasty will each generate a corresponding unverified random number based on a verifiable random number hash calculation method. The specific formula is as follows:

[0083] r_j = VRF.Hash(epoch_i, sk_j)

[0084] Where r_j is the random number to be verified corresponding to the j-th consensus node; j = 0, 1, ..., t-1 (specifically, t is 100 in the above example); t is the total number of consensus nodes; VRF.Hash is the hash function for verifiable random numbers; epoch_i is the given message of the current dynasty (specifically, epoch_0 is the given message of the first dynasty); and sk_j is the private key of the j-th consensus node (each node generates a pair of public and private keys).

[0085] The 100 consensus nodes of the first dynasty each generate proof data corresponding to their respective consensus nodes based on a verifiable random number proof calculation method. The specific formula is as follows:

[0086] proof_j=VRF.Proof(epoch_i,sk_j)

[0087] Where, proof_j is the proof data corresponding to the j-th consensus node; j = 0, 1, ..., t-1 (specifically, t is 100 in the above example); t is the total number of consensus nodes; VRF.Proof is the verifiable random number proof function; epoch_i is the given message of the current dynasty (specifically, epoch_0 is the given message of the first dynasty); and sk_j is the private key of the j-th consensus node.

[0088] In this invention, epoch_0 is the given message of the first dynasty, epoch_1 is the given message of the second dynasty, epoch_2 is the given message of the third dynasty, epoch_3 is the given message of the fourth dynasty, and epoch_4 is the given message of the fifth dynasty.

[0089] All generated random numbers to be verified and proof data are submitted to the smart contract.

[0090] Verification unit 203 is used to determine whether the random numbers to be verified corresponding to each consensus node of the current dynasty are valid through smart contract verification conditions. If they are valid, the random numbers to be verified that have passed the verification are retained; otherwise, the random numbers to be verified that have failed the verification are removed.

[0091] Specifically, the smart contract verification conditions include:

[0092] Check if VRF.P2H(proof_j) = r_j is satisfied;

[0093] Verify whether VRF.Verify(pk_j, epoch_i, proof_j) = True;

[0094] Wherein, VRF.P2H is the verifiable random number proof-to-hash function, proof_j is the proof data corresponding to the j-th consensus node; r_j is the random number to be verified corresponding to the j-th consensus node; j = 0, 1, ..., t-1 (specifically, in the above example, t is 100); t is the total number of consensus nodes; VRF.Verify is the verification random number verification function, pk_j is the public key of the j-th consensus node, j = 0, 1, ..., t-1; t is the total number of consensus nodes; epoch_i is the given message of the current dynasty, True means correct.

[0095] In this invention, VRF.P2H is the verification of VRF hash by VRF proof, and VRF.Verify is the verification of VRF proof by public key. That is, the public key is used to verify whether the proof data is a proof generated based on a given message. If it is, it is considered valid and the verification passes; otherwise, the verification fails.

[0096] Retain the random numbers that pass the verification. Assume that the first dynasty retained l+1 random numbers to be verified.

[0097] The next dynasty consensus node determination unit 204 is used to calculate the distributed random number of the next dynasty based on the unverified random number of the current dynasty; and to determine the consensus node of the next dynasty based on the distributed random number of the next dynasty and the consensus node determination rules.

[0098] Specifically, the distributed random number for the second dynasty is calculated based on the l+1 random numbers to be verified in the first dynasty. The calculation formula is as follows:

[0099] R i+1 =SHA256(r_0||r_1||…||r_l)

[0100] Among them, R i+1 For the next dynasty (specifically the second dynasty), SHA256 is the cryptographic hash function, r_0 is the random number to be verified corresponding to the 0th consensus node that has passed the verification, r_1 is the random number to be verified corresponding to the 1st consensus node that has passed the verification, r_l is the random number to be verified corresponding to the 1st consensus node that has passed the verification, and l+1 is the number of random numbers to be verified that have passed the verification in the current dynasty (the first dynasty).

[0101] The consensus nodes for the second dynasty are determined based on the distributed random number (R1) and consensus node determination rules of the second dynasty.

[0102] Specifically, the indices of the 1000 nodes are [0,1,2,…,999]. In the second generation, the first consensus node is the node whose index matches (is equal to) SHA256(R1)%1000, the second consensus node is the node whose index matches SHA256(SHA256(R1))%1000, the third consensus node is the node whose index matches SHA256(SHA256(SHA256(R1)))%1000, and so on, until 100 consensus nodes are determined.

[0103] By repeating the above operations, the distributed random number of the third dynasty can be obtained from the 100 consensus nodes of the second dynasty, and then the 100 consensus nodes of the third dynasty can be obtained; the distributed random number of the fourth dynasty can be obtained from the 100 consensus nodes of the third dynasty, and then the 100 consensus nodes of the fourth dynasty can be obtained; the distributed random number of the fifth dynasty can be obtained from the 100 consensus nodes of the fourth dynasty, and then the 100 consensus nodes of the fifth dynasty can be obtained.

[0104] The beneficial effects of this invention are:

[0105] This invention provides a method and system for dynamically updating blockchain consensus nodes based on verifiable random numbers. This method and system can dynamically select consensus nodes and ensure that the selection process is uncontrollable and the selection result is unpredictable. It solves the problems of centralization, DDoS attacks, and performance regression caused by Byzantine nodes in the "fixed consensus node" mechanism of blockchain systems, making large-scale blockchain nodes run more stably in production environments.

[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for dynamic updating of blockchain consensus nodes based on verifiable random numbers, characterized in that, include: S1. Divide all blocks into multiple groups, each group corresponding to a dynasty; determine the consensus node of the current dynasty based on the distributed random number of the current dynasty and the consensus node determination rules; wherein, the distributed random number of the first dynasty is configured by the system. The consensus node determination rule is as follows: Mix the index of all nodes with SHA256 ( )%n、SHA256(SHA256( ))%n, SHA256 (SHA256 (SHA256 ( )))%n……Identify and use consistent nodes as consensus nodes, until t consensus nodes are found; Wherein, n is the number of all nodes, is a distributed random number of the current dynasty, SHA256 is a cryptographic hash function, and t is a preset number of consensus nodes. S2. Generate a random number to be verified for each consensus node of the current dynasty based on a verifiable random number hash calculation method; generate proof data for each consensus node based on a verifiable random number proof calculation method; and submit the random number to be verified and the proof data to the smart contract. S3. Verify the validity of the random numbers to be verified corresponding to each consensus node of the current dynasty through the smart contract verification condition check. If they are valid, retain the random numbers to be verified that have passed the verification; otherwise, remove the random numbers to be verified that have not passed the verification. S4. Calculate the distributed random number for the next dynasty based on the verified random number of the current dynasty; determine the consensus node for the next dynasty based on the distributed random number of the next dynasty and the consensus node determination rules. The distributed random number for the next dynasty is calculated according to the following formula: in, Distributed random numbers for the next dynasty For cryptographic hash functions, This is the random number to be verified corresponding to the 0th consensus node that has passed the verification. The random number to be verified corresponds to the first consensus node that passes the verification. For the first one that passed the verification The number of random numbers to be verified corresponding to each consensus node. This represents the number of random numbers to be verified for the current dynasty.

2. The method according to claim 1, characterized in that, The random number to be verified for each consensus node is calculated according to the following formula: in, Let be the random number to be verified corresponding to the i-th consensus node; =0,1,…,t-1; t is the total number of consensus nodes; For verifiable random number hash functions, Given the current dynasty, For the first The private key of each consensus node.

3. The method according to claim 1, characterized in that, The proof data corresponding to each consensus node is calculated according to the following formula: in, For the first Proof data corresponding to each consensus node; =0,1,…,t-1; t is the total number of consensus nodes; For a verifiable random number proof function, Given the current dynasty, For the first The private key of each consensus node.

4. The method according to claim 1, characterized in that, The smart contract verification conditions include: Check if it meets the requirements ; Check if it meets the requirements ; in, To prove the conversion of verifiable random numbers to a hash function, For the first Proof data corresponding to each consensus node; For the first The random number to be verified corresponding to each consensus node; =0,1,…,t-1; t is the total number of consensus nodes; To verify the random number verification function, For the first The public keys of the consensus nodes, =0,1,…,t-1; t is the total number of consensus nodes; Given the current dynasty, That is correct.

5. A blockchain consensus node dynamic update system based on verifiable random numbers, characterized in that, include: The current dynasty consensus node is used to divide all blocks into multiple groups, each group corresponding to a dynasty. The consensus node for the current dynasty is determined based on the distributed random number and consensus node determination rules of the current dynasty; among them, the distributed random number for the first dynasty is configured by the system. The consensus node determination rule is as follows: Mix the index of all nodes with SHA256 ( )%n、SHA256(SHA256( ))%n, SHA256 (SHA256 (SHA256 ( )))%n……Identify and use consistent nodes as consensus nodes, until t consensus nodes are found; Where n is the total number of nodes. t represents the distributed random number for the current dynasty, SHA256 is the cryptographic hash function, and t is the preset number of consensus nodes; The generation unit is used to generate unverified random numbers corresponding to each consensus node of the current dynasty based on a verifiable random number hash calculation method; generate proof data corresponding to each consensus node based on a verifiable random number proof calculation method; and submit the unverified random numbers and proof data to the smart contract. The verification unit is used to determine whether the random numbers to be verified corresponding to each consensus node of the current dynasty are valid through the verification conditions of the smart contract. If they are valid, the random numbers to be verified that have passed the verification are retained; otherwise, the random numbers to be verified that have failed the verification are removed. The next dynasty consensus node determination unit is used to calculate the distributed random number of the next dynasty based on the unverified random number of the current dynasty; and to determine the consensus node of the next dynasty based on the distributed random number of the next dynasty and the consensus node determination rules. The distributed random number for the next dynasty is calculated according to the following formula: in, Distributed random numbers for the next dynasty For cryptographic hash functions, This is the random number to be verified corresponding to the 0th consensus node that has passed the verification. The random number to be verified corresponds to the first consensus node that passes the verification. For the first one that passed the verification The number of random numbers to be verified corresponding to each consensus node. This represents the number of random numbers to be verified for the current dynasty.

6. The system according to claim 5, characterized in that, The smart contract verification conditions include: Check if it meets the requirements ; Check if it meets the requirements ; in, To prove the conversion of verifiable random numbers to a hash function, For the first Proof data corresponding to each consensus node; For the first The random number to be verified corresponding to each consensus node; =0,1,…,t-1; t is the total number of consensus nodes; To verify the random number verification function, For the first The public keys of the consensus nodes, =0,1,…,t-1; t is the total number of consensus nodes; Given the current dynasty, That is correct.