Node selection method, device, equipment and medium based on verifiable random function

By constructing a verifiable random function based on the SM2 elliptic curve public key cryptography algorithm and generating a verifiable random number and proof value set, the problem of the lack of domestic cryptographic algorithms is solved and independent, controllable and secure hash result verification is achieved.

CN117595984BActive Publication Date: 2024-09-06SSC HLDG CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202311270944.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-28
Publication Date
2024-09-06
Estimated Expiration
2043-09-28

AI Technical Summary

Technical Problem

There is currently a lack of verifiable random functions based on domestic cryptographic algorithms, which cannot meet the country's independent and controllable security needs for verifiable random functions.

Method used

The system parameter set is constructed based on the SM2 elliptic curve public key cryptography algorithm. The user's private key and system parameters are used to generate the public key. The verifiable random number and proof value set are calculated through a series of hash functions to ensure the correctness and accuracy of the hash results. Verifiability.

Benefits of technology

It realizes an autonomous, controllable and verifiable random function that meets national security needs, ensures the correctness and verifiability of hash results, and meets the security needs of blockchain consensus and other fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117595984B
    Figure CN117595984B
Patent Text Reader

Abstract

The present invention discloses a method, device, equipment and storage medium for constructing a verifiable random function based on SM2, and relates to the field of computer technology, including: constructing a system parameter set including a finite field, the number of elements in the finite field, elliptic curve parameters, an alpha group, any generator in the alpha group, the order of the generator, a first hash function, a second hash function and a third hash function; calculating a public key using a private key and a generator; calculating a current message using the first hash function to obtain a hash value; using the second hash function, calculating based on an intermediate value, a generator and a hash value to obtain a first part of the proof value; determining the second part of the proof value using the private key, the intermediate value, the first part of the proof value, and the order of the generator; determining the third part of the proof value using the private key and the hash value; calculating the third part of the proof value using the third hash function to obtain a verifiable random number. The present invention can meet the national security requirements for autonomous and controllable verifiable random functions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for constructing a verifiable random function based on SM2. Background Art

[0002] At present, there is a VRF (Verifiable Random Function) standard draft proposed by the IETF organization internationally. Among them, the verifiable random function is an encryption function that generates a pseudo-random number based on data input and attaches a certificate, which can be verified by anyone. The data input of VRF usually contains a pair of public and private keys, also known as verification key and secret key, and a seed. The public and private keys are generated, while the seed is selected. Then these values ​​are input into VRF together, and the private key and seed are used to generate a random number, that is, VRF will generate a random number and a certificate. The most critical thing is to generate a certificate, because users can verify the function through the certificate, and keeping the private key confidential can ensure that the random number cannot be predicted. VRF is widely used in digital signatures, key encapsulation, blockchain consensus and other fields. VRF can be used to select block nodes and has become an important tool for random selection of blockchain consensus nodes in non-interactive mode. However, there is currently no VRF based on domestic cryptographic algorithms, which cannot meet the country's security requirements for independent and controllable verifiable random functions. Summary of the invention

[0003] In view of this, the purpose of the present invention is to provide a method, device, equipment and storage medium for constructing a verifiable random function based on SM2, which can ensure the correctness and verifiability of the hash result, and meet the national security requirements for autonomous and controllable verifiable random functions. The specific scheme is as follows:

[0004] In a first aspect, the present invention discloses a method for constructing a verifiable random function based on SM2, comprising:

[0005] Constructing a system parameter set; the system parameter set includes a finite field, the number of elements in the finite field, elliptic curve parameters, an alpha group, any generator in the alpha group, the order of the generator, a first hash function, a second hash function, and a third hash function;

[0006] Calculate a corresponding public key using a randomly selected user private key and the generator in the system parameter set;

[0007] Using the first hash function to perform hash calculation on the current message to obtain a corresponding hash value;

[0008] Using the second hash function, and performing a hash calculation based on the randomly selected intermediate value, the generator, and the hash value to obtain a corresponding first partial proof value;

[0009] Determining a corresponding second partial proof value using the private key, the intermediate value, the first partial proof value, and the order of the generator;

[0010] Determine a corresponding third part of the proof value using the private key and the hash value;

[0011] A third hash function is used to perform a hash calculation on the third part of the proof value to obtain a corresponding verifiable random number, and a corresponding proof value set is constructed based on the first part of the proof value, the second part of the proof value and the third part of the proof value.

[0012] Optionally, the calculating a corresponding public key using a randomly selected user private key and the generator in the system parameter set includes:

[0013] The randomly selected user private key and the generator in the system parameter set are point multiplied to obtain the corresponding public key.

[0014] Optionally, the using the second hash function and performing hash calculation based on the randomly selected intermediate value, the generator and the hash value to obtain the corresponding first partial proof value includes:

