Data signing and encrypting method and device, data un-signing and un-encrypting method and device, and equipment
By generating a first private key and a public key, generating an identifier based on the public key, and using hash operations and elliptic curve algorithms to generate ciphertext and signatures, the problem of high requirements for random number generation equipment in traditional schemes is solved, and a wider range of digital signatures and encryption applications are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING PUSH TIMES TECH CO LTD
- Filing Date
- 2024-09-24
- Publication Date
- 2026-06-26
AI Technical Summary
Traditional solutions require the use of random numbers for digital signatures and encryption, which results in high requirements for the generation equipment and a limited range of applications.
By generating a first private key and a public key, generating an identifier based on the public key, and using hash operations and elliptic curve algorithms to generate ciphertext and a signature, no random numbers are needed; the target parameters are used directly for signing and encryption.
It expands the applicability of digital signatures and encryption, and improves security and flexibility.
Smart Images

Figure CN119420472B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and in particular to a data signature method and apparatus, a data desealing method and apparatus, and a device. Background Technology
[0002] With the development of internet technology, mobile office and mobile payment are becoming increasingly popular, and mobile information technology and cloud services are becoming trends. To ensure the security of data transmission, cryptographic technology is indispensable. Meanwhile, digital signatures, as a security technology that has emerged alongside the development of information network technology, can verify whether data has been altered during transmission, ensuring the integrity, authenticity, and non-repudiation of the transmitted data.
[0003] Taking the SM2 (Elliptic Curve Public Key Cryptography) algorithm as an example, random numbers are required for signing and encryption. The quality of the random numbers directly affects the security of the algorithm. However, the equipment required to generate random numbers is high-end and has a limited range of applications. Summary of the Invention
[0004] This application provides a data signing and encryption method and apparatus, a data designing and encryption method and apparatus, and a device to solve the problem that traditional solutions require the use of random numbers for digital signatures and encryption, but the equipment for generating random numbers has high requirements, resulting in a limited scope of application. The aim is to expand the scope of application of digital signatures and encryption.
[0005] Firstly, this application provides a data signature encryption method, applied to a first user terminal, comprising:
[0006] Generate a first private key and a first public key, and generate a first identifier based on the first public key and the first user identifier;
[0007] The first private key and the data to be encrypted are hashed to obtain the target parameters, and the first ciphertext is generated based on the target parameters.
[0008] The target parameters and the first identifier are used to sign the data to be encrypted to generate a first signature, and a second signature is generated based on the target parameters, the first private key and the first signature;
[0009] An encryption key is generated based on the target parameters and the second public key. The data to be encrypted is then encrypted using the encryption key, the first signature, and the second signature to generate a second ciphertext. The second public key is generated and sent by the second user terminal.
[0010] A target ciphertext is generated based on the first ciphertext and the second ciphertext, and the target ciphertext is sent to the second user terminal.
[0011] Optionally, generating the first ciphertext based on the target parameters includes:
[0012] The target parameters are multiplied by the base points of the elliptic curve to generate the first ciphertext.
[0013] Optionally, the step of using the target parameter and the first identifier to sign the data to be encrypted to generate a first signature includes:
[0014] The first identifier is hashed with the data to be encrypted to generate a first intermediate parameter;
[0015] A first signature is generated based on the first intermediate parameter and the target parameter according to the first signature formula;
[0016] The first signature formula is: r = e + x1 mod n;
[0017] Where r represents the first signature, e represents the first intermediate parameter, and e = Hv(Z) A ∥M), Hv represents the hash function, Z A Let M represent the first identifier, M represent the data to be encrypted, x1 represent the x-coordinate of the first ciphertext C1, C1 = kG, k represents the target parameter, G represents the base point of the elliptic curve, mod represents the modulo operation, and n represents the order of G, which is a positive integer.
[0018] Optionally, generating the second signature based on the target parameter, the first private key, and the first signature includes:
[0019] A second signature is generated based on the target parameters, the first private key, and the first signature, according to the second signature formula.
[0020] The second signature formula is: s=((1+d A ) -1 (k-rd A ))modn;
[0021] Where s represents the second signature, d A represents the first private key, and k represents the target parameter.
[0022] Optionally, generating the encryption key based on the target parameters and the second public key includes:
[0023] The target parameter and the second public key are multiplied to generate the second intermediate parameter;
[0024] According to the encryption key generation formula, an encryption key is generated based on the second intermediate parameter;
[0025] The encryption key generation formula is: t=KDF(x2∥y2,klen);
[0026] Where t represents the encryption key, KDF represents the encryption key derivation function, and x2 represents the second intermediate parameter kP. B The x-coordinate, y2, represents the second intermediate parameter kP. B The ordinate of P B The second public key is represented by klen = mlen + rlen + slen, where klen represents the encryption key length, mlen represents the length of the data to be encrypted, rlen represents the length of the first signature, and slen represents the length of the second signature.
[0027] The step of encrypting the data to be encrypted based on the encryption key, the first signature, and the second signature to generate the second ciphertext includes:
[0028] The data to be encrypted, the first signature, and the second signature are concatenated to obtain a first concatenation result;
[0029] The first concatenation result is encrypted using the XOR encryption algorithm and the encryption key to generate the second ciphertext.
[0030] Optionally, generating the target ciphertext based on the first ciphertext and the second ciphertext includes:
[0031] The first ciphertext and the second ciphertext are concatenated to generate the target ciphertext.
[0032] Secondly, this application provides a data decryption method, applied to a second user terminal, including:
[0033] Generate a second private key and a second public key;
[0034] The system receives target ciphertext sent by a first user terminal. The target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext. The first ciphertext is generated based on target parameters. The second ciphertext is generated by encrypting the data to be encrypted using an encryption key, a first signature, and a second signature. The encryption key is generated based on the target parameters and the second public key. The first signature is generated by signing the data to be encrypted using the target parameters and a first identifier. The second signature is generated based on the target parameters, a first private key, and the first signature. The target parameters are obtained by hashing the first private key and the data to be encrypted.
[0035] A decryption key is generated based on the first ciphertext and the second private key, and the second ciphertext is decrypted based on the decryption key to generate a first signature, a second signature, and decrypted data;
[0036] A verification signature is generated based on the first identifier, the first public key, the first signature, the second signature, and the decryption data. If the verification signature is equal to the first signature, the verification is successful, and the decryption data is output. The first public key is generated and sent by the first user terminal.
[0037] Optionally, generating the decryption key based on the first ciphertext and the second private key includes:
[0038] A third intermediate parameter is generated based on the second private key and the first ciphertext;
[0039] According to the decryption key generation formula, a decryption key is generated based on the third intermediate parameter;
[0040] The formula for generating the decryption key is: t′=KDF(x2′∥y2′,klen);
[0041] Where t′ represents the decryption key, and x2′ represents the third intermediate parameter d. B The x-coordinate of C1, y2′ represents the third intermediate parameter d. B The ordinate of C1, d B C1 represents the second private key, C1 represents the first ciphertext, klen = mlen + rlen + slen, klen represents the decryption key length, mlen represents the decryption data length, rlen represents the first signature length, and slen represents the second signature length.
[0042] The step of decrypting the second ciphertext based on the decryption key to generate a first signature, a second signature, and decrypted data includes:
[0043] According to the decryption algorithm corresponding to the XOR encryption algorithm, the second ciphertext is decrypted using the decryption key to obtain the second concatenation result;
[0044] Obtain the first signature, the second signature, and the decrypted data from the second splicing result.
[0045] Optionally, generating a verification signature based on the first identifier, the first public key, the first signature, the second signature, and the decryption data includes:
[0046] The first identifier is hashed with the decrypted data to generate a fourth intermediate parameter;
[0047] Based on the first signature and the second signature, a fifth intermediate parameter is generated;
[0048] Based on the second signature, the fifth intermediate parameter, and the first public key, the sixth intermediate parameter is generated;
[0049] A verification signature is generated based on the fourth intermediate parameter and the sixth intermediate parameter according to the verification signature generation formula.
[0050] The formula for generating the verification signature is: R = (e′ + x1′) mod n;
[0051] Where R represents the verification signature, e′ represents the fourth intermediate parameter, and e′ = Hv(Z) A ∥M′), Z A M' represents the first identifier, M' represents the decrypted data, and x1' represents the sixth intermediate parameter s'G+u'P. A The x-coordinate, s′ represents the second signature, u represents the fifth intermediate parameter, u = (r′ + s′) mod n, P A This represents the first public key.
[0052] Thirdly, this application provides a data signature device, applied to a first user terminal, comprising:
[0053] The first generation module is used to generate a first private key and a first public key, and to generate a first identifier based on the first public key and the first user identifier;
[0054] The second generation module is used to perform a hash operation on the first private key and the data to be encrypted to obtain target parameters, and generate the first ciphertext based on the target parameters;
[0055] The third generation module is used to sign the data to be encrypted using the target parameters and the first identifier to generate a first signature, and to generate a second signature based on the target parameters, the first private key and the first signature;
[0056] An encryption module is used to generate an encryption key based on the target parameters and the second public key, and to encrypt the data to be encrypted based on the encryption key, the first signature, and the second signature to generate a second ciphertext. The second public key is generated and sent by the second user terminal.
[0057] The sending module is used to generate target ciphertext based on the first ciphertext and the second ciphertext, and send the target ciphertext to the second user terminal.
[0058] Fourthly, this application provides a data decryption device for use in a second user terminal, comprising:
[0059] The fourth generation module is used to generate the second private key and the second public key;
[0060] The receiving module is used to receive target ciphertext sent by a first user terminal. The target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext. The first ciphertext is generated based on target parameters. The second ciphertext is generated by encrypting the data to be encrypted using an encryption key, a first signature, and a second signature. The encryption key is generated based on the target parameters and the second public key. The first signature is generated by signing the data to be encrypted using the target parameters and a first identifier. The second signature is generated based on the target parameters, a first private key, and the first signature. The target parameters are obtained by hashing the first private key and the data to be encrypted.
[0061] The decryption module is used to generate a decryption key based on the first ciphertext and the second private key, and to decrypt the second ciphertext based on the decryption key to generate a first signature, a second signature and decrypted data;
[0062] The verification module is used to generate a verification signature based on the first identifier, the first public key, the first signature, the second signature, and the decryption data. If the verification signature is equal to the first signature, the verification is successful, and the decryption data is output. The first public key is generated and sent by the first user terminal.
[0063] Fifthly, this application provides an electronic device, including a storage component and a processing component; the storage component stores one or more computer instructions, which are invoked and executed by the processing component, and the processing component executes the one or more computer instructions to implement the data signature method as described in the first aspect.
[0064] In a sixth aspect, this application provides an electronic device, including a storage component and a processing component; the storage component stores one or more computer instructions, which are invoked and executed by the processing component, and the processing component executes the one or more computer instructions to implement the data decryption method as described in the second aspect.
[0065] In a seventh aspect, this application provides a computer-readable storage medium storing a computer program that, when executed by a computer, implements the data signature method as described in the first aspect, or the data desealing method as described in the second aspect.
[0066] Eighthly, this application provides a computer program product storing a computer program that, when executed by a computer, implements the data signature method as described in the first aspect, or the data desealing method as described in the second aspect.
[0067] In this embodiment, a target parameter can be generated by hashing the first private key of the first user terminal and the data to be encrypted. A first ciphertext is generated based on the target parameter. A first signature is generated by signing the data to be encrypted using the target parameter and a first identifier. A second signature is generated based on the target parameter, the first private key, and the first signature. An encryption key is generated based on the target parameter and a second public key. The data to be encrypted is then encrypted based on the encryption key, the first signature, and the second signature to generate a second ciphertext. A target ciphertext is generated based on the first ciphertext and the second ciphertext, and the target ciphertext is sent to the second user terminal. This eliminates the need for random numbers, solving the problem that traditional solutions require high-performance random number generation equipment, resulting in a limited scope of application for signatures and encryption. This improves the applicability of signatures and encryption.
[0068] These or other aspects of this application will become more apparent in the following description of the embodiments. Attached Figure Description
[0069] To more clearly illustrate the technical solutions in the embodiments of this application 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 some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0070] Figure 1 A flowchart of one embodiment of a data signature method provided in this application is shown;
[0071] Figure 2 A flowchart of one embodiment of a data decryption method provided in this application is shown;
[0072] Figure 3 This illustration shows a structural schematic diagram of one embodiment of a data signature device provided in this application;
[0073] Figure 4 This illustration shows a structural schematic diagram of one embodiment of a data decryption and signature device provided in this application;
[0074] Figure 5 A schematic diagram of the structure of an embodiment of an electronic device provided in this application is shown. Detailed Implementation
[0075] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0076] In some of the processes described in the specification, claims, and accompanying drawings of this application, multiple operations appearing in a specific order are included. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not themselves represent any execution order. Furthermore, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first," "second," etc., in this document are used to distinguish different messages, devices, modules, etc., and do not represent a chronological order, nor do they limit "first" and "second" to different types.
[0077] The technical solution of this application is applicable to the field of data processing, especially to the field of data encryption based on digital signatures. Digital signatures are a security technology that has emerged with the development of information network technology. They can verify whether data has been altered during transmission, ensuring the integrity, authenticity, and non-repudiation of transmitted data.
[0078] Taking the SM2 (Elliptic Curve Public Key Cryptography) algorithm as an example, random numbers are required for signing and encryption. The quality of the random numbers directly affects the security of the algorithm. However, the equipment required to generate random numbers is high-end and has a limited range of applications.
[0079] To address the aforementioned technical problems, the inventors conceived of the possibility of achieving digital signatures and encryption without using random numbers. Based on this, the technical solution of this application is proposed, providing a data signature and encryption method, including: generating a first private key and a first public key; generating a first identifier based on the first public key and a first user identifier; performing a hash operation on the first private key and the data to be encrypted to obtain target parameters, and generating first ciphertext based on the target parameters; signing the data to be encrypted using the target parameters and the first identifier to generate a first signature, and generating a second signature based on the target parameters, the first private key, and the first signature; generating an encryption key based on the target parameters and the second public key, and encrypting the data to be encrypted using the encryption key, the first signature, and the second signature to generate second ciphertext, wherein the second public key is generated and sent by a second user terminal; generating a target ciphertext based on the first ciphertext and the second ciphertext, and sending the target ciphertext to the second user terminal.
[0080] In this embodiment, target parameters are generated by hashing the first private key of the first user terminal and the data to be encrypted. Signing and encryption are then performed based on the target parameters. This eliminates the need for random numbers and solves the problem that traditional schemes have high requirements for random number generation equipment, resulting in a limited scope of application for digital signatures and encryption. This approach can improve the applicability of digital signatures and encryption.
[0081] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0082] like Figure 1 The diagram shown is a flowchart of an embodiment of a data signature method provided in this application. The method may include the following steps.
[0083] 101: Generate a first private key and a first public key, and generate a first identifier based on the first public key and the first user identifier.
[0084] In this embodiment, the method is applicable to a two-party encryption scenario, where a first user terminal encrypts the data to be encrypted, and a second user terminal decrypts it. The data encryption method in this embodiment can be applied to the first user terminal.
[0085] In this embodiment, the SM2 (Elliptic Curve Public Key Encryption) algorithm can be used. The SM2 algorithm can include elliptic curve parameters E(Fq), a, b, G, and n. Here, E can represent an elliptic curve over a finite field Fq, G can represent a base point of order n on the elliptic curve E, where n is a positive integer, and G and n are parameters of the elliptic curve.
[0086] Specifically, the first user can randomly select the first private key d. A ∈Zn, where Zn represents a positive integer, and the first public key P is generated based on the first private key and elliptic curve parameters. A P A =d A G.
[0087] Furthermore, the first user terminal can generate the first identifier based on the first public key and the first user identifier according to the identifier generation formula.
[0088] The identifier generation formula can be: Z A =H 256 (ENTL A ∥ID A ∥a∥b∥x G ∥y G ∥x A ∥y A ); where Z A H represents the first identifier. 256 ENTL represents a hash function. A The length of the first user identifier is represented by , a and b represent the elliptic curve parameters, and x... G The x-coordinate of the base point G is represented by y.G The ordinate of the base point G is represented by x. A Represents the first public key P A x-coordinate, y A Represents the first public key P A The ordinate.
[0089] 102: Perform a hash operation on the first private key and the data to be encrypted to obtain the target parameter, and generate the first ciphertext based on the target parameter.
[0090] Specifically, the target parameter k = H(d) A ∥M), where k represents the target parameter, H represents the hash function, and d A M represents the first private key, and M represents the data to be encrypted.
[0091] Optionally, the target parameters can be multiplied with the elliptic curve base point to generate the first ciphertext C1, C1 = kG = (x1, y1), where C1 represents the first ciphertext, G represents the elliptic curve base point, x1 represents the abscissa, and y1 represents the ordinate.
[0092] To facilitate computation and processing, the first ciphertext can be converted into a bit string.
[0093] 103: Use the target parameter and the first identifier to sign the data to be encrypted to generate a first signature, and generate a second signature based on the target parameter, the first private key and the first signature.
[0094] 104: Generate an encryption key based on the target parameters and the second public key, and encrypt the data to be encrypted based on the encryption key, the first signature, and the second signature to generate the second ciphertext.
[0095] The second public key is generated and sent by the second user terminal.
[0096] The generation process of the first signature, the second signature, and the second ciphertext will be described in subsequent embodiments.
[0097] 105: Generate the target ciphertext based on the first ciphertext and the second ciphertext, and send the target ciphertext to the second user terminal.
[0098] After obtaining the first ciphertext and the second ciphertext, the first ciphertext and the second ciphertext can be concatenated to generate the target ciphertext, and then the target ciphertext can be sent to the second user terminal.
[0099] In this embodiment, a target parameter can be generated by hashing the first private key of the first user terminal and the data to be encrypted. A first ciphertext is generated based on the target parameter. A first signature is generated by signing the data to be encrypted using the target parameter and a first identifier. A second signature is generated based on the target parameter, the first private key, and the first signature. An encryption key is generated based on the target parameter and a second public key. The data to be encrypted is then encrypted based on the encryption key, the first signature, and the second signature to generate a second ciphertext. A target ciphertext is generated based on the first ciphertext and the second ciphertext, and the target ciphertext is sent to the second user terminal. This eliminates the need for random numbers, solving the problem that traditional solutions require high-performance random number generation equipment, resulting in a limited scope of application for digital signatures and encryption. This approach can improve the applicability of digital signatures and encryption.
[0100] The following explains the generation process of the first signature, the second signature, and the second ciphertext.
[0101] In some embodiments, generating a first signature by signing the data to be encrypted using the target parameter and the first identifier may include:
[0102] The first identifier is hashed with the data to be encrypted to generate the first intermediate parameter.
[0103] Specifically, the first intermediate parameter e = Hv(Z) A ∥M), Hv represents the hash function, Z A M represents the first identifier, and M represents the data to be encrypted.
[0104] Then, the first signature can be generated based on the first intermediate parameters and the target parameters according to the first signature formula;
[0105] The first signature formula can be: r = e + x1 mod n;
[0106] Where r represents the first signature, e represents the first intermediate parameter, and e = Hv(Z) A ∥M), Hv represents the hash function, Z A Let M represent the first identifier, M represent the data to be encrypted, x1 represent the x-coordinate of the first ciphertext C1, C1 = kG, k represents the target parameter, G represents the base point of the elliptic curve, mod represents the modulo operation, and n represents the order of G, which is a positive integer.
[0107] In some embodiments, generating a second signature based on the target parameter, the first private key, and the first signature may include:
[0108] A second signature is generated based on the target parameters, the first private key, and the first signature, according to the second signature formula.
[0109] The second signature formula can be: s=((1+d) A ) -1(k-rd A ))modn;
[0110] Where s represents the second signature, d A represents the first private key, and k represents the target parameter.
[0111] To facilitate computation and processing, the first signature and the second signature can be converted into bit strings, where rlen represents the length of the bit string converted from the first signature and slen represents the length of the bit string converted from the second signature.
[0112] Furthermore, generating an encryption key based on the target parameters and the second public key can include:
[0113] The target parameter and the second public key are multiplied to generate the second intermediate parameter.
[0114] Specifically, calculate the second intermediate parameter kP B = (x2, y2), where x2 represents the x-coordinate and y2 represents the y-coordinate.
[0115] According to the encryption key generation formula, an encryption key is generated based on the second intermediate parameter;
[0116] The formula for generating the encryption key can be: t=KDF(x2∥y2,klen);
[0117] Where t represents the encryption key, KDF represents the encryption key derivation function, and x2 represents the second intermediate parameter kP. B The x-coordinate, y2, represents the second intermediate parameter kP. B The ordinate of P B Let klen represent the second public key, where klen = mlen + rlen + slen, klen represents the encryption key length, mlen represents the length of the data to be encrypted, rlen represents the length of the first signature, and slen represents the length of the second signature.
[0118] Furthermore, encrypting the data to be encrypted using the encryption key, the first signature, and the second signature to generate the second ciphertext may include:
[0119] The data to be encrypted, the first signature, and the second signature are concatenated to obtain the first concatenation result;
[0120] Using the XOR encryption algorithm, the first concatenation result is encrypted with the encryption key to generate the second ciphertext.
[0121] Specifically, the second ciphertext C2 = t⊕(M∥r∥s), where C2 represents the second ciphertext, t represents the encryption key, and ⊕ represents the XOR algorithm.
[0122] Then, the first and second ciphertexts can be concatenated to obtain the target ciphertext C = C1∥C2.
[0123] The first client can send the target encrypted text to the second client.
[0124] like Figure 2 The diagram shown is a flowchart of an embodiment of a data decryption method provided in this application. The method may include the following steps.
[0125] 201: Generate the second private key and the second public key.
[0126] In this embodiment, it can be applied to a second user terminal. The second user terminal can randomly select a second private key d. B ∈Zn, and generate the second public key P based on the second private key and the elliptic curve base points. B P B =d B G.
[0127] 202: Receive the target ciphertext sent by the first user terminal.
[0128] The target ciphertext is obtained by concatenating the first ciphertext and the second ciphertext. The generation process of the first ciphertext, the second ciphertext, the first signature, and the second signature can be found by referring to... Figure 1 The embodiments shown are not described in detail here.
[0129] 203: Generate a decryption key based on the first ciphertext and the second private key, and decrypt the second ciphertext based on the decryption key to generate the first signature, the second signature, and the decrypted data.
[0130] The second user terminal can extract the first ciphertext from the target ciphertext, convert it into a point on an elliptic curve, and determine whether it satisfies the elliptic curve equation. If it does, continue with subsequent decryption steps; otherwise, the verification fails.
[0131] Specifically, a third intermediate parameter d can be generated based on the second private key and the first ciphertext. B C1=(x2′,y2′), d B C1 represents the second private key, C2 represents the first ciphertext, x2′ represents the x-coordinate, and y2′ represents the y-coordinate.
[0132] 204: Generate a verification signature based on the first identifier, the first public key, the first signature, the second signature, and the decryption data. If the verification signature is equal to the first signature, the verification is successful, and the decryption data is output.
[0133] The first public key is generated and sent by the first user terminal.
[0134] Specifically, the process of generating the decryption key, decryption data, and verification signature will be described in subsequent embodiments.
[0135] In this embodiment, target parameters are generated by hashing the first private key of the first user terminal and the data to be encrypted. Signing and encryption are then performed based on the target parameters. This eliminates the need for random numbers and solves the problem that traditional schemes require high-performance random number generation equipment, resulting in a limited scope of application for digital signatures and encryption. This approach can improve the applicability of digital signatures and encryption.
[0136] In some embodiments, generating a decryption key based on the first ciphertext and the second private key may include:
[0137] Generate a third intermediate parameter based on the second private key and the first ciphertext;
[0138] The decryption key is generated based on the third intermediate parameter according to the decryption key generation formula.
[0139] The formula for generating the decryption key can be: t′=KDF(x2′∥y2′,klen);
[0140] Where t′ represents the decryption key, and x2′ represents the third intermediate parameter d. B The x-coordinate of C1, y2′ represents the third intermediate parameter d. B The ordinate of C1, d B C1 represents the second private key, C2 represents the first ciphertext, klen = mlen + rlen + slen, klen represents the decryption key length, mlen represents the decryption data length, rlen represents the first signature length, and slen represents the second signature length.
[0141] After generating the decryption key, you can check if the decryption key is 0. If it is, the verification fails; otherwise, continue with the subsequent operations.
[0142] At this point, decrypting the second ciphertext using the decryption key to generate the first signature, the second signature, and the decrypted data may include:
[0143] According to the decryption algorithm corresponding to the XOR encryption algorithm, the second ciphertext is decrypted using the decryption key to obtain the second concatenation result;
[0144] Obtain the first signature, the second signature, and the decrypted data from the second concatenation result.
[0145] Specifically, we can calculate m′∥r′∥s′=t′⊕C2. Here, m′ represents the decrypted data, and C2 represents the second ciphertext.
[0146] Additionally, the first and second signatures can be converted into integers to verify r′∈Zn and s′∈Zn. If they are not true, the verification fails.
[0147] Furthermore, generating a verification signature based on the first identifier, the first public key, the first signature, the second signature, and the decrypted data may include:
[0148] The first identifier and the decrypted data are hashed to generate the fourth intermediate parameter.
[0149] Specifically, the fourth intermediate parameter e′=Hv(Z) A ∥M′), Z A M represents the first identifier, and M′ represents the decrypted data. The fourth intermediate parameter can be converted to an integer.
[0150] Based on the first signature and the second signature, a fifth intermediate parameter is generated.
[0151] Specifically, the fifth intermediate parameter u′ = (r′ + s′) mod n. If u′ = 0, the verification fails.
[0152] The sixth intermediate parameter is generated based on the second signature, the fifth intermediate parameter, and the first public key.
[0153] Specifically, the sixth intermediate parameter s′G+u′P A = (x1′, y1′), where x1′ represents the x-coordinate.
[0154] According to the verification signature generation formula, a verification signature is generated based on the fourth and sixth intermediate parameters;
[0155] The formula for generating the signature can be: R = (e′ + x1′) mod n;
[0156] Where R represents the verification signature, e′ represents the fourth intermediate parameter, and e′ = Hv(Z) A ∥M′), Z A M' represents the first identifier, M' represents the decrypted data, and x1' represents the sixth intermediate parameter s'G+u'P. A The x-coordinate of P, s′ represents the second signature, u′ represents the fifth intermediate parameter, u′=(r′+s′)modn, P A This represents the first public key.
[0157] Afterwards, if the verification signature is equal to the first signature, the verification passes and the decrypted data is output.
[0158] like Figure 3 The diagram shown is a structural schematic of an embodiment of a data signature device provided in this application. The device may include the following modules.
[0159] The first generation module 301 is used to generate a first private key and a first public key, and to generate a first identifier based on the first public key and the first user identifier;
[0160] The second generation module 302 is used to perform a hash operation on the first private key and the data to be encrypted to obtain target parameters, and generate the first ciphertext based on the target parameters;
[0161] The third generation module 303 is used to sign the data to be encrypted using the target parameters and the first identifier to generate a first signature, and to generate a second signature based on the target parameters, the first private key and the first signature;
[0162] The encryption module 304 is used to generate an encryption key based on the target parameters and the second public key, and to encrypt the data to be encrypted based on the encryption key, the first signature, and the second signature to generate a second ciphertext. The second public key is generated and sent by the second user terminal.
[0163] The sending module 305 is used to generate a target ciphertext based on the first ciphertext and the second ciphertext, and send the target ciphertext to the second user terminal.
[0164] Figure 3 The data signing device shown can be used to achieve Figure 1 The implementation principle and technical effects of the data signature method shown will not be elaborated further. The specific methods by which each module and unit of the data processing device in the above embodiments performs its operations have been described in detail in the embodiments related to this method, and will not be elaborated upon here.
[0165] like Figure 4 The diagram shown is a structural schematic of an embodiment of a data decryption device provided in this application. The device may include the following modules.
[0166] The fourth generation module 401 is used to generate the second private key and the second public key;
[0167] The receiving module 402 is configured to receive target ciphertext sent by a first user terminal. The target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext. The first ciphertext is generated based on target parameters. The second ciphertext is generated by encrypting data to be encrypted using an encryption key, a first signature, and a second signature. The encryption key is generated based on the target parameters and the second public key. The first signature is generated by signing the data to be encrypted using the target parameters and a first identifier. The second signature is generated based on the target parameters, a first private key, and the first signature. The target parameters are obtained by hashing the first private key and the data to be encrypted.
[0168] The decryption module 403 is used to generate a decryption key based on the first ciphertext and the second private key, and to decrypt the second ciphertext based on the decryption key to generate a first signature, a second signature and decrypted data;
[0169] The verification module 404 is used to generate a verification signature based on the first identifier, the first public key, the first signature, the second signature, and the decryption data, and to output the decryption data if the verification signature is equal to the first signature. The first public key is generated and sent by the first user terminal.
[0170] Figure 4 The data decryption device shown can be used to achieve Figure 2 The implementation principle and technical effects of the data decryption method shown will not be elaborated further. The specific methods by which each module and unit of the data processing device in the above embodiments performs its operations have been described in detail in the embodiments related to this method, and will not be elaborated upon here.
[0171] like Figure 5 The diagram shown is a structural schematic of an embodiment of an electronic device provided in this application. The device may include a storage component 501 and a processing component 502.
[0172] Storage component 501 stores one or more computer instructions, wherein one or more computer instructions are invoked and executed by processing component 502 to achieve... Figure 1 The data signature method shown in the embodiments, or Figure 2 The data decryption method shown in the embodiment.
[0173] Of course, the electronic device may also include other components, such as input / output interfaces, communication components, etc.
[0174] Input / output interfaces provide interfaces between processing components and peripheral interface modules, which can be output devices, input devices, etc.
[0175] The communication component is configured to facilitate wired or wireless communication between electronic devices and other devices.
[0176] Processing component 502 may include one or more processors to execute computer instructions to perform all or part of the steps in the methods described above. Alternatively, the processing component may be implemented as one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the methods described above.
[0177] Storage component 501 is configured to store various types of data to support operations at the terminal. The storage component can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0178] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a computer, can perform the above-described functions. Figure 1 The data signature method shown in the embodiments, or Figure 2 The data decryption method shown in the embodiments. The computer-readable medium may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device.
[0179] This application also provides a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program can perform the above-described functions when executed by a computer. Figure 1 The data signature method shown in the embodiments, or Figure 2 The data decryption method shown in the embodiment.
[0180] In such embodiments, the computer program may be downloaded and installed from a network, and / or installed from a removable medium. When the computer program is executed by a processor, it performs the various functions defined in the system of this application.
[0181] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0182] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0183] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0184] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A data signature method, characterized in that, Applied to the first user terminal, including: Generate a first private key and a first public key, and generate a first identifier based on the first public key and the first user identifier; The first private key and the data to be encrypted are hashed to obtain the target parameters, and the first ciphertext is generated based on the target parameters. The target parameters and the first identifier are used to sign the data to be encrypted to generate a first signature, and a second signature is generated based on the target parameters, the first private key and the first signature; An encryption key is generated based on the target parameters and the second public key. The data to be encrypted is then encrypted using the encryption key, the first signature, and the second signature to generate a second ciphertext. The second public key is generated and sent by the second user terminal. A target ciphertext is generated based on the first ciphertext and the second ciphertext, and the target ciphertext is sent to the second user terminal.
2. The method according to claim 1, characterized in that, The generation of the first ciphertext based on the target parameters includes: The target parameters are multiplied by the base points of the elliptic curve to generate the first ciphertext.
3. The method according to claim 1, characterized in that, The step of using the target parameter and the first identifier to sign the data to be encrypted to generate a first signature includes: The first identifier is hashed with the data to be encrypted to generate a first intermediate parameter; A first signature is generated based on the first intermediate parameter and the target parameter according to the first signature formula; The first signature formula is: r = e + x1 mod n; Where r represents the first signature, e represents the first intermediate parameter, and e = Hv(Z) A ∥M), Hv represents the hash function, Z A Let M represent the first identifier, M represent the data to be encrypted, x1 represent the x-coordinate of the first ciphertext C1, C1=kG, k represent the target parameter, G represent the base point of the elliptic curve, mod represents the modulo operation, and n represents the order of G, which is a positive integer.
4. The method according to claim 3, characterized in that, The step of generating the second signature based on the target parameter, the first private key, and the first signature includes: A second signature is generated based on the target parameters, the first private key, and the first signature, according to the second signature formula. The second signature formula is: s=((1+d) A ) -1 (k-rd A ))modn; Where s represents the second signature, d A represents the first private key, and k represents the target parameter.
5. The method according to claim 4, characterized in that, The step of generating the encryption key based on the target parameters and the second public key includes: The target parameter and the second public key are multiplied to generate the second intermediate parameter; According to the encryption key generation formula, an encryption key is generated based on the second intermediate parameter; The encryption key generation formula is: t=KDF(x2∥y2,klen); Where t represents the encryption key, KDF represents the encryption key derivation function, and x2 represents the second intermediate parameter kP. B The x-coordinate, y2, represents the second intermediate parameter kP. B The ordinate of P B The second public key is represented by klen = mlen + rlen + slen, where klen represents the encryption key length, mlen represents the length of the data to be encrypted, rlen represents the length of the first signature, and slen represents the length of the second signature. The step of encrypting the data to be encrypted based on the encryption key, the first signature, and the second signature to generate the second ciphertext includes: The data to be encrypted, the first signature, and the second signature are concatenated to obtain a first concatenation result; The first concatenation result is encrypted using the XOR encryption algorithm and the encryption key to generate the second ciphertext.
6. The method according to claim 5, characterized in that, The step of generating the target ciphertext based on the first ciphertext and the second ciphertext includes: The first ciphertext and the second ciphertext are concatenated to generate the target ciphertext.
7. A data decryption method, characterized in that, Applied to the second user terminal, including: Generate a second private key and a second public key; The system receives target ciphertext sent by a first user terminal. The target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext. The first ciphertext is generated based on target parameters. The second ciphertext is generated by encrypting the data to be encrypted using an encryption key, a first signature, and a second signature. The encryption key is generated based on the target parameters and the second public key. The first signature is generated by signing the data to be encrypted using the target parameters and a first identifier. The second signature is generated based on the target parameters, a first private key, and the first signature. The target parameters are obtained by hashing the first private key and the data to be encrypted. A decryption key is generated based on the first ciphertext and the second private key, and the second ciphertext is decrypted based on the decryption key to generate a first signature, a second signature, and decrypted data; A verification signature is generated based on the first identifier, the first public key, the first signature, the second signature, and the decryption data. If the verification signature is equal to the first signature, the verification is successful, and the decryption data is output. The first public key is generated and sent by the first user terminal.
8. The method according to claim 7, characterized in that, The process of generating the decryption key based on the first ciphertext and the second private key includes: A third intermediate parameter is generated based on the second private key and the first ciphertext; According to the decryption key generation formula, a decryption key is generated based on the third intermediate parameter; The formula for generating the decryption key is: t′=KDF(x2′∥y2′,klen); Where t′ represents the decryption key, and x2′ represents the third intermediate parameter d. B The x-coordinate of C1, y2′ represents the third intermediate parameter d. B The ordinate of C1, d B C1 represents the second private key, C1 represents the first ciphertext, klen = mlen + rlen + slen, klen represents the decryption key length, mlen represents the decryption data length, rlen represents the first signature length, and slen represents the second signature length. The step of decrypting the second ciphertext based on the decryption key to generate a first signature, a second signature, and decrypted data includes: According to the decryption algorithm corresponding to the XOR encryption algorithm, the second ciphertext is decrypted using the decryption key to obtain the second concatenation result; Obtain the first signature, the second signature, and the decrypted data from the second splicing result.
9. The method according to claim 8, characterized in that, The step of generating a verification signature based on the first identifier, the first public key, the first signature, the second signature, and the decryption data includes: The first identifier is hashed with the decrypted data to generate a fourth intermediate parameter; Based on the first signature and the second signature, a fifth intermediate parameter is generated; Based on the second signature, the fifth intermediate parameter, and the first public key, the sixth intermediate parameter is generated; A verification signature is generated based on the fourth intermediate parameter and the sixth intermediate parameter according to the verification signature generation formula. The formula for generating the verification signature is: R = (e′ + x1′) mod n; Where R represents the signature verification, e′ represents the fourth intermediate parameter, and e′=Hv(Z) A ∥M′), Z A M' represents the first identifier, M' represents the decrypted data, and x1' represents the sixth intermediate parameter s'G+u'P. A The x-coordinate of P, s′ represents the second signature, u′ represents the fifth intermediate parameter, u′=(r′+s′)modn, P A Let r' represent the first public key, r' represent the first signature, G represent the base point of the elliptic curve, and n represent the order of G, which is a positive integer.
10. A data signature device, characterized in that, Applied to the first user terminal, including: The first generation module is used to generate a first private key and a first public key, and to generate a first identifier based on the first public key and the first user identifier; The second generation module is used to perform a hash operation on the first private key and the data to be encrypted to obtain target parameters, and generate the first ciphertext based on the target parameters; The third generation module is used to sign the data to be encrypted using the target parameters and the first identifier to generate a first signature, and to generate a second signature based on the target parameters, the first private key and the first signature; An encryption module is used to generate an encryption key based on the target parameters and the second public key, and to encrypt the data to be encrypted based on the encryption key, the first signature, and the second signature to generate a second ciphertext. The second public key is generated and sent by the second user terminal. The sending module is used to generate target ciphertext based on the first ciphertext and the second ciphertext, and send the target ciphertext to the second user terminal.
11. A data decryption device, characterized in that, Applied to the second user terminal, including: The fourth generation module is used to generate the second private key and the second public key; The receiving module is used to receive target ciphertext sent by a first user terminal. The target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext. The first ciphertext is generated based on target parameters. The second ciphertext is generated by encrypting the data to be encrypted using an encryption key, a first signature, and a second signature. The encryption key is generated based on the target parameters and the second public key. The first signature is generated by signing the data to be encrypted using the target parameters and a first identifier. The second signature is generated based on the target parameters, a first private key, and the first signature. The target parameters are obtained by hashing the first private key and the data to be encrypted. The decryption module is used to generate a decryption key based on the first ciphertext and the second private key, and to decrypt the second ciphertext based on the decryption key to generate a first signature, a second signature and decrypted data; The verification module is used to generate a verification signature based on the first identifier, the first public key, the first signature, the second signature, and the decryption data. If the verification signature is equal to the first signature, the verification is successful, and the decryption data is output. The first public key is generated and sent by the first user terminal.
12. An electronic device, characterized in that, Includes storage components and processing components; The storage component stores one or more computer instructions; the one or more computer instructions are invoked and executed by the processing component. The processing component executes one or more computer instructions to implement the data signature method as described in any one of claims 1 to 6.
13. An electronic device, characterized in that, Includes storage components and processing components; The storage component stores one or more computer instructions; the one or more computer instructions are invoked and executed by the processing component. The processing component executes one or more computer instructions to implement the data decryption method as described in any one of claims 7 to 9.
14. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a computer, it implements the data signature method as described in any one of claims 1 to 6, or the data desealing method as described in any one of claims 7 to 9.
15. A computer program product, characterized in that, The device contains a computer program that, when executed by a computer, implements the data signature method as described in any one of claims 1 to 6, or the data desealing method as described in any one of claims 7 to 9.