A signature verification method and device based on SM2, equipment and storage medium
Patent Information
- Application Number
- CN202311296448.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-09
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-10-09
AI Technical Summary
[0037] In this application, the process involves obtaining information to be signed and the corresponding digital signature, determining target parameters based on the digital signature and the order of the elliptic curve base points, and converting the coordinates of the public key and the coordinates of the elliptic curve base points into first and second Jacobian coordinates in the Montgomery domain, respectively. A dot product operation is performed on the target parameters and the first Jacobian coordinates to obtain a first target result. A dot product operation is also performed on the first signature value in the digital signature and the second Jacobian coordinates to obtain a second target result. A dot addition operation is performed on the first and second target results to obtain a third target result, which is then converted into affine coordinates. When the signature value to be verified, determined based on the affine coordinates and the information to be signed, matches the second signature value in the digital signature, the verification of the information to be signed and the digital signature is deemed successful. Therefore, this application transforms the coordinates of the public key and the coordinates of the elliptic curve base point into the first and second Jacobian coordinates in the Montgomery field, respectively. This enables the dot product operation on the two Jacobian coordinates in the Montgomery field. After the dot product operation, the third target result obtained by dot addition based on the first and second target results is transformed into affine coordinates for verification of the information to be signed and the digital signature. Compared with the ordinary signature verification method, this saves two inversion operations and improves the signature verification performance of SM2.
Smart Images

