Malicious client detection method, device, electronic device and storage medium for encrypted federated learning
By using adaptive clipping and differential privacy mechanisms plus Gaussian noise, combined with the Repeated Median linear regression algorithm to screen benign gradients, the problem of malicious client detection and gradient security in federated learning is solved, and data privacy protection and model performance are improved.
Patent Information
- Application Number
- CN202410493166.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-23
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-04-23
AI Technical Summary
In federated learning, the behavior of malicious clients may cause model performance to decline, and the gradient interaction process is vulnerable to attacks, leading to data privacy leaks. It is difficult for existing technologies to effectively detect and eliminate malicious clients and ensure the security of the gradient interaction process.
Calculate the client gradient by adaptive clipping threshold based on historical iteration rounds, add differentially private Gaussian noise, and use the Repeated Median linear regression algorithm to calculate the gradient residual and confidence, screen out benign gradients, and eliminate malicious gradients with lower scores. Aggregation and broadcasting.
It effectively protects data privacy, improves the reliability of the federated learning system and the security of the gradient interaction process, and prevents malicious attacks from affecting model performance.
Smart Images

Figure CN118316699B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of artificial intelligence, and more specifically, relates to a malicious client detection method, device, electronic device and storage medium for encrypted federated learning. Background Art
[0002] With the advent of the information age, machine learning has gradually changed people's way of life and production, and has made great progress in speech, image and text recognition, language translation, etc. At the same time, with the rapid development of artificial intelligence technology, data privacy and security have become major issues worldwide. Faced with the "data island" phenomenon that restricts the development of artificial intelligence and data privacy and security issues, federated learning, as a new type of distributed machine learning technology, has emerged. It does not require large-scale data transmission and sharing. Each data holder can achieve collaborative modeling locally to improve the effect of artificial intelligence models. It is an effective way to solve the above problems and has important research value and practical application significance.
[0003] However, in practical applications, federated learning also has some security risks. During the training process, some clients may behave maliciously and dishonestly. They may tamper with local model parameter updates and try to influence the global model update direction, resulting in a decrease in federated learning performance. In the face of these malicious behaviors of clients, some measures need to be taken to ensure the security and robustness of the model to ensure the stability and reliability of the federated learning system.
[0004] For example, Chinese patent document CN117113413A discloses a robust federated learning privacy protection system based on blockchain. By adding an additional small communication overhead, the gradient on the blockchain is privacy protected in plain text. The impact on model performance is theoretically lower than differential privacy, and it can expand the existing robust aggregation algorithm to defend against attacks from malicious clients. The three aggregation algorithms Krum, Sim and TD are modified, and a new aggregation algorithm SD is proposed to apply these four aggregation methods to the system. The scheme proposed in the present invention has dynamically adjustable privacy protection capabilities, is robust against malicious attacks, and when considering privacy protection, the modified three Byzantine aggregation methods have higher performance than the original ones.
[0005] Chinese patent document CN117077806A discloses a differential privacy federated learning method based on random election verification blockchain. The design method is as follows: first, the decentralization of blockchain is utilized to build a federated learning system based on identity authentication blockchain. Secondly, a random selection mechanism is used to determine the verification leader node to ensure the fairness of the verification node block generation, and the verification node anomaly detection mechanism is used to defend against malicious node attacks to ensure the accuracy of the global model. Finally, differential privacy is used to protect the security of the local model, and an incentive mechanism is designed according to the degree of contribution of the node to the model to encourage the node to train a high-quality model, thereby improving the accuracy of the global model.
[0006] The above method achieves data privacy protection by defending against attacks from malicious clients, but malicious clients still exist. Therefore, when the federated learning system is locally trained, detecting and eliminating potential malicious clients to deal with the impact of malicious behavior has become one of the urgent issues to be solved.
[0007] In addition, federated learning introduces a large number of gradient interactions, which are not only threatened by model users like centralized training, but may also be attacked by untrusted clients. Attackers use gradients to infer specific features or certain statistical characteristics in the client's local data set, thereby restoring the original data and leaking data privacy. Therefore, in the context of federated learning, effectively protecting the client's local training gradients to deal with privacy leaks caused by malicious attacks has become one of the issues that people are widely concerned about. Summary of the invention
[0008] The present invention aims to overcome at least one defect of the above-mentioned prior art and provide a malicious client detection method for encrypted federated learning, with the purpose of detecting and eliminating clients with malicious behavior in the federated learning process and ensuring the security of the gradient interaction process.
[0009] The present invention also provides a device for implementing the malicious client detection method for encrypted federated learning.
[0010] The detailed technical scheme of the present invention is as follows:
[0011] A malicious client detection method for encrypted federated learning, the method comprising:
[0012] S1. Calculate the clipping threshold of the current iteration round based on the client gradient of the historical iteration round, and adaptively clip the gradients of all clients participating in federated learning according to the clipping threshold of the current iteration round to obtain the clipped intermediate gradient;
[0013] S2. Introduce a differential privacy mechanism, add Gaussian noise to the clipped intermediate gradient, obtain the noise-injected target gradient, and upload the target gradient to the server participating in federated learning;
[0014] S3, adding an index to each dimension element of the target gradient of all clients to form a two-dimensional point set, and using the Repeated Median linear regression algorithm to calculate the residual of each dimension element of the target gradient, and calculating the confidence of each dimension element of the target gradient according to the residual, and calculating the gradient score of each dimension element according to the confidence, and screening out the benign gradients in all target gradients according to the sum of the scores of all elements of the target gradient of each client;
[0015] S4. Aggregate the selected benign gradients to obtain a global gradient, and broadcast the global gradient to all clients for gradient update.
[0016] Preferably, in step S1, the L2 norm of each client gradient in t rounds of iteration is calculated, and the p percentile of the historical gradient L2 norm is selected as the clipping threshold in the current iteration round, that is:
[0017]
[0018] In formula (1), C t represents the clipping threshold in the tth iteration, represents the L2 norm of the historical client gradient of the i-th round calculated in the t-th round iteration, p is the percentage of the clipping threshold selection, and 0≤p≤1.
[0019] Preferably, according to the present invention, in step S1, the gradients of all clients are clipped according to the clipping threshold in the current iteration round, and the clipped intermediate gradient is obtained as follows:
[0020]
[0021] In formula (2), Represents the intermediate gradient after clipping of the i-th client in the t-th iteration.
[0022] Preferably, according to the present invention, in step S2, Gaussian noise is added to the clipped intermediate gradient to obtain a target gradient of injected noise:
[0023]
[0024] In formula (3), represents the target gradient of the noise injected by the i-th client in the t-th iteration, It means that it has a mean of zero and a variance of σ 2 C t2 Gaussian noise, where represents Gaussian distribution, σ 2 represents the variance and I is the identity matrix.
[0025] Preferably, in step S3, the residual of each dimensional element of the target gradient is calculated using a Repeated Median linear regression algorithm, which specifically includes:
[0026] Generate a linear regression equation y=κ+ξx based on a two-dimensional point set;
[0027] The Repeated Median linear regression algorithm is used to estimate the slope ξ and intercept κ of the linear regression equation, namely:
[0028]
[0029]
[0030] In formula (4) and (5), denote the n-th dimension element of the target gradient of the j-th client and the i-th client respectively, denotes the index of the n-th dimension element of the target gradient of the j-th client and the i-th client, respectively, where i,j∈{1,2,…,m}, m is the number of clients;
[0031] Calculate the residual of each dimension element of all client target gradients. For the n-th dimension element, the residual is:
[0032] r n ←y n -κ-ξx n (6);
[0033] In formula (6), r n Represents the residual of the n-th element of the client-side objective gradient.
[0034] Preferably, in step S3, the confidence of each dimensional element of the target gradient is calculated according to the residual, and the gradient score of each dimensional element is calculated according to the confidence, and the benign gradients in all target gradients are screened out according to the sum of the scores of all elements of the target gradient of each client, which specifically includes:
[0035] Normalize the residuals of each dimension element of all client target gradients, take the absolute value of the residuals of each dimension element of the client target gradient and calculate the median gradient, for the n-th dimension element, expressed as
[0036]
[0037] In formula (7), The median gradient of the absolute value of the residual of the n-th dimension element of the client objective gradient;
[0038] The median gradient is scaled by a constant γ with the number of clients m The scaling result is expressed as:
[0039]
[0040] In formula (8), a is the adjustment constant, and a=5;
[0041] For the residual r n Normalize the residual r n Divide by the scaling result τ n ,Right now:
[0042]
[0043] In formula (9), e n Represents the normalized residual of the n-th dimension element of the client target gradient;
[0044] According to the residual normalization result of each dimension element of the client target gradient, the confidence of each dimension element is calculated:
[0045]
[0046] In formula (10), w n represents the confidence of the n-th dimension element of the client target gradient, H n The index x of the n-th dimension element of the client objective gradient n The projection matrix, diag(H n ) represents the projection matrix H n The diagonal elements of , Ψ represents the confidence interval, and Ψ(x) = max(-Z, min(Z, x)), λ is a hyperparameter;
[0047] According to the confidence of each dimension element of the client target gradient, the score of each dimension element is calculated:
[0048]
[0049] In formula (11), represents the score of the n-th dimension element of the client objective gradient, σ(w n ) represents the standard deviation of the confidence of the n-th dimension element of the client target gradient;
[0050] Based on the score of each dimension element of the client's target gradient, the sum of the scores of all elements of each client's target gradient is calculated:
[0051]
[0052] In formula (12), W (k) represents the sum of the scores of all elements of the target gradient of the k-th client, and N represents the number of all elements of the target gradient of the k-th client;
[0053] According to the sum of the scores of all elements of each client's target gradient, the benign gradients among all target gradients are screened out.
[0054] Preferably, according to the present invention, in step S4, the selected benign gradients are aggregated to obtain a global gradient as follows:
[0055]
[0056] In formula (13), represents the global gradient obtained in the tth iteration, m is the number of clients, and f is the number of malicious clients;
[0057] The global gradient is broadcast to all clients for gradient update, that is:
[0058]
[0059] In formula (14), g t+1 represents the client gradient of the t+1th round, and η is the learning rate.
[0060] In another aspect of the present invention, a device for implementing a malicious client detection method for encrypted federated learning is provided, the device comprising:
[0061] The clipping module is used to calculate the clipping threshold of the current iteration round based on the client gradient of the historical iteration round, and adaptively clip the gradients of all clients participating in the federated learning according to the clipping threshold of the current iteration round to obtain the clipped intermediate gradient;
[0062] A noise injection module is used to add Gaussian noise to the clipped intermediate client gradient to obtain a target client gradient injected with noise, and upload the target client gradient to a server participating in federated learning;
[0063] A calculation module, used to add an index to each dimensional element of all target client gradients to form a two-dimensional point set, and use the Repeated Median linear regression algorithm to calculate the residual of each dimensional element of the target client gradient, calculate the confidence of each dimensional element of the target client gradient based on the residual, and calculate the gradient score of each dimensional element based on the confidence, and screen out the benign gradients in all target gradients based on the sum of the scores of all elements of each client target gradient;
[0064] The aggregation module is used to aggregate the selected benign client gradients to obtain a global gradient, and broadcast the global gradient to all clients for gradient update.
[0065] In another aspect of the present invention, there is also provided an electronic device, comprising:
[0066] at least one processor; and
[0067] A memory storing instructions, which, when executed by the at least one processor, causes the at least one processor to execute the malicious client detection method for encrypted federated learning as described above.
[0068] In another aspect of the present invention, a machine-readable storage medium is provided, which stores executable instructions, and when the instructions are executed, the machine executes the malicious client detection method for encrypted federated learning as described above.
[0069] Compared with the prior art, the present invention has the following beneficial effects:
[0070] The present invention provides a malicious client detection method for encrypted federated learning. By adding Gaussian noise that satisfies the differential privacy mechanism to the client gradient, malicious attackers cannot infer relevant information of the original data, thereby protecting data privacy. At the same time, in order to detect malicious behavior of the client during training and improve the reliability of the federated learning system, the present invention adopts a Repeated Median linear regression algorithm to calculate the residual and confidence of the corresponding gradient, and then scores each client gradient according to the calculation result, and judges the gradients with lower scoring values as malicious gradients and eliminates them. The remaining benign gradients participate in the aggregation calculation to ensure the security of the gradient interaction process. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] Figure 1 It is a flow chart of the malicious client detection method for encrypted federated learning described in the present invention.
[0072] Figure 2 It is the topology diagram of the federated learning system.
[0073] Figure 3 It is a schematic diagram showing that the test accuracy of the method of the present invention varies with the number of training rounds.
[0074] Figure 4 It is a schematic diagram showing how the test accuracy of the method of the present invention varies with the number of malicious clients. DETAILED DESCRIPTION
[0075] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.
[0076] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present disclosure belongs.
[0077] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0078] In the absence of conflict, the embodiments in the present disclosure and the features in the embodiments may be combined with each other.
[0079] In view of the problems existing in the prior art, the present invention provides a malicious client detection method for encrypted federated learning, which aims to detect and eliminate clients with malicious behaviors in the federated learning process and ensure the security of the gradient interaction process.
[0080] Malicious clients can seriously affect data security and model performance. To reduce the risk of data privacy leakage, the present invention adds Gaussian noise that satisfies the differential privacy mechanism to the client gradient, so that malicious attackers cannot infer relevant information of the original data, thereby protecting data privacy. To detect malicious behavior of the client during training and improve the reliability of the federated learning system, the present invention adopts a Repeated Median linear regression algorithm to calculate the residual and confidence of the corresponding gradient, and then scores the gradients of each client according to the calculation results. The gradients with lower scoring values are judged as malicious gradients and eliminated, and the remaining benign gradients participate in the aggregation calculation.
[0081] The malicious client detection method and device for encrypted federated learning of the present invention are described in detail below in conjunction with specific embodiments.
[0082] Embodiment 1,
[0083] Ginseng Figure 1 This embodiment provides a malicious client detection method for encrypted federated learning, which is applied to the federated learning system. Figure 2 ,The federated learning system includes two entities, client (Client) and server (Server), and multiple clients communicate with a single server.
[0084] The method comprises:
[0085] S1. Calculate the clipping threshold of the current iteration round based on the client gradient of the historical iteration round, and adaptively clip the gradients of all clients participating in federated learning according to the clipping threshold of the current iteration round to obtain the clipped intermediate gradient.
[0086] This embodiment designs an adaptive gradient clipping method to adaptively clip the gradient sizes of all clients within a reasonable threshold, thereby preventing any single local update from excessively affecting the global model update and causing a gradient explosion problem.
[0087] Specifically, suppose the federated learning system has m clients (P1, P2, ..., P m ), corresponding to m local training data sets D i (i=1,2,…,m). Assume that there are f malicious clients that attempt to upload meaningless or malicious client gradients to prevent the global model from converging correctly.
[0088] First, the client P i Receive the global gradient from the server in the previous round Using its local dataset D i Train its local model and obtain its client gradient for round t Each client gradient contains n elements (ie, a vector).
[0089] In the differential privacy mechanism, gradient clipping is crucial. If the gradient clipping threshold is set too large, it will introduce too much unnecessary noise, thus affecting the model performance; if the gradient clipping threshold is set too small, there is a risk of exposing too much gradient information.
[0090] Based on this, the method of this embodiment adopts an adaptive method to clip the gradient. The specific process is as follows.
[0091] First, calculate the L2 norm of each client gradient in t rounds of iterations, and select the p percentile of the historical gradient L2 norm as the clipping threshold of the current iteration, that is:
[0092]
[0093] In formula (1), C t represents the clipping threshold in the tth iteration, represents the L2 norm of the historical client gradient of the i-th round calculated in the t-th round iteration, p is the percentage of the clipping threshold selection, and 0≤p≤1.
[0094] Then according to the obtained clipping threshold C t Clip the gradients of all clients, and get the intermediate gradient after client clipping:
[0095]
[0096] In formula (2), Represents the intermediate gradient after clipping of the i-th client in the t-th iteration.
[0097] The above adaptive clipping method can predict the change of the gradient in the current iteration according to the change trend of the client's historical gradient, and determine the appropriate gradient clipping threshold accordingly, which can effectively prevent the impact of excessive gradients on model updates. In addition, this method only needs to specify the clipping percentage and will not expose the original gradient information, thereby better protecting privacy.
[0098] S2. Introduce a differential privacy mechanism, add Gaussian noise to the clipped intermediate gradient, obtain the target gradient injected with noise, and upload the target gradient to the server participating in federated learning.
[0099] In order to prevent the leakage of local privacy data, security measures need to be taken to effectively protect the gradients before the client uploads the gradients obtained from its local training to the server.
[0100] The method in this embodiment introduces a differential privacy mechanism to the intermediate gradient after the client is clipped Adding Gaussian noise, the target gradient of injected noise is:
[0101]
[0102] In formula (3), represents the target gradient of the noise injected by the i-th client in the t-th iteration, It means that it has a mean of zero and a variance of σ 2 C t 2 Gaussian noise, where represents Gaussian distribution, σ 2 represents the variance and I is the identity matrix.
[0103] Then inject the noise into the target gradient Upload to the server for secure aggregation.
[0104] By adding Gaussian noise to the clipped client gradient, the client gradient is protected from inference attacks during the communication iteration process, effectively protecting the client gradient and local data and reducing the risk of privacy leakage.
[0105] S3. Add an index to each dimensional element of the target gradient of all clients to form a two-dimensional point set, and use the Repeated Median linear regression algorithm to calculate the residual of each dimensional element of the target gradient, calculate the confidence of each dimensional element of the target gradient based on the residual, and calculate the gradient score of each dimensional element based on the confidence, and screen out the benign gradients in all target gradients based on the sum of the scores of all elements of the target gradient of each client.
[0106] In this embodiment, in order to identify malicious behaviors during training, detect and remove malicious clients, a malicious client detection and removal method based on Repeated Median linear regression is designed under the protection of differential privacy mechanism. The specific process is as follows.
[0107] First, the server sorts each dimension element of the target gradient of all received clients in ascending order, descending order, or sequential order, etc. Here, ascending order is preferred. The nth dimension element of the target gradient of the i-th client is represented as
[0108] Then add an index to each dimension element of the target gradient of all sorted clients Finally, a two-dimensional point set (x n ,y n ). In this embodiment, the index can be set to a positive integer from 1 to N.
[0109] Exemplarily, assume that there are 3 clients, and the target gradient of each client contains 2 elements, namely: client 1, element n1 = [2.5, 3.1]; client 2, element n2 = [1.7, 4.2]; client 3, element n3 = [0.9, 2.8].
[0110] The elements of each dimension of the target gradients of all clients are sorted in ascending order, and the elements of the first dimension after sorting are [0.9, 1.7, 2.5], and the elements of the second dimension are [2.8, 3.1, 4.2].
[0111] Add an index to each dimension element of the target gradient of all sorted clients, and set the index of each dimension element to: [1, 2, 3], then the formed two-dimensional point set is {(1, 0.9), (2, 1.7), (3, 2.5), (1, 2.8), (2, 3.1), (3, 4.2)}.
[0112] Based on the above obtained two-dimensional point set (x n ,y n), generate the linear regression equation y = κ + ξx. Then the server uses the Repeated Median linear regression algorithm to estimate the slope ξ and intercept κ of the linear regression equation, that is:
[0113]
[0114]
[0115] In formula (4) and (5), denote the n-th dimension element of the target gradient of the j-th client and the i-th client respectively, denotes the index of the n-th dimension element of the target gradient of the j-th client and the i-th client, respectively, where i,j∈{1,2,…,m}, m is the number of clients.
[0116] After that, the residual of each dimension element of all client target gradients is calculated. For the n-th dimension element, the residual is:
[0117] r n ←y n -κ-ξx n (6);
[0118] In formula (6), r n Represents the residual of the n-th element of the client-side objective gradient.
[0119] In this embodiment, the confidence of each dimensional element of the target gradient is calculated according to the residual, and the gradient score of each dimensional element is calculated according to the confidence. According to the sum of the scores of all elements of the target gradient of each client, the benign gradients in all target gradients are screened out, specifically including:
[0120] First, the residual of each dimension of the client target gradient is normalized.
[0121] Since the residuals of different elements are not easy to compare, the residuals need to be normalized. Take the absolute value of the residual of each dimension element of the client target gradient and calculate its median gradient. For the n-th dimension element, it is expressed as
[0122]
[0123] In formula (7), Represents the median gradient of the absolute value of the residual of the n-th dimension element of the client objective gradient.
[0124] The median gradient is scaled by a constant γ with the number of clients m The scaling result is expressed as:
[0125]
[0126] In formula (8), a is an adjustment constant, and a=5, and the adjustment constant can be set.
[0127] For the residual r n Normalize the residual r n Divide by the scaling result τ n ,Right now:
[0128]
[0129] In formula (9), e n Represents the residual normalization result of the n-th dimension element of the client objective gradient.
[0130] The above process obtains the residual normalization results of each dimensional element of all client target gradients, ensuring that the residuals are adjusted according to their typical amplitudes and scale factors, making them more comparable between different elements.
[0131] Then, the server calculates the confidence of each dimension of each client's target gradient based on the residual normalization result of each dimension of the element:
[0132]
[0133] In formula (10), w n represents the confidence of the n-th dimension element of the client target gradient, H n The index x of the n-th dimension element of the client objective gradient n The projection matrix, diag(H n ) represents the projection matrix H n The diagonal elements of , Ψ represents the confidence interval, and Ψ(x) = max(-Z, min(Z, x)), λ is a hyperparameter.
[0134] Then, according to the confidence of each dimension element of the client target gradient, the score of each dimension element is calculated:
[0135]
[0136] In formula (11), represents the score of the n-th dimension element of the client objective gradient, and σ(·) represents the standard deviation of the confidence of the n-th dimension element of the client objective gradient.
[0137] Based on the score of each dimension element of the client's target gradient, the sum of the scores of all elements of each client's target gradient is calculated:
[0138]
[0139] In formula (12), W (k) represents the sum of the scores of all elements of the target gradient of the kth client, and N represents the number of all elements of the target gradient of the kth client.
[0140] Finally, all clients are sorted in ascending order according to the sum of the scores of all elements of the target gradients of all m clients, and the first f clients with lower scores are regarded as malicious clients and eliminated, and the remaining mf clients are retained as benign clients, and the target gradients of the benign clients will be used as benign gradients in the aggregation calculation.
[0141] S4. Aggregate the selected benign gradients to obtain a global gradient, and broadcast the global gradient to all clients for gradient update.
[0142] That is, the target gradients of mf benign clients with higher scores are finally aggregated as benign gradients to obtain the global gradient:
[0143]
[0144] In formula (13), Represents the global gradient obtained in the tth iteration.
[0145] Finally, the global gradient Broadcast to all clients to update local model gradients:
[0146]
[0147] In formula (14), g t+1 represents the client gradient of the t+1th round, and η is the learning rate.
[0148] In this example, the MNIST dataset is used, and the convolutional neural network model CNN is adopted to test the test accuracy under the label flipping attack. The results are as follows: Figure 3 and Figure 4 shown.
[0149] Figure 3 A schematic diagram showing the test accuracy of the method of this embodiment changes with the number of training rounds. It can be seen that the method still has a high test accuracy under attack, indicating that the method has detected and eliminated malicious clients, verifying the effectiveness of the method.
[0150] Figure 4 A schematic diagram showing the variation of the test accuracy of the method of this embodiment with the number of malicious clients shows that as the number of attackers increases, the test accuracy remains at a relatively high standard, indicating that this method has good performance even when the number of malicious clients increases.
[0151] Embodiment 2,
[0152] This embodiment provides a device for implementing a malicious client detection method for encrypted federated learning, the device comprising:
[0153] The clipping module is used to calculate the clipping threshold of the current iteration round based on the client gradient of the historical iteration round, and adaptively clip the gradients of all clients participating in the federated learning according to the clipping threshold of the current iteration round to obtain the clipped intermediate gradient;
[0154] A noise injection module is used to add Gaussian noise to the clipped intermediate client gradient to obtain a target client gradient injected with noise, and upload the target client gradient to a server participating in federated learning;
[0155] A calculation module, used to add an index to each dimensional element of all target client gradients to form a two-dimensional point set, and use the Repeated Median linear regression algorithm to calculate the residual of each dimensional element of the target client gradient, calculate the confidence of each dimensional element of the target client gradient based on the residual, and calculate the gradient score of each dimensional element based on the confidence, and screen out the benign gradients in all target gradients based on the sum of the scores of all elements of each client target gradient;
[0156] The aggregation module is used to aggregate the selected benign client gradients to obtain a global gradient, and broadcast the global gradient to all clients for gradient update.
[0157] Embodiment 3,
[0158] This embodiment also provides an electronic device, including:
[0159] at least one processor; and
[0160] A memory storing instructions, which, when executed by the at least one processor, causes the at least one processor to execute the malicious client detection method for encrypted federated learning as described above.
[0161] In this embodiment, the electronic device may include, but is not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile computing devices, smart phones, tablet computers, cellular phones, personal digital assistants (PDAs), handheld devices, messaging devices, wearable computing devices, consumer electronic devices, and the like.
[0162] Embodiment 4,
[0163] This embodiment also provides a machine-readable storage medium storing executable instructions, which, when executed, enable the machine to execute the malicious client detection method for encrypted federated learning as described above.
[0164] Specifically, a system or device equipped with a readable storage medium can be provided, on which software program codes that implement the functions of any of the above-mentioned embodiments are stored, and a computer or processor of the system or device can read and execute instructions stored in the readable storage medium.
[0165] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute part of this specification.
[0166] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer or a cloud via a communication network.
[0167] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0168] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0169] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0170] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0171] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solution of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention shall be included in the protection scope of the claims of the present invention.
Claims
1. A malicious client detection method for encrypted federated learning, characterized in that: The method comprises: S1. Calculate the clipping threshold of the current iteration round based on the client gradient of the historical iteration round, and adaptively clip the gradients of all clients participating in federated learning according to the clipping threshold of the current iteration round to obtain the clipped intermediate gradient; The clipping threshold of the current iteration round is calculated based on the client gradient of the historical iteration rounds, specifically: Calculate the L2 norm of each client gradient in t rounds of iterations, and select the p percentile of the historical gradient L2 norm as the clipping threshold in the current iteration round, that is: In formula (1), C t represents the clipping threshold in the tth iteration, represents the L2 norm of the historical client gradient of the i-th round calculated in the t-th round iteration, p is the percentage of the clipping threshold selection, and 0≤p≤1; The gradients of all clients are clipped according to the clipping threshold in the current iteration round, and the clipped intermediate gradients are: In formula (2), represents the intermediate gradient after clipping of the i-th client in the t-th iteration; S2. Introduce a differential privacy mechanism, add Gaussian noise to the clipped intermediate gradient, obtain the noise-injected target gradient, and upload the target gradient to the server participating in federated learning; S3, adding an index to each dimension element of the target gradient of all clients to form a two-dimensional point set, and using the RepeatedMedian linear regression algorithm to calculate the residual of each dimension element of the target gradient, and calculating the confidence of each dimension element of the target gradient according to the residual, and calculating the gradient score of each dimension element according to the confidence, and screening out the benign gradients in all target gradients according to the sum of the scores of all elements of the target gradient of each client; S4. Aggregate the selected benign gradients to obtain a global gradient, and broadcast the global gradient to all clients for gradient update.
2. The malicious client detection method for encrypted federated learning according to claim 1 is characterized in that: In step S2, Gaussian noise is added to the clipped intermediate gradient to obtain a target gradient injected with noise: In formula (3), represents the target gradient of the noise injected by the i-th client in the t-th iteration, It means that it has a mean of zero and a variance of σ 2 C t 2 Gaussian noise, where represents Gaussian distribution, σ 2 represents the variance and I is the identity matrix.
3. The malicious client detection method for encrypted federated learning according to claim 1 is characterized in that: In step S3, the Repeated Median linear regression algorithm is used to calculate the residual of each dimensional element of the target gradient, which specifically includes: Generate a linear regression equation y=K+ξx based on a two-dimensional point set; The Repeated Median linear regression algorithm is used to estimate the slope ξ and intercept K of the linear regression equation, namely: In formula (4) and (5), denote the n-th dimension element of the target gradient of the j-th client and the i-th client respectively, denotes the index of the n-th dimension element of the target gradient of the j-th client and the i-th client, respectively, where i, j ∈ {1, 2, ..., m}, m is the number of clients; Calculate the residual of each dimension element of all client target gradients. For the n-th dimension element, the residual is: r n ←y n -k-xx n (6); In formula (6), r n Represents the residual of the n-th element of the client-side objective gradient.
4. The malicious client detection method for encrypted federated learning according to claim 1 is characterized in that: In step S3, the confidence of each dimensional element of the target gradient is calculated according to the residual, and the gradient score of each dimensional element is calculated according to the confidence, and the benign gradients in all target gradients are screened out according to the sum of the scores of all elements of the target gradient of each client, which specifically includes: Normalize the residuals of each dimension element of all client target gradients, take the absolute value of the residuals of each dimension element of the client target gradient and calculate the median gradient, for the n-th dimension element, expressed as In formula (7), The median gradient of the absolute value of the residual of the n-th dimension element of the client objective gradient; The median gradient is scaled by a constant γ with the number of clients m The scaling result is expressed as: In formula (8), a is the adjustment constant, and a=5; For the residual r n Normalize the residual r n Divide by the scaling result τ n ,Right now: In formula (9), e n Represents the normalized residual of the n-th dimension element of the client target gradient; According to the residual normalization result of each dimension element of the client target gradient, the confidence of each dimension element is calculated: In formula (10), w n represents the confidence of the n-th dimension element of the client target gradient, H n The index x of the n-th dimension element of the client objective gradient n The projection matrix, diag(H n ) represents the projection matrix H n is a vector of diagonal elements of , Ψ represents the confidence interval, and λ is a hyperparameter; According to the confidence of each dimension element of the client target gradient, the score of each dimension element is calculated: In formula (11), represents the score of the n-th dimension element of the client objective gradient, σ(w n ) represents the standard deviation of the confidence of the n-th dimension element of the client target gradient; Based on the score of each dimension element of the client's target gradient, the sum of the scores of all elements of each client's target gradient is calculated: In formula (12), W (k) represents the sum of the scores of all elements of the target gradient of the k-th client, and N represents the number of all elements of the target gradient of the k-th client; According to the sum of the scores of all elements of each client's target gradient, the benign gradients among all target gradients are screened out.
5. The malicious client detection method for encrypted federated learning according to claim 1, characterized in that: In step S4, the selected benign gradients are aggregated to obtain a global gradient: In formula (13), represents the global gradient obtained in the tth iteration, m is the number of clients, and f is the number of malicious clients; The global gradient is broadcast to all clients for gradient update, that is: In formula (14), g t+1 represents the client gradient of the t+1th round, and η is the learning rate.
6. A device for implementing a malicious client detection method for encrypted federated learning, characterized in that: The device comprises: The clipping module is used to calculate the clipping threshold of the current iteration round based on the client gradient of the historical iteration round, and adaptively clip the gradients of all clients participating in the federated learning according to the clipping threshold of the current iteration round to obtain the clipped intermediate gradient; The clipping threshold of the current iteration round is calculated based on the client gradient of the historical iteration rounds, specifically: Calculate the L2 norm of each client gradient in t rounds of iterations, and select the p percentile of the historical gradient L2 norm as the clipping threshold in the current iteration round, that is: In formula (1), C t represents the clipping threshold in the tth iteration, represents the L2 norm of the historical client gradient of the i-th round calculated in the t-th round iteration, p is the percentage of the clipping threshold selection, and 0≤p≤1; The gradients of all clients are clipped according to the clipping threshold in the current iteration round, and the clipped intermediate gradients are: In formula (2), represents the intermediate gradient after clipping of the i-th client in the t-th iteration; A noise injection module is used to add Gaussian noise to the clipped intermediate gradient to obtain a target gradient injected with noise, and upload the target gradient to a server participating in federated learning; A calculation module, used to add an index to each dimensional element of the target gradient of all clients to form a two-dimensional point set, and use the Repeated Median linear regression algorithm to calculate the residual of each dimensional element of the target gradient, calculate the confidence of each dimensional element of the target gradient based on the residual, and calculate the gradient score of each dimensional element based on the confidence, and screen out the benign gradients in all target gradients based on the sum of the scores of all elements of the target gradient of each client; The aggregation module is used to aggregate the selected benign gradients to obtain a global gradient, and broadcast the global gradient to all clients for gradient update.
7. An electronic device, characterized in that: include: at least one processor; as well as A memory storing instructions, which, when executed by the at least one processor, causes the at least one processor to execute the malicious client detection method for encrypted federated learning as described in any one of claims 1 to 5.
8. A machine-readable storage medium, characterized in that: It stores executable instructions, which, when executed, enable the machine to perform the malicious client detection method for encrypted federated learning as described in any one of claims 1 to 5.
