Data homomorphic encryption method and device, data transmission method and device

By generating η bit private key and random number, a smaller size public key is calculated and homomorphic encryption is performed, the problems of excessive public key size and low encryption efficiency in the existing homomorphic encryption methods are solved, and more efficient data encryption is achieved.

CN114584278BActive Publication Date: 2025-05-02BEIJING INFOSEC TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210134717.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-14
Publication Date
2025-05-02
Estimated Expiration
2042-02-14

AI Technical Summary

Technical Problem

In the existing homomorphic encryption methods, the public key size is too large, resulting in severe computing resource consumption, and can only encrypt plaintext data of one bit length at a time, which is relatively inefficient.

Method used

By generating a private key p of length η bits, and generating random numbers q0, q1, b0, and b1 according to the private key and security parameters, the first and second public keys x0, x1 are calculated, and homomorphic encryption calculation is used for these public keys and random numbers to obtain the encrypted ciphertext.

Benefits of technology

Reducing the public key size to O(λ3), greatly saving computing resources, and improving plaintext space, significantly improving encryption efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114584278B_ABST
    Figure CN114584278B_ABST
Patent Text Reader

Abstract

The present application discloses a data homomorphic encryption method and apparatus, and a data transmission method and apparatus. The data homomorphic encryption method includes: obtaining data to be encrypted; obtaining preset security parameters λ, ρ, ρ′, η, γ and a set plaintext length, where ρ = λ, ρ′ = 2λ, η = O(λ 2 ), γ = O(λ 3 ), and the set plaintext length is greater than 1 bit; generating a private key according to η; generating a random number q0 and a random number q1 according to the private key and γ, and generating a random number b0 and a random number b1 according to the security ρ′; generating a first public key according to the private key, the random number q0, the random number b0 and the set plaintext length, and generating a second public key according to the private key, the random number q1, the random number b1 and the set plaintext length; for each data to be encrypted, generating a first random number and a second random number according to ρ, and performing homomorphic encryption calculation according to the set plaintext length, the first public key, the second public key, the first random number, the second random number and the data to be encrypted to obtain the encrypted ciphertext.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data security, and in particular to a data homomorphic encryption method and device, and a data transmission method and device. Background Art

[0002] With the widespread application of cloud computing technology, especially the large number of e-commerce transactions on cloud computing servers, how to safely and effectively protect user privacy and security has become a hot topic in the field of cryptography research. In order to ensure the security of data transmission, homomorphic encryption technology has been widely used. Homomorphic encryption technology is a cryptographic technology based on the computational complexity theory of mathematical problems. The data that has been homomorphically encrypted is processed to obtain an output. This output is decrypted, and the result is the same as the output obtained by processing the unencrypted original plaintext data using the same method.

[0003] Marten van Dijk, Craig Gentry, Shai Halevi and Vinod Vaikuntanathan proposed a homomorphic encryption method based on integers (Fully Homomorphic Encryption over the Integers), called the DGHV scheme, in which the public key size is too high, up to O(λ 10 ), where λ is a security parameter. This scheme cannot be applied due to limitations of computing resources and other factors. In addition, this scheme can only encrypt plaintext data of one bit in length at a time, which makes the encryption efficiency low.

[0004] Therefore, how to compress the size of the public key in the homomorphic encryption method and increase the plaintext space to improve encryption efficiency is one of the technical problems that need to be urgently solved in the existing technology. Summary of the invention

[0005] In order to solve the problems in the background technology, the embodiments of the present application provide a data homomorphic encryption method and device, and a data transmission method and device.

[0006] In a first aspect, an embodiment of the present application provides a data homomorphic encryption method, including:

[0007] Obtain the data to be encrypted;

[0008] Get the preset security parameters λ, ρ, ρ′, η, γ and set the plaintext length, where ρ=λ, ρ′=2λ, η=O(λ 2 ),γ=O(λ 3 ), the set plaintext length is greater than 1 bit;

[0009] Generate a private key according to the security parameter n;

[0010] Generate a random number q based on the private key and the security parameter γ 0 and the random number q 1 , and generate a random number b according to the security parameter ρ′ 0 and random number b 1 ;

[0011] According to the private key, the random number q 0 , the random number b 0 and the set plaintext length to generate a first public key, and according to the private key and the random number q 1 , the random number b 1 and the set plaintext length to generate a second public key;

[0012] For each piece of data to be encrypted obtained, a first random number and a second random number are generated according to the security parameter ρ, and homomorphic encryption calculation is performed according to the set plaintext length, the first public key, the second public key, the first random number, the second random number and the data to be encrypted to obtain the encrypted ciphertext.

[0013] In a possible implementation, generating a private key according to the security parameter n specifically includes:

[0014] Generate an integer p of length η bits, where p∈[2 η-1 ,2 η );

[0015] The p is determined to be a private key.

[0016] In a possible implementation, the random number q 0 and the random number q 1 The following conditions are met:

[0017]

[0018] Wherein, p represents the private key;

[0019] Z represents a set of integers.

[0020] In a possible implementation, the random number b 0 and the random number b 1 The following conditions are met:

[0021] b 0 ,b 1 ∈(-2 ρ′ ,2 ρ′ )

[0022] In a possible implementation, according to the private key, the random number q 0 , the random number b 0and generating a first public key by setting the plaintext length, specifically comprising:

[0023] The first public key is calculated by the following formula:

[0024] x 0 =pq 0 +Qb 0

[0025] Among them, x 0 represents the first public key;

[0026] p represents the private key;

[0027] Q represents the set plaintext length; and

[0028] According to the private key, the random number q 1 , the random number b 1 and generating a second public key by setting the plaintext length, specifically comprising:

[0029] The second public key is calculated by the following formula:

[0030] x 1 =pq 1 +Qb 1

