A data encryption method and a data decryption method
Patent Information
- Application Number
- CN202211449761.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-18
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2042-11-18
AI Technical Summary
[0003]现有的同态加密如Paillier加法同态加密或者ElGamal、RSA乘法同态密钥长度较长,计算性能低下
Smart Images

Figure CN115834185B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data security technology, and more specifically, to a data encryption method and a data decryption method. Background Technology
[0002] With the widespread application of cloud computing, especially the large number of e-commerce transactions on cloud platforms, how to securely and effectively protect user privacy and security has become a hot topic in the field of cryptography research. Storing data in plaintext may expose sensitive data to cloud service providers, posing a series of security problems for users' confidential data. To solve this problem, homomorphic encryption schemes have emerged. These schemes encrypt user data before sending the ciphertext to the cloud. Data in the cloud can then be uploaded, downloaded, deleted, updated, and retrieved, all while remaining in ciphertext. This approach avoids the risks of data interception, copying, alteration, or forgery during transmission, and also prevents data storage providers from leaking data or the server from being compromised.
[0003] Existing homomorphic encryption methods, such as Paillier additive homomorphic encryption or ElGamal and RSA multiplicative homomorphic encryption, have long key lengths and low computational performance. Elliptic curve encryption offers the advantages of short key lengths and high computational performance while maintaining the same level of security. However, existing elliptic curve-based encryption algorithms do not possess homomorphic properties. Generally, plaintext messages need to be encoded into elliptic curve group elements, but this encoding method is computationally complex and has a certain probability of encoding / decoding errors, resulting in low efficiency in practical applications. Summary of the Invention
[0004] This application provides a data encryption method and a data decryption method that uses SM2 elliptic curve parameters to obtain the public key. Therefore, when encoding data, it is not necessary to map the plaintext to elliptic curve points, which reduces the amount of computation and avoids encoding and decoding errors that reduce efficiency.
[0005] This application provides a data encryption method, including:
[0006] Generate public and private keys;
[0007] The first piece of data is encrypted using the public key to obtain the first ciphertext;
[0008] The generation of public and private keys specifically includes:
[0009] Randomly generate a private key;
[0010] The public key is computed using the private key, the order of the finite field, and the boosting of the base points in the SM2 elliptic curve parameters.
[0011] Preferably, the first data is encrypted using a public key to obtain the first ciphertext, specifically including:
[0012] Generate the first random number;
[0013] The first sub-ciphertext is calculated using the first random number, the order of the finite field, and the base point in the SM2 elliptic curve parameters;
[0014] Calculate the second ciphertext using the first ciphertext, the first random number, and the public key;
[0015] Combine the first ciphertext and the second ciphertext into the first tuple, which is the first ciphertext.
[0016] Preferably, the data encryption method further includes:
[0017] A homomorphic operation is performed on the first ciphertext obtained by encrypting the first data and the second ciphertext obtained by encrypting the second data to obtain the first homomorphic ciphertext.
[0018] Preferably, the first homomorphic ciphertext is a second binary tuple formed by the first sum between the first sub-ciphertext and the third sub-ciphertext of the second ciphertext and the second sum between the second sub-ciphertext and the fourth sub-ciphertext of the second ciphertext;
[0019] The third ciphertext is calculated in the same way as the first ciphertext, and the fourth ciphertext is calculated in the same way as the second ciphertext.
[0020] This application provides a data decryption method, including:
[0021] Receive the third ciphertext and private key;
[0022] Calculate the ring elements using the private key and a third ciphertext;
[0023] Use ring elements to extract the third data corresponding to the third ciphertext.
[0024] Preferably, the third ciphertext is a third binary tuple composed of the fifth and sixth sub-ciphertexts;
[0025] The difference between the sixth ciphertext and the dot product of the fifth ciphertext and the private key is used as the ring element.
[0026] Preferably, the third ciphertext is the second homomorphic ciphertext.
[0027] Preferably, the fifth sub-ciphertext is the sum of the seventh sub-ciphertext obtained by encrypting the fourth data and the eighth sub-ciphertext obtained by encrypting the fifth data, and the sixth sub-ciphertext is the sum of the ninth sub-ciphertext obtained by encrypting the fourth data and the tenth sub-ciphertext obtained by encrypting the fifth data.
[0028] Preferably, the seventh sub-ciphertext is obtained by calculating using the second random number corresponding to the fourth data, the order of the finite field, and the base point in the SM2 elliptic curve parameters, and the eighth sub-ciphertext is obtained by calculating using the third random number corresponding to the fifth data, the order of the finite field, and the base point in the SM2 elliptic curve parameters.
[0029] Preferably, the ninth ciphertext is obtained by calculating using the seventh ciphertext, the second random number, and the public key, and the tenth ciphertext is obtained by calculating using the eighth ciphertext, the third random number, and the public key.
[0030] Other features and advantages of this application will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description
[0031] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments of the present application and, together with their description, serve to explain the principles of the present application.
[0032] Figure 1 A flowchart of the data encryption method provided in this application;
[0033] Figure 2 A flowchart of the data decryption method provided for this application. Detailed Implementation
[0034] Various exemplary embodiments of the present application will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present application.
[0035] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the scope of this application and its application or use.
[0036] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, they should be considered part of the specification.
[0037] In all the examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.
[0038] like Figure 1 As shown, the data encryption method provided in this application includes:
[0039] S110: Generate public and private keys.
[0040] Specifically, generating public and private keys includes:
[0041] S1101: Randomly generate a private key d (d←Z / qZ), where Z / qZ are system parameters.
[0042] Where q is the order in the parameters of the SM2 curve, then q = FFFFFFFEFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123.
[0043] In the ECIES algorithm (elliptic curve integrate encrypt scheme), q is a system parameter, q = FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551.
[0044] S1102: Lifting using private key d, the order p of the finite field, and the base point G in the SM2 elliptic curve parameters. Calculate public key Q:
[0045] in:
[0046] In the SM2 algorithm, p=FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF.
[0047] O = (ε: 1: 0), ε 2 =0, ε∈F p (ε), where O represents the point at infinity, F p (ε) denotes a finite field.
[0048] In fact, there are Public key Where [dp] = dp mod n, E(F) p ) is the SM2 elliptic curve group over a finite field, and n is the order of the SM2 elliptic curve group, n = FFFFFFFEFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123.
[0049] S120: Encrypt the first data using the public key to obtain the first ciphertext.
[0050] During encryption, the input data is the first data m1 and the public key Q, and the output data is the encrypted first ciphertext C1.
[0051] Specifically, the first data is encrypted using the public key to obtain the first ciphertext, which includes:
[0052] S1201: Generate the first random number k1 (k1←Z / qZ).
[0053] S1202: Calculate the first sub-ciphertext C using the first random number k1, the order p of the finite field, and the base point G in the SM2 elliptic curve parameters. 11 :
[0054] C 11 =[k1p]G (1)
[0055] Where [k1p] = k1p mod n, and [k1p]G represents the dot product of [k1p] and G.
[0056] S1203: Using the first ciphertext C 11 The second ciphertext C is calculated using the first random number k1 and the public key Q. 12 :
[0057] C 12 =C 11 +[k1]Q (2)
[0058] S1204: The first ciphertext C 11 Second ciphertext C 12 Combined into the first tuple, which serves as the first ciphertext C1:
[0059] C1=(C 11 C 12 (3)
[0060] At this point, the first data m1 is promoted to the remaining class ring E(F). p In [ε]), obtain the first ring element. Specifically, points R1 = (x1, y1) ∈ E(F) on the elliptic curve are randomly generated. p ), first ring element The following conditions must be met:
[0061]
[0062] Where, x 01 =x1+εm,y 01 =y1+rε, where r is the value that makes y1+rε. The only valid solution.
[0063] Based on the above, this application provides a data decryption method. Specifically, the data decryption method includes:
[0064] S210: Receive the third ciphertext C3 and the private key d. The third ciphertext C3 is the fifth sub-ciphertext C.31 And the sixth son's cipher text C 32 The third tuple is formed by combining the five sub-ciphertexts. 31 According to step S1202, the sixth sub-ciphertext C is obtained. 32 Obtained according to S1203.
[0065] S220: Calculate the third ring element using the third ciphertext C3 and the private key d.
[0066]
[0067] In other words, the third ring element For the sixth ciphertext C 32 With the fifth ciphertext C 31 The difference between the dot product of the private key d and the private key d. Where,
[0068] S230: Utilizing third-ring elements Extract the third data m3 corresponding to the third ciphertext C3.
[0069] Specifically, the point R3=(x3,y3)∈E(F) on the elliptic curve is calculated by solving the following system of equations. p ),
[0070]
[0071] Where a0,b0,a1,b1∈F q , a=a0+a1ε, b=b0+b1ε, and there are projections π(a)=π(a0+a1ε)=a0, π(b)=π(b0+b1ε)=b0. Among them, F q Let a0 = -3 and b0 = 28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93.
[0072] Because the following relationship exists:
[0073] x 03 =x³ + εm³ (6)
[0074] y 03 =y3+rε (7)
[0075] y3 2 =x3 3 +a0x3+b0 (8)
[0076] Therefore, according to R3 and The third data m3 can then be obtained.
[0077] In this application, the public key is obtained using SM2 elliptic curve parameters. Therefore, when encoding data, it is not necessary to map the plaintext onto the elliptic curve, which reduces the amount of computation and effectively avoids encoding and decoding errors caused by encoding messages into group elements.
[0078] Based on the above, preferably, homomorphic encryption technology is used to encrypt multiple data. That is, after obtaining the first ciphertext C1 by encrypting the first data m1 through step S120 and obtaining the second ciphertext C2 by encrypting the second data m2, homomorphic operation is performed on the first ciphertext C1 and the second ciphertext C2 to obtain the first homomorphic ciphertext.
[0079] As an example, the first homomorphic ciphertext C is obtained by adding the first ciphertext C1 and the second ciphertext C2. add1 :
[0080] C add1 =C1+C2=(C 11 +C 21 C 12 +C 22 (9)
[0081] That is, the first homomorphic ciphertext C add1 For the first ciphertext C 11 The third sub-ciphertext C of the second ciphertext C2 21 The first and second sub-ciphertext C 12 The fourth sub-ciphertext C of the second ciphertext C2 22 The second tuple is formed by combining the second and third sub-ciphertexts. The third sub-ciphertext C... 21 With the first ciphertext C 11 The calculation method is the same, the fourth ciphertext C 22 With the second ciphertext C 12 The calculation method is the same.
[0082] Based on the above, if the third ciphertext to be decrypted is the second homomorphic ciphertext C add2 Then the fifth ciphertext C mentioned above 31 The seventh ciphertext C obtained by encrypting the fourth data m4 41 And the eighth ciphertext C obtained by encrypting the fifth data m5 51 The sum of the sixth ciphertext C 32 The ninth ciphertext C obtained by encrypting the fourth data m4 42 And the tenth ciphertext C obtained by encrypting the fifth data m5 52 The sum of, i.e.
[0083] C add2 =(C 31 C 32 )=(C41 +C 51 C 42 +C 52 (10)
[0084] Among them, the seventh ciphertext C 41 The eighth sub-ciphertext C is obtained by using the second random number k2 corresponding to the fourth data m4, the order p of the finite field, and the base point G in the SM2 elliptic curve parameters. 51 It is obtained by using the third random number k3 corresponding to the fifth data m5, the order p of the finite field, and the base point G in the SM2 elliptic curve parameters.
[0085] Ninth cipher text C 42 To utilize the seventh ciphertext C 41 The tenth ciphertext C is obtained by calculating the second random number k2 and the public key Q. 52 To utilize the eighth ciphertext C 51 It is obtained by calculating the third random number k3 and the public key Q.
[0086] In the second homomorphic ciphertext C add2 During decryption, the sum of the fourth data m4 and the fifth data m5 is obtained using the same method as in steps S220 and S230.
[0087] This application combines the SM2 algorithm with homomorphic encryption for data encryption, combining the high-performance computation of elliptic curves with the homomorphic properties of homomorphic encryption. While ensuring computational performance, the key length is shorter than that of Paillier, ElGamal, and RSA algorithms.
[0088] While specific embodiments of this application have been described in detail by way of examples, those skilled in the art should understand that the above examples are for illustrative purposes only and are not intended to limit the scope of this application. Those skilled in the art should understand that modifications can be made to the above embodiments without departing from the scope and spirit of this application. The scope of this application is defined by the appended claims.
Claims
1. A data encryption method, characterized in that, include: Generate public and private keys; The generation of public and private keys includes: Randomly generate a private key; The public key is calculated using the private key, the order of the finite field, and the lifting of the base points in the SM2 elliptic curve parameters; specifically: Randomly generate a private key d, d←Z / qZ, where Z / qZ are system parameters and q is the order in the SM2 curve parameters; The lifting of the base point G in the SM2 elliptic curve parameters is achieved using the private key d, the order p of the finite field, and the parameters of the base point G. Calculate the public key : ; , ( ), , ,in, Represents the point at infinity. Represents a finite field; Encrypting the first data using the public key to obtain the first ciphertext specifically includes: generating a first random number; calculating a first sub-ciphertext using the first random number, the order of the finite field, and the base point in the SM2 elliptic curve parameters; calculating a second sub-ciphertext using the first sub-ciphertext, the first random number, and the public key; and combining the first sub-ciphertext and the second sub-ciphertext into a first tuple as the first ciphertext.
2. The data encryption method according to claim 1, characterized in that, Also includes: A homomorphic operation is performed on the first ciphertext obtained by encrypting the first data and the second ciphertext obtained by encrypting the second data to obtain a first homomorphic ciphertext; wherein the second ciphertext is obtained in the same way as the first ciphertext.
3. The data encryption method according to claim 2, characterized in that, The first homomorphic ciphertext is a second tuple formed by the first sum between the first sub-ciphertext and the third sub-ciphertext of the second ciphertext and the second sum between the second sub-ciphertext and the fourth sub-ciphertext of the second ciphertext; The third sub-ciphertext is calculated in the same way as the first sub-ciphertext, and the fourth sub-ciphertext is calculated in the same way as the second sub-ciphertext.
4. A data decryption method, characterized in that, include: Receive the third ciphertext and private key; Calculate the ring elements using the private key and the third ciphertext; The ring element is used to extract the third data corresponding to the third ciphertext; Wherein, the third ciphertext is a third binary tuple composed of the fifth sub-ciphertext and the sixth sub-ciphertext; the difference between the dot product of the sixth sub-ciphertext, the fifth sub-ciphertext, and the private key is used as the ring element; wherein, the fifth sub-ciphertext is obtained according to the calculation method of the first sub-ciphertext in any one of claims 1 to 3; the sixth sub-ciphertext is obtained according to the calculation method of the second sub-ciphertext in any one of claims 1 to 3.
5. The data decryption method according to claim 4, characterized in that, The third ciphertext is the second homomorphic ciphertext.
6. The data decryption method according to claim 5, characterized in that, The fifth sub-ciphertext is the sum of the seventh sub-ciphertext obtained by encrypting the fourth data and the eighth sub-ciphertext obtained by encrypting the fifth data, and the sixth sub-ciphertext is the sum of the ninth sub-ciphertext obtained by encrypting the fourth data and the tenth sub-ciphertext obtained by encrypting the fifth data.
7. The data decryption method according to claim 6, characterized in that, The seventh sub-ciphertext is obtained by using the second random number corresponding to the fourth data, the order of the finite field, and the base point in the SM2 elliptic curve parameters. The eighth sub-ciphertext is obtained by using the third random number corresponding to the fifth data, the order of the finite field, and the base point in the SM2 elliptic curve parameters.
8. The data decryption method according to claim 7, characterized in that, The ninth ciphertext is obtained by calculating using the seventh ciphertext, the second random number, and the public key, and the tenth ciphertext is obtained by calculating using the eighth ciphertext, the third random number, and the public key.
Citation Information
Patent Citations
Data casual transmission method and device, electronic equipment and storage medium
CN113259329A