Point addition operation module and public key generation method and encryption and decryption method using the same
By designing the point addition operation module, variables that may be 0 are converted into subtrahends to avoid division by 0 operations. This solves the security vulnerability caused by the point addition operation of the Montgomery ladder algorithm in elliptic curve cryptography and enhances the security of the encryption process.
Patent Information
- Application Number
- CN202211204150.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-09-29
AI Technical Summary
In the existing elliptic curve cryptography, the point addition operation based on the Montgomery ladder algorithm has a division by 0 operation, which leads to system errors and side channel leakage, affecting encryption security.
A dot addition operation module is designed, which avoids division by 0 operations and ensures the security of the encryption process by converting variables that may be 0 from the divisor position to the subtrahend position. This module contains modular subtraction, modular multiplication, modular addition and modular division units, and calculates the x-coordinate of the point addition result based on the coordinates of the curve points and the curve parameters.
It effectively avoids the division-by-zero operation in the elliptic curve encryption process, enhances the security of the encryption process, prevents side channel leaks and fault injection attacks, and ensures the security of public key generation and information encryption.
Smart Images

Figure CN115495764B
Abstract
Description
Technical Field
[0001] The present disclosure generally relates to the field of information encryption technology. More specifically, the present disclosure relates to a point addition operation module and a public key generation method and an encryption and decryption method using the same. Background Art
[0002] Since its introduction in 1985, elliptic curve cryptography (ECC) has developed into an important public key encryption technology. Based on ECC technology, a variety of cryptographic algorithm standards have been developed, such as ECDSA and SM2. ECC is complex to implement, and studying its efficient implementation is of great significance to the application of ECC in practical problems.
[0003] The Montgomery Power Ladder (MPL) algorithm is a protection algorithm against timing attacks. Its characteristics are that the execution path is independent of the key and the algorithm does not contain pseudo operations. Relying on the special structure of the MPL algorithm, the intermediate data of the MPL algorithm have a special relationship.
[0004] For the point addition and doubling operations of intermediate data that satisfy the above special relationship, in order to improve the implementation efficiency of the operation, a point addition operation method that does not require a y coordinate is proposed in the prior art to adapt to the encryption algorithm. However, since the division operation involved in this method involves a division by 0 operation, it is easy to cause the system to report an error, and even lead to side channel leakage, or attackers can use this error to perform fault injection attacks, affecting encryption security.
[0005] In view of this, there is an urgent need to provide a point addition operation module to solve the security loopholes in the encryption process caused by the point addition operation method in the MPL algorithm. Summary of the invention
[0006] In order to at least solve one or more of the technical problems mentioned above, the present disclosure proposes a point addition operation module and a public key generation method and encryption and decryption method using the same in multiple aspects to achieve more reliable and secure information encryption and decryption.
[0007] In a first aspect, the present disclosure provides a point addition operation module, the input end of the point addition operation module is used to receive the x-coordinates of two curve points in a curve point group; wherein the modular subtraction result of the two curve points is a fixed point, and the point addition operation module is initialized based on the fixed point; the output end of the point addition operation module is used to output the x-coordinate of the point-plus-curve point corresponding to the point addition operation result of the two curve points; the point addition operation module is configured to: obtain a first variable based on the x-coordinates of the two curve points and the curve parameters of the curve point group; use the x-coordinate of the modular subtraction result of the two curve points as the second variable, and take the modular subtraction result of the first variable and the second variable as the x-coordinate of the point-plus-curve point.
[0008] In some embodiments, the point addition operation module includes a subtraction unit; the subtraction unit is configured to: perform subtraction on the x-coordinates of the two curve points to obtain the second variable, and perform subtraction on the first variable and the second variable to obtain the x-coordinate of the point plus the curve point.
[0009] In some embodiments, the point addition operation module is further configured to determine the first variable according to a modular multiplication result, a modular addition result and a modular subtraction result of the x-coordinates of the two curve points, and a curve parameter of the curve point group.
[0010] In some embodiments, the point addition operation module also includes a modular multiplication unit, a modular addition unit and a modular division unit; the modular multiplication unit is respectively connected to the modular subtraction unit, the modular addition unit and the modular division unit, and is configured to: perform modular multiplication based on the x-coordinates of the two curve points to obtain multiple intermediate variables required for calculating the first variable; the modular addition unit is configured to: perform modular addition based on the curve parameters of the curve point group and the x-coordinates of the two curve points to obtain multiple intermediate variables required for calculating the first variable; the modular subtraction unit is also configured to: perform modular subtraction based on the x-coordinates of the two curve points to obtain multiple intermediate variables required for calculating the first variable; the modular division unit is connected to the modular subtraction unit, and is configured to: perform modular division based on the multiple intermediate variables to obtain the first variable.
[0011] In some embodiments, if the coordinates of the two curve points are affine coordinates, then correspondingly, the point addition operation module is configured to calculate the x-coordinate of the point-plus-curve point according to the following formula:
[0012]
[0013] Among them, x1 and x2 are the x coordinates of the two curve points respectively, a and b are curve parameters of the curve point group, x3 is the x coordinate of the point plus the curve point, and x is the x coordinate of the result of the modular subtraction of the two curve points.
[0014] In some embodiments, if the coordinates of the two curve points are Jacobian coordinates, then correspondingly, the point addition operation module is configured to calculate the x-coordinate of the point-plus-curve point according to the following formula:
[0015]
[0016] in,
[0017] In some embodiments, the point addition operation module also includes a storage unit; the storage unit is respectively connected to the modular subtraction unit, the modular multiplication unit, the modular addition unit and the modular division unit; the constant 4b is pre-stored in the storage unit; the storage unit is used to store the x-coordinates of two curve points in the curve point group received by the input end of the point addition operation module, and to store the multiple intermediate variables, the first variable and the second variable processed by the point addition operation module.
[0018] In a second aspect, the present disclosure provides a method for generating an elliptic curve public key, comprising: determining a base point and a private key; wherein the private key is an integer and is less than the order of the base point in the curve point group of the elliptic curve; based on the base point and the private key, generating a public key through a point addition operation module and a point multiplication operation module to send to an encryption party; wherein the point addition operation module is a point addition operation module as described in any of the above items.
[0019] In a third aspect, the present disclosure provides an elliptic curve encryption method, comprising: obtaining a public key and a base point; the base point is a curve point in the curve point group of the elliptic curve; encoding the information to be encrypted into an information point in the curve point group of the elliptic curve; the information point is a curve point in the curve point group of the elliptic curve that is different from the base point; determining an encrypted integer; based on the encrypted integer and the base point, generating a first encrypted document through a point addition operation module and a point doubling operation module to send to a decryption party; based on the encrypted integer, the information point and the first encrypted document, generating a second encrypted document through the point addition operation module and the point doubling operation module to send to a decryption party; wherein the point addition operation module is a point addition operation module as described in any one of the above items.
[0020] In a fourth aspect, the present disclosure provides an elliptic curve decryption method, comprising: obtaining a first encrypted document and a second encrypted document issued by an encrypting party; based on the first encrypted document, the second encrypted document and a private key, calculating information points through a point addition operation module and a point multiplication operation module; wherein encrypted information is encoded on the information points; decoding the information points to obtain the encrypted information; wherein the point addition operation module is a point addition operation module as described in any one of the above items.
[0021] The point addition operation module disclosed in the present invention can obtain a first variable based on the coordinates of the two curve points performing the point addition operation and the curve parameters of the curve point group. In the point addition operation module disclosed in the present invention, the first variable acts as the minuend; and the x coordinate of the modular subtraction result of the two curve points is used as the second variable, acting as the subtrahend, so as to obtain the x coordinate of the point-added curve point in the point addition operation result through modular subtraction. In the existing point addition operation process, the x coordinate of the modular subtraction result of the two curve points used for the point addition operation is located at the divisor position, and in the actual encryption process, there is a situation where the x coordinate of the modular subtraction result is 0, which leads to a division by 0 operation; and the point addition operation module disclosed in the present invention converts the variable that may be 0 from the divisor to the subtrahend, effectively avoiding the division by 0 operation. Even in the case where the x coordinate of the modular subtraction result of the two curve points is 0, since the subtrahend is 0, it will not cause the system to report an error, nor will it cause the power consumption curve of the system to have an abnormal shape and cause side channel leakage, thereby ensuring the security of the encryption process. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] By reading the detailed description below with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0023] Figure 1 A schematic diagram showing a flow chart of a method for generating an elliptic curve public key according to some embodiments of the present disclosure;
[0024] Figure 2 A schematic diagram showing the operation process of the point addition operation module of some embodiments of the present disclosure;
[0025] Figure 3 A structural block diagram of a point addition operation module in some embodiments of the present disclosure is shown;
[0026] Figure 4 A schematic diagram showing a flow chart of an elliptic curve encryption method according to some embodiments of the present disclosure;
[0027] Figure 5 A schematic diagram showing a flow chart of an elliptic curve decryption method according to some embodiments of the present disclosure;
[0028] Figure 6 A structural block diagram of an electronic device according to some embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0030] It should be understood that the terms "include" and "comprising" used in the specification and claims of the present disclosure indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0031] It should also be understood that the terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. As used in this disclosure and claims, the singular forms of "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise. It should also be further understood that the term "and / or" used in this disclosure and claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations.
[0032] As used in this specification and claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0033] The existing elliptic curve encryption methods involve point addition operations, whether for the public key generation process or the information encryption process. Relying on the special structure of the MPL algorithm, the intermediate data of the MPL algorithm have a special relationship. For the point addition and doubling operations of the intermediate data that satisfy the above special relationship, in order to improve the efficiency of the operation, a point addition method that does not require a y coordinate is proposed in the prior art to adapt the encryption algorithm. However, since the division operation involved in this method involves a division by 0 operation, it is easy to cause the system to report an error, or even cause side channel leakage, or attackers use this error to perform fault injection attacks, affecting encryption security.
[0034] To address this problem, the present disclosure discloses a point addition operation module, which converts a variable that may be 0 from the divisor position to the subtrahend position to effectively avoid the division by 0 operations involved in public key generation and information encryption during the elliptic curve encryption process, thereby ensuring the security of the elliptic curve encryption process.
[0035] The specific implementation of the present disclosure is described in detail below using the public key generation process as an example.
[0036] Figure 1 The schematic diagram of the process of generating the elliptic curve public key of the embodiment of the disclosure is shown. The process of generating the elliptic curve public key of the embodiment of the disclosure may include:
[0037] In step 101, a base point and a private key are determined, wherein the private key is an integer and is smaller than the order of the base point in the curve point group of the elliptic curve.
[0038] It should be noted that in the elliptic curve encryption process, the elliptic curve used is defined on a finite field and discretized to form a number of discrete curve points located on the elliptic curve. These discrete curve points constitute the curve point group of the elliptic curve, and any point in the curve point group can be selected as the base point G.
[0039] It should be noted that if for a curve point on the elliptic curve, assuming it is the base point G, there is a minimum positive integer n that can make the result of scalar multiplication of nG be a point at infinity, then n is the order of G. When determining the private key, the selected private key k should be an integer less than n.
[0040] In the disclosed embodiment, after the selected elliptic curve (after discretization) is determined, a discrete curve point is selected from its curve point group as the base point G, and then the private key k is determined.
[0041] In step 102, based on the base point and the private key, a public key is generated through a point addition operation module and a point multiplication operation module to be sent to the encryption party.
[0042] It should be noted that, in some embodiments, the encrypting party and the decrypting party may upload public data, such as the public key, base point and elliptic curve in the disclosed embodiments, to a public server so that all parties can obtain the data.
[0043] In the disclosed embodiment, after the base point G and the private key k are determined, a public key K=kG is generated through a scalar multiplication operation, which involves point addition and point doubling operations.
[0044] It should be noted that the doubling operation is a special point addition operation for adding two identical curve points, while the point addition operation in this article specifically refers to the point addition operation for two different curve points. For example, taking k as 3, 2G can be calculated by doubling the point operation, and then 2G is used as a new curve point, and the point addition operation is performed with G to obtain K=G+2G.
[0045] In the existing public key generation process, it is assumed that two curve points that need to be added are P1 (x1, y1) and P2 (x2, y2), and the point addition result of P1 and P2 is P3 (x3, y3).
[0046] If (x, y) = P1-P2, the x-coordinate x3 of P3 can be calculated without the y-coordinate by the following formula:
[0047]
[0048] The above is the point addition process in the affine coordinate system. After conversion to the Jacobi coordinate system, the x coordinate X3 of P3 in the Jacobi coordinate system is calculated by the following formula:
[0049]
[0050] in, The Jacobian coordinates of P1 are (X1, Y1, Z1), the Jacobian coordinates of P2 are (X2, Y2, Z2), and the Jacobian coordinates of P3 are (X3, Y3, Z3).
[0051] Therefore, when P(0, y) = P1-P2, the above process will involve a division by 0 operation, resulting in Z3 = 0, which means that P3 is a point at infinity. However, since the selected private key is a positive integer with an order less than the base point, no point at infinity should be generated during the public key generation process.
[0052] Furthermore, according to the basic structure of the elliptic curve, the base point G can generate the entire elliptic curve. Therefore, assuming that P(0, y) = cG, P2 = dG, then P1 = P2 + P(0, y) = (c + d) G, P3 = P1 + P2 = (c + d + d) G. Obviously, P3 should not be a point at infinity.
[0053] Therefore, in the public key generation process of the prior art, there is a functional calculation error caused by the division by zero operation, which causes the power consumption curve to present a special shape, which is easy to distinguish from the normal situation, resulting in side channel leakage. Similarly, attackers may also use this erroneous result to perform fault injection attacks, affecting the security of the entire elliptic curve encryption process.
[0054] To solve this problem, the disclosed embodiment adopts the following point addition operation module to generate a public key in step 102. Taking the point addition operation module performing a point addition operation as an example, combined with Figure 2 The operation process of the point addition module is described below:
[0055] In step 201 , x-coordinates of two curve points in a curve point group are received.
[0056] The result of the modular subtraction of the two curve points is a fixed point, and the point addition operation module is initialized based on the fixed point. That is, assuming that the two input curve points are P1(x1, y1) and P2(x2, y2), P1 and P2 satisfy P(x, y) = P1-P2, and the x coordinate of the fixed point P is used as the operation parameter in the point addition operation module.
[0057] In some embodiments, the two curve points may be the base point G and the doubling point operation result output by the doubling point operation module, for example, when calculating 3G, the two curve points may be the base point G and the doubling point operation result 2G output by the doubling point operation module. In some embodiments, the two curve points may both be the doubling point operation result output by the doubling point operation module, for example, when calculating 6G, the two curve points may be the doubling point operation result 2G and the doubling point operation result 4G.
[0058] In step 202, a first variable is obtained based on the x-coordinates of the two curve points and the curve parameters of the curve point group.
[0059] Specifically, the point addition operation module determines the first variable according to the modular multiplication result, the modular addition result and the modular subtraction result of the x-coordinates of the two curve points, and the curve parameters of the curve point group.
[0060] In the elliptic curve cryptography algorithm, the curve parameters of an elliptic curve defined on a finite field, that is, the curve point group, can be represented by the following parameter group {p, a, b, G, n, h}, where p, a, b are used to determine the elliptic curve, a and b are constants in the affine equation of the elliptic curve, G is the base point, n is the order of the base point G, and h is the integer part of the result of dividing the number of all curve points in the curve point group by n.
[0061] In step 202, the point addition module calculates the x-coordinates of the two curve points and the constants a and b in the affine equation of the elliptic curve according to the formula Calculate the first variable. Where x1 and x2 are the x coordinates of the two curve points.
[0062] It is understandable that if Figure 3As shown, the point addition operation module 300 in the disclosed embodiment includes a modular subtraction unit 301 , a modular multiplication unit 302 , a modular addition unit 303 and a modular division unit 304 .
[0063] The modular multiplication unit 302 is respectively connected to the modular subtraction unit 301, the modular addition unit 303 and the modular division unit 304, and is configured to perform modular multiplication based on the x-coordinates of the two curve points to obtain multiple intermediate variables required to calculate the first variable, for example, the intermediate variable x1x2.
[0064] The modular addition unit 303 is configured to perform modular addition based on the curve parameters of the curve point group and the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable, for example, the intermediate variable x1x2+a.
[0065] The modular subtraction unit 301 is further configured to perform modular subtraction based on the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable, for example, the intermediate variables x1-x2.
[0066] The modular division unit 304 is connected to the modular subtraction unit 301 and is configured to perform modular division based on the multiple intermediate variables to obtain the first variable.
[0067] In step 203, the x-coordinate of the result of the modular subtraction of the two curve points is taken as the second variable, and the result of the modular subtraction of the first variable and the second variable is taken as the x-coordinate of the point-plus-curve point.
[0068] Specifically, in the disclosed embodiment, in step 203, the subtraction unit included in the point addition operation module performs subtraction on the x-coordinates of the two curve points to obtain the second variable, and performs subtraction on the first variable and the second variable to obtain the x-coordinate of the point-plus-curve point.
[0069] Specifically, assume that two curve points are P1(x1, y1) and P2(x2, y2), and the result of adding P1 and P2 is point plus curve point P3(x3, y3). If (x, y) = P1-P2, then x is the second variable obtained by performing modular subtraction on the x coordinates of the two curve points. Next, perform modular subtraction on the first variable and the second variable to obtain the x coordinate of the point plus curve point
[0070] In step 204, the x-coordinate of the point-added curve point corresponding to the point-added operation result of the two curve points is output.
[0071] Furthermore, the coordinates of the point-plus-curve point can also be determined based on the x-coordinate of the point-plus-curve point and the curve parameters of the curve point group. Since the point-plus-curve point P3 and the curve points P1 and P2 used for the point addition operation are all points on the elliptic curve, the y-coordinate of the point-plus-curve point can be determined based on the affine equation of the elliptic curve and the x-coordinate of the point-plus-curve point, thereby determining the coordinates (x3, y3) of the point-plus-curve point.
[0072] In some embodiments, the output end of the point addition operation module outputs the x-coordinate of the point plus curve point to the doubling point operation module for doubling operation. For example, after the point addition operation module calculates the point plus curve point P3=3G (P1=G, P2=2G), it outputs it to the doubling point operation module to calculate P4=6G.
[0073] In some embodiments, the output end of the point addition operation module can also transmit the coordinates of the point plus curve point to the input end of the point addition operation module. For example, after the point addition operation module calculates the point plus curve point P3=3G (P1=G, P2=2G), it transmits it to the input end of the point addition operation module, performs point addition operation with P2, and calculates P5=5G.
[0074] That is, the input end of the point addition operation module executes step 201 to obtain the doubling operation result output by the doubling operation module, and the point addition operation module further calculates the doubling operation result and the point addition operation result of the base point G by executing steps 202 to 204, and sends it to the input end of the doubling operation module through the output end of the point addition operation module for doubling operation until the public key K is obtained.
[0075] Taking the private key k as 14 as an example, the generation process of the public key K is as follows: 2G is calculated by the doubling operation module, and then the point addition operation module calculates 3G based on the doubling operation result 2G and the base point G, and hands it over to the doubling operation module to calculate 6G. The point addition calculation module calculates 7G based on the doubling calculation result 6G and the base point G, and hands it over to the doubling operation module to calculate the public key K=14G.
[0076] It can be seen that in the embodiment of the present disclosure, the point addition operation module is connected to the point doubling operation module, and the point addition operation module can use the output result of the point doubling operation module as input data to perform point addition operation, and the point doubling operation module can use the output result of the point addition operation module as input data to perform point doubling operation, thereby generating a public key.
[0077] It is understandable that in the actual elliptic curve encryption process, for the security of encryption, the value of the private key k is often greater than the value in the above example. The above description is only an example given for ease of understanding and does not constitute a limitation of the present disclosure.
[0078] The point addition operation module in this disclosure is further described below:
[0079] If the input end of the point addition operation module obtains the affine coordinates of two curve points, then correspondingly, the point addition operation module is configured to calculate the x coordinate of the point-added curve point according to the following formula:
[0080]
[0081] Among them, x1 and x2 are the x coordinates of the two curve points respectively, a and b are curve parameters of the curve point group, x3 is the x coordinate of the point plus the curve point, and x is the x coordinate of the result of the modular subtraction of the two curve points.
[0082] If the input end of the point addition operation module obtains the Jacobian coordinates of two curve points, then correspondingly, the point addition operation module is configured to calculate the x coordinate of the point-added curve point according to the following formula:
[0083]
[0084] in,
[0085] The following is an explanation of the generation process of the calculation formula for the x-coordinate of the point-addition curve point in the above point-addition operation module:
[0086] Assume that the input data of the point addition operation module are curve point P1 (x1, y1) and curve point P2 (x2, y2), and the point addition result of P1 and P2 output by the point addition operation module is point plus curve point P3 (x3, y3), (x, y) = P1-P2.
[0087] In affine coordinates, the point addition formula is as follows:
[0088]
[0089] in,
[0090] According to the geometric relationship between P1, P2 and P3, we can get:
[0091] x3(x1-x2) 2 =(y1-y2) 2 -(x1+x2)(x1-x2) 2
[0092] =y1 2 +y2 2 -2y1y2-(x1 3 +x2 3 -x2x1 2 -x1x2 2 )
[0093] =-2y1y2+2b+(x1x2+a)(x1+x2)
[0094] Since (x, y) = P1-P2, we have:
[0095] x(x1-x2) 2 =2y1y2+2b+(x1x2+a)(x1+x2);
[0096] Based on the above two formulas, eliminating 2y1y2, we can get:
[0097] (x3+x)(x1-x2) 2 =4b+2(x1x2+a)(x1+x2);
[0098] That is, the calculation formula used by the point addition operation module in the affine coordinates in the embodiment of the present disclosure is obtained:
[0099]
[0100] Among them, x1 and x2 are the x coordinates of the two curve points respectively, a and b are curve parameters of the curve point group, x3 is the x coordinate of the point plus the curve point, and x is the x coordinate of the result of the modular subtraction of the two curve points.
[0101] According to the conversion relationship between affine coordinates and Jacobian coordinates, we can also get the calculation formula used by the point addition operation module under Jacobian coordinates:
[0102]
[0103] in,
[0104] Compared with the point addition operation module used in the existing public key generation process using the MPL algorithm, in the point addition operation module provided in the embodiment of the present disclosure, the x coordinate of the modular subtraction result of the two curve points is used as the second variable, acting as a subtrahend, so as to obtain the x coordinate of the point plus curve point in the point addition operation result by modular subtraction. In the existing point addition operation process, the x coordinate of the modular subtraction result of the two curve points used for the point addition operation is located at the divisor position, and in the actual elliptic curve encryption process, there is a situation where the x coordinate of the modular subtraction result is 0, which leads to a division by 0 operation, anomalies in the public key generation link, resulting in side channel leakage, and even attackers can use this erroneous result to perform fault injection attacks, resulting in the security of the public key generation link being difficult to guarantee. The point addition operation module disclosed in the present disclosure converts the variable that may be 0 from the divisor to the subtrahend, effectively avoiding the division by 0 operation. Even in the case where the x coordinate of the modular subtraction result of the two curve points is 0, since the subtrahend is 0, it will not cause the system to report an error, nor will it cause the power consumption curve of the system to have an abnormal shape and cause side channel leakage, thereby ensuring the security of the encryption process.
[0105] Furthermore, the point addition operation module 300 may also include a storage unit 305, which is respectively connected to the modular subtraction unit 301, the modular multiplication unit 302, the modular addition unit 303 and the modular division unit 304, and is used to store the x-coordinates of two curve points in the curve point group received by the input end of the point addition operation module, and to store the multiple intermediate variables, the first variable and the second variable processed by the point addition operation module.
[0106] For ease of understanding, the execution process of the point addition operation module provided in the embodiment of the present disclosure is introduced below by taking the point addition operation in the Jacobi coordinate system as an example.
[0107] The point addition operation module performs the operation tasks shown in the following table in sequence:
[0108] step Computational tasks step Computational tasks 1 <![CDATA[T1=X1Z2]]> 8 <![CDATA[T7=aT5]]> 2 <![CDATA[T2=X2Z1]]> 9 <![CDATA[T8=T6+T7]]> 3 <![CDATA[T3=T1-T2]]> 10 <![CDATA[T9=2T8T4]]> 4 <![CDATA[Z3=T3 2 ]]> 11 <![CDATA[T 10 =xZ3]]> 5 <![CDATA[T4=T1+T2]]> 12 <![CDATA[T 11 =T5 2 ]]> 6 <![CDATA[T5=Z1Z2]]> 13 <![CDATA[T 12 =4bT 11 ]]> 7 <![CDATA[T6=X1X2]]> 14 <![CDATA[X3=T 12 +T9-T 10 ]]>
[0109] Among them, T i Represents the intermediate variable temporarily stored in the register unit, i={1, 2..., 12}.
[0110] It should be noted that the execution order of the steps corresponding to the computing tasks described in the above table is only an example. In some embodiments, the computing tasks of some steps can be adjusted. For example, the computing tasks of step 1 and step 2 can be swapped.
[0111] In one embodiment, when a=-3, the elliptic curve encryption algorithm used is the SM2 encryption algorithm, and the calculation tasks corresponding to step 8 and step 9 in the above table can be replaced with T7=T6-T5-T5-T5.
[0112] In one embodiment, when a=0, the adopted elliptic curve encryption algorithm is the SM2 encryption algorithm, steps 8 and 9 in the above table can be skipped, and T8 in the subsequent steps can be replaced by T6.
[0113] In some embodiments, 4b can be pre-stored in the register unit as a constant, which can reduce two addition executions in the dot addition operation module.
[0114] The above introduces the scenario in which the point addition calculation module is applied to the public key generation link of the elliptic curve encryption method. The point addition calculation module disclosed in the present disclosure can also be applied to the information encryption link.
[0115] See also Figure 4 The embodiment of the present disclosure also provides an elliptic curve encryption method, which includes the following steps:
[0116] In step 401, a public key and a base point are obtained.
[0117] The base point G is a curve point in the curve point group of the elliptic curve.
[0118] In some embodiments, the public key K and the base point G can be obtained by the encryption party from a public server. In some embodiments, the encryption party can also obtain them directly from the decryption party.
[0119] It should be noted that, in step 401, the encryption party also obtains the curve parameters of the elliptic curve.
[0120] In step 402, the information to be encrypted is encoded into an information point in the curve point group of the elliptic curve, wherein the information point M is a curve point in the curve point group of the elliptic curve that is different from the base point G.
[0121] In step 403, an encrypted integer is determined, wherein the encrypted integer r is a random integer.
[0122] In step 404, based on the encrypted integer and the base point, a first encrypted document is generated by a point addition operation module and a point multiplication operation module to be sent to a decryption party.
[0123] Specifically, the first encrypted document C1 = rG. The calculation process of the first encrypted document is a scalar multiplication calculation process, which can be performed using a point addition operation module and a point multiplication operation module. The specific execution method can refer to the public key generation process in the above embodiment, which will not be repeated here.
[0124] It can be understood that the point addition operation module used in the public key generation method described above is also applicable to the calculation process of the first encrypted document in this embodiment.
[0125] After the encryption party obtains the first encrypted document C1 through calculation, it can upload it to a public server or directly send it to the decryption party.
[0126] In step 405, based on the encrypted integer, the information point and the first encrypted official document, a second encrypted official document is generated by a point addition operation module and a point multiplication operation module to be sent to a decryption party.
[0127] Specifically, the second encrypted public document C2=M+rK, wherein the calculation process of rK is a scalar multiplication calculation process, which can be performed using a point addition operation module and a point multiplication operation module. The specific execution method can refer to the public key generation process in the above embodiment, which will not be repeated here. M+rK can be calculated by the point addition operation module provided in the above embodiment.
[0128] It can be understood that the point addition operation module used in the public key generation method described above is also applicable to the calculation process of the second encrypted document in this embodiment.
[0129] It should be noted that the above elliptic curve encryption method can adopt the Montgomery ladder algorithm, that is, the above point addition operation module can be applied to the Montgomery ladder algorithm.
[0130] Corresponding to the above elliptic curve encryption method, the present disclosure also provides an elliptic curve decryption method, see Figure 5 , the elliptic curve decryption method comprises:
[0131] In step 501, a first encrypted official document and a second encrypted official document are obtained.
[0132] The decryption party may obtain the first encrypted official document and the second encrypted official document from the public server, or directly from the encryption party.
[0133] In step 502, an information point is calculated based on the first encrypted official document, the second encrypted official document and the private key, wherein the information point is encoded with encrypted information.
[0134] The decryption party has the private key corresponding to the public key used when the first encrypted document and the second encrypted document were generated. By combining the first encrypted document and the second encrypted document, the information point M encoding the encrypted information can be calculated according to the formula C2-kC1.
[0135] Specifically, C2-kC1=M+rK-rkG. Since the public key K=kG, C2-kC1=M+rK-rK=M.
[0136] The above calculation process can be calculated by a point addition operation module and a point doubling operation module. The structure and operation flow of the point addition operation module have been described in detail in the embodiment provided above and will not be elaborated here.
[0137] In step 503, the information point is decoded to obtain the encrypted information.
[0138] It should be noted that the above elliptic curve decryption method can adopt the Montgomery ladder algorithm, that is, the above point addition operation module can be applied to the Montgomery ladder algorithm.
[0139] The present disclosure provides a point addition operation module, and for the convenience of understanding by those skilled in the art, the embodiment of its application in the public key generation process, elliptic curve encryption process and elliptic curve decryption process of elliptic curve encryption is introduced. It should be noted that the point addition operation module can be applied in a variety of application scenarios including but not limited to those introduced above, for example, it can also be applied to software registration protection.
[0140] The point addition operation module provided by the present disclosure can avoid security issues caused by the division by zero operation involved in the point addition operation in various encryption scenarios, thereby providing security and stability guarantees for the stable operation of various encryption and decryption application processes.
[0141] Corresponding to the aforementioned method embodiments, the present disclosure also provides an electronic device and corresponding embodiments. Figure 6 It is a schematic diagram of the structure of an electronic device shown in an embodiment of the present application.
[0142] See also Figure 6 , the electronic device 1000 includes a memory 1010 and a processor 1020 .
[0143] The processor 1020 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0144] The memory 1010 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, ROM can store static data or instructions required by the processor 1020 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at run time. In addition, the memory 1010 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory 1010 may include a readable and / or writable removable storage device, such as a laser disc (CD), a read-only digital versatile disc (such as a DVD-ROM, a double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (such as an SD card, a mini SD card, a Micro-SD card, etc.), a magnetic floppy disk, etc. The computer-readable storage medium does not include carrier waves and transient electronic signals transmitted wirelessly or wired.
[0145] The memory 1010 stores executable codes, and when the executable codes are processed by the processor 1020 , the processor 1020 can execute part or all of the methods described above.
[0146] The scheme of the present disclosure has been described in detail above with reference to the accompanying drawings. In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. Those skilled in the art should also be aware that the actions and modules involved in the specification are not necessarily required for the present disclosure. In addition, it can be understood that the steps in the method of the embodiment of the present disclosure can be adjusted in order, merged and deleted according to actual needs, and the modules in the device of the embodiment of the present disclosure can be merged, divided and deleted according to actual needs.
[0147] In addition, the method according to the present disclosure may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing some or all of the steps in the above method of the present disclosure.
[0148] Alternatively, the present disclosure may also be implemented as a non-temporary machine-readable storage medium (or computer-readable storage medium, or machine-readable storage medium) on which executable code (or computer program, or computer instruction code) is stored. When the executable code (or computer program, or computer instruction code) is executed by a processor of an electronic device (or electronic device, server, etc.), the processor executes part or all of the steps of the above-mentioned method according to the present disclosure.
[0149] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the application herein may be implemented as electronic hardware, computer software, or combinations of both.
[0150] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system and method according to multiple embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a part of a module, a program segment or a code, and the part of the module, the program segment or the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or the flow chart, and the combination of the square boxes in the block diagram and / or the flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0151] Although multiple embodiments of the present disclosure have been shown and described herein, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art may think of many changes, modifications, and alternatives without departing from the thought and spirit of the present disclosure. It should be understood that in the process of practicing the present disclosure, various alternatives to the embodiments of the present disclosure described herein may be adopted. The attached claims are intended to define the scope of protection of the present disclosure, and therefore cover equivalents or alternatives within the scope of these claims.
Claims
1. A method for generating an elliptic curve public key, characterized in that: include: Determine a base point and a private key; wherein the private key is an integer and is less than the order of the base point in the curve point group of the elliptic curve; Based on the base point and the private key, a public key is generated through a point addition operation module and a point multiplication operation module to be sent to the encryption party; The input end of the point addition operation module is used to receive the x coordinates of two curve points in the curve point group; the modular subtraction result of the two curve points is a fixed point, and the point addition operation module is initialized based on the fixed point; The output end of the point addition operation module is used to output the x-coordinate of the point-added curve point corresponding to the point addition operation result of the two curve points; The point addition operation module is configured to: obtain a first variable based on the x-coordinates of the two curve points and the curve parameters of the curve point group; use the x-coordinate of the modular subtraction result of the two curve points as the second variable, and take the modular subtraction result of the first variable and the second variable as the x-coordinate of the point-plus-curve point; The formula for calculating the first variable is: In the above formula, x1 and x2 are the x-coordinates of the two curve points respectively, and a and b are the curve parameters of the curve point group.
2. The method for generating an elliptic curve public key according to claim 1, wherein: The point addition operation module includes a modular subtraction unit; The modular subtraction unit is configured to: perform modular subtraction on the x-coordinates of the two curve points to obtain the second variable, and perform modular subtraction on the first variable and the second variable to obtain the x-coordinate of the point plus the curve point.
3. The method for generating an elliptic curve public key according to claim 2, wherein: The point addition operation module is further configured to determine the first variable according to the modular multiplication result, the modular addition result and the modular subtraction result of the x-coordinates of the two curve points and the curve parameters of the curve point group.
4. The method for generating an elliptic curve public key according to claim 3, characterized in that: The point addition operation module further includes a modular multiplication unit, a modular addition unit and a modular division unit; The modular multiplication unit is connected to the modular subtraction unit, the modular addition unit and the modular division unit respectively, and is configured to: perform modular multiplication based on the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable; The modular addition unit is configured to: perform modular addition based on the curve parameters of the curve point group and the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable; The modular reduction unit is further configured to: perform modular reduction based on the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable; The modular division unit is connected to the modular subtraction unit and is configured to perform modular division based on the multiple intermediate variables to obtain the first variable.
5. The method for generating an elliptic curve public key according to claim 4, characterized in that: If the coordinates of the two curve points are affine coordinates, then accordingly, the point addition operation module is configured to calculate the x coordinate of the point-plus-curve point according to the following formula: Among them, x1 and x2 are the x coordinates of the two curve points respectively, a and b are curve parameters of the curve point group, x3 is the x coordinate of the point plus the curve point, and x is the x coordinate of the result of the modular subtraction of the two curve points.
6. The method for generating an elliptic curve public key according to claim 5, characterized in that: If the coordinates of the two curve points are Jacobian coordinates, then accordingly, the point addition operation module is configured to calculate the x coordinate of the point-plus-curve point according to the following formula: in, 7. The method for generating an elliptic curve public key according to claim 5, characterized in that: The point addition operation module further includes a register unit; the register unit is respectively connected to the modular subtraction unit, the modular multiplication unit, the modular addition unit and the modular division unit; the register unit is pre-stored with a constant 4b; The storage unit is used to store the x-coordinates of two curve points in the curve point group received by the input end of the point addition operation module, and to store the multiple intermediate variables, the first variable and the second variable processed by the point addition operation module.
8. An elliptic curve encryption method, characterized in that: include: Get the public key and base point; The base point is a curve point in the curve point group of the elliptic curve; Encoding the information to be encrypted into an information point in the curve point group of the elliptic curve; the information point is a curve point in the curve point group of the elliptic curve that is different from the base point; Determine the encrypted integer; Based on the encrypted integer and the base point, a first encrypted document is generated by a point addition operation module and a point multiplication operation module to be sent to a decryption party; Based on the encrypted integer, the information point and the first encrypted official document, a second encrypted official document is generated by the point addition operation module and the point multiplication operation module to be sent to the decryption party; The input end of the point addition operation module is used to receive the x coordinates of two curve points in the curve point group; the modular subtraction result of the two curve points is a fixed point, and the point addition operation module is initialized based on the fixed point; The output end of the point addition operation module is used to output the x-coordinate of the point-added curve point corresponding to the point addition operation result of the two curve points; The point addition operation module is configured to: obtain a first variable based on the x-coordinates of the two curve points and the curve parameters of the curve point group; use the x-coordinate of the modular subtraction result of the two curve points as the second variable, and take the modular subtraction result of the first variable and the second variable as the x-coordinate of the point-plus-curve point; The formula for calculating the first variable is: In the above formula, x1 and x2 are the x-coordinates of the two curve points respectively, and a and b are the curve parameters of the curve point group.
9. The elliptic curve encryption method according to claim 8, characterized in that: The point addition operation module includes a modular subtraction unit; The modular subtraction unit is configured to: perform modular subtraction on the x-coordinates of the two curve points to obtain the second variable, and perform modular subtraction on the first variable and the second variable to obtain the x-coordinate of the point plus the curve point.
10. The elliptic curve encryption method according to claim 9, characterized in that: The point addition operation module is further configured to determine the first variable according to the modular multiplication result, the modular addition result and the modular subtraction result of the x-coordinates of the two curve points and the curve parameters of the curve point group.
11. The elliptic curve encryption method according to claim 10, characterized in that: The point addition operation module further includes a modular multiplication unit, a modular addition unit and a modular division unit; The modular multiplication unit is connected to the modular subtraction unit, the modular addition unit and the modular division unit respectively, and is configured to: perform modular multiplication based on the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable; The modular addition unit is configured to: perform modular addition based on the curve parameters of the curve point group and the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable; The modular reduction unit is further configured to: perform modular reduction based on the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable; The modular division unit is connected to the modular subtraction unit and is configured to perform modular division based on the multiple intermediate variables to obtain the first variable.
12. The elliptic curve encryption method according to claim 11, characterized in that: If the coordinates of the two curve points are affine coordinates, then accordingly, the point addition operation module is configured to calculate the x coordinate of the point-plus-curve point according to the following formula: Among them, x1 and x2 are the x coordinates of the two curve points respectively, a and b are curve parameters of the curve point group, x3 is the x coordinate of the point plus the curve point, and x is the x coordinate of the result of the modular subtraction of the two curve points.
13. The elliptic curve encryption method according to claim 12, characterized in that: If the coordinates of the two curve points are Jacobian coordinates, then accordingly, the point addition operation module is configured to calculate the x coordinate of the point-plus-curve point according to the following formula: in, 14. The elliptic curve encryption method according to claim 12, characterized in that: The point addition operation module further includes a register unit; the register unit is respectively connected to the modular subtraction unit, the modular multiplication unit, the modular addition unit and the modular division unit; the register unit is pre-stored with a constant 4b; The register unit is used to store the x-coordinates of two curve points in the curve point group received by the input end of the point addition operation module, and to store the multiple intermediate variables, the first variable and the second variable processed by the point addition operation module.
15. An elliptic curve decryption method, characterized in that: include: Obtaining the first encrypted official document and the second encrypted official document issued by the encryption party; Based on the first encrypted official document, the second encrypted official document and the private key, information points are calculated by a point addition operation module and a point multiplication operation module; wherein the information points are encoded with encrypted information; Decoding the information point to obtain the encrypted information; The input end of the point addition operation module is used to receive the x coordinates of two curve points in the curve point group; the modular subtraction result of the two curve points is a fixed point, and the point addition operation module is initialized based on the fixed point; The output end of the point addition operation module is used to output the x-coordinate of the point-added curve point corresponding to the point addition operation result of the two curve points; The point addition operation module is configured to: obtain a first variable based on the x-coordinates of the two curve points and the curve parameters of the curve point group; use the x-coordinate of the modular subtraction result of the two curve points as the second variable, and take the modular subtraction result of the first variable and the second variable as the x-coordinate of the point-plus-curve point; The formula for calculating the first variable is: In the above formula, x1 and x2 are the x-coordinates of the two curve points respectively, and a and b are the curve parameters of the curve point group.
16. The elliptic curve decryption method according to claim 15, characterized in that: The point addition operation module includes a modular subtraction unit; The modular subtraction unit is configured to: perform modular subtraction on the x-coordinates of the two curve points to obtain the second variable, and perform modular subtraction on the first variable and the second variable to obtain the x-coordinate of the point plus the curve point.
17. The elliptic curve decryption method according to claim 16, characterized in that: The point addition operation module is further configured to determine the first variable according to the modular multiplication result, the modular addition result and the modular subtraction result of the x-coordinates of the two curve points and the curve parameters of the curve point group.
18. The elliptic curve decryption method according to claim 17, characterized in that: The point addition operation module further includes a modular multiplication unit, a modular addition unit and a modular division unit; The modular multiplication unit is connected to the modular subtraction unit, the modular addition unit and the modular division unit respectively, and is configured to: perform modular multiplication based on the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable; The modular addition unit is configured to: perform modular addition based on the curve parameters of the curve point group and the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable; The modular reduction unit is further configured to: perform modular reduction based on the x-coordinates of the two curve points to obtain a plurality of intermediate variables required for calculating the first variable; The modular division unit is connected to the modular subtraction unit and is configured to perform modular division based on the multiple intermediate variables to obtain the first variable.
19. The elliptic curve decryption method according to claim 18, characterized in that: If the coordinates of the two curve points are affine coordinates, then accordingly, the point addition operation module is configured to calculate the x coordinate of the point-plus-curve point according to the following formula: Among them, x1 and x2 are the x coordinates of the two curve points respectively, a and b are curve parameters of the curve point group, x3 is the x coordinate of the point plus the curve point, and x is the x coordinate of the result of the modular subtraction of the two curve points.
20. The elliptic curve decryption method according to claim 19, characterized in that: If the coordinates of the two curve points are Jacobian coordinates, then accordingly, the point addition operation module is configured to calculate the x coordinate of the point-plus-curve point according to the following formula: in, 21. The elliptic curve decryption method according to claim 19, characterized in that: The point addition operation module further includes a register unit; the register unit is respectively connected to the modular subtraction unit, the modular multiplication unit, the modular addition unit and the modular division unit; the register unit is pre-stored with a constant 4b; The storage unit is used to store the x-coordinates of two curve points in the curve point group received by the input end of the point addition operation module, and to store the multiple intermediate variables, the first variable and the second variable processed by the point addition operation module.
Citation Information
Patent Citations
Encoding of points of an elliptic curve
CN102318264A
Method and device for realizing scalar multiplication in chip and computer readable storage medium
CN109582284A
Data encryption system based on elliptic curve encryption algorithm
CN112685758A
Elliptic domain curve operational method and elliptic domain curve operational unit
WO2015164996A1