[0031] Among them, x 1 represents the second public key;

[0032] x 0 and x 1 The following conditions are met: |x 1 |<|x 0 |.

[0033] In a possible implementation, for each piece of data to be encrypted, homomorphic encryption calculation is performed using the following formula to obtain an encrypted ciphertext:

[0034] c i =(m i +Qr i +r′ i x 1 )mod x 0

[0035] Among them, c i represents the ciphertext of the i-th data to be encrypted, i=1~n, n represents the number of data to be encrypted;

[0036] m i Indicates the i-th data to be encrypted;

[0037] Q represents the set plaintext length;

[0038] r i represents a first random number generated for the i-th data to be encrypted;

[0039] r i ' represents a second random number generated for the i-th data to be encrypted;

[0040] r i and r i ′ satisfies the following conditions: i ,r′ i ∈(-2 ρ ,2 ρ );

[0041] x 0 represents the first public key;

[0042] x 1 represents the second public key;

[0043] x 0 and x 1 The following conditions are met: |x 1 |<|x 0 |;

[0044] mod means modular operation.

[0045] In a possible implementation, the method further includes:

[0046] Sending the encrypted ciphertext of each data to be encrypted and the first public key to the target server, so that the target server performs a homomorphic operation on the encrypted ciphertext of each data to be encrypted according to the first public key to obtain a ciphertext homomorphic operation result;

[0047] Receiving the ciphertext homomorphic operation result returned by the target server;

[0048] The ciphertext homomorphic operation result is decrypted using the private key to obtain the decrypted corresponding plaintext homomorphic operation result.

[0049] In a possible implementation, decrypting the ciphertext homomorphic operation result using the private key to obtain the decrypted corresponding plaintext homomorphic operation result specifically includes:

[0050] The ciphertext homomorphic operation result is decrypted by the following formula:

[0051] m=(c mod p)mod Q

[0052] Wherein, m represents the result of the plaintext homomorphic operation;

[0053] c represents the result of the ciphertext homomorphic operation;

[0054] p represents the private key;

[0055] Q represents the set plaintext length;

[0056] Among them, if but like but

[0057] In a second aspect, an embodiment of the present application provides a data homomorphic encryption device, including:

[0058] A first acquisition unit, used to acquire data to be encrypted;

[0059] The second acquisition unit is used to acquire preset security parameters λ, ρ, ρ′, η, γ and set the plaintext length, where ρ=λ, ρ′=2λ, η=O(λ 2 ),γ=O(λ 3 ), the set plaintext length is greater than 1 bit;

[0060] A first generating unit, configured to generate a private key according to the security parameter n;

[0061] The second generating unit is used to generate a random number q according to the private key and the security parameter γ 0 and the random number q 1 , and generate a random number b according to the security parameter ρ′ 0 and random number b 1 ;

[0062] The third generating unit is used to generate a random number q according to the private key and the random number q 0 , the random number b 0 and the set plaintext length to generate a first public key, and according to the private key and the random number q 1 , the random number b 1 and the set plaintext length to generate a second public key;

[0063] The encryption unit is used to generate a first random number and a second random number according to the security parameter ρ for each acquired data to be encrypted, and perform homomorphic encryption calculation according to the set plaintext length, the first public key, the second public key, the first random number, the second random number and the data to be encrypted to obtain an encrypted ciphertext.

[0064] In a possible implementation manner, the first generating unit is specifically configured to generate an integer p with a length of n bits, where p∈[2 η-1 ,2 η ); determine the p as a private key.

[0065] In a possible implementation, the random number q 0 and the random number q 1 The following conditions are met:

[0066]

[0067] Wherein, p represents the private key;

[0068] Z represents a set of integers.

[0069] In a possible implementation, the random number b 0 and the random number b 1 The following conditions are met:

[0070] b 0 ,b 1 ∈(-2 ρ′ ,2 ρ′ )

[0071] In a possible implementation manner, the third generation unit is specifically configured to calculate the first public key by using the following formula:

[0072] x 0 =pq 0 +Qb 0

[0073] Among them, x 0 represents the first public key;

[0074] p represents the private key;

[0075] Q represents the set plaintext length; and

[0076] The second public key is calculated by the following formula:

[0077] x 1 =pq 1 +Qb 1

[0078] Among them, x 1 represents the second public key;

[0079] x 0 and x 1 The following conditions are met: |x 1 |<|x 0 |.

[0080] In a possible implementation, the encryption unit is specifically used to perform homomorphic encryption calculation on each acquired data to be encrypted by using the following formula to obtain an encrypted ciphertext:

[0081] c i =(mi +Qr i +r i 'x 1 )mod x 0

[0082] Among them, c i represents the ciphertext of the i-th data to be encrypted, i=1~n, n represents the number of data to be encrypted;

[0083] m i Indicates the i-th data to be encrypted;

[0084] Q represents the set plaintext length;

[0085] r i represents a first random number generated for the i-th data to be encrypted;

[0086] r′ i represents a second random number generated for the i-th data to be encrypted;

[0087] r i and r′ i The following conditions are met: i ,r′ i ∈(-2 ρ ,2 ρ );

[0088] x 0 represents the first public key;

[0089] x 1 represents the second public key;

[0090] x 0 and x 1 The following conditions are met: |x 1 |<|x 0 |;

[0091] mod means modular operation.

[0092] In a possible implementation, the method further includes:

[0093] A sending unit, used for sending the encrypted ciphertext of each data to be encrypted and the first public key to a target server, so that the target server performs a homomorphic operation on the encrypted ciphertext of each data to be encrypted according to the first public key to obtain a ciphertext homomorphic operation result;

[0094] A receiving unit, used to receive the ciphertext homomorphic operation result returned by the target server;

[0095] The decryption unit is used to decrypt the ciphertext homomorphic operation result using the private key to obtain the corresponding plaintext homomorphic operation result after decryption.

[0096] In a possible implementation, the decryption unit is specifically used to decrypt the ciphertext homomorphic operation result by using the following formula:

[0097] m=(c mod p)mod Q

[0098] Wherein, m represents the result of the plaintext homomorphic operation;

[0099] c represents the result of the ciphertext homomorphic operation;

[0100] p represents the private key;

[0101] Q represents the set plaintext length;

[0102] Among them, if but like but

[0103] In a third aspect, an embodiment of the present application provides a data transmission method, including:

[0104] Receive N data identification information sent by the target server, determine the target data identification to be queried, encrypt N-1 0s respectively according to the data homomorphic encryption method described in the present application to obtain corresponding N-1 encrypted first ciphertexts, and encrypt 1 to obtain an encrypted second ciphertext;

[0105] Determine N-1 of the first ciphertexts as ciphertexts corresponding to N-1 data identifiers other than the target data identifier, and determine the second ciphertext as the ciphertext corresponding to the target data identifier;

[0106] Sorting each of the first ciphertexts and the second ciphertexts according to the arrangement order of the N data identifiers to generate a ciphertext set;

[0107] Sending a data request to the target server, wherein the data request carries the ciphertext set and the public key, so that the target server sequentially performs a homomorphic operation on the first ciphertext and the second ciphertext in the ciphertext set according to the public key and the data corresponding to the N data identifiers to obtain a ciphertext homomorphic operation result;

[0108] Receive the encrypted homomorphic operation result returned by the target server, use the private key to decrypt the encrypted homomorphic operation result, and obtain the data corresponding to the target data identifier.

[0109] In a fourth aspect, an embodiment of the present application provides a data transmission device, including:

[0110] An encryption unit, used to receive N data identification information sent by a target server, determine the target data identification to be queried, encrypt N-1 0s respectively according to the data homomorphic encryption method described in the present application to obtain corresponding N-1 encrypted first ciphertexts, and encrypt 1 to obtain an encrypted second ciphertext;

[0111] a determination unit, configured to respectively determine the N-1 first ciphertexts as ciphertexts corresponding to the N-1 data identifiers other than the target data identifier, and determine the second ciphertext as the ciphertext corresponding to the target data identifier;

[0112] A generating unit, configured to sort the first ciphertexts and the second ciphertexts according to the arrangement order of the N data identifiers to generate a ciphertext set;

[0113] A sending unit, configured to send a data request to the target server, wherein the data request carries the ciphertext set and the public key, so that the target server performs a homomorphic operation on the first ciphertext and the second ciphertext in the ciphertext set in sequence according to the public key and the data corresponding to the N data identifiers to obtain a ciphertext homomorphic operation result;

[0114] The decryption unit is used to receive the encrypted homomorphic operation result returned by the target server, decrypt the encrypted homomorphic operation result using a private key, and obtain the data corresponding to the target data identifier.

[0115] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the data homomorphic encryption method or the data transmission method described in the present application is implemented.

[0116] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, which, when executed by a processor, implements the steps in the data homomorphic encryption method or the data transmission method described in the present application.

[0117] The beneficial effects of the embodiments of the present application are as follows:

[0118] In the data homomorphic encryption scheme provided in the embodiment of the present application, the data to be encrypted is obtained, the preset security parameters λ, ρ, ρ′, η, γ and the plaintext length are set, where ρ = λ, ρ′ = 2λ, η = O(λ 2 ),γ=O(λ 3 ), the plaintext length is set to be greater than 1 bit, a private key is generated according to the security parameter η, and a random number q is generated according to the private key and the security parameter γ0 and the random number q 1 , and generate a random number b based on the security parameter ρ′ 0 and random number b 1 , according to the private key and random number q 0 , random number b 0 And set the plaintext length to generate the first public key, and according to the private key, random number q 1 , random number b 1 The first public key and the second public key are generated according to the set plaintext length, and for each piece of data to be encrypted, the first random number and the second random number are generated according to the security parameter ρ, and homomorphic encryption calculation is performed according to the set plaintext length, the first public key, the second public key, the first random number, the second random number and the data to be encrypted to obtain the encrypted ciphertext. Compared with the prior art, the public key size is reduced to O(λ 3 ), which is much smaller than the existing public key size (O(λ 10 )), and the plaintext length is greater than 1 bit, which greatly increases the encrypted plaintext space, saves computing resources and improves encryption efficiency.

[0119] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0120] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0121] Figure 1 A schematic diagram of the implementation process of the data homomorphic encryption method provided in the embodiment of the present application;

[0122] Figure 2 A schematic diagram of the structure of a data homomorphic encryption device provided in an embodiment of the present application;

[0123] Figure 3 A schematic diagram of an implementation flow of a data transmission method provided in an embodiment of the present application;

[0124] Figure 4 A schematic diagram of the structure of a data transmission device provided in an embodiment of the present application;

[0125] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0126] In order to solve the problems in the background technology, the embodiments of the present application provide a data homomorphic encryption method and device, and a data transmission method and device.

[0127] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.

[0128] like Figure 1 As shown, it is a schematic diagram of the implementation process of the data homomorphic encryption method provided in the embodiment of the present application, which may specifically include the following steps:

[0129] S11. Obtain data to be encrypted.

[0130] In a specific implementation, the terminal obtains the data to be encrypted, and the size of each data to be encrypted is ∈(0, Q), where Q is a preset plaintext length, and Q is an integer greater than 1 bit in length. It can be set by itself during the specific implementation process, and the embodiment of the present application does not limit this. For example, Q can be, but is not limited to, the value of: 2 8 , 2 16 , 2 32 or 2 64 etc.

