A homomorphic encryption-based federated learning method and a related device thereof

By using the Paillier algorithm in federated learning to perform integer concatenation and unpacking of gradient values, the problems of data security and privacy protection in existing technologies are solved, and model updates with higher accuracy and security are achieved.

CN116451804BActive Publication Date: 2026-05-15SHANGHAI HOMO STATE INFORMATION TECH CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANGHAI HOMO STATE INFORMATION TECH CO LTD
Filing Date
2023-03-28
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing federated machine learning methods have shortcomings in data security and privacy protection, especially since homomorphic encryption algorithms cannot support scalar multiplication operations and pose risks when the server is untrusted.

Method used

The Paillier algorithm is used for packing, encrypting, and decrypting gradient values. Key pairs are used to concatenate and depacket integer gradient values. The algorithm supports scalar multiplication and homomorphic operations on the aggregation server, ensuring data privacy and model accuracy.

Benefits of technology

It improves the accuracy and security of models in the federated learning process, ensures the protection of data privacy, and avoids the risks brought by untrusted servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116451804B_ABST
    Figure CN116451804B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of data processing, and provides a federated learning method based on homomorphic encryption and a related device thereof, which comprises: obtaining a key pair and aggregated weight information; obtaining a local gradient value by using an initial federated learning model and training data pre-stored in a client; packing the local gradient value by using a preset homomorphic encryption algorithm, encrypting the packed gradient value based on the key pair, and sending the encrypted gradient value to an aggregation server; obtaining an aggregated gradient value in the aggregation server, decrypting the aggregated gradient value based on the key pair, unpacking the decrypted aggregated gradient value by using the preset homomorphic encryption algorithm, and updating the initial federated learning model based on the unpacked aggregated gradient value to obtain a global model. The present application can support number multiplication homomorphism in the aggregation process of the aggregation server, so as to improve the accuracy of the final local model, and also ensures the security in the federated learning process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic digital data processing technology, and in particular to a federated learning method based on homomorphic encryption and related equipment. Background Technology

[0002] Federated machine learning is a machine learning framework that effectively solves the data silo problem, allowing participants to jointly build models without sharing data. It technically breaks down data silos and enables AI collaboration. Because federated machine learning requires cross-organizational data sharing and fusion, it has certain requirements regarding data security.

[0003] Currently, privacy-preserving computation methods applied in federated machine learning mainly include differential privacy, homomorphic encryption, secure multi-party computation (MPC), and secure aggregation. Differential privacy exposes ordinary gradients to the central server during aggregation, and information can be easily recovered from the gradients. Secure MPC requires carefully designed computation and synchronization protocols between clients. While these protocols can guarantee privacy, they are difficult to implement in practice, especially in geographically distributed scenarios. Furthermore, the need to redesign existing machine learning frameworks or algorithms and partition computation between the two parties to adapt to the MPC paradigm may compromise privacy guarantees when performance is considered. In secure aggregation algorithms, the aggregator can see the aggregated gradient, and clients must synchronize keys and zero-sum masks for each iteration, placing high demands on synchronous training. Existing homomorphic encryption algorithms only support addition in their packing schemes and cannot homomorphically compute scalar multiplication, thus breaking the homomorphism of scalar multiplication. Moreover, existing homomorphic encryption algorithms rely on the server designating a leader, which can pose vulnerabilities if the server is untrusted. Summary of the Invention

[0004] This invention provides a federated learning method and related equipment based on homomorphic encryption to address the shortcomings of existing technologies.

[0005] This invention provides a federated learning method based on homomorphic encryption, which is applied to multiple clients, including:

[0006] Obtain key pairs and aggregate weight information;

[0007] Local gradient values ​​are obtained using the initial federated learning model and training data pre-stored in the client.

[0008] The local gradient values ​​are packaged using a preset homomorphic encryption algorithm, the packaged gradient values ​​are encrypted based on the key pair, and the encrypted gradient values ​​are sent to the aggregation server; wherein, the preset homomorphic encryption algorithm is the Paillier algorithm;

[0009] The aggregation server obtains the aggregated gradient value after aggregating the encrypted gradient values ​​obtained from multiple clients and the aggregation weight information. The aggregated gradient value is decrypted based on the key pair. The decrypted aggregated gradient value is unpacked using the preset homomorphic encryption algorithm. The initial federated learning model is updated based on the unpacked aggregated gradient value to obtain the global model.

[0010] According to the federated learning method based on homomorphic encryption provided by the present invention, the step of packaging the local gradient values ​​using a preset homomorphic encryption algorithm includes:

[0011] Scaling the local gradient values ​​that are of floating-point data type yields scaled gradient values.

[0012] The scaled gradient value is scaled again based on the length information of the key pair, the precision requirement of the local gradient value, and the preset carry position information to obtain an integer gradient value.

