Homomorphic encryption method, device, medium and computer program product

By performing preset division decomposition and exponentiation on plaintext scalars, the efficiency of ciphertext multiplication operations in homomorphic encryption is improved, and the application problem of homomorphic encryption in scenarios with high timeliness requirements is solved.

CN113794548BActive Publication Date: 2024-11-08WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111071870.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-13
Publication Date
2024-11-08
Estimated Expiration
2041-09-13

AI Technical Summary

Technical Problem

The efficiency of cipher text multiplication operation under homomorphic encryption is too low, which makes it impossible to apply to scenarios with high timeliness requirements.

Method used

By performing preset division decomposition of plain text scalars, a digital sequence is obtained, and the ciphertext data and digital sequence are exponentiated to improve the efficiency of ciphertext multiplication.

Benefits of technology

Improves the applicability of homomorphic encryption, allowing it to be applied to scenarios with timeliness or high performance requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113794548B_ABST
    Figure CN113794548B_ABST
Patent Text Reader

Abstract

The present application discloses a homomorphic encryption method, device, medium and computer program product, which are applied to a first device, wherein the homomorphic encryption method comprises: obtaining a plaintext scalar to be sent by the first device, and obtaining ciphertext data for performing a multiplication operation with the plaintext scalar, wherein the ciphertext data is data for homomorphically encrypting the plaintext scalar; performing a preset base decomposition on each plaintext element in the plaintext scalar to obtain a digit sequence corresponding to each plaintext element, wherein one digit sequence corresponds to one plaintext element, and one digit sequence includes several digits of the preset base; performing a power operation on the ciphertext data as the base of the power operation and each digit sequence as the exponent of the power operation to obtain a homomorphic encryption result, and sending the homomorphic encryption result to a second device. The present application improves the efficiency of ciphertext multiplication operations under homomorphic encryption, thereby improving the applicability of homomorphic encryption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology of financial technology (Fintech), and in particular to a homomorphic encryption method, device, medium and computer program product. Background Art

[0002] With the rapid development of financial technology and Internet technology, more and more technologies (such as distributed, big data, artificial intelligence, blockchain, etc.) are applied in the financial field to realize various data processing and business processing.

[0003] Homomorphic encryption is a widely used cryptographic tool that can perform multiplication operations in the ciphertext state. However, when performing multiplication operations on ciphertext data and plaintext data, since the ciphertext data and plaintext data are usually large integers (i.e., the number of bits is large), a large number of modular exponentiation operations are required, which leads to low efficiency of ciphertext multiplication operations under homomorphic encryption, and thus makes homomorphic encryption unable to be applied in scenarios with high timeliness requirements. Therefore, how to improve the efficiency of ciphertext multiplication operations under homomorphic encryption to improve the applicability of homomorphic encryption is a problem that needs to be solved urgently. Summary of the invention

[0004] The main purpose of this application is to provide a homomorphic encryption method, device, medium and computer program product, aiming to solve the technical problem of low efficiency of ciphertext multiplication operations under homomorphic encryption, thereby improving the applicability of homomorphic encryption.

[0005] To achieve the above object, the present application provides a homomorphic encryption method, which is applied to a first device, and the homomorphic encryption method includes the following steps:

[0006] Obtaining a plaintext scalar to be sent by the first device, and obtaining ciphertext data to be multiplied by the plaintext scalar, wherein the ciphertext data is data homomorphically encrypted on the plaintext scalar;

[0007] Decomposing each plaintext element in the plaintext scalar in a preset base to obtain a digit sequence corresponding to each plaintext element, wherein one digit sequence corresponds to one plaintext element, and one digit sequence includes a number of digits in the preset base;

[0008] Perform a power operation on the ciphertext data as a power operation base and each of the digital sequences as a power operation exponent to obtain a homomorphic encryption result, and send the homomorphic encryption result to the second device.

[0009] Optionally, the step of performing a power operation on the ciphertext data as a power operation base and each of the digit sequences as power operation exponents to obtain a homomorphic encryption result includes:

[0010] Using the ciphertext data as a base for power calculation and using a number of digits in the digit sequence as exponents for power calculation;

[0011] Performing a power operation based on the power operation base and the power operation exponents to obtain a plurality of first power operation results;

[0012] Performing a multiplication operation on the plurality of first power operation results to obtain a multiplication operation result corresponding to the plaintext element;

[0013] Returning to the step of using a number of digits in the digit sequence as exponents of the power operation, until all digits in the digit sequence are subjected to the power operation;

[0014] Based on the multiplication results corresponding to each of the plaintext elements, the homomorphic encryption results corresponding to the ciphertext data and the plaintext scalar are determined.

[0015] Optionally, the step of performing a power operation based on the power operation base and the power operation exponents to obtain a plurality of first power operation results includes:

[0016] Based on the power operation base and the power operation exponents, a plurality of pre-stored power operation results are obtained, wherein the pre-stored power operation results are a plurality of first power operation results obtained by performing power operation based on the power operation base and the power operation exponents.

[0017] Optionally, the preset base is binary, and the step of performing a power operation based on the power operation base and the power operation exponents to obtain a plurality of first power operation results comprises:

[0018] Compare the number of the exponentiation exponents with the number of binary bits of a current plaintext element, where the current plaintext element is the plaintext element corresponding to the exponentiation exponents;

[0019] If half of the number of binary bit digits is less than the number, a pre-stored maximum power operation result is determined based on the power operation base and the number of binary bit digits, and a number of pre-stored zero-bit power operation results are determined based on the binary number of the current plaintext element, the zero-bit power operation result is a power operation result corresponding to a bit number of zero in the binary number, the power operation base of the zero-bit power operation result is the ciphertext data, and the power operation exponent of the zero-bit power operation result is a negative number of the number of binary digits corresponding to a bit number of zero in the binary number;

[0020] The maximum power operation result and the several zero-bit power operation results are used as several first power operation results obtained by performing power operation based on the power operation base and the several power operation exponents.

[0021] Optionally, before the step of performing a power operation on the ciphertext data as the power operation base and each of the digital sequences as the power operation exponents to obtain a homomorphic encryption result, the step further includes:

[0022] Decomposing the maximum value of the plaintext scalar in a preset base to obtain a corresponding maximum value digit sequence, wherein the maximum value of the plaintext scalar is determined by the number of bits of the plaintext scalar;

[0023] Performing a power operation based on the ciphertext data as a power operation base and the maximum value digit sequence as a power operation exponent to obtain a plurality of second power operation results;

[0024] The plurality of second exponentiation results are stored for performing exponentiation on the ciphertext data as a base of exponentiation and each of the digit sequences as exponents of exponentiation based on the plurality of second exponentiation results.

[0025] Optionally, the step of performing a power operation based on the ciphertext data as a power operation base and the maximum value digit sequence as a power operation exponent to obtain a plurality of second power operation results comprises:

[0026] Based on the order of the digits in the maximum value digit sequence from small to large, determining the current digit in the maximum value digit sequence to be subjected to the power operation, and the power operation result corresponding to the minimum digit in the maximum value digit sequence is the ciphertext data;

[0027] The power operation result corresponding to the previous digit is multiplied by itself by a preset number of times to obtain the power operation result corresponding to the current digit, wherein the previous digit is a digit before the current digit in a maximum value digit sequence sorted from small to large, and the preset number of times is determined by the preset base;

[0028] Returning to the step of determining the current digit to be subjected to exponentiation in the maximum value digit sequence based on the order of the digits in the maximum value digit sequence from small to large, until all digits in the maximum value digit sequence obtain corresponding exponentiation results;

[0029] Based on the power operation results corresponding to the current digits, a plurality of second power operation results are determined, which are obtained by performing power operation on the ciphertext data as the power operation base and the maximum value digit sequence as the power operation exponent.

[0030] Optionally, the first device is a device participating in federated learning, and the step of obtaining a plaintext scalar to be sent by the first device and obtaining ciphertext data to be multiplied by the plaintext scalar includes:

[0031] Receive ciphertext data sent by a second device participating in federated learning, and obtain a plaintext scalar to be sent by the first device, so as to perform a multiplication operation on the plaintext scalar and the ciphertext data.

[0032] In addition, to achieve the above-mentioned purpose, the present application also provides a homomorphic encryption device, which includes: a memory, a processor, and a homomorphic encryption program stored in the memory and executable on the processor, and when the homomorphic encryption program is executed by the processor, the steps of the homomorphic encryption method as described above are implemented.