Figure CN117220890B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of signature verification technology, and in particular to a signature verification method, apparatus, device and storage medium based on SM2. Background Technology
[0002] The SM2 algorithm (Elliptic Curve Public Key Cryptography) is currently the standard commercial cryptographic algorithm. Digital signature and verification technologies based on the SM2 algorithm have been widely used in various fields such as finance, payment, and government affairs, becoming the cornerstone of information security. Therefore, improving the performance of the SM2 signature verification algorithm is an important direction for SM2 algorithm optimization; that is, how to improve the performance of the SM2 signature verification method is a problem that needs to be solved. Summary of the Invention
[0003] In view of this, the purpose of this invention is to provide a signature verification method, apparatus, device, and storage medium based on SM2, which can perform dot product and dot addition operations using Jacobian coordinates in the Montgomery domain, and then convert the target result into affine coordinates after the dot addition is completed. Compared with the ordinary signature verification method, this saves two inversion operations and improves the signature verification performance of SM2. The specific scheme is as follows:
[0004] Firstly, this application provides a signature verification method based on SM2, including:
[0005] Obtain the information to be signed and the corresponding digital signature, determine the target parameters based on the digital signature and the order of the elliptic curve base point, and convert the coordinates of the public key and the coordinates of the elliptic curve base point into the first Jacobian coordinates and the second Jacobian coordinates in the Montgomery domain, respectively.
[0006] Perform a dot product operation on the target parameters and the first Jacobian coordinates to obtain the first target result;
[0007] Perform a dot product operation on the first signature value and the second Jacobian coordinate in the digital signature to obtain the second target result;
[0008] A dot-matrix operation is performed on the first target result and the second target result to obtain a third target result. The third target result is then converted into affine coordinates. When the signature value to be verified, determined based on the affine coordinates and the information to be signed, is consistent with the second signature value in the digital signature, the verification of the information to be signed and the digital signature is deemed successful.
[0009] Optionally, the step of performing a dot product operation on the target parameter and the first Jacobian coordinate to obtain the first target result includes:
[0010] The first Jacobian coordinates are determined as the current public key coordinates, the target parameter is determined as the current parameter, and the first preset coordinates are configured as the first current result;
[0011] Determine whether the least bit of the current parameter is equal to a first preset value. If the least bit of the current parameter is not equal to the first preset value, perform a doubling operation on the current public key coordinates to obtain a new current public key coordinate, and perform a first preset right shift operation on the current parameter to obtain a new current parameter. Then determine whether the current parameter is greater than a first preset threshold.
[0012] If the current parameter is greater than the first preset threshold, then jump back to the step of determining whether the least bit of the current parameter is equal to the first preset value;
[0013] If the current parameter is not greater than the first preset threshold, then the first current result is determined as the first target result.
[0014] Optionally, after determining whether the least significant bit of the current parameter is equal to a first preset value, the method further includes:
[0015] If the least bit of the current parameter is equal to the first preset value, then a dot-plus operation is performed on the current public key coordinates and the first current result to obtain a new first current result, and then the process jumps back to the step of performing a doubling operation on the current public key coordinates.
[0016] Optionally, performing a dot product operation on the first signature value and the second Jacobian coordinate in the digital signature to obtain the second target result includes:
[0017] The second Jacobian coordinates are determined as the current base point coordinates, the first signature value in the digital signature is determined as the current signature value, and the second preset coordinates are configured as the second current result;
[0018] Determine whether the least bit of the current signature value is equal to the second preset value. If the least bit of the current signature value is not equal to the second preset value, perform a doubling operation on the current base point coordinates to obtain new current base point coordinates, and perform a second preset right shift operation on the current signature value to obtain a new current signature value. Then determine whether the current signature value is greater than the second preset threshold.
[0019] If the current signature value is greater than the second preset threshold, then jump back to the step of determining whether the least significant bit of the current signature value is equal to the second preset value;
[0020] If the current signature value is not greater than the second preset threshold, then the second current result is determined as the second target result.
[0021] Optionally, after determining whether the least significant bit of the current signature value is equal to the second preset value, the method further includes:
[0022] If the least bit of the current signature value is equal to the second preset value, then a dot addition operation is performed on the current base point coordinates and the second current result to obtain a new second current result, and then the process jumps back to the step of performing a doubling operation on the current base point coordinates.
[0023] Optionally, the step of converting the coordinates of the public key and the coordinates of the elliptic curve base point into first and second Jacobian coordinates in the Montgomery domain, respectively, includes:
[0024] Determine the bit length of the preset modulus in the Montgomery domain, and determine the conversion parameters based on the bit length and the preset modulus;
[0025] Based on the transformation parameters, the coordinates of the public key and the coordinates of the elliptic curve base point are respectively transformed into the first Jacobian coordinates and the second Jacobian coordinates in the Montgomery domain.
[0026] Optionally, converting the third target result into affine coordinates includes:
[0027] The third target result is transformed using the Montgomery modular multiplication algorithm and based on the preset modulus and the transformation parameters to obtain the corresponding affine coordinates.
[0028] Secondly, this application provides a signature verification device based on SM2, comprising:
[0029] The coordinate transformation module is used to obtain the information to be signed and the corresponding digital signature, and to determine the target parameters based on the digital signature and the order of the elliptic curve base point, and to transform the coordinates of the public key and the coordinates of the elliptic curve base point into the first Jacobian coordinates and the second Jacobian coordinates in the Montgomery domain, respectively.
[0030] The first result determination module is used to perform a dot product operation on the target parameter and the first Jacobian coordinate to obtain the first target result;
[0031] The second result determination module is used to perform a dot product operation on the first signature value and the second Jacobian coordinate in the digital signature to obtain the second target result;
[0032] The signature verification module is used to perform a dot-matrix operation on the first target result and the second target result to obtain a third target result, and convert the third target result into affine coordinates. When the signature value to be verified determined based on the affine coordinates and the information to be signed is consistent with the second signature value in the digital signature, it is determined that the verification of the information to be signed and the digital signature is successful.
[0033] Thirdly, this application provides an electronic device, comprising:
[0034] Memory, used to store computer programs;
[0035] A processor is used to execute the computer program to implement the aforementioned SM2-based signature verification method.
[0036] Fourthly, this application provides a computer-readable storage medium for storing a computer program that, when executed by a processor, implements the aforementioned signature verification method based on SM2.
[0037] In this application, the process involves obtaining information to be signed and the corresponding digital signature, determining target parameters based on the digital signature and the order of the elliptic curve base points, and converting the coordinates of the public key and the coordinates of the elliptic curve base points into first and second Jacobian coordinates in the Montgomery domain, respectively. A dot product operation is performed on the target parameters and the first Jacobian coordinates to obtain a first target result. A dot product operation is also performed on the first signature value in the digital signature and the second Jacobian coordinates to obtain a second target result. A dot addition operation is performed on the first and second target results to obtain a third target result, which is then converted into affine coordinates. When the signature value to be verified, determined based on the affine coordinates and the information to be signed, matches the second signature value in the digital signature, the verification of the information to be signed and the digital signature is deemed successful. Therefore, this application transforms the coordinates of the public key and the coordinates of the elliptic curve base point into the first and second Jacobian coordinates in the Montgomery field, respectively. This enables the dot product operation on the two Jacobian coordinates in the Montgomery field. After the dot product operation, the third target result obtained by dot addition based on the first and second target results is transformed into affine coordinates for verification of the information to be signed and the digital signature. Compared with the ordinary signature verification method, this saves two inversion operations and improves the signature verification performance of SM2. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0039] Figure 1 This application discloses a flowchart of a signature verification method based on SM2.
[0040] Figure 2 This is a schematic diagram of a signature verification device based on SM2 disclosed in this application;
[0041] Figure 3 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0042] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0043] The SM2 algorithm is currently the standard commercial cryptographic algorithm. Digital signature and verification technologies based on the SM2 algorithm have been widely used in various fields such as finance, payment, and government affairs, becoming the cornerstone of information security. Therefore, how to improve the performance of SM2 signature verification methods is a problem that needs to be solved. To this end, this application provides a signature verification method based on SM2. By using Jacobian coordinates in the Montgomery field to perform dot multiplication and dot addition operations, and then converting the target result into affine coordinates after the dot addition, this method saves two inversion operations compared to ordinary signature verification methods, thus improving the signature verification performance of SM2.
[0044] See Figure 1 As shown, this embodiment of the invention discloses a signature verification method based on SM2, including:
[0045] Step S11: Obtain the information to be signed and the corresponding digital signature, and determine the target parameters based on the digital signature and the order of the elliptic curve base point, and convert the coordinates of the public key and the coordinates of the elliptic curve base point into the first Jacobian coordinates and the second Jacobian coordinates in the Montgomery domain, respectively.
[0046] In this embodiment, to-be-signed information message and a digital signature corresponding to the to-be-signed information are obtained, wherein the digital signature comprises a first signature value s and a second signature value r, the first signature value s is the latter half of the digital signature, and the second signature value r is the first half of the digital signature. The order N of the elliptic curve base point G is obtained, and a target parameter a is determined based on the order N, the first signature value s and the second signature value r, that is, a=(r+s)mod N, wherein mod represents a modular operation. If the target parameter is equal to zero, it indicates that the verification of the to-be-signed information and the corresponding digital signature fails. If the target parameter is not equal to zero, the coordinates of the public key P and the coordinates of the elliptic curve base point G are respectively converted into a first Jacobian coordinate and a second Jacobian coordinate in the Montgomery domain.
[0047] Further, the bit length n_bit of a preset modulus p in the Montgomery domain is determined, and a conversion parameter R is determined based on the bit length and the preset modulus, that is, R=(1<<n_bit)mod p, wherein << represents a left shift operation. The coordinates (Px, Py) of the public key and the coordinates (Gx, Gy) of the elliptic curve base point are respectively converted into the first Jacobian coordinate and the second Jacobian coordinate in the Montgomery domain based on the conversion parameter. Specifically, for the coordinates of the public key P, Pz is set to 1 by default, and Px, Py and Pz are respectively multiplied by the conversion parameter R to obtain the first Jacobian coordinate (PxR, PyR, PzR) corresponding to the public key P in the Montgomery domain, and the related formulas are as follows:
[0048] PxR=Px*R;
[0049] PyR=Py*R;
[0050] PzR=Pz*R;
[0051] For the coordinates of the elliptic curve base point G, Gz is set to 1 by default, and Gx, Gy and Gz are respectively multiplied by the conversion parameter R to obtain the second Jacobian coordinate (GxR, GyR, GzR) corresponding to the elliptic curve base point G in the Montgomery domain.
[0052] Step S12: performing a point multiplication operation on the target parameter and the first Jacobian coordinate to obtain a first target result.
[0053] In this embodiment, if the target parameter is not equal to zero, since the target parameter is a value greater than or equal to 0, a ≠ 0, i.e., a > 0. Therefore, a dot product operation is performed on the target parameter and the first Jacobian coordinates to obtain the first target result (x1R, y1R, z1R). Specifically, the first Jacobian coordinates are determined as the current public key coordinates (PxR, PyR, PzR), the target parameter is determined as the current parameter a, and a first preset coordinate is configured as the first current result (x1R, y1R, z1R); where the first preset coordinate defaults to (0, 0, 0). It is determined whether the least significant bit of the current parameter is equal to 1. If the least significant bit of the current parameter is not equal to 1, a dot product operation is performed on the current public key coordinates to obtain the new current public key coordinates (PxR, PyR, PzR), and a first preset right shift operation is performed on the current parameter, i.e., a = a >> 1, where >> represents a right shift operation, i.e., shifting one bit to the right to obtain the new current parameter. Then, it is determined whether the new current parameter is greater than 0. If the current parameter is greater than 0, the process jumps back to the step of determining whether the least significant bit of the current parameter is equal to 1. If the current parameter is not greater than 0, the first current result is determined as the first target result and output (x1R, y1R, z1R). If the least significant bit of the current parameter is equal to 1, a point addition operation of Jacobian coordinates is performed on the current public key coordinates (PxR, PyR, PzR) and the first current result (x1R, y1R, z1R) to obtain the new first current result (x1R, y1R, z1R), and the process jumps back to the step of performing a point multiplication operation of Jacobian coordinates on the current public key coordinates.
[0054] Step S13: Perform a dot product operation on the first signature value and the second Jacobian coordinate in the digital signature to obtain the second target result.
[0055] In this embodiment, if the first signature value s in the digital signature is not equal to zero, since the first signature value is a value greater than or equal to 0, s ≠ 0, i.e., s > 0. Therefore, a dot product operation is performed on the first signature value and the second Jacobian coordinates to obtain the second target result (x²R, y²R, z²R). Specifically, the second Jacobian coordinates are determined as the current base point coordinates (GxR, GyR, GzR), the first signature value in the digital signature is determined as the current signature value s, and the second preset coordinates are configured as the second current result (x²R, y²R, z²R), where the second preset coordinates are (0, 0, 0). Further, it is determined whether the least significant bit of the current signature value s is equal to 1. If the least significant bit of the current signature value is not equal to 1, a Jacobian coordinate doubling operation is performed on the current base point coordinates to obtain the new current base point coordinates (GxR, GyR, GzR), and a second preset right shift operation is performed on the current signature value, s = s >> 1, where >> represents a right shift operation, that is, shifting one bit to the right to obtain the new current signature value. Then it is determined whether the new current signature value is greater than 0; if the current signature value is greater than 0, it jumps back to the step of determining whether the least significant bit of the current signature value s is equal to 1; if the current signature value is not greater than 0, the second current result is determined as the second target result and output (x2R, y2R, z2R). If the least significant bit of the current signature value is equal to 1, then perform a point addition operation of Jacobian coordinates on the current base point coordinates (GxR, GyR, GzR) and the second current result (x2R, y2R, z2R) to obtain a new second current result (x2R, y2R, z2R), and then jump back to the above step of performing a point multiplication operation of Jacobian coordinates on the current base point coordinates.
[0056] Step S14: Perform a dot addition operation on the first target result and the second target result to obtain a third target result, and convert the third target result into affine coordinates. When the signature value to be verified determined based on the affine coordinates and the signature information to be signed is consistent with the second signature value in the digital signature, it is determined that the verification of the signature information to be signed and the digital signature is successful.
[0057] In this embodiment, the first target result (x1R, y1R, z1R) and the second target result (x2R, y2R, z2R) are subjected to point addition of Jacobian coordinates to obtain the third target result (x3R, y3R, z3R), where the third target result is also the Jacobian coordinate in the Montgomery domain; and the third target result is transformed into affine coordinates (x3, y3, z3) in the modular p domain using the Montgomery modular multiplication algorithm, with the following formulas:
[0058] x3=x3R*1*R -1 (mod p);
[0059] y3=y3R*1*R -1 (mod p);
[0060] z3=z3R*1*R -1 (mod p);
[0061] Where R represents the transformation parameter and p represents the preset modulus. Further, based on x3 and z3, the intermediate parameter x4 is determined, x4 = x3 / z3. 2 Then, based on the message to be signed, intermediate parameters, and the order N of the elliptic curve base point, the signature value r1 to be verified is determined, r1 = (message + x4) mod N. It is then determined whether the signature value r1 to be verified is consistent with the second signature value r in the digital signature. If they are consistent, i.e., r1 = r, then the verification of the message to be signed and the digital signature is successful; if they are inconsistent, i.e., r1 ≠ r, then the verification of the message to be signed and the digital signature fails.
[0062] Therefore, this application transforms the coordinates of the public key and the coordinates of the elliptic curve base point into the first and second Jacobian coordinates in the Montgomery field, respectively. This enables the dot product operation on the two Jacobian coordinates in the Montgomery field. After the dot product operation, the third target result obtained by dot addition based on the first and second target results is transformed into affine coordinates for verification of the information to be signed and the digital signature. Compared with the ordinary signature verification method, this saves two inversion operations and improves the signature verification performance of SM2.
[0063] See Figure 2 As shown, an embodiment of the present invention discloses a signature verification device based on SM2, comprising:
[0064] The coordinate transformation module 11 is used to obtain the information to be signed and the corresponding digital signature, and to determine the target parameters based on the digital signature and the order of the elliptic curve base point, and to transform the coordinates of the public key and the coordinates of the elliptic curve base point into the first Jacobian coordinates and the second Jacobian coordinates in the Montgomery domain, respectively.
[0065] The first result determination module 12 is used to perform a dot product operation on the target parameter and the first Jacobian coordinate to obtain the first target result;
[0066] The second result determination module 13 is used to perform a dot product operation on the first signature value and the second Jacobian coordinate in the digital signature to obtain the second target result;
[0067] The signature verification module 14 is used to perform a dot addition operation on the first target result and the second target result to obtain a third target result, and convert the third target result into affine coordinates. When the signature value to be verified determined based on the affine coordinates and the signature information to be signed is consistent with the second signature value in the digital signature, it is determined that the verification of the signature information to be signed and the digital signature is successful.
[0068] Therefore, this application transforms the coordinates of the public key and the coordinates of the elliptic curve base point into the first and second Jacobian coordinates in the Montgomery field, respectively. This enables the dot product operation on the two Jacobian coordinates in the Montgomery field. After the dot product operation, the third target result obtained by dot addition based on the first and second target results is transformed into affine coordinates for verification of the information to be signed and the digital signature. Compared with the ordinary signature verification method, this saves two inversion operations and improves the signature verification performance of SM2.
[0069] In some specific embodiments, the first result determination module 12 includes:
[0070] The first current information determination unit is used to determine the first Jacobian coordinates as the current public key coordinates, determine the target parameter as the current parameter, and configure the first preset coordinates as the first current result;
[0071] The first doubling unit is used to determine whether the least bit of the current parameter is equal to a first preset value. If the least bit of the current parameter is not equal to the first preset value, then the doubling operation is performed on the current public key coordinates to obtain a new current public key coordinate, and the first preset right shift operation is performed on the current parameter to obtain a new current parameter. Then, it is determined whether the current parameter is greater than a first preset threshold.
[0072] The first step jump unit is used to jump back to the step of determining whether the least bit of the current parameter is equal to the first preset value if the current parameter is greater than the first preset threshold.
[0073] The first result determination unit is used to determine the first current result as the first target result if the current parameter is not greater than the first preset threshold.
[0074] In some specific embodiments, the first result determination module 12 further includes:
[0075] The first dot-add unit is used to perform a dot-add operation on the current public key coordinates and the first current result if the least bit of the current parameter is equal to the first preset value, so as to obtain a new first current result, and then jump back to the step of performing a doubling operation on the current public key coordinates.
[0076] In some specific embodiments, the second result determination module 13 includes:
[0077] The second current information determination unit is used to determine the second Jacobian coordinates as the current base point coordinates, determine the first signature value in the digital signature as the current signature value, and configure the second preset coordinates as the second current result;
[0078] The second doubling unit is used to determine whether the least bit of the current signature value is equal to the second preset value. If the least bit of the current signature value is not equal to the second preset value, then the doubling operation is performed on the current base point coordinates to obtain the new current base point coordinates, and the second preset right shift operation is performed on the current signature value to obtain the new current signature value. Then, it is determined whether the current signature value is greater than the second preset threshold.
[0079] The second step jump unit is used to jump back to the step of determining whether the least bit of the current signature value is equal to the second preset value if the current signature value is greater than the second preset threshold.
[0080] The second result determination unit is used to determine the second current result as the second target result if the current signature value is not greater than the second preset threshold.
[0081] In some specific embodiments, the second result determining module 13 further includes:
[0082] The second dot-add unit is used to perform a dot-add operation on the current base point coordinates and the second current result if the least bit of the current signature value is equal to the second preset value, so as to obtain a new second current result, and then jump back to the step of performing a doubling operation on the current base point coordinates.
[0083] In some specific embodiments, the coordinate transformation module 11 includes:
[0084] A conversion parameter determination unit is used to determine the bit length of a preset modulus in the Montgomery domain, and to determine conversion parameters based on the bit length and the preset modulus;
[0085] The coordinate transformation unit is used to transform the coordinates of the public key and the coordinates of the elliptic curve base point into first Jacobian coordinates and second Jacobian coordinates in the Montgomery domain, respectively, based on the transformation parameters.
[0086] In some specific embodiments, the signature verification module 14 includes:
[0087] The affine coordinate determination unit is used to transform the third target result using the Montgomery modular multiplication algorithm and based on the preset modulus and the transformation parameters to obtain the corresponding affine coordinates.
[0088] Furthermore, embodiments of this application also disclose an electronic device, Figure 3 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0089] Figure 3 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the signature verification method based on SM2 disclosed in any of the foregoing embodiments. Alternatively, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0090] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0091] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0092] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the SM2-based signature verification method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0093] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned SM2-based signature verification method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0094] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0095] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0096] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0097] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0098] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A signature verification method based on SM2, characterized in that, include: Obtain the information to be signed and the corresponding digital signature, determine the target parameters based on the digital signature and the order of the elliptic curve base point, and convert the coordinates of the public key and the coordinates of the elliptic curve base point into the first Jacobian coordinates and the second Jacobian coordinates in the Montgomery domain, respectively. Perform a dot product operation on the target parameters and the first Jacobian coordinates to obtain the first target result; Perform a dot product operation on the first signature value and the second Jacobian coordinate in the digital signature to obtain the second target result; A dot-matrix operation is performed on the first target result and the second target result to obtain a third target result. The third target result is then converted into affine coordinates. When the signature value to be verified, determined based on the affine coordinates and the signature information to be signed, is consistent with the second signature value in the digital signature, the verification of the signature information to be signed and the digital signature is deemed successful. The first signature value is the latter half of the digital signature, and the second signature value is the first half of the digital signature; The step of performing a dot product operation on the target parameter and the first Jacobian coordinate to obtain the first target result includes: The first Jacobian coordinates are determined as the current public key coordinates, the target parameter is determined as the current parameter, and the first preset coordinates are configured as the first current result; Determine whether the least bit of the current parameter is equal to a first preset value. If the least bit of the current parameter is not equal to the first preset value, perform a doubling operation on the current public key coordinates to obtain a new current public key coordinate, and perform a first preset right shift operation on the current parameter to obtain a new current parameter. Then determine whether the current parameter is greater than a first preset threshold. If the current parameter is greater than the first preset threshold, then jump back to the step of determining whether the least bit of the current parameter is equal to the first preset value; If the current parameter is not greater than the first preset threshold, then the first current result is determined as the first target result; If the least bit of the current parameter is equal to the first preset value, then perform a dot addition operation on the current public key coordinates and the first current result to obtain a new first current result, and then jump back to the step of performing a doubling operation on the current public key coordinates; The step of performing a dot product operation on the first signature value and the second Jacobian coordinate in the digital signature to obtain the second target result includes: The second Jacobian coordinates are determined as the current base point coordinates, the first signature value in the digital signature is determined as the current signature value, and the second preset coordinates are configured as the second current result; Determine whether the least bit of the current signature value is equal to the second preset value. If the least bit of the current signature value is not equal to the second preset value, perform a doubling operation on the current base point coordinates to obtain new current base point coordinates, and perform a second preset right shift operation on the current signature value to obtain a new current signature value. Then determine whether the current signature value is greater than the second preset threshold. If the current signature value is greater than the second preset threshold, then jump back to the step of determining whether the least significant bit of the current signature value is equal to the second preset value; If the current signature value is not greater than the second preset threshold, then the second current result is determined as the second target result; If the least bit of the current signature value is equal to the second preset value, then a dot addition operation is performed on the current base point coordinates and the second current result to obtain a new second current result, and then the process jumps back to the step of performing a doubling operation on the current base point coordinates.
2. The signature verification method based on SM2 according to claim 1, characterized in that, The step of converting the coordinates of the public key and the coordinates of the elliptic curve base point into first and second Jacobian coordinates in the Montgomery domain, respectively, includes: Determine the bit length of the preset modulus in the Montgomery domain, and determine the conversion parameters based on the bit length and the preset modulus; Based on the transformation parameters, the coordinates of the public key and the coordinates of the elliptic curve base point are respectively transformed into the first Jacobian coordinates and the second Jacobian coordinates in the Montgomery domain.
3. The signature verification method based on SM2 according to claim 2, characterized in that, The process of converting the third target result into affine coordinates includes: The third target result is transformed using the Montgomery modular multiplication algorithm and based on the preset modulus and the transformation parameters to obtain the corresponding affine coordinates.
4. A signature verification device based on SM2, characterized in that, The SM2-based signature verification device is used to implement the SM2-based signature verification method as described in any one of claims 1 to 3, wherein the SM2-based signature verification device comprises: The coordinate transformation module is used to obtain the information to be signed and the corresponding digital signature, and to determine the target parameters based on the digital signature and the order of the elliptic curve base point, and to transform the coordinates of the public key and the coordinates of the elliptic curve base point into the first Jacobian coordinates and the second Jacobian coordinates in the Montgomery domain, respectively. The first result determination module is used to perform a dot product operation on the target parameter and the first Jacobian coordinate to obtain the first target result; The second result determination module is used to perform a dot product operation on the first signature value and the second Jacobian coordinate in the digital signature to obtain the second target result; The signature verification module is used to perform a dot-matrix operation on the first target result and the second target result to obtain a third target result, and convert the third target result into affine coordinates. When the signature value to be verified determined based on the affine coordinates and the information to be signed is consistent with the second signature value in the digital signature, it is determined that the verification of the information to be signed and the digital signature is successful; the first signature value is the latter half of the digital signature, and the second signature value is the former half of the digital signature.
5. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the SM2-based signature verification method as described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the signature verification method based on SM2 as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Elliptic curve signature method, signature verification method and device
CN113032844A
Hardware rapid implementation method for point multiplication operation in prime number field
CN115001691A