[0015] Performing a dot product of the randomly selected intermediate value and the generator to obtain a corresponding first dot product result, and performing a dot product of the intermediate value and the hash value to obtain a corresponding second dot product result;

[0016] The second Hash function is used to perform a Hash calculation on the first dot product result and the second dot product result to obtain a corresponding first partial proof value.

[0017] Optionally, determining a corresponding second partial proof value by using the private key, the intermediate value, the first partial proof value, and the order of the generator includes:

[0018] The private key, the intermediate value, the first part of the proof value, and the order of the generator are calculated using a first preset formula to obtain a corresponding second part of the proof value; the preset formula is s=((1+d) -1 ·(kr·d)))mod q;

[0019] Among them, s represents the second part of the proof value, d represents the private key, k represents the intermediate value, r represents the first part of the proof value, and q represents the order of the generator.

[0020] Optionally, the determining a corresponding third part of the proof value by using the private key and the hash value includes:

[0021] The private key and the hash value are point-multiplied to obtain the corresponding third part proof value.

[0022] Optionally, the SM2-based verifiable random function construction method further includes:

[0023] Determine whether a process of performing hash calculation on the third part of the proof values ​​in the proof value set by using the third hash function to obtain the verifiable random number is established;

[0024] If so, reusing the first hash function to perform hash calculation on the message to obtain a corresponding target hash value for verification;

[0025] Calculating the first part of the proof value and the second part of the proof value in the proof value set, the generator and the public key using a second preset formula to obtain a corresponding first verification value; wherein the second preset formula is U1=s·G+(r+s)·P, and U1 represents the first verification value, r represents the first part of the proof value in the proof value set, s represents the second part of the proof value in the proof value set, G represents the generator, and P represents the public key;

[0026] The first part of the proof value, the second part of the proof value, the third part of the proof value and the target hash value in the proof value set are calculated using a third preset formula to obtain a corresponding second verification value; wherein the third preset formula is U2=s·Q′+(r+s)·V, and U2 represents the second verification value, Q′ represents the target hash value, r represents the first part of the proof value in the proof value set, s represents the second part of the proof value in the proof value set, and V represents the third part of the proof value in the proof value set;

[0027] Using the second hash function to perform hash calculation on the first verification value and the second verification value to obtain a corresponding target partial proof value;

[0028] Determine whether the target partial proof value is consistent with the first partial proof value in the proof value set to obtain a corresponding determination result;

[0029] Based on the judgment result, it is determined whether the verifiable random number is valid.

[0030] Optionally, determining whether the verifiable random number is valid based on the judgment result includes:

[0031] If the judgment result indicates that the target partial proof value is consistent with the first partial proof value in the proof value set, then it is determined that the verifiable random number is valid and the verification is passed;

[0032] If the judgment result indicates that the target partial proof value is inconsistent with the first partial proof value in the proof value set, the verifiable random number is determined to be invalid and the verification fails.

[0033] In a second aspect, the present invention discloses a verifiable random function construction device based on SM2, comprising:

[0034] A construction module, used to construct a system parameter set; the system parameter set includes a finite field, the number of elements in the finite field, elliptic curve parameters, an alpha group, any generator in the alpha group, the order of the generator, a first hash function, a second hash function, and a third hash function;

[0035] A first calculation module, used to calculate a corresponding public key using a randomly selected user private key and the generator in the system parameter set;

[0036] A second calculation module, configured to perform a hash calculation on the current message using the first hash function to obtain a corresponding hash value;

[0037] A first proof value determination module, configured to use the second hash function and perform a hash calculation based on the randomly selected intermediate value, the generator and the hash value to obtain a corresponding first partial proof value;

[0038] A second proof value determination module, configured to determine a corresponding second partial proof value using the private key, the intermediate value, the first partial proof value, and the order of the generator;

[0039] A third proof value determination module, configured to determine a corresponding third partial proof value using the private key and the hash value;

[0040] A verifiable random number generation module, configured to perform a hash calculation on the third part of the proof value using a third hash function to obtain a corresponding verifiable random number;

[0041] A proof value set construction module is used to construct a corresponding proof value set based on the first part of the proof value, the second part of the proof value and the third part of the proof value.

[0042] In a third aspect, the present invention discloses an electronic device, comprising:

[0043] Memory, used to store computer programs;

[0044] A processor is used to execute the computer program to implement the steps of the aforementioned disclosed method for constructing a verifiable random function based on SM2.

[0045] In a fourth aspect, the present invention discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the aforementioned disclosed method for constructing a verifiable random function based on SM2 are implemented.

