Blockchain voting method, device, terminal equipment and storage medium
By building the weight value of the consensus node in the blockchain network and the number of random selection of sub -users, the selection of consensus nodes to select the lack of randomness and weight assumptions of the same weight assumptions, and achieve a fair and safe consensus process.
Patent Information
- Application Number
- CN202211482459.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-24
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2042-11-24
AI Technical Summary
In the blockchain network, the selection of consensus nodes lacks randomness, and the voting weight assumptions are the same, which cannot fairly reflect the weight value of consensus nodes.
By modeling the weight value of the consensus node as the number of sub -users, the number of users of the child randomly selected to determine the selection and voting weight of the consensus node, and verify the consensus voting message to ensure its effectiveness.
It achieves fair and random selection of consensus nodes from the blockchain network and ensures that their voting weights reflect the actual weight values, thus improving the fairness and security of the consensus process.
Smart Images

Figure CN115865366B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of blockchain technology, and in particular relates to a blockchain voting method, device, terminal equipment and computer-readable storage medium. Background Art
[0002] With the rapid development of science and technology, blockchain technology, as a distributed ledger technology, has had a profound impact on finance, smart manufacturing, supply chain, logistics and other fields, and has driven a new round of technological and application changes.
[0003] At present, in the blockchain network, consensus is reached on a batch of transactions contained in a block through a consensus algorithm. After the consensus is reached, the transactions in the block and their updates to the ledger status will be written into the distributed ledger. Therefore, the consensus algorithm is a key component of the blockchain system. The specific operation of the consensus algorithm is to transmit consensus-related information by assembling voting messages and sending them to other consensus nodes, and to drive the operation of the consensus process by collecting, processing and counting voting messages from other consensus nodes. Therefore, it is very important to select several suitable nodes from the blockchain network to participate in the operation of the consensus protocol and to regulate the voting operation of the consensus nodes. However, in common and mainstream public chains and consortium chains, the selection of consensus nodes is not sufficiently random, and it is generally assumed that the weights of consensus nodes when voting are the same.
[0004] In summary, how to fairly and randomly select the required number of consensus nodes from the participant nodes of the blockchain network to participate in the operation of the consensus algorithm, while ensuring that the voting weight of the consensus node in the specific consensus process can fairly reflect the weight value of the consensus node itself, has become a technical problem that needs to be urgently solved in the field of blockchain technology. Summary of the invention
[0005] The main purpose of the present invention is to provide a blockchain voting method, apparatus, terminal device and computer-readable storage medium, which aims to fairly and randomly select a required number of consensus nodes from the participant nodes of the blockchain network to participate in the operation of the consensus algorithm, while ensuring that the voting weight of the consensus node in the specific consensus process can fairly reflect the weight value of the consensus node itself.
[0006] In order to achieve the above object, the present invention provides a blockchain voting method, which comprises:
[0007] Modeling the weight value of a consensus node in a blockchain network as the number of sub-users in the consensus node;
[0008] Determine the number of sub-users of the randomly selected sub-users in the consensus node, and determine whether the consensus node is selected as the consensus node in the target consensus step according to the number of sub-users;
[0009] When it is determined that the consensus node is selected as the consensus node in the target consensus step, verifying the consensus voting message corresponding to the consensus node to obtain a verification result;
[0010] When the verification result is verification passed, the number of sub-users is used as the voting weight of the consensus node to vote on the block corresponding to the target consensus step.
[0011] Optionally, the step of determining the number of sub-users of the randomly selected sub-users in the consensus node includes:
[0012] Determine the hash value corresponding to the consensus node;
[0013] Determine a random probability value corresponding to the hash value according to the hash value;
[0014] The number of sub-users of the sub-users randomly selected in the consensus node is determined according to the random probability value.
[0015] Optionally, before the step of determining the hash value corresponding to the consensus node, the method further includes:
[0016] Determine the corresponding role of the consensus node in the target consensus step;
[0017] Determine the random seed of the block corresponding to the target consensus step;
[0018] An input value corresponding to the consensus node is determined based on the target consensus step, the role, and the random seed.
[0019] Optionally, the step of determining a hash value corresponding to the consensus node comprises:
[0020] The consensus node calculates the input value based on a verifiable random function to generate a hash value corresponding to the consensus node.
[0021] Optionally, the step of determining the number of sub-users of the randomly selected sub-users in the consensus node according to the random probability value includes:
[0022] Determine the probability distribution interval of the random probability value according to the random probability value;
[0023] The number of sub-users of the randomly selected sub-users in the consensus node is determined based on the probability distribution interval and the cumulative distribution curve of the binomial distribution.
[0024] Optionally, the step of verifying the consensus voting message corresponding to the consensus node to obtain a verification result includes:
[0025] Determine a consensus voting message corresponding to the consensus node, and send the consensus voting message to other consensus nodes, wherein the other consensus nodes are consensus nodes in the blockchain network except the consensus node;
[0026] The consensus voting message is verified by the other consensus nodes to obtain a verification result.
[0027] Optionally, the step of verifying the consensus voting message by the other consensus nodes to obtain a verification result includes:
[0028] Parsing the consensus voting message corresponding to the consensus node through the other consensus nodes to obtain the hash value corresponding to the consensus node and the number of sub-users;
[0029] The correctness of the hash value and the number of sub-users is verified by the other consensus nodes to obtain a verification result.
[0030] In addition, to achieve the above-mentioned purpose, the present invention also provides a blockchain voting device, the blockchain voting device comprising:
[0031] A modeling module, which models the weight value of a consensus node in a blockchain network as the number of sub-users in the consensus node;
[0032] A sub-user number module, which determines the number of sub-users of the randomly selected sub-users in the consensus node, and determines whether the consensus node is selected as the consensus node in the target consensus step according to the number of sub-users;
[0033] A verification module, when determining that the consensus node is selected as the consensus node in the target consensus step, verifies the consensus voting message corresponding to the consensus node to obtain a verification result;
[0034] The voting module, when the verification result is verification passed, uses the number of sub-users as the voting weight of the consensus node to vote on the block corresponding to the target consensus step.
[0035] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal device, which includes: a memory, a processor, and a blockchain voting program stored in the memory and executable on the processor. When the blockchain voting program of the terminal device is executed by the processor, the steps of the blockchain voting method described above are implemented.
[0036] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a blockchain voting program is stored, and when the blockchain voting program is executed by a processor, the steps of the blockchain voting method as described above are implemented.
[0037] A blockchain voting method, apparatus, terminal device and computer-readable storage medium proposed in an embodiment of the present invention, wherein the method models the weight value of a consensus node in a blockchain network as the number of sub-users in the consensus node; determines the number of sub-users of a randomly selected sub-user in the consensus node, and determines whether the consensus node is selected as a consensus node in a target consensus step based on the number of sub-users; when it is determined that the consensus node is selected as a consensus node in the target consensus step, verifies the consensus voting message corresponding to the consensus node to obtain a verification result; when the verification result is verification passed, uses the number of sub-users as the voting weight of the consensus node to vote for the block corresponding to the target consensus step.
[0038] The embodiment of the present invention models the weight value of the consensus node in the blockchain network as the number of sub-users in the consensus node, determines the number of randomly selected sub-users in the consensus node, and determines whether the consensus node is selected as the consensus node in the target consensus step based on the number. When it is determined that the consensus node is selected as the consensus node in the target consensus step, the consensus voting message corresponding to the consensus node is verified and a verification result is obtained. When the verification result is passed, the number of sub-users selected in the consensus node is used as the voting weight of the consensus node to vote for the block corresponding to the target consensus step. In this way, the present invention realizes the fair and random selection of the required number of consensus nodes from the participant nodes of the blockchain network to participate in the operation of the consensus algorithm, while ensuring that the voting weight of the consensus node in the specific consensus process can fairly reflect the weight value of the consensus node itself. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a schematic diagram of the device structure of the hardware operating environment of the terminal device involved in the embodiment of the present invention;
[0040] Figure 2 This is a schematic diagram of the steps of the first embodiment of the blockchain voting method of the present invention;
[0041] Figure 3 This is a schematic diagram of the architecture involved in an embodiment of the blockchain voting method of the present invention;
[0042] Figure 4 This is a flow chart of an embodiment of the blockchain voting method of the present invention;
[0043] Figure 5This is a schematic diagram of the functional modules of an embodiment of a blockchain voting device of the present invention.
[0044] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0045] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0046] Reference Figure 1 , Figure 1 The present invention is a schematic diagram of the device structure of the hardware operating environment of the terminal device involved in the embodiment of the present invention.
[0047] The terminal device of the embodiment of the present invention may be a terminal device applied in the field of blockchain technology. Specifically, the terminal device may be a smart phone, a PC (personal computer), a tablet computer, a portable computer, etc.
[0048] like Figure 1 As shown, the terminal device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (DiSplay), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed RAM memory, or it may be a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may optionally be a storage device independent of the aforementioned processor 1001.
[0049] Those skilled in the art will understand that Figure 1 The terminal device structure shown in the figure does not constitute a limitation on the terminal device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0050] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a blockchain voting program.
[0051] exist Figure 1In the terminal shown, the network interface 1004 is mainly used to connect to the backend server and communicate data with the backend server; the user interface 1003 is mainly used to connect to the client and communicate data with the client; and the processor 1001 can be used to call the blockchain voting program stored in the memory 1005 and perform the following operations:
[0052] Modeling the weight value of a consensus node in a blockchain network as the number of sub-users in the consensus node;
[0053] Determine the number of sub-users of the randomly selected sub-users in the consensus node, and determine whether the consensus node is selected as the consensus node in the target consensus step according to the number of sub-users;
[0054] When it is determined that the consensus node is selected as the consensus node in the target consensus step, verifying the consensus voting message corresponding to the consensus node to obtain a verification result;
[0055] When the verification result is verification passed, the number of sub-users is used as the voting weight of the consensus node to vote on the block corresponding to the target consensus step.
[0056] Optionally, the processor 1001 may also be used to call a blockchain voting program stored in the memory 1005 and perform the following operations:
[0057] Determine the hash value corresponding to the consensus node;
[0058] Determine a random probability value corresponding to the hash value according to the hash value;
[0059] The number of sub-users of the sub-users randomly selected in the consensus node is determined according to the random probability value.
[0060] Optionally, the processor 1001 may also be used to call a blockchain voting program stored in the memory 1005, and before the step of determining the hash value corresponding to the consensus node, further perform the following operations:
[0061] Determine the corresponding role of the consensus node in the target consensus step;
[0062] Determine the random seed of the block corresponding to the target consensus step;
[0063] An input value corresponding to the consensus node is determined based on the target consensus step, the role, and the random seed.
[0064] Optionally, the processor 1001 may also be used to call a blockchain voting program stored in the memory 1005 and perform the following operations:
[0065] The consensus node calculates the input value based on a verifiable random function to generate a hash value corresponding to the consensus node.
[0066] Optionally, the processor 1001 may also be used to call a blockchain voting program stored in the memory 1005 and perform the following operations:
[0067] Determine the probability distribution interval of the random probability value according to the random probability value;
[0068] The number of sub-users of the randomly selected sub-users in the consensus node is determined based on the probability distribution interval and the cumulative distribution curve of the binomial distribution.
[0069] Optionally, the processor 1001 may also be used to call a blockchain voting program stored in the memory 1005 and perform the following operations:
[0070] Determine a consensus voting message corresponding to the consensus node, and send the consensus voting message to other consensus nodes, wherein the other consensus nodes are consensus nodes in the blockchain network except the consensus node;
[0071] The consensus voting message is verified by the other consensus nodes to obtain a verification result.
[0072] Optionally, the processor 1001 may also be used to call a blockchain voting program stored in the memory 1005 and perform the following operations:
[0073] Parsing the consensus voting message corresponding to the consensus node through the other consensus nodes to obtain the hash value corresponding to the consensus node and the number of sub-users;
[0074] The correctness of the hash value and the number of sub-users is verified by the other consensus nodes to obtain a verification result.
[0075] Based on the above-mentioned terminal device, various embodiments of the blockchain voting method of the present invention are proposed.
[0076] At present, in the blockchain network, consensus is reached on a batch of transactions contained in a block through a consensus algorithm. After the consensus is reached, the transactions in the block and their updates to the ledger status will be written into the distributed ledger. Therefore, the consensus algorithm is a key component of the blockchain system. The specific operation of the consensus algorithm is to transmit consensus-related information by assembling voting messages and sending them to other consensus nodes, and to drive the operation of the consensus process by collecting, processing and counting voting messages from other consensus nodes. Therefore, it is very important to select several suitable nodes from the blockchain network to participate in the operation of the consensus protocol and to regulate the voting operation of the consensus nodes. However, in common and mainstream public chains and consortium chains, the selection of consensus nodes is not sufficiently random, and it is generally assumed that the weights of consensus nodes when voting are the same.
[0077] In view of the above phenomenon, the present invention proposes a blockchain voting method. The blockchain voting method of the present invention models the weight value of the consensus node in the blockchain network as the number of sub-users in the consensus node, determines the number of randomly selected sub-users in the consensus node, and determines whether the consensus node is selected as the consensus node in the target consensus step according to the number. When it is determined that the consensus node is selected as the consensus node in the target consensus step, the consensus voting message corresponding to the consensus node is verified and the verification result is obtained. When the verification result is passed, the number of sub-users selected in the consensus node is used as the voting weight of the consensus node to vote for the block corresponding to the target consensus step. In this way, the present invention realizes the fair and random selection of the required number of consensus nodes from the participant nodes of the blockchain network to participate in the operation of the consensus algorithm, while ensuring that the voting weight of the consensus node in the specific consensus process can fairly reflect the weight value of the consensus node itself.
[0078] Please refer to Figure 2 , Figure 2 This is a flowchart of the first embodiment of the blockchain voting method of the present invention. It should be noted that although the logical order is shown in the flowchart, in some cases, the blockchain voting method of the present invention can of course perform the steps shown or described in a different order than here.
[0079] In the first embodiment of the blockchain voting method of the present invention, the blockchain voting method of the present invention includes:
[0080] Step S10: Modeling the weight value of the consensus node in the blockchain network as the number of sub-users in the consensus node;
[0081] In this embodiment, the terminal device models the weight value of the consensus node in the blockchain network as the number of sub-users in the consensus node.
[0082] Exemplarily, the weight value of the consensus node is modeled by the terminal device as the number of sub-users, that is, the weight value is an integer, and the number of sub-users owned by the consensus node is the value of the integer. Specifically, the sub-users of the consensus node are an abstract modeling based on the weight value of the consensus node. For a consensus node with a weight of w, the consensus node is modeled as having w sub-users, that is, sub-users 1, 2, 3, ..., w.
[0083] Step S20: determining the number of sub-users of the randomly selected sub-users in the consensus node, and determining whether the consensus node is selected as the consensus node in the target consensus step according to the number of sub-users;
[0084] In this embodiment, the terminal device determines the number of sub-users of the randomly selected sub-users in the consensus node, and then determines whether the consensus node itself is selected as the consensus node in the target consensus step based on the number of sub-users.
[0085] Exemplarily, each time a consensus node is selected, for a consensus node with a weight of w, the number of sub-users it has is w. In a specific step of the consensus algorithm, the number of sub-users selected by the sub-user selection algorithm each time may be a value among 0, 1, 2, ..., w. The number of sub-users selected by the consensus node represents the voting weight it has in this consensus step, and if the number of selected sub-users is 0, it means that the consensus node is not selected in the consensus step, and thus will not participate in the specific consensus and voting in the specific step of the consensus algorithm. When the number of selected sub-users is i, it means that the consensus node sends a voting message every time in the consensus step, and the total number of votes of the consensus node in the consensus step is i. Specifically, if a consensus node with a weight value of 100 has 5 sub-users selected in a selection, then the consensus node sends a voting message every time in the consensus step, indicating that the node actually has a total number of votes in the consensus step of 5, and so on.
[0086] Exemplarily, the blockchain consensus algorithm runs to a specific step and starts to select the consensus nodes required for the step. The above-mentioned specific step refers to a specific stage in the operation of a specific consensus algorithm. The consensus algorithm is generally divided into several stages, in which there will be specific operations, such as proposing blocks, voting on blocks, etc., and there may be several voting stages, depending on the specific design of the consensus algorithm. The above-mentioned consensus steps correspond to the block proposal stage or a specific voting stage, etc. For example, the possible values of the above-mentioned specific step are "block_propose", "vote_phase_1" or "vote_phase_2", etc. The specific value form can be customized during implementation.
[0087] Step S30, when it is determined that the consensus node is selected as the consensus node in the target consensus step, verifying the consensus voting message corresponding to the consensus node to obtain a verification result;
[0088] In this embodiment, when the terminal device determines that the consensus node is selected as the consensus node in the target consensus step, it verifies the consensus voting message corresponding to the consensus node to obtain a verification result.
[0089] Exemplarily, when the number of selected sub-users in a consensus node is greater than 0, it is determined that the consensus node is selected as the consensus node in the target consensus step, and the terminal device verifies the correctness of the consensus voting message corresponding to the consensus node to obtain a verification result, wherein the verification result includes verification passed and verification failed.
[0090] Step S40, when the verification result is verification passed, the number of sub-users is used as the voting weight of the consensus node to vote on the block corresponding to the target consensus step.
[0091] In this embodiment, when the terminal device verifies that the verification result of the consensus voting message of the consensus node is passed, the number of sub-users selected in the consensus node is used as the voting weight of the consensus node, and the block corresponding to the target consensus step is voted based on the voting weight.
[0092] Exemplarily, when it is determined that the verification result of the consensus voting message for verifying the consensus node is that the verification is passed, the terminal device counts the number of votes corresponding to the sender node of the message as the number of selected sub-users, and continues with subsequent consensus processing. Specifically, if the number of sub-users selected by the sender node of the message is 5, then its voting count in the current consensus step is 5; if it is determined that the verification result of the consensus voting message for verifying the consensus node is that the verification is failed, no operation is performed, that is, it is determined that the consensus node does not participate in the target consensus step.
[0093] In this embodiment, the blockchain voting method of the present invention models the weight value of the consensus node in the blockchain network as the number of sub-users in the consensus node by the terminal device; the terminal device determines the number of sub-users of the randomly selected sub-users in the consensus node, and then determines whether the consensus node itself is selected as the consensus node in the target consensus step based on the number of sub-users; when the terminal device determines that the consensus node is selected as the consensus node in the target consensus step, the terminal device verifies the consensus voting message corresponding to the consensus node to obtain a verification result; when the terminal device verifies that the verification result of the consensus voting message of the consensus node is that the verification is passed, the number of sub-users selected in the consensus node is used as the voting weight of the consensus node, and votes for the block corresponding to the target consensus step based on the voting weight.
[0094] In this way, the embodiment of the present invention models the weight value of the consensus node in the blockchain network as the number of sub-users in the consensus node, determines the number of randomly selected sub-users in the consensus node, and determines whether the consensus node is selected as the consensus node in the target consensus step based on the number. When it is determined that the consensus node is selected as the consensus node in the target consensus step, the consensus voting message corresponding to the consensus node is verified and a verification result is obtained. When the verification result is passed, the number of sub-users selected in the consensus node is used as the voting weight of the consensus node to vote for the block corresponding to the target consensus step. Thus, the present invention realizes the fair and random selection of the required number of consensus nodes from the participant nodes of the blockchain network to participate in the operation of the consensus algorithm, while ensuring that the voting weight of the consensus node in the specific consensus process can fairly reflect the weight value of the consensus node itself.
[0095] Furthermore, based on the first embodiment of the blockchain voting method of the present invention, a second embodiment of the blockchain voting method of the present invention is proposed.
[0096] In this embodiment, in the blockchain voting method of the present invention, in the above step S20, the step of "determining the number of sub-users of the sub-users randomly selected in the consensus node" may include:
[0097] Step S201, determining the hash value corresponding to the consensus node;
[0098] Step S202, determining a random probability value corresponding to the Hash value according to the Hash value;
[0099] Step S203, determining the number of sub-users of the sub-users randomly selected in the consensus node according to the random probability value.
[0100] In this embodiment, the terminal device determines the hash value corresponding to the consensus node, determines the random probability value corresponding to the hash value based on the hash value, and then determines the number of sub-users randomly selected in the consensus node based on the random probability value.
[0101] For example, in the consensus node selection process, when the random number selection algorithm generates a random number, a corresponding probability value can be obtained by random number calculation. The specific calculation method is as follows: assuming that the length corresponding to the random number R is 32 bytes, that is, 256 bits, then the probability value is
[0102] Then, the number of randomly selected sub-users in the consensus node is determined according to the probability value.
[0103] Furthermore, in a feasible embodiment, before the above step S201, the blockchain voting method of the present invention may further include:
[0104] Step A, determining the corresponding role of the consensus node in the target consensus step;
[0105] In this embodiment, the terminal device determines the corresponding role of the consensus node in the target consensus step.
[0106] Exemplarily, the role corresponding to the consensus node refers to the role corresponding to the consensus node to be selected when performing an operation in the current step. For example, if the step is "block_propose", one possible value of the role is "proposer", or if the step is "vote_phase_1", one possible value of the role is "committee", etc.
[0107] It should be noted that the specific value form of the role of the consensus node can be customized during implementation. It should be understood that based on the different design requirements of actual applications, in different feasible implementation methods, the role value of the consensus node can be any value that meets the actual needs. The present invention does not limit the role value of the consensus node.
[0108] Step B, determining the random seed of the block corresponding to the target consensus step;
[0109] In this embodiment, the terminal device determines the random seed of the block corresponding to the target consensus step.
[0110] For example, the random seed can be updated as the number of blocks in the blockchain continues to grow. Since the consensus process of a block may be divided into several steps, the same random seed can be used in different steps of the consensus process of the same block, while different random seeds will be used in the consensus process of different blocks. A possible method to determine the random seed, that is, the random seed corresponding to the current block, is to record the corresponding random seed as RandomSeed for the current block height h. h , then RandomSeed h You can use VRF (Verifiable Random Function) based on RandomSeed h-1 Calculated, that is, through (RandomSeed h,π)=VRFskRandomSeedh-1. Among them, sk is the private key of the proposer node of the previous block of the current block in the blockchain, that is, the parent block. In other words, when proposing the parent block, the proposer node of the parent block needs to simultaneously use the current random seed RandomSeed h-1 Call the VRF verifiable random function to generate the random seed RandomSeed corresponding to the block with height h h The π mentioned above is the corresponding proof, which also needs the same RandomSeed h Stored together in the parent block for consensus. Based on the above discussion, RandomSeed h It can also be found in the public ledger of the blockchain.
[0111] Step C: determining the input value corresponding to the consensus node based on the target consensus step, the role and the random seed.
[0112] In this embodiment, the terminal device determines the input value corresponding to the consensus node based on the target consensus step, the role of the consensus node, and the random seed of the current block.
[0113] Exemplarily, [the random seed of the current block]||[the consensus specific step]||[the role corresponding to the consensus node] is taken as the value of the input value x corresponding to the consensus node, where “||” represents the concatenation of values.
[0114] Furthermore, in a feasible embodiment, the blockchain voting method of the present invention, the above step S201 may include:
[0115] Step D, calculating the input value by the consensus node based on a verifiable random function to generate a hash value corresponding to the consensus node.
[0116] In this embodiment, the VRF verifiable random function is called by the consensus node to calculate the input value corresponding to the consensus node and generate a hash value corresponding to the consensus node.
[0117] It should be noted that VRF is a function that generates random numbers. Its characteristics are that for any given input x, for example, x is a string, the user uses his private key sk to call VRF (verifiable random function) to generate a hash value and a corresponding proof, that is, (hash, π) = VRF sk(x), where hash is the generated hash value, which is an unpredictable random number, and π is the corresponding proof. Anyone can use the user's public key pk and the proof π to verify that the hash value hash is generated by the user using his private key sk to call VRF (verifiable random function) based on x. The verification method is to call the verification function VerifyVRF pk (hash, π, x), where pk, hash, π and x are as described above. The properties of VRF (Verifiable Random Function) make it a good source of randomness.
[0118] Exemplarily, all consensus nodes to be selected independently run the VRF verifiable random function locally to generate random numbers and corresponding proofs. The specific method of calling the VRF verifiable random function is: (hash, π) = VRF sk (x), x is the input value of the VRF verifiable random function, that is, the input value corresponding to the consensus node, sk is the private key of the consensus node to be selected. The hash value is the generated unpredictable but easily publicly verifiable random number, and π is the corresponding proof.
[0119] Further, in a feasible embodiment, the voting method of the blockchain of the present invention, the above step S203 may include:
[0120] Step E, determining the probability distribution interval of the random probability value according to the random probability value;
[0121] Step F: determining the number of sub-users of the randomly selected sub-users in the consensus node based on the probability distribution interval and the cumulative distribution curve of the binomial distribution.
[0122] In this embodiment, the terminal device determines the probability distribution interval of the random probability value according to the random probability value, and determines the number of sub-users of the randomly selected sub-users in the consensus node based on the probability distribution interval and the cumulative distribution curve of the binomial distribution.
[0123] Exemplarily, the binomial distribution cumulative distribution curve corresponds to the graph of the binomial distribution cumulative distribution function. For a consensus node with a weight of w, the number of sub-users it has is w. In a specific step of the consensus algorithm, the number of sub-users selected each time using the sub-user selection algorithm may be a value among 0, 1, 2, ..., w. Assume that the sum of the weight values selected by all participating consensus nodes obtained from the public ledger of the blockchain is W, and the expected number of node sub-users to be selected in a specific consensus step is e, where the probability expectation value can be used to calculate the probability of any sub-user of any consensus node being selected. Then the probability of any sub-user of any consensus node being selected is And the probability of m sub-users of the consensus node being selected is Here = represents the number of combinations of selecting m sub-users from w sub-users. Thus, on the corresponding cumulative distribution curve of the binomial distribution of the sub-user selection, the probability interval [0, 1] on the vertical axis can be divided into and the remaining series intervals Here (k=1, ..., w). Then, by checking which interval the probability value is in, the number of sub-users selected by the consensus node can be determined. Specifically, if the probability value is in interval, the number of sub-users selected by the consensus node is 6, and so on.
[0124] Exemplarily, all consensus nodes to be selected independently calculate the probability value corresponding to the random number locally and use the probability value to select the sub-user of the current consensus node. Assuming that the weight of the current consensus node is w, and the hash value generated in step S50 is an n-bit integer, the random probability value is The method for selecting sub-users is to execute a loop starting from k=0 to determine whether P(s) is in If it is within the interval, then k+1 is returned, that is, the current consensus node has k+1 sub-users selected. If not, k is incremented by 1 and its value is judged again. If k<w, the judgment operation of whether it is within the interval is continued. Otherwise, if k=w, 0 is returned, indicating that no sub-user is selected for the current consensus node, that is, it has not been selected as a consensus node in the current consensus step.
[0125] In addition, if Figure 3 As shown in the figure, the blockchain network includes a series of participant nodes, which are interconnected through a P2P network (peer-to-peer network); the weight value of node i is wi, and the weight value of the node is modeled as the number of sub-users in the node; then, based on the VRF verifiable random function and the binomial distribution cumulative distribution curve, a sub-user is randomly selected from each sub-user, so as to determine the selected consensus node and the voting weight of the consensus node according to the consensus node selection and verification method.
[0126] In this embodiment, the blockchain voting method of the present invention determines the hash value corresponding to the consensus node by the terminal device, and determines the random probability value corresponding to the hash value based on the hash value, and then determines the number of randomly selected sub-users in the consensus node based on the random probability value; the terminal device determines the role corresponding to the consensus node in the target consensus step and the random seed of the block corresponding to the target consensus step, and determines the input value corresponding to the consensus node based on the target consensus step, the role of the consensus node and the random seed of the current block; the VRF verifiable random function is called by the consensus node to calculate the input value corresponding to the consensus node to generate the hash value corresponding to the consensus node; the terminal device determines the probability distribution interval of the random probability value based on the random probability value, and determines the number of sub-users of the randomly selected sub-users in the consensus node based on the probability distribution interval and the cumulative distribution curve of the binomial distribution.
[0127] In this way, by randomly selecting sub-users in the consensus node and determining the number of selected sub-users, the weight value of the consensus node, the probability of the consensus node being selected to participate in the operation of the consensus algorithm, and the voting weight of the consensus node after being selected are reflected, thereby greatly improving the fairness of consensus node selection and bringing more flexible and broader selection space to the design and implementation of blockchain networks and consensus algorithms.
[0128] Furthermore, based on the first embodiment and / or the second embodiment of the blockchain voting method of the present invention, a third embodiment of the blockchain voting method of the present invention is proposed.
[0129] In this embodiment, the blockchain voting method of the present invention, in the above step S30, "verifying the consensus voting message corresponding to the consensus node to obtain a verification result" may include:
[0130] Step S301, determining a consensus voting message corresponding to the consensus node, and sending the consensus voting message to other consensus nodes, wherein the other consensus nodes are consensus nodes in the blockchain network except the consensus node;
[0131] Step S302: verifying the consensus voting message through the other consensus nodes to obtain a verification result.
[0132] In this embodiment, the terminal device determines the consensus voting message corresponding to the consensus node, and sends the consensus voting message to other consensus nodes, which then verify the consensus voting message to obtain a verification result, wherein the other consensus nodes are all other consensus nodes in the blockchain network except the current consensus node.
[0133] It should be noted that the blockchain voting method of the present invention can also be used to select consensus nodes in each consensus step when proposing a block.
[0134] Exemplarily, all consensus nodes whose selected sub-user numbers are greater than 0 store their corresponding hash values, proof π, and the selected sub-user number, i.e., the value of k+1 when the loop exits, in the consensus vote or block proposal message corresponding to the current consensus step, and send it to all other consensus nodes in the blockchain network through P2P (peer-to-peer). Each consensus node mutually verifies the consensus vote message or block proposal message received by each other from other consensus nodes.
[0135] It should be noted that the blockchain network contains a series of participant nodes, which are connected to each other through a P2P peer-to-peer network. Nodes can be divided into observer nodes and consensus nodes according to whether they participate in the operation of the consensus algorithm. Observer nodes only synchronize blocks and blockchain ledgers and do not participate in the operation of the consensus algorithm. Consensus nodes not only synchronize blocks and blockchain ledgers, but also participate in the operation of the consensus algorithm, verify, execute and vote on blocks, and maintain and update the blockchain ledger together with other consensus nodes.
[0136] Further, in a feasible embodiment, the blockchain voting method of the present invention, the above step S302 may include:
[0137] Step G, parsing the consensus voting message corresponding to the consensus node through the other consensus nodes to obtain the hash value corresponding to the consensus node and the number of sub-users;
[0138] Step H: Verify the correctness of the hash value and the number of sub-users through the other consensus nodes to obtain a verification result.
[0139] In this embodiment, the consensus voting message corresponding to the current consensus node is parsed by other consensus nodes in the blockchain to obtain the hash value corresponding to the current consensus node and the number of selected sub-users. Then, other consensus nodes verify the correctness of the hash value and the number of sub-users to obtain the final verification result.
[0140] For example, the consensus voting message or block proposal message includes a hash value and the number of sub-users of the selected sub-user, that is, the value of k+1 when the loop exits. The verification process is divided into two steps. The first step is to verify h as Correctness of h value: Call VRF to verify the verification function VerifyVRF corresponding to the random function pk(hash, π, x), where pk is the public key of the sender node of the consensus voting message or block proposal message, hash is the hash value, π is the corresponding proof generated by the sender node of the consensus voting message or block proposal message when the hash value is generated by the VRF verifiable random function in step S50, and x is x=[RandomSeed of the current block]||[Current consensus specific step]||[Role corresponding to the consensus node], where "||" represents the concatenation of values. The process of verifying the correctness of the hash value will produce two results: verification passed and failed. If the result is verification failed, 0 is returned, indicating that the sender node of the consensus voting message or block proposal message is not selected as a consensus node. If the result is verification passed, the corresponding verification operation of the second step of the verification process is continued, that is, the number of sub-users selected by the sender node of the consensus voting message or block proposal message is verified: a random number, that is, a hash value, is calculated, corresponding to the generated random probability value and the probability value is used to select the sub-user of the current consensus node. Assuming the current hash value is an n-bit integer, the random probability value corresponding to the current hash value is
[0141]
[0142] Next, a loop is executed starting from k=0 to determine whether P(s) is within If it is within the interval, then return k+1, that is, the current consensus node has k+1 sub-users selected. If not, then k is incremented by 1 and its value is judged. If k<w, then continue to judge whether it is within the interval. Otherwise, if k=w, then the value of P(s) is If the value is within the range, it returns 0, which means that no sub-user is selected by the current consensus node, which means that it is not selected as a consensus node in the current consensus step.
[0143] For example, Figure 4As shown, the process of the blockchain voting method of the present invention is as follows: first, determine the specific step that the blockchain consensus algorithm is currently running to, and start selecting the consensus node required for the step; determine the role corresponding to the consensus node to be selected; determine the number of expected sub-users required for the role corresponding to the consensus node to be selected; determine the random seed of the current block; all consensus nodes to be selected independently run the VRF verifiable random function locally to generate their own corresponding random numbers and corresponding proofs; all consensus nodes to be selected independently calculate the probability value corresponding to the random number locally and use the probability value to select the sub-user of the current consensus node; all consensus nodes whose number of selected sub-users is greater than 0 store the generated hash value, proof π, and the number of selected sub-users in the consensus vote or block proposal message corresponding to the current consensus step, and send it to all other consensus nodes in the blockchain network; each consensus node mutually verifies the consensus vote message or block proposal message of the current consensus step received by each other, including the hash value and the number of selected sub-users; finally, the current consensus node processes the consensus vote message or block proposal message, and processes the voting count according to the corresponding number of sub-users selected.
[0144] In this embodiment, the blockchain voting method of the present invention determines the consensus voting message corresponding to the consensus node through a terminal device, and sends the consensus voting message to other consensus nodes, which are then verified by other consensus nodes to obtain a verification result, wherein other consensus nodes are all other consensus nodes in the blockchain network except the current consensus node; the consensus voting message corresponding to the current consensus node is parsed by other consensus nodes in the blockchain to obtain a hash value corresponding to the current consensus node and the number of selected sub-users, and then other consensus nodes verify the correctness of the hash value and the number of sub-users to obtain a final verification result.
[0145] In this way, on the basis of ensuring the randomness of consensus node selection, the public verifiability of consensus node selection results is also guaranteed, thereby effectively avoiding various potential attacks such as node bribery, thereby improving the security of the blockchain network.
[0146] In addition, an embodiment of the present invention also provides a blockchain voting device.
[0147] Please refer to Figure 5 , Figure 5 This is a functional module diagram of an embodiment of a blockchain voting device of the present invention. Figure 5 As shown, the blockchain voting device of the present invention includes:
[0148] A modeling module 10, used to model the weight value of a consensus node in a blockchain network as the number of sub-users in the consensus node;
[0149] The sub-user number module 20 is used to determine the number of sub-users of the randomly selected sub-users in the consensus node, and determine whether the consensus node is selected as the consensus node in the target consensus step according to the number of sub-users;
[0150] A verification module 30, for verifying the consensus voting message corresponding to the consensus node to obtain a verification result when it is determined that the consensus node is selected as the consensus node in the target consensus step;
[0151] The voting module 40 is used to use the number of sub-users as the voting weight of the consensus node to vote on the block corresponding to the target consensus step when the verification result is verification passed.
[0152] Optionally, the sub-user quantity module 20 includes:
[0153] A hash value unit, used to determine the hash value corresponding to the consensus node;
[0154] A probability value unit, used to determine a random probability value corresponding to the Hash value according to the Hash value;
[0155] A sub-user number unit is used to determine the number of sub-users randomly selected in the consensus node according to the random probability value.
[0156] Optionally, the blockchain voting device of the present invention further includes:
[0157] An input value module is used to determine the role corresponding to the consensus node in the target consensus step; determine the random seed of the block corresponding to the target consensus step; and determine the input value corresponding to the consensus node based on the target consensus step, the role and the random seed.
[0158] Optionally, the hash value unit is further used to calculate the input value based on a verifiable random function through the consensus node to generate a hash value corresponding to the consensus node.
[0159] Optionally, the sub-user number unit is further used to determine the probability distribution interval of the random probability value according to the random probability value; and determine the number of sub-users randomly selected in the consensus node based on the probability distribution interval and the cumulative distribution curve of the binomial distribution.
[0160] Optionally, the verification module 30 further includes:
[0161] A message sending unit, used to determine the consensus voting message corresponding to the consensus node, and send the consensus voting message to other consensus nodes, wherein the other consensus nodes are consensus nodes in the blockchain network except the consensus node;
[0162] A verification unit is used to verify the consensus voting message through the other consensus nodes to obtain a verification result.
[0163] Optionally, the verification unit is further used to parse the consensus voting message corresponding to the consensus node through the other consensus nodes to obtain the hash value corresponding to the consensus node and the number of sub-users; and verify the correctness of the hash value and the number of sub-users through the other consensus nodes to obtain a verification result.
[0164] The present invention also provides a computer storage medium, on which a blockchain voting program is stored. When the blockchain voting program is executed by a processor, the steps of the blockchain voting program method described in any of the above embodiments are implemented.
[0165] The specific embodiments of the computer storage medium of the present invention are basically the same as the embodiments of the blockchain voting program method of the present invention described above, and will not be described in detail here.
[0166] The present invention also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the steps of the blockchain voting method of the present invention as described in any of the above embodiments, which will not be repeated here.
[0167] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0168] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0169] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, including a number of instructions for a terminal device (which can be a TWS headset, etc.) to execute the methods described in each embodiment of the present invention.
[0170] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A blockchain voting method, characterized in that: The blockchain voting method includes: Modeling the weight value of a consensus node in a blockchain network as the number of sub-users in the consensus node; Determine the number of sub-users of the randomly selected sub-users in the consensus node, and determine whether the consensus node is selected as the consensus node in the target consensus step according to the number of sub-users; When determining that the consensus node is selected as the consensus node in the target consensus step, verifying the correctness of the consensus voting message corresponding to the consensus node to obtain a verification result; When the verification result is verification passed, the number of sub-users is used as the voting weight of the consensus node to vote on the block corresponding to the target consensus step; The step of determining the number of sub-users of the randomly selected sub-users in the consensus node comprises: Determine the hash value corresponding to the consensus node; Determine a random probability value corresponding to the hash value according to the hash value; Determine the probability distribution interval of the random probability value according to the random probability value; The number of sub-users of the randomly selected sub-users in the consensus node is determined based on the probability distribution interval and the cumulative distribution curve of the binomial distribution.
2. The blockchain voting method according to claim 1, characterized in that: Before the step of determining the hash value corresponding to the consensus node, the method further includes: Determine the corresponding role of the consensus node in the target consensus step; Determine the random seed of the block corresponding to the target consensus step; An input value corresponding to the consensus node is determined based on the target consensus step, the role, and the random seed.
3. The blockchain voting method according to claim 2, characterized in that: The step of determining the hash value corresponding to the consensus node comprises: The consensus node calculates the input value based on a verifiable random function to generate a hash value corresponding to the consensus node.
4. The blockchain voting method according to claim 1, characterized in that: The step of verifying the correctness of the consensus voting message corresponding to the consensus node to obtain a verification result includes: Determine a consensus voting message corresponding to the consensus node, and send the consensus voting message to other consensus nodes, wherein the other consensus nodes are consensus nodes in the blockchain network except the consensus node; The correctness of the consensus voting message is verified by the other consensus nodes to obtain a verification result.
5. The blockchain voting method according to claim 4, characterized in that: The step of verifying the correctness of the consensus voting message by the other consensus nodes to obtain a verification result includes: Parsing the consensus voting message corresponding to the consensus node through the other consensus nodes to obtain the hash value corresponding to the consensus node and the number of sub-users; The correctness of the hash value and the number of sub-users is verified by the other consensus nodes to obtain a verification result.
6. A blockchain voting device, characterized in that: The blockchain voting device comprises: A modeling module, which models the weight value of a consensus node in a blockchain network as the number of sub-users in the consensus node; A sub-user quantity module determines the number of sub-users of the randomly selected sub-users in the consensus node, and determines whether the consensus node is selected as the consensus node in the target consensus step according to the number of sub-users; determines the hash value corresponding to the consensus node; determines the random probability value corresponding to the hash value according to the hash value; determines the probability distribution interval of the random probability value according to the random probability value; determines the number of sub-users of the randomly selected sub-users in the consensus node based on the probability distribution interval and the cumulative distribution curve of the binomial distribution; A verification module, when determining that the consensus node is selected as the consensus node in the target consensus step, verifies the correctness of the consensus voting message corresponding to the consensus node to obtain a verification result, wherein the verification result is obtained by verifying the correctness of the hash value and the number of sub-users in the consensus voting message of the consensus node by other consensus nodes, and the other consensus nodes are consensus nodes in the blockchain network except the consensus node; The voting module, when the verification result is verification passed, uses the number of sub-users as the voting weight of the consensus node to vote on the block corresponding to the target consensus step.
7. A terminal device, characterized in that: The terminal device includes: a memory, a processor, and a blockchain voting program stored in the memory and executable on the processor. When the blockchain voting program is executed by the processor, the steps of the blockchain voting method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a blockchain voting program, which, when executed by a processor, implements the steps of the blockchain voting method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Block chain generation method and device, storage medium and electronic equipment
CN114465866A