SM2 key generation method and related methods, computer equipment and storage medium

Through the SM2 key generation method and public key recovery method, the elliptic curve parameters shared by KGC and users are used to generate signature and encryption private keys, which solves the problem of certificate management and SM9 algorithm calculation overhead, and achieves efficient key generation and use. Reduces computing resource consumption.

CN115549905BActive Publication Date: 2024-09-24BEIJING WUZI TIANSHU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211241725.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-11
Publication Date
2024-09-24
Estimated Expiration
2042-10-11

AI Technical Summary

Technical Problem

The traditional certificate-based public key infrastructure (PKI) system and SM9 identification cryptographic algorithm cause high computing overhead for user-side computing devices in application scenarios such as vehicle networks and the Internet of Things, making it difficult to effectively manage certificates and keys.

Method used

Using the SM2 key generation method, the elliptic curve parameters are shared with users through the Key Generation Center (KGC), the user's signature private key and encryption private key are generated, and the public key is restored through the user's identifiable identification and the KGC's master public key, simplifying Certificate management to reduce computing overhead.

Benefits of technology

It realizes the distinction between signature keys and encryption keys, avoids the high computing requirements of certificate chain verification, saves computing resources, and distinguishes the use of signature and encryption keys through private key generators to avoid mixing and improve system efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115549905B
    Figure CN115549905B
Patent Text Reader

Abstract

The present invention provides an SM2 key generation method and a corresponding public key recovery method, a digital signature generation method, a digital signature verification method, a data encryption method, a data decryption method, and provides corresponding computer equipment and a computer-readable storage medium. The SM2 key generation method comprises the following steps: step 1, step 2 and / or step 3, wherein step 1. establishes system parameters; step 2. generates a user signature private key ds based on the system parameters. A ; Step 3. Generate a user encryption private key based on the system parameters A The present invention uses the user's identifiable identification and the KGC system master key to jointly calculate the user's signature / encryption key, saving a lot of computing resources; by using a private key generator to restore the signature public key and encryption public key, the generation and use of the signature key and encryption key are distinguished at the algorithm level to avoid mixing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security technology, and in particular to an SM2 key generation method and related methods, computer equipment and storage media. Background Art

[0002] The SM2 cryptographic algorithm is a public key cryptographic algorithm issued by the National Cryptography Administration. The traditional certificate-based Public Key Infrastructure (PKI) system is a system that uses digital certificates and a trusted third party to associate public keys, user identity information, and identifiable identifiers.

[0003] However, using a certificate-based PKI system, certificate management has high requirements for the computing devices on the user side. In application scenarios such as vehicle networks and the Internet of Things, using a certificate-based PKI system will bring large computing overhead to the computing devices on the user side. For this reason, the identity-based cryptographic algorithm system uses the user's identifiable identity as the user's public key, such as the SM9 identity cryptographic algorithm issued by the National Cryptography Administration, to simplify certificate management. However, the SM9 identity cryptographic algorithm itself also has high requirements for computing overhead.

[0004] In order to overcome the high computational overhead in certificate management and SM9 identification cryptographic algorithm, the present invention provides a method for generating SM2 keys and signature verification, encryption and decryption for users based on user identification and a key generation center (KGC), using the SM2 public key algorithm and simplifying the high computational overhead brought by certificate management. Summary of the invention

[0005] In view of this, the present invention provides an SM2 key generation method and related methods, computer equipment and storage media to solve the problem of high computational overhead in the above-mentioned certificate management and SM9 identification cryptographic algorithm.

[0006] The SM2 key generation method provided by the present invention comprises the following steps: step 1, step 2 and / or step 3,

[0007] in,

[0008] Step 1. Establish system parameters;

[0009] Step 2. Generate user signature private key ds based on the system parameters A ;

[0010] Step 3. Generate a user encryption private key based on the system parameters A .

[0011] Further, the step 1 includes the following steps:

[0012] S11. The user and the key generation center KGC share the elliptic curve E(Fq) parameters G and n of the SM2 algorithm, where E(Fq) is an elliptic curve defined on a finite field Fq, G represents a base point of order n on the elliptic curve E(Fq), and n is a prime number;

[0013] S12. The key generation center KGC generates the system master private key ms and the system master public key P Pub , where the system master public key P Pub =[ms]×G, the meaning of the square brackets [] represents the doubling operation on the elliptic curve E(Fq), the system master public key P Pub is a point on the elliptic curve E(Fq), and the meanings of the square brackets [] in the following calculation formulas all represent the doubling operation of the point on the elliptic curve E(Fq);

[0014] S13. The key generation center KGC randomly selects a first private key generator kid 0 ∈[1,n-1] and the second private key generator kid 1 ∈[1,n-1], and kid 0 and kid 1 Not equal;

[0015] S14. The key generation center KGC publishes the system master public key P Pub 、The first private key generator kid 0 And the second private key generator kid 1 .

[0016] Further, the step 2 comprises the following steps:

[0017] S21. The user generates a first random number r A ∈[1,n-1], calculate U A =[r A ]×G;

[0018] S22. The user sends the U A and the user's identifiable ID A Submit to the key generation center KGC;

[0019] S23. The key generation center KGC uses the system master private key ms to calculate the first part of the key value t A And the first public key to restore data W A , and the first part of the key value t A And the first public key to restore data W A Send it to the user and return the first ciphertext Cipher to the user 1 Or the second ciphertext Cipher2 ;

[0020] S24. The user receives the first ciphertext Cipher 1 Or the second ciphertext Cipher 2 , after decryption, the first part of the key value t is obtained A and the first public key to restore data W A , calculate H A =H 256 (ENTL A ‖ID A ‖x Pub ‖y Pub ) and h A =H 256 (x W ‖y W ‖H A ), calculate the user signature private key ds A =(h A ×t A +r A )mod n, save the user signature private key ds A And the first public key to restore data W A , where H 256 is a hash function with an output of 256 bits; ENTL A The identifiable ID is represented by 2 bytes A The byte length of the string; ‖ represents the concatenation of byte strings; x Pub ,y Pub is the system master public key P Pub The coordinates of W ,y W Recover data W for the first public key A coordinates; x mod y represents the remainder of x with respect to y.

[0021] Further, in step S23, the calculation includes the following steps:

[0022] A1. Calculate the H A =H 256 (ENTL A ‖ID A ‖x Pub ‖y Pub ), and convert to a byte string;

[0023] A2. Generate a second random number w∈[1, n-1];

[0024] A3. Calculate the first public key to restore data W A =[w]×G+U A +[kid 0]×P pub ;

[0025] A4. Calculate the h A =H 256 (x W ‖y W ‖H A ), and convert to a byte string;