[0013] Based on the length information of the key pair, all the gradient values ​​of the integers are concatenated to obtain the concatenated integer as the packaged gradient value.

[0014] According to a federated learning method based on homomorphic encryption provided by the present invention, the scaling of local gradient values ​​of data type floating-point to obtain scaled gradient values ​​includes:

[0015] Obtain the exponent information i and the sign information s corresponding to the local gradient value of the floating-point number;

[0016] Based on the local gradient value 'a' of the floating-point number, the scaled gradient value 'b' is calculated according to the exponent information 'i' and the sign information 's': b = a * 10 i *s.

[0017] According to a federated learning method based on homomorphic encryption provided by the present invention, the step of further scaling the scaled gradient value according to the length information of the key pair, the precision requirement of the local gradient value, and the preset carry position information to obtain an integer gradient value includes:

[0018] The first scaling factor is determined based on the length information of the key pair and the accuracy requirement of the local gradient value;

[0019] The first scaling factor is used to scale the scaled gradient value and then round it to obtain an initial integer gradient value.

[0020] The second scaling factor is determined based on the preset carry position information, and the gradient value of the initial integer is scaled using the second scaling factor to obtain the gradient value of the integer.

[0021] According to a federated learning method based on homomorphic encryption provided by the present invention, the step of unpacking the decrypted aggregated gradient value using the preset homomorphic encryption algorithm includes:

[0022] By comparing the encrypted gradient value with the decrypted aggregated gradient value, aggregated gradient carry information is obtained;

[0023] The decrypted aggregated gradient value is depacked based on the aggregated gradient carry information, the length information of the key pair, the precision requirement of the local gradient value, and the preset carry position information, thereby obtaining multiple initial depacked gradient values.

[0024] The initial unpacked gradient value is restored based on the exponential information i and the positive / negative sign information s to obtain the final unpacked aggregated gradient value.

[0025] According to a federated learning method based on homomorphic encryption provided by the present invention, the step of obtaining key pairs and aggregated weight information includes:

[0026] Key pairs and aggregated weight information are obtained from a trusted third party, wherein the key pair includes a public key and a private key, which are obtained through a preset homomorphic encryption algorithm, including:

[0027] Randomly generate a first prime number p and a second prime number q;

[0028] The product of the first prime number p and the second prime number q is used as the first component N of the public key;

[0029] Calculate the least common multiple between the value of the first prime number p minus 1 and the value of the second prime number q minus 1, thereby obtaining the first component λ of the key;

[0030] A second component g of the public key is randomly generated, which satisfies g∈Z*N^2 and gcd(L(g λ modN 2 ),N)=1;

[0031] Based on the first component N of the public key, the second component g of the public key, and the first component λ of the key, the second component μ of the key is obtained: μ = (L(g) λ modN 2 )) -1 modN.

[0032] This invention also provides a homomorphic encryption-based federated learning method, which is applied in an aggregation server and includes:

[0033] The encrypted gradient values ​​and aggregated weight information are obtained from multiple clients. All encrypted gradient values ​​are aggregated according to the aggregated weight information to obtain aggregated gradient values, and the aggregated gradient values ​​are sent to each client.

[0034] This invention also provides a homomorphic encryption-based federated learning system, which is applied to multiple clients, including:

[0035] The initial information acquisition module is used to acquire key pairs and aggregate weight information;

[0036] The gradient value acquisition module is used to obtain local gradient values ​​using the initial federated learning model and training data pre-stored in the client.

[0037] The data packaging and encryption module is used to package the local gradient values ​​using a preset homomorphic encryption algorithm, encrypt the packaged gradient values ​​based on the key pair, and send the encrypted gradient values ​​to the aggregation server; wherein, the preset homomorphic encryption algorithm is the Paillier algorithm.

[0038] The data decryption and unpacking module is used to obtain the aggregated gradient value after the aggregation server performs aggregation processing based on the encrypted gradient value obtained from multiple clients and the aggregation weight information, decrypt the aggregated gradient value based on the key pair, unpack the decrypted aggregated gradient value using the preset homomorphic encryption algorithm, and update the initial federated learning model based on the unpacked aggregated gradient value to obtain the global model.

[0039] This invention also provides a homomorphic encryption-based federated learning system, which is applied in an aggregation server and includes:

[0040] The aggregation module is used to obtain encrypted gradient values ​​and aggregated weight information from multiple clients, aggregate all encrypted gradient values ​​according to the aggregated weight information to obtain aggregated gradient values, and send the aggregated gradient values ​​to each client.

[0041] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the federated learning method based on homomorphic encryption as described above.

[0042] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the federated learning method based on homomorphic encryption as described above.

[0043] The federated learning method based on homomorphic encryption provided by this invention, along with its related equipment, utilizes the Paillier algorithm to package and encrypt gradient values ​​in the client, and decrypt and unpack the aggregated gradient values ​​sent by the aggregation server. This supports scalar multiplication homomorphism in the aggregation process of the aggregation server, thereby improving the accuracy of the final global model and ensuring the security of the federated learning process. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0045] Figure 1 This is one of the flowcharts of the federated learning method based on homomorphic encryption provided by the present invention;