[0033] In addition, to achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which a homomorphic encryption program is stored, and when the homomorphic encryption program is executed by a processor, the steps of the homomorphic encryption method as described above are implemented.

[0034] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the homomorphic encryption method as described above are implemented.

[0035] The present application provides a homomorphic encryption method, device, medium and computer program product, which obtains a plaintext scalar to be sent by a first device and obtains ciphertext data to be multiplied by the plaintext scalar. Since the ciphertext data is data homomorphically encrypted with the plaintext scalar, the ciphertext data and the plaintext scalar can be directly multiplied, that is, the ciphertext can be directly processed, and the result of the multiplication operation is also the encryption result; then, each plaintext element in the plaintext scalar is decomposed into a preset base to obtain a digit sequence corresponding to each plaintext element, one digit sequence corresponds to one plaintext element, and one digit sequence includes a number of digits in the preset base; finally, Afterwards, a power operation is performed on the ciphertext data serving as the base of the power operation and each digit sequence serving as the power operation exponent to obtain a homomorphic encryption result, and the homomorphic encryption result is sent to the second device. Compared with the prior art that directly uses plaintext elements as power operation exponents to perform power operation, the present application decomposes the plaintext elements into a preset base, which can make the number of digits serving as power operation exponents smaller than the original plaintext elements serving as power operation exponents, thereby reducing the computational complexity, and further improving the efficiency of ciphertext multiplication operations under homomorphic encryption, so that homomorphic encryption can be applied to application scenarios with high timeliness requirements or high performance requirements, thereby improving the applicability of homomorphic encryption. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A schematic diagram of the terminal structure of the hardware operating environment involved in the embodiment of the present application;

[0037] Figure 2 This is a flowchart of the first embodiment of the homomorphic encryption method of the present application;

[0038] Figure 3 This is a flow chart of the second embodiment of the homomorphic encryption method of the present application.

[0039] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0040] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0041] Reference Figure 1 , Figure 1 This is a schematic diagram of the terminal structure of the hardware operating environment involved in the embodiment of the present application.

[0042] The terminal in the embodiment of the present application is a homomorphic encryption device, which can be a terminal device with processing functions such as a PC (personal computer), a microcomputer, a laptop computer, a server, etc.

[0043] like Figure 1 As shown, the terminal may include: a processor 1001, such as a CPU (Central Processing Unit), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0044] Those skilled in the art will understand that Figure 1 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0045] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a homomorphic encryption program.

[0046] exist Figure 1In the terminal shown, the processor 1001 can be used to call the homomorphic encryption program stored in the memory 1005 and execute the steps in the homomorphic encryption method provided in the following embodiments of the present application.

[0047] Based on the above hardware structure, various embodiments of the homomorphic encryption method of the present application are proposed.

[0048] The present application provides a homomorphic encryption method.

[0049] Reference Figure 2 , Figure 2 This is a flowchart of the first embodiment of the homomorphic encryption method of the present application.

[0050] In this embodiment, the homomorphic encryption method is applied to a first device, and the homomorphic encryption method includes:

[0051] Step S10, obtaining a plaintext scalar to be sent by the first device, and obtaining ciphertext data for multiplication operation with the plaintext scalar, wherein the ciphertext data is data for homomorphically encrypting the plaintext scalar;

[0052] In this embodiment, the homomorphic encryption method is applied to the scenario of homomorphic encryption. Furthermore, it can be applied to the encryption process, secure computing or privacy computing under federated learning, or to privacy computing under non-federated learning, without specific limitation here. Among them, the homomorphic encryption algorithm can be the Paillier algorithm, that is, an additive homomorphic algorithm; the homomorphic encryption algorithm can also be the Gentry algorithm, that is, a fully homomorphic algorithm (including additive homomorphic and multiplicative homomorphic algorithms); of course, the homomorphic encryption algorithm can also be other homomorphic encryption algorithms, and the Paillier algorithm is used as an example for explanation in this embodiment and the following embodiments.

[0053] Specifically, the homomorphic encryption method can be applied to interactive scenarios with high privacy requirements or large data volumes, such as image recognition, text recognition, and speech recognition. In other words, the plaintext scalar can be image data, text data, speech data, etc. Of course, the application scenarios of the homomorphic encryption method are not limited, and can be applied to any interactive scenario, thereby improving the performance of homomorphic encryption in various scenarios.

[0054] Furthermore, the homomorphic encryption method can be applied to a federated learning scenario for building an image recognition model, or to a federated learning scenario for building a text recognition model, or to a federated learning scenario for building a speech recognition model, or to a federated learning scenario for other recognition models or prediction models. In other words, the plaintext scalar can be an intermediate parameter corresponding to federated learning. Specifically, refer to the fourth embodiment below, which will not be described one by one here.

[0055] It should be noted that the plaintext scalar is the data that the first device needs to encrypt and send, and the ciphertext data can be the ciphertext sent by other parties (it can be the ciphertext obtained by other parties using homomorphic encryption, or it can be a key or key-related parameters) or the first device's own key for homomorphic encryption.

[0056] In one embodiment, the homomorphic encryption method is applied to a first device participating in federated learning, and the step S10 includes:

[0057] Receive the ciphertext data of the second device participating in federated learning, and obtain the plaintext scalar that needs to be multiplied, and the ciphertext data is the data that is multiplied with the plaintext scalar. Among them, the first device participating in federated learning can be a participant in federated learning, that is, a data party (data provider or data application party) or a collaborator (coordinator). Correspondingly, the second device participating in federated learning can also be a participant in federated learning, that is, a data party (data provider or data application party) or a collaborator (coordinator). For example, the first device acts as a data application party and the second device acts as a data provider. First, the second device homomorphically encrypts its own data to obtain ciphertext data. Then, the second device sends the ciphertext data to the first device so that the first device can receive the ciphertext data of the second device. Finally, the first device multiplies the ciphertext data with its own plaintext data to obtain the ciphertext multiplication result. It can be understood that the result obtained by the operation of the ciphertext data and the plaintext data is also encrypted data, that is, the ciphertext multiplication result is also ciphertext. Of course, the first device can also perform homomorphic encryption on the ciphertext multiplication result.

[0058] It should be noted that the ciphertext data of the second device is the ciphertext obtained by homomorphically encrypting its own plaintext data. In addition, the multiplication operation of ciphertext data and plaintext scalar is called scalar homomorphism, that is, multiplying a plaintext by a ciphertext still results in a ciphertext. For example, the first device is Party A and the second device is Party B. Party B's data can be sent to Party A because Party B's data is ciphertext and there is no risk in sending it to Party A. Party A will calculate the data, and because the result is still ciphertext, Party A can safely send it to Party B because both parties hold the public key and cannot decrypt the data. Of course, a coordinating party C can be added on the basis of Party A and Party B to perform logistic regression operations.

[0059] In another embodiment, the homomorphic encryption method is applied to a first device participating in federated learning, and the step S10 includes:

[0060] Obtain the ciphertext data and plaintext scalar that need to be multiplied, where the ciphertext data is a homomorphically encrypted public key. It should be noted that when the ciphertext data is a homomorphically encrypted public key, the current multiplication operation is to homomorphically encrypt the plaintext scalar, thereby obtaining the ciphertext corresponding to the plaintext scalar. For example, the first device is a data provider, and the first device uses the public key to homomorphically encrypt its own plaintext scalar, that is, to perform a modular exponentiation operation equivalent to the multiplication operation, thereby obtaining the ciphertext corresponding to the plaintext scalar. The modulus of the modular exponentiation operation can also be a homomorphically encrypted public key. Finally, the first device will send the ciphertext to another participant in federated learning.

[0061] In this embodiment, the plaintext scalar to be sent by the first device is obtained, and the ciphertext data to be multiplied by the plaintext scalar is obtained, and the ciphertext data is the data homomorphically encrypted on the plaintext scalar. The ciphertext data can be the ciphertext obtained after homomorphic encryption; it can also be the public key for homomorphic encryption, or it can be the key parameters related to homomorphic encryption.

[0062] It should be noted that the ciphertext multiplication operation (ciphertext multiplication operation) under homomorphic encryption is the multiplication of plaintext data and ciphertext data, which is equivalent to modular exponentiation, that is, the plaintext can be used as a power exponent to perform a power operation. Specifically, refer to the following formula:

[0063] d*b≡d b mod m;

[0064] Among them, d is the ciphertext data, b is the plaintext data, ≡ is the equivalent symbol, mod represents the modulus operation, and m is the modulus, which can be the key data generated in the homomorphic encryption process.

[0065] In addition, it should be noted that for modular operations, the result of repeated modular operations remains unchanged. Therefore, if the ciphertext data is the data obtained by modular exponentiation, the ciphertext multiplication operation under homomorphic encryption can be equivalent to a power operation, that is, the ciphertext data is directly used as the base of the power operation, and the plaintext elements in the plaintext scalar are used as the exponent of the power operation to perform the power operation. Specifically, refer to the following formula:

[0066] d*b≡d b ;

[0067] Among them, d is the ciphertext data, b is the plaintext data, and ≡ is the equivalent symbol.

[0068] In this embodiment, the ciphertext data is a ciphertext element. If in other embodiments, the ciphertext data is a scalar, each ciphertext element in the ciphertext data is individually multiplied by the plaintext scalar to obtain the multiplication result corresponding to each ciphertext element. The scalar of the ciphertext data or the plaintext scalar includes a one-dimensional vector form, a two-dimensional matrix form, or a higher-dimensional scalar form.

[0069] In one embodiment, after the above step S10, the homomorphic encryption method further includes:

[0070] If the plaintext scalar is a plaintext matrix, the plaintext matrix is ​​converted into a plaintext array so that the plaintext scalar is a plaintext array. It can be understood that converting the plaintext matrix into a plaintext array can improve the efficiency of multiplication operations.

[0071] Correspondingly, after the following step S30, the homomorphic encryption method further includes:

[0072] The multiplication result is converted into a matrix result. It should be noted that the process of converting the multiplication result into a matrix form corresponds to the process of converting the plaintext matrix into a plaintext array, which will not be described in detail here.

[0073] In some embodiments, after the above step S10, the homomorphic encryption method further includes:

[0074] If there is a floating point number in each plaintext element in the plaintext scalar, the floating point number is fixed-pointed so that each plaintext element in the plaintext scalar is a fixed-point number. In other words, integers are used to simulate floating point numbers, and floating point numbers are fixed-pointed to obtain fixed-point numbers, thereby improving the efficiency of ciphertext multiplication operations. Of course, both floating point numbers and integers can also be fixed-pointed, that is, each plaintext element is fixed-pointed. Subsequently, it is only necessary to perform corresponding inverse fixed-pointing on the multiplication operation results.

[0075] Step S20, decomposing each plaintext element in the plaintext scalar in a preset base to obtain a digit sequence corresponding to each plaintext element, wherein one digit sequence corresponds to one plaintext element, and one digit sequence includes a number of digits in the preset base;

[0076] In this embodiment, each plaintext element in the plaintext scalar is decomposed into a preset base to obtain a digit sequence corresponding to each plaintext element, one digit sequence corresponds to one plaintext element, and one digit sequence includes a plurality of digits in the preset base. A plaintext scalar includes a plurality of plaintext elements, and the plurality of plaintext elements include one or more plaintext elements. The plurality of digits in the preset base include one or more digits.

[0077] It should be noted that the preset base may include binary, octal or hexadecimal, etc. To further improve the efficiency of multiplication operations, the preset base may be set to binary to match the calculation base of the current computing device. Of course, it may also be set to other higher power bases, which is also convenient for the computing device to process.

[0078] In one embodiment, the above step S20 includes:

[0079] Decomposing each plaintext element in the plaintext scalar in binary form to obtain a binary digit sequence corresponding to each plaintext element, wherein one binary digit sequence corresponds to one plaintext element, and one binary digit sequence includes a plurality of binary digits, wherein the plurality of binary digits includes one or more digits.

[0080] It should be noted that a plaintext element in a plaintext scalar can be regarded as a group of binary numbers, that is, a binary digit sequence. For example, if the plaintext element is 7, then 7=1+2+4=2^0+2^1+2^2; if the plaintext element is 19, then 19=16+2+1=2^4+2^1+2^0.

[0081] In addition, it should be noted that the relationship between the digits in the digit sequence is an additive relationship. For example, if the digit sequence is {2^0, 2^1, 2^2}, then the result of adding the digits in the digit sequence is 2^0+2^1+2^2=1+2+4=7. In other words, each plaintext element is decomposed into the result of adding binary digits. Specifically, the plaintext element b is:

[0082]

[0083] Among them, i represents the position of the current bit, n represents the number of bits of plaintext element b, and b i The value of b is 1 or 0. i The value of 1 means the corresponding bit number is 1. i A value of 0 means the corresponding number of bits is 0.

[0084] It can be understood that the execution process of the decomposition of higher powers is basically the same as that of the binary decomposition, and will not be repeated here. For example, when the default base is octal, the plaintext element b is:

[0085]

[0086] Among them, i represents the position of the current bit, n represents the number of bits of plaintext element b, and b i The value of b is 1 or 0. i The value of 1 indicates that the corresponding bit number is non-zero. i A value of 0 means the corresponding number of bits is 0.

[0087] Step S30, performing a power operation on the ciphertext data as the base of the power operation and each of the digital sequences as the exponent of the power operation to obtain a homomorphic encryption result, and sending the homomorphic encryption result to the second device.

[0088] In this embodiment, the ciphertext data as the base of the power operation and each digital sequence as the exponent of the power operation are subjected to power operation to obtain a homomorphic encryption result, and the homomorphic encryption result is sent to the second device. It should be noted that, through the above analysis of homomorphic encryption, it can be seen that the ciphertext multiplication operation under the homomorphic encryption secret state can be equivalent to a power operation, that is, the ciphertext data is directly used as the base of the power operation, and the plaintext elements in the plaintext scalar are used as the power operation exponent to perform the power operation. Specifically, refer to the following formula:

[0089] d*b≡d b ;

[0090] Where d is the ciphertext data, b is the plaintext data, and ≡ is the equivalent symbol. Based on this, the ciphertext data as the base of the power operation and each digit sequence as the exponent of the power operation are subjected to power operation, and the multiplication result (i.e., the homomorphic encryption result) can be obtained. The multiplication result (i.e., the homomorphic encryption result) includes the multiplication result of each plaintext element in the plaintext scalar and the ciphertext data.

[0091] For ease of understanding, the preset base system is binary as an example for explanation, and the plaintext element b is:

[0092]

[0093] Among them, i represents the position of the current bit, n represents the number of bits of plaintext element b, and b i The value of b is 1 or 0. i The value of 1 means the corresponding bit number is 1. i The value of 0 represents that the corresponding bit number is 0. Based on this, the result of the multiplication operation can be converted into the product of the results of each power operation. Specifically, refer to the following formula:

[0094]

[0095] Among them, d is the ciphertext data, b is the plaintext data, i represents the position of the current bit in the plaintext element b, n represents the number of bits of the plaintext element b, and b i The value of b is 1 or 0. i The value of 1 means the corresponding bit number is 1. i The value of 0 means that the corresponding bit number is 0. For example, the number of bits n of the plaintext element b is 53 bits, refer to the following formula:

[0096]

[0097] Specifically, based on the above derivation formula for performing power operation, it can be known that performing power operation on the ciphertext data as the power operation base and each digital sequence as the power operation exponent can be converted into power operation and multiplication operation. That is, the above step S30 includes: performing power operation and multiplication operation on the ciphertext data as the power operation base and each digital sequence as the power operation exponent to obtain a multiplication operation result. The specific execution process can refer to the second embodiment described below, which will not be repeated here.

[0098] It should be noted that the number of binary digits of the ciphertext data used as the base of the power operation and the plaintext element used as the exponent of the power operation is often relatively large, such as 1024 bits and 2048 bits. Therefore, the benefit of this embodiment for improving the efficiency of ciphertext multiplication operation is relatively large and has practical value. Based on this, the larger the number of binary digits of the ciphertext data or the plaintext element, the greater the benefit of this embodiment for improving the efficiency of ciphertext multiplication operation.

[0099] It can be understood that the ciphertext data used as the base of the power operation and each digit sequence used as the power operation exponent are subjected to power operation. Since the number of digits in the digit sequence used as the power operation exponent is smaller than the plaintext element used as the power operation exponent, the computational complexity of the ciphertext multiplication operation can be reduced. Specifically, if the plaintext element is set to n, the computational complexity of directly using the plaintext element as the power operation exponent for power operation is n, that is, n multiplications are performed, while the computational complexity of using each digit sequence after the preset base decomposition as the power operation exponent for power operation is log(n), that is, log(n) multiplications are performed.

