Privacy protection anti-poisoning federal learning aggregation method and system and electronic equipment
By using the model anomaly detection algorithm of local differential privacy and homomorphic encryption technology in federated learning, combined with CKKS fully homomorphic encryption, the problems of privacy leakage and poisoning attacks in federated learning are solved, and the security protection and performance of model parameters are achieved. optimization.
Patent Information
- Application Number
- CN202410678188.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-08-23
AI Technical Summary
There are problems of privacy leakage and poisoning attacks in federated learning. It is difficult for existing technology to effectively protect model privacy and resist poisoning attacks at the same time.
Using the model anomaly detection algorithm based on local differential privacy and CKKS fully homomorphic encryption technology, the client performs differential privacy and homomorphic encryption processing locally, and the server uses the model anomaly detection algorithm to screen malicious models and assign aggregation weights to implement ciphertext models homomorphic aggregation.
It effectively prevents attackers from inferring private data, accurately detects and resists poisoning attacks, reduces model performance losses caused by differential privacy, and ensures the security of model parameters.
Smart Images

Figure CN118536621A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security technology, and in particular to a privacy-preserving anti-poisoning federated learning aggregation method, system and electronic equipment. Background Art
[0002] With the advent of the big data era, artificial intelligence technology has flourished. As the basic technology of artificial intelligence, machine learning is widely used in many fields such as image recognition, medical diagnosis, and autonomous driving. Traditional machine learning requires data to be collected to a central server for centralized training. However, the collected data often contains a lot of sensitive information, such as patient information in medical data. Once this sensitive information is leaked, it will cause damage to people's personal and property safety. At the same time, in order to obtain a better quality model, machine learning will collect a large amount of data for training and fusion, and the collection of a large amount of data means that more sensitive information is leaked. As the contradiction between the above data security issues and the data needs of machine learning intensifies, the development of machine learning technology is severely restricted.
[0003] Federated learning has emerged as data security and privacy issues become increasingly serious. Federated learning is a special distributed machine learning framework that enables multiple data holders to collaboratively train a machine learning model. Federated learning has a server and multiple clients (data holders). During the training process, the clients participating in federated learning do not need to share private data. They only need to use private data to train a local model locally, and then send the local model parameters to the server for aggregation. After several rounds of iterations, the final model trained jointly can be obtained.
[0004] Federated learning can satisfy the requirements of all parties to jointly model without snooping on the original data, which largely solves the problem of data privacy. However, with the deepening of research, the privacy leakage or model security issues in federated learning have also begun to slowly emerge. Although federated learning can avoid direct data leakage, the local model parameters of the client will lead to indirect data leakage. Studies have shown that attackers can infer the original private data of the client from the model parameter information shared by the client. In addition, the final model after training may also cause privacy leakage. The attacker only needs to obtain the final trained white box or black box model to extract the original data. Federated learning is also vulnerable to poisoning attacks. Since the clients participating in the training are not necessarily honest and reliable, some malicious clients may "poison" the local data or local model during the training process to reduce the availability of the model or even directly destroy the model.
[0005] For privacy leakage in federated learning, the main solutions are cryptographic federated learning solutions and perturbation-based federated learning solutions. Cryptographic federated learning solutions mainly use secure multiparty computation (SMPC) and homomorphic encryption (HE). Although these two technologies can avoid privacy leakage, the calculation is limited after parameter encryption, and the corresponding calculation under ciphertext will bring high computational cost, which greatly reduces the training efficiency; perturbation-based federated learning solutions mainly use differential privacy (DP) technology. Different from secure multiparty computation and homomorphic encryption, differential privacy is a technology that protects privacy by adding noise to parameters. Federated learning solutions based on differential privacy can avoid complex encryption and decryption processes, effectively prevent inference attacks, and protect data privacy, but the added noise often leads to poor performance of the final model. For poisoning attacks in federated learning, the main solution is currently a federated learning solution based on anomaly detection mechanism. Such solutions require corresponding calculations of model parameters, etc., and most of them cannot provide privacy protection for parameters during training. In the prior art, a Chinese patent with publication number CN 116796832 A discloses a highly available federated learning method in a personalized differential privacy scenario, but this method cannot distinguish between benign and malicious models, and it is difficult to effectively protect the privacy of the model and resist poisoning attacks.
[0006] In summary, the security and privacy issues in federated learning are already very serious. Therefore, it is urgent to propose a federated learning solution that can both protect model privacy and resist poisoning attacks. Summary of the invention
[0007] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a privacy-preserving anti-poisoning federated learning aggregation method, system and electronic device.
[0008] The purpose of the present invention can be achieved by the following technical solutions:
[0009] The present invention provides a privacy-preserving anti-poisoning federated learning aggregation method, comprising the following steps:
[0010] S1. The client decrypts the global model, and uses the global model and local data to optimize the model according to the loss function to obtain a new local optimal local model;
[0011] S2. The client uses a local training algorithm to perform differential privacy and homomorphic encryption on the local optimal local model to obtain a noisy local model and a ciphertext local model.
[0012] S3. The server uses a model anomaly detection algorithm according to the noise local model to filter out malicious local models, and assigns corresponding aggregation weights to the remaining local models;
[0013] S4. The server aggregates the local model of the ciphertext according to the weighted homomorphic aggregation algorithm to obtain the global model of the ciphertext.
[0014] The loss function optimization model is expressed by the following formula:
[0015]
[0016] Among them, w i is the local optimal local model, and B is Batch, which represents the training batch.
[0017] The noise local model is constructed by using the noise algorithm NoiceAdd(w i ) is obtained by performing differential privacy processing.
[0018] Furthermore, the specific steps of obtaining the noise local model are as follows:
[0019] The local optimal local model w i The L2 norm of is within a certain threshold C, which is expressed by the following formula:
[0020]
[0021] Define the client local model sensitivity as:
[0022] Δs i =2C / |D i |
[0023] Among them, |D i |For client C i The size of the private dataset.
[0024] The noise scale σ is set to:
[0025]
[0026] The client adds noise distribution to the trimmed local model parameters: Noise:
[0027]
[0028] Get the noise local model
[0029] The ciphertext local model is constructed by using the encryption algorithm Dec(w i ) is homomorphically encrypted to obtain the ciphertext local model.
[0030] Furthermore, the encryption algorithm Dec(w i ) specifically includes: using the CKKS encryption function Enc(x) to encrypt to obtain the ciphertext local model.
[0031] The step S3 specifically includes:
[0032] S31, calculating the noise local model The cosine similarity c between the local models and other noise i,j :
[0033]
[0034] S32, storing the cosine similarity in list c i =[c i,1 ,c i,2 ,...,c i,K ], and then initialize an aggregate similarity c for each client i,sum , list c i The sum of the elements greater than or equal to the median is denoted by c i,sum =c i,sum +c i,j ;
[0035] S33, store the aggregated similarity of each local model in list c sum =[c 1,sun ,c 2,sum ,...,c K,sum ]middle;
[0036] S34, according to list c sum The median value of evaluates the aggregate similarity of each client's local model. If the list c sum Medium Noise Local Model The aggregate similarity c i,sum Greater than the aggregate similarity list c sum If the local model is the median of , the local model is considered to be a benign model and its aggregate similarity remains unchanged; otherwise, it is considered to be a model with low contribution or malicious, and its aggregate similarity is set to 0:
[0037]
[0038] S35. Assign aggregation weight q to the local model according to the proportion of aggregation similarity i :
[0039]
[0040] The process in step S4 is expressed by the following formula:
[0041]
[0042] in, is the global model, q i is the aggregation weight, It is a ciphertext local model.
[0043] In a second aspect, the present invention provides a privacy-preserving and poison-resistant federated learning aggregation system, comprising a server, a client, and a homomorphic key distribution mechanism, wherein the system is used to implement any of the methods described above.
[0044] In a third aspect, the present invention provides an electronic device, comprising a memory, a processor, and a program stored in the memory, wherein the processor implements any of the above-described methods when executing the program.
[0045] Compared with the prior art, the present invention has the following beneficial effects:
[0046] (1) The present invention proposes a model anomaly detection algorithm based on local differential privacy, which sets aggregation weights based on differential privacy and cosine similarity. During the detection process, local differential privacy technology can ensure that attackers or semi-honest servers cannot infer private information in the local data set through local model parameters; at the same time, the detection algorithm can accurately detect whether the local model uploaded by the screening client is a malicious poisoning model, effectively resisting poisoning attacks.
[0047] (2) The present invention proposes a model aggregation algorithm based on homomorphic encryption. The present invention uses CKKS fully homomorphic encryption technology to encrypt the original model parameters without noise and upload them to the server. Finally, the server homomorphically aggregates the local model according to the aggregation weights obtained by the model anomaly detection algorithm. The ciphertext of the homomorphic aggregation original model parameters can greatly reduce the model performance loss problem caused by differential privacy technology, while ensuring the security of the model parameters. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is a system architecture diagram of the present invention;
[0049] Figure 2 is the local training algorithm graph;
[0050] Figure 3 It is the model anomaly detection algorithm diagram;
[0051] Figure 4 It is the server weighted homomorphic aggregation algorithm graph;
[0052] Figure 5 It is the noise algorithm diagram. DETAILED DESCRIPTION
[0053] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0054] This embodiment designs a privacy-preserving anti-poisoning federated learning solution in a semi-honest environment, which can protect client private data and model parameters throughout the distributed modeling process, and can also resist poisoning attacks with a poisoning ratio of less than 50%, such as Figure 1 As shown in the system architecture diagram, this embodiment consists of a server, multiple clients and a homomorphic key distribution mechanism, in which the homomorphic key generation center is responsible for distributing homomorphic keys to the clients during training; the client has weak computing power and is only responsible for training and uploading local models; the server has strong computing power and is responsible for the model screening and model aggregation operations in the embodiment.
[0055] The experimental environment of this embodiment is Intel(R) Xeon(R) Gold 6130 CPU@2.10GHz, the operating system is Linux, the development environment is Pycharm, the programming language is python3.8, and PyTorch1.7.1 is used to implement neural network model training.
[0056] Based on this system, this embodiment provides a privacy-preserving anti-poisoning federated learning aggregation method, including the following steps:
[0057] Step 1: The client decrypts the global model and trains it locally using private data.
[0058] Specifically, this step includes the following sub-steps:
[0059] Step 1.1: Figure 2 As shown in the figure, the client decrypts the received encrypted global model using the homomorphic key CKKS decryption function Dec(x) issued by the key distribution agency to obtain w i And use it as the local model for the next round of iterations.
[0060] Step 1.2: The client then optimizes the model and the local data set according to the loss function to obtain the local optimal local model w i Among them, the loss function optimization model is expressed as follows:
[0061]
[0062] Among them, w i is the local optimal local model, and B is Batch, which represents the training batch.
[0063] Step 2: Differential privacy and homomorphic encryption processing of the client local model;
[0064] Specifically, this step includes the following sub-steps:
[0065] Step 2.1: The client performs the local model w i Noise algorithm NoiceAdd(w i ) performs local differential privacy processing to obtain a noisy local model
[0066] Specifically, Figure 5 As shown, the noise algorithm NoiceAdd(w i ) includes:
[0067] The local model parameter w i The L2 norm of is within a certain threshold C, that is:
[0068]
[0069] The client-side local model sensitivity is then defined as:
[0070] Δs i =2C / |D i |
[0071] Among them, |D i |For client C i The size of the private dataset.
[0072] The noise scale σ is set to:
[0073]
[0074] The client adds noise distribution to the trimmed local model parameters: Noise:
[0075]
[0076] Get the noise local model At this point, the differential privacy processing of model parameters is completed.
[0077] Step 2.2: The client performs homomorphic encryption on the local model:
[0078] Using encryption algorithm Dec(w i ) is homomorphically encrypted to obtain the ciphertext local model
[0079] Specifically, Figure 2 As shown, the client encrypts the local model using the CKKS encryption function Enc(x) to obtain the ciphertext local model
[0080] Step 2.3: The client will make the noise local model and encrypted local model Send to the server.
[0081] In the overall process of the present invention, the model parameters are always protected by differential privacy and homomorphic encryption, thereby achieving privacy protection of the model and preventing reasoning attacks.
[0082] Step 3: The server-side model anomaly detection algorithm detects the local model and assigns weights.
[0083] Before the server aggregates the local model, it must first calculate the aggregation weight of the local model based on the model anomaly detection algorithm to avoid the influence of malicious local models on the global model.
[0084] The specific implementation process of this step is as follows Figure 3 As shown, it includes the following sub-steps:
[0085] Step 3.1: Calculate the client's noise local model parameters The cosine similarity c between the local models i,j :
[0086]
[0087] Step 3.2, and store in the list Then, an aggregate similarity c is initialized for each client. i,sum , list c i The sum of the elements greater than or equal to the median is denoted by c i,sum =c i,sum +c i,j .
[0088] Step 3.3: Store the aggregated similarity of each local model in a list middle.
[0089] Step 3.4, according to list c sum The median value of evaluates the aggregate similarity of each client's local model. If the list c sum Medium Noise Local Model The aggregate similarity c i,sum Greater than the aggregate similarity list c sum If the local model is the median of , the local model is considered to be a benign model and its aggregate similarity remains unchanged; otherwise, it is considered to be a model with low contribution or malicious, and its aggregate similarity is set to 0:
[0090]
[0091] Step 3.5: Assign aggregation weights to the local model based on the proportion of aggregation similarity:
[0092]
[0093] At this point, the model anomaly detection algorithm is completed. In the model anomaly detection algorithm, the local model that has been disturbed by noise can retain the characteristics of the model parameters to the greatest extent, ensuring that the model anomaly detection process correctly filters out malicious local models while also ensuring data privacy.
[0094] Step 4: Weighted homomorphic aggregation of local models on the server side;
[0095] Specifically, Figure 4 As shown, this step includes the following sub-steps:
[0096] Step 4.1: The server calculates the aggregation weight q based on the model anomaly detection algorithm MAD i ,
[0097] Step 4.2: Obtain the global model through the weighted homomorphic aggregation formula
[0098]
[0099] Step 4.3: Global model The data is returned to the client participating in the new round of iteration for a new round of training.
[0100] In a second aspect, this embodiment provides a privacy-preserving and anti-poisoning federated learning aggregation system, including a server, a client, and a homomorphic key distribution mechanism, and the system is used to implement the method mentioned in the above embodiment.
[0101] In a third aspect, this embodiment provides an electronic device, including a memory, a processor, and a program stored in the memory, wherein the processor implements the method mentioned in the above embodiment when executing the program. The storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0102] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A privacy-preserving and anti-poisoning federated learning aggregation method, It is characterized in that The following steps are involved: S1. The client decrypts the global model, and uses the global model and local data to optimize the model according to the loss function to obtain a new local optimal local model; S2. The client uses a local training algorithm to perform differential privacy and homomorphic encryption on the local optimal local model to obtain a noisy local model and a ciphertext local model. S3. The server uses a model anomaly detection algorithm according to the noise local model to filter out malicious local models, and assigns corresponding aggregation weights to the remaining local models; S4. The server aggregates the local model of the ciphertext according to the weighted homomorphic aggregation algorithm to obtain the global model of the ciphertext.
2. According to claim 1, a privacy-preserving anti-poisoning federated learning aggregation method, It is characterized in that The loss function optimization model is expressed by the following formula: Among them, w i is the local optimal local model, and B is Batch, which represents the training batch.
3. According to the privacy-preserving and anti-poisoning federated learning aggregation method of claim 1, It is characterized in that The noise local model is constructed by using the noise algorithm NoiceAdd(w i ) is obtained by performing differential privacy processing.
4. According to claim 3, a privacy-preserving anti-poisoning federated learning aggregation method, It is characterized in that The specific steps of obtaining the noise local model are as follows: The local optimal local model w i L 2 The norm is within a certain threshold C, which is expressed by the following formula: Define the client local model sensitivity as: Δs i =2C / |D i | Among them, |D i |For client C i The size of the private dataset; The noise scale σ is set to: The client adds noise distribution to the trimmed local model parameters: Noise: Get the noise local model 5. According to claim 1, a privacy-preserving anti-poisoning federated learning aggregation method, It is characterized in that The ciphertext local model is constructed by using the encryption algorithm Dec(w i ) is homomorphically encrypted to obtain the ciphertext local model.
6. A privacy-preserving and anti-poisoning federated learning aggregation method according to claim 5, It is characterized in that The encryption algorithm Dec(w i ) specifically includes: using the CKKS encryption function Enc(x) to encrypt to obtain the ciphertext local model.
7. According to claim 1, a privacy-preserving anti-poisoning federated learning aggregation method, It is characterized in that The step S3 specifically includes: S31, calculating the noise local model The cosine similarity c between the local models and other noise i,j : S32, storing the cosine similarity in list c i =[c i,1 ,c i,2 ,...,c i,K ], and then initialize an aggregate similarity c for each client i,sum , list c i The sum of the elements greater than or equal to the median is denoted by c i,sum =c i,sum +c i,j ; S33, store the aggregated similarity of each local model in list c sum =[c 1,sun ,c 2,sum ,...,c K,sum ]middle; S34, according to list c sum The median value of evaluates the aggregate similarity of each client's local model. If the list c sum Medium Noise Local Model The aggregate similarity c i,sum Greater than the aggregate similarity list c sum If the local model is the median of , the local model is considered to be a benign model and its aggregate similarity remains unchanged; otherwise, it is considered to be a model with low contribution or malicious, and its aggregate similarity is set to 0: S35. Assign aggregation weight q to the local model according to the proportion of aggregation similarity i :
8. According to claim 1, a privacy-preserving anti-poisoning federated learning aggregation method, It is characterized in that The process in step S4 is expressed by the following formula: in, is the global model, q i is the aggregation weight, It is a ciphertext local model.
9. A privacy-preserving anti-poisoning federated learning aggregation system, comprising a server, a client, and a homomorphic key distribution mechanism, It is characterized in that The system is used to implement the method according to any one of claims 1-8.
10. An electronic device comprising a memory, a processor, and a program stored in the memory, It is characterized in that When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
