Data signcryption method and device, data de-signcryption method and device and equipment
By using hash calculation in the digital signature and encryption scheme to generate target parameters and sign and encrypt based on this parameter, the problem of high requirements for random number generation devices in traditional solutions is solved, expanding the scope of application and improving security.
Patent Information
- Application Number
- CN202411337409.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-09-24
AI Technical Summary
In traditional digital signature and encryption schemes, the random number generation equipment requirements are high, resulting in a smaller scope of application.
By hashing calculations and hashing calculations of the first private key and data to be encrypted, a first ciphertext is generated based on the target parameters, and a first signature is generated using the target parameters and a first identifier to sign the encrypted data to be encrypted, And generate a second signature based on the target parameters, the first private key and the first signature, and finally generate an encryption key based on the target parameters and the second public key, encrypt the encrypted data, and generate a second ciphertext.
No random numbers are required, which expands the scope of application of digital signatures and encryption, and improves security and flexibility.
Smart Images

Figure CN119420472A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of data processing, and in particular to a data signcryption method and device, a data decryption method and device, and equipment. Background Art
[0002] With the development of Internet technology, mobile office and mobile payment are becoming more and more popular, and mobile informatization and cloud services have become a trend. In order to ensure the security of data transmission, cryptographic technology is indispensable. At the same time, digital signature, as a security technology that has emerged with the development of information network technology, can verify whether the data has changed during the transmission process and ensure 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 random numbers directly affects the security of the algorithm. However, the random number generation equipment has high requirements and a small scope of application. Summary of the invention
[0004] The embodiments of the present application provide a data signcryption method and device, a data decryption method and device, and a device to solve the problem that in traditional solutions, random numbers are needed for digital signing and encryption, but the requirements for the random number generation device are high, resulting in a small scope of application. The purpose is to expand the scope of application of digital signatures and encryption.
[0005] In a first aspect, the present application provides a data signcryption 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] Performing a hash operation on the first private key and the data to be encrypted to obtain a target parameter, and generating a first ciphertext based on the target parameter;
[0008] Signing the data to be encrypted using the target parameter and the first identifier to generate a first signature, and generating a second signature based on the target parameter, the first private key and the first signature;
[0009] Generate an encryption key based on the target parameter and a second public key, and encrypt the data to be encrypted based on the encryption key, the first signature, and the second signature to generate a second ciphertext, wherein 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 client.
[0011] Optionally, generating a first ciphertext based on the target parameter includes:
[0012] The target parameter is multiplied by an elliptic curve base point to generate a first ciphertext.
[0013] Optionally, the using the target parameter and the first identifier to sign the data to be encrypted to generate a first signature includes:
[0014] Performing a hash calculation on the first identifier and the data to be encrypted to generate a first intermediate parameter;
[0015] Generate a first signature based on the first intermediate parameter and the target parameter according to a first signature formula;
[0016] The first signature formula is: r=e+x1modn;
[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 represents the first identifier, M represents the data to be encrypted, x1 represents the horizontal 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 modular 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] Generate a second signature based on the target parameter, the first private key and the first signature according to a second signature formula;
[0020] The second signature formula is: s=((1+d A ) -1 (k-rd A ))modn;
[0021] Among them, s represents the second signature, d A represents the first private key, and k represents the target parameter.
[0022] Optionally, the generating an encryption key based on the target parameter and the second public key includes:
[0023] Calculate the product of the target parameter and the second public key to generate a second intermediate parameter;
[0024] Generate an encryption key based on the second intermediate parameter according to an encryption key generation formula;
[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 horizontal axis y2 represents the second intermediate parameter kP B The vertical coordinate, P B represents the second public key, klen=mlen+rlen+slen, klen represents the encryption key length, mlen represents the length of the data to be encrypted, rlen represents the first signature length, and slen represents the second signature length;
[0027] The encrypting the to-be-encrypted data based on the encryption key, the first signature, and the second signature to generate a second ciphertext comprises:
[0028] Concatenate the data to be encrypted, the first signature, and the second signature to obtain a first concatenation result;
[0029] According to an XOR encryption algorithm, the first concatenation result is encrypted using the encryption key to generate a second ciphertext.
[0030] Optionally, generating a target ciphertext based on the first ciphertext and the second ciphertext includes:
[0031] The first ciphertext and the second ciphertext are concatenated to generate a target ciphertext.
[0032] In a second aspect, the present application provides a data decryption and signcryption method, which is applied to a second user terminal, comprising:
[0033] Generate a second private key and a second public key;
[0034] Receive a target ciphertext sent by a first user terminal, where the target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext, where the first ciphertext is generated based on a target parameter, where the second ciphertext is generated by encrypting data to be encrypted using an encryption key, a first signature, and a second signature, where the encryption key is generated based on the target parameter and the second public key, where the first signature is generated by signing the data to be encrypted based on the target parameter and a first identifier, where the second signature is generated based on the target parameter, a first private key, and the first signature, where the target parameter is obtained by performing a hash calculation on the first private key and the data to be encrypted;
[0035] 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 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 decrypted data. When the verification signature is equal to the first signature, the verification passes and the decrypted data is output. The first public key is generated and sent by the first user terminal.
[0037] Optionally, generating a decryption key based on the first ciphertext and the second private key includes:
[0038] Generate a third intermediate parameter based on the second private key and the first ciphertext;
[0039] Generate a decryption key based on the third intermediate parameter according to a decryption key generation formula;
[0040] The decryption key generation formula is: t′=KDF(x2′∥y2′,klen);
[0041] Where t′ represents the decryption key, x2′ represents the third intermediate parameter d B The abscissa of C1, y2′ represents the third intermediate parameter d B The vertical coordinate of C1, d B represents the second private key, C1 represents the first ciphertext, klen=mlen+rlen+slen, klen represents the decryption key length, mlen represents the decrypted data length, rlen represents the first signature length, and slen represents the second signature length;
[0042] The decrypting the second ciphertext based on the decryption key to generate the first signature, the second signature and the decrypted data comprises:
[0043] Decrypting the second ciphertext using the decryption key according to the decryption algorithm corresponding to the XOR encryption algorithm to obtain a second splicing result;
[0044] The first signature, the second signature and the decrypted data are obtained 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 decrypted data includes:
[0046] Performing a hash calculation on the first identifier and the decrypted data to generate a fourth intermediate parameter;
[0047] Generate a fifth intermediate parameter based on the first signature and the second signature;
[0048] Generate a sixth intermediate parameter based on the second signature, the fifth intermediate parameter and the first public key;
[0049] Generate a verification signature based on the fourth intermediate parameter and the sixth intermediate parameter according to a verification signature generation formula;
[0050] The verification signature generation formula is: R = (e'+x1') modn;
[0051] Where R represents the verification signature, e′ represents the fourth intermediate parameter, and e′=Hv(Z A ∥M′), Z A represents the first identifier, M′ represents the decrypted data, and x1′ represents the sixth intermediate parameter s′G+u′P A The horizontal axis of s′ represents the second signature, u represents the fifth intermediate parameter, u=(r′+s′)modn, P A Represents the first public key.
[0052] In a third aspect, the present application provides a data signcryption device, applied to a first user terminal, comprising:
[0053] A first generating module, configured to generate a first private key and a first public key, and generate a first identifier based on the first public key and a first user identifier;
[0054] A second generating module, configured to perform a hash operation on the first private key and the data to be encrypted to obtain a target parameter, and generate a first ciphertext based on the target parameter;
[0055] A third generating module, configured to sign the data to be encrypted using the target parameter and the first identifier to generate a first signature, and to generate a second signature based on the target parameter, the first private key and the first signature;
[0056] an encryption module, configured to generate an encryption key based on the target parameter and a 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, wherein the second public key is generated and sent by the second user terminal;
[0057] A sending module 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.
[0058] In a fourth aspect, the present application provides a data decryption and signcryption device, applied to a second user terminal, comprising:
[0059] A fourth generating module, used to generate a second private key and a second public key;
[0060] a receiving module, configured to receive a target ciphertext sent by a first user terminal, wherein the target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext, wherein the first ciphertext is generated based on a target parameter, and the second ciphertext is generated by encrypting data to be encrypted using an encryption key, a first signature, and a second signature, wherein the encryption key is generated based on the target parameter and the second public key, wherein the first signature is generated by signing the data to be encrypted based on the target parameter and a first identifier, wherein the second signature is generated based on the target parameter, a first private key, and the first signature, and wherein the target parameter is obtained by performing a hash calculation on the first private key and the data to be encrypted;
[0061] a decryption module, configured to 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 a first signature, a second signature, and decrypted data;
[0062] A 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 decrypted data, and if the verification signature is equal to the first signature, the verification passes and the decrypted data is output. The first public key is generated and sent by the first user terminal.
[0063] In a fifth aspect, the present application provides an electronic device comprising a storage component and a processing component; the storage component stores one or more computer instructions, the one or more computer instructions are called and executed by the processing component, and the processing component executes the one or more computer instructions to implement the data signcryption method as described in the first aspect.
[0064] In a sixth aspect, the present application provides an electronic device comprising a storage component and a processing component; the storage component stores one or more computer instructions, the one or more computer instructions are called 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, the present application provides a computer-readable storage medium storing a computer program, which, when executed by a computer, implements the data signcryption method as described in the first aspect, or the data designcryption method as described in the second aspect.
[0066] In an eighth aspect, the present application provides a computer program product storing a computer program, wherein when the computer program is executed by a computer, the computer program implements the data signcryption method described in the first aspect, or the data designcryption method described in the second aspect.
[0067] In an embodiment of the present application, a first private key of a first user terminal and data to be encrypted can be used to perform a hash calculation to generate a target parameter, a first ciphertext can be generated based on the target parameter, and the target parameter and the first identifier can be used to sign the encrypted data to generate a first signature, and a second signature can be generated based on the target parameter, the first private key and the first signature, and an encryption key can be generated based on the target parameter and the second public key, and the encrypted data can be encrypted based on the encryption key, the first signature and the second signature to generate a second ciphertext, a target ciphertext can be generated based on the first ciphertext and the second ciphertext, and the target ciphertext can be sent to the second user terminal without using random numbers. This solves the problem that the traditional scheme has high requirements for random number generation equipment, resulting in a smaller scope of application of signatures and encryption, and can improve the scope of application of signatures and encryption.
[0068] These and other aspects of the present application will become more clearly understood in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0070] Figure 1 A flow chart of an embodiment of a data signcryption method provided by the present application is shown;
[0071] Figure 2 A flow chart of an embodiment of a data decryption and signcryption method provided by the present application is shown;
[0072] Figure 3 A schematic diagram showing the structure of an embodiment of a data signcryption device provided by the present application is shown;
[0073] Figure 4 A schematic diagram showing the structure of an embodiment of a data decryption and signcryption device provided by the present application is shown;
[0074] Figure 5 A schematic structural diagram of an embodiment of an electronic device provided by the present application is shown. DETAILED DESCRIPTION
[0075] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0076] In some of the processes described in the specification and claims of this application and the above-mentioned figures, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish between different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.
[0077] The technical solution of this application is applicable to the field of data processing, especially 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 changed during transmission and ensure 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 random numbers directly affects the security of the algorithm. However, the random number generation equipment has high requirements and a small scope of application.
[0079] In order to solve the above technical problems, the inventors thought whether it is possible to implement digital signature and encryption without using random numbers. Based on this, the technical solution of the present application is proposed, and a data sign-encryption method is provided, including generating a first private key and a first public key, and generating a first identifier based on the first public key and the first user identifier; performing a hash operation on the first private key and the data to be encrypted to obtain a target parameter, and generating a first ciphertext based on the target parameter; signing the data to be encrypted using the target parameter and the first identifier to generate a first signature, and generating a second signature based on the target parameter, the first private key and the first signature; generating an encryption key based on the target parameter and the second public key, and encrypting 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 being generated and sent by the 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 an embodiment of the present application, a target parameter is generated by performing a hash calculation using the first private key of the first user terminal and the data to be encrypted, and signing and encryption are performed based on the target parameter without using a random number. This solves the problem in traditional solutions that high requirements for random number generation equipment result in a smaller scope of application of digital signatures and encryption, and can improve the scope of application of digital signatures and encryption.
[0081] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0082] like Figure 1 As shown, it is a flow chart of an embodiment of a data signcryption method provided by the present application, and 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 a first user identifier.
[0084] In the embodiment of the present application, it is applicable to the scenario of two-party encryption, where the first user terminal encrypts the data to be encrypted and the second user terminal decrypts it. The data encryption method of 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 for implementation. The SM2 algorithm may include elliptic curve parameters E(Fq), a, b, G, and n. Among them, E may represent an elliptic curve on a finite field Fq, G may represent a base point of order n on the elliptic curve E, n is a positive integer, and G and n are parameters of the elliptic curve.
[0086] Specifically, the first user terminal may randomly select a first private key d A ∈Zn, Zn represents a positive integer, and a first public key P is generated based on the first private key and the elliptic curve parameters A , P A =d A G.
[0087] Furthermore, the first user terminal may generate a first identifier based on the first public key and the first user identifier according to an 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 Indicates the first identifier, H 256 Represents a hash function, ENTL A represents the length of the first user identifier, a and b represent the elliptic curve parameters, x G Indicates the horizontal coordinate of the base point G, yG Indicates the ordinate of the base point G, x A Represents the first public key P A The horizontal axis, y A Represents the first public key P A The vertical coordinate of .
[0089] 102: Perform a hash operation on the first private key and the data to be encrypted to obtain a target parameter, and generate a 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 represents the first private key, and M represents the data to be encrypted.
[0091] And, optionally, the target parameter and the elliptic curve base point can be multiplied to generate a first ciphertext C1, C1=kG=(x1,y1), where C1 represents the first ciphertext, G represents the elliptic curve base point, x1 represents the horizontal coordinate, and y1 represents the vertical coordinate.
[0092] In order to facilitate computational processing, the first ciphertext may be converted into a bit string.
[0093] 103: Sign the data to be encrypted using the target parameter and the first identifier 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 parameter 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 a 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 a target ciphertext based on the first ciphertext and the second ciphertext, and send the target ciphertext to the second client.
[0098] After obtaining the first ciphertext and the second ciphertext, the first ciphertext and the second ciphertext may be concatenated to generate a target ciphertext, and the target ciphertext may be sent to the second user terminal.
[0099] In this embodiment, the first private key of the first user terminal and the data to be encrypted can be used to perform a hash calculation to generate a target parameter, a first ciphertext is generated based on the target parameter, and the target parameter 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 parameter, the first private key and the first signature, and an encryption key is generated based on the target parameter and the second public key, and the encrypted data is 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 without using random numbers. This solves the problem that the random number generation device in the traditional solution has high requirements, resulting in a small scope of application of digital signatures and encryption, and can improve the scope of application of digital signatures and encryption.
[0100] The generation process of the first signature, the second signature and the second ciphertext is described below.
[0101] In some embodiments, signing the data to be encrypted using the target parameter and the first identifier to generate the first signature may include:
[0102] A hash calculation is performed on the first identifier and the data to be encrypted to generate a first intermediate parameter.
[0103] Specifically, the first intermediate parameter e=Hv(Z A ∥M), Hv represents the hash function, Z A represents the first identifier, and M represents the data to be encrypted.
[0104] Afterwards, a first signature may be generated based on the first intermediate parameter and the target parameter according to the first signature formula;
[0105] The first signature formula may be: r=e+x1modn;
[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 represents the first identifier, M represents the data to be encrypted, x1 represents the horizontal 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 modular operation, and n represents the order of G, which is a positive integer.
[0107] In some embodiments, generating the second signature based on the target parameter, the first private key, and the first signature may include:
[0108] Generate a second signature based on the target parameter, the first private key and the first signature according to the second signature formula;
[0109] The second signature formula may be: s=((1+d A ) -1(k-rd A ))modn;
[0110] Among them, s represents the second signature, d A represents the first private key, and k represents the target parameter.
[0111] To facilitate calculation and processing, the first signature and the second signature may be converted into a bit string, rlen represents the length of the first signature converted into the bit string, and slen represents the length of the second signature converted into the bit string.
[0112] Further, generating an encryption key based on the target parameter and the second public key may include:
[0113] The target parameter and the second public key are multiplied to generate a second intermediate parameter.
[0114] Specifically, calculate the second intermediate parameter kP B =(x2,y2), x2 represents the horizontal coordinate, y2 represents the vertical coordinate.
[0115] Generate an encryption key based on the second intermediate parameter according to an encryption key generation formula;
[0116] The encryption key generation formula 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 horizontal axis y2 represents the second intermediate parameter kP B The vertical coordinate, P B Represents the second public key, klen=mlen+rlen+slen, klen represents the encryption key length, mlen represents the length of the data to be encrypted, rlen represents the first signature length, and slen represents the second signature length.
[0118] Further, encrypting the data to be encrypted based on the encryption key, the first signature, and the second signature to generate the second ciphertext may include:
[0119] Concatenate the data to be encrypted, the first signature, and the second signature to obtain a first concatenation result;
[0120] According to the XOR encryption algorithm, the first concatenation result is encrypted using the encryption key to generate a 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] Afterwards, the first ciphertext and the second ciphertext may be concatenated to obtain the target ciphertext C=C1||C2.
[0123] The first client may send the target ciphertext to the second client.
[0124] like Figure 2 As shown, it is a flow chart of an embodiment of a data decryption signcryption method provided by the present application, and the method may include the following steps.
[0125] 201: Generate a second private key and a second public key.
[0126] In this embodiment, it can be applied to the second user terminal. The second user terminal can randomly select the second private key d B ∈Zn, and generate the second public key P based on the second private key and the elliptic curve base point B , P B =d B G.
[0127] 202: Receive a target ciphertext sent by a first client.
[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 refer to Figure 1 The illustrated embodiments will not be described in detail.
[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 a first signature, a second signature, and decrypted data.
[0130] The second user terminal can obtain the first ciphertext from the target ciphertext and convert it into a point on the elliptic curve to determine whether the elliptic curve equation is satisfied. If satisfied, continue to perform subsequent decryption steps, if not satisfied, verification fails.
[0131] Specifically, the third intermediate parameter d can be generated based on the second private key and the first ciphertext. B C1=(x2′,y2′),d B represents the second private key, C1 represents the first ciphertext, x2′ represents the abscissa, and y2′ represents the ordinate.
[0132] 204: Generate a verification signature based on the first identifier, the first public key, the first signature, the second signature and the decrypted data, and if the verification signature is equal to the first signature, the verification is successful and the decrypted data is output.
[0133] The first public key is generated and sent by the first user terminal.
[0134] Specifically, the generation process of the decryption key, decrypted data and verification signature will be described in subsequent embodiments.
[0135] In this embodiment, the target parameters are generated by performing hash calculation using the first private key of the first user terminal and the data to be encrypted, and signing and encryption are performed based on the target parameters without using random numbers. This solves the problem in traditional solutions that high requirements for random number generation equipment result in a smaller scope of application of digital signatures and encryption, and can improve the scope of application 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] Generate a decryption key based on the third intermediate parameter according to a decryption key generation formula;
[0139] The decryption key generation formula can be: t′=KDF(x2′∥y2′,klen);
[0140] Where t′ represents the decryption key, x2′ represents the third intermediate parameter d B The abscissa of C1, y2′ represents the third intermediate parameter d B The vertical coordinate of C1, d B represents the second private key, C1 represents the first ciphertext, klen=mlen+rlen+slen, klen represents the decryption key length, mlen represents the decrypted data length, rlen represents the first signature length, and slen represents the second signature length.
[0141] After the decryption key is generated, it can be determined whether the decryption key is 0. If so, the verification fails. If not, continue to perform subsequent operations.
[0142] At this time, decrypting the second ciphertext based on the decryption key to generate the first signature, the second signature, and the decrypted data may include:
[0143] Decrypt the second ciphertext using the decryption key according to the decryption algorithm corresponding to the XOR encryption algorithm to obtain a second concatenation result;
[0144] The first signature, the second signature and the decrypted data are obtained from the second concatenation result.
[0145] Specifically, m′||r′||s′=t′⊕C2 can be calculated, where m′ represents the decrypted data and C2 represents the second ciphertext.
[0146] Furthermore, the first signature and the second signature can be converted into integers to verify r′∈Zn and s′∈Zn. If not, the verification fails.
[0147] Further, 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] A hash calculation is performed on the first identifier and the decrypted data to generate a fourth intermediate parameter.
[0149] Specifically, the fourth intermediate parameter e′=Hv(Z A ∥M′), Z A represents the first identifier, M′ represents the decrypted data, and the fourth intermediate parameter can be converted into an integer.
[0150] A fifth intermediate parameter is generated based on the first signature and the second signature.
[0151] Specifically, the fifth intermediate parameter u′=(r′+s′)modn, if u′=0, the verification fails.
[0152] A 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′), x1′ represents the horizontal coordinate.
[0154] Generate a verification signature based on the fourth intermediate parameter and the sixth intermediate parameter according to a verification signature generation formula;
[0155] The verification signature generation formula 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 represents the first identifier, M′ represents the decrypted data, and x1′ represents the sixth intermediate parameter s′G+u′P A The horizontal axis of s′ represents the second signature, u′ represents the fifth intermediate parameter, u′=(r′+s′)modn, P A Represents the first public key.
[0157] Afterwards, when the verification signature is equal to the first signature, the verification is passed and the decrypted data is output.
[0158] like Figure 3 As shown, it is a structural schematic diagram of an embodiment of a data sign-encryption device provided by the present application, and the device may include the following modules.
[0159] A first generating module 301, configured to generate a first private key and a first public key, and generate a first identifier based on the first public key and a first user identifier;
[0160] The second generating module 302 is used to perform a hash operation on the first private key and the data to be encrypted to obtain a target parameter, and generate a first ciphertext based on the target parameter;
[0161] A third generating module 303 is used to sign the to-be-encrypted data using the target parameter and the first identifier to generate a first signature, and to generate a second signature based on the target parameter, the first private key and the first signature;
[0162] An encryption module 304 is used to generate an encryption key based on the target parameter and a second public key, and encrypt the data to be encrypted based on the encryption key, the first signature, and the second signature to generate a second ciphertext, wherein 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 client.
[0164] Figure 3 The data signcryption device shown can be used to implement Figure 1 The implementation principle and technical effect of the data signcryption method shown are not described in detail. The specific way in which each module and unit performs operations in the data processing device in the above embodiment has been described in detail in the embodiment of the method, and will not be described in detail here.
[0165] like Figure 4 As shown, it is a structural schematic diagram of an embodiment of a data decryption and sign-encryption device provided by the present application, and the device may include the following modules.
[0166] The fourth generating module 401 is used to generate a second private key and a second public key;
[0167] A receiving module 402 is configured to receive a target ciphertext sent by a first user terminal, wherein the target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext, wherein the first ciphertext is generated based on a target parameter, and the second ciphertext is generated by encrypting data to be encrypted using an encryption key, a first signature, and a second signature, wherein the encryption key is generated based on the target parameter and the second public key, wherein the first signature is generated by signing the data to be encrypted based on the target parameter and a first identifier, wherein the second signature is generated based on the target parameter, a first private key, and the first signature, and wherein the target parameter is obtained by performing a hash calculation on the first private key and the data to be encrypted;
[0168] A decryption module 403, configured to 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 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 decrypted data, and if the verification signature is equal to the first signature, the verification passes and the decrypted data is output. 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 implement Figure 2 The implementation principle and technical effect of the data decryption and signcryption method shown are not described in detail. The specific manner in which each module and unit performs operations in the data processing device in the above embodiment has been described in detail in the embodiment of the method, and will not be described in detail here.
[0171] like Figure 5 , which is a schematic diagram of the structure of an embodiment of an electronic device provided by the present application, the device may include a storage component 501 and a processing component 502.
[0172] The storage component 501 stores one or more computer instructions, wherein the one or more computer instructions are called and executed by the processing component 502 to implement Figure 1 The data signcryption method shown in the embodiment, 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] The input / output interface provides an interface between the processing component and the peripheral interface module, which may be an output device, an input device, etc.
[0175] The communication component is configured to facilitate, among other things, wired or wireless communications between the electronic device and other devices.
[0176] The processing component 502 may include one or more processors to execute computer instructions to complete all or part of the steps in the above method. Of course, the processing component can also be implemented by 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 to perform the above method.
[0177] The 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 memory, flash memory, magnetic disk or optical disk.
[0178] The present application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a computer, the above-mentioned Figure 1 The data signcryption method shown in the embodiment, or Figure 2 The data decryption and signcryption method shown in the embodiment. The computer-readable medium may be included in the electronic device described in the above embodiment; or it may exist independently without being assembled into the electronic device.
[0179] The present application also provides a computer program product, which includes a computer program carried on a computer-readable storage medium. When the computer program is executed by a computer, the above-mentioned Figure 1 The data signcryption method shown in the embodiment, or Figure 2 The data decryption method shown in the embodiment.
[0180] In such an embodiment, 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, various functions defined in the system of the present application are performed.
[0181] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0182] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0183] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment 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 the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A data signcryption 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; Performing a hash operation on the first private key and the data to be encrypted to obtain a target parameter, and generating a first ciphertext based on the target parameter; Signing the data to be encrypted using the target parameter and the first identifier to generate a first signature, and generating a second signature based on the target parameter, the first private key and the first signature; Generate an encryption key based on the target parameter and a second public key, and encrypt the data to be encrypted based on the encryption key, the first signature, and the second signature to generate a second ciphertext, wherein 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 client.
2. The method according to claim 1, characterized in that Generating the first ciphertext based on the target parameter comprises: The target parameter is multiplied by an elliptic curve base point to generate a first ciphertext.
3. The method according to claim 1, characterized in that The using the target parameter and the first identifier to sign the data to be encrypted to generate a first signature comprises: Performing a hash calculation on the first identifier and the data to be encrypted to generate a first intermediate parameter; Generate a first signature based on the first intermediate parameter and the target parameter according to a first signature formula; The first signature formula is: r=e+x1modn; 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 represents the first identifier, M represents the data to be encrypted, x1 represents the horizontal 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 modular operation, and n represents the order of G, which is a positive integer.
4. The method according to claim 3, characterized in that Generating the second signature based on the target parameter, the first private key and the first signature includes: Generate a second signature based on the target parameter, the first private key and the first signature according to a second signature formula; The second signature formula is: s=((1+d A ) -1 (k-rd A ))modn; Among them, 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 generating of the encryption key based on the target parameter and the second public key comprises: Calculate the product of the target parameter and the second public key to generate a second intermediate parameter; Generate an encryption key based on the second intermediate parameter according to an encryption key generation formula; 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 horizontal axis y2 represents the second intermediate parameter kP B The vertical axis, P B represents the second public key, klen=mlen+rlen+slen, klen represents the encryption key length, mlen represents the length of the data to be encrypted, rlen represents the first signature length, and slen represents the second signature length; The encrypting the to-be-encrypted data based on the encryption key, the first signature, and the second signature to generate a second ciphertext comprises: Concatenate the data to be encrypted, the first signature, and the second signature to obtain a first concatenation result; According to an XOR encryption algorithm, the first concatenation result is encrypted using the encryption key to generate a second ciphertext.
6. The method according to claim 5, characterized in that Generating a target ciphertext based on the first ciphertext and the second ciphertext includes: The first ciphertext and the second ciphertext are concatenated to generate a 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; Receive a target ciphertext sent by a first user terminal, where the target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext, where the first ciphertext is generated based on a target parameter, where the second ciphertext is generated by encrypting data to be encrypted using an encryption key, a first signature, and a second signature, where the encryption key is generated based on the target parameter and the second public key, where the first signature is generated by signing the data to be encrypted based on the target parameter and a first identifier, where the second signature is generated based on the target parameter, a first private key, and the first signature, where the target parameter is obtained by performing a hash calculation on the first private key and the data to be encrypted; 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 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 decrypted data. When the verification signature is equal to the first signature, the verification passes and the decrypted 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 generating a decryption key based on the first ciphertext and the second private key comprises: Generate a third intermediate parameter based on the second private key and the first ciphertext; Generate a decryption key based on the third intermediate parameter according to a decryption key generation formula; The decryption key generation formula is: t′=KDF(x2′∥y2′,klen); Where t′ represents the decryption key, x2′ represents the third intermediate parameter d B The abscissa of C1, y2′ represents the third intermediate parameter d B The vertical coordinate of C1, d B represents the second private key, C1 represents the first ciphertext, klen=mlen+rlen+slen, klen represents the decryption key length, mlen represents the decrypted data length, rlen represents the first signature length, and slen represents the second signature length; The decrypting the second ciphertext based on the decryption key to generate the first signature, the second signature and the decrypted data comprises: Decrypting the second ciphertext using the decryption key according to the decryption algorithm corresponding to the XOR encryption algorithm to obtain a second splicing result; The first signature, the second signature and the decrypted data are obtained from the second splicing result.
9. The method according to claim 8, characterized in that Generating a verification signature based on the first identifier, the first public key, the first signature, the second signature, and the decrypted data comprises: Performing a hash calculation on the first identifier and the decrypted data to generate a fourth intermediate parameter; Generate a fifth intermediate parameter based on the first signature and the second signature; Generate a sixth intermediate parameter based on the second signature, the fifth intermediate parameter and the first public key; Generate a verification signature based on the fourth intermediate parameter and the sixth intermediate parameter according to a verification signature generation formula; The verification signature generation formula is: R = (e'+x1') modn; Where R represents the verification signature, e′ represents the fourth intermediate parameter, and e′=Hv(Z A ∥M′), Z A represents the first identifier, M′ represents the decrypted data, and x1′ represents the sixth intermediate parameter s′G+u′P A The horizontal axis of s′ represents the second signature, u′ represents the fifth intermediate parameter, u′=(r′+s′)modn, P A Represents the first public key.
10. A data signcryption device, characterized in that: Applied to the first user terminal, including: A first generating module, configured to generate a first private key and a first public key, and generate a first identifier based on the first public key and a first user identifier; A second generating module, configured to perform a hash operation on the first private key and the data to be encrypted to obtain a target parameter, and generate a first ciphertext based on the target parameter; A third generating module, configured to sign the data to be encrypted using the target parameter and the first identifier to generate a first signature, and to generate a second signature based on the target parameter, the first private key and the first signature; an encryption module, configured to generate an encryption key based on the target parameter and a 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, wherein the second public key is generated and sent by the second user terminal; A sending module 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.
11. A data decryption and signcryption device, characterized in that: Applied to the second user terminal, including: A fourth generating module, used to generate a second private key and a second public key; a receiving module, configured to receive a target ciphertext sent by a first user terminal, wherein the target ciphertext is obtained by concatenating a first ciphertext and a second ciphertext, wherein the first ciphertext is generated based on a target parameter, and the second ciphertext is generated by encrypting data to be encrypted using an encryption key, a first signature, and a second signature, wherein the encryption key is generated based on the target parameter and the second public key, wherein the first signature is generated by signing the data to be encrypted based on the target parameter and a first identifier, wherein the second signature is generated based on the target parameter, a first private key, and the first signature, and wherein the target parameter is obtained by performing a hash calculation on the first private key and the data to be encrypted; a decryption module, configured to 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 a first signature, a second signature, and decrypted data; A 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 decrypted data, and if the verification signature is equal to the first signature, the verification passes and the decrypted data is output. The first public key is generated and sent by the first user terminal.
12. An electronic device, characterized in that: including storage components and processing components; The storage component stores one or more computer instructions; the one or more computer instructions are called and executed by the processing component; The processing component executes the one or more computer instructions to implement the data signcryption method according to any one of claims 1 to 6.
13. An electronic device, characterized in that: including storage components and processing components; The storage component stores one or more computer instructions; the one or more computer instructions are called and executed by the processing component; The processing component executes the one or more computer instructions to implement the data decryption method according to 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, the data signcryption method according to any one of claims 1 to 6 or the data designcryption method according to any one of claims 7 to 9 is implemented.
15. A computer program product, characterized in that A computer program is stored, and when the computer program is executed by a computer, the data signcryption method according to any one of claims 1 to 6 or the data decryption signcryption method according to any one of claims 7 to 9 is implemented.
Citation Information
Patent Citations
Certificateless signcryption system and method based on trap door hash function
CN111262709A
Digital signature and verification method, device and system
CN112688784A
Data processing method and device, electronic equipment and storage medium
CN112822014A
SM2-based signature verification method, device and system
CN112887081A
Signcrypted envelope message
US11356427B1