[0046] It can be seen that the present invention provides a method for constructing a verifiable random function based on SM2, including: constructing a system parameter set; the system parameter set includes a finite field, the number of elements in the finite field, elliptic curve parameters, an alpha group, an arbitrary generator in the alpha group, the order of the generator, a first hash function, a second hash function and a third hash function; using a randomly selected user private key and the generator in the system parameter set to calculate a corresponding public key; using the first hash function to perform a hash calculation on the current message to obtain a corresponding hash value; using the second hash function, and based on the randomly selected intermediate value, the generator and the hash value to perform a hash calculation to obtain a corresponding first part proof value; using the private key, the intermediate value, the first part proof value, and the order of the generator to determine the corresponding second part proof value; using the private key and the hash value to determine the corresponding third part proof value; using the third hash function to perform a hash calculation on the third part proof value to obtain a corresponding verifiable random number, and constructing a corresponding proof value set based on the first part proof value, the second part proof value and the third part proof value. It can be seen that the present invention generates a corresponding verifiable random number and proof value set by constructing a verifiable random function based on the SM2 elliptic curve public key cryptography algorithm, which can meet the country's security requirements for independent and controllable verifiable random functions, and can ensure both the correctness and the verifiability of the hash result. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0048] Figure 1 A flow chart of a method for constructing a verifiable random function based on SM2 disclosed in the present invention;

[0049] Figure 2 A specific verification method flow chart disclosed in the present invention;

[0050] Figure 3 A specific SM2-based verifiable random function construction and verification schematic diagram disclosed in the present invention;

[0051] Figure 4 Another specific SM2-based verifiable random function construction and verification schematic diagram disclosed in the present invention;

[0052] Figure 5 This is a schematic diagram of the structure of a verifiable random function construction device based on SM2 disclosed in the present invention;

[0053] Figure 6 The present invention is a structural diagram of an electronic device disclosed in the present invention. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0055] Currently, there is no VRF based on domestic cryptographic algorithms, which cannot meet the national security requirements for autonomous and controllable verifiable random functions. To this end, the present invention provides a verifiable random function construction scheme based on SM2, which can meet the national security requirements for autonomous and controllable verifiable random functions, and can ensure the correctness and verifiability of hash results.

[0056] The embodiment of the present invention discloses a method for constructing a verifiable random function based on SM2, see Figure 1 As shown, the method includes:

[0057] Step S11: construct a system parameter set; the system parameter set includes a finite field, the number of elements in the finite field, elliptic curve parameters, an alpha group, any generator in the alpha group, the order of the generator, a first hash function, a second hash function and a third hash function.

[0058] It can be understood that, in the initialization phase, the system is initialized to obtain the system parameter set corresponding to the system construction output, including the finite field, the number of elements in the finite field, the elliptic curve parameters, the alpha group, any generator in the alpha group, the order of the generator, the first hash function, the second hash function and the third hash function. For example, given the security parameter 1 n , then for a selected finite field Generate elliptic curve equation y 2 =x 3+ax+b mod p, construct an Abelian group using the points that satisfy this equation Then randomly select a generator from the Abelian group The coordinates of the generator G are (x G ,y G ), the order of the generator G is q, and the hash function is selected Output the corresponding system parameters in, as well as

[0059] Among them, the Abelian group represents the elliptic curve group of prime order q. The elements in the Abelian group are points on the elliptic curve. a and b represent the elliptic curve parameters. G represents the Abelian group. A generator of , q represents the order of the generator G, that is, the Abelian group of order, and represents the set of integers consisting of the integers 1, 2, ..., q-1, represents a prime field containing p elements.

[0060] Step S12: Calculate the corresponding public key using the randomly selected user private key and the generator in the system parameter set.

[0061] In this embodiment, after the system parameters are constructed, in the key generation stage, the corresponding public key is calculated using the randomly selected user private key and the generator in the system parameter set. Specifically, the randomly selected user private key and the generator in the system parameter set are point-multiplied to obtain the corresponding public key. For example, the randomly selected user private key The public key is calculated using the private key and the generator in the system parameter set, that is, P = d·G, thereby obtaining the corresponding public-private key pair (P, d), where d represents the user's private key and P represents the user's public key.

[0062] Step S13: Use the first hash function to perform hash calculation on the current message to obtain a corresponding hash value.

[0063] In this embodiment, after determining the current public-private key pair, in the random number and proof generation stage, the first hash function is used to perform a hash calculation on the current message m to obtain a corresponding hash value. For example, the hash value of the message m is calculated using the first hash function, that is, Q=H1(m), where Q represents the hash value.

[0064] Step S14: Utilize the second hash function and perform hash calculation based on the randomly selected intermediate value, the generator and the hash value to obtain the corresponding first partial proof value.

