Homomorphic encryption processing method and related equipment
By reading and selecting zero ciphertexts for encryption in homomorphic encryption, and using modular multiplication instead of modular exponentiation operations, the problem of low homomorphic encryption efficiency is solved, an efficient and lossless encryption process is realized, and the training efficiency of federated learning is improved .
Patent Information
- Application Number
- CN202210132649.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-22
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2041-12-22
AI Technical Summary
There is a problem of inefficiency in the homomorphic encryption process, especially due to the increasing time-consuming process caused by a large number of modular exponentiation operations. Existing optimization methods usually lose accuracy and security, and hardware optimization requires high resource requirements.
By reading the first zero ciphertext and obtaining the most recent P 200 ciphertext, check whether it is a new zero ciphertext. If so, directly encrypt it. Otherwise, select Q from the P 200 ciphertext for encryption , uses modular multiplication instead of modular exponentiation operations to reduce direct modular exponentiation operations.
It realizes efficient and lossless homomorphic encryption, improves encryption efficiency, and improves the training efficiency of federated learning without losing accuracy and security.
Smart Images

Figure CN114444108B_ABST
Abstract
Description
[0001] This application is a divisional application of the Chinese patent application submitted to the China Patent Office on December 22, 2021, with application number 2021115763636 and application name “Homomorphic Encryption Processing Method and Related Equipment”, all contents of which are incorporated by reference in this application. Technical Field
[0002] The present application relates to the field of data encryption technology, and in particular to a homomorphic encryption processing method and related equipment. Background Art
[0003] In recent years, academia and industry have begun to use federated learning solutions to solve such problems. Federated learning uses knowledge such as cryptography and machine learning to improve the actual effect of AI models while ensuring data privacy and legal compliance. Homomorphic encryption has become the most widely used privacy protection technology in federated learning in the industry because it supports direct calculations on ciphertext.
[0004] In homomorphic encryption, the encryption process of plaintext includes a large number of modular multiplication and modular exponentiation operations on multiplication cycle groups, which makes the encryption process very time-consuming. There are many optimizations in the computational level of homomorphic encryption, such as reducing the length of the secret key, making the large numbers involved in the calculation smaller, or replacing them with encryption schemes with faster calculation speeds, which usually loses a certain degree of accuracy and security; in addition, there are hardware-based optimizations such as multi-process, distributed, and designing specific encryption computing chips, which have certain requirements on the user's hardware reserves and provision capabilities. Therefore, the problem of how to improve the efficiency of homomorphic encryption needs to be solved urgently. Summary of the invention
[0005] The embodiments of the present application provide a homomorphic encryption processing method and related equipment, which can improve the efficiency of homomorphic encryption.
[0006] In a first aspect, an embodiment of the present application provides a homomorphic encryption processing method, the method comprising:
[0007] Read the first zero ciphertext, and obtain the most recently retained P second zero ciphertexts, where P is a positive integer;
[0008] detecting whether the first zero ciphertext is a new zero ciphertext;
[0009] When the first zero ciphertext is a new zero ciphertext, encrypting the plaintext to be encrypted according to the first zero ciphertext to obtain a first ciphertext;
[0010] When the first zero ciphertext is not a new zero ciphertext, selecting Q second zero ciphertexts from the P second zero ciphertexts, where Q is a positive integer less than or equal to P;
[0011] The plaintext to be encrypted is encrypted according to the Q second zero ciphertexts to obtain a second ciphertext.
[0012] In a second aspect, an embodiment of the present application provides a homomorphic encryption processing device, the device comprising: a zero ciphertext acquisition unit, a detection unit, a first encryption unit and a second encryption unit, wherein:
[0013] The zero ciphertext acquisition unit is used to read the first zero ciphertext and acquire the most recently retained P second zero ciphertexts, where P is a positive integer;
[0014] The detection unit is used to detect whether the first zero ciphertext is a new zero ciphertext;
[0015] The first encryption unit is configured to encrypt the plaintext to be encrypted according to the first zero ciphertext to obtain a first ciphertext when the first zero ciphertext is a new zero ciphertext;
[0016] The second encryption unit is used to select Q second zero ciphertexts from the P second zero ciphertexts when the first zero ciphertext is not a new zero ciphertext, where Q is a positive integer less than or equal to P; and encrypt the plaintext to be encrypted according to the Q second zero ciphertexts to obtain a second ciphertext.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps in the first aspect of the embodiment of the present application.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps described in the first aspect of the embodiment of the present application.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in the first aspect of the embodiment of the present application. The computer program product may be a software installation package.
[0020] In the sixth aspect, an embodiment of the present application provides a homomorphic encryption processing system, which includes: a homomorphic encryption application system, a key generation center, a ciphertext storage center and a zero ciphertext system, wherein the above-mentioned homomorphic encryption processing system is used to execute part or all of the steps described in the first aspect of the embodiment of the present application.
[0021] The implementation of the embodiments of the present application has the following beneficial effects:
[0022] It can be seen that the homomorphic encryption processing method and related equipment described in the embodiments of the present application, by reading the first zero ciphertext and obtaining the most recently retained P second zero ciphertexts, P is a positive integer, detects whether the first zero ciphertext is a new zero ciphertext, and when the first zero ciphertext is a new zero ciphertext, encrypts the encrypted plaintext according to the first zero ciphertext to obtain the first ciphertext, and when the first zero ciphertext is not a new zero ciphertext, selects Q second zero ciphertexts from the P second zero ciphertexts, Q is a positive integer less than or equal to P, and encrypts the encrypted plaintext according to the Q second zero ciphertexts to obtain the second ciphertext. In the homomorphic encryption process, since zero ciphertext is used to implement encryption, the modular exponentiation operation in the encryption process can be replaced by a modular multiplication operation, reducing direct modular exponentiation operations, achieving efficient and lossless homomorphic encryption, and improving encryption efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 It is a structural schematic diagram of a homomorphic encryption processing system for implementing a homomorphic encryption processing method provided in an embodiment of the present application;
[0025] Figure 2 It is a flowchart of a homomorphic encryption processing method provided in an embodiment of the present application;
[0026] Figure 3 It is a demonstration schematic diagram of a matrix partition provided in an embodiment of the present application;
[0027] Figure 4 It is a flowchart of another homomorphic encryption processing method provided in an embodiment of the present application;
[0028] Figure 5 It is a flowchart of another homomorphic encryption processing method provided in an embodiment of the present application;
[0029] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0030] Figure 7 It is a block diagram of the functional units of a homomorphic encryption processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0032] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0033] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0034] The electronic devices described in the embodiments of the present application may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, PDAs, driving recorders, traffic command platforms, servers, laptops, mobile Internet devices (MID, Mobile Internet Devices) or wearable devices (such as smart watches, Bluetooth headsets), etc. The above are only examples and not exhaustive, including but not limited to the above electronic devices. The electronic device can also be a cloud server.
[0035] The embodiments of the present application are described in detail below.
[0036] See also Figure 1 , Figure 1 It is a structural schematic diagram of a homomorphic encryption processing system for implementing a homomorphic encryption processing method provided in an embodiment of the present application. As shown in the figure, the homomorphic encryption processing system includes: a homomorphic encryption application system, a key generation center, a ciphertext storage center and a zero ciphertext system.
[0037] Among them, the key generation center is used to generate public keys. The key generation center can be independent of the homomorphic encryption application system, or the key generation center is integrated with the homomorphic encryption application system. The ciphertext storage center can be independent of the homomorphic encryption application system, or the ciphertext storage center is integrated with the homomorphic encryption application system. The zero ciphertext system can be independent of the homomorphic encryption application system, or the zero ciphertext system is integrated with the homomorphic encryption application system. Of course, the homomorphic encryption application system, the key generation center, the ciphertext storage center and the zero ciphertext system can be independent of each other. The zero ciphertext system can be an online system or an offline system. The homomorphic encryption application system can be an online system. The ciphertext storage center can include at least one of the following: a disk, a database redis, a distributed file system (hadoop distributed file system, HDFS), etc., which are not limited here.
[0038] Among them, the homomorphic encryption application system can be any system suitable for homomorphic encryption. The homomorphic encryption application system can include at least one of the following: a federated learning system, a confidential computing system, a privacy computing system, etc., which is not limited here.
[0039] Based on the above homomorphic encryption processing system, it can be used to perform the following steps:
[0040] Read the first zero ciphertext, and obtain the most recently retained P second zero ciphertexts, where P is a positive integer;
[0041] detecting whether the first zero ciphertext is a new zero ciphertext;
[0042] When the first zero ciphertext is a new zero ciphertext, encrypting the plaintext to be encrypted according to the first zero ciphertext to obtain a first ciphertext;
[0043] When the first zero ciphertext is not a new zero ciphertext, selecting Q second zero ciphertexts from the P second zero ciphertexts, where Q is a positive integer less than or equal to P;
[0044] The plaintext to be encrypted is encrypted according to the Q second zero ciphertexts to obtain a second ciphertext.
[0045] It can be seen that the embodiment of the present application reads the first zero ciphertext and obtains the most recently retained P second zero ciphertexts, where P is a positive integer, and detects whether the first zero ciphertext is a new zero ciphertext. When the first zero ciphertext is a new zero ciphertext, the encrypted plaintext is encrypted according to the first zero ciphertext to obtain the first ciphertext. When the first zero ciphertext is not a new zero ciphertext, Q second zero ciphertexts are selected from the P second zero ciphertexts, where Q is a positive integer less than or equal to P. The encrypted plaintext is encrypted according to the Q second zero ciphertexts to obtain the second ciphertext. In the homomorphic encryption process, since zero ciphertext is used to implement encryption, the modular exponentiation operation in the encryption process can be replaced by a modular multiplication operation, thereby reducing direct modular exponentiation operations, achieving efficient and lossless homomorphic encryption, and improving encryption efficiency.
[0046] See also Figure 2 , Figure 2 is a flow chart of a homomorphic encryption processing method provided in an embodiment of the present application, which is applied to Figure 1 The homomorphic encryption processing system shown in the figure, as shown in the figure, the homomorphic encryption processing method includes:
[0047] 201. Read the first zero ciphertext, and obtain the most recently retained P second zero ciphertexts, where P is a positive integer.
[0048] In the embodiment of the present application, the zero ciphertext may be a ciphertext obtained by encrypting 0 with a public key. The first zero ciphertext may be obtained by encrypting 0 with a public key by a homomorphic encryption application system. The number of the first zero ciphertexts may be X, where X is a positive integer, and X may be 1, 2, 3, etc., which is not limited here. Of course, the homomorphic encryption application system may also implement other encryption functions through a public key.
[0049] In a specific implementation, the first zero ciphertext can be read, and the most recently retained P second zero ciphertexts can be obtained, where P is a positive integer, for example, P can be 10, and the first zero ciphertext can be stored in a different location from the second zero ciphertext. For example, the first zero ciphertext can be stored in a homomorphic encryption application system, and the second zero ciphertext can be stored in a ciphertext storage center. Of course, the first zero ciphertext and the second zero ciphertext can also be stored in the same location, for example, both are stored in a ciphertext storage center or a homomorphic encryption application system.
[0050] In a specific implementation, the homomorphic encryption application system, key generation center, ciphertext storage center, and zero ciphertext system can all be located on a server or an electronic device (client). For example, some of the homomorphic encryption application system, key generation center, ciphertext storage center, and zero ciphertext system are located on a server, and others are located on an electronic device (client).
[0051] Of course, the number of key generation centers can be 1 or 2. When there is 1 key generation center, it can be located in a server or an electronic device. When there are 2 key generation centers, one can be located in a server and the other in an electronic device.
[0052] To give an example, the homomorphic encryption application system can be set up on the server, the zero ciphertext system can be set up on the electronic device (client), and the zero ciphertext system can generate corresponding zero ciphertext before the electronic device connects to the server or when initiating the connection. The key generation center can be set up on the server or the electronic device, which is used to store the zero ciphertext generated by the zero ciphertext system. Since the zero ciphertext is stored in the cloud server and the electronic device respectively, the source of the zero ciphertext is enriched, and the randomness of the zero ciphertext is also enriched, thereby further improving the encryption security.
[0053] Optionally, the above step 201, obtaining the most recently retained P second zero ciphertexts, may include the following steps:
[0054] The P second zero ciphertexts are obtained from a ciphertext storage center, wherein the ciphertext storage center pre-stores M second zero ciphertexts, wherein each of the M second zero ciphertexts is obtained by encrypting 0 by a zero ciphertext system using a public key, and M is a positive integer greater than or equal to P.
[0055] In the embodiment of the present application, the ciphertext storage center can store M second zero ciphertexts, where M is an integer greater than or equal to P, and P second zero ciphertexts can be randomly selected from the M second zero ciphertexts, or the most recently generated P second zero ciphertexts can be selected. The second zero ciphertext can be obtained by encrypting 0 by the zero ciphertext system using the public key, and the P second zero ciphertexts are different zero ciphertexts.
[0056] Optionally, the public key is a homomorphic encryption public key, which is generated by a key generation center.
[0057] Among them, in the embodiment of the present application, the public key is a homomorphic encryption public key, which is generated by a key generation center, and the public key can be distributed and transmitted to the zero ciphertext system and the homomorphic encryption application system. The zero ciphertext system is used to encrypt 0 based on the public key to generate a second zero ciphertext. The homomorphic encryption application system can encrypt 0 based on the public key to obtain the first zero ciphertext or the second zero ciphertext, and can also implement other encryption functions based on the public key.
[0058] Optionally, the zero ciphertext system is an offline system or an online system.
[0059] Among them, the zero ciphertext system can be an online system, for example, it can generate zero ciphertext in real time, or the zero ciphertext system can be an offline system, it can generate zero ciphertext in advance in an offline state and store these zero ciphertexts in a ciphertext storage center.
[0060] 202. Detect whether the first zero ciphertext is a new zero ciphertext.
[0061] In a specific implementation, it is possible to detect whether the first zero ciphertext is a used zero ciphertext. If it has been used, it means that the first zero ciphertext is not a new zero ciphertext. If it has not been used, it means that the first zero ciphertext is a new zero ciphertext. The above-mentioned used means that the first zero ciphertext is used to encrypt plaintext.
[0062] 203. When the first zero ciphertext is a new zero ciphertext, encrypt the plaintext to be encrypted according to the first zero ciphertext to obtain a first ciphertext.
[0063] Among them, in the embodiment of the present application, the plaintext to be encrypted can be text or characters, and its expression form can include at least one of the following forms: number, vector, matrix, etc., which are not limited here. In a specific implementation, the first zero ciphertext can be added to the plaintext to be encrypted to obtain the first ciphertext. For example, when the homomorphic encryption application system is a federated learning system, the first ciphertext can be used for federated learning training.
[0064] Among them, the plaintext to be encrypted can be one-dimensional data or multi-dimensional data. For example, the plaintext to be encrypted can be image encoding data, or audio encoding data, or important privacy data, or Internet financial data.
[0065] In a specific implementation, when the first zero ciphertext is a new zero ciphertext, since the new zero ciphertext has not been used, the plaintext to be encrypted can be encrypted according to the first zero ciphertext to obtain the first ciphertext.
[0066] 204. When the first zero ciphertext is not a new zero ciphertext, select Q second zero ciphertexts from the P second zero ciphertexts, where Q is a positive integer less than or equal to P.
[0067] When the first zero ciphertext is not a new zero ciphertext, Q second zero ciphertexts may be randomly or sequentially selected from P second zero ciphertexts, where Q is a positive integer less than or equal to P. The sequential order may be the order of ciphertext storage time or the order of ciphertext storage addresses.
[0068] Optionally, the above step 204, selecting Q second zero ciphertexts from the P second zero ciphertexts, may include the following steps:
[0069] 41. Obtain target attribute information of the plaintext to be encrypted;
[0070] 42. Determine the number of second zero ciphertexts corresponding to the target attribute information to obtain Q;
[0071] 43. Select the Q second zero ciphertexts from the P second zero ciphertexts.
[0072] In the embodiment of the present application, the target attribute information may include at least one of the following: plaintext type, plaintext length, plaintext importance level, etc., which are not limited here. The plaintext type may include at least one of the following: number, vector, matrix, etc., which are not limited here.
[0073] In a specific implementation, a mapping relationship between preset attribute information and the allocated number of second zero ciphertexts can be pre-stored. After obtaining the target attribute information of the plaintext to be encrypted, the allocated number corresponding to the target attribute information, i.e., Q, can be determined according to the mapping relationship. Then, Q second zero ciphertexts can be selected from P second zero ciphertexts. In this way, corresponding zero ciphertexts can be allocated based on the attributes of the plaintext, and dynamic data encryption can be achieved. For example, the number of second zero ciphertexts required for vectors and matrices is different.
[0074] 205. Encrypt the plaintext to be encrypted according to the Q second zero ciphertexts to obtain a second ciphertext.
[0075] Among them, in the embodiment of the present application, for example, when Q is 1, the second zero ciphertext can be added to the plaintext to be encrypted to obtain the second ciphertext. For another example, when Q is greater than 1, the plaintext to be encrypted can be divided into Q segments, each segment corresponds to a second zero ciphertext, each second zero ciphertext is added to the plaintext to be encrypted of the corresponding segment, and then these encrypted plaintexts are spliced to obtain the second ciphertext, so that the security of homomorphic encryption can be improved. Next, for example, when the homomorphic encryption application system is a federated learning system, the second ciphertext can be used for federated learning training.
[0076] In a specific implementation, once the first zero ciphertext or the second zero ciphertext is used, the homomorphic encryption application system can generate a new zero ciphertext by encrypting the 0 with a public key, or the zero ciphertext system can generate a new zero ciphertext by encrypting the 0 with a public key. The total number of the first zero ciphertext and the second zero ciphertext can be maintained within a preset range, which can be preset or defaulted by the system.
[0077] Optionally, the above step 205, encrypting the plaintext to be encrypted according to the Q second zero ciphertexts to obtain the second ciphertext, may include the following steps:
[0078] 51. Divide the plaintext to be encrypted into N sub-plaintexts, where N is an integer greater than 1, and Q is greater than or equal to N;
[0079] 52. Divide the Q second zero ciphertexts into N zero ciphertext groups, each zero ciphertext group including at least one second zero ciphertext;
[0080] 53. Encrypt the N sub-plaintexts according to the N zero ciphertext groups to obtain N ciphertexts;
[0081] 54. Determine the second ciphertext according to the N ciphertexts.
[0082] In a specific implementation, the plaintext to be encrypted can be divided into N sub-plaintexts, where N is an integer greater than 1, and Q is greater than or equal to N. For example, when N is a number, it can be divided into N sub-plaintexts based on the number of bits. For another example, when N is a vector, it can be divided into N sub-plaintexts based on the dimension of the vector. For another example, when N is a matrix, the matrix can be decomposed into N sub-matrices, each of which can correspond to a sub-plaintext. Alternatively, the size of the matrix can be divided into multiple regions, each of which corresponds to a matrix block, such as Figure 3 As shown, a matrix ( Figure 3 The left picture in the figure) can be divided into 4 matrix blocks ( Figure 3 In the right figure), if the matrix size is A*B, it is divided into 4 matrix blocks with a matrix size of (A / 2)*(B / 2), such as Figure 3 As shown, the entire rectangle can represent the matrix before division, and the four rectangles after division can represent four matrix blocks.
[0083] Furthermore, the Q second zero ciphertexts can be divided into N zero ciphertext groups, each zero ciphertext group includes at least one second zero ciphertext, and then the N sub-plaintexts are encrypted according to the N zero ciphertext groups to obtain N ciphertexts. For example, each sub-plaintext can be encrypted corresponding to a zero ciphertext group. Finally, the second ciphertext can be determined based on the N ciphertexts, such as splicing the N ciphertexts to obtain the second ciphertext. In this way, security and encryption efficiency can be improved.
[0084] In a specific implementation, when N sub-plaintexts are encrypted according to N zero ciphertext groups, each zero ciphertext group may correspond to a thread or process, and the zero ciphertext group and the corresponding sub-plaintext may be encrypted synchronously through the thread or process, thereby further improving the encryption efficiency.
[0085] In specific implementation, the embodiments of the present application can improve the efficiency of homomorphic encryption application fields, such as federated learning training. In specific implementation, the embodiments of the present application are applied to any scenario involving homomorphic encryption, such as network security, Internet finance, secure transmission of Internet of Things data, etc., without limitation here.
[0086] For example, Figure 4As shown in the figure, when the homomorphic encryption application system is used as the federated learning system, the federated learning system can be an online system and the zero ciphertext system can be an offline system. The key generation center is used to generate a homomorphic encryption public key, and the public key is pushed to the federated learning system and the zero ciphertext system respectively. The zero ciphertext system uses the public key to encrypt 0 to generate enough zero ciphertexts and store them in the ciphertext storage center. The federated learning system can read the zero ciphertext and obtain the latest 10 zero ciphertexts from the ciphertext storage center, detect whether these read zero ciphertexts have new zero ciphertexts, if yes, encrypt the encrypted plaintext with the new zero ciphertext to obtain the ciphertext, if not, select at least one zero ciphertext from the latest 10 zero ciphertexts, and use the at least one zero ciphertext to encrypt the encrypted plaintext to obtain the ciphertext.
[0087] In the specific implementation, considering that the modular exponentiation of large numbers is the main reason why the homomorphic encryption process is time-consuming, the above-mentioned embodiment of the present application uses the addition operation between the plaintext to be encrypted and a specific ciphertext (zero ciphertext) to encrypt the plaintext, thereby replacing the modular exponentiation operation in the encryption process with a modular multiplication operation, reducing the direct modular exponentiation operation, and realizing an efficient and lossless homomorphic encryption scheme, thereby improving the training efficiency of federated learning. At the same time, considering the security of the encryption scheme, in the embodiment of the present application, the encryption process of the plaintext is split into two parts: specific ciphertext generation and ciphertext addition, and the generation of the specific ciphertext does not depend on the plaintext data to be encrypted, so it can be completed offline. The random encryption algorithm based on the offline specific ciphertext generation and online plaintext encryption can still meet the security requirements of the chosen-plaintext attack (CPA).
[0088] The specific implementation process can be divided into two cases: offline generation of zero ciphertext and online encryption. The following is a detailed description.
[0089] For offline generation of zero ciphertext, the key generation center can be an independent system. The key generation center can be used offline to generate a public key, and the public key can be used to encrypt 0 to generate enough zero ciphertext, which is then stored in the ciphertext storage center and directly read and used when the model starts training.
[0090] For some federated learning systems, the initial design is that the public key will be generated and synchronized only when a federated modeling begins. At this time, the key generation center is a submodule of the federated learning system. In this case, after the federated learning system initializes and generates (or receives) the public key, the zero ciphertext generation system uses the public key to generate zero ciphertext (that is, encrypt 0), and stores the zero ciphertext in the ciphertext storage center to be read and used when the model training starts.
[0091] In addition, because the encryption of 0 is much slower than online ciphertext addition (about 10-100 times slower), there may be insufficient zero ciphertexts in the ciphertext storage center at the beginning of federated learning training. In this case, when no new ciphertext is generated, a random one can be selected from the existing zero ciphertexts for use (still with a certain degree of randomness). Because the zero ciphertext system here is an independent system, it can be independent of the federated learning system and keep running to generate zero ciphertexts, so there will be enough zero ciphertexts available in the later stages of model training.
[0092] For online encryption scenarios, such as Figure 4 As shown, online encryption can use the zero ciphertext generated offline to directly sum with the plaintext to be encrypted to achieve random encryption of the plaintext. It can include the following steps:
[0093] 1. Read zero ciphertext from the ciphertext storage center and keep the most recent 10 zero ciphertexts;
[0094] 2. When there is no new zero ciphertext in the ciphertext storage center, a zero ciphertext is randomly selected from the reserved zero ciphertexts;
[0095] 3. The encrypted plaintext plus the selected zero ciphertext is the encryption result of the ciphertext;
[0096] 4. Use the encrypted data for subsequent federated learning training or other applications.
[0097] The embodiment of the present application can realize an offline generation of a homomorphic ciphertext of 0, i.e., zero ciphertext, and use the zero ciphertext to encrypt the plaintext to be encrypted online (i.e., direct summation), which greatly improves the data encryption process and thus greatly improves the training efficiency of federated learning.
[0098] In homomorphic encryption, the main encryption overhead is the large number modular exponentiation operation on the multiplication cycle group. Specific optimization of this module can greatly improve the computational efficiency. In addition, based on the homomorphism of homomorphic encryption, it can support the direct addition of plaintext and ciphertext to obtain a ciphertext, which can also be regarded as an encryption process for the plaintext here. And there is no modular exponential operation involved, but a modular multiplication operation, which is very efficient. When the ciphertext involved in the addition operation is 0, the decrypted ciphertext obtained after the addition is equal to the plaintext involved in the addition operation.
[0099] In addition, if only one ciphertext of 0 is used, the encrypted ciphertext of the data is certain and cannot meet the CPA security requirements. Therefore, as many different ciphertexts of 0 as possible should be generated (the homomorphic encryption algorithm is generally a random encryption scheme, that is, the ciphertext of 0 is different each time it is encrypted).
[0100] In the embodiments of the present application, the number of large number modular exponentiation operations in real-time homomorphic encryption can be reduced, greatly improving the encryption efficiency of real-time homomorphic encryption.
[0101] In summary, the embodiments of the present application can effectively improve the efficiency of real-time homomorphic encryption by designing a homomorphic encryption scheme that supports offline computing without losing the accuracy and security of the federated learning model, thereby improving the training efficiency of federated learning.
[0102] It can be seen that the homomorphic encryption processing method described in the embodiment of the present application reads the first zero ciphertext and obtains the most recently retained P second zero ciphertexts, where P is a positive integer, detects whether the first zero ciphertext is a new zero ciphertext, and when the first zero ciphertext is a new zero ciphertext, encrypts the encrypted plaintext according to the first zero ciphertext to obtain the first ciphertext, and when the first zero ciphertext is not a new zero ciphertext, selects Q second zero ciphertexts from the P second zero ciphertexts, where Q is a positive integer less than or equal to P, and encrypts the encrypted plaintext according to the Q second zero ciphertexts to obtain the second ciphertext. In the homomorphic encryption process, since zero ciphertext is used to implement encryption, the modular exponentiation operation in the encryption process can be replaced by a modular multiplication operation, thereby reducing direct modular exponentiation operations, achieving efficient and lossless homomorphic encryption, and improving encryption efficiency.
[0103] With the above Figure 2 For the embodiments shown, please refer to Figure 5 , Figure 5 : is a flow chart of a homomorphic encryption processing method provided in an embodiment of the present application, which is applied to an electronic device. As shown in the figure, the homomorphic encryption processing method includes:
[0104] 501. Read a first zero ciphertext, and obtain P second zero ciphertexts from a ciphertext storage center, wherein the ciphertext storage center pre-stores M second zero ciphertexts, and each of the M second zero ciphertexts is obtained by encrypting 0 by a public key in a zero ciphertext system, wherein M is a positive integer greater than or equal to P, and P is a positive integer; the public key is a homomorphic encryption public key, which is generated by a key generation center, and the zero ciphertext system is an offline system.
[0105] 502. Detect whether the first zero ciphertext is a new zero ciphertext.
[0106] 503. When the first zero ciphertext is a new zero ciphertext, encrypt the plaintext to be encrypted according to the first zero ciphertext to obtain a first ciphertext.
[0107] 504. When the first zero ciphertext is not a new zero ciphertext, select Q second zero ciphertexts from the P second zero ciphertexts, where Q is a positive integer less than or equal to P.
[0108] 505. Encrypt the plaintext to be encrypted according to the Q second zero ciphertexts to obtain a second ciphertext.
[0109] The specific description of the above steps 501 to 505 can refer to the above Figure 2 The corresponding steps of the described homomorphic encryption processing method will not be repeated here.
[0110] It can be seen that the homomorphic encryption processing method described in the embodiment of the present application uses the addition operation between the plaintext to be encrypted and a specific ciphertext (zero ciphertext) to encrypt the plaintext, thereby replacing the modular exponentiation operation in the encryption process with a modular multiplication operation, reducing the direct modular exponentiation operation, and realizing an efficient and lossless homomorphic encryption scheme, thereby improving the training efficiency of federated learning. At the same time, considering the security of the encryption scheme, in the embodiment of the present application, the encryption process of the plaintext is split into two parts: specific ciphertext generation and ciphertext addition, and the generation of the specific ciphertext does not depend on the plaintext data to be encrypted, so it can be completed offline. The random encryption algorithm based on the offline specific ciphertext generation and online plaintext encryption can still meet the CPA (chosen plaintext attack) security requirements.
[0111] In accordance with the above embodiment, please refer to Figure 6 , Figure 6 : is a structural diagram of an electronic device provided in an embodiment of the present application. As shown in the figure, the electronic device includes a processor, a memory, a communication interface, and one or more programs, which are applied to the electronic device. The one or more programs are stored in the memory and configured to be executed by the processor. In the embodiment of the present application, the program includes instructions for executing the following steps:
[0112] Read the first zero ciphertext, and obtain the most recently retained P second zero ciphertexts, where P is a positive integer;
[0113] detecting whether the first zero ciphertext is a new zero ciphertext;
[0114] When the first zero ciphertext is a new zero ciphertext, encrypting the plaintext to be encrypted according to the first zero ciphertext to obtain a first ciphertext;
[0115] When the first zero ciphertext is not a new zero ciphertext, selecting Q second zero ciphertexts from the P second zero ciphertexts, where Q is a positive integer less than or equal to P;
[0116] The plaintext to be encrypted is encrypted according to the Q second zero ciphertexts to obtain a second ciphertext.
[0117] Optionally, in the aspect of obtaining the most recently retained P second zero ciphertexts, the program includes instructions for performing the following steps:
[0118] The P second zero ciphertexts are obtained from a ciphertext storage center, wherein the ciphertext storage center pre-stores M second zero ciphertexts, wherein each of the M second zero ciphertexts is obtained by encrypting 0 by a zero ciphertext system using a public key, and M is a positive integer greater than or equal to P.
[0119] Optionally, the public key is a homomorphic encryption public key, which is generated by a key generation center.
[0120] Optionally, the zero ciphertext system is an offline system or an online system.
[0121] Optionally, in the aspect of selecting Q second zero ciphertexts from the P second zero ciphertexts, the program includes instructions for performing the following steps:
[0122] Obtaining target attribute information of the plaintext to be encrypted;
[0123] Determine the number of second zero ciphertexts corresponding to the target attribute information to obtain Q;
[0124] The Q second zero ciphertexts are selected from the P second zero ciphertexts.
[0125] Optionally, in the aspect of encrypting the plaintext to be encrypted according to the Q second zero ciphertexts to obtain the second ciphertext, the program includes instructions for executing the following steps:
[0126] Divide the plaintext to be encrypted into N sub-plaintexts, where N is an integer greater than 1, and Q is greater than or equal to N;
[0127] Dividing the Q second zero ciphertexts into N zero ciphertext groups, each zero ciphertext group including at least one second zero ciphertext;
[0128] Encrypting the N sub-plaintexts according to the N zero ciphertext groups to obtain N ciphertexts;
[0129] The second ciphertext is determined according to the N ciphertexts.
[0130] It can be seen that the electronic device described in the embodiment of the present application reads the first zero ciphertext and obtains the most recently retained P second zero ciphertexts, where P is a positive integer, to detect whether the first zero ciphertext is a new zero ciphertext. When the first zero ciphertext is a new zero ciphertext, the encrypted plaintext is encrypted according to the first zero ciphertext to obtain the first ciphertext. When the first zero ciphertext is not a new zero ciphertext, Q second zero ciphertexts are selected from the P second zero ciphertexts, where Q is a positive integer less than or equal to P, and the encrypted plaintext is encrypted according to the Q second zero ciphertexts to obtain the second ciphertext. In the homomorphic encryption process, since zero ciphertext is used to implement encryption, the modular exponentiation operation in the encryption process can be replaced by a modular multiplication operation, thereby reducing direct modular exponentiation operations, achieving efficient and lossless homomorphic encryption, and improving encryption efficiency.
[0131] Figure 7 700 is a functional unit block diagram of a homomorphic encryption processing device 700 involved in an embodiment of the present application. The homomorphic encryption processing device 700 is applied to an electronic device, and the device 700 includes: a zero ciphertext acquisition unit 701, a detection unit 702, a first encryption unit 703 and a second encryption unit 704, wherein:
[0132] The zero ciphertext acquisition unit 701 is used to read the first zero ciphertext and acquire the most recently retained P second zero ciphertexts, where P is a positive integer;
[0133] The detection unit 702 is used to detect whether the first zero ciphertext is a new zero ciphertext;
[0134] The first encryption unit 703 is configured to encrypt the plaintext to be encrypted according to the first zero ciphertext to obtain a first ciphertext when the first zero ciphertext is a new zero ciphertext;
[0135] The second encryption unit 704 is used to select Q second zero ciphertexts from the P second zero ciphertexts when the first zero ciphertext is not a new zero ciphertext, where Q is a positive integer less than or equal to P; and encrypt the plaintext to be encrypted according to the Q second zero ciphertexts to obtain a second ciphertext.
[0136] Optionally, in the aspect of obtaining the most recently retained P second zero ciphertexts, the zero ciphertext obtaining unit 701 is specifically used to:
[0137] The P second zero ciphertexts are obtained from a ciphertext storage center, wherein the ciphertext storage center pre-stores M second zero ciphertexts, wherein each of the M second zero ciphertexts is obtained by encrypting 0 by a zero ciphertext system using a public key, and M is a positive integer greater than or equal to P.
[0138] Optionally, the public key is a homomorphic encryption public key, which is generated by a key generation center.
[0139] Optionally, the zero ciphertext system is an offline system or an online system.
[0140] Optionally, in the aspect of selecting Q second zero ciphertexts from the P second zero ciphertexts, the second encryption unit 704 is specifically used to:
[0141] Obtaining target attribute information of the plaintext to be encrypted;
[0142] Determine the number of second zero ciphertexts corresponding to the target attribute information to obtain Q;
[0143] The Q second zero ciphertexts are selected from the P second zero ciphertexts.
[0144] Optionally, in the aspect of encrypting the plaintext to be encrypted according to the Q second zero ciphertexts to obtain the second ciphertext, the second encryption unit 704 is specifically used to:
[0145] Divide the plaintext to be encrypted into N sub-plaintexts, where N is an integer greater than 1, and Q is greater than or equal to N;
[0146] Dividing the Q second zero ciphertexts into N zero ciphertext groups, each zero ciphertext group including at least one second zero ciphertext;
[0147] Encrypting the N sub-plaintexts according to the N zero ciphertext groups to obtain N ciphertexts;
[0148] The second ciphertext is determined according to the N ciphertexts.
[0149] It can be seen that the homomorphic encryption processing device described in the embodiment of the present application reads the first zero ciphertext and obtains the most recently retained P second zero ciphertexts, where P is a positive integer, to detect whether the first zero ciphertext is a new zero ciphertext. When the first zero ciphertext is a new zero ciphertext, the encrypted plaintext is encrypted according to the first zero ciphertext to obtain the first ciphertext. When the first zero ciphertext is not a new zero ciphertext, Q second zero ciphertexts are selected from the P second zero ciphertexts, where Q is a positive integer less than or equal to P, and the encrypted plaintext is encrypted according to the Q second zero ciphertexts to obtain the second ciphertext. In the homomorphic encryption process, since zero ciphertext is used to implement encryption, the modular exponentiation operation in the encryption process can be replaced by a modular multiplication operation, thereby reducing direct modular exponentiation operations, achieving efficient and lossless homomorphic encryption, and improving encryption efficiency.
[0150] It can be understood that the functions of each program module of the homomorphic encryption processing device of this embodiment can be specifically implemented according to the method in the above-mentioned method embodiment, and its specific implementation process can refer to the relevant description of the above-mentioned method embodiment, which will not be repeated here.
[0151] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.
[0152] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.
[0153] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0154] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0155] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0156] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0157] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0158] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the above-mentioned methods in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0159] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable memory, which may include a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0160] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A homomorphic encryption processing method, characterized in that: The method comprises: Read the first zero ciphertext, and obtain the most recently retained P second zero ciphertexts, where the first zero ciphertext and the second zero ciphertext are both ciphertexts obtained by encrypting 0 with a public key, and P is a positive integer; Detecting whether the first zero ciphertext is a new zero ciphertext, wherein the new zero ciphertext is a zero ciphertext that has not been used; When the first zero ciphertext is a new zero ciphertext, encrypting the plaintext to be encrypted according to the first zero ciphertext to obtain a first ciphertext; When the first zero ciphertext is not a new zero ciphertext, selecting Q second zero ciphertexts from the P second zero ciphertexts, where Q is a positive integer less than or equal to P; The plaintext to be encrypted is encrypted according to the Q second zero ciphertexts to obtain a second ciphertext. Specifically, when Q is 1, the second zero ciphertext is added to the plaintext to be encrypted to obtain the second ciphertext; when Q is greater than 1, the plaintext to be encrypted is divided into Q segments, each segment corresponds to a second zero ciphertext, each second zero ciphertext is added to the plaintext to be encrypted of the corresponding segment, and then the encrypted plaintexts are spliced to obtain the second ciphertext.
2. The method according to claim 1, characterized in that The obtaining of the most recently retained P second zero ciphertexts includes: The P second zero ciphertexts are obtained from a ciphertext storage center, wherein the ciphertext storage center pre-stores M second zero ciphertexts, wherein each of the M second zero ciphertexts is obtained by encrypting 0 by a zero ciphertext system using a public key, and M is a positive integer greater than or equal to P.
3. The method according to claim 2, characterized in that The public key is a homomorphic encryption public key, which is generated by a key generation center.
4. The method according to claim 2 or 3, characterized in that: The zero ciphertext system is an offline system or an online system.
5. The method according to any one of claims 1 to 3, characterized in that: The step of selecting Q second zero ciphertexts from the P second zero ciphertexts comprises: Obtaining target attribute information of the plaintext to be encrypted; Determine the number of second zero ciphertexts corresponding to the target attribute information to obtain Q; The Q second zero ciphertexts are selected from the P second zero ciphertexts.
6. A homomorphic encryption processing device, characterized in that: The device comprises: a zero ciphertext obtaining unit, a detection unit, a first encryption unit and a second encryption unit, wherein: The zero ciphertext acquisition unit is used to read the first zero ciphertext and acquire the most recently retained P second zero ciphertexts, where the first zero ciphertext and the second zero ciphertext are both ciphertexts obtained by encrypting 0 with a public key, and P is a positive integer; The detection unit is used to detect whether the first zero ciphertext is a new zero ciphertext, and the new zero ciphertext is a zero ciphertext that has not been used; The first encryption unit is configured to encrypt the plaintext to be encrypted according to the first zero ciphertext to obtain a first ciphertext when the first zero ciphertext is a new zero ciphertext; The second encryption unit is used to select Q second zero ciphertexts from the P second zero ciphertexts when the first zero ciphertext is not a new zero ciphertext, where Q is a positive integer less than or equal to P; and to encrypt the plaintext to be encrypted according to the Q second zero ciphertexts to obtain a second ciphertext, specifically: when Q is 1, add the second zero ciphertext to the plaintext to be encrypted to obtain the second ciphertext; when Q is greater than 1, divide the plaintext to be encrypted into Q segments, each segment corresponds to a second zero ciphertext, add each second zero ciphertext to the plaintext to be encrypted of the corresponding segment, and then splice these encrypted plaintexts to obtain the second ciphertext.
7. The device according to claim 6, characterized in that In the aspect of obtaining the most recently retained P second zero ciphertexts, the zero ciphertext obtaining unit is specifically used for: The P second zero ciphertexts are obtained from a ciphertext storage center, wherein the ciphertext storage center pre-stores M second zero ciphertexts, wherein each of the M second zero ciphertexts is obtained by encrypting 0 by a zero ciphertext system using a public key, and M is a positive integer greater than or equal to P.
8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store one or more programs and is configured to be executed by the processor, wherein the program comprises instructions for executing the steps in the method according to any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that: A computer program for electronic data exchange is stored, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Homomorphic encryption processing method and related equipment
CN113965314A