[0046] Figure 2 This is the second flowchart of the federated learning method based on homomorphic encryption provided by the present invention;

[0047] Figure 3 This is one of the structural diagrams of the federated learning system based on homomorphic encryption provided by the present invention;

[0048] Figure 4 This is the second schematic diagram of the structure of the federated learning system based on homomorphic encryption provided by the present invention;

[0049] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0050] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0051] Before describing the federated learning method based on homomorphic encryption provided by this invention, the technical terms mentioned in the embodiments of this invention will be explained.

[0052] Homomorphic encryption (HE) refers to encryption algorithms that satisfy the property of homomorphic operation on ciphertext. That is, after data is homomorphically encrypted, a specific calculation is performed on the ciphertext. The ciphertext calculation result, after being homomorphically decrypted, is equivalent to performing the same calculation directly on the plaintext data, thus achieving "computable but invisible" data.

[0053] If a homomorphic encryption algorithm supports arbitrary computations on ciphertext, it is called a fully homomorphic encryption (FHE). Generally speaking, since any computation can be constructed using addition and multiplication, if an encryption algorithm satisfies both additive and multiplicative homomorphism, it can be said to satisfy full homomorphism.

[0054] Federated learning is a distributed machine learning framework with privacy protection and secure encryption technology. It aims to enable decentralized participants to collaborate on training machine learning models without disclosing their private data to other participants.

[0055] The training process of the classic federated learning framework can be simply summarized as follows:

[0056] 1. The coordinating party establishes a basic model and informs all participating parties of the model's basic structure and parameters;

[0057] 2. Each participating party uses local data to train the model and returns the results to the coordinator;

[0058] 3. The coordinator summarizes the models from all participating parties to build a more accurate global model, thereby improving the overall model performance and effectiveness.

[0059] Federated learning frameworks encompass various technologies, including traditional machine learning model training techniques, algorithms for coordinating parameter integration, efficient communication technologies for transmission between coordinators and participants, and privacy-preserving encryption technologies. Currently, the four main privacy-preserving computation methods used in machine learning are: differential privacy, homomorphic encryption, secure multi-party computation, and secure aggregation.

[0060] In homomorphic encryption, a privacy-preserving computation method, BatchCrypt is a federated learning framework based on Paillier homomorphic encryption. However, BatchCrypt only supports addition and cannot homomorphically compute scalar multiplication, thus breaking the original homomorphic property of scalar multiplication in Paillier. Furthermore, BatchCrypt can only have its leader designated by the server; if the server is untrusted, potential vulnerabilities may exist.

[0061] To address the aforementioned problems, this invention provides a federated learning method based on homomorphic encryption, which will be described in detail below with reference to the accompanying drawings.

[0062] Figure 1 This is one of the flowcharts illustrating the federated learning method based on homomorphic encryption provided by this invention, such as... Figure 1 As shown, a federated learning method based on homomorphic encryption is applied to multiple clients and includes the following steps:

[0063] S101, obtain the key pair and aggregate weight information.

[0064] In this step, key pairs and aggregate weight information are obtained from a trusted third party, or they can be obtained from a leader specified by the aggregation server. Here, the specified leader refers to one determined from multiple clients.

[0065] Furthermore, the aggregated weights are the weights of the gradient values ​​from each client during the aggregation process, rather than the weights in the trained model. These aggregated weights are determined using common weighting methods based on subjective weighting and expert scoring, such as the Analytic Hierarchy Process (AHP). The key pair is obtained from the `paillier.generate_paillier_keypair()` function in Python's PHE library, which is set up in a trusted third party or a designated leader.

[0066] S102 uses the initial federated learning model and training data pre-stored in the client to obtain local gradient values.

[0067] In this step, the initial federated learning model in each client is trained and updated using the training data. The gradient values ​​obtained during the training and update process are local gradient values ​​compared to the aggregated gradient values.

[0068] It should be noted that the initial federated learning model in this invention can be a network model related to image processing or a network model related to natural language processing; this invention does not limit it in this respect.

[0069] S103, the local gradient values ​​are packaged using a preset homomorphic encryption algorithm, the packaged gradient values ​​are encrypted based on the key pair, and the encrypted gradient values ​​are sent to the aggregation server.

[0070] The preset homomorphic encryption algorithm is the Paillier algorithm.

[0071] In this step, the present invention packages the local gradient values ​​generated in the client based on the floating-point nature of the gradient values ​​and the characteristics of the Paillier algorithm to obtain integer packaged gradient values. These packaged gradient values ​​are then encrypted using a key pair and sent to the aggregation server. The specific packaging process is described below.