[0100] The embodiment of the present application provides a homomorphic encryption method, which obtains a plaintext scalar to be sent by a first device, and obtains ciphertext data that is multiplied by the plaintext scalar. Since the ciphertext data is data that is homomorphically encrypted with the plaintext scalar, the ciphertext data and the plaintext scalar can be directly multiplied, that is, the ciphertext can be directly processed, and the result of the multiplication operation is also the encryption result; then, each plaintext element in the plaintext scalar is decomposed into a preset base to obtain a digit sequence corresponding to each plaintext element, one digit sequence corresponds to one plaintext element, and one digit sequence includes a number of digits in the preset base; finally, The ciphertext data of the power operation base and each digital sequence serving as the power operation exponent are subjected to power operation to obtain a homomorphic encryption result, and the homomorphic encryption result is sent to a second device. Compared with the prior art which directly performs power operation on plaintext elements as power operation exponents, the present application decomposes the plaintext elements into a preset base, which can make the number of digits serving as power operation exponents smaller than the plaintext elements originally serving as power operation exponents, thereby reducing the computational complexity, and further improving the efficiency of ciphertext multiplication operations under homomorphic encryption, so that homomorphic encryption can be applied to application scenarios with high timeliness requirements or high performance requirements, thereby improving the applicability of homomorphic encryption.

[0101] Furthermore, based on the above-mentioned first embodiment, a second embodiment of the homomorphic encryption method of the present application is proposed.

[0102] Reference Figure 3 , Figure 3 This is a flow chart of the second embodiment of the homomorphic encryption method of the present application.

[0103] In this embodiment, in the above step S30, the ciphertext data as the base of the power operation and each of the digital sequences as the exponent of the power operation are subjected to power operation to obtain a homomorphic encryption result, including:

[0104] Step S31, using the ciphertext data as a base for power calculation, and using a number of digits in the digit sequence as exponents for power calculation;

[0105] In this embodiment, the ciphertext data is used as the base of the power operation, and several digits in a digit sequence are used as the exponent of the power operation. Among them, a digit sequence corresponding to a plaintext element may include one or more digits. For example, the preset base of the above step S20 is binary, and the plaintext element is 4, then its digit sequence includes 2^2; the plaintext element is 7, then its digit sequence includes 2^0, 2^1 and 2^2. For another example, the preset base of the above step S20 is octal, the plaintext element is 64, then its digit sequence includes 8^2; the plaintext element is 75, then its digit sequence includes 8^1, 8^2 and 3.

[0106] Step S32, performing a power operation based on the power operation base and a plurality of the power operation exponents to obtain a plurality of first power operation results;

[0107] In this embodiment, a power operation is performed based on a power operation base and a plurality of power operation exponents to obtain a plurality of first power operation results, wherein the number of the plurality of power operation exponents corresponds one to one to the number of the plurality of first power operation results.

[0108] It should be noted that as many power operation exponents as there are, as many power operation expressions are constructed, the power operation base of each power operation expression is the ciphertext data, and the power operation exponent of each power operation expression corresponds to a different digit, based on which different first power operation results can be obtained.

[0109] In one embodiment, a plurality of first power operation results are obtained by performing power operation respectively using a computing unit based on a power operation base and a plurality of power operation exponents.

[0110] In another embodiment, the above step S32 includes:

[0111] Step A321, based on the power operation base and the power operation exponents, obtain a plurality of pre-stored power operation results, wherein the plurality of pre-stored power operation results are a plurality of first power operation results obtained by performing power operation based on the power operation base and the plurality of power operation exponents.

[0112] In this embodiment, based on the power operation base and several power operation exponents, several corresponding power operation formulas can be determined, and then based on the several power operation formulas, several pre-stored power operation results are obtained, wherein the pre-stored power operation results are also several first power operation results obtained by performing power operation based on the power operation base and several power operation exponents.

[0113] It should be noted that when performing exponentiation based on the exponentiation base and several exponentiation exponents, there is no need to use the computing unit to recalculate the exponentiation result. It is only necessary to reuse the exponentiation result calculated and stored in advance, thereby saving the computing process and computing resources, and further improving the efficiency of ciphertext multiplication operations.

[0114] Accordingly, in order to obtain a plurality of pre-stored power operation results, before the above step S30, the homomorphic encryption method further includes:

[0115] The maximum value of the plaintext scalar is decomposed into a preset base to obtain a corresponding maximum value digit sequence, wherein the maximum value of the plaintext scalar is determined by the number of bits of the plaintext scalar; a power operation is performed based on the ciphertext data as the power operation base and the maximum value digit sequence as the power operation exponent to obtain multiple second power operation results; the multiple second power operation results are stored for use in performing power operations on the ciphertext data as the power operation base and each of the digit sequences as the power operation exponent based on the multiple second power operation results. The specific execution process refers to the third embodiment described below, which will not be described in detail here.

[0116] In another embodiment, the preset number system is binary, and the above step S32 includes:

[0117] Step A322, comparing the number of the exponentiation exponents with the number of binary bits of the current plaintext element, the current plaintext element being the plaintext element corresponding to the exponentiation exponents;

[0118] In this embodiment, the number of several exponentiation exponents is compared with the number of binary bits of the current plaintext element, and the current plaintext element is the plaintext element corresponding to the several exponentiation exponents. Specifically, it is determined whether the number of binary bits of the current plaintext element is more than 1 or more than 0. If it is more than 1, half of the number of binary bits of the current plaintext element is less than the number of several exponentiation exponents; if it is more than 0, half of the number of binary bits of the current plaintext element is greater than the number of several exponentiation exponents.

[0119] The number of binary bits represents the bit length of the current plaintext element. For example, if the binary number of the current plaintext element is 111110, the number of binary bits is 6.

[0120] It should be noted that the number of exponentiation exponents represents the number of digits in the digit sequence obtained after the current plaintext element is decomposed into binary. Specifically, refer to the following formula:

[0121]

[0122] Where b represents the current plaintext element, i represents the position of the current bit, n represents the number of binary bits of the current plaintext element b, and b i The value of b is 1 or 0. i The value of 1 means the corresponding bit number is 1. i The value of 0 represents the corresponding bit number is 0. Based on this, the number of bits in the current plaintext element b at positions i=0 to i=n is 1, corresponding to b i is 1, and then there is a corresponding digit 2 in the digit sequence i , and then there is a corresponding exponentiation 2 i For example, if the binary bit number of the current plaintext element is 111110, the number of digits in the digit sequence corresponding to the current plaintext element is 5, and accordingly, the number of exponents of the power operation is also 5.

[0123] Step A323: if half of the number of binary bit digits is less than the number, then determine a pre-stored maximum power operation result based on the power operation base and the number of binary bit digits, and determine a number of pre-stored zero-bit power operation results based on the binary number of the current plaintext element, the zero-bit power operation result being a power operation result corresponding to a bit number of zero in the binary number, the power operation base of the zero-bit power operation result being the ciphertext data, and the power operation exponent of the zero-bit power operation result being a negative number of the number of binary digits corresponding to a bit number of zero in the binary number;

[0124] In this embodiment, if half of the number of binary bits is less than the number of exponents of the power operation, the pre-stored maximum power operation result is determined based on the power operation base and the number of binary bits. Specifically, if the power operation base is d and the number of binary bits is n, the maximum power operation result is And based on the binary number of the current plaintext element, several pre-stored zero-bit power operation results are determined, the zero-bit power operation result is the power operation result corresponding to the bit number of zero in the binary number, the power operation base of the zero-bit power operation result is the ciphertext data, and the power operation exponent of the zero-bit power operation result is the negative number of the binary bit number corresponding to the bit number of zero in the binary number. Specifically, based on the binary number of the current plaintext element, the number of bits that are 0 in the binary number is determined, and the corresponding binary bit number of the bit number that is 0 is obtained, then, based on the ciphertext data and the binary bit number, the corresponding power operation formula is determined, and finally, the corresponding zero-bit power operation result is obtained based on the power operation formula.