[0131] S12. Obtain preset security parameters λ, ρ, ρ′, η, γ and set the plaintext length.

[0132] In specific implementation, ρ=λ, ρ′=2λ, η=O(λ 2 ),γ=O(λ 3 ), for example, assuming λ = 128, then ρ = 128, ρ′ = 256, η = O(128 2 ), γ=O(128 3 ).

[0133] S13. Generate a private key according to the security parameter η.

[0134] In specific implementation, the terminal randomly generates an integer p of length η bits, where p∈[2 η-1 ,2 η ), and determine the integer p as the private key, that is, the private key sk = p.

[0135] S14. Generate a random number q based on the private key and security parameter γ 0 and the random number q 1 , and generate a random number b based on the security parameter ρ′ 0 and random number b 1 .

[0136] In specific implementation, the terminal generates a random number q based on the private key p and the security parameter γ 0 and the random number q 1 , random number q 0 and the random number q 1 The following conditions are met:

[0137]

[0138] Wherein, Z represents a set of integers.

[0139] The terminal generates a random number b based on the security parameter ρ′ 0 and random number b 1 , random number b 0 and the random number b 1 The following conditions are met:

[0140] b 0 ,b 1 ∈(-2 ρ′ ,2 ρ′ )

[0141] S15, based on the private key and random number q 0 , random number b 0 And set the plaintext length to generate the first public key, and according to the private key, random number q 1 , random number b 1 And set the plaintext length to generate the second public key.

[0142] In specific implementation, the terminal can calculate the first public key through the following formula:

[0143] x 0 =pq 0 +Qb 0

[0144] Among them, x 0 represents the first public key;

[0145] p represents the private key;

[0146] Q indicates setting the plaintext length.

[0147] The second public key is calculated by the following formula:

[0148] x 1 =pq 1 +Qb 1

[0149] Among them, x 1 represents the second public key;

[0150] Let x 0 and x 1 The following conditions are met: |x 1|<|x 0 |.

[0151] That is, the public key pk=(x 0 , x 1 ).

[0152] S16. For each piece of data to be encrypted, generate a first random number and a second random number according to the security parameter ρ, and perform homomorphic encryption calculation according to the set plaintext length, the first public key, the second public key, the first random number, the second random number and the data to be encrypted to obtain the encrypted ciphertext.

[0153] In specific implementation, the terminal performs homomorphic encryption calculation for each piece of data to be encrypted using the following formula to obtain the encrypted ciphertext:

[0154] c i =(m i +Qr i +r′ i x 1 )mod x 0

[0155] Among them, c i represents the ciphertext of the i-th data to be encrypted, i=1~n, n represents the number of data to be encrypted;

[0156] m i Indicates the i-th data to be encrypted;

[0157] Q means setting the plaintext length;

[0158] r i represents the first random number generated for the i-th data to be encrypted;

[0159] r i ' represents the second random number generated for the i-th data to be encrypted;

[0160] r i and r′ i The following conditions are met: i ,r i ′∈(-2 ρ ,2 ρ );

[0161] x 0 represents the first public key;

[0162] x 1 represents the second public key;

[0163] x 0 and x 1 The following conditions are met: |x 1 |<|x 0 |;

[0164] mod means modular operation.

[0165] When the terminal needs to interact with the target server for data, the terminal sends the encrypted ciphertext of each data to be encrypted and the first public key to the target server. The target server performs a homomorphic operation on the encrypted ciphertext of each data to be encrypted according to the first public key to obtain a ciphertext homomorphic operation result, and returns the ciphertext homomorphic operation result to the terminal. The terminal receives the ciphertext homomorphic operation result returned by the target server, decrypts the ciphertext homomorphic operation result using the private key, and obtains the corresponding plaintext homomorphic operation result after decryption.

[0166] During specific implementation, the target server can provide application services for the terminal. It can be a cloud computing server or a physical server, which is not limited in the embodiments of the present application.

[0167] The target server receives the encrypted ciphertext c of each encrypted data sent by the terminal. 1 ~c n and the first public key x 0 After that, the ciphertext c 1 ~c n Performing homomorphic addition operations can also be performed on the ciphertext c 1 ~c n Perform multiplication homomorphic operations and also perform operations on the ciphertext c 1 ~c n Performing a mixed homomorphic operation of addition and multiplication, which is not limited in the present embodiment. 1 ~c n When performing addition homomorphic operations, the ciphertext homomorphic operation results are: If the target server has a ciphertext c 1 ~c n When performing multiplication homomorphic operations, the ciphertext homomorphic operation results are:

[0168] The terminal decrypts the ciphertext homomorphic operation result returned by the target server using the following formula:

[0169] m=(c mod p)mod Q

[0170] Among them, m represents the result of the plaintext homomorphic operation;

[0171] c represents the result of the ciphertext homomorphic operation;

[0172] p represents the private key;

[0173] Q means setting the plaintext length;

[0174] Among them, if but like but

[0175] The data homomorphic encryption method provided in the embodiment of the present application, the terminal obtains the data to be encrypted, obtains the preset security parameters λ, ρ, ρ′, η, γ and sets the plaintext length, where ρ = λ, ρ′ = 2λ, η = O(λ 2 ),γ=O(λ 3 ), the plaintext length is set to be greater than 1 bit, a private key is generated according to the security parameter η, and a random number q is generated according to the private key and the security parameter γ 0 and the random number q 1 , and generate a random number b based on the security parameter ρ′ 0 and random number b 1 , according to the private key and random number q 0 , random number b 0 And set the plaintext length to generate the first public key, and according to the private key, random number q 1 , random number b 1 The first public key and the second public key are generated according to the set plaintext length, and for each piece of data to be encrypted, the first random number and the second random number are generated according to the security parameter ρ, and homomorphic encryption calculation is performed according to the set plaintext length, the first public key, the second public key, the first random number, the second random number and the data to be encrypted to obtain the encrypted ciphertext. Compared with the prior art, the public key size is reduced to O(λ 3 ), which is much smaller than the existing public key size (O(λ 10 )), that is, the public key is reduced by an order of magnitude, and the plaintext length is increased to any integer Q greater than 1 bit (2 8 , 2 16 , 2 32 or 2 64 etc.), integers can be operated, which greatly increases the encrypted plaintext space, saves computing resources and improves encryption efficiency.