[0072] S104, obtain the aggregated gradient value after the aggregation server performs aggregation processing based on the encrypted gradient values ​​obtained from multiple clients and the aggregation weight information, decrypt the aggregated gradient value based on the key pair, decompress the decrypted aggregated gradient value using the preset homomorphic encryption algorithm, and update the initial federated learning model based on the decompressed aggregated gradient value to obtain the global model.

[0073] In this step, the client obtains the aggregated gradient value from the aggregation server. This aggregated gradient value is obtained by directly calculating the weighted average of the encrypted integer gradient value. It does not require decryption of the encrypted integer gradient value. Furthermore, the weighted averaging process supports scalar multiplication homomorphism, ensuring that the final aggregated gradient value has the characteristic of homomorphism. This not only makes the aggregation process more private but also ensures that the final global model is more accurate.

[0074] After receiving the aggregated gradient value sent by the aggregation server, the client decrypts and unpacks the aggregated gradient value using the previous key pair and information from the packaging process, thereby obtaining the unpacked aggregated gradient value. Based on the aggregated gradient value, the client upgrades and updates the initial federated learning model to obtain the global model and realize federated learning.

[0075] The federated learning method based on homomorphic encryption provided by the present invention utilizes the Paillier algorithm to package and encrypt gradient values ​​in the client, and to decrypt and unpack the aggregated gradient values ​​sent by the aggregation server, thereby supporting scalar multiplication homomorphism in the aggregation process of the aggregation server, improving the accuracy of the final global model, and ensuring the security of the federated learning process.

[0076] Furthermore, based on the above embodiments, the step of packaging the local gradient values ​​using a preset homomorphic encryption algorithm includes:

[0077] Scaling is performed on the local gradient values ​​that are of floating-point data type to obtain the scaled gradient values.

[0078] More specifically, first obtain the exponent information i and the positive / negative sign information s corresponding to the local gradient value of the floating-point number.

[0079] Then, based on the local gradient value a of the floating-point number, the scaled gradient value b is calculated according to the exponent information i and the sign information s: b = a * 10 i *s.