[0125] The maximum power calculation result is the maximum value of the binary bit number of the current plaintext element. For example, if the ciphertext data is d and the binary bit number is 4, the corresponding maximum power calculation result is d. 15 , the number of binary bits is 5, then the corresponding maximum power calculation result is d 31 .

[0126] The binary number of the current plaintext element is the binary representation of the current plaintext element. For example, if the binary bit number of the current plaintext element is 4 and the decimal number of the current plaintext element is 14, then the binary number of the current plaintext element is 1110. The zero-bit exponentiation result is the exponentiation result corresponding to the bit number of the binary number of the current plaintext element being zero. For example, if the ciphertext data is d and the binary number of the current plaintext element is 1110, then the zero-bit exponentiation result is d. -1 , if the binary number of the current plaintext element is 11100, the result of the zero-bit power operation is d -1 and d -2 , if the binary number of the current plaintext element is 11010, the result of the zero-bit exponentiation operation is d -1 and d -3 .

[0127] The number of binary digits increases from 1, that is, the lowest binary digit of the binary number of the current plaintext element is 1.

[0128] For example, if the base of the exponentiation operation (ciphertext data) is 2 and the number of binary bits of the current plaintext element is 4, then the maximum exponentiation result is 2. 15 , if the binary number of the current plaintext element is 1110, the result of the zero-bit power operation is 2 -1 , and there is only one zero-bit exponentiation result, so that the subsequent maximum exponentiation result 2 15 The result of the power operation with zero bit is 2 -1 Multiply to get 2 14 For another example, if the base of the exponentiation operation (ciphertext data) is 4 and the number of binary bits of the current plaintext element is 4, then the maximum exponentiation result is 4.15 , if the binary number of the current plaintext element is 1110, the result of the zero-bit power operation is 4 -1 , and there is only one zero-bit exponentiation result, so that the subsequent maximum exponentiation result is 4 15 The result of the power operation with zero bit is 4 -1 Multiplying together gives 4 14 .

[0129] It can be understood that if half of the binary bit number of the current plaintext element is less than the number of exponents of the power operation, it means that the binary number of the current plaintext element is more 1 than 0. At this time, if the power operation is performed directly based on the power operation base and several power operation exponents, the number of multiplication operations of the subsequent multiplication operations of several first power operation results must be greater than n / 2, where n is the number of binary bits of the current plaintext element; and through this embodiment, since several zero-bit power operation results must be less than n / 2, correspondingly, the number of multiplication operations of the subsequent multiplication operations of several first power operation results must be less than n / 2. Therefore, this embodiment can further improve the efficiency of ciphertext multiplication operations.

[0130] Accordingly, before the above step A323, the homomorphic encryption method further includes:

[0131] Obtain the maximum value of the plaintext scalar, and determine a negative digit sequence based on the number of bits of the plaintext scalar, the maximum value of the plaintext scalar is determined by the number of bits of the plaintext scalar; perform a power operation based on the ciphertext data as the power operation base and the maximum value as the power operation exponent to obtain a maximum power operation result; and perform a power operation based on the ciphertext data as the power operation base and the negative digit sequence as the power operation exponent to obtain a number of zero-bit power operation results; store the maximum power operation result and the number of zero-bit power operation results for determining a pre-stored maximum power operation result based on the power operation base and the number of binary bits, and determine a pre-stored number of zero-bit power operation results based on the binary number of the current plaintext element. That is, calculate And store the result as the maximum power operation result, calculate d -1 ,d -2 ,d -3 to d -n The result of each zero-bit exponentiation operation is taken as the result, where d is the ciphertext data and n is the number of bits of the plaintext scalar.

[0132] It can be understood that, since the stored maximum power operation result and the zero-bit power operation result can be reused, when the dimension of the plaintext scalar is higher, since the plaintext scalar contains more plaintext elements, the reuse is stronger, so that the benefit of this embodiment for improving the efficiency of ciphertext multiplication operation is greater and more practical. At the same time, the binary digits of the ciphertext data as the base of the power operation and the plaintext element as the power operation exponent are often relatively large, such as 1024 bits and 2048 bits. Therefore, the characteristics of the maximum power operation result and the zero-bit power operation result being reusable are utilized to improve the benefit of this embodiment for improving the efficiency of ciphertext multiplication operation. Based on this, if the binary digits of the ciphertext data or the plaintext element are larger, the benefit of this embodiment for improving the efficiency of ciphertext multiplication operation is greater.

[0133] Step A324: Use the maximum power operation result and the several zero-bit power operation results as several first power operation results obtained by performing power operation based on the power operation base and the several power operation exponents.

[0134] In this embodiment, the maximum power operation result and several zero-bit power operation results are used as several first power operation results obtained by performing power operation based on the power operation base and several power operation exponents. It should be noted that the several first power operation results need to be multiplied later to obtain a number multiplication result corresponding to a plaintext element. Based on this, the product of the maximum power operation result and the several zero-bit power operation results is equal to the product of the several first power operation results obtained by performing power operation based on the power operation base and several power operation exponents. Therefore, the maximum power operation result and the several zero-bit power operation results can be used as several first power operation results, that is, one maximum power operation result corresponds to one first power operation result, one zero-bit power operation result corresponds to one first power operation result, and the number of the several first power operation results is the number of the several zero-bit power operation results plus one.

[0135] For ease of understanding, for example, if the base of the power operation (ciphertext data) is 2 and the number of binary bits of the current plaintext element is 4, then the maximum power operation result is 2 15 , if the binary number of the current plaintext element is 1110, the result of the zero-bit power operation is 2 -1 , and there is only one zero-bit exponentiation result, so that the subsequent maximum exponentiation result 2 15 The result of the power operation with zero bit is 2 -1 Multiply to get 2 14 Based on this, the exponents of several power operations are 2, 4, and 8, and the corresponding first power operation results are 2 2 , 2 4 , 2 8 , then several first power operation results 2 2 , 2 4 , 2 8Multiply them and you get 2 14 Therefore, the multiplication results obtained by adopting the above embodiment or the present embodiment are the same.

[0136] In some embodiments, after the above step A322, the homomorphic encryption method further includes:

[0137] If half of the number of binary bits is greater than the number, then based on the power operation base and the power operation exponents, a plurality of pre-stored power operation results are obtained, wherein the pre-stored power operation results are a plurality of first power operation results obtained by performing power operation based on the power operation base and the power operation exponents. Specifically, refer to the embodiment of the above step A321.

[0138] Alternatively, if half of the binary bit number is greater than the number, based on the power operation base and the power operation exponents, the calculation unit performs power operation respectively to obtain several first power operation results. Specifically, reference may be made to the first embodiment above.

[0139] Step S33, performing a multiplication operation on the plurality of first power operation results to obtain a multiplication operation result corresponding to the plaintext element;

[0140] In this embodiment, a plurality of first power operation results are multiplied to obtain a multiplication result corresponding to a plaintext element. Specifically, a plurality of first power operation results are multiplied in sequence to finally obtain a multiplication result corresponding to a plaintext element.

[0141] It should be noted that the formula obtained by referring to the above analysis is:

[0142]

[0143] Among them, d is the ciphertext data, b is the plaintext data, i represents the position of the current bit in the plaintext element b, n represents the number of bits of the plaintext element b, and b i The value of b is 1 or 0. i The value of 1 means the corresponding bit number is 1. i The value of 0 represents the corresponding bit number is 0. Based on this, it can be known that when calculating several first power operation results When Perform cumulative multiplication to obtain a multiplication result corresponding to a plaintext element.

[0144] Step S34, returning to the step of using a plurality of digits in the digit sequence as exponents of the power operation, until all the digit sequences are subjected to the power operation;

[0145] In this embodiment, the process returns to the step S31 in which several digits in a digit sequence are used as exponents of the power operation until all digit sequences are subjected to the power operation. It should be noted that the steps S32 and S33 are used to calculate the result of the multiplication operation corresponding to a plaintext element, and the plaintext scalar includes several plaintext elements, each of which corresponds to a digit sequence. Therefore, the step of calculating the result of the multiplication operation corresponding to a plaintext element needs to be executed repeatedly until all plaintext elements in the plaintext scalar are subjected to the power operation and the corresponding multiplication operation results are obtained.

[0146] Step S35, based on the multiplication results corresponding to each of the plaintext elements, determine the homomorphic encryption results corresponding to the ciphertext data and the plaintext scalar.