[0176] Based on the same inventive concept, an embodiment of the present application also provides a data homomorphic encryption device. Since the principle of solving the problem by the above-mentioned data homomorphic encryption device is similar to that of the data homomorphic encryption method, the implementation of the above-mentioned device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0177] like Figure 2 As shown, it is a structural schematic diagram of a data homomorphic encryption device provided in an embodiment of the present application, which may include:

[0178] A first acquisition unit 21, used to acquire data to be encrypted;

[0179] The second acquisition unit 22 is used to acquire preset security parameters λ, ρ, ρ′, η, γ and set the plaintext length, where ρ=λ, ρ′=2λ, η=O(λ 2 ),γ=O(λ 3 ), the set plaintext length is greater than 1 bit;

[0180] A first generating unit 23, configured to generate a private key according to the security parameter n;

[0181] The second generating unit 24 is used to generate a random number q according to the private key and the security parameter γ 0 and the random number q 1 , and generate a random number b according to the security parameter ρ′ 0 and random number b 1 ;

[0182] The third generating unit 25 is used to generate a random number q according to the private key and the random number q 0 , the random number b 0 and the set plaintext length to generate a first public key, and according to the private key and the random number q 1 , the random number b 1 and the set plaintext length to generate a second public key;

[0183] The encryption unit 26 is used to generate a first random number and a second random number according to the security parameter ρ for each acquired data to be encrypted, and perform homomorphic encryption calculation according to the set plaintext length, the first public key, the second public key, the first random number, the second random number and the data to be encrypted to obtain an encrypted ciphertext.

[0184] In a possible implementation manner, the first generating unit 23 is specifically configured to generate an integer p with a length of n bits, where p∈[2 η-1 ,2 η ); determine the p as a private key.

[0185] In a possible implementation, the random number q 0 and the random number q 1 The following conditions are met:

[0186]

[0187] Wherein, p represents the private key;

[0188] Z represents a set of integers.

[0189] In a possible implementation, the random number b 0 and the random number b 1 The following conditions are met:

[0190] b 0 ,b 1 ∈(-2 ρ′ ,2 ρ′ )

[0191] In a possible implementation manner, the third generation unit 25 is specifically configured to calculate the first public key using the following formula:

[0192] x 0 =pq 0 +Qb 0

[0193] Among them, x 0 represents the first public key;

[0194] p represents the private key;

[0195] Q represents the set plaintext length; and

[0196] The second public key is calculated by the following formula:

[0197] x 1 =pq 1 +Qb 1

[0198] Among them, x 1 represents the second public key;

[0199] x 0 and x 1 The following conditions are met: |x 1 |<|x 0 |.

[0200] In a possible implementation, the encryption unit 26 is specifically configured to perform homomorphic encryption calculation on each acquired data to be encrypted by using the following formula to obtain an encrypted ciphertext:

[0201] c i =(m i +Qr i +r′ i x 1 )mod x 0

[0202] Among them, c i represents the ciphertext of the i-th data to be encrypted, i=1~n, n represents the number of data to be encrypted;

[0203] m i Indicates the i-th data to be encrypted;

[0204] Q represents the set plaintext length;

[0205] r i represents a first random number generated for the i-th data to be encrypted;

[0206] r′ i represents a second random number generated for the i-th data to be encrypted;

[0207] r i and r′ i The following conditions are met: i ,r′ i ∈(-2 ρ ,2 ρ );

[0208] x 0 represents the first public key;

[0209] x 1 represents the second public key;

[0210] x 0 and x 1 The following conditions are met: |x 1 |<|x 0 |;

[0211] mod means modular operation.

[0212] In a possible implementation, the method further includes:

[0213] A sending unit, used for sending the encrypted ciphertext of each data to be encrypted and the first public key to a target server, so that the target server performs a homomorphic operation on the encrypted ciphertext of each data to be encrypted according to the first public key to obtain a ciphertext homomorphic operation result;

[0214] A receiving unit, used to receive the ciphertext homomorphic operation result returned by the target server;

[0215] The decryption unit is used to decrypt the ciphertext homomorphic operation result using the private key to obtain the corresponding plaintext homomorphic operation result after decryption.

[0216] In a possible implementation, the decryption unit is specifically used to decrypt the ciphertext homomorphic operation result by using the following formula:

[0217] m=(c mod p)mod Q

[0218] Wherein, m represents the result of the plaintext homomorphic operation;

[0219] c represents the result of the ciphertext homomorphic operation;

[0220] p represents the private key;

[0221] Q represents the set plaintext length;

[0222] Among them, if but like but

[0223] Based on the same inventive concept, an embodiment of the present application also provides a data transmission method. Since the principle of solving the problem by the above-mentioned data transmission method is similar to that of the data homomorphic encryption method, the implementation of the above-mentioned data transmission method can refer to the implementation of the data homomorphic encryption method, and the repeated parts will not be repeated.

[0224] like Figure 3 As shown, it is a schematic diagram of the implementation process of the data transmission method provided in the embodiment of the present application. The data transmission method is applied to an application scenario of data encryption query based on the data homomorphic encryption method provided in the embodiment of the present application, and may include the following steps:

[0225] S31. The target server sends N data identification information to the terminal.