[0065] In this embodiment, the first part of the proof value is calculated by using the second hash function, and performing a hash calculation based on the randomly selected intermediate value, the generator, and the hash value to obtain the corresponding first part of the proof value. Specifically, the randomly selected intermediate value and the generator are point-multiplied to obtain the corresponding first point-multiplication result, and the intermediate value and the hash value are point-multiplied to obtain the corresponding second point-multiplication result; the first point-multiplication result and the second point-multiplication result are hashed using the second hash function to obtain the corresponding first part of the proof value. For example, the intermediate value k is randomly selected, and The intermediate value is point multiplied with the generator G and the hash value respectively to obtain the corresponding first point product result and the second point product result, and then the first point product result and the second point product result are hashed using the second hash function to obtain the corresponding first partial proof value r, that is, r=H2(k·G, k·Q).

[0066] Step S15: Determine a corresponding second partial proof value using the private key, the intermediate value, the first partial proof value, and the order of the generator.

[0067] In this embodiment, the corresponding second part of the proof value is determined using the private key, the intermediate value, the first part of the proof value, and the order of the generator. Specifically, the private key, the intermediate value, the first part of the proof value, and the order of the generator are calculated using a first preset formula to obtain the corresponding second part of the proof value; the preset formula is s = ((1+d)-1·(kc-r·d)) mod q.

[0068] Among them, s represents the second part of the proof value, d represents the private key, k represents the intermediate value, r represents the first part of the proof value, and q represents the order of the generator.

[0069] Step S16: Determine the corresponding third part proof value using the private key and the hash value.

[0070] In this embodiment, the corresponding third part of the proof value is determined using the private key and the hash value. Specifically, the private key and the hash value are multiplied to obtain the corresponding third part of the proof value. For example, the third part of the proof value V is calculated, that is, V=d·Q.

[0071] Step S17: Use a third hash function to perform hash calculation on the third part of the proof value to obtain a corresponding verifiable random number, and construct a corresponding proof value set based on the first part of the proof value, the second part of the proof value and the third part of the proof value.

[0072] In this embodiment, a third hash function is used to perform a hash calculation on the third part of the proof value to obtain a corresponding verifiable random number, for example, to calculate a verifiable random number v, ie, v=H3(V).

[0073] In this embodiment, after calculating the first part of the proof value, the second part of the proof value and the third part of the proof value, a corresponding proof value set, i.e. (V, r, s), is constructed based on the first part of the proof value, the second part of the proof value and the third part of the proof value.

[0074] It can be seen that in the embodiment of the present invention, the verifiable random function constructed based on the SM2 elliptic curve public key cryptographic algorithm is used to generate the corresponding verifiable random number and proof value set, which can meet the national security requirements for independent and controllable verifiable random functions, and can ensure both the correctness and the verifiability of the hash result.

[0075] After generating the random number v and the proof value (V, r, s), corresponding verification can be performed. The embodiment of the present invention also discloses a specific verification method, see Figure 2 As shown, the method may include:

[0076] Step S21: Determine whether the process of using the third hash function to perform hash calculation on the third part of the proof value in the proof value set to obtain the verifiable random number is established.

[0077] In this embodiment, for the verifiable random number v, message m, and proof value (V, r, s), it is first determined whether the process of using the third hash function to perform hash calculation on the third part of the proof value in the proof value set to obtain the verifiable random number is established, that is, whether v=H3(V) is established. If not, it can be directly determined that the current verification fails.

[0078] Step S22: If established, the first hash function is reused to perform hash calculation on the message to obtain a corresponding target hash value for verification.

[0079] In this embodiment, when judging whether the process of using the third hash function to perform hash calculation on the third part of the proof value in the proof value set to obtain the verifiable random number is established, if it is established, that is, v=H3(V), then the first hash function is reused to perform hash calculation on the message to obtain the corresponding target hash value for verification, that is, Q′=H1(m).

[0080] Step S23: Use a second preset formula to calculate the first part of the proof value and the second part of the proof value in the proof value set, the generator and the public key to obtain a corresponding first verification value; wherein the second preset formula is U1=s·G+(r+s)·P, and U1 represents the first verification value, r represents the first part of the proof value in the proof value set, s represents the second part of the proof value in the proof value set, G represents the generator, and P represents the public key.

[0081] It can be understood that in the key pair generated in the key generation phase, the private key is used to generate a partial hash value, and the public key is used to verify the hash value.

[0082] Step S24: Use a third preset formula to calculate the first part of the proof value, the second part of the proof value, the third part of the proof value and the target hash value in the proof value set to obtain a corresponding second verification value; wherein the third preset formula is U2=s·Q′+(r+s)·V, and U2 represents the second verification value, Q′ represents the target hash value, r represents the first part of the proof value in the proof value set, s represents the second part of the proof value in the proof value set, and V represents the third part of the proof value in the proof value set.