[0147] In this embodiment, based on the multiplication results corresponding to each plaintext element, the homomorphic encryption results corresponding to the ciphertext data and the plaintext scalar are determined. Among them, the multiplication result corresponding to a plaintext element is an element, and the homomorphic encryption result corresponding to the plaintext scalar is a scalar, which includes multiple elements. Specifically, if the plaintext scalar is a two-dimensional array, the homomorphic encryption result corresponding to the plaintext scalar is also a two-dimensional array; if the plaintext scalar is a three-dimensional matrix, the homomorphic encryption result corresponding to the plaintext scalar is also a three-dimensional matrix; if the plaintext scalar is a scalar of other higher dimensions, the homomorphic encryption result corresponding to the plaintext scalar is also the corresponding scalar.

[0148] Of course, if the plaintext scalar is converted into an array, the homomorphic encryption result corresponding to the plaintext scalar is also an array. Therefore, the homomorphic encryption result corresponding to the plaintext scalar can be subsequently converted into the scalar form before the plaintext scalar is converted. For example, if the plaintext scalar is converted from a matrix to an array, the homomorphic encryption result corresponding to the plaintext scalar can be subsequently converted into a matrix.

[0149] In this embodiment, the ciphertext data as the exponentiation base and each digit sequence as the exponentiation exponent are subjected to exponentiation and multiplication operations to obtain the multiplication result. Compared with the prior art that directly uses the plaintext element as the exponentiation exponent for exponentiation, the present application decomposes the plaintext element into a preset base, so that the number of digits of the exponentiation exponent in the first exponentiation results obtained by performing exponentiation based on the exponentiation base and several exponentiation exponents is smaller than the plaintext element originally used as the exponentiation exponent, thereby reducing the computational complexity and improving the efficiency of the ciphertext multiplication operation. Furthermore, the pre-stored several exponentiation results are used as the first exponentiation results obtained by performing exponentiation based on the exponentiation base and several exponentiation exponents, and the results calculated in advance are used, thereby further improving the efficiency of the ciphertext multiplication operation. Furthermore, if half of the binary bit number of the current plaintext element is less than the number of exponents of the power operation, it means that the binary number of the current plaintext element has more 1s than 0s. At this time, if the power operation is performed directly based on the power operation base and several power operation exponents, the number of subsequent multiplication operations of several first power operation results must be greater than n / 2, where n is the number of binary bits of the current plaintext element; and through this embodiment, since several zero-bit power operation results must be less than n / 2, correspondingly, the number of subsequent multiplication operations of several first power operation results must be less than n / 2. Therefore, this embodiment can further improve the efficiency of ciphertext multiplication operations.

[0150] Furthermore, based on the above-mentioned first embodiment, a third embodiment of the homomorphic encryption method of the present application is proposed.

[0151] In this embodiment, before the above step S30, the homomorphic encryption method further includes:

[0152] Step A40, decomposing the maximum value of the plaintext scalar in a preset base to obtain a corresponding maximum value digit sequence, wherein the maximum value of the plaintext scalar is determined by the number of bits of the plaintext scalar;

[0153] In this embodiment, the maximum value of the plaintext scalar is decomposed into a preset base to obtain a corresponding maximum value digit sequence, and the maximum value of the plaintext scalar is determined by the number of bits of the plaintext scalar. The maximum value of the plaintext scalar is the maximum value that the plaintext element in the plaintext scalar can reach under the current number of bits. For example, if the number of bits of the plaintext scalar is n, the maximum value of the plaintext scalar is 2 n-1 .

[0154] Specifically, the above step A40 includes:

[0155] Based on the number of bits of the plaintext scalar, a maximum value of the plaintext scalar is determined; and the maximum value is decomposed into a preset base to obtain a corresponding maximum value digit sequence.

[0156] The maximum value digit sequence includes a plurality of digits.

[0157] It should be noted that the preset base may include binary, octal or hexadecimal, etc. To further improve the efficiency of multiplication operations, the preset base may be set to binary to match the calculation base of the current computing device. Of course, it may also be set to other higher power bases, which is also convenient for the computing device to process.

[0158] In one embodiment, the step A40 includes:

[0159] The maximum value of the plaintext scalar is decomposed into binary to obtain a corresponding maximum value digit sequence, and the maximum value of the plaintext scalar is determined by the number of bits of the plaintext scalar.

[0160] It should be noted that the maximum value of a plaintext scalar can be viewed as a set of binary numbers, that is, a binary digit sequence, which is referred to as a maximum digit sequence. For example, if the maximum value of the plaintext scalar is 15, then 15=1+2+4+8=2^0+2^1+2^2+2^3; if the maximum value of the plaintext scalar is 7, then 7=1+2+4=2^0+2^1+2^2.

[0161] In addition, it should be noted that the relationship between the digits in the maximum value digit sequence is an additive relationship. For example, if the maximum value digit sequence is {2^0, 2^1, 2^2}, then the result of adding the digits in the maximum value digit sequence is 2^0+2^1+2^2=1+2+4=7. In other words, the maximum value of the plaintext scalar is decomposed into the result of adding binary digits. Specifically, the maximum value b of the plaintext scalar is:

[0162]

[0163] Where i represents the position of the current bit, and n represents the number of bits of the maximum value b of the plaintext scalar. In other words, the maximum value digit sequence is {2 0 , 2 1 , ..., 2 n-1}.

[0164] It can be understood that the execution process of the decomposition of higher powers is basically the same as that of the binary decomposition, and will not be repeated here. For example, when the preset base is octal, the maximum value b of the plaintext scalar is:

[0165]

[0166] Among them, i represents the position of the current bit, and n represents the number of bits of the maximum value b of the plaintext scalar.

[0167] Step A50, performing a power operation based on the ciphertext data as a power operation base and the maximum value digit sequence as a power operation exponent to obtain a plurality of second power operation results;

[0168] In this embodiment, a power operation is performed based on the ciphertext data as the power operation base and the maximum value digit sequence as the power operation exponent to obtain multiple second power operation results, wherein the number of the maximum value digit sequence corresponds to the number of the multiple second power operation results.

[0169] It should be noted that as many power expressions as the maximum value digital sequence has digits, the power operation base of each power expression is the ciphertext data, and the power operation exponent of each power expression corresponds to different digits, based on which different second power operation results can be obtained.

[0170] In one embodiment, a plurality of second power operation results are obtained by performing power operation on the ciphertext data as the power operation base and the maximum value digit sequence as the power operation exponent using a computing unit.

[0171] In another embodiment, the step A50 includes:

[0172] Step A51, based on the order of the digits in the maximum value digit sequence from small to large, determine the current digit in the maximum value digit sequence to be subjected to exponentiation, and the exponentiation result corresponding to the minimum digit in the maximum value digit sequence is the ciphertext data;

[0173] In this embodiment, based on the order of the digits in the maximum value digit sequence from small to large, the current digit in the maximum value digit sequence to be subjected to the exponentiation operation is determined, and the exponentiation operation result corresponding to the minimum digit in the maximum value digit sequence is the ciphertext data. Specifically, based on the order of the digits in the maximum value digit sequence from small to large, the digits in the maximum value digit sequence are sequentially obtained as the exponentiation operation exponents to perform the exponentiation operation with the ciphertext data as the exponentiation operation base.

[0174] It should be noted that the smallest digit in the maximum value digit sequence is 1, that is, b 0 =1, b is the preset base, based on which, the power calculation result corresponding to the smallest digit in the maximum digit sequence is d 1 , d is the ciphertext data, that is, the power operation result corresponding to the smallest digit in the maximum value digit sequence is the ciphertext data.

[0175] For example, taking the default binary system as an example, the maximum value b of the plaintext scalar is:

[0176]

[0177] Among them, i represents the position of the current bit, and n represents the number of bits of the maximum value b of the plaintext scalar. Based on this, the maximum value digit sequence is in the order of 2 0 , 2 1 , ..., 2 n-1 .

[0178] Step A52, multiplying the power operation result corresponding to the previous digit by a preset number of times to obtain the power operation result corresponding to the current digit, wherein the previous digit is a digit before the current digit in a maximum value digit sequence sorted from small to large, and the preset number of times is determined by the preset base;

[0179] In this embodiment, the power operation result corresponding to the previous digit is multiplied by a preset number of times to obtain the power operation result corresponding to the current digit, the previous digit is the digit before the current digit in the maximum value digit sequence sorted from small to large, and the preset number of times is determined by the preset base. The preset number of times corresponds to the preset base one by one, if the preset base is binary, the preset number of times is 2, if the preset base is octal, the preset number of times is 8.