[0080] For example, assuming the gradient value is 0.0093653 (in reality, this is a 64-bit floating-point number, but we'll use this as an example for simplicity), then the exponent information *i* of this gradient value is 3, which is the number of zeros before the significant digit "9". The sign information *s* means that *s* is 1 when the gradient value is positive and -1 when the gradient value is negative. Based on this, in this case, *b* = 0.0093653 * 10^3 * 1 = 9.3653.

[0081] The scaled gradient value is scaled again based on the length information of the key pair, the accuracy requirement of the local gradient value, and the preset carry position information to obtain an integer gradient value.

[0082] Specifically, the first scaling factor is determined based on the length information of the key pair and the accuracy requirements of the local gradient value.

[0083] Then, the scaled gradient value is scaled using the first scaling factor and rounded to obtain the initial integer gradient value.

[0084] Finally, a second scaling factor is determined based on the preset carry position information, and the gradient value of the initial integer is scaled using the second scaling factor to obtain the gradient value of the integer.

[0085] In this embodiment, the key pair length information refers to the security key length of 2048 corresponding to the Paillier algorithm. The precision requirement of the local gradient value refers to the precision requirement for retaining the local gradient value (i.e., not completely retaining the 64-bit gradient value). Taking into account both the security key length of 2048 and the 64-bit gradient value, it is determined that the scaled gradient value will be scaled again to an integer of about 60 bits, that is, the first scaling factor is 10^64, so that a packet with one security key length can hold 32 gradient values ​​(2048 = 64 * 32).

[0086] After obtaining the first scaling factor, the scaled gradient value is scaled and rounded to obtain the initial integer gradient value. Then, the initial integer gradient value is scaled again according to the second scaling factor. This second scaling factor is determined based on preset carry-in information. The preset carry-in information refers to situations where data carry-in occurs during gradient value aggregation. For example, a weighted average of three-digit gradient values ​​becomes a four-digit number. If the extra digits at the carry-in position are not retained, they will cover surrounding values, resulting in incomplete aggregated gradient values. The specific carry-in information can be set according to requirements, such as retaining 1 carry-in position (i.e., the second scaling factor is 10^1), 2 carry-in positions (i.e., the second scaling factor is 10^2), 3 carry-in positions (i.e., the second scaling factor is 10^3), etc. This invention determines to retain 3 carry-in positions based on the actual situation of the gradient value, that is, the second scaling factor is 10^3.

[0087] It should be noted that the first and second scaling factors mentioned above can be adjusted according to actual needs. In determining the first scaling factor, if fewer bits are retained for the local gradient values, the number of local gradient values ​​included in each data packet increases, resulting in a smaller first scaling factor. While this reduces computation, it sacrifices accuracy. Conversely, if the first scaling factor is set large enough, while maintaining gradient accuracy, the computational load is higher, requiring adjustment based on specific needs.

[0088] Based on the length information of the key pair, all the gradient values ​​of the integers are concatenated to obtain the concatenated integer as the packaged gradient value.

[0089] After obtaining the final integer gradient value, the final integer gradient value is concatenated according to the length information of the key pair. That is, the integer gradient value is packaged according to the length of the key pair 2048, resulting in multiple data packets. After concatenating all the data packets, a large integer is obtained. This large integer is then encrypted, and the subsequent aggregation server directly performs a weighted average calculation based on the encrypted large integer.

[0090] The federated learning method based on homomorphic encryption provided in this embodiment of the invention can support scalar multiplication homomorphism in the aggregation process of the aggregation server, thereby improving the accuracy of the final local model and ensuring the security of the federated learning process.

[0091] Furthermore, based on the above embodiments, the step of unpacking the decrypted aggregate gradient value using the preset homomorphic encryption algorithm includes:

[0092] By comparing the encrypted gradient value with the decrypted aggregated gradient value, the carry information of the aggregated gradient is obtained. That is, by comparing the data in the reserved carry position of the packaged gradient value with the data in the decrypted aggregated gradient value, if the value of the reserved carry position changes from 0 to non-zero, it indicates that a carry has occurred.

[0093] It should be noted that if the first gradient value has a carry, the number of bits in the decrypted aggregate gradient value will be higher than the number of bits in the original gradient value (i.e., the encrypted gradient value).

[0094] The decrypted aggregated gradient value is decompressed based on the aggregated gradient carry information, the key pair length information, the local gradient value precision requirements, and the preset carry position information, thereby obtaining multiple initial decompressed gradient values. In other words, the initial decompressed gradient values ​​are obtained from the decrypted aggregated gradient value based on the previously determined first and second scaling factors.

[0095] The initial unpacked gradient value is restored based on the exponential information i and the positive / negative sign information s to obtain the final unpacked aggregated gradient value.

[0096] For example, suppose the decrypted aggregate gradient value is 500000032000002040000, the local gradient values ​​'a' are 0.005, -0.021, and 0.301, and the gradient values ​​'b' after the first scaling are 5, 2.1, and 3.01. Assume the first scaling factor is 10^4 and the second scaling factor is 10^3. Then the integer gradient values ​​are 5000000, 2100000, and 3010000, and the packaged gradient value is 500000021000003010000. Based on the above information, the gradient value of 5000000320000... The data 02040000 is unpacked. Based on the first scaling factor, four characters are extracted. Then, based on the second scaling factor, it is determined whether a carry occurs at the reserved carry position. If a carry occurs, the carry value is determined and combined with the next four characters extracted based on the first scaling factor. If no carry occurs, the data at the reserved carry position is ignored, and the process is repeated, extracting four characters based on the first scaling factor and then checking the next reserved carry position for a carry. This process is repeated until all data is extracted. The initial aggregated gradient values ​​after unpacking are 5000, 3200, and 2040. Finally, the gradient values ​​are restored based on the previously determined exponent information i and the positive / negative sign information s, resulting in 0.005, -0.032, and 0.204.

[0097] The federated learning method based on homomorphic encryption provided in this embodiment of the invention can support scalar multiplication homomorphism in the aggregation process of the aggregation server, thereby improving the accuracy of the final local model and ensuring the security of the federated learning process.

[0098] Furthermore, based on the above embodiments, obtaining the key pair and aggregate weight information includes:

[0099] Key pairs and aggregated weight information are obtained from a trusted third party, wherein the key pair includes a public key and a private key, which are obtained through a preset homomorphic encryption algorithm, including:

[0100] Randomly generate a first prime number p and a second prime number q;

[0101] The product of the first prime number p and the second prime number q is used as the first component N of the public key;

[0102] Calculate the least common multiple between the value of the first prime number p minus 1 and the value of the second prime number q minus 1, thereby obtaining the first component λ of the key;

[0103] A second component g of the public key is randomly generated, which satisfies g∈Z*N^2 and gcd(L(g λ modN 2 ),N)=1;

[0104] Based on the first component N of the public key, the second component g of the public key, and the first component λ of the key, the second component μ of the key is obtained: μ = (L(g) λ modN 2 )) -1 modN.

[0105] The federated learning method based on homomorphic encryption provided in this embodiment of the invention can further improve data security during the federated learning process.

[0106] Figure 2 This is the second flowchart of the federated learning method based on homomorphic encryption provided by this invention, as shown below. Figure 2 As shown, this federated learning method based on homomorphic encryption is applied to an aggregation server, including:

[0107] S201: Obtain encrypted gradient values ​​and aggregated weight information from multiple clients, aggregate all encrypted gradient values ​​according to the aggregated weight information to obtain aggregated gradient values, and send the aggregated gradient values ​​to each client.