[0226] In a specific implementation, the target server is a service provider, and the corresponding relationship between data identifiers and data is stored in its database. The target server sends N data identification information to the terminal, where N is an integer greater than or equal to 2.

[0227] S32. The terminal determines the target data identification information to be queried, and encrypts N-1 0s respectively according to the data homomorphic encryption method provided in the embodiment of the present application to obtain the corresponding N-1 encrypted first ciphertexts, and encrypts 1 to obtain the encrypted second ciphertext.

[0228] Specifically, the terminal receives N data identification information sent by the target server, determines the target data identification information to be queried, and assumes that the target data identification is k, k∈(1,N). The terminal uses the public key pk=(x 0 , x 1 ) Encrypt N-1 0s and one 1 respectively, encrypt the N-1 0s to obtain the corresponding N-1 encrypted first ciphertexts, and encrypt 1 to obtain an encrypted second ciphertext.

[0229] S33. The terminal determines the N-1 first ciphertexts as the ciphertexts corresponding to the N-1 data identifiers other than the target data identifier, and determines the second ciphertext as the ciphertext corresponding to the target data identifier.

[0230] In specific implementation, the terminal determines the N-1 first ciphertexts as the ciphertexts corresponding to the N-1 data identifiers other than the target data identifier k, and determines the second ciphertext as the ciphertext corresponding to the target data identifier k.

[0231] S34. The terminal sorts the first ciphertexts and the second ciphertexts according to the arrangement order of the N data identifiers to generate a ciphertext set.

[0232] In specific implementation, the sorted ciphertext set is as follows:

[0233] C=(Enc pk,1 (0), Enc pk,2 (0), ..., Enc pk,k (1), ..., Enc pk,N (0))

[0234] Among them, Enc pk,k (1) is the second ciphertext, i.e., the ciphertext corresponding to the target data identifier k; except Enc pk,k (1) External Enc pk,1 (0), Enc pk,2 (0),……,Enc pk,N (0) are all the first ciphertexts, which are the ciphertexts corresponding to data identifiers 1, 2, ..., N (except k).

[0235] S35. The terminal sends a data request to the target server, and the data request carries a ciphertext set and a public key.

[0236] Among them, the public key can send the first public key x 0 .

[0237] S36. The target server performs homomorphic operation on the first ciphertext and the second ciphertext in the ciphertext set in sequence according to the public key and the data corresponding to the N data identifiers to obtain the ciphertext homomorphic operation result.

[0238] In specific implementation, the data corresponding to data identifiers 1 to N are {D 1 ,D 2, ..., D k ,……D N}, the target server performs homomorphic operations through the following formula to obtain the ciphertext homomorphic operation results:

[0239] T=[D 1 *Enc pk,1 (0)+D 2 *Enc pk,2 (0)+…+D k *Enc pk,k (1)+…+D N *Enc pk,N(0)]mod x 0

[0240] Where T represents the result of the ciphertext homomorphic operation.

[0241] S37. The target server sends the encrypted homomorphic operation result to the terminal.

[0242] S38. The terminal uses the private key to decrypt the ciphertext homomorphic operation result to obtain the data corresponding to the target data identifier.

[0243] During specific implementation, the terminal receives the ciphertext homomorphic operation result T returned by the target server, decrypts the ciphertext homomorphic operation result using the private key (sk=p), and obtains the data corresponding to the target data identifier.

[0244] Specifically, the ciphertext homomorphic operation result T is decrypted by the following formula:

[0245] (T mod p) mod Q = D 1 *0+D 2 *0+…+D k *1+…+D N *0=D k

[0246] In this way, the terminal can obtain the data D corresponding to the target data identifier k to be queried k ,During the interaction between the terminal and the target server, the target server can never know what the specific data queried by the terminal is, which further improves the security of data transmission.

[0247] Based on the same inventive concept, an embodiment of the present application also provides a data transmission device. Since the principle of solving the problem by the above-mentioned data transmission device is similar to that of the data transmission method, the implementation of the above-mentioned data transmission device can refer to the implementation of the data transmission method, and the repeated parts will not be repeated.

[0248] like Figure 4 As shown, a schematic diagram of the structure of a data transmission device provided in an embodiment of the present application may include:

[0249] The encryption unit 41 is used to receive N data identification information sent by the target server, determine the target data identification to be queried, encrypt N-1 0s respectively according to the data homomorphic encryption method described in the present application to obtain corresponding N-1 encrypted first ciphertexts, and encrypt 1 to obtain an encrypted second ciphertext;

[0250] A determination unit 42, configured to determine the N-1 first ciphertexts as ciphertexts corresponding to the N-1 data identifiers other than the target data identifier, and determine the second ciphertext as the ciphertext corresponding to the target data identifier;

[0251] A generating unit 43, configured to sort the first ciphertexts and the second ciphertexts according to the arrangement order of the N data identifiers to generate a ciphertext set;

[0252] A sending unit 44 is used to send a data request to the target server, wherein the data request carries the ciphertext set and the public key, so that the target server performs a homomorphic operation on the first ciphertext and the second ciphertext in the ciphertext set in sequence according to the public key and the data corresponding to the N data identifiers to obtain a ciphertext homomorphic operation result;

[0253] The decryption unit 45 is used to receive the encrypted homomorphic operation result returned by the target server, decrypt the encrypted homomorphic operation result using a private key, and obtain the data corresponding to the target data identifier.

[0254] Based on the same technical concept, the embodiment of the present application also provides an electronic device 500, referring to Figure 5 As shown, the electronic device 500 is used to implement the data homomorphic encryption method described in the above method embodiment. The electronic device 500 of this embodiment may include: a memory 501, a processor 502, and a computer program stored in the memory and executable on the processor, such as a data homomorphic encryption program. When the processor executes the computer program, the steps in the above data homomorphic encryption method or data transmission method embodiment are implemented, such as Figure 1 Alternatively, when the processor executes the computer program, the functions of the modules / units in the above-mentioned device embodiments are implemented, for example, 21.