[0180] It should be noted that the power operation result of each digit in the digit sequence for calculating the maximum value is , d is the ciphertext data used as the base of the power operation, b is the preset base, and i is the digit position of the current digit (the minimum is 0), then For example, if the default base is binary, Based on this, the power operation result corresponding to the previous digit is multiplied by itself a preset number of times to obtain the power operation result corresponding to the current digit.

[0181] It can be understood that the computational complexity of calculating the power operation result corresponding to each digit in the maximum value digit sequence is n, and the computational complexity of calculating the power operation result corresponding to all digits in the maximum value digit sequence is n. 2 . According to this embodiment, the computational complexity of calculating the power operation results corresponding to all digits in the maximum value digit sequence is n, that is, n multiplications are performed. Therefore, this embodiment can reduce the computational complexity of the ciphertext multiplication operation, thereby further improving the efficiency of the ciphertext multiplication operation.

[0182] For example, taking the default binary system as an example, the maximum value digit sequence is in the order of 2 from small to large. 0 , 2 1 , ..., 2 n-1 , the current digit is 2 1 , then the previous digit is 2 0 , and the previous digit 2 0 The result of the power operation is the ciphertext data. At this time, the current digit 2 1The result of the power operation is the square of the ciphertext data, that is, the ciphertext data is multiplied by itself twice, after which the current digit is 2 2 , then the previous digit is 2 1 , and the previous digit 2 1 The result of the power operation is as above (the square of the ciphertext data). At this time, the current digit 2 2 The result of the power operation is the previous digit 2 1 The square of the result of the power operation, that is, the previous digit 2 1 The result of the power operation is multiplied by itself twice. For another example, taking the default base as octal as an example, the maximum value digit sequence is in the order of 8 from small to large. 0 , 8 1 , ..., 8 n-1 , the current digit is 8 1 , then the previous digit is 8 0 , and the previous digit is 8 0 The result of the power operation is the ciphertext data. At this time, the current digit is 8 1 The result of the power operation is the eighth power of the ciphertext data, that is, the ciphertext data is multiplied by itself eight times.

[0183] Step A53, returning to the step of determining the current digit to be subjected to exponentiation in the maximum value digit sequence based on the order of the digits in the maximum value digit sequence from small to large, until all digits in the maximum value digit sequence obtain corresponding exponentiation results;

[0184] In this embodiment, the step of determining the current digit to be subjected to exponentiation in the maximum value digit sequence based on the order of the digits in the maximum value digit sequence from small to large is returned until all digits in the maximum value digit sequence obtain corresponding exponentiation results. It should be noted that the maximum value digit sequence includes multiple digits, and each digit needs to calculate the corresponding exponentiation result. Therefore, it is necessary to execute the above steps A51 and A52 cyclically so that all digits in the maximum value digit sequence obtain corresponding exponentiation results.

[0185] Step A54, based on the power operation results corresponding to each of the current digits, determine a plurality of second power operation results obtained by performing power operation on the ciphertext data as the power operation base and the maximum value digit sequence as the power operation exponent.

[0186] In this embodiment, based on the power operation results corresponding to each current digit, multiple second power operation results obtained by performing power operation on the ciphertext data as the power operation base and the maximum value digit sequence as the power operation exponent are determined. That is, the power operation result corresponding to each current digit is a second power operation result, and the power operation results corresponding to each current digit are multiple second power operation results.

[0187] Step A60, storing the plurality of second exponentiation results, so as to perform exponentiation on the ciphertext data as the exponentiation base and each of the digit sequences as the exponentiation exponent based on the plurality of second exponentiation results.

[0188] In this embodiment, multiple second power operation results are stored so as to perform power operation on the ciphertext data as the power operation base and each digital sequence as the power operation exponent based on the multiple second power operation results. For details, please refer to the above-mentioned second embodiment, which will not be described one by one here.

[0189] It should be noted that this embodiment calculates d^(2^0), d^(2^1), d^(2^2), d^(2^3), ...., d^(2^n) and stores the results of each exponentiation operation, so that when performing exponentiation operation based on the exponentiation operation base and several exponentiation operation exponents, there is no need to use the calculation unit to recalculate the exponentiation operation result, and only needs to reuse the exponentiation operation result calculated and stored in advance, thereby saving calculation process and calculation resources, and further improving the efficiency of ciphertext multiplication operation.

[0190] In this embodiment, a plurality of second power operation results obtained by performing power operation based on the ciphertext data as the power operation base and the maximum value digit sequence as the power operation exponent are pre-stored, so that in the subsequent ciphertext multiplication operation process, the pre-stored power operation results can be used as the first power operation results obtained by performing power operation based on the power operation base and the power operation exponents, and the results calculated in advance can be used, thereby further improving the efficiency of the ciphertext multiplication operation.

[0191] Furthermore, based on the above-mentioned first embodiment, a fourth embodiment of the homomorphic encryption method of the present application is proposed.

[0192] In this embodiment, the first device is a device participating in federated learning. Before the above step S10, the homomorphic encryption method further includes:

[0193] When receiving the ciphertext data of the second device participating in federated learning, the step of obtaining the plaintext scalar to be sent by the first device and obtaining the ciphertext data to be multiplied by the plaintext scalar is performed to obtain a logistic regression model. Specifically, when receiving the ciphertext data of the second device participating in federated learning, the ciphertext data is the ciphertext data that needs to be multiplied. The ciphertext data is the data obtained by the second device performing homomorphic encryption on its own plaintext data, and the plaintext data is the data that the second device needs to send and share.

[0194] Among them, the first device participating in federated learning can be a participant in federated learning, that is, a data party (data provider or data application party) or a collaborator (coordinator). Correspondingly, the second device participating in federated learning can also be a participant in federated learning, that is, a data party (data provider or data application party) or a collaborator (coordinator). For example, the first device acts as a data application party, and the second device acts as a data provider. First, the second device homomorphically encrypts its own plaintext data to obtain ciphertext data. Then, the second device sends the ciphertext data to the first device so that the first device can receive the ciphertext data of the second device. Finally, the first device multiplies the ciphertext data with its own plaintext data to obtain the result of the multiplication operation. It can be understood that the result obtained by the operation of ciphertext data and plaintext data is also encrypted data, that is, the result of the multiplication operation is also ciphertext. Of course, the first device can also perform homomorphic encryption on the result of the multiplication operation.

[0195] It should be noted that the ciphertext data of the second device is the ciphertext obtained by homomorphically encrypting its own plaintext data. In addition, the multiplication operation of ciphertext data and plaintext scalar is called scalar homomorphism, that is, multiplying a plaintext by a ciphertext still results in a ciphertext. For example, the first device is Party A and the second device is Party B. Party B's data can be sent to Party A because Party B's data is ciphertext and there is no risk in sending it to Party A. Party A will calculate the data, and because the result is still ciphertext, Party A can safely send it to Party B because both parties hold the public key and cannot decrypt the data. Of course, a coordinating party C can be added on the basis of Party A and Party B to perform logistic regression operations to obtain a logistic regression model.

[0196] In one embodiment, the logistic regression model is as follows:

[0197]

[0198] Among them, w T x is the intermediate parameter of federated learning, w T x is the data that the first device and the second device need to interact with, for example, w of the second device itself T x is set to u A , the second device pairs u A Perform homomorphic encryption to obtain [[u A ]], then the first device receives [[u A ]], and the ciphertext data [[u A ]] performs operations with its own plaintext data, for example, its own plaintext data is w T x(set to u B ).

[0199] It should be noted that the loss function and gradient are Taylor expanded and polynomial approximated to support homomorphic encryption, that is, only multiplication and addition and subtraction. It can be understood that the loss function and gradient both include w in the logistic regression model. T x, therefore, after the logistic regression model is constructed, model training and model prediction can be performed on the model of the first device and / or the second device. Specifically, homomorphic encryption is widely used in federated learning, which will not be described in detail here.

[0200] In some embodiments, the first device is a device participating in federated learning, and the above step S10 includes:

[0201] Step A11, receiving ciphertext data sent by the second device participating in federated learning, and obtaining the plaintext scalar to be sent by the first device, so as to perform a multiplication operation on the plaintext scalar and the ciphertext data.