[0108] In this embodiment, the aggregation weight information is set according to the number of clients. For example, if there are two clients, the aggregation weight for both clients is 0.5, meaning the gradient values ​​on each client are directly weighted and averaged. Alternatively, the aggregation weight information can be set according to requirements. For instance, if the aggregation weight for client A is set to 0.3 and the aggregation weight for client B is set to 0.7, then the aggregated gradient value = 0.3 * gradient value of client A + 0.7 * gradient value of client B.

[0109] The federated learning method based on homomorphic encryption provided in this embodiment of the invention can support scalar multiplication homomorphism in the aggregation process of the aggregation server, thereby improving the accuracy of the final local model and ensuring the security of the federated learning process.

[0110] The following describes the homomorphic encryption-based federated learning system provided by this invention. The homomorphic encryption-based federated learning system described below can be referred to in correspondence with the homomorphic encryption-based federated learning method described above.

[0111] Figure 3 This is one of the structural diagrams of the federated learning system based on homomorphic encryption provided by the present invention; for example... Figure 3 As shown, a federated learning system based on homomorphic encryption includes:

[0112] The initial information acquisition module 301 acquires key pairs and aggregate weight information.

[0113] In this module, key pairs and aggregate weight information are obtained from a trusted third party, or they can be obtained from a leader specified by the aggregation server. Here, the specified leader refers to one determined from multiple clients.

[0114] Furthermore, the aggregated weights are the weights of the gradient values ​​from each client during the aggregation process, rather than the weights in the trained model. These aggregated weights are determined using common weighting methods based on subjective weighting and expert scoring, such as the Analytic Hierarchy Process (AHP). The key pair is obtained from the `paillier.generate_paillier_keypair()` function in Python's PHE library, which is set up in a trusted third party or a designated leader.

[0115] The gradient value acquisition module 302 acquires local gradient values ​​using the initial federated learning model and training data pre-stored in the client.

[0116] In this module, the initial federated learning models in each client are trained and updated using the training data. The gradient values ​​obtained during the training and update process are local gradient values ​​compared to the aggregated gradient values.

[0117] It should be noted that the initial federated learning model in this invention can be a network model related to image processing or a network model related to natural language processing; this invention does not limit it in this respect.

[0118] The data packaging and encryption module 303 uses a preset homomorphic encryption algorithm to package the local gradient values, encrypts the packaged gradient values ​​based on the key pair, and sends the encrypted gradient values ​​to the aggregation server.

[0119] The preset homomorphic encryption algorithm is the Paillier algorithm.

[0120] In this module, the present invention packages the local gradient values ​​generated in the client based on the floating-point nature of the gradient values ​​and the characteristics of the Paillier algorithm to obtain integer packaged gradient values. These packaged gradient values ​​are then encrypted using a key pair and sent to the aggregation server. The specific packaging process is described below.

[0121] The data decryption and unpacking module 304 obtains the aggregated gradient value after the aggregation server performs aggregation processing based on the encrypted gradient value obtained from multiple clients and the aggregation weight information, decrypts the aggregated gradient value based on the key pair, unpacks the decrypted aggregated gradient value using the preset homomorphic encryption algorithm, and updates the initial federated learning model based on the unpacked aggregated gradient value to obtain the global model.

[0122] In this module, the client obtains the aggregated gradient value from the aggregation server. This aggregated gradient value is obtained by directly calculating the weighted average of the encrypted integer gradient value. It does not require decryption of the encrypted integer gradient value. Furthermore, the weighted averaging process supports scalar multiplication homomorphism, ensuring that the final aggregated gradient value has the characteristic of homomorphism. This not only makes the aggregation process more private but also ensures that the final global model is more accurate.

[0123] After receiving the aggregated gradient value sent by the aggregation server, the client decrypts and unpacks the aggregated gradient value using the previous key pair and information from the packaging process, thereby obtaining the unpacked aggregated gradient value. Based on the aggregated gradient value, the client upgrades and updates the initial federated learning model to obtain the global model and realize federated learning.

[0124] The federated learning system based on homomorphic encryption provided in this embodiment of the invention utilizes the Paillier algorithm to package and encrypt gradient values ​​in the client, and to decrypt and unpack the aggregated gradient values ​​sent by the aggregation server, thereby supporting scalar multiplication homomorphism in the aggregation process of the aggregation server, improving the accuracy of the final global model, and ensuring the security of the federated learning process.

[0125] Figure 4 This is the second schematic diagram of the structure of the federated learning system based on homomorphic encryption provided by this invention; as shown below. Figure 4 As shown, a federated learning system based on homomorphic encryption includes:

[0126] The aggregation module 401 obtains encrypted gradient values ​​and aggregated weight information from multiple clients, aggregates all encrypted gradient values ​​according to the aggregated weight information to obtain aggregated gradient values, and sends the aggregated gradient values ​​to each client.