[0026] A5. The h A Convert to an integer. If the converted integer is 0, go to step A2;

[0027] A6. Calculate the first part of the key value t A =(h A -1 ×(w+kid 0 ×ms)+kid 0 ×ms)modn, and then the key generation center KGC converts the first part of the key value t A and the first public key to restore data W A Sending to the user, including sending method B or sending method C,

[0028] The sending method B comprises the following steps:

[0029] B1. Calculate K = [ms] × U A , the first key k = KDF(x K ||y K , 128), where x K ,y K is the coordinate of K, KDF is a key derivation function, and the first key k is a 128-bit byte string generated by the key derivation function;

[0030] B2. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W According to the conversion to byte string;

[0031] B3. Use the first key k and SM4 cryptographic algorithm to encrypt the plaintext t A ||x W ||y W Encrypt to obtain the first ciphertext Cipher 1 =SM4_ENC(k, t A ||x W ||y W ), and the first ciphertext Cipher 1 Sent to the user, where SM4_ENC(k, tA ||x W ||y W ) indicates that the plain text t is encrypted using the SM4 encryption algorithm and the first 128-bit key k. A ||x W ||y W Perform encryption calculation and output ciphertext;

[0032] The sending method C comprises the following steps:

[0033] C1. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to byte string;

[0034] C2. Use the U A As the third public key, and use the SM2 encryption algorithm to encrypt the plaintext t A ||x W ||y W After encryption, the second ciphertext Cipher is obtained 2 =SM2_ENC(U A , t A ||x W ||y W ), and the second ciphertext Cipher 2 Sent to the user, where SM2_ENC(U A , t A ||x W ||y W ) indicates the use of the SM2 encryption algorithm and the third public key U A , for the plaintext t A ||x W ||y W Perform encryption calculation and output ciphertext,

[0035] In the step S24, when performing the decryption,

[0036] If the sending method B is used in step S23, the decryption method is method D, which includes the following steps:

[0037] D1. Calculate K' = [r A ]×P Pub , the second key k'=KDF(x K’ ||y K’ , 128), where x K’ ,y K’is the coordinate of K', the second key k' is a 128-bit byte string generated by the key derivation function;

[0038] D2. Use the second key k' and SM4 cryptographic algorithm to perform the first ciphertext Cipher 1 Decrypt to get the plaintext:

[0039] t A ||x W ||y W =SM4_DEC(k', Cipher 1 ),

[0040] Among them, SM4_DEC(k', Cipher 1 ) indicates that the first ciphertext Cipher is decrypted using the SM4 decryption algorithm and the second 128-bit key k'. 1 Perform decryption calculation and output plaintext;

[0041] D3. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to an integer, thereby decrypting to obtain the first part of the key value t A and the first public key to restore data W A ;

[0042] If the sending method C is used in step S23, the decryption method is method E, which includes the following steps:

[0043] E1. Use the first random number r A As the first private key, and use the SM2 decryption algorithm to decrypt the second ciphertext Cipher 2 After decryption, we get the plaintext:

[0044] t A ||x W ||y W =SM2_DEC(r A , Cipher 2 );

[0045] Among them, SM2_DEC(r A , Cipher 2 ) indicates the use of the SM2 decryption algorithm and the first private key r A , for the second ciphertext Cipher 2 Perform decryption calculation and output plaintext;

[0046] E2. The first part of the key value tA And the first public key to restore data W A The coordinate x W ,y W Convert to an integer, thereby decrypting to obtain the first part of the key value t A and the first public key to restore data W A .

[0047] Further, the step three includes the following steps:

[0048] S31. The user generates a third random number rr A ∈[1,n-1], calculate UU A =[rr A ]×G;

[0049] S32. The user sends the UU A and the user's identifiable ID A Submit to the key generation center KGC;

[0050] S33. The key generation center KGC uses the system master private key ms to calculate the second part of the signature key value tt A and the second public key to restore data WW A , and the second part of the signature key value tt A and the second public key to restore data WW A Send it to the user and return the third ciphertext Cipher to the user 3 Or the fourth ciphertext Cipher 4 ;

[0051] S34. The user receives the third ciphertext Cipher 3 Or the fourth ciphertext Cipher 4 , after decryption, the second part of the signature key value tt is obtained A and the second public key to restore data WW A , calculate hh A =H 256 (x WW ‖y WW ‖H A ), and then calculate the user encryption private key de A =(hh A ×tt A +rr A )modn, and save the user encrypted private key de A and the second public key to restore data WW A , where x WW ,y WW Recover data WW for the second public key A The coordinates of .

[0052] Further, in step S33, the calculation includes the following steps:

[0053] G1. Calculate the H A =H 256 (ENTL A ‖ID A ‖x Pub ‖y Pub );

[0054] G2. Generate a fourth random number ww∈[1, n-1];

[0055] G3. Calculate the second public key to restore data WW A =[ww]×G+UU A +[kid 1 ]×P pub ;

[0056] G4. Calculate hh A =H 256 (x WW ‖y WW ‖H A ), where x WW ,y WW Recover data WW for the second public key A The coordinates of and converted to a byte string;

[0057] G5. The hh A Convert to an integer. If the converted integer is 0, go to step G2;

[0058] G6. Calculate tt A =(hh A -1 ×(ww+kid 1 ×ms)+kid 1 × ms) mod n, and then the key generation center KGC converts the second part of the key value tt A and the second public key to restore data WW A Sending to the user, including sending method H or sending method I,

[0059] The sending method H comprises the following steps:

[0060] H1. Calculate KK = [ms] × UU A , the third key kk=KDF(x KK ||y KK , 128), where x KK ,y KKare the coordinates of KK, the third key kk is a 128-bit byte string generated by the key derivation function;

[0061] H2. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW and WW Convert to byte string;

[0062] H3. Using the third key kk and SM4 cryptographic algorithm for tt A ||x WW ||y WW Encrypt to obtain the third ciphertext Cipher 3 =SM4_ENC(kk, tt A ||x WW ||y WW ), and the third ciphertext Cipher 3 Sending to the user;

[0063] The sending method I comprises the following steps:

[0064] I1. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW and WW Convert to byte string;

[0065] I2. Use of the UU A As the fourth public key, and use the SM2 encryption algorithm to tt A ||x WW ||y WW After encryption, the fourth ciphertext Cipher is obtained 4 =SM2_ENC(UU A ,tt A ||x WW ||y WW ), and the fourth ciphertext Cipher 4 sent to the user,

[0066] The step S34 includes the following steps:

[0067] When performing the decryption,

[0068] If the sending method H is used in step S33, the decryption method is method J, which includes the following steps:

[0069] J1. Calculate KK' = [rr A ]×P Pub, the fourth key kk'=KDF(x KK’ ||y KK’ , 128), where x KK’ ,y KK’ are the coordinates of the KK', the fourth key kk' is a 128-bit byte string generated by the key derivation function;

[0070] J2. Use the fourth key kk' and SM4 cryptographic algorithm to the third ciphertext Cipher 3 Decrypt to get the plaintext

[0071] tt A ||x WW ||y WW =SM4_DEC(kk', Cipher 3 );

[0072] J3. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW ,y WW Converted to an integer, decrypted to obtain the second part of the key value tt A and the second public key to restore data WW A ;

[0073] If the sending method I is used in step S33, the decryption method is method K, which includes the following steps:

[0074] K1. Use the third random number rr A As the second private key, and use the SM2 decryption algorithm to decrypt the fourth ciphertext Cipher 4 After decryption, we get the plaintext

[0075] tt A ||x WW ||y WW =SM2_DEC(rr A , Cipher 4 );

[0076] K2. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW ,y WW Converted to an integer, decrypted to obtain the second part of the key value tt A and the second public key to restore data WW A .

[0077] The present invention also provides a public key recovery method, wherein the SM2 key generation method is used to generate a first public key P' A Or / and generate a second public key PP' A ,

[0078] in,

[0079] The first public key P' is generated A , is the user's identifiable ID A , the system master public key P of the key generation center KGC pub , the first public key restores data W A And the first private key generator kid 0 , generate the corresponding first public key P' A , including the following steps:

[0080] G1. Calculate H11 = H 256 (ENTL‖ID A ‖x Pub ‖y Pub ), where H 256 is a hash function with an output of 256 bits, ENTL is the identifiable ID represented by 2 bytes A The byte length of , ‖ represents the concatenation of byte strings, x Pub ,y Pub is the system master public key P Pub The coordinates of

[0081] G2. Restore the first public key to data W A The coordinate x W ,y W Convert to a byte string and calculate h11=H 256 (x W ‖y W ‖H11), and converting said h11 into an integer;

[0082] G3. Calculate P' A =W A +[kid 0 ×h11]×P pub ;

[0083] The second public key PP' is generated A The identifiable ID is used A , the system master public key P of the key generation center KGC pub , the second public key restores the data WW A And the second private key generator kid 1 , generate the corresponding second public key PP' A , including the following steps:

[0084] M1. Calculate H11 = H 256 (ENTL‖ID A ‖x Pub ‖y Pub );

[0085] M2. Restore data WW using the second public key A The coordinate x WW ,y WW Convert to a byte string and calculate h22 = H 256 (x WW ‖y WW ‖H11), and converting said h22 into an integer;

[0086] M3. Calculation of PP' A =WW A +[kid 1 ×h22]×P pub .

[0087] The present invention also provides an SM2 key generation method, wherein the above-mentioned public key recovery method is adopted, comprising the following steps:

[0088] S25. The user chooses to perform the first public key verification, including the following steps:

[0089] F1. Using the above public key recovery method, generate the first public key P' A ;

[0090] F2. Calculate P A =[d A ]×G;

[0091] F3. If P' A =P A , then the first public key verification succeeds, otherwise the first public key verification fails;

[0092] Or include the following steps:

[0093] S35. The user chooses to perform a second public key verification, including the following steps:

[0094] L1. Using the above public key recovery method, generate a second public key PP' A ;

[0095] L2. Calculate PP A =[de A ]×G;

[0096] L3. If PP' A =PP A , then the second public key verification succeeds, otherwise the second public key verification fails.

[0097] The present invention also provides a digital signature generation method, wherein the above-mentioned SM2 key generation method is used to calculate the digital signature of the signature data e.

[0098] The present invention also provides a digital signature verification method, wherein the above-mentioned public key recovery method is used to verify the signature value.

[0099] The present invention also provides a data encryption method, wherein the above-mentioned public key recovery method is used to encrypt the data plaintext.

[0100] The present invention also provides a data decryption method, wherein the SM2 key generation method mentioned above is used to decrypt the encrypted data ciphertext.

[0101] The present invention also provides a computer device, comprising a memory, a first processor, and a first computer program stored in the memory and executable on the first processor, wherein the first computer program implements one or more of the following methods when executed by the first processor:

[0102] The above-mentioned SM2 key generation method, public key recovery method, digital signature generation method, digital signature verification method, data encryption method, and data decryption method.

[0103] The present invention further provides a computer-readable storage medium for storing a second computer program, wherein the second computer program can be executed by at least one second processor to enable the at least one second processor to perform one or more of the following methods:

[0104] The above-mentioned SM2 key generation method, public key recovery method, digital signature generation method, digital signature verification method, data encryption method, and data decryption method.

[0105] Compared with the prior art, the present invention has the following beneficial effects:

[0106] 1. The present invention allows users to distinguish between signature keys and encryption keys through private key generators during the process of generating signature keys and encryption keys. Moreover, signature verifiers and data encryptors also need to use private key generators to restore signature public keys and encryption public keys, thereby distinguishing the generation and use of signature keys and encryption keys at the algorithm level to avoid mixing.

[0107] 2. The present invention saves a lot of computing resources. The present invention recovers and verifies the user's SM2 public key by using the user identification, public key recovery data and the master public key of KGC, thus avoiding the large amount of computing and network resources required for certificate-based certificate chain verification. BRIEF DESCRIPTION OF THE DRAWINGS

[0108] In order to more clearly illustrate the technical solutions in the present invention, 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 some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0109] Figure 1 A flow chart of the SM2 key generation method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0110] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

[0111] The following describes in detail an SM2 key generation method provided by the present invention in conjunction with the accompanying drawings.

[0112] Figure 1 FIG. 4 is a flow chart of a method for generating a SM2 key according to an embodiment of the present invention. Figure 1 As shown, the SM2 key generation method includes the following steps:

[0113] 1. Establish system parameters, including steps:

[0114] S11. The user and the key generation center (KGC) share the parameters G and n of the elliptic curve E(Fq) of the SM2 algorithm, where E(Fq) is an elliptic curve defined on a finite field Fq, G represents a base point of order n on the elliptic curve E(Fq), and n is a prime number. The specific values ​​of each parameter are pre-set according to the SM2 algorithm;

[0115] S12. The key generation center KGC generates the system master private key ms and the system master public key P Pub , where P Pub =[ms]×G, the square brackets [] represent the doubling operation on the elliptic curve E(Fq), P Pub is a point on the elliptic curve E(Fq). It should be noted that the square brackets [] in each calculation formula in the present invention represent the doubling operation of the point on the elliptic curve E(Fq);

[0116] S13. The key generation center KGC randomly selects the first private key generator kid 0 ∈[1,n-1] and the second private key generator kid1 ∈[1,n-1], and kid 0 and kid 1 Not equal, where the first private key generator is kid 0 It is used to generate the user signature private key; kid 1 Generator for user decryption private key, used to generate user decryption private key;

[0117] S14. The key generation center KGC publishes P Pub 、kid 0 and kid 1 .

[0118] 2. Based on the system parameters, generate the user signature private key, including the following steps:

[0119] S21. The user generates a first random number r A ∈[1,n-1], based on the first random number r A With G, calculate U A =[r A ]×G;

[0120] S22. The user will A and the user's identifiable ID A Submit to the key generation center KGC;

[0121] S23. The key generation center KGC uses the system master private key ms to calculate the first part of the key value t A And the first public key to restore data W A , and the first part of the key value t A And the first public key to restore data W A Sent to the user, the calculation specifically includes the following steps:

[0122] A1. Calculate H A =H 256 (ENTL A ‖ID A ‖x Pub ‖y Pub ) and converted to a byte string, where ENTL A A 2-byte identifiable ID A The byte length of the string; ‖ represents the concatenation of byte strings; x Pub ,y Pub is the system master public key P of KGC Pub The coordinates of H 256For a hash function with an output of 256 bits (such as the SM3 cryptographic algorithm), the conversion into a byte string is performed in accordance with the method given in 4.2.6 of the national standard GB / T32918.1-2016;

[0123] A2. Generate a second random number w∈[1, n-1];

[0124] A3. Based on the second random number w, calculate the first public key recovery data W A =[w]×G+U A +[kid 0 ]×P pub ;

[0125] A4. Recover data W based on the first public key A , calculate h A =H 256 (x W ‖y W ‖H A ) and convert it to a byte string, where x W ,y W Recover data W for the first public key A The coordinates are converted into byte strings according to the method given in 4.2.6 of the national standard GB / T32918.1-2016;

[0126] A5. A Convert to an integer. If the converted integer is 0, go to step A2.

[0127] Among them, h A The conversion to integer is carried out according to the method given in 4.2.3 of GB / T 32918.1-2016;

[0128] A6. Calculate the first part of the key value t A =(h A -1 ×(w+kid 0 ×ms)+kid 0 ×ms) mod n, and then the key generation center KGC converts the first part of the key value t A and the first public key to restore data W A Sent to the user, x mod y represents the remainder operation of x on y, including sending method B or sending method C,

[0129] The sending method B comprises the following steps:

[0130] B1. Calculate K = [ms] × U A , the first key k = KDF(x K ||yK , 128), where x K ,y K is the coordinate of K, KDF is the key derivation function in Section 5.4.3 of GB / T 32918.4-2016 - Information Security Technology SM2 Elliptic Curve Public Key Cryptography Algorithm Part 4: Public Key Cryptography Algorithm, and the first key k is a 128-bit byte string generated by the key derivation function;

[0131] B2. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to a byte string according to the method given in 4.2.6 of GB / T32918.1-2016;

[0132] B3. Use the first key k and SM4 cryptographic algorithm to encrypt the plaintext t A ||x W ||y W Encrypt to get the first ciphertext Cipher 1 =SM4_ENC(k, t A ||x W ||y W ), and the first ciphertext Cipher 1 Sent to the user, where SM4_ENC(k, t A ||x W ||y W ) indicates the use of the SM4 encryption algorithm defined in GB / T 32907-2016 - Information Security Technology SM4 Block Cipher Algorithm and a 128-bit first key k for plaintext t A ||x W ||y W Perform encryption calculation and output ciphertext;

[0133] The sending method C comprises the following steps:

[0134] C1. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to a byte string, wherein the conversion is performed according to the method given in 4.2.6 of GB / T 32918.1-2016;

[0135] C2.Use U A As the third public key, and use the SM2 encryption algorithm to encrypt the plaintext t A ||x W ||yW After encryption, the second ciphertext Cipher is obtained 2 =SM2_ENC(U A , t A ||x W ||y W ), and the second ciphertext Cipher 2 Sent to the user, where SM2_ENC(U A , t A ||x W ||y W ) indicates the use of the SM2 encryption algorithm and the third public key U in GB / T32918.4-2016 A , for the plaintext t A ||x W ||y W Perform encryption calculation and output ciphertext;

[0136] S24. The user receives the first ciphertext Cipher returned by the key generation center KGC 1 Or the second ciphertext Cipher 2 , after decryption, the first part of the key value t is obtained A and the first public key to restore data W A , calculate H A =H 256 (ENTL A ‖ID A ‖x Pub ‖y Pub ) and h A =H 256 (x W ‖y W ‖H A ), calculate the user signature private key ds A =(h A ×t A +r A )(mod n), save the user signature private key ds A And the first public key to restore data W A ,

[0137] When performing the decryption,

[0138] If sending method B is used in step S23, the decryption method is method D, which includes the following steps:

[0139] D1. Calculate K' = [r A ]×P Pub , the second key k'=KDF(x K’ ||y K’ , 128), where x K’,y K’ is the coordinate of K', the second key k' is a 128-bit byte string generated by a key derivation function;

[0140] D2. Use the second key k' and SM4 cryptographic algorithm to encrypt the first ciphertext Cipher 1 Decrypt to get the plaintext:

[0141] t A ||x W ||y W =SM4_DEC(k', Cipher 1 );

[0142] Among them, SM4_DEC(k', Cipher 1 ) indicates that the SM4 decryption algorithm in GB / T 32907-2016 and the 128-bit second key k' are used to decrypt the first ciphertext Cipher 1 Perform decryption calculation and output plaintext.

[0143] D3. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to an integer, thereby decrypting to obtain the first part of the key value t A and the first public key to restore data W A Among them, t A and x W ,y W The conversion to integer is carried out according to the method given in 4.2.3 of GB / T 32918.1-2016;

[0144] If the sending method C is used in step S23, the decryption method is method E, which includes the following steps:

[0145] E1. Use the first random number r A As the first private key, and use the SM2 decryption algorithm to decrypt the second ciphertext Cipher 2 After decryption, we get the plaintext:

[0146] t A ||x W ||y W =SM2_DEC(r A , Cipher 2 ),

[0147] Among them, SM2_DEC(r A , Cipher 2) indicates the use of the SM2 decryption algorithm and the first private key r in GB / T 32918.4-2016 A , for the second ciphertext Cipher 2 Perform decryption calculation and output plaintext;

[0148] E2. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to an integer, thereby decrypting to obtain the first part of the key value t A and the first public key to restore data W A Among them, t A and x W ,y W The conversion to integer is carried out according to the method given in 4.2.3 of GB / T 32918.1-2016;

[0149] S25. The user can choose whether to perform the first public key verification. If the first public key verification is not performed, the user signature private key generation is returned successfully. If the first public key verification is performed, the following steps are included:

[0150] F1. Use an identifiable ID A , the system master public key P of the key generation center KGC pub , the first public key restores data W A And the first private key generator kid 0 , generate the corresponding first public key P' A (ie, restore the first public key P' A ), the generation comprises the following steps:

[0151] G1. Calculate H11 = H 256 (ENTL‖ID A ‖x Pub ‖y Pub ), where ENTL is 2 bytes representing ID A The byte length of

[0152] G2. Use the method given in 4.2.6 of GB / T32918.1-2016 to restore the data W using the first public key A The coordinate x W ,y W Convert to a byte string and calculate h11=H 256 (x W ‖y W ‖H11), and convert h11 into an integer according to the method given in 4.2.3 of GB / T 32918.1-2016;

[0153] G3. Calculate P' A =W A +[kid 0 ×h11]×P pub ;

[0154] F2. Calculate P A =[d A ]×G;

[0155] F3. If P' A =P A , then the first public key verification succeeds, otherwise the first public key verification fails;

[0156] F4. If the first public key verification succeeds, it returns that the user signature private key generation is successful, otherwise it returns that the user signature private key generation fails.

[0157] 3. Based on the system parameters, generate a user encryption private key (this step and step 2 can be performed first or simultaneously, or only one can be performed as needed), including the following steps:

[0158] S31. The user generates a third random number rr A ∈[1,n-1], calculate UU A =[rr A ]×G;

[0159] S32. The user will A and the user's identifiable ID A Submit to the key generation center KGC;

[0160] S33. The key generation center KGC uses the system master private key ms to calculate the second part of the signature key value tt A and the second public key to restore data WW A , and tt A and WW A Sent to the user, wherein the calculation comprises the following steps:

[0161] G1. Calculate H A =H 256 (ENTL A ‖ID A ‖x Pub ‖y Pub );

[0162] G2. Generate a fourth random number ww∈[1, n-1];

[0163] G3. Based on the fourth random number ww, calculate the second public key recovery data WW A =[ww]×G+UU A+[kid 1 ]×P pub ;

[0164] G4. Restore data WW based on the second public key A , calculate hh A =H 256 (x WW ‖y WW ‖H A ), where x WW ,y WW Recover data WW for the second public key A The coordinates are converted into byte strings according to the method given in 4.2.6 of GB / T32918.1-2016;

[0165] G5. According to the method given in 4.2.3 of GB / T 32918.1-2016, hh A Convert to an integer. If the converted integer is 0, go to step G2;

[0166] G6. Calculate tt A =(hh A -1 ×(ww+kid 1 ×ms)+kid 1 ×ms)(mod n), and then the key generation center KGC converts the second part of the key value tt A and the second public key to restore data WW A Send to the user, including sending method H or sending method I,

[0167] The sending method H comprises the following steps:

[0168] H1. Calculate KK = [ms] × UU A , the third key kk=KDF(x KK ||y KK , 128), where x KK ,y KK is the coordinate of KK, where kk is a 128-bit byte string generated by a key derivation function;

[0169] H2. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW and WW Convert to a byte string according to the method given in 4.2.6 of GB / T32918.1-2016;

[0170] H3. Use the third key kk and SM4 cryptographic algorithm to clear the plaintext tt A||x WW ||y WW Encrypt to get the third ciphertext Cipher 3 =SM4_ENC(kk, tt A ||x WW ||y WW ), and the third ciphertext Cipher 3 Sent to the user, where SM4_ENC(kk, tt A ||x WW ||y WW ) indicates the use of the SM4 encryption algorithm defined in GB / T 32907-2016 - Information Security Technology SM4 Block Cipher Algorithm and a 128-bit third key kk for the plaintext tt A ||x WW ||y WW Perform encryption calculation and output ciphertext;

[0171] The sending method I comprises the following steps:

[0172] I1. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW and WW Convert to a byte string according to the method given in 4.2.6 of GB / T32918.1-2016;

[0173] I2.Use UU A As the fourth public key, and use the SM2 encryption algorithm to encrypt the plaintext tt A ||x WW ||y WW After encryption, the fourth ciphertext Cipher is obtained 4 =SM2_ENC(UU A ,tt A ||x WW ||y WW ), and the fourth ciphertext Cipher 4 Sent to the user, where SM2_ENC(UU A ,tt A ||x WW ||y WW ) indicates the use of the SM2 encryption algorithm and the fourth public key UU in GB / T 32918.4-2016 A , for the plaintext tt A ||x WW ||y WW Perform encryption calculation and output ciphertext;

[0174] S34. The user receives the third ciphertext Cipher returned by the key generation center KGC 3 Or the fourth ciphertext Cipher 4 , after decryption, we get the second part of the signature key value tt A and the second public key to restore data WW A , calculate hh A =H 256 (x WW ‖y WW ‖H A ), and then calculate the user's encrypted private key de A =(hh A ×tt A +rr A )(modn), and save the user encrypted private key de A And the second public key restores the data WW A ,

[0175] When performing the decryption,

[0176] If the sending method H is used in step S33, the decryption method is method J, which includes the following steps:

[0177] J1. Calculate KK' = [rr A ]×P Pub , the fourth key kk'=KDF(x KK’ ||y KK’ , 128), where x KK’ ,y KK’ is the coordinate of KK', the fourth key kk' is a 128-bit byte string generated by a key derivation function;

[0178] J2. Use the fourth key kk' and the SM4 cryptographic algorithm to the third ciphertext Cipher 3 Decrypt to get the plaintext

[0179] tt A ||x WW ||y WW =SM4_DEC(kk', Cipher 3 ),

[0180] Among them, SM4_DEC(kk', Cipher 3 ) indicates that the SM4 decryption algorithm in GB / T 32907-2016 and the 128-bit fourth key kk' are used to decrypt the third ciphertext Cipher 3 Perform decryption calculation and output plaintext;

[0181] J3. According to the method given in 4.2.3 of GB / T 32918.1-2016, the second part of the key value tt A and the second public key to restore data WW A The coordinate x WW ,y WW Converted to an integer, decrypted to obtain the second part of the key value tt A and the second public key to restore data WW A ;

[0182] If sending method I is used in S33, the decryption method is method K, which includes the following steps:

[0183] K1. Use the third random number rr A As the second private key, and use the SM2 decryption algorithm to decrypt the fourth ciphertext Cipher 4 After decryption, we get the plaintext

[0184] tt A ||x WW ||y WW =SM2_DEC(rr A , Cipher 4 )

[0185] Among them, SM2_DEC(rr A , Cipher 4 ) indicates the use of the SM2 decryption algorithm and the second private key rr in GB / T 32918.4-2016 A , for the fourth ciphertext Cipher 4 Perform decryption calculation and output plaintext;

[0186] K2. According to the method given in 4.2.3 of GB / T 32918.1-2016, the second part of the key value tt A and the second public key to restore data WW A The coordinate x WW ,y WW Converted to an integer, decrypted to obtain the second part of the key value tt A and the second public key to restore data WW A ;

[0187] S35. The user can choose whether to perform the second public key verification. If the second public key verification is not performed, the user encryption private key generation is returned successfully. If the second public key verification is performed, the following steps are included:

[0188] L1. Use an identifiable ID A , the system master public key P of the key generation center KGC pub, the second public key restores the data WW A And the second private key generator kid 1 , generate the corresponding second public key PP' A (ie, restore the second public key PP' A ), the generation comprises the following steps:

[0189] M1. Calculate H11 = H 256 (ENTL‖ID A ‖x Pub ‖y Pub ), where ENTL is 2 bytes representing ID A The byte length of

[0190] M2. Use the method given in 4.2.6 of GB / T32918.1-2016 to restore the data WW using the second public key A The coordinate x WW ,y WW Convert to a byte string and calculate h22 = H 256 (x WW ‖y WW ‖H11), and convert h22 into an integer according to the method given in 4.2.3 of GB / T 32918.1-2016;

[0191] M3. Calculation of PP' A =WW A +[kid 1 ×h22]×P pub ;

[0192] L2. Calculate PP A =[de A ]×G;

[0193] L3. If PP' A =PP A , then the second public key verification succeeds, otherwise the second public key verification fails;

[0194] L4. If the second public key verification succeeds, it returns that the user encrypted private key generation is successful, otherwise it returns that the user encrypted private key generation fails.

[0195] It should be noted that in the above SM2 key generation method, step F1 and step L1 are respectively the first public key P' A and the second public key PP' A That is, the present invention also provides a public key recovery method, and the specific steps are the above-mentioned step F1 and / or step L1.

[0196] The present invention also provides a digital signature generation method, which adopts the above-mentioned SM2 key generation method, wherein the user, i.e. the signer, uses the SM2 key generation method to calculate the user signature private key ds A After that, the digital signature is calculated for the 256-bit data to be signed e. Specifically, the user follows A in 6.1 of GB / T32981.2-2016 3 -A 7 The method generates the signature value (r, s).

[0197] The present invention also provides a digital signature verification method, which adopts the above-mentioned SM2 key generation method, wherein the signature verifier uses the identifiable identification ID of the signer (i.e., the user) to receive the 256-bit data to be signed ee and the signature value (rr, ss) A , the first public key restores data W A and the system master public key P of the key generation center KGC pub Perform signature verification, including the steps of: using the above step F1 to restore the complete first public key P' A , using the first public key P' A As the public key, according to 7.1 of GB / T32981.2-2016, 5 -B 7 Step 1 verifies the signature value (rr, ss).

[0198] The present invention also provides a data encryption method, which adopts the above-mentioned SM2 key generation method, wherein the data encryptor B uses the identifiable identification ID of the encrypted data receiver A (ie, the user) A , the second public key restores the data WW A and the system master public key P of the key generation center KGC pub Encrypt the plaintext data m to be encrypted, including the steps of: using the above step L1 to restore the complete second public key PP' A , using the second public key PP' A As the public key, the data plaintext m is encrypted according to the encryption algorithm in 6.1 of GB / T32981.4-2016.

[0199] The present invention also provides a data decryption method, which adopts the above-mentioned SM2 key generation method, wherein the encrypted data receiver A uses the user encryption private key de A Decrypting the encrypted data ciphertext C to restore the plaintext includes the following steps: decrypting according to the decryption algorithm in 7.1 of GB / T32981.4-2016.

[0200] In summary, the SM2 key generation method provided by the present invention can be used to generate signature private keys and encryption private keys, and the signature private key can generate digital signatures; the encryption private key can be used to encrypt data and decrypt data. The public key recovery method can recover the user's (signature / encryption) public key from the user's identifiable identifier and (signature / encryption) public key recovery data, wherein the signature public key is used for digital signature verification, and the encryption public key is used for encrypting data.

[0201] The present invention also provides a computer device, comprising a storage device, a first processor, and a first computer program stored in the storage device and executable on the first processor. When the first computer program is executed by the first processor, it implements one or more of the above-mentioned two SM2 key generation methods, public key recovery method, digital signature generation method, digital signature verification method, data encryption method, and data decryption method.

[0202] The present invention also provides a computer-readable storage medium for storing a second computer program, which can be executed by at least one second processor so that the at least one second processor executes one or more of the two SM2 key generation methods, public key recovery methods, digital signature generation methods, digital signature verification methods, data encryption methods and data decryption methods mentioned above.

[0203] The SM2 key generation method provided by the present invention saves a lot of computing resources by jointly calculating the user signature / encryption key through the user and KGC according to the user's identifiable identification and the KGC system master key. In the process of generating the user signature / encryption key, the present invention can distinguish the user signature / encryption key through the private key generator, and the signature verifier and the data encryptor also need to use the private key generator to restore the signature public key and the encryption public key, so that the generation and use of the signature key and the encryption key are distinguished from the algorithm level to avoid mixing. At the same time, KGC can use the same master private key to generate signature keys and encryption keys for users. The signature verifier and the data encryptor can restore the signature public key and the encryption public key through the KGC system master public key, the user's public key recovery data and the user's identifiable identification and perform signature verification or data encryption.

[0204] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0205] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.

Claims

1. SM2 key generation method, It is characterized in that The method comprises the following steps: step one, step two and step three. in, Step 1. Establish system parameters; Step 2. Generate user signature private key ds based on the system parameters A ; Step 3. Generate a user encryption private key based on the system parameters A ; The step 1 comprises the following steps: S11. The user and the key generation center KGC share the elliptic curve E(Fq) parameters G and n of the SM2 algorithm, where E(Fq) is an elliptic curve defined on a finite field Fq, G represents a base point of order n on the elliptic curve E(Fq), and n is a prime number. S12. The key generation center KGC generates the system master private key ms and the system master public key P Pub , where the system master public key P Pub =[ms]×G, the meaning of the square brackets [] represents the doubling operation on the elliptic curve E(Fq), the system master public key P Pub is a point on the elliptic curve E(Fq), and the meanings of the square brackets [] in the following calculation formulas all represent the doubling operation on the elliptic curve E(Fq). S13. The key generation center KGC randomly selects a first private key generator kid 0 ∈[1,n-1] and the second private key generator kid 1 ∈[1,n-1], and kid 0 and kid 1 Not equal, S14. The key generation center KGC publishes the system master public key P Pub 、The first private key generator kid 0 And the second private key generator kid 1 ; The step 2 comprises the following steps: S21. The user generates a first random number r A ∈[1,n-1], calculate U A =[r A ]×G, S22. The user sends the U A and the user's identifiable ID A Submit to the key generation center KGC, S23. The key generation center KGC uses the system master private key ms to calculate the first part of the key value t A And the first public key to restore data W A , and the first part of the key value t A And the first public key to restore data W A Send it to the user and return the first ciphertext Cipher to the user 1 Or the second ciphertext Cipher 2 , S24. The user receives the first ciphertext Cipher 1 Or the second ciphertext Cipher 2 , after decryption, the first part of the key value t is obtained A and the first public key to restore data W A , calculate H A =H 256 (ENTL A ∥ID A ∥x Pub ∥y Pub ) and h A =H 256 (x W ∥y W ∥H A ), calculate the user signature private key ds A =(h A ×t A +r A )mod n, save the user signature private key ds A And the first public key to restore data W A , where H 256 is a hash function with an output of 256 bits; ENTL A The identifiable ID is represented by 2 bytes A The byte length of the string; ‖ represents the concatenation of byte strings; x Pub ,y Pub is the system master public key P Pub The coordinates of W ,y W Recover data W for the first public key A coordinates; x mod y represents the remainder of x on y; The step three comprises the following steps: S31. The user generates a third random number rr A ∈[1,n-1], calculate UU A =[rr A ]×G, S32. The user sends the UU A and the user's identifiable ID A Submit to the key generation center KGC, S33. The key generation center KGC uses the system master private key ms to calculate the second part of the signature key value tt A and the second public key to restore data WW A , and the second part of the signature key value tt A and the second public key to restore data WW A Send it to the user and return the third ciphertext Cipher to the user 3 Or the fourth ciphertext Cipher 4 , S34. The user receives the third ciphertext Cipher 3 Or the fourth ciphertext Cipher 4 , after decryption, the second part of the signature key value tt is obtained A and the second public key to restore data WW A , calculate hh A =H 256 (x WW ‖y WW ‖H A ), and then calculate the user encryption private key de A =(hh A ×tt A +rr A )mod n, and save the user encrypted private key de A and the second public key to restore data WW A , where x WW ,y WW Recover data WW for the second public key A The coordinates of .

2. The SM2 key generation method according to claim 1, It is characterized in that In step S23, the calculation includes the following steps: A1. Calculate the H A =H 256 (ENTL A ∥ID A ∥x Pub ∥y Pub ), and convert to a byte string; A2. Generate a second random number w∈[1, n-1]; A3. Calculate the first public key to restore data W A =[w]×G+U A +[kid 0 ]×P pub ; A4. Calculate the h A =H 256 (x W ∥y W ∥H A ), and convert to a byte string; A5. The h A Convert to an integer. If the converted integer is 0, go to step A2; A6. Calculate the first part of the key value t A =(h A -1 ×(w+kid 0 ×ms)+kid 0 × ms) mod n, and then the key generation center KGC converts the first part of the key value t A and the first public key to restore data W A Sending to the user, including sending method B or sending method C, The sending method B comprises the following steps: B1. Calculate K = [ms] × U A , the first key k = KDF(x K ||y K , 128), where x K ,y K is the coordinate of K, KDF is a key derivation function, and the first key k is a 128-bit byte string generated by the key derivation function; B2. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to byte string; B3. Use the first key k and SM4 cryptographic algorithm to encrypt the plaintext t A ||x W ||y W Encrypt to obtain the first ciphertext Cipher 1 =SM4_ENC(k, t A ||x W ||y W ), and the first ciphertext Cipher 1 Sent to the user, where SM4_ENC(k, t A ||x W ||y W ) indicates that the plain text t is encrypted using the SM4 encryption algorithm and the first 128-bit key k. A ||x W ||y W Perform encryption calculation and output ciphertext; The sending method C comprises the following steps: C1. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to byte string; C2. Use of the U A As the third public key, and use the SM2 encryption algorithm to encrypt the plaintext t A ||x W ||y W After encryption, the second ciphertext Cipher is obtained 2 =SM2_ENC(U A , t A ||x W ||y W ), and the second ciphertext Cipher 2 Sent to the user, where SM2_ENC(U A , t A ||x W ||y W ) indicates the use of the SM2 encryption algorithm and the third public key U A , for the plaintext t A ||x W ||y W Perform encryption calculation and output ciphertext, In the step S24, when performing the decryption, If the sending method B is used in step S23, the decryption method is method D, which includes the following steps: D1. Calculate K' = [r A ]×P Pub , the second key k'=KDF(x K’ ||y K’ , 128), where x K’ ,y K’ is the coordinate of K', the second key k' is a 128-bit byte string generated by the key derivation function; D2. Use the second key k' and SM4 cryptographic algorithm to perform the first ciphertext Cipher 1 Decrypt to get the plaintext: t A ||x W ||y W =SM4_DEC(k’,Cipher 1 ), Among them, SM4_DEC(k', Cipher 1 ) indicates that the first ciphertext Cipher is decrypted using the SM4 decryption algorithm and the second 128-bit key k'. 1 Perform decryption calculation and output plaintext; D3. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to an integer, thereby decrypting to obtain the first part of the key value t A and the first public key to restore data W A ; If the sending method C is used in step S23, the decryption method is method E, which includes the following steps: E1. Use the first random number r A As the first private key, and use the SM2 decryption algorithm to decrypt the second ciphertext Cipher 2 After decryption, we get the plaintext: t A ||x W ||y W =SM2_DEC(r A ,Cipher 2 ); Among them, SM2_DEC(r A , Cipher 2 ) indicates the use of the SM2 decryption algorithm and the first private key r A , for the second ciphertext Cipher 2 Perform decryption calculation and output plaintext; E2. The first part of the key value t A And the first public key to restore data W A The coordinate x W ,y W Convert to an integer, thereby decrypting to obtain the first part of the key value t A and the first public key to restore data W A .

3. The SM2 key generation method according to claim 1, It is characterized in that In step S33, the calculation includes the following steps: G1. Calculate the H A =H 256 (ENTL A ∥ID A ∥x Pub ∥y Pub ); G2. Generate a fourth random number ww∈[1, n-1]; G3. Calculate the second public key to restore data WW A =[ww]×G+UU A +[kid 1 ]×P pub ; G4. Calculate hh A =H 256 (x WW ∥y WW ∥H A ), where x WW ,y WW Recover data WW for the second public key A , and convert it into a byte string; G5. The hh A Convert to an integer. If the converted integer is 0, go to step G2; G6. Calculate tt A =(hh A -1 ×(ww+kid 1 ×ms)+kid 1 × ms) mod n, and then the key generation center KGC converts the second part of the key value tt A and the second public key to restore data WW A Sending to the user, including sending method H or sending method I, The sending method H comprises the following steps: H1. Calculate KK = [ms] × UU A , the third key kk=KDF(x KK ||y KK , 128), where x KK ,y KK are the coordinates of KK, the third key kk is a 128-bit byte string generated by the key derivation function; H2. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW and WW Convert to byte string; H3. Using the third key kk and SM4 cryptographic algorithm for tt A ||x WW ||y WW Encrypt to obtain the third ciphertext Cipher 3 =SM4_ENC(kk, tt A ||x WW ||y WW ), and the third ciphertext Cipher 3 Sending to the user; The sending method I comprises the following steps: I1. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW and WW Convert to byte string; I2. Use of the UU A As the fourth public key, and use the SM2 encryption algorithm to tt A ||x WW ||y WW After encryption, the fourth ciphertext Cipher is obtained 4 =SM2_ENC(UU A ,tt A ||x WW ||y WW ), and the fourth ciphertext Cipher 4 sent to the user, The step S34 includes the following steps: When performing the decryption, If the sending method H is used in step S33, the decryption method is method J, which includes the following steps: J1. Calculate KK' = [rr A ]×P Pub , the fourth key kk'=KDF(x KK’ ||y KK’ , 128), where x KK’ ,y KK’ are the coordinates of the KK', the fourth key kk' is a 128-bit byte string generated by the key derivation function; J2. Use the fourth key kk' and SM4 cryptographic algorithm to the third ciphertext Cipher 3 Decrypt to get the plaintext tt A ||x WW ||y WW =SM4_DEC(kk’,Cipher 3 ); J3. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW ,y WW Converted to an integer, decrypted to obtain the second part of the key value tt A and the second public key to restore data WW A If the sending method I is used in step S33, the decryption method is method K, and the method K includes the following steps: K1. Use the third random number rr A As the second private key, and use the SM2 decryption algorithm to decrypt the fourth ciphertext Cipher 4 After decryption, we get the plaintext tt A ||x WW ||y WW =SM2_DEC(rr A ,Cipher 4 ); K2. The second part of the key value tt A and the second public key to restore data WW A The coordinate x WW ,y WW Converted to an integer, decrypted to obtain the second part of the key value tt A and the second public key to restore data WW A .

4. Public key recovery method, It is characterized in that Generate a first public key P' using any one of claims 1 and 2 A Or / and using any one of claims 1 and 3 to generate a second public key PP' A , in, The first public key P' is generated A , is the user's identifiable ID A , the system master public key P of the key generation center KGC pub , the first public key restores data W A And the first private key generator kid 0 , generate the corresponding first public key P' A , including the following steps: G1. Calculate H11 = H 256 (ENTL‖ID A ‖x Pub ‖y Pub ), where H 256 is a hash function with an output of 256 bits, ENTL is the identifiable ID represented by 2 bytes A The byte length of , ‖ represents the concatenation of byte strings, x Pub ,y Pub is the system master public key P Pub The coordinates of G2. Restore the first public key to data W A The coordinate x W ,y W Convert to a byte string and calculate h11=H 256 (x W ‖y W ‖H11), and converting said h11 into an integer; G3. Calculate P' A =W A +[kid 0 ×h11]×P pub ; The second public key PP' is generated A The identifiable ID is used A , the system master public key P of the key generation center KGC pub , the second public key restores the data WW A And the second private key generator kid 1 , generate the corresponding second public key PP' A , including the following steps: M1. Calculate H11 = H 256 (ENTL‖ID A ‖x Pub ‖y Pub ); M2. Restore data WW using the second public key A The coordinate x WW ,y WW Convert to a byte string and calculate h22 = H 256 (x WW ‖y WW ‖H11), and converting said h22 into an integer; M3. Calculation of PP' A =WW A +[kid 1 ×h22]×P pub . 5.SM2 key generation method, It is characterized in that Adopt any one of claims 1 and 2 or / and adopt any one of claims 1 and 3, and adopt claim 4, wherein: When any one of claims 1 and 2 and claim 4 are adopted, the method comprises the following steps: S25. The user chooses to perform the first public key verification, including the following steps: F1. Using claim 4, generate a first public key P' A ; F2. Calculate P A =[ds A ]×G; F3. If P' A =P A , then the first public key verification succeeds, otherwise the first public key verification fails; When any one of claims 1 and 3 and claim 4 are adopted, the method comprises the following steps: S35. The user chooses to perform a second public key verification, including the following steps: L1. Using claim 4, generate a second public key PP' A ; L2. Calculate PP A =[de A ]×G; L3. If PP' A =PP A , then the second public key verification succeeds, otherwise the second public key verification fails.

6. Digital signature generation method, It is characterized in that The user, i.e. the signer, uses the SM2 key generation method described in any one of claims 1-3 and 5 to calculate the user signature private key ds A Afterwards, the digital signature is calculated for the 256-bit data to be signed e to generate the signature value (r, s).

7. Digital signature verification method, It is characterized in that The signature verifier recovers the complete first public key P' by using step F1 of claim 5 for the received 256-bit data to be signed ee and the signature value (rr, ss). A , using the first public key P' A Use the public key to verify the signature value (rr, ss).

8. Data encryption method, It is characterized in that Data encryptor B uses step L1 described in claim 5 to recover the complete second public key PP' A , using the second public key PP' A Use the public key to encrypt the data plaintext m.

9. Data decryption method, It is characterized in that The encrypted data receiver A uses the SM2 key generation method described in any one of claims 1-3 and 5 to generate the user encryption private key de A , decrypt the encrypted data ciphertext C and restore the plaintext.

10. Computer equipment, It is characterized in that The invention comprises a memory, a first processor, and a first computer program stored in the memory and executable on the first processor, wherein when the first computer program is executed by the first processor, one or more of the following methods are implemented: The SM2 key generation method according to any one of claims 1 to 3 and 5; The public key recovery method as described in claim 4; The digital signature generation method according to claim 6; The digital signature verification method according to claim 7; The data encryption method according to claim 8; The data decryption method as claimed in claim 9.

11. Computer readable storage medium, It is characterized in that The computer-readable storage medium is used to store a second computer program, and the second computer program can be executed by at least one second processor to enable the at least one second processor to perform one or more of the following methods: The SM2 key generation method according to any one of claims 1 to 3 and 5; The public key recovery method as described in claim 4; The digital signature generation method according to claim 6; The digital signature verification method according to claim 7; The data encryption method according to claim 8; The data decryption method as claimed in claim 9.