[0202] In this embodiment, the ciphertext data sent by the second device participating in the federated learning is received, and the plaintext scalar to be sent by the first device is obtained, so as to perform a multiplication operation on the plaintext scalar and the ciphertext data. Among them, the first device participating in the federated learning can be a participant in the federated learning, that is, a data party (data provider or data application party) or a collaborating party (coordinating party). Correspondingly, the second device participating in the federated learning can also be a participant in the federated learning, that is, a data party (data provider or data application party) or a collaborating party (coordinating party). For example, the first device acts as a data application party and the second device acts as a data provider. First, the second device performs homomorphic encryption on its own data to obtain ciphertext data. Then, the second device sends the ciphertext data to the first device so that the first device can receive the ciphertext data of the second device. Finally, the first device performs a multiplication operation on the ciphertext data and its own plaintext data to obtain a ciphertext multiplication operation result. It can be understood that the result obtained by the operation of the ciphertext data and the plaintext data is also encrypted data, that is, the ciphertext multiplication operation result is also ciphertext. Of course, the first device can also perform homomorphic encryption on the ciphertext multiplication operation result.

[0203] It should be noted that the ciphertext data of the second device is the ciphertext obtained by homomorphically encrypting its own plaintext data. In addition, the multiplication operation of ciphertext data and plaintext scalar is called scalar homomorphism, that is, multiplying a plaintext by a ciphertext still results in a ciphertext. For example, the first device is Party A and the second device is Party B. Party B's data can be sent to Party A because Party B's data is ciphertext and there is no risk in sending it to Party A. Party A will calculate the data, and because the result is still ciphertext, Party A can safely send it to Party B because both parties hold the public key and cannot decrypt the data. Of course, a coordinating party C can be added on the basis of Party A and Party B to perform logistic regression operations.

[0204] In this embodiment, the homomorphic encryption method is applied to the scenario of federated learning to solve the computational bottleneck of calculating the product of ciphertext data and plaintext data in the logistic regression of homomorphic encryption, thereby solving the problem of low efficiency of ciphertext multiplication operations under homomorphic encryption in federated learning.

[0205] The present application also provides a computer-readable storage medium having a homomorphic encryption program stored thereon. When the homomorphic encryption program is executed by a processor, the steps of the homomorphic encryption method described in any of the above embodiments are implemented.

[0206] The specific embodiments of the computer-readable storage medium of the present application are basically the same as the embodiments of the above-mentioned homomorphic encryption method, and will not be repeated here.

[0207] The present application also provides a computer program product, which includes a computer program, and when the computer program product is executed by a processor, implements the steps of the homomorphic encryption method described in any of the above embodiments.

[0208] The specific embodiments of the computer program product of the present application are basically the same as the embodiments of the above-mentioned homomorphic encryption method and will not be described in detail here.

[0209] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0210] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0211] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0212] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A homomorphic encryption method, It is characterized in that Applied to the first device, the homomorphic encryption method comprises the following steps: Obtaining a plaintext scalar to be sent by the first device, and obtaining ciphertext data to be multiplied by the plaintext scalar, wherein the ciphertext data is data homomorphically encrypted on the plaintext scalar; Decomposing each plaintext element in the plaintext scalar in a preset base to obtain a digit sequence corresponding to each plaintext element, wherein one digit sequence corresponds to one plaintext element, and one digit sequence includes a number of digits in the preset base; Performing a power operation on the ciphertext data as a power operation base and each of the digital sequences as a power operation exponent to obtain a homomorphic encryption result, and sending the homomorphic encryption result to the second device; The step of performing a power operation on the ciphertext data as the power operation base and each of the digit sequences as the power operation exponents to obtain a homomorphic encryption result comprises: Using the ciphertext data as a base for power calculation and using a number of digits in the digit sequence as exponents for power calculation; Performing a power operation based on the power operation base and the power operation exponents to obtain a plurality of first power operation results; Performing a multiplication operation on the plurality of first power operation results to obtain a multiplication operation result corresponding to the plaintext element; Returning to the step of using a number of digits in the digit sequence as exponents of the power operation, until all digits in the digit sequence are subjected to the power operation; Based on the multiplication results corresponding to each of the plaintext elements, the homomorphic encryption results corresponding to the ciphertext data and the plaintext scalar are determined.

2. The homomorphic encryption method according to claim 1, It is characterized in that The step of performing a power operation based on the power operation base and the power operation exponents to obtain a plurality of first power operation results comprises: Based on the power operation base and the power operation exponents, a plurality of pre-stored power operation results are obtained, wherein the pre-stored power operation results are a plurality of first power operation results obtained by performing power operation based on the power operation base and the power operation exponents.

3. The homomorphic encryption method according to claim 1, It is characterized in that The preset base is binary, and the step of performing a power operation based on the power operation base and a plurality of the power operation exponents to obtain a plurality of first power operation results comprises: Compare the number of the exponentiation exponents with the number of binary bits of a current plaintext element, where the current plaintext element is the plaintext element corresponding to the exponentiation exponents; If half of the number of binary bit digits is less than the number, a pre-stored maximum power operation result is determined based on the power operation base and the number of binary bit digits, and a number of pre-stored zero-bit power operation results are determined based on the binary number of the current plaintext element, the zero-bit power operation result is a power operation result corresponding to a bit number of zero in the binary number, the power operation base of the zero-bit power operation result is the ciphertext data, and the power operation exponent of the zero-bit power operation result is a negative number of the number of binary digits corresponding to a bit number of zero in the binary number; The maximum power operation result and the several zero-bit power operation results are used as several first power operation results obtained by performing power operation based on the power operation base and the several power operation exponents.

4. The homomorphic encryption method according to claim 1, It is characterized in that Before the step of performing a power operation on the ciphertext data as the power operation base and each of the digital sequences as the power operation exponents to obtain a homomorphic encryption result, the step further includes: Decomposing the maximum value of the plaintext scalar in a preset base to obtain a corresponding maximum value digit sequence, wherein the maximum value of the plaintext scalar is determined by the number of bits of the plaintext scalar; Performing a power operation based on the ciphertext data as a power operation base and the maximum value digit sequence as a power operation exponent to obtain a plurality of second power operation results; The plurality of second exponentiation results are stored for performing exponentiation on the ciphertext data as a base of exponentiation and each of the digit sequences as exponents of exponentiation based on the plurality of second exponentiation results.

5. The homomorphic encryption method according to claim 4, It is characterized in that The step of performing a power operation based on the ciphertext data as a power operation base and the maximum value digit sequence as a power operation exponent to obtain a plurality of second power operation results comprises: Based on the order of the digits in the maximum value digit sequence from small to large, determining the current digit in the maximum value digit sequence to be subjected to the power operation, and the power operation result corresponding to the minimum digit in the maximum value digit sequence is the ciphertext data; The power operation result corresponding to the previous digit is multiplied by itself by a preset number of times to obtain the power operation result corresponding to the current digit, wherein the previous digit is a digit before the current digit in a maximum value digit sequence sorted from small to large, and the preset number of times is determined by the preset base; Returning to the step of determining the current digit to be subjected to exponentiation in the maximum value digit sequence based on the order of the digits in the maximum value digit sequence from small to large, until all digits in the maximum value digit sequence obtain corresponding exponentiation results; Based on the power operation results corresponding to the current digits, a plurality of second power operation results are determined, which are obtained by performing power operation on the ciphertext data as the power operation base and the maximum value digit sequence as the power operation exponent.

6. The homomorphic encryption method according to any one of claims 1 to 5, It is characterized in that The first device is a device participating in federated learning, and the step of obtaining a plaintext scalar to be sent by the first device and obtaining ciphertext data for multiplication operation with the plaintext scalar includes: Receive ciphertext data sent by a second device participating in federated learning, and obtain a plaintext scalar to be sent by the first device, so as to perform a multiplication operation on the plaintext scalar and the ciphertext data.

7. A homomorphic encryption device, It is characterized in that The homomorphic encryption device includes: a memory, a processor, and a homomorphic encryption program stored in the memory and executable on the processor. When the homomorphic encryption program is executed by the processor, the steps of the homomorphic encryption method according to any one of claims 1 to 6 are implemented.

8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a homomorphic encryption program, which, when executed by a processor, implements the steps of the homomorphic encryption method according to any one of claims 1 to 6.

9. A computer program product, It is characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the homomorphic encryption method according to any one of claims 1 to 6 are implemented.