[0127] In this embodiment, the aggregation weight information is set according to the number of clients. For example, if there are two clients, the aggregation weight for both clients is 0.5, meaning the gradient values ​​on each client are directly weighted and averaged. Alternatively, the aggregation weight information can be set according to requirements. For instance, if the aggregation weight for client A is set to 0.3 and the aggregation weight for client B is set to 0.7, then the aggregated gradient value = 0.3 * gradient value of client A + 0.7 * gradient value of client B.

[0128] The federated learning method based on homomorphic encryption provided in this embodiment of the invention can support scalar multiplication homomorphism in the aggregation process of the aggregation server, thereby improving the accuracy of the final local model and ensuring the security of the federated learning process.

[0129] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a homomorphic encryption-based federated learning method applied to multiple clients, including: obtaining key pairs and aggregated weight information; obtaining local gradient values ​​using an initial federated learning model and training data pre-stored in the client; packaging the local gradient values ​​using a preset homomorphic encryption algorithm, encrypting the packaged gradient values ​​based on the key pair, and sending the encrypted gradient values ​​to an aggregation server; wherein the preset homomorphic encryption algorithm is the Paillier algorithm; obtaining aggregated gradient values ​​after the aggregation server aggregates the encrypted gradient values ​​and aggregated weight information obtained from multiple clients, decrypting the aggregated gradient values ​​based on the key pair, unpacking the decrypted aggregated gradient values ​​using the preset homomorphic encryption algorithm, and updating the initial federated learning model based on the unpacked aggregated gradient values ​​to obtain a global model.

[0130] Alternatively, it can be used to execute a homomorphic encryption-based federated learning method applied on an aggregation server, comprising: obtaining encrypted gradient values ​​and aggregation weight information from multiple clients, aggregating all encrypted gradient values ​​according to the aggregation weight information to obtain aggregated gradient values, and sending the aggregated gradient values ​​to each client.

[0131] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0132] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, which, when executed by a computer, enable the computer to execute the homomorphic encryption-based federated learning method provided by the above methods. This homomorphic encryption-based federated learning method is applied to multiple clients, including: obtaining key pairs and aggregated weight information; obtaining local gradient values ​​using an initial federated learning model and training data pre-stored in the client; packaging the local gradient values ​​using a preset homomorphic encryption algorithm, encrypting the packaged gradient values ​​based on the key pair, and sending the encrypted gradient values ​​to an aggregation server; wherein the preset homomorphic encryption algorithm is the Paillier algorithm; obtaining aggregated gradient values ​​after the aggregation server aggregates the encrypted gradient values ​​and aggregated weight information obtained from multiple clients, decrypting the aggregated gradient values ​​based on the key pair, unpacking the decrypted aggregated gradient values ​​using the preset homomorphic encryption algorithm, and updating the initial federated learning model based on the unpacked aggregated gradient values ​​to obtain a global model.

[0133] Alternatively, it can be used to execute a homomorphic encryption-based federated learning method applied on an aggregation server, comprising: obtaining encrypted gradient values ​​and aggregation weight information from multiple clients, aggregating all encrypted gradient values ​​according to the aggregation weight information to obtain aggregated gradient values, and sending the aggregated gradient values ​​to each client.

[0134] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the aforementioned homomorphic encryption-based federated learning methods. These methods are applied across multiple clients and include: acquiring key pairs and aggregation weight information; acquiring local gradient values ​​using an initial federated learning model and training data pre-stored in the client; packaging the local gradient values ​​using a preset homomorphic encryption algorithm, encrypting the packaged gradient values ​​based on the key pair, and sending the encrypted gradient values ​​to an aggregation server; wherein the preset homomorphic encryption algorithm is the Paillier algorithm; acquiring aggregated gradient values ​​obtained by the aggregation server based on the encrypted gradient values ​​and aggregation weight information acquired from multiple clients, decrypting the aggregated gradient values ​​based on the key pair, unpacking the decrypted aggregated gradient values ​​using the preset homomorphic encryption algorithm, and updating the initial federated learning model based on the unpacked aggregated gradient values ​​to obtain a global model.

[0135] Alternatively, it can be used to execute a homomorphic encryption-based federated learning method applied on an aggregation server, comprising: obtaining encrypted gradient values ​​and aggregation weight information from multiple clients, aggregating all encrypted gradient values ​​according to the aggregation weight information to obtain aggregated gradient values, and sending the aggregated gradient values ​​to each client.

