Abstract:
Disclosed are a method and device for generating a digital signature. The method comprises: a device generating a digital signature parameter r that meets an effective determining condition; generating a digital signature parameter s according to the following formula s=((1+d A ) −1 ·(r+k)−r)mod n, by using a private key d A , a random number k, r, and an elliptic curve parameter n, a value range of k being [1, n−1]; determining if the generated s is 0; if s is 0, regenerating r that meets the effective determining condition, and regenerating s by using d A , the regenerated k with the value range of [1, n−1] and the regenerated r and n, until s is not 0; converting data types of r and s that is not 0 into byte strings, to obtain a digital signature (r, s). According to the technical solutions provided by embodiments of this application, a digital signature parameter s is obtained by using a simplified calculation formula, and the number of times that big integers are calculated can be reduced, so that the calculation efficiency of generating a digital signature based on an SM2 digital signature generation algorithm is improved.

Description:
[0001]    This application is a US National Stage of International Application No. PCT/CN2014/084380, filed Aug. 14, 2014, designating the United States, and claiming the benefit of Chinese Patent Application No. 201310363349.7, filed with the State Intellectual Property Office of People&#39;s Republic of China on Aug. 16, 2013 and entitled “Method and device for generating digital signature”, the content of which is hereby incorporated by reference in its entirety. 
     
    
     FIELD 
       [0002]    The present invention relates to the field of information technologies and particularly to a method and device for generating a digital signature. 
       BACKGROUND 
       [0003]    The SM2 digital signature algorithm which is a component of the Public Key Cryptographic Algorithm SM2 Based on Elliptic Curves has been well applied in the field of user identity authentication and information integrity check functions. The operational efficiency of the SM2 digital signature algorithm has been the focus of attention by the users of the algorithm being applied. The SM2 digital signature algorithm is consisted of the SM2 digital signature generation algorithm and the SM2 digital signature verification algorithm. 
         [0004]    If M represents a message to be signed, then in order to obtain a digital signature (r, s) of the message M, to be used by a user A, this can be performed in the following SM2 digital signature generation algorithm: 
         [0005]    A1: Set  M =Z A ∥M. 
         [0006]    Where ∥ represents a cascading operation, and Z A  represents a hash value of the user A, obtained in a cryptographic hash function, to generate the digital signature. 
         [0007]    A2: Calculate e=H ν ( M ), and convert the data type of e from a string of bits into an integer. 
         [0008]    Where H ν ( ) represents a cryptographic hash function with a message digest length of ν bits, e.g., the SM3 Cryptographic Hash Algorithm. 
         [0009]    A3: Generate a random number kε[1, n−1] using a random number generator. 
         [0010]    Where n represents a parameter of an elliptical curve. 
         [0011]    A4: Calculate a point (x 1 ,y 1 )=[k]G on the elliptical curve, where x 1  represents a field element, and convert the data type of x 1  into an integer. 
         [0012]    Where G represents a basic point on the elliptical curve, and [k]G represents the point multiplication of k and G. 
         [0013]    The type of an equation of the elliptical curve can be a prime number field equation y 2 =x 3 +ax+b or a binary field equation y 2 +xy=x 3 +ax 2 +b. 
         [0014]    A5: Calculate 
         [0000]        r =( e+x   1 )mod  n   Equation 1
 
         [0015]    That is, a modular operation is performed on n using (e+x 1 ). 
         [0016]    If r=0 or r+k=n, then A3 is returned. 
         [0017]    A6: Calculate 
         [0000]        s =((1+ d   A ) −1 ·( k−r·d   A ))mod  n   Equation 2
 
         [0018]    If s=0, then A3 is returned. 
         [0019]    Where d A  represents a private key of the user A. 
         [0020]    A7: Convert the data type of r and s from an integer into a string of bytes, and the digital signature of the message M is (r, s). 
         [0021]    The user A can be a system or a device, and the SM2 digital signature generation algorithm can be performed by a subsystem or a hardware module arranged in the user A, a software module executable in the user A, etc., or can be a system or a device, in communication with the user A, invoked by the user A. 
         [0022]    The user A is provided with a distinguishable identity ID A  with the length of entlen A  bits, where ENTL A  represents two bytes into which an integer entlen A  is converted. In the SM2 digital signature generation algorithm, the data type of the coordinates x G  and y G  of G, and the coordinates x A  and y A  of P A  are converted into a string of bits, so Z A =H 256 (ENTL A ∥ID A ∥a∥b∥x G ∥y G ∥x A ∥y A ), where P A  represents a public key of the user A, and H 256 ( ) represents a cryptographic hash function with a message digest length of 256 bits, e.g., the SM3 Cryptographic Hash Algorithm. 
         [0023]    Moreover in a particular engineering implementation, those skilled in the art typically transform Equation 2 as in Equation 3 and Equation 4 below by converting a negative integral power algorithm, i.e., (1+d A ) −1 , into performing a modular inverse algorithm, i.e., (1+d A ) −1  mod n, to thereby facilitate the engineering implementation. 
         [0000]        s =(((1+ d   A ) −1  mod  n )·(( k−r−d   A )mod  n ))mod  n   Equation 3
 
         [0000]        s =(((1+ d   A ) −1  mod  n )·(( k −( r−d   A )mod  n )mod  n ))mod  n   Equation 4
 
         [0024]    The SM2 digital signature generation algorithm is performed based upon the theory of the ECC algorithm where large integer multiplication, large integer modular multiplication, and other large integer operations are the most significant factor to influence the operational efficiency of the algorithm, and although the existing SM2 digital signature generation algorithm can satisfy some demand for the operational efficiency, it may be desirable to further improve the operational efficiency, and there has been absent a corresponding solution in the prior art. 
       SUMMARY 
       [0025]    The object of the invention is to provide a method and device for generating a digital signature so as to further improve the operational efficiency of generating a digital signature in the SM2 digital signature generation algorithm. 
         [0026]    The object of the invention is attained by the following technical solutions: 
         [0027]    A method for generating a digital signature includes: 
         [0028]    generating, by a device, a digital signature parameter r satisfying a validity judgment condition; 
         [0029]    generating, by the device, a digital signature parameter s using a private key d A , a random number k in the range [1, n−1], the digital signature parameter r, and an elliptical curve parameter n in the equation of: 
         [0000]        s =((1+ d   A ) −1 ·( r+k )− r )mod  n;  
 
         [0030]    judging, by the device, whether the digital signature s is 0, and if the digital signature s is 0, then regenerating a digital signature parameter r satisfying the validity judgment condition, and regenerating the digital signature parameter s using the private key d A , a regenerated random number k in the range [1, n−1], the digital signature parameter r regenerated, and the elliptical curve parameter n until the digital signature parameter s is not 0; and 
         [0031]    converting, by the device, the data type of the resulting digital signature parameter r and digital signature parameter s which is not 0 into a string of bytes to obtain a digital signature (r, s). 
         [0032]    The method according to the embodiment of the invention can obtain the digital signature parameter s by lowering the number of large integer operations to thereby improve the operational efficiency of generating a digital signature in the SM2 digital signature algorithm. 
         [0033]    Preferably generating, by the device, the digital signature parameter s in the equation of s=((1+d A ) −1 ·(r+k)−r) mod n includes: 
         [0034]    after performing a large integer addition operation on the digital signature parameter r and the random number k, performing, by the device, an operation of a result (r+k) of the large integer addition operation modulo the elliptical curve parameter n; 
         [0035]    after adding 1 to the private key d A , calculating, by the device, a modular inverse of (1+d A ) modulo the elliptical curve parameter n; 
         [0036]    performing, by the device, a large integer multiplication operation on a result of the large integer addition operation result modulo n, and a result of the modular inverse; and 
         [0037]    after subtracting the digital signature parameter r from a result of the large integer multiplication operation, performing, by the device, an operation of a result of the large integer multiplication operation, after the digital signature parameter r being subtracted, modulo the elliptical curve parameter n to obtain the digital signature parameter s. 
         [0038]    The digital signature parameter s can be generated in the process above to thereby dispense with one large integer multiplication or one large integer modular multiplication operation. 
         [0039]    Further to any one of the embodiments above, preferably before the digital signature parameter s is generated, the method further includes: 
         [0040]    obtaining, by the device, an operation result r+k of the validity judgment condition on r to generate the digital signature parameter s using the private key d A , the operation result r+k of the validity judgment condition on r, the digital signature parameter r, and the elliptical curve parameter n. 
         [0041]    The digital signature parameter s can be generated directly using the operation result (r+k) of the validity judgment condition on r to thereby further improve the operational efficiency. 
         [0042]    Further to any one of the embodiments above, preferably before the digital signature parameter s is generated, the method further includes: 
         [0043]    obtaining, by the device, an operation result (r+k)mod n of the validity judgment condition on r to generate the digital signature parameter s using the private key d A , the operation result (r+k)mod n of the validity judgment condition on r, the digital signature parameter r, and the elliptical curve parameter n. 
         [0044]    An operation of (r·d A )mod n can be avoided to thereby dispense with one large integer modular multiplication operation. 
         [0045]    A device for generating a digital signature includes: 
         [0046]    a parameter input interface unit configured to obtain a hash value Z A  and a message M to be signed; 
         [0047]    a cascading operating unit configured to perform a cascading operation on the hash value Z A , and the message M to be signed, obtained by the parameter input interface unit to generate  M ; 
         [0048]    a cryptographic hash algorithm operating unit configured to perform a cryptographic hash operation on  M  generated by the cascading operating unit to generate message digest information e; 
         [0049]    a random number generator configured to generate a random number k in the range [1, n−1]; 
         [0050]    an Elliptic Curves Cryptography, ECC, algorithm operating unit configured to perform an elliptical curve point multiplication operation (x 1 ,y 1 )=kG according to the random number k generated by the random number generator to obtain the abscissa x 1  of an elliptical curve point, wherein G represents an elliptical curve parameter; 
         [0051]    a data type converting unit configured to convert the data type of the message digest information e generated by the cryptographic hash algorithm operating unit into an integer type, and further convert the data type of the abscissa x 1  of the elliptical curve point, generated by the ECC algorithm operating unit into an integer type; 
         [0052]    a large integer operating unit configured to generate a digital signature parameter r using the message digest information e and abscissa x 1  of the elliptical curve point converted by the data type converting unit; 
         [0053]    a validity judgment unit configured to judge the validity of the digital signature parameter r generated by the large integer operating unit; 
         [0054]    if the digital signature parameter r does not satisfy a validity judgment condition, then the random number generator regenerates a random number k in the range [1, n−1]; the ECC algorithm operating unit obtains again an abscissa x 1  of an elliptical curve point using the random number k regenerated by the random number generator; the data type converting unit converts the data type of the abscissa x 1  of the elliptical curve point, obtained again; the large integer operating unit regenerate a digital signature parameter r using the message digest information e and the abscissa x 1  of the elliptical curve point converted; and the validity judgment unit judges again the validity of the digital signature parameter r regenerated using the digital signature parameter r regenerated and the random number k regenerated; 
         [0055]    wherein the large integer operating unit is further configured to generate a digital signature parameter s using a private key d A , the random number k generated by the random number generator, the digital signature parameter r, and an elliptical curve parameter n in the equation of: s=((1+d A ) −1 ·(r+k)−r) mod n; 
         [0056]    the validity judgment unit is further configured to judge whether the digital signature parameter s generated by the large integer operating unit is 0; if the digital signature parameter s is 0, then the random number generator regenerates a random number k in the range [1, n−1], and the large integer operating unit regenerates a digital signature parameter r, and if the digital signature parameter r regenerated satisfies the validity judgment condition, then the large integer operating unit regenerates a digital signature parameter s using the private key d A , the random number k regenerated in the range [1, n−1], the digital signature parameter r regenerated, and the elliptical curve parameter n; 
         [0057]    the data type converting unit is further configured to convert the data type of the digital signature parameter r, and the digital signature parameter s which is not 0, finally generated by the large integer operating unit into a string of bytes to obtain a digital signature (r, s); and 
         [0058]    a parameter output interface unit configured to output the digital signature (r, s). 
         [0059]    The device according to the embodiment of the invention can obtain the digital signature parameter s by lowering the number of large integer operations to thereby improve the operational efficiency of generating a digital signature in the SM2 digital signature algorithm. 
         [0060]    Preferably the large integer operating unit configured to generate the digital signature parameter s is configured: 
         [0061]    to perform a large integer addition operation on the digital signature parameter r, and the random number k generated by the random number generator, and then perform an operation of a result (r+k) of the large integer addition operation modulo the elliptical curve parameter n; 
         [0062]    to add 1 to the private key d A , and then calculate a modular inverse of (1+d A ) modulo the elliptical curve parameter n; 
         [0063]    to perform a large integer multiplication operation on a result of the large integer addition operation result modulo n, and a result of the modular inverse; and 
         [0064]    to subtract the digital signature parameter r from a result of the large integer multiplication operation, and then perform an operation of a result of the large integer multiplication operation, after the digital signature parameter r being subtracted, modulo the elliptical curve parameter n to obtain the digital signature parameter s. 
         [0065]    The digital signature parameter s can be generated in the process above to thereby dispense with one large integer multiplication or one large integer modular multiplication operation. 
         [0066]    Further to any one of the embodiments above of the device, preferably if the validity judgment unit judges the validity of the digital signature parameter r using an operation result r+k of the validity judgment condition on the digital signature parameter r, then the large integer operating unit further generates the operation result r+k of the validity judgment condition on the digital signature parameter r using the digital signature parameter r generated, and the random number k generated by the random number generator after generating the digital signature parameter r; and 
         [0067]    the large integer operating unit configured to generate the digital signature parameter s is configured: 
         [0068]    to perform an operation of result (r+k) modulo the elliptical curve parameter n; 
         [0069]    to add 1 to the private key d A , and then calculate a modular inverse of (1+d A ) modulo the elliptical curve parameter n; 
         [0070]    to perform a large integer multiplication operation on a result of (r+k) modulo n, and a result of the modular inverse; and 
         [0071]    to subtract the digital signature parameter r from a result of the large integer multiplication operation, and then perform an operation of a result of the large integer multiplication operation, after the digital signature parameter r being subtracted, modulo the elliptical curve parameter n, resulting in the digital signature parameter s. 
         [0072]    The digital signature parameter s can be generated directly using the operation result (r+k) of the validity judgment condition on r to thereby further improve the operational efficiency. 
         [0073]    Further to any one of the embodiments above of the device, preferably if the validity judgment unit judges the validity of the digital signature parameter r using an operation result (r+k) mod n of the validity judgment condition on the digital signature parameter r, then the large integer operating unit further generates the operation result (r+k)mod n the validity judgment condition on the digital signature parameter r using the digital signature parameter r generated, the random number k generated by the random number generator, and the elliptical curve parameter n after generating the digital signature parameter r; and 
         [0074]    the large integer operating unit configured to generate the digital signature parameter s is configured: 
         [0075]    to add 1 to the private key d A , and then calculate a modular inverse of (1+d A ) modulo the elliptical curve parameter n; 
         [0076]    to perform a large integer multiplication operation on the operation result (r+k)mod n and a result of the modular inverse; and 
         [0077]    to subtract the digital signature parameter r from a result of the large integer multiplication operation, and then perform an operation of a result of the large integer multiplication operation, after the digital signature parameter r being subtracted, modulo the elliptical curve parameter n to obtain the digital signature parameter s. 
         [0078]    An operation of (r·d A )mod n can be avoided to thereby dispense with one large integer modular multiplication operation. 
         [0079]    Further to any one of the embodiments above, the private key d A  used by the large integer operating unit can be generated by the device, or can be obtained from the outside, as described below by way of an example. 
         [0080]    First Implementation: 
         [0081]    The device further includes: 
         [0082]    a key generating unit configured to generate the private key d A ; and 
         [0083]    a key storing unit configured to store the private key d A  generated by the key generating unit; and 
         [0084]    the large integer operating unit obtains the private key d A  from the key storing unit to generate the digital signature parameter s. 
         [0085]    Second Implementation: 
         [0086]    the parameter input interface unit is further configured to obtain the private key d A ; and the large integer operating unit obtains the private key d A  from the parameter input interface unit to generate the digital signature parameter s. 
         [0087]    Third Implementation: 
         [0088]    the device further includes a key storing unit; the parameter input interface unit is further configured to obtain the private key d A ; the key storing unit is configured to store the private key d A  obtained by the parameter input interface unit; and the large integer operating unit obtains the private key d A  from the key storing unit to generate the digital signature parameter s. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0089]      FIG. 1  illustrates a flow chart of a first method according to an embodiment of the invention; 
           [0090]      FIG. 2  illustrates a flow chart of a second method according to an embodiment of the invention; 
           [0091]      FIG. 3  illustrates a flow chart of a third method according to an embodiment of the invention; and 
           [0092]      FIG. 4  illustrates a schematic diagram of a device according to an embodiment of the invention. 
       
    
    
     DETAILED DESCRIPTION OF THE EMBODIMENTS 
       [0093]    Embodiments of the invention provide a technical solution to generation of a digital signature, where after a digital signature parameter r satisfying a validity judgment condition is generated, a device generates a digital signature parameter s using a private key d A , a random number k in the range [1, n−1], the digital signature parameter r, and an elliptical curve parameter n in the equation of: s=((1+d A ) −1 ·(r+k)−r) mod n, and judges whether the digital signature parameter s is 0; and if the digital signature parameter s is 0, then the device regenerates a digital signature parameter r satisfying the validity judgment condition, and regenerates a digital signature parameter s using the private key d A , a regenerated random number k in the range [1, n−1], the digital signature parameter r regenerated, and the elliptical curve parameter n until the digital signature parameter s is not 0 to obtain a digital signature (r, s) by converting the data type of the resulting digital signature parameter r and digital signature parameter s which is not 0 into a string of bytes. The digital signature parameter s can be obtained with a smaller number of large integer operations to thereby improve the operational efficiency of generating a digital signature in the SM2 digital signature generation algorithm. 
         [0094]    The technical solution according to the embodiments of the invention will be described below in details with reference to the drawings. 
         [0095]      FIG. 1  illustrates a method for generating a digital signature according to an embodiment of the invention, which particularly includes the following operations: 
         [0096]    Operation  100 . A device generates a digital signature parameter r satisfying a validity judgment condition. 
         [0097]    Here the validity judgment condition being satisfied refers to the digital signature parameter r generated by the device not being 0, and r+k not being n, where n represents an elliptical curve parameter, and k represents a random number in the range of [1, n−1]. 
         [0098]    The digital signature parameter r satisfying the validity judgment condition can be generated in the same way as in the SM2 digital signature generation algorithm without any limitation thereto. 
         [0099]    Operation  110 . The device generates a digital signature parameters using a private key d A , the random number k in the range [1, n−1], the digital signature parameter r, and the elliptical curve parameter n in the equation of: 
         [0000]        s =((1+ d   A ) −1 −( r+k )− r )mod  n   Equation 5
 
         [0100]    Where Equation 2 above is simplified into Equation 5 so that the digital signature parameter s can be generated in Equation 5 without performing the operation r·d A  to thereby dispense with one large integer operation. Equation 2 is simplified as follows: 
         [0000]    
       
         
           
             
               
                 
                   s 
                   = 
                   
                     
                       ( 
                       
                         
                           
                             ( 
                             
                               1 
                               + 
                               
                                 d 
                                 A 
                               
                             
                             ) 
                           
                           
                             - 
                             1 
                           
                         
                         · 
                         
                           ( 
                           
                             k 
                             - 
                             
                               r 
                               · 
                               
                                 d 
                                 A 
                               
                             
                           
                           ) 
                         
                       
                       ) 
                     
                      
                     mod 
                      
                     
                         
                     
                      
                     n 
                   
                 
               
             
             
               
                 
                   = 
                   
                     
                       ( 
                       
                         
                           
                             ( 
                             
                               1 
                               + 
                               
                                 d 
                                 A 
                               
                             
                             ) 
                           
                           
                             - 
                             1 
                           
                         
                         · 
                         
                           ( 
                           
                             k 
                             - 
                             
                               r 
                               · 
                               
                                 d 
                                 A 
                               
                             
                             + 
                             r 
                             - 
                             r 
                           
                           ) 
                         
                       
                       ) 
                     
                      
                     mod 
                      
                     
                         
                     
                      
                     n 
                   
                 
               
             
             
               
                 
                   = 
                   
                     
                       ( 
                       
                         
                           
                             ( 
                             
                               1 
                               + 
                               
                                 d 
                                 A 
                               
                             
                             ) 
                           
                           
                             - 
                             1 
                           
                         
                         · 
                         
                           ( 
                           
                             
                               ( 
                               
                                 r 
                                 + 
                                 k 
                               
                               ) 
                             
                             - 
                             
                               r 
                                
                               
                                 ( 
                                 
                                   1 
                                   + 
                                   
                                     d 
                                     A 
                                   
                                 
                                 ) 
                               
                             
                           
                           ) 
                         
                       
                       ) 
                     
                      
                     mod 
                      
                     
                         
                     
                      
                     n 
                   
                 
               
             
             
               
                 
                   = 
                   
                     
                       ( 
                       
                         
                           
                             
                               ( 
                               
                                 1 
                                 + 
                                 
                                   d 
                                   A 
                                 
                               
                               ) 
                             
                             
                               - 
                               1 
                             
                           
                           · 
                           
                             ( 
                             
                               r 
                               + 
                               k 
                             
                             ) 
                           
                         
                         - 
                         r 
                       
                       ) 
                     
                      
                     mod 
                      
                     
                         
                     
                      
                     n 
                   
                 
               
             
           
         
       
     
         [0101]    Where the private key d A  is a private key of a digital signature user (e.g., the user A above). The digital signature user can be a system or a device, and particularly the digital signature user can be a User Equipment (UE), or can be a network node participating in identity authentication, e.g., an eNB, a Mobile Management Entity (MME), etc. 
         [0102]    Operation  120 . The device judges whether the digital signature s is 0, and if the digital signature s is not 0, then the device proceeds to the step  130 ; if the digital signature s is 0, the device regenerates a digital signature parameter r satisfying the validity judgment condition, and regenerates a digital signature parameter s using the private key d A , a regenerated random number k in the range [1, n−1], the regenerated digital signature parameter r, and the elliptical curve parameter n until the generated digital signature parameter s is not 0. 
         [0103]    Operation  130 . The device obtains a digital signature (r, s) by converting the data type of the resulting digital signature parameter r and digital signature parameter s which is not 0 into a string of bytes. 
         [0104]    A digital signature generator (i.e., the device above) performing the operations above can be a subsystem or a hardware module arranged in the digital signature user, a software module executable in the digital signature user, etc., or can be a system or device, in communication with the digital signature user, invoked by the digital signature user. 
         [0105]    As for the private key of the digital signature user, if the digital signature generator is a subsystem or a hardware module arranged in the digital signature use, a software module executable in the digital signature use, etc., then the digital signature generator can generate and store the key. As for the private key of the digital signature user, the digital signature generator can alternatively obtain and store it from the digital signature user, or can obtain and apply it from the digital signature user without storing it. 
         [0106]    In a real application, the digital signature parameter s can be obtained in Equation 5 particularly in a number of implementations to thereby dispense with one large integer multiplication operation or large integer modular multiplication operation. 
         [0107]    In a preferred implementation, the device generates the digital signature parameter s using the private key d A , the random number k, the digital signature parameter r, and the elliptical curve parameter n in the equation of: 
         [0000]        s =(((1+ d   A ) −1  mod  n )·(( r+k )mod  n )− r )mod  n   Equation 6
 
         [0108]    s=((1+d A ) −1 ·(r+k)·r)mod n is transformed into Equation 6. 
         [0109]    Stated otherwise, after a large integer addition operation is performed on the digital signature parameter r and the random number k, the device performs an operation of a result (r+k) of the large integer addition operation modulo the elliptical curve parameter n; and after  1  is added to the private key d A , the device calculates a modular inversion of (1+d A ) modulo the elliptical curve parameter n, performs a large integer multiplication operation on a results of the large integer addition operation result modulo n and a result of the modular inverse, and after subtracting the digital signature parameter r from a result of the large integer multiplication operation, performs an operation of a result of the large integer multiplication operation, after the digital signature parameter r being subtracted, modulo the elliptical curve parameter n to obtain the digital signature parameters. 
         [0110]    The equation is simplified as follows: 
         [0000]    
       
         
           
             
               
                 
                   s 
                   = 
                   
                     
                       ( 
                       
                         
                           
                             
                               ( 
                               
                                 1 
                                 + 
                                 
                                   d 
                                   A 
                                 
                               
                               ) 
                             
                             
                               - 
                               1 
                             
                           
                           · 
                           
                             ( 
                             
                               r 
                               + 
                               k 
                             
                             ) 
                           
                         
                         - 
                         r 
                       
                       ) 
                     
                      
                     mod 
                      
                     
                         
                     
                      
                     n 
                   
                 
               
             
             
               
                 
                   = 
                   
                     
                       ( 
                       
                         
                           
                             ( 
                             
                               
                                 ( 
                                 
                                   
                                     
                                       ( 
                                       
                                         1 
                                         + 
                                         
                                           d 
                                           A 
                                         
                                       
                                       ) 
                                     
                                     
                                       - 
                                       1 
                                     
                                   
                                    
                                   mod 
                                    
                                   
                                       
                                   
                                    
                                   n 
                                 
                                 ) 
                               
                               · 
                               
                                 ( 
                                 
                                   
                                     ( 
                                     
                                       r 
                                       + 
                                       k 
                                     
                                     ) 
                                   
                                    
                                   mod 
                                    
                                   
                                       
                                   
                                    
                                   n 
                                 
                                 ) 
                               
                             
                             ) 
                           
                            
                           mod 
                            
                           
                               
                           
                            
                           n 
                         
                         - 
                         
                           r 
                            
                           
                               
                           
                            
                           mod 
                            
                           
                               
                           
                            
                           n 
                         
                       
                       ) 
                     
                      
                     mod 
                      
                     
                         
                     
                      
                     n 
                   
                 
               
             
             
               
                 
                   = 
                   
                     
                       ( 
                       
                         
                           
                             ( 
                             
                               
                                 
                                   ( 
                                   
                                     1 
                                     + 
                                     
                                       d 
                                       A 
                                     
                                   
                                   ) 
                                 
                                 
                                   - 
                                   1 
                                 
                               
                                
                               mod 
                                
                               
                                   
                               
                                
                               n 
                             
                             ) 
                           
                           · 
                           
                             ( 
                             
                               
                                 ( 
                                 
                                   r 
                                   + 
                                   k 
                                 
                                 ) 
                               
                                
                               mod 
                                
                               
                                   
                               
                                
                               n 
                             
                             ) 
                           
                         
                         - 
                         r 
                       
                       ) 
                     
                      
                     mod 
                      
                     
                         
                     
                      
                     n 
                   
                 
               
             
           
         
       
     
         [0111]    In this preferred implementation, the digital signature parameter s is calculated in Equation 6. 
         [0112]    It shall be noted that the digital signature parameter s can be generated in another particular implementation than this preferred embodiment. Since simplified Equation 5 has been suggested in the embodiment of the invention, a particular implementation in Equation 5 can occur to those skilled in the art without any inventive effort and thus will fall into the scope of the invention. 
         [0113]    Further any one of the embodiments above, in order to further improve the operational efficiency of generating the digital signature, the operation result r+k of the validity judgment condition on r can be further obtained before the digital signature parameter s is generated. The device can generate the digital signature parameter s directly using the operation result r+k of the validity judgment condition on r, the private key d A , the digital signature parameter r, and the elliptical curve parameter n. 
         [0114]    Further any one of the embodiments above, in order to further improve the operational efficiency of generating the digital signature, the operation result (r+k)mod n of the validity judgment condition on r can be further obtained before the digital signature parameter s is generated. The device can generate the digital signature parameter s directly using the operation result (r+k)mod n of the validity judgment condition on r, the private key d A , the digital signature parameter r, and the elliptical curve parameter n. In this preferred implementation, the judgment on the validity of r according to the operation result (r+k) modulo n, i.e., (r+k) mod n is equivalent to the judgment on the validity of r according to the operation result r+k of the validity judgment condition because in the SM2 digital signature generation algorithm, both the ranges of the digital signature parameter r and the random number k are [1, n−1], so the range of r+k is [2, 2n−2], which means that (r+k) mod n=0 is equivalent to r+k=n. Accordingly the digital signature parameter r satisfying the judgment condition can be generated by judging whether (r+k) mod n=0 instead of whether r+k=n. 
         [0115]    If a message M to be signed, then an implementation of a digital signature (r, s) of M obtained will be described below in details with reference to  FIG. 2  taking Equation 6 as an example. This implementation particularly includes the following operations: 
         [0116]    Operation  200 . A cascading operation is performed on a hash value of a digital signature user, and a message M, that is,  M =Z A ∥M is set. 
         [0117]    Operation  210 . Message digest information e is obtained, that is, e=H ν ( M ) is calculated, and the data type of e is converted from a string of bits into an integer type. 
         [0118]    Operation  220 . A random number kε[1, n−1] is generated using a random number generator. 
         [0119]    Operation  230 . A point (x 1 ,y 1 )=[k]G on an elliptical curve is calculated, where x 1  represents a field element, and the data type of x 1  is converted into an integer type. 
         [0120]    Operation  240 . A digital signature parameter r is generated, that is, r is calculated as 
         [0000]        r =( e+x   1 )mod  n   Equation 1
 
         [0121]    Operation  250 . Validity judgment is made on r: if t=r+k, then the values of r and t are judged so that if r=0 or t=n, then r does not satisfy a validity judgment condition, and the flow goes back to the operation  220 ; and if r≠0 and t≠n, then r satisfies the validity judgment condition, and the flow proceeds to the operation  260 . 
         [0122]    Operation  260 . A digital signature parameter s is generated using a private key d A  of the digital signature user, an operation result r+k of the validity judgment condition on r, the digital signature parameter r, and an elliptical curve parameter n in the equation of: 
         [0000]        s =(((1+ d   A ) −1  mod  n )·( t  mod  n )− r )mod  n   Equation 7
 
         [0123]    It shall be noted that Equation 7 is substantially the same as Equation 6 above except that Equation 7 represents that the digital signature parameter s is generated using the operation result r+k of the validity judgment condition on r without recalculating r+k. 
         [0124]    Operation  270 . It is judged whether the value of s is 0, and if s is 0, then the flow goes back to the operation  220 ; ifs is not 0, the flow proceeds to the operation  280 . 
         [0125]    Operation  280 . The data type of the digital signature parameters r and s obtained is converted from an integer into a string of bytes to obtain a digital signature (r, s) of the message M. 
         [0126]    In the embodiment illustrated in  FIG. 2 , the digital signature parameter s can be generated in Equation 7 to thereby dispense with one large integer multiplication operation or one large integer modular multiplication operation, and the digital signature parameter s can be generated in Equation 7 directly using the operation result r+k of the validity judgment condition on r to thereby further improve the operational efficiency. 
         [0127]    If a message to be signed is M, then an implementation of obtaining a digital signature (r, s) of M will be described below in details with reference to  FIG. 3  taking Equation 6 as an example. This implementation particularly includes the following operations: 
         [0128]    Operation  300 . A cascading operation is performed on a hash value of a digital signature user, and a message M, that is,  M =Z A ∥M is set. 
         [0129]    Operation  310 . Message digest information e is obtained, that is, e=H ν ( M ) is calculated, and the data type of e is converted from a string of bits into an integer. 
         [0130]    Operation  320 . A random number kε[1, n−1] is generated using a random number generator. 
         [0131]    Operation  330 . A point (x 1 , y 1 )=[k]G on an elliptical curve is calculated, where x 1  represents a field element, and the data type of x 1  is converted into an integer type. 
         [0132]    Operation  340 . A digital signature parameter r is generated, that is, r is calculated as 
         [0000]        r =( e+x   1 )mod  n   Equation 1
 
         [0133]    Operation  350 . Validity judgment is made on r: if t=(r+k) mod n, then the values of r and t are judged so that if r=0 or t=n, then r does not satisfy a validity judgment condition, and the flow goes back to the operation  320 ; and if r≠0 and t≠n, then r satisfies the validity judgment condition, and the flow proceeds to the operation  360 . 
         [0134]    Operation  360 . A digital signature parameter s is generated using a private key d A  of the digital signature user, an operation result (r+k) mod n of the validity judgment condition on r, the digital signature parameter r, and an elliptical curve parameter n in the equation of: 
         [0000]        s =(((1+ d   A ) −1  mod  n )· t−r )mod  n   Equation 8
 
         [0135]    It shall be noted that Equation 8 is substantially the same as Equation 6 above except that Equation 8 represents that the digital signature parameter s is generated using the operation result (r+k) mod n of the validity judgment condition on r without recalculating (r+k)mod n. 
         [0136]    Operation  370 . It is judged whether the value of s is 0, and if the value of s is 0, then the flow goes back to the operation  320 ; if the value of s is not 0, the flow proceeds to the operation  380 . 
         [0137]    Operation  380 . The data type of the digital signature parameters r and s obtained is converted from an integer into a string of bytes to obtain a digital signature (r, s) of the message M. 
         [0138]    In the embodiment illustrated in  FIG. 3 , the digital signature parameter s can be generated in Equation 8 to thereby dispense with one large integer multiplication operation or one large integer modular multiplication operation, and the digital signature parameter s can be generated in Equation 8 directly using the operation result (r+k) mod n of the validity judgment condition on r to thereby further improve the operational efficiency. 
         [0139]    Moreover it shall be noted that the method for generating a digital signature can be improved using the solution of the invention by dispensing with one large integer multiplication operation from Equation 3 and with one large integer modular multiplication operation from Equation 4. 
         [0140]    Based upon the same inventive idea as the method, an embodiment of the invention further provides a device for generating a digital signature, structured as illustrated in  FIG. 4 , which includes: 
         [0141]    A parameter input interface unit  401  is configured to obtain a hash value Z A  and a message M to be signed. 
         [0142]    The parameter input interface unit  401  outputs the hash value Z A  obtained and message M to be signed to a cascading operating unit  402 . 
         [0143]    The cascading operating unit  402  is configured to perform a cascading operation on the hash value Z A  and the message M to be signed, obtained by the parameter input interface unit  401  to generate  M . 
         [0144]    The cascading operating unit  402  outputs the  M  to a cryptographic hash algorithm operating unit  403 . 
         [0145]    The cryptographic hash algorithm operating unit  403  is configured to perform a cryptographic hash operation on  M  generated by the cascading operating unit  402  to generate message digest information e. 
         [0146]    The cryptographic hash algorithm operating unit  403  outputs the message digest information e generated to a data type converting unit  406 . 
         [0147]    A random number generator  404  is configured to generate a random number k in the range [1, n−1]. 
         [0148]    The random number generator  404  transmits the random number k generated to an ECC algorithm operating unit  405 . 
         [0149]    The ECC algorithm operating unit  405  is configured to perform an elliptical curve algorithm point multiplication operation (x 1 , y 1 )=kG according to on the random number k generated by the random number generator  404  to obtain the abscissa x 1  of an elliptical curve point, where G represents an elliptical curve parameter 
         [0150]    The ECC algorithm operating unit  405  outputs the abscissa x 1  of the elliptical curve point to the data type converting unit  406 . 
         [0151]    The data type converting unit  406  is configured to convert the data type of the message digest information e generated by the cryptographic hash algorithm operating unit  403  into an integer type, and further convert the data type of the abscissa x 1  of the elliptical curve point, generated by the ECC algorithm operating unit  405  into an integer type. 
         [0152]    The data type converting unit  406  outputs the message digest information e and abscissa x 1  of the elliptical curve point converted by the data type converting  406 , to a large integer operating unit  407 . 
         [0153]    The large integer operating unit  407  is configured to generate a digital signature parameter r using the message digest information e and abscissa x 1  of the elliptical curve point converted by the data type converting unit  406 . 
         [0154]    The large integer operating unit  407  outputs the digital signature parameter r generated to a validity judgment unit  408 . 
         [0155]    The validity judgment unit  408  is configured to judge the validity of the digital signature parameter r generated by the large integer operating unit  407 . 
         [0156]    If the digital signature parameter r does not satisfy a validity judgment condition, then the random number generator  404  regenerates a random number k in the range [1, n−1]; the ECC algorithm operating unit  405  obtains again an abscissa x 1  of an elliptical curve point using the random number k regenerated by the random number generator  404 ; the data type converting unit  406  converts the data type of the abscissa x 1  of the elliptical curve point, obtained again; the large integer operating unit  407  regenerate a digital signature parameter r using the message digest information e and the abscissa x 1  of the elliptical curve point converted; and the validity judgment unit  408  judges again the validity of the digital signature parameter r regenerated using the digital signature parameter r regenerated and the random number k regenerated. 
         [0157]    Here if the digital signature parameter r does not satisfy the validity judgment condition, then the random number generator  404  can be triggered by the validity judgment unit  408  to regenerate the random number, or the random number generator  404  can be triggered by an additional control unit to regenerate the random number. 
         [0158]    The large integer operating unit  407  is further configured to generate a digital signature parameter s using a private key d A , the random number k generated by the random number generator  404 , the digital signature parameter r, and an elliptical curve parameter n in the equation of: s=((1+d A ) −1 ·(r+k)−r)mod n. 
         [0159]    The validity judgment unit  408  is further configured to judge whether the digital signature parameter s generated by the large integer operating unit  407  is 0. 
         [0160]    If the digital signature parameter s is 0, then the random number generator  404  regenerates a random number k in the range [1, n−1], and the large integer operating unit  407  regenerates a digital signature parameter r, and if the digital signature parameter r regenerated satisfies the validity judgment condition, then the large integer operating unit regenerates a digital signature parameter s using the private key d A , the random number k regenerated in the range [1, n−1], the digital signature parameter r regenerated, and the elliptical curve parameter n. 
         [0161]    The data type converting unit  406  is further configured to convert the data type of the digital signature parameter r, and the digital signature parameter s which is not 0, finally generated by the large integer operating unit  407  into a string of bytes to obtain a digital signature (r, s). 
         [0162]    A parameter output interface unit  409  is configured to output the digital signature (r, s). 
         [0163]    Preferably the large integer operating unit  407  configured to generate the digital signature parameter s is configured: 
         [0164]    To perform a large integer addition operation on the digital signature parameter r, and the random number k generated by the random number generator  404 , and then perform an operation of a result (r+k) of the large integer addition operation modulo the elliptical curve parameter n; 
         [0165]    To add 1 to the private key d A , and then calculate a modular inverse of (1+d A ) modulo the elliptical curve parameter n; 
         [0166]    To perform a large integer multiplication operation on a result of the large integer addition operation result modulo n, and a result of the modular inverse; and 
         [0167]    To subtract the digital signature parameter r from a result of the large integer multiplication operation, and then perform an operation of a result of the large integer multiplication operation, after the digital signature parameter r being subtracted, modulo the elliptical curve parameter n to obtain the digital signature parameter s. 
         [0168]    Further to the embodiment illustrated in  FIG. 4 , preferably if the validity judgment unit  408  judges the validity of the digital signature parameter r using an operation result r+k of the validity judgment condition on the digital signature parameter r, then the large integer operating unit  407  further generates the operation result r+k of the validity judgment condition on the digital signature parameter r using the digital signature parameter r generated, and the random number k generated by the random number generator  404  after generating the digital signature parameter r; and 
         [0169]    The large integer operating unit  407  configured to generate the digital signature parameter s is configured: 
         [0170]    To perform an operation of result (r+k) modulo the elliptical curve parameter n; 
         [0171]    To add 1 to the private key d A , and then calculate a modular inverse of (1+d A ) modulo the elliptical curve parameter n; 
         [0172]    To perform a large integer multiplication operation on a result of (r+k) modulo n, and a result of the modular inverse; and 
         [0173]    To subtract the digital signature parameter r from a result of the large integer multiplication operation, and then perform an operation of a result of the large integer multiplication operation, after the digital signature parameter r being subtracted, modulo the elliptical curve parameter n to obtain the digital signature parameter s. 
         [0174]    Further to the embodiment illustrated in  FIG. 4 , preferably if the validity judgment unit  408  judges the validity of the digital signature parameter r using an operation result (r+k)mod n of the validity judgment condition on the digital signature parameter r, then the large integer operating unit  407  further generates the operation result (r+k)mod n of the validity judgment condition on the digital signature parameter r using the digital signature parameter r generated; the random number k generated by the random number generator  404 , and the elliptical curve parameter n after generating the digital signature parameter r; and 
         [0175]    The large integer operating unit  407  configured to generate the digital signature parameter s is configured: 
         [0176]    To add 1 to the private key d A , and then calculate a modular inverse of (1+d A ) modulo the elliptical curve parameter n; 
         [0177]    To perform a large integer multiplication operation on the operation result (r+k)mod n, and a result of the modular inverse; and 
         [0178]    To subtract the digital signature parameter r from a result of the large integer multiplication operation, and then perform an operation of a result of the large integer multiplication operation, after the digital signature parameter r being subtracted, modulo the elliptical curve parameter n to obtain the digital signature parameter s. 
         [0179]    Further to any one of the embodiments illustrated in  FIG. 4 , the private key d A  used by the large integer operating unit  407  can be generated by the device, or can be obtained from the outside, as described below by way of an example. 
         [0180]    First Implementation: 
         [0181]    The device according to the embodiment of the invention further includes a key generating unit and a key storing unit, where the key generating unit is configured to generate the private key d A , and the key storing unit is configured to store the private key d A  generated by the key generating unit. 
         [0182]    Accordingly the large integer operating unit  407  obtains the private key d A  from the key storing unit to generate the digital signature parameter s. 
         [0183]    Second Implementation: 
         [0184]    The parameter input interface unit  401  is further configured to obtain the private key d A . 
         [0185]    Accordingly the large integer operating unit  407  obtains the private key d A  from the parameter input interface unit  401  to generate the digital signature parameter s. 
         [0186]    Third Implementation: 
         [0187]    The device according to the embodiment of the invention further includes a key storing unit. 
         [0188]    The parameter input interface unit  401  is further configured to obtain the private key d A ; and the key storing unit is configured to store the private key d A  obtained by the parameter input interface unit  401 . 
         [0189]    Accordingly the large integer operating unit  407  obtains the private key d A  from the key storing unit to generate the digital signature parameter s. 
         [0190]    Those skilled in the art shall appreciate that the embodiments of the invention can be embodied as a method, a system or a computer program product. Therefore the invention can be embodied in the form of an all-hardware embodiment, an all-software embodiment or an embodiment of software and hardware in combination. Furthermore the invention can be embodied in the form of a computer program product embodied in one or more computer useable storage mediums (including but not limited to a disk memory, a CD-ROM, an optical memory, etc.) in which computer useable program codes are contained. 
         [0191]    The invention has been described in a flow chart and/or a block diagram of the method, the device (system) and the computer program product according to the embodiments of the invention. It shall be appreciated that respective flows and/or blocks in the flow chart and/or the block diagram and combinations of the flows and/or the blocks in the flow chart and/or the block diagram can be embodied in computer program instructions. These computer program instructions can be loaded onto a general-purpose computer, a specific-purpose computer, an embedded processor or a processor of another programmable data processing device to produce a machine so that the instructions executed on the computer or the processor of the other programmable data processing device create means for performing the functions specified in the flow(s) of the flow chart and/or the block(s) of the block diagram. 
         [0192]    These computer program instructions can also be stored into a computer readable memory capable of directing the computer or the other programmable data processing device to operate in a specific manner so that the instructions stored in the computer readable memory create an article of manufacture including instruction means which perform the functions specified in the flow(s) of the flow chart and/or the block(s) of the block diagram. 
         [0193]    These computer program instructions can also be loaded onto the computer or the other programmable data processing device so that a series of operational steps are performed on the computer or the other programmable data processing device to create a computer implemented process so that the instructions executed on the computer or the other programmable device provide steps for performing the functions specified in the flow(s) of the flow chart and/or the block(s) of the block diagram. 
         [0194]    Although the preferred embodiments of the invention have been described, those skilled in the art benefiting from the underlying inventive concept can make additional modifications and variations to these embodiments. Therefore the appended claims are intended to be construed as encompassing the preferred embodiments and all the modifications and variations coming into the scope of the invention. 
         [0195]    Evidently those skilled in the art can make various modifications and variations to the invention without departing from the spirit and scope of the invention. Thus the invention is also intended to encompass these modifications and variations thereto so long as the modifications and variations come into the scope of the claims appended to the invention and their equivalents.