[0255] The specific connection medium between the memory 501 and the processor 502 is not limited in the embodiment of the present application. Figure 5 In the embodiment, the memory 501 and the processor 502 are connected via a bus 503. The bus 503 is connected to the processor 502 via a bus 503. Figure 5 The connection between other components is shown by bold lines, which is only for schematic illustration and is not intended to be limiting. The bus 503 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0256] The memory 501 may be a volatile memory, such as a random-access memory (RAM); the memory 501 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 501 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 501 may be a combination of the above memories.

[0257] Processor 502, used to implement Figure 1 A data homomorphic encryption method as shown or as Figure 3 The data transmission method shown.

[0258] An embodiment of the present application also provides a computer-readable storage medium that stores computer-executable instructions required to execute the above-mentioned processor, which includes a program required to execute the above-mentioned processor.

[0259] In some possible implementations, various aspects of the data homomorphic encryption method or data transmission method provided by the present application may also be implemented in the form of a program product, which includes a program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the data homomorphic encryption method or data transmission method according to various exemplary implementations of the present application described above in this specification.

[0260] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0261] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (apparatus), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0262] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0263] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0264] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0265] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A data homomorphic encryption method, characterized in that: include: Obtain the data to be encrypted; Get the preset safety parameters λ, ρ, ρ ′ , η, γ and set the plaintext length, where ρ = λ, ρ ′ =2λ,η=O(λ 2 ),γ=O(λ 3 ), the set plaintext length is greater than 1 bit, the security parameter η is used to constrain the length of the private key, and the security parameter γ is used to constrain the length of the public key; Generate a private key according to the security parameter n; Generate a random number q0 and a random number q1 according to the private key and the security parameter γ, and ′ Generate random numbers b0 and b1; Generate a first public key according to the private key, the random number q0, the random number b0 and the set plaintext length, and generate a second public key according to the private key, the random number q1, the random number b1 and the set plaintext length; For each acquired data to be encrypted, generate a first random number and a second random number according to the security parameter ρ, and perform homomorphic encryption calculation according to the set plaintext length, the first public key, the second public key, the first random number, the second random number, and the data to be encrypted to obtain an encrypted ciphertext; The step of generating a first public key according to the private key, the random number q0, the random number b0 and the set plaintext length specifically includes: The first public key is calculated by the following formula: x0=pq0+Qb0 Wherein, x0 represents the first public key; p represents the private key; Q represents the set plaintext length; and Generating a second public key according to the private key, the random number q1, the random number b1 and the set plaintext length specifically includes: The second public key is calculated by the following formula: x1=pq1+Qb1 Wherein, x1 represents the second public key; x0 and x1 satisfy the following condition: |x1|<|x0|.

2. The method according to claim 1, characterized in that Generating a private key according to the security parameter n specifically includes: Generate an integer p of length η bits, where p∈[2 η-1 ,2 η ); The p is determined to be a private key.

3. The method according to claim 2, characterized in that The random number q0 and the random number q1 satisfy the following conditions: Wherein, p represents the private key; Z represents a set of integers.

4. The method according to claim 3, characterized in that The random number b0 and the random number b1 satisfy the following conditions: b0,b1∈(-2 ρ ′,2 ρ ′).

5. The method according to claim 1, characterized in that For each piece of data to be encrypted, the following formula is used to perform homomorphic encryption calculation to obtain the encrypted ciphertext: c i =(m i +Qr i +r i ′ x1)mod x0 Among them, c i represents the ciphertext of the i-th data to be encrypted, i=1, 2, 3, ..., n, n represents the number of data to be encrypted; m i Indicates the i-th data to be encrypted; Q represents the set plaintext length; r i represents a first random number generated for the i-th data to be encrypted; r i ′ represents a second random number generated for the i-th data to be encrypted; r i and r i ′ The following conditions are met: i ,r i ′ ∈(-2 ρ ,2 ρ ); x0 represents the first public key; x1 represents the second public key; x0 and x1 satisfy the following condition: |x1|<|x0|; mod means modular operation.

6. The method according to claim 5, characterized in that Also includes: Sending the encrypted ciphertext of each data to be encrypted and the first public key to the target server, so that the target server performs a homomorphic operation on the encrypted ciphertext of each data to be encrypted according to the first public key to obtain a ciphertext homomorphic operation result; Receiving the ciphertext homomorphic operation result returned by the target server; The ciphertext homomorphic operation result is decrypted using the private key to obtain the decrypted corresponding plaintext homomorphic operation result.

7. The method according to claim 6, characterized in that Decrypting the ciphertext homomorphic operation result using the private key to obtain the decrypted corresponding plaintext homomorphic operation result, specifically including: The ciphertext homomorphic operation result is decrypted by the following formula: m=(c mod p)mod Q Wherein, m represents the result of the plaintext homomorphic operation; c represents the result of the ciphertext homomorphic operation; p represents the private key; Q represents the set plaintext length; Among them, if but like but 8. A data transmission method, characterized in that: include: Receive N data identification information sent by the target server, determine the target data identification to be queried, encrypt N-1 0s respectively according to the data homomorphic encryption method according to any one of claims 1 to 7 to obtain corresponding N-1 encrypted first ciphertexts, and encrypt 1 to obtain an encrypted second ciphertext; Determine N-1 of the first ciphertexts as ciphertexts corresponding to N-1 data identifiers other than the target data identifier, and determine the second ciphertext as the ciphertext corresponding to the target data identifier; Sorting each of the first ciphertexts and the second ciphertexts according to the arrangement order of the N data identifiers to generate a ciphertext set; Sending a data request to the target server, wherein the data request carries the ciphertext set and the public key, so that the target server sequentially performs a homomorphic operation on the first ciphertext and the second ciphertext in the ciphertext set according to the public key and the data corresponding to the N data identifiers to obtain a ciphertext homomorphic operation result; Receive the encrypted homomorphic operation result returned by the target server, use the private key to decrypt the encrypted homomorphic operation result, and obtain the data corresponding to the target data identifier.