[0083] Step S25: Use the second hash function to perform hash calculation on the first verification value and the second verification value to obtain a corresponding target partial proof value.

[0084] In this embodiment, after calculating the first verification value and the second verification value using the newly generated target hash value, partial proof values ​​in the proof value set, the generator and the public key, the first verification value and the second verification value are hashed using the second hash function to obtain the corresponding target partial proof value, that is, r′=H2(U1, U2), where r′ represents the target partial proof value.

[0085] Step S26: Determine whether the target partial proof value is consistent with the first partial proof value in the proof value set to obtain a corresponding judgment result.

[0086] In this embodiment, after determining the target partial proof value for verification, it is determined whether the target partial proof value is consistent with the first partial proof value in the proof value set to obtain a corresponding judgment result, that is, whether r=r′ holds.

[0087] Step S27: Determine whether the verifiable random number is valid based on the judgment result.

[0088] In this embodiment, whether the verifiable random number is valid is determined based on the judgment result. If the judgment result shows that the target partial proof value is consistent with the first partial proof value in the proof value set, the verifiable random number is determined to be valid and the verification passes; if the judgment result shows that the target partial proof value is inconsistent with the first partial proof value in the proof value set, the verifiable random number is determined to be invalid and the verification fails.

[0089] For example, see Figure 3 As shown, the system initialization is completed to obtain the corresponding system parameters After generating the corresponding public-private key pair (P, d), for the current message m, in the proof part, the process of generating a verifiable random number and proof value is as follows:

[0090] (a) Calculate the hash value Q = H1(m) for message m;

[0091] (b) Randomly select an intermediate value k, and Calculate the partial proof value r = H2(k·G, k·Q);

[0092] (c) Calculate the partial proof value s = ((1 + d) -1 ·(kr·d))mod q;

[0093] (d) Calculate the partial proof value V = d·Q;

[0094] (e) Calculate a verifiable random number v = H3(V);

[0095] (f) Output a verifiable random number v and a proof value (V, r, s).

[0096] In the verification part, the output verifiable random number v and the proof value (V, r, s), as well as the message m are used for verification. The specific verification process is as follows:

[0097] (a) Determine whether v = H3(V) holds. If not, output a preset symbol ⊥ to indicate that the current verification fails;

[0098] (b) Recalculate Q′=H1(m);

[0099] (c) Calculate U1 = s·G + (r + s)·P;

[0100] (d) Calculate U2 = s·Q′ + (r + s)·V;

[0101] (e) Calculate r′=H2(U1, U2);

[0102] (f) Determine whether r=r′ holds. If r=r′ holds, determine that the verifiable random number is valid and the verification is successful; if r=r′ does not hold, determine that the verifiable random number is invalid and the verification is unsuccessful.

[0103] In addition, in order to realize batch verification of multiple results and improve verification efficiency, it is necessary to adjust the proof value set, that is, to construct a corresponding proof value set based on the first dot product result, the second dot product result, the second part of the proof value and the third part of the proof value, that is, (V, A, B, s), where A = k·G, B = k·Q. It should be pointed out that r in the original proof value set (V, r, s) belongs to The elements of In order to realize batch verification of multiple results, A and B in the proof value set (V, A, B, s) constructed are both points on the elliptic curve. The purpose of adjusting the original proof value set (V, r, s) to (T, A, B, s) is to improve the verification efficiency.

[0104] For example, for multiple random numbers v1, ..., v generated n , multiple proof values ​​(V1, A1, B1, s1), ..·, (V n , A n , B n ,s n ), the current multiple messages m1, ..., m n The batch verification process may include: for all i∈[1,n], firstly determining whether the process of using the third hash function to perform hash calculation on the third part of the proof value in the i-th proof value set to obtain the i-th verifiable random number is established, that is, determining whether v i =H3(V i ) is true. If not, the i-th random number can be directly determined to be invalid. If true, then for all i∈[1,n], the i-th message is hashed using the first hash function to obtain the corresponding i-th target hash value for verification, i.e., Q′ i =H1(m i ), and use the calculation r i =H2(A i , B i ), then pick 2 random numbers judge Is it true? If true, the i-th verifiable random number is determined to be valid and the verification is passed, and 1 is returned; if not true, the i-th verifiable random number is determined to be invalid and the verification is not passed. It should be pointed out that represents an elliptic curve multi-scalar multiplication algorithm, and an existing optimization algorithm, such as the Strauss-Shamir elliptic curve multi-scalar optimization algorithm, can be used to improve computational efficiency, where O is the infinity point of the elliptic curve.

[0105] For example, see Figure 4 As shown, when i = 1, the system initialization is completed and the corresponding system parameters are obtained. After generating the corresponding public-private key pair (P, d), for the current message m, in the proof part, the process of generating a verifiable random number and proof value is as follows:

[0106] P1: Calculate the hash value Q = H1(m) for message m;

[0107] P2: Randomly select an intermediate value k, and Calculating partial proof values

[0108] r = H2(k·G, k·Q);

[0109] P3: Calculate the partial proof value s = ((1+d) -1 ·(kr·d))mod q;

[0110] P4: Calculate the partial proof value V = d·Q;

[0111] P5: Calculate the verifiable random number v = H3(V);

[0112] P6: Output a verifiable random number v and a proof value (V, A, B, s).

[0113] In the verification part, when i=1, the output verifiable random number v and the proof value (V, A, B, s), as well as the message m are used for verification. The specific verification process is as follows:

[0114] V1: Determine whether v=H3(V) is true. If not, output the preset symbol ⊥ to indicate that the current verification fails;

[0115] V2: recalculate Q′=H1(m);

[0116] V3: recalculate r′=H2(A, B);

[0117] V4: Determine whether A=s·G+(r′+s)·P holds; if not, determine that the verifiable random number is invalid, and the verification fails, and return 0;

[0118] V5: Determine whether B=s·Q′+(r′+s)·V holds; if not, determine that the verifiable random number is invalid, and the verification fails, and return 0;

[0119] V6: If the above judgments are all true, the verifiable random number is determined to be valid, and the verification is passed, and 1 is returned.

[0120] Correspondingly, the embodiment of the present invention also discloses a verifiable random function construction device based on SM2, see Figure 5 As shown, the device comprises:

[0121] A construction module 11 is used to construct a system parameter set; the system parameter set includes a finite field, the number of elements in the finite field, elliptic curve parameters, an alpha group, any generator in the alpha group, the order of the generator, a first hash function, a second hash function, and a third hash function;

[0122] A first calculation module 12, used to calculate a corresponding public key using a randomly selected user private key and the generator in the system parameter set;

[0123] A second calculation module 13, configured to perform a hash calculation on the current message using the first hash function to obtain a corresponding hash value;

[0124] A first proof value determination module 14, configured to use the second hash function and perform a hash calculation based on the randomly selected intermediate value, the generator and the hash value to obtain a corresponding first partial proof value;

[0125] A second proof value determination module 15, configured to determine a corresponding second proof value using the private key, the intermediate value, the first proof value, and the order of the generator;

[0126] A third proof value determination module 16, configured to determine a corresponding third partial proof value using the private key and the hash value;

[0127] A verifiable random number generating module 17, configured to perform a hash calculation on the third part of the proof value using a third hash function to obtain a corresponding verifiable random number;

[0128] The proof value set construction module 18 is used to construct a corresponding proof value set based on the first part of the proof value, the second part of the proof value and the third part of the proof value.

[0129] It can be seen from the above that the verifiable random function constructed based on the SM2 elliptic curve public key cryptographic algorithm in the embodiment of the present invention generates a corresponding verifiable random number and proof value set, which can meet the country's security requirements for independent and controllable verifiable random functions, and can ensure both the correctness and verifiability of the hash result.

[0130] In some specific embodiments, the first calculation module 12 may specifically include:

[0131] The public key calculation unit is used to perform point multiplication on a randomly selected user private key and the generator in the system parameter set to obtain a corresponding public key.

[0132] In some specific embodiments, the first certification value determination module 14 may specifically include:

[0133] A first dot product unit, used for performing a dot product on the randomly selected intermediate value and the generator to obtain a corresponding first dot product result;

[0134] A second dot product unit, used for performing a dot product on the intermediate value and the hash value to obtain a corresponding second dot product result;

[0135] The first proof value determining unit is used to use the second Hash function to perform a Hash calculation on the first dot product result and the second dot product result to obtain a corresponding first partial proof value.

[0136] In some specific embodiments, the second proof value determination module 15 may specifically include:

[0137] The second proof value determination unit is used to calculate the private key, the intermediate value, the first part of the proof value, and the order of the generator using a first preset formula to obtain a corresponding second part of the proof value; the preset formula is s=((1+d) -1 ·(kr·d))mod q;

[0138] Among them, s represents the second part of the proof value, d represents the private key, k represents the intermediate value, r represents the first part of the proof value, and q represents the order of the generator.

[0139] In some specific embodiments, the third proof value determination module 16 may specifically include:

[0140] The third proof value determination unit is used to perform a point multiplication on the private key and the hash value to obtain a corresponding third partial proof value.

[0141] In some specific embodiments, the SM2-based verifiable random function construction device may further include:

[0142] A first judgment module is used to judge whether a process of performing hash calculation on the third part of the proof value in the proof value set by using the third hash function to obtain the verifiable random number is established;

