Implementation method of blockchain election based on verifiable random function
By using verifiable random functions based on elliptic curves, employing double hashing and zero-knowledge proofs, the problems of insufficient randomness and vulnerability to attacks in blockchain elections are solved, improving election fairness and consensus performance, and enhancing security and decentralization.
Patent Information
- Application Number
- CN202210681968.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-15
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-06-15
AI Technical Summary
The random numbers generated in existing blockchain elections are not random enough and are vulnerable to attacks. There is also a trade-off between the number of consensus nodes and performance.
We employ a verifiable random function based on elliptic curves, generate random numbers through double hashing, and introduce non-interactive zero-knowledge proofs to verify the correctness of the random numbers, thereby improving the fairness and security of the election.
The generated random numbers are more random, which improves the fairness and consensus performance of blockchain elections, and enhances the security and decentralization of the consensus mechanism.
Smart Images

Figure CN115834096B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of information encryption security, in particular to a method for implementing blockchain election based on verifiable random function. BACKGROUND
[0002] A verifiable random function (VRF) is an encryption scheme that maps an input to a verifiable random output. It outputs a random number and a proof through the prove function of the private key and information of the input, and the verifier verifies the output and the public key through the verify verification function to detect whether it is correct. The verifiable random function can be used in the election stage of the blockchain consensus mechanism, so that the leader can be selected fairly and randomly.
[0003] Currently, the verifiable random number used in the blockchain election still has the following problems: the generated random number is not random enough, and the risk of attack is relatively large. SUMMARY
[0004] The purpose of the present application is to provide a method for implementing blockchain election based on verifiable random function, and the random number generated by the method can be correctly verified. As a core component of the blockchain, the consensus algorithm faces an important trade-off problem, that is, the trade-off between the number of consensus nodes and the consensus performance. Although the more the number of consensus nodes, the higher the degree of decentralization, but at the same time it will lead to the reduction of the performance of the consensus mechanism. The random number generation scheme proposed by the present method can be used in the election of the consensus mechanism to improve the consensus performance of the blockchain.
[0005] The verifiable random function (VRF) is another application of public key cryptography combined with hash functions. Only the holder of the private key can calculate the hash value, but anyone with the public key can verify the correctness of the hash value. VRF helps to prevent enumeration attacks on hash-based data structures.
[0006] The verifiable random function can be regarded as a random oracle, which obtains a random number output through any input. The verifiable random function has a non-interactive zero-knowledge proof in addition to the random oracle, which can be used to verify the correctness of the random number output, indicating that the random number is indeed generated by a person or node. There are two systems, one VRF uses RSA mechanism, and the other VRF uses elliptic curve (EC), and the present application uses elliptic curve to design VRF.
[0007] The specific technical solution is:
[0008] The application discloses an implementation method of a blockchain election based on a verifiable random function, and the generated pseudo-random number is made more random through double hash processing, and the fairness of the election is improved. The method mainly comprises the following steps: generating a public key and a private key, mapping given information into a random number through twice hash operations, generating the random number and a corresponding verification value, calculating a vote number, checking whether the random number is correct, and checking whether the vote number is correct.
[0009] In the application, the verifiable random function is the most important part. Two most important functions of the verifiable random function are a prove generation function and a verify verification function, which correspond to a vote generation process and a vote checking process of the election respectively. The prove generation function generally comprises two processes: generating a proof string with a fixed length according to a received public key pair and an input information string, and generating a corresponding proof hash value (the random number required by us) through the generated proof string. The method improves the hash processing process on the basis of an elliptic curve VRF random number generation method, and introduces twice hash processing methods. In order to verify the correctness of the generated random number, the verify verification function restores the position of the input information on the elliptic curve by receiving the public key, the original input information and the proof string, so as to compare the effect. If the random number is obtained by the prove generation function through the original input information and the given public key pair, the output result of the verify verification function is valid, otherwise, the output result of the verify verification function is invalid.
[0010] The specific process is as follows:
[0011] Step S1. Generating a public key and a private key of the VRF method. First, a 32-byte random number x is generated as a private key, and then a public key y is generated according to the following formula:
[0012] y=x*B (1)
[0013] Wherein, B is a base point of the elliptic curve.
[0014] Step S2. Mapping given information into a random number through twice hash operations. In the case of the known public key y, the calculation process of the hash value of the given input information alpha is shown in the following formula:
[0015] h=double_hash_to_curve(y,alpha) (2)
[0016] In the double_hash_to_curve function, the application adopts twice hash processing, randomizes the input information first, and then maps the input information to a point on the elliptic curve to obtain the random number h, so as to further improve the security and uniqueness of the public key pair information.
[0017] Step S3. Generating random number and corresponding verification value. The calculation process of generating random number is shown in the following formula:
[0018] hash = x * h (3)
[0019] k = nonce_generate() (4)
[0020] c = hash_point(h, Gamma, k * B, k * h) (5)
[0021] s = (k + c * x) mod q (6)
[0022] Wherein, the parameter q refers to the prime order of the prime order subgroup, k is the random number for verification, hash_point is used for hashing mapping the point on the elliptic curve into an integer.
[0023] The random number hash and corresponding verification parameters c and s are obtained. hash is a random number which is difficult to distinguish, obtained by multiplying the integer x corresponding to the private key of the point h mapped on the elliptic curve; parameter c is a hash value obtained by hashing the given point on the elliptic curve, which ensures that only the same point can obtain the same hash value in verification; parameter s is a verification value generated by the elliptic interval based on the above parameters, which is used to verify the authenticity of the random number.
[0024] Step S4. Calculating the number of votes. The pseudo code of an optional calculation process is as follows:
[0025]
[0026] Wherein, j is the final number of votes, hashlen is the binary length of hash, w is the weight of the user, such as the number of currencies, is a binomial distribution.
[0027] After execution, the node publishes the random number hash, the corresponding verification parameters c and s, and the final number of votes obtained in this phase.
[0028] After the node publishes the random number, the verification value and the number of votes, it enters the verification vote phase.
[0029] Step S5. Verifying whether the random number is correct. First, the point h of the elliptic curve is obtained according to formula (2). Secondly, the relevant parameters are calculated by the following formula:
[0030] u = y * c + s * B (7)
[0031] v = c * hash + s * h (8)
[0032] c' = hash_point(h, hash, u, v) (9)
[0033] where y is the public key, B is the base point of the elliptic curve. u and v are points on the elliptic curve after calculation of given parameters, which are equal to k*B and k*h respectively when not forged, and c' after hash mapping is also equal to c in step S3.
[0034] Finally, compare c and c', if the same, pass the verification and return valid; otherwise, fail the verification and return invalid.
[0035] Step S6. Verify the vote number. This step is the same as step S4, if the result is the same as the published vote number, return the vote number, otherwise return 0.
[0036] In order to efficiently complete the task of blockchain key security and security enhancement technology, a verifiable random function for the election process of the blockchain consensus mechanism is constructed, and an election process based on the verifiable random function is given. This method can verify the authenticity of random numbers and has high security, ensuring the non-distinguishability of the elliptic curve random point for the enemy. The model framework uses two hash operations to further improve the security and uniqueness of the public and private key information. The application can well enhance the security of the blockchain key and its technology, and improve the attack difficulty. BRIEF DESCRIPTION OF DRAWINGS
[0037] Figure 1 is a flowchart of the application;
[0038] Figure 2 is the execution process of generating votes of the embodiment;
[0039] Figure 3 is the execution process of the vote verification stage of the embodiment. DETAILED DESCRIPTION
[0040] The specific technical solutions of the application are illustrated in combination with the embodiments.
[0041] The application gives a DHVRF based on Ed25519 elliptic curve, and gives the election process of the blockchain based on this. As shown in the figure, Figure 1 the election flowchart based on DHVRF includes the vote generation process (left) and the vote verification process (right)
[0042] Figure 2is the execution process of generating a vote. As can be seen, the function first codes to generate a public and private key pair, where P represents the public key, and the length is 256 bits; S represents the private key, and the length is 512 bits. Secondly, the code maps the information to a point h on the elliptic curve through a double hash operation. Here, the mapping method is:
[0043]
[0044] where cofactor is the cofactor of the elliptic curve, and for the Ed25519 elliptic curve, the cofactor is 8.
[0045] Subsequently, the function generates random numbers hash and verification values c and s according to formulas (3)-(6). Finally, the code calculates the vote count.
[0046] Figure 3 is the execution process of verifying the vote. First, the program calculates the required parameters u and c' according to formulas (7)-(9) to verify the correctness of the random number. The following figure prints out "Random Number Validation Passed!", indicating that the two parameters are equal, and the random number passes the test. Then the vote count is verified, and the following figure prints out "Vote Validation Passed!", indicating that the vote count is correct, and finally the real vote count is returned.
Claims
1. An implementation method of a blockchain election based on a verifiable random function, characterized in that, The method comprises the following steps: S1, generating a public and private key; Specifically comprising the following processes: First, a 32-byte random number x is generated as a private key, and then a public key y is generated according to the following formula: y = x*B (1) Wherein, B is the base point of the elliptic curve; S2, mapping given information to a random number through two hash operations; In the case of known public key y, the calculation process of the hash value of the given input information alpha is shown in the following formula: h = double_hash_to_curve(y, alpha) (2) In the double_hash_to_curve function, two hash operations are adopted, the input information is first randomized, and then mapped to a point on the elliptic curve to obtain a random number h; S3, generating a random number and a corresponding verification value; The calculation process of the random number is shown in the following formula: hash = x*h (3) k = nonce_generate() (4) c = hash_point(h, hash, k*B, k*h) (5) s = (k + c*x) mod q (6) Wherein, the parameter q refers to the prime order of the large prime order subgroup, k is a random number for verification, and hash_point is used to hash map the point on the elliptic curve to an integer; The random number hash and the corresponding verification parameters c and s are obtained; hash is a random number that is difficult to distinguish, which is obtained by multiplying the point h mapped to the elliptic curve and the integer x corresponding to the private key; Parameter c is a hash value obtained by hashing the given point on the elliptic curve, which ensures that only the same point can obtain the same hash value during verification; Parameter s is a verification value generated by the elliptic interval based on the above parameters, which is used to verify the authenticity of the random number; S4, calculating the vote number; First j zero, each time j 1, until j satisfy belongs to the interval ; when this condition is met j That is the number of votes; wherein, hashlen is the binary length of hash , w is the weight of the user, is a binomial distribution; After execution, the node publishes the random number hash, the corresponding verification parameters c and s, and the final vote number obtained in this phase; After the node publishes the random number, the verification value and the vote number, it enters the verification vote phase; S5, verifying whether the random number is correct; The method comprises the following steps: First, the point h on the elliptic curve is obtained according to formula (2); second, the relevant parameters are calculated through the following formula: u = y*c+s*B (7) v = c*hash + s*h (8) c' = hash_point (h, hash, u, v) (9) Wherein, y is the public key, B is the base point of the elliptic curve; u and v are points on the elliptic curve obtained by calculating the given parameters, which are equal to k*B and k*h respectively when not counterfeit, at this time, the hash mapping c' is also equal to c in step S3; Finally, compare c and c', if they are the same, pass the verification and return valid; otherwise, do not pass the verification and return invalid; S6, verifying whether the vote number is correct; This step is the same as step S4, if the obtained result is the same as the published vote number, the vote number is returned, otherwise 0 is returned.
Citation Information
Patent Citations
Data verification method and device
CN113037479A
Election method based on block chain
CN113285799A