[0136] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0137] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A federated learning method based on homomorphic encryption, characterized in that, This homomorphic encryption-based federated learning method is applied to multiple clients, including: Obtain key pairs and aggregate weight information; Local gradient values ​​are obtained using the initial federated learning model and training data pre-stored in the client. The local gradient values ​​are packaged using a preset homomorphic encryption algorithm, the packaged gradient values ​​are encrypted based on the key pair, and the encrypted gradient values ​​are sent to the aggregation server; wherein, the preset homomorphic encryption algorithm is the Paillier algorithm; The aggregation server obtains the aggregated gradient value, which is the result of aggregating the encrypted gradient values ​​obtained from multiple clients and the aggregation weight information. The aggregated gradient value is then decrypted using the key pair. The decrypted aggregated gradient value is then unpacked using the preset homomorphic encryption algorithm. Finally, the initial federated learning model is updated based on the unpacked aggregated gradient value to obtain the global model. The step of packaging the local gradient values ​​using a preset homomorphic encryption algorithm includes: Scaling the local gradient values ​​that are of floating-point data type yields scaled gradient values. The scaled gradient value is scaled again based on the length information of the key pair, the precision requirement of the local gradient value, and the preset carry position information to obtain an integer gradient value. Based on the length information of the key pair, all the gradient values ​​of the integers are concatenated to obtain the concatenated integer as the packaged gradient value.

2. The federated learning method based on homomorphic encryption according to claim 1, characterized in that, The scaling of local gradient values ​​of floating-point data type to obtain scaled gradient values ​​includes: Obtain the exponent information i and the sign information s corresponding to the local gradient value of the floating-point number; Based on the local gradient value 'a' of the floating-point number, the scaled gradient value 'b' is calculated according to the exponent information 'i' and the sign information 's': b = a * 10 i *s.

3. The federated learning method based on homomorphic encryption according to claim 1, characterized in that, The step of scaling the scaled gradient value again based on the length information of the key pair, the precision requirement of the local gradient value, and the preset carry position information to obtain an integer gradient value includes: The first scaling factor is determined based on the length information of the key pair and the accuracy requirement of the local gradient value; The first scaling factor is used to scale the scaled gradient value and then round it to obtain an initial integer gradient value. The second scaling factor is determined based on the preset carry position information, and the gradient value of the initial integer is scaled using the second scaling factor to obtain the gradient value of the integer.

4. The federated learning method based on homomorphic encryption according to claim 2, characterized in that, The step of unpacking the decrypted aggregate gradient value using the preset homomorphic encryption algorithm includes: By comparing the encrypted gradient value with the decrypted aggregated gradient value, aggregated gradient carry information is obtained; The decrypted aggregated gradient value is depacked based on the aggregated gradient carry information, the length information of the key pair, the precision requirement of the local gradient value, and the preset carry position information, thereby obtaining multiple initial depacked gradient values. The initial unpacked gradient value is restored based on the exponential information i and the positive / negative sign information s to obtain the final unpacked aggregated gradient value.

5. The federated learning method based on homomorphic encryption according to any one of claims 1-4, characterized in that, The acquisition of key pairs and aggregated weight information includes: Key pairs and aggregated weight information are obtained from a trusted third party, wherein the key pair includes a public key and a private key, which are obtained through a preset homomorphic encryption algorithm, including: Randomly generate a first prime number p and a second prime number q; The product of the first prime number p and the second prime number q is used as the first component N of the public key; Calculate the least common multiple between the value of the first prime number p minus 1 and the value of the second prime number q minus 1, thereby obtaining the first component λ of the key; A second component g of the public key is randomly generated, which satisfies g∈Z*N^2 and gcd(L(g λ modN 2 ),N)=1; Based on the first component N of the public key, the second component g of the public key, and the first component λ of the key, the second component μ of the key is obtained: μ = (L(g) λ modN 2 )) -1 mod N, In the formula, Z is the set of integers, gcd() is the greatest common divisor function, L(x) = (x-1) / N is the function, and x is the independent variable.

6. A federated learning system based on homomorphic encryption, characterized in that, This homomorphic encryption-based federated learning system is used on multiple clients, including: The initial information acquisition module is used to acquire key pairs and aggregate weight information; The gradient value acquisition module is used to obtain local gradient values ​​using the initial federated learning model and training data pre-stored in the client. The data packaging and encryption module is used to package the local gradient values ​​using a preset homomorphic encryption algorithm, encrypt the packaged gradient values ​​based on the key pair, and send the encrypted gradient values ​​to the aggregation server; wherein, the preset homomorphic encryption algorithm is the Paillier algorithm. The data decryption and unpacking module is used to obtain the aggregated gradient value after the aggregation server has processed the encrypted gradient values ​​obtained from multiple clients and the aggregation weight information, decrypt the aggregated gradient value based on the key pair, unpack the decrypted aggregated gradient value using the preset homomorphic encryption algorithm, and update the initial federated learning model based on the unpacked aggregated gradient value to obtain the global model. The step of packaging the local gradient values ​​using a preset homomorphic encryption algorithm includes: Scaling the local gradient values ​​that are of floating-point data type yields scaled gradient values. The scaled gradient value is scaled again based on the length information of the key pair, the precision requirement of the local gradient value, and the preset carry position information to obtain an integer gradient value. Based on the length information of the key pair, all the gradient values ​​of the integers are concatenated to obtain the concatenated integer as the packaged gradient value.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the federated learning method based on homomorphic encryption as described in any one of claims 1 to 5.