[0143] a target hash value determination module, configured to, when the process of performing hash calculation on the third part of the proof value in the proof value set by using the third hash function to obtain the verifiable random number is established, re-use the first hash function to perform hash calculation on the message to obtain a corresponding target hash value for verification;

[0144] a first verification value determination module, configured to calculate the first part of the proof value and the second part of the proof value in the proof value set, the generator, and the public key using a second preset formula to obtain a corresponding first verification value; wherein the second preset formula is U1=s·G+(r+s)·P, and U1 represents the first verification value, r represents the first part of the proof value in the proof value set, s represents the second part of the proof value in the proof value set, G represents the generator, and P represents the public key;

[0145] A second verification value determination module, configured to calculate the first part of the proof value, the second part of the proof value, the third part of the proof value and the target hash value in the proof value set by using a third preset formula to obtain a corresponding second verification value; wherein the third preset formula is U2=s·Q′+(r+s)·V, and U2 represents the second verification value, Q′ represents the target hash value, r represents the first part of the proof value in the proof value set, s represents the second part of the proof value in the proof value set, and V represents the third part of the proof value in the proof value set;

[0146] a target partial proof value determination module, configured to perform a hash calculation on the first verification value and the second verification value using the second hash function to obtain a corresponding target partial proof value;

[0147] A second judgment module is used to judge whether the target partial proof value is consistent with the first partial proof value in the proof value set to obtain a corresponding judgment result;

[0148] A third judgment module is used to determine whether the verifiable random number is valid based on the judgment result. In some specific embodiments, the third judgment module may specifically include:

[0149] A first determination unit, configured to determine that the verifiable random number is valid and the verification is passed when the determination result indicates that the target partial proof value is consistent with the first partial proof value in the proof value set;

[0150] The second determination unit is configured to determine that the verifiable random number is invalid and the verification fails when the determination result indicates that the target partial proof value is inconsistent with the first partial proof value in the proof value set.

[0151] Furthermore, an embodiment of the present invention also provides an electronic device. Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the diagram cannot be regarded as any limitation on the scope of application of the present invention.

[0152] Figure 6 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present invention. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the method for constructing a verifiable random function based on SM2 disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0153] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present invention, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0154] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0155] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the SM2-based verifiable random function construction method executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.

[0156] Furthermore, an embodiment of the present invention also discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the steps of the method for constructing a verifiable random function based on SM2 disclosed in any of the aforementioned embodiments are implemented.

[0157] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0158] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device 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 device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0159] The above is a detailed introduction to the method, device, equipment and storage medium for constructing a verifiable random function based on SM2 provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for selecting a block node based on a verifiable random function, characterized in that: The verifiable random function is a function constructed based on the SM2 algorithm; wherein the method includes: Constructing a system parameter set; the system parameter set includes a finite field, the number of elements in the finite field, elliptic curve parameters, an alpha group, any generator in the alpha group, the order of the generator, a first hash function, a second hash function, and a third hash function; Calculating a corresponding public key using a randomly selected user private key and the generator in the system parameter set; Performing a hash calculation on the current message using the first hash function to obtain a corresponding hash value; Using the second hash function, and performing a hash calculation based on the randomly selected intermediate value, the generator, and the hash value to obtain a corresponding first partial proof value; Determining a corresponding second partial proof value using the private key, the intermediate value, the first partial proof value, and the order of the generator; Determining a corresponding third part of the proof value using the private key and the hash value; Performing a hash calculation on the third partial proof value using a third hash function to obtain a corresponding verifiable random number, and constructing a corresponding proof value set based on the first partial proof value, the second partial proof value, and the third partial proof value; Selecting a block producing node from the blockchain based on the verifiable random function that outputs the verifiable random number and the set of proof values; The step of using the second hash function and performing a hash calculation based on the randomly selected intermediate value, the generator, and the hash value to obtain the corresponding first partial proof value includes: Performing a dot product of the randomly selected intermediate value and the generator to obtain a corresponding first dot product result, and performing a dot product of the intermediate value and the hash value to obtain a corresponding second dot product result; Performing a hash calculation on the first dot product result and the second dot product result using the second hash function to obtain a corresponding first partial proof value; The determining of the corresponding second partial proof value using the private key, the intermediate value, the first partial proof value, and the order of the generator includes: The private key, the intermediate value, the first part of the proof value, and the order of the generator are calculated using a first preset formula to obtain the corresponding second part of the proof value; the preset formula is s=((1+d) -1 ·(kr·d))mod q; Wherein, s represents the second part of the proof value, d represents the private key, k represents the intermediate value, r represents the first part of the proof value, and q represents the order of the generator; The determining of the corresponding third part of the proof value using the private key and the hash value includes: The private key and the hash value are multiplied to obtain the corresponding third part of the proof value.