9. A data homomorphic encryption device, characterized in that: include: A first acquisition unit, used to acquire data to be encrypted; The second acquisition unit is used to obtain the preset safety parameters λ, ρ, ρ ′ , η, γ and set the plaintext length, where ρ = λ, ρ ′ =2λ,η=O(λ 2 ),γ=O(λ 3 ), the set plaintext length is greater than 1 bit, the security parameter η is used to constrain the length of the private key, and the security parameter γ is used to constrain the length of the public key; A first generating unit, configured to generate a private key according to the security parameter n; The second generating unit is configured to generate a random number q0 and a random number q1 according to the private key and the security parameter γ, and ′ Generate random numbers b0 and b1; a third generating unit, configured to generate a first public key according to the private key, the random number q0, the random number b0 and the set plaintext length, and to generate a second public key according to the private key, the random number q1, the random number b1 and the set plaintext length; an encryption unit, configured to generate a first random number and a second random number according to the security parameter ρ for each acquired data to be encrypted, and perform homomorphic encryption calculation according to the set plaintext length, the first public key, the second public key, the first random number, the second random number and the data to be encrypted to obtain an encrypted ciphertext; The third generation unit is specifically configured to calculate the first public key using the following formula: x0=pq0+Qb0 Wherein, x0 represents the first public key; p represents the private key; Q represents the set plaintext length; and The second public key is calculated by the following formula: x1=pq1+Qb1 Wherein, x1 represents the second public key; x0 and x1 satisfy the following condition: |x1|<|x0|.

10. The device according to claim 9, characterized in that The first generating unit is specifically used to generate an integer p with a length of n bits, where p∈[2 η-1 ,2 η ); determine the p as a private key.

11. The device according to claim 10, characterized in that The random number q0 and the random number q1 satisfy the following conditions: Wherein, p represents the private key; Z represents a set of integers.

12. The device according to claim 11, characterized in that The random number b0 and the random number b1 satisfy the following conditions: b0,b1∈(-2 ρ ′,2 ρ ′).

13. The device according to claim 9, characterized in that The encryption unit is specifically used to perform homomorphic encryption calculation on each acquired data to be encrypted by using the following formula to obtain the encrypted ciphertext: c i =(m i +Qr i +r i ′ x1)mod x0 Among them, c i represents the ciphertext of the i-th data to be encrypted, i=1, 2, 3, ..., n, n represents the number of data to be encrypted; m i Indicates the i-th data to be encrypted; Q represents the set plaintext length; r i represents a first random number generated for the i-th data to be encrypted; r i ′ represents a second random number generated for the i-th data to be encrypted; r i and r i ′ The following conditions are met: i ,r i ′ ∈(-2 ρ ,2 ρ ); x0 represents the first public key; x1 represents the second public key; x0 and x1 satisfy the following condition: |x1|<|x0|; mod means modular operation.

14. The device according to claim 13, characterized in that Also includes: A sending unit, used for sending the encrypted ciphertext of each data to be encrypted and the first public key to a target server, so that the target server performs a homomorphic operation on the encrypted ciphertext of each data to be encrypted according to the first public key to obtain a ciphertext homomorphic operation result; A receiving unit, used to receive the ciphertext homomorphic operation result returned by the target server; The decryption unit is used to decrypt the ciphertext homomorphic operation result using the private key to obtain the corresponding plaintext homomorphic operation result after decryption.

15. The device according to claim 14, characterized in that The decryption unit is specifically used to decrypt the ciphertext homomorphic operation result by the following formula: m=(c mod p)mod Q Wherein, m represents the result of the plaintext homomorphic operation; c represents the result of the ciphertext homomorphic operation; p represents the private key; Q represents the set plaintext length; Among them, if but like but 16. A data transmission device, characterized in that: include: An encryption unit, used to receive N data identification information sent by a target server, determine the target data identification to be queried, encrypt N-1 0s respectively according to the data homomorphic encryption method according to any one of claims 1 to 7 to obtain corresponding N-1 encrypted first ciphertexts, and encrypt 1 to obtain an encrypted second ciphertext; a determination unit, configured to respectively determine the N-1 first ciphertexts as ciphertexts corresponding to the N-1 data identifiers other than the target data identifier, and determine the second ciphertext as the ciphertext corresponding to the target data identifier; A generating unit, configured to sort the first ciphertexts and the second ciphertexts according to the arrangement order of the N data identifiers to generate a ciphertext set; A sending unit, configured to send a data request to the target server, wherein the data request carries the ciphertext set and the public key, so that the target server performs a homomorphic operation on the first ciphertext and the second ciphertext in the ciphertext set in sequence according to the public key and the data corresponding to the N data identifiers to obtain a ciphertext homomorphic operation result; The decryption unit is used to receive the encrypted homomorphic operation result returned by the target server, decrypt the encrypted homomorphic operation result using a private key, and obtain the data corresponding to the target data identifier.

17. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, it implements the data homomorphic encryption method according to any one of claims 1 to 7 or the data transmission method according to claim 8.

18. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps in the data homomorphic encryption method as described in any one of claims 1 to 7 or the data transmission method as described in claim 8 are implemented.

Citation Information

Patent Citations

  • Many-to-one homomorphic encryption public key compression method on integer

    CN111585743A

  • N-time public key compression method for integer homomorphic encryption

    CN113114461A