2. The method for selecting a block node based on a verifiable random function according to claim 1, characterized in that: The calculating a corresponding public key using a randomly selected user private key and the generator in the system parameter set includes: Perform a point multiplication on the randomly selected user private key and the generator in the system parameter set to obtain the corresponding public key.

3. The method for selecting a block node based on a verifiable random function according to claim 1 or 2, characterized in that: Also includes: Determining whether a process of performing hash calculation on the third part of the proof values ​​in the proof value set using the third hash function to obtain the verifiable random number is established; If so, reusing the first hash function to perform hash calculation on the message to obtain a corresponding target hash value for verification; Calculating the first partial proof value and the second partial proof value in the proof value set, the generator, and the public key using a second preset formula to obtain a corresponding first verification value; wherein the second preset formula is U1=s·G+(r+s)·P, where U1 represents the first verification value, r represents the first partial proof value in the proof value set, s represents the second partial proof value in the proof value set, G represents the generator, and P represents the public key; Calculating the first partial proof value, the second partial proof value, the third partial proof value, and the target hash value in the proof value set using a third preset formula to obtain a corresponding second verification value; wherein the third preset formula is U2=s·Q′+(r+s)·V, where U2 represents the second verification value, Q′ represents the target hash value, r represents the first partial proof value in the proof value set, s represents the second partial proof value in the proof value set, and V represents the third partial proof value in the proof value set; Performing a hash calculation on the first verification value and the second verification value using the second hash function to obtain a corresponding target partial proof value; Determining whether the target partial certification value is consistent with the first partial certification value in the certification value set to obtain a corresponding determination result; Based on the judgment result, it is determined whether the verifiable random number is valid.

4. The method for selecting a block node based on a verifiable random function according to claim 3, characterized in that: The determining whether the verifiable random number is valid based on the judgment result includes: If the judgment result indicates that the target partial proof value is consistent with the first partial proof value in the proof value set, then the verifiable random number is determined to be valid and the verification is passed; If the judgment result indicates that the target partial proof value is inconsistent with the first partial proof value in the proof value set, the verifiable random number is determined to be invalid and the verification fails.

5. A block node selection device based on a verifiable random function, characterized in that: The verifiable random function is a function constructed based on the SM2 algorithm; wherein the device includes: A construction module is configured to construct a system parameter set, wherein the system parameter set includes a finite field, the number of elements in the finite field, elliptic curve parameters, an alpha group, any generator in the alpha group, the order of the generator, a first hash function, a second hash function, and a third hash function; A first calculation module, configured to calculate a corresponding public key using a randomly selected user private key and the generator in the system parameter set; A second calculation module, configured to perform a hash calculation on the current message using the first hash function to obtain a corresponding hash value; a first proof value determination module, configured to use the second hash function to perform a hash calculation based on the randomly selected intermediate value, the generator, and the hash value to obtain a corresponding first partial proof value; a second proof value determination module, configured to determine a corresponding second partial proof value using the private key, the intermediate value, the first partial proof value, and the order of the generator; A third proof value determination module, configured to determine a corresponding third partial proof value using the private key and the hash value; a verifiable random number generation module, configured to perform a hash calculation on the third partial proof value using a third hash function to obtain a corresponding verifiable random number; a proof value set construction module, configured to construct a corresponding proof value set based on the first part of the proof value, the second part of the proof value, and the third part of the proof value; Furthermore, the block-producing node selection device based on a verifiable random function is specifically configured to select a block-producing node from the blockchain based on the verifiable random function that outputs the verifiable random number and the proof value set; The first proof value determination module is specifically configured to: perform a dot product of the randomly selected intermediate value and the generator to obtain a corresponding first dot product result, and perform a dot product of the intermediate value and the hash value to obtain a corresponding second dot product result; and perform a hash calculation on the first dot product result and the second dot product result using the second hash function to obtain a corresponding first partial proof value; The second proof value determination module is specifically configured to calculate the corresponding second proof value by using a first preset formula on the private key, the intermediate value, the first partial proof value, and the order of the generator; the preset formula is s=((1+d) -1 (kr·d)) mod q; where s represents the second partial proof value, d represents the private key, k represents the intermediate value, r represents the first partial proof value, and q represents the order of the generator; The third proof value determination module is specifically configured to perform a point multiplication on the private key and the hash value to obtain a corresponding third part of the proof value.

6. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the method for selecting a block producer node based on a verifiable random function as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that Used to store a computer program; wherein, when the computer program is executed by a processor, the steps of the method for selecting a block node based on a verifiable random function according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Block-out node determination method and device of block chain, equipment and medium

    CN112883106A

  • Special medical food supervision method and system based on block chain technology

    CN114862418A

  • Implementation method of block chain election based on verifiable random function

    CN115834096A

  • Verifiable random function construction method and device based on SM2

    CN116827545A