Federal learning method for heterogeneous adaptive quantization privacy protection
By adopting heterogeneous adaptive quantization and privacy protection technologies in federated learning, dynamically adjusting the quantization level and using Boolean sharing and Diffie-Hellman key exchange protocols, the problems of large communication overhead and reduced accuracy in high-dimensional model training are solved, achieving efficient and accurate model training and protecting gradient privacy.
Patent Information
- Application Number
- CN202510109003.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-05-09
AI Technical Summary
The existing federated learning methods have problems such as large communication overhead, reduced model accuracy and convergence performance in high-dimensional model training, especially in edge device environments with heterogeneity and communication limitations.
The federated learning method of privacy protection of heterogeneous adaptive quantization is adopted, and the gradient privacy is protected by dynamically adjusting the quantization level according to the gradient norm by combining Boolean sharing and Diffie-Hellman key exchange protocols, optimizing communication efficiency and balancing accuracy and time.
It effectively reduces communication time, improves the efficiency and accuracy of model training, is suitable for edge device environments with heterogeneity and limited communication, and ensures the protection of gradient privacy.
Smart Images

Figure CN119962637A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to heterogeneous adaptive quantization, privacy protection and federated learning, and in particular to a privacy-preserving federated learning method of heterogeneous adaptive quantization. Background Art
[0002] With the popularity of deep neural networks on smart devices, edge devices also generate a large amount of data. In order to utilize this data, the traditional method is to upload the data to the cloud for training, but this will bring the risk of privacy leakage, so federated learning is used to protect privacy. Federated learning is a machine learning method that allows geographically dispersed edge devices to learn models without leaking privacy. It is also a distributed machine learning method. Its data is distributed on a large number of mobile user devices. Each participant only needs to upload the gradient to the central server, but the communication overhead of uploading and downloading the gradient in each round of training may be very high, especially in edge devices with limited wireless bandwidth. This leads to communication problems in model training and heterogeneity problems caused by uneven data distribution and different computing capabilities of participants.
[0003] Most existing methods for solving communication problems: (1) Allow each user to perform multiple local updates to reduce communication load. By reducing the frequency of communication between users and servers, communication overhead and network burden can be reduced. However, when dealing with complex deep learning, even if the frequency of communication is reduced, the number of model parameters updated each time is huge, and the problem of high communication overhead cannot be solved. (2) Use compression technology to reduce the amount of data transmitted by users in each training round, that is, reduce the amount of data in transmission through gradient compression. However, the randomness and approximation introduced by the compression method will affect the convergence performance and accuracy of the model, so the quantization level needs to be carefully selected. However, the existing gradient quantization algorithm mainly relies on fixed and predetermined quantization during the training process. However, the actual federated learning tasks have different characteristics in terms of convergence time, communication cost and network conditions, and the optimal quantization level is different at different times, so the quantization level needs to be adaptively adjusted according to the training round.
[0004] Existing research either reduces the communication frequency between users and servers or reduces the communication overhead by compressing gradients, but it is not suitable for high-dimensional models and will reduce the accuracy of the model and affect the convergence performance of the model. Summary of the invention
[0005] The purpose of the present invention is to provide a heterogeneous adaptive quantization privacy-preserving federated learning, which dynamically adjusts the quantization level according to the change of the gradient norm during the training process, so as to achieve a balance between accuracy and reducing communication time, and at the same time assigns a lower quantization level to slow nodes, which can reduce waiting time, thereby achieving the shortest total training time. The communication problem is solved by quantization, and the privacy of the gradient is protected by Boolean sharing and Diffie-Hellman key exchange protocol. The server realizes the gradient aggregation of participants based on Boolean to arithmetic sharing.
[0006] In order to achieve the above-mentioned invention object, the technical solution adopted by the present invention is as follows: a heterogeneous adaptive quantitative privacy protection federated learning method, comprising the following steps
[0007] S10, system initialization phase, the system administrator SM builds the system platform, generates public system parameters PP, and publicly releases PP and related parameters FP of federated learning; each user, server A and B uses the public parameters to generate their own public key and private key pair; users apply to participate in the training of certain federated learning tasks on the platform, and all users’ quantitative levels s i,0 Initialize s0, the initial model vector w for each user i,0 =w0;
[0008] S20, user updates local model stage, each user C i Use the global aggregate gradient g sent by server A k Update local model weights w i,k+1 , and according to the received quantitative level s i,k and auxiliary quantization s' i,k Quantify the gradient g' i,k and g" i,k , update the model parameters to w' according to the quantized gradient i and w" i , through the model parameter w' on the local test set i and w" i Predict the loss value L i,k and L' i,k ; The loss value L calculated based on the quantization level and the auxiliary quantization level i,k ,L' i,k , download time dt i,k , calculation time ct i,k , communication time mt i,k Sent to the server for calculating the next round of quantization level;
[0009] S30, server A calculates the quantization level and receives the loss value L from all users i,k ,L' i,k , download time dti,k , calculation time ct i,k and communication time mt i,k , estimate the two loss reduction rates R k ,R' k , calculate the derivative of the loss function to determine the quantization level s for the k+1th round k+1 The update direction of the aggregated gradient is further adjusted according to the gradient norm of the aggregated gradient. k+1 ; Server A estimates the computing time and communication time of each user and allocates an appropriate number of quantization bits b to each user i,k+1 , so that the local training time of all users is equal;
[0010] S40, the user calculates the quantized gradient and receives s from server A i,k+1 Perform gradient quantization and convert the gradient g i,k+1 Quantify It forms a triple with its norm and sign vector And set the download time of this round dt i,k+1 , calculation time ct i,k+1 , communication time mt i,k+1 Keep it;
[0011] S50, user protection gradient privacy, each user obtains the public key of server A, B, and calculates the session key between the server and the user with his own private key, inputs the two session keys into the pseudo-random generator, generates two random numbers, and adds the two random numbers to the quantized gradient Qs i,k+1 (g i,k+1 ) performs XOR operation to calculate the quantized gradient after blinding Then its sign bit and norm form a triple Then send it to server A;
[0012] S60, the server calculates the Boolean share, and server A receives the triple sent by the user According to the quantization level of each user, verify whether the quantization gradient is complete. If it is complete, (||g i,k+1 ||2,σ i,k+1 ) is sent to server B, otherwise it is discarded. Server A uses its own private key and the verified user public key to calculate the corresponding session key, and puts it into the random generator to obtain a binary random number. The binary random number is XORed with the blinded quantization gradient to obtain the Boolean shared vector Server B uses its own private key and the verified user public key to calculate the corresponding session key, and puts the session key into the random generator to obtain a binary number, that is, the Boolean shared value h i,2 ;
[0013] S70, the server converts the Boolean share to the arithmetic share. Servers A and B convert the Boolean share value by generating a public key and a ciphertext, and use oblivious transfer to calculate the corresponding double verification bit. Servers A and B convert the Boolean share value to the arithmetic share value respectively, and complete the conversion of each bit by exchanging the calculation results, and finally generate the user's arithmetic share vector;
[0014] S80, calculating global model parameters and auxiliary quantization level stage, servers A and B combine the user's symbol vector into a symbol matrix, and arithmetic sharing into an arithmetic sharing matrix, and use the arithmetic sharing matrix and the symbol matrix to calculate their own aggregation vectors; server B sends its own aggregation vector to server A; A uses B's aggregation vector to calculate the global aggregation gradient, and uses it to calculate the global model parameter w k+1 , calculate the auxiliary quantization level according to the quantization level obtained in S40 And the auxiliary quantization level s' i,k+1 Send it to the corresponding users, and at the same time send the global aggregate gradient and global model parameters of this round to all users;
[0015] S90, model training phase, when the model training round k≤T, user C i Repeat steps S20 to S80, otherwise the user ends the federated learning task, and the system administrator SM and all users obtain the final global aggregate gradient g T and the global model parameter w T .
[0016] Furthermore, the step S10 includes:
[0017] S101. The system administrator builds the platform. All participants register with the aggregation server. The system administrator selects a prime number p and a random number f∈Z p * , Z p * ={1, 2, ..., p-1}, set the initial quantization level of all users to s0, the user initial model parameter to w0, a scaling factor λ, select a pseudo-random generator PRG(.), obtain the system public parameter PP={p,f,PRG(.)}, and publish the system public parameter PP and the related parameters of the federated learning task FP={s0,w0,λ} in a bulletin board;
[0018] S102: Assume that the i-th user participating in the federated learning task is C i , C i Choose a random number r i ∈Z p * , r i As its private key ski And keep it secret, calculate the public key Get a pair of public and private keys (pk i ,sk i );
[0019] S103, server A selects a random number r a ∈Z p * , will r a As server A's private key ask, calculate the public key After getting a pair of public and private keys (ask, apk), server B selects a random number r b ∈Z p * , r b As its private key bsk, calculate the public key A pair of public and private keys (bsk, bpk) is obtained, and the server and the user use their public and private key pairs to build a secure data transmission channel.
[0020] Further, step S20 includes:
[0021] S201: Assume user C i Execute the k+1th round (0≤k≤T). When k=0, the system model parameter w0 is obtained. When k>0, the user obtains the global aggregate gradient g k , w i,k is the model parameter of the kth round, and the global aggregate gradient broadcast by A is g k , C i Received k Then update the local model parameters w i,k+1 =w k -ηg k ;
[0022] S202. Assume that Qs(·) is a random uniform quantization function, the quantization level s∈N={1, 2, ...}, the sign function sgn(x)∈{0, 1}, when x≥0, sgn(x)=0, when x<0, sgn(x)=1, that is, when x is a non-negative number, sgn(x) outputs bit 0, when x is a negative number, sgn(x) outputs bit 1; ζ(v,s) is a probability function, v=(v 1, v 2,… v d )∈R and v≠0, there exists an integer l(0≤l<s) such that |v j | / ||v||2∈[l / s,(l+1) / s], define the probability function ζ(v,s)→{l / s,(l+1) / s}, which is 1-(s·|v j | / ||v||2+l) is equal to l / s, with s·|vj The probability value of | / ||v||2+l is equal to (l+1) / s, j=1,2,…,d. Loss function Where w is the model parameter, l h (w) is the loss value of data sample h, and D is the number of data samples.
[0023] S203, assuming s i,k It is C i The quantization level of the kth round, s' i,k is the auxiliary quantization level, ||g k ||2 is g k The second norm of C i For g k Each component of i,k To quantify, g k,j =Qs i,k (g k,j )=||g k ||2·sgn(g k,j )·ζ(g k ,s i,k ), where 0≤j≤d, so quantization is g' i,k =(g k,1 ,g k,2 ,…,g k,d );C i For g k Each component of s' i,k Quantify, g' k ,j=Qs' i,k (g k,j )=||g k ||2·sgn(g k,j )·ζ(g k ,s i,k ), so quantized to get g" i,k =(g' k,1 ,g' k,2 ,…,g' k,d ), using the quantized gradient g' i,k Update model parameters w' i =w k -ηg' i,k and w" i =w k -ηg" i,k , and use the two model parameters to calculate the corresponding loss value L on the local test set i,k =L(w' i ),L' i,k =L(w” i );
[0024] S204, User Ci L i,k ,L' i,k , the time dt used for downloading parameters in this round i,k , local computing time ct i,k and communication time mt i,k Send to A;
[0025] S205. Assume that g(w) is the gradient of model parameter w, which is the value of user C. i Perform stochastic gradient descent on the local training data to further optimize the model parameters w i,k+1 =w i,k -ηg(w i,k ), and retain the gradient value g i,k+1 =g(w i,k+1 ).
[0026] Further, step S30 includes:
[0027] S301: After receiving the loss values sent by all users, server A calculates the average loss value. and auxiliary user loss value
[0028] S302: Server A calculates the real L by using the model parameters and gradients saved in the kth round. k-1 ;
[0029] S303: Server A estimates the k-th round user's quantization level s k and auxiliary quantization level s' k The average time T when quantizing the gradient k-1,k and auxiliary average time T' k-1,k , where st k is the time spent by the server in round k, so Server A calculates the number of quantization bits of the user at different quantization levels Estimate the communication time mt′ at the auxiliary quantization level i,k = b′ i,k / b i,k mt i,k , calculate
[0030] S304, A calculates two loss reduction rates pass To obtain the derivative sign, replace s k Update to the opposite direction of sign if Initial quantization level of the k+1th round if get Server A calculates the global aggregate gradient g for round kk The norm of ||g k ||, and calculate the final quantization level of the k+1th round through the gradient norm
[0031] S305. Assumption Y i,k User C i The transmission time coefficient of the k+1th round, b i,k+1 For user C i The number of quantization bits, A is based on the previous k rounds of user C i The local computation time ct i,k Estimate the local computation time for k+1 rounds The communication time is estimated using the communication time of the kth round, where Transmission time coefficient Y i,k =mt i,k / b i,k , A calculates C i The local training time t i,k+1 =ct i,k+1 +mt i,k+1 ≈ct i,k+1 +b i,k+1 ×Y i,k+1 , since any two users C i and C j Quantization bit b i,k+1 , b j,k+1 Satisfy b j,k+1 =1 / Y j,k (ct i,k+1 -ct j,k+1 +b i,k+1 ×Y i,k+1 ), by allocating the number of quantization bits, the local training time of n users meets t 1,k+1 =t 2,k+1 =…=t n,k+1 ,and So suppose user C i The quantization level s i,k+1 =s k+1 and but The output quantization level of the k+1th round is calculated accordingly and sent to each user.
[0032] Further, step S40 includes:
[0033] S401, User C i Receive the quantization level s from server A i,k+1 , let g i,j,k+1 is the gradient g i,k+1The jth component of 1≤j≤d, let the sign function sgn(x)∈{0,1}, when x≥0, sgn(x)=0, when x<0, sgn(x)=1, that is, when x is a non-negative number, sgn(x) outputs bit 0, when x is a negative number, sgn(x) outputs bit 1;
[0034] S402, User C i Using the sign function sgn(x), the gradient vector g i,k+1 Each component of σ is calculated with the corresponding symbol value σ i,j,k+1 =sgn(g i,j,k+1 ), we get the vector g i,k+1 The symbol vector σ i,k+1 =(σ i,1,k+1, σ i,2,k+1 , …, σ i,d,k+1 );
[0035] S403, User C i Calculate the gradient norm of this round ||g i,k+1 ||2, and calculate each gradient classification g i,j,k+1 The absolute value of |gi,j,k+1| will be the interval [0,||g i,k+1 ||2] The interval is divided into s i,k+1 -1 interval of equal length, that is, 0 = τ0 < τ1 < τ2 < ... < τs i,k+1 =||g i,k+1 ||2, when the gradient g i,j,k+1 In the interval [τ i ,τ i+1 ), which falls on τ i The probability of the endpoint is p = 1-(|g i,j,k+1 |-τ i ) / (τ i+1 -τ i ), falls on τ i+1 The probability of is (1-p), so each gradient component is quantized as Get quantized gradients Form a triple Each portion The length is
[0036] S404, User C i Set the download time of this round dt i,k+1 , calculation time ct i,k+1 , the communication time is retained mt i,k+1 .
[0037] Further, step S50 includes:
[0038] S501, User C i Use your own private key sk i Calculate the random number with the public keys apk and bpk of servers A and B respectively Then use the pseudo-random generator PRG(.) to generate two random binary bits h of length Li i,a =PRG(r i,a ) and h i,b =PRG(r i,b );
[0039] S502: Quantized gradient vector Each component Blindness is performed to protect privacy, that is, Composition blindness Get triples And send it to server A.
[0040] Further, step S60 includes:
[0041] S601, server A receives triplet verify Is the binary length of d·L i , and ||g i,k+1 ||2 is greater than zero; if The length is equal to d·L i And||g i,k+1 ||2 is greater than zero, then (||g i,k+1 ||2,σ i,k+1 ) is sent to server B, otherwise it is discarded;
[0042] S602, server A uses its private key ask and the user's public key pk i , calculate the random number r i,a Put it into the pseudo-random generator PRG(.) and generate a random binary bit h i,a =PRG(r i,a ), and then blind the gradient Each component Perform a Boolean transformation Get Boolean shared vector
[0043] S603, server B receives (||g i,k+1 ||2,σ i,k+1 ), using its private key bsk and the user's public key pk i Calculate a random number And put it into the pseudo-random generator PRG(.) to get a length of L i The binary random number h i,b =PRG(r i,b ).
[0044] Further, step S70 includes:
[0045] S701. Server A selects a random bit b1∈{1,0} and two random numbers z, C∈Z p * , and sends C to server B. B also selects a random bit b2∈{1,0} and a random public-private key pair (pk,sk), and sets pk'=C-pk. When b2=1, set pk1 * =pk',pk2 * =pk, when b2 = 0, let pk1 * =pk,pk2 * =pk', and the public key pair (pk1 * ,pk2 * ) to server A;
[0046] S702, A receives the public key pair (pk1 * ,pk2 * ), calculate the ciphertext (e1,e2) = (Enc(z,pk1 * ),Enc(z+b1,pk2 * )) and sends the ciphertext (e1, e2) to B. After B receives the ciphertext (e1, e2), when b2=1, it decrypts e2 with sk:
[0047] Dec(e2,sk)=Dec(Enc(z+b1,pk2 * ),sk)=Dec(Enc(z+b1,pk),sk)=z+b1, otherwise when b2=0, decrypt e1 with sk:Dec(e1,sk)=Dec(Enc(z,pk1 * ),sk)=Dec(Enc(z,pk),sk)=z, B can only get one of z and z+b1, so let a=z+b1b2(mod p);
[0048] S703, A calculates b1'=b1+2z(mod p), that is, converts the Boolean share b1 into the corresponding arithmetic share b1', and generates a double verification bit (b1, b1'). Server B calculates b2'=b2-2a(mod p)=b2-2z-2b1b2(mod p), that is, converts the Boolean share b2 into the corresponding arithmetic share b2', and generates a double verification bit (b2, b2'). Therefore, the execution of S701 to S703 between the two servers can realize the conversion of Boolean shares b1 and b2 into corresponding arithmetic shares b1' and b2';
[0049] S704, due to is a vector The jth component of i To convert the Boolean shared value of bit into the corresponding arithmetic shared value, server A needs L i double verification bit, let (b 1,t ,b 1,t ')yes The t-th double verification bit (1≤t≤L i ), A executes steps S701 to S703, and each Boolean share b 1,t Transformed into the corresponding arithmetic share b 1,t ';Server B command (b 2,t ,b 2,t ') is h i,b The t-th double verification bit (1≤t≤L i ), to make the length L i The Boolean shared value h i,b Convert to the corresponding arithmetic shared value, B executes steps S701 to S703, converting each Boolean share b 2,t Transformed into the corresponding arithmetic share b 2,t ';
[0050] S705, Order is a vector The tth binary bit of h i,b,t is a Boolean value h i,b The t-th binary bit (1≤t≤L i ), server A uses double authentication bit (b 1,t ,b 1,t ') and Boolean shared bits calculate Send v1 to B; Server B uses a double verification bit (b 2,t ,b 2,t ') and a Boolean shared bit h i,b,t ∈{0,1}, calculate Send v2 to A; A and B calculate A gets the arithmetic shared value g′ of the tth bit i,j,t,k+1 =v+b 1,t '-2vb 1,t '(mod p), B obtains the arithmetic shared value h' of the tth bit i,j,t =b2,t '-2vb 2,t '(mod p); because It can be calculated Servers A and B implement the conversion of single-bit Boolean shares to corresponding arithmetic shares;
[0051] S706, A uses each arithmetic shared value g′ i,j,t,k+1 (1≤t≤L i )calculate Calculate user C i The arithmetic shared vector g′ i,k+1 =(g′ i,1,k+1 ,g′ i,2,k+1 ,…,g′ i,d,k+1 ); B calculates each bit of the arithmetic shared value h′ i,j,t (1≤t≤L i ), Calculate user C i The arithmetic shared vector h′ i =(h′ i,1 ,h′ i,2 ,…,h′ i,d ).
[0052] Further, step S80 includes:
[0053] S801, Server A and User C i The arithmetic shared vector g′ i,k+1 Form an n-row d-column arithmetic shared matrix G n×d , 1≤i≤n; server B and user C i The arithmetic shared vector h′ i Form an n-row d-column arithmetic shared matrix H n×d , 1≤i≤m; A takes the symbol vector σ of n users i,k+1 =(σ i,1,k+1, σ i,2,k+1, … , σ i,d,k+1 ), forming a symbol matrix F with n rows and d columns n×d , let F j Represents the symbol matrix F n×d The jth column of G j Denotes the arithmetic sharing matrix G n×d The jth column of
[0054] S802, for 1≤j≤d, when F j The sign bit σ i,j,k+1 = 0, 1≤i≤n, server A uses G j Calculate the corresponding components in the column When F jThe sign bit σ i,j,k+1 =1, 1≤i≤n, calculate Get two vectors g1 + =(g 1,1 + ,g 1,2 + ,…,g 1,d + ) and g1 - =(g 1,1 - ,g 1,2 - ,…,g 1,d - ), where vector g1 + It's G j The vector consisting of the sum of all positive numbers in the corresponding components of the column, vector g1 - It's G j A vector consisting of the sum of all negative numbers of the corresponding components in the column;
[0055] S803, server B sends the symbol vector σ of n participants i,k+1 =(σ i,1,k+1, σ i,2,k+1 , …, σ i,d,k+1 ), forming a symbol matrix F with n rows and d columns n×d , where F j is the symbolic matrix F n×d The jth column of H j Denotes the arithmetic sharing matrix H n×d The jth column of j The sign bit σ i,d,k+1 = 0, 1≤i≤n, server B uses H j Calculate the corresponding components in the column When F j The sign bit σ i,j =1, 1≤i≤m, calculate Get two vectors g2 + =(g 2,1 + ,g 2,2 + ,…,g 2,d + ) and g2 - =(g 2,1 - ,g 2,2 - ,…,g 2,d - ), and g2 + and g2- Sent to A; where vector g2 + Yes H j The vector consisting of the sum of all positive numbers in the corresponding components of the column, vector g2 - Yes H j A vector consisting of the sum of all negative numbers of the corresponding components in the column;
[0056] S804, server A is represented by vector g1 + ,g2 + ,g1 - and g2 - For each component of and the scaling factor λ, calculate:
[0057] g j + =(g 1,j + +g 2,j + mod p) / 10 λ ,
[0058] g j - =(g 1,j - +g 2,j - mod p) / 10 λ ,
[0059] Get two vectors g + =(g1 + ,g2 + ,…,g d + ) and vector g - =(g1 - ,g1 - ,…,g d - ); Server A calculates and updates the global aggregate gradient: g k+1 =g k +(g + -g - ) / n.
[0060] S805, A uses g k+1 Update the global model parameters w k+1 =w k -ηg k+1。
[0061] S806: Server A calculates the quantization level s obtained in S30. k+1 ,pass Get auxiliary quantization level s' k+1 , and according to step S305, the auxiliary quantization level s'k+1 Assigned to each user;
[0062] S807, A will g k+1 and w k+1 Sent to each user.
[0063] Further, step S90 includes:
[0064] S901, when the model training round k≤T, user C i Repeat steps S20 to S90, otherwise the user ends the federated learning task, and the system administrator SM and all users obtain the final global aggregate gradient g T and the global model parameter w T .
[0065] Table 1 shows the symbols in the present invention
[0066]
[0067]
[0068]
[0069]
[0070] Compared with the prior art, the present invention has the following beneficial effects:
[0071] (1) The present invention provides a heterogeneous adaptive quantization privacy-preserving federated learning method. The server infers the quantization level of this round based on the model loss of the previous round, and allocates the corresponding quantization level according to the different computing power and communication capabilities of each user, so as to solve the problem of high total time overhead caused by long server waiting time. In addition, the communication bottleneck problem is solved through quantization technology, so that the model can be quickly trained in federated learning.
[0072] (2) The present invention provides a heterogeneous adaptive quantitative privacy-preserving federated learning method, which uses the Diffie-Hellman key exchange protocol to establish a secure communication channel and combines Boolean sharing to blind the user's gradient, thereby effectively protecting the user's privacy. Because lightweight Boolean operations are used, the user's communication overhead is not increased.
[0073] (3) The present invention provides a heterogeneous adaptive quantitative privacy-preserving federated learning method, in which the Boolean shares owned by each server are converted into arithmetic shares through the method of oblivious transmission between servers, and the servers use the arithmetic shares to aggregate the global model.
[0074] (4) The present invention can dynamically adjust the quantization level through the current training loss and allocate corresponding quantization levels according to the communication capabilities of different devices, so as to solve the problem of heterogeneity. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0076] Figure 1 A flowchart of a heterogeneous adaptive quantitative privacy-preserving federated learning method provided by the present invention.
[0077] Figure 2 A system structure diagram of a heterogeneous adaptive quantitative privacy-preserving federated learning method provided by the present invention. DETAILED DESCRIPTION
[0078] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. Of course, the specific examples described here are only used to explain the present invention and are not used to limit the present invention.
[0079] Example 1
[0080] Reference Figure 1 to Figure 2 , the technical solution provided by this embodiment is, a heterogeneous adaptive quantitative privacy protection federated learning method, such as Figure 1 As shown in the figure, it includes the system initialization stage, the user updates the local model stage, the server calculates the next round of quantization level, the user performs quantization gradient, the user protects privacy, the server calculates Boolean sharing, the conversion from Boolean sharing to arithmetic sharing, calculates global model parameters, the server calculates auxiliary quantization level and sends it to each user with the global aggregate gradient, and the model training stage. Figure 2 As shown in the figure, the system model of a heterogeneous adaptive quantitative privacy-preserving federated learning method consists of four entities: system administrator SM, user C i , Server A and Server B. The system administrator SM is a trusted entity and will correctly perform the system initialization steps. Participant C i Semi-honest, they will correctly perform local model training, quantization, and privacy protection. Servers A and B are semi-honest. They deduce the quantization level of each client based on the loss and training time at different quantization levels sent by the user, and assign the quantization level to each user. They will correctly verify the triples sent by the user, implement the conversion from Boolean to arithmetic sharing, aggregate the arithmetic sharing, and calculate and update the global model parameters.
[0081] This example provides a heterogeneous adaptive quantitative privacy-preserving federated learning method, which includes the following steps:
[0082] S10, system initialization phase, the system administrator SM builds the system platform, generates public system parameters PP, and publicly releases PP and related parameters FP of federated learning; each user, server A and B uses the public parameters to generate their own public key and private key pair; users apply to participate in the training of certain federated learning tasks on the platform, and all users’ quantitative levels s i,0 Initialize s0, the initial model vector w for each user i,0 =w0;
[0083] S20, user updates local model stage, each user C i Use the global aggregate gradient g sent by server A k Update local model weights w i,k+1 , and according to the received quantitative level s i,k and auxiliary quantization s' i,k Quantify the gradient g' i,k and g" i,k , update the model parameters to w' according to the quantized gradient i and w" i , through the model parameter w' on the local test set i and w" i Predict the loss value L i,k and L' i,k ; The loss value L calculated based on the quantization level and the auxiliary quantization level i,k ,L' i,k , download time dt i,k , calculation time ct i,k , communication time mt i,k Sent to the server for calculating the next round of quantization level;
[0084] S30, server A calculates the quantization level and receives the loss value L from all users i,k ,L' i,k , download time dt i,k , calculation time ct i,k and communication time mt i,k , estimate the two loss reduction rates R k ,R' k , calculate the derivative of the loss function to determine the quantization level s for the k+1th round k+1 The update direction of the aggregated gradient is further adjusted according to the gradient norm of the aggregated gradient. k+1 ; Server A estimates the computing time and communication time of each user and allocates an appropriate number of quantization bits b to each user i,k+1, so that the local training time of all users is equal;
[0085] S40, the user calculates the quantized gradient and receives s from server A i,k+1 Perform gradient quantization and convert the gradient g i,k+1 Quantify It forms a triple with its norm and sign vector And set the download time of this round dt i,k+1 , calculation time ct i,k+1 , communication time mt i,k+1 Keep it;
[0086] S50, user protection gradient privacy, each user obtains the public key of server A, B, and calculates the session key between the server and the user with his own private key, inputs the two session keys into the pseudo-random generator, generates two random numbers, and adds the two random numbers to the quantized gradient Qs i,k+1 (g i,k+1 ) performs XOR operation to calculate the quantized gradient after blinding Then its sign bit and norm form a triple Then send it to server A;
[0087] S60, the server calculates the Boolean share, and server A receives the triple sent by the user According to the quantization level of each user, verify whether the quantization gradient is complete. If it is complete, (||g i,k+1 ||2,σ i,k+1 ) is sent to server B, otherwise it is discarded. Server A uses its own private key and the verified user public key to calculate the corresponding session key, and puts it into the random generator to obtain a binary random number. The binary random number is XORed with the blinded quantization gradient to obtain the Boolean shared vector Server B uses its own private key and the verified user public key to calculate the corresponding session key, and puts the session key into the random generator to obtain a binary number, that is, the Boolean shared value h i,2 ;
[0088] S70, the server converts the Boolean share to the arithmetic share. Servers A and B convert the Boolean share value by generating a public key and a ciphertext, and use oblivious transfer to calculate the corresponding double verification bit. Servers A and B convert the Boolean share value to the arithmetic share value respectively, and complete the conversion of each bit by exchanging the calculation results, and finally generate the user's arithmetic share vector;
[0089] S80, calculating global model parameters and auxiliary quantization level stage, servers A and B combine the user's symbol vector into a symbol matrix, and arithmetic sharing into an arithmetic sharing matrix, and use the arithmetic sharing matrix and the symbol matrix to calculate their own aggregation vectors; server B sends its own aggregation vector to server A; A uses B's aggregation vector to calculate the global aggregation gradient, and uses it to calculate the global model parameter w k+1 , calculate the auxiliary quantization level according to the quantization level obtained in S40 And the auxiliary quantization level s' i,k+1 Send it to the corresponding users, and at the same time send the global aggregate gradient and global model parameters of this round to all users;
[0090] S90, model training phase, when the model training round k≤T, user C i Repeat steps S20 to S80, otherwise the user ends the federated learning task, and the system administrator SM and all users obtain the final global aggregate gradient g T and the global model parameter w T .
[0091] The step S10 specifically includes the following steps:
[0092] S101. The system administrator builds the platform. All participants register with the aggregation server. The system administrator selects a prime number p and a random number f∈Z p * , Z p * ={1, 2, ..., p-1}, set the initial quantization level of all users to s0, the user initial model parameter to w0, a scaling factor λ, select a pseudo-random generator PRG(.), obtain the system public parameter PP={p,f,PRG(.)}, and publish the system public parameter PP and the related parameters of the federated learning task FP={s0,w0,λ} in a bulletin board;
[0093] S102: Assume that the i-th user participating in the federated learning task is C i , C i Choose a random number r i ∈Z p * , r i As its private key sk i And keep it secret, calculate the public key Get a pair of public and private keys (pk i ,sk i );
[0094] S103, server A selects a random number r a ∈Z p* , will r a As server A's private key ask, calculate the public key After getting a pair of public and private keys (ask, apk), server B selects a random number r b ∈Z p * , r b As its private key bsk, calculate the public key A pair of public and private keys (bsk, bpk) is obtained, and the server and the user use their public and private key pairs to build a secure data transmission channel.
[0095] The step S20 specifically includes the following steps:
[0096] S201: Assume user C i Execute the k+1th round (0≤k≤T). When k=0, the system model parameter w0 is obtained. When k>0, the user obtains the global aggregate gradient g k , w i,k is the model parameter of the kth round, and the global aggregate gradient broadcast by A is g k , C i Received k Then update the local model parameters w i,k+1 =w k -ηg k ;
[0097] S202. Assume that Qs(·) is a random uniform quantization function, the quantization level s∈N={1, 2, ...}, the sign function sgn(x)∈{0, 1}, when x≥0, sgn(x)=0, when x<0, sgn(x)=1, that is, when x is a non-negative number, sgn(x) outputs bit 0, when x is a negative number, sgn(x) outputs bit 1; ζ(v,s) is a probability function, v=(v 1, v 2,… v d )∈R and v≠0, there exists an integer l(0≤l<s) such that |v j | / ||v||2∈[l / s,(l+1) / s], define the probability function ζ(v,s)→{l / s,(l+1) / s}, which is 1-(s·|v j | / ||v||2+l) is equal to l / s, with s·|v j The probability value of | / ||v||2+l is equal to (l+1) / s, j=1,2,…,d. Loss function Where w is the model parameter, l h (w) is the loss value of data sample h, and D is the number of data samples.
[0098] S203, assuming si,k It is C i The quantization level of the kth round, s' i,k is the auxiliary quantization level, ||g k ||2 is g k The second norm of C i For g k Each component of i,k To quantify, g k,j =Qs i,k (g k,j )=||g k ||2·sgn(g k,j )·ζ(g k ,s i,k ), where 0≤j≤d, so quantization is g' i,k =(g k,1 ,g k,2 ,…,g k,d );C i For g k Each component of s' i,k Quantify, g' k,j =Qs' i,k (g k,j )=||g k ||2·sgn(g k,j )·ζ(g k ,s i,k ), so quantized to get g" i,k =(g' k,1 ,g' k,2 ,…,g' k,d ), using the quantized gradient g' i,k Update model parameters w' i =w k -ηg' i,k and w" i =w k -ηg" i,k , and use the two model parameters to calculate the corresponding loss value L on the local test set i,k =L(w' i ),L' i,k =L(w” i );
[0099] S204, User C i L i,k ,L' i,k , the time dt used for downloading parameters in this round i,k , local computing time ct i,k and communication time mt i,k Send to A;
[0100] S205. Assume that g(w) is the gradient of model parameter w, which is the value of user C. i Perform stochastic gradient descent on the local training data to further optimize the model parameters w i,k+1 =w i,k -ηg(w i,k ), and retain the gradient value g i,k+1 =g(w i,k+1 ).
[0101] The step S30 specifically includes the following steps:
[0102] S301: After receiving the loss values sent by all users, server A calculates the average loss value. and auxiliary user loss value
[0103] S302: Server A calculates the real L by using the model parameters and gradients saved in the kth round. k-1 ;
[0104] S303: Server A estimates the k-th round user's quantization level s k and auxiliary quantization level s' k The average time T when quantizing the gradient k-1,k and auxiliary average time T' k-1,k , where st k is the time spent by the server in round k, so Server A calculates the number of quantization bits of the user at different quantization levels Estimate the communication time mt′ at the auxiliary quantization level i,k = b′ i,k / b i,k mt i,k , calculate
[0105] S304, A calculates two loss reduction rates pass To obtain the derivative sign, replace s k Update to the opposite direction of sign if Initial quantization level of the k+1th round if get Server A calculates the global aggregate gradient g for round k k The norm of ||g k ||, and calculate the final quantization level of the k+1th round through the gradient norm
[0106] S305. Assumption Y i,k User C i The transmission time coefficient of the k+1th round, bi,k+1 For user C i The number of quantization bits, A is based on the previous k rounds of user C i The local computation time ct i,k Estimate the local computation time for k+1 rounds The communication time is estimated using the communication time of the kth round, where Transmission time coefficient Y i,k =mt i,k / b i,k , A calculates C i The local training time t i,k+1 =ct i,k+1 +mt i,k+1 ≈ct i,k+1 +b i,k+1 ×Y i,k+1 , since any two users C i and C j Quantization bit b i,k+1 , b j,k+1 Satisfy b j,k+1 =1 / Y j,k (ct i,k+1 -ct j,k+1 +b i,k+1 ×Y i,k+1 ), by allocating the number of quantization bits, the local training time of n users meets t 1,k+1 =t 2,k+1 =…=t n,k+1 ,and So suppose user C i The quantization level s i,k+1 =s k+1 and but The output quantization level of the k+1th round is calculated accordingly and sent to each user.
[0107] The step S40 specifically includes the following steps:
[0108] S401, User C i Receive the quantization level s from server A i,k+1 , let g i,j,k+1 is the gradient g i,k+1 The jth component of 1≤j≤d, let the sign function sgn(x)∈{0,1}, when x≥0, sgn(x)=0, when x<0, sgn(x)=1, that is, when x is a non-negative number, sgn(x) outputs bit 0, when x is a negative number, sgn(x) outputs bit 1;
[0109] S402, User C i Using the sign function sgn(x), the gradient vector gi,k+1 Each component of σ is calculated with the corresponding symbol value σ i,j,k+1 =sgn(g i,j,k+1 ), we get the vector g i,k+1 The symbol vector σ i,k+1 =(σ i,1,k+1, σ i,2,k+1, …, σ i,d,k+1 );
[0110] S403, User C i Calculate the gradient norm of this round ||g i,k+1 ||2, and calculate each gradient classification g i,j,k+1 The absolute value of |gi,j,k+1| will be the interval [0,||g i,k+1 ||2] The interval is divided into s i,k+1 -1 interval of equal length, that is, 0 = τ0 < τ1 < τ2 < ... < τs i,k+1 =||g i,k+1 ||2, when the gradient g i,j,k+1 In the interval [τ i ,τ i+1 ), which falls on τ i The probability of the endpoint is p = 1-(|g i,j,k+1 |-τ i ) / (τ i+1 -τ i ), falls on τ i+1 The probability of is (1-p), so each gradient component is quantized as Get quantized gradients Form a triple Each portion The length is
[0111] S404, User C i Set the download time of this round dt i,k+1 , calculation time ct i,k+1 , the communication time is retained mt i,k+1 .
[0112] The step S50 specifically includes the following steps:
[0113] S501, User C i Use your own private key sk i Calculate the random number with the public keys apk and bpk of servers A and B respectively Then use the pseudo-random generator PRG(.) to generate two random binary bits h of length Li i,a =PRG(r i,a ) and h i,b=PRG(r i,b );
[0114] S502: Quantized gradient vector Each component Blindness is performed to protect privacy, that is, Composition blindness Get triples And send it to server A.
[0115] The step S60 specifically includes the following steps:
[0116] S601, server A receives triplet verify Is the binary length of d·L i , and ||g i,k+1 ||2 is greater than zero; if The length is equal to d·L i And||g i,k+1 ||2 is greater than zero, then (||g i,k+1 ||2,σ i,k+1 ) is sent to server B, otherwise it is discarded;
[0117] S602, server A uses its private key ask and the user's public key pk i , calculate the random number r i,a Put it into the pseudo-random generator PRG(.) and generate a random binary bit h i,a =PRG(r i,a ), and then blind the gradient Each component Perform a Boolean transformation Get Boolean shared vector
[0118] S603, server B receives (||g i,k+1 ||2,σ i,k+1 ), using its private key bsk and the user's public key pk i Calculate a random number And put it into the pseudo-random generator PRG(.) to get a length of L i The binary random number h i,b =PRG(r i,b ).
[0119] The step S70 specifically includes the following steps: S701, server A selects a random bit b1∈{1,0} and two random numbers z, C∈Z p* , and sends C to server B. B also selects a random bit b2∈{1,0} and a random public-private key pair (pk,sk), and sets pk'=C-pk. When b2=1, set pk1 * =pk',pk2 * =pk, when b2 = 0, let pk1 * =pk,pk2 * =pk', and the public key pair (pk1 * ,pk2 * ) to server A;
[0120] S702, A receives the public key pair (pk1 * ,pk2 * ), calculate the ciphertext (e1,e2) = (Enc(z,pk1 * ),Enc(z+b1,pk2 * )), and sends the ciphertext (e1, e2) to B. After B receives the ciphertext (e1, e2), when b2 = 1, it uses sk to decrypt e2: Dec(e2, sk) = Dec(Enc(z+b1, pk2 * ),sk)=Dec(Enc(z+b1,pk),sk)=z+b1, otherwise when b2=0, decrypt e1 with sk:Dec(e1,sk)=Dec(Enc(z,pk1 * ),sk)=Dec(Enc(z,pk),sk)=z, B can only get one of z and z+b1, so let a=z+b1b2(mod p);
[0121] S703, A calculates b1'=b1+2z(mod p), that is, converts the Boolean share b1 into the corresponding arithmetic share b1', and generates a double verification bit (b1, b1'). Server B calculates b2'=b2-2a(mod p)=b2-2z-2b1b2(mod p), that is, converts the Boolean share b2 into the corresponding arithmetic share b2', and generates a double verification bit (b2, b2'). Therefore, the execution of S701 to S703 between the two servers can realize the conversion of Boolean shares b1 and b2 into corresponding arithmetic shares b1' and b2';
[0122] S704, due to is a vector The jth component of i To convert the Boolean shared value of bit into the corresponding arithmetic shared value, server A needs L i double verification bit, let (b 1,t ,b1,t ')yes The t-th double verification bit (1≤t≤L i ), A executes steps S701 to S703, and each Boolean share b 1,t Transformed into the corresponding arithmetic share b 1,t ';Server B command (b 2,t ,b 2,t ') is h i,b The t-th double verification bit (1≤t≤L i ), to make the length L i The Boolean shared value h i,b Convert to the corresponding arithmetic shared value, B executes steps S701 to S703, converting each Boolean share b 2,t Transformed into the corresponding arithmetic share b 2,t ';
[0123] S705, Order is a vector The tth binary bit of h i,b,t is a Boolean value h i,b The t-th binary bit (1≤t≤L i ), server A uses double authentication bit (b 1,t ,b 1,t ') and Boolean shared bits calculate Send v1 to B; Server B uses a double verification bit (b 2,t ,b 2,t ') and a Boolean shared bit h i,b,t ∈{0,1}, calculate Send v2 to A; A and B calculate A gets the arithmetic shared value g′ of the tth bit i,j,t,k+1 =v+b 1,t '-2vb 1,t '(mod p), B obtains the arithmetic shared value h' of the tth bit i,j,t =b 2,t '-2vb 2,t '(mod p); because It can be calculated Servers A and B implement the conversion of single-bit Boolean shares to corresponding arithmetic shares;
[0124] S706, A uses each arithmetic shared value g′ i,j,t,k+1 (1≤t≤L i )calculate Calculate user C i The arithmetic shared vector g′ i,k+1 =(g′i,1,k+1 ,g′ i,2,k+1 ,…,g′ i,d,k+1 ); B calculates each bit of the arithmetic shared value h′ i,j,t (1≤t≤L i ), Calculate user C i The arithmetic shared vector h′ i =(h′ i,1 ,h′ i,2 ,…,h′ i,d ).
[0125] The step S80 specifically includes the following steps:
[0126] S801, Server A and User C i The arithmetic shared vector g′ i,k+1 Form an n-row d-column arithmetic shared matrix G n×d , 1≤i≤n; server B and user C i The arithmetic shared vector h′ i Form an n-row d-column arithmetic shared matrix H n×d , 1≤i≤m; A takes the symbol vector σ of n users i,k+1 =(σ i,1,k+1, σ i,2,k+1, … , σ i,d,k+1 ), forming a symbol matrix F with n rows and d columns n×d , let F j Represents the symbol matrix F n×d The jth column of G j Denotes the arithmetic sharing matrix G n×d The jth column of
[0127] S802, for 1≤j≤d, when F j The sign bit σ i,j,k+1 = 0, 1≤i≤n, server A uses G j Calculate the corresponding components in the column When F j The sign bit σ i,j,k+1 =1, 1≤i≤n, calculate Get two vectors g1 + =(g 1,1 + ,g 1,2 + ,…,g 1,d + ) and g1 - =(g 1,1 - ,g 1,2 -,…,g 1,d - ), where vector g1 + It's G j The vector consisting of the sum of all positive numbers in the corresponding components of the column, vector g1 - It's G j A vector consisting of the sum of all negative numbers of the corresponding components in the column;
[0128] S803, server B sends the symbol vector σ of n participants i,k+1 =(σ i,1,k+1 , σ i,2,k+1 ,… , σ i,d,k+1 ), forming a symbol matrix F with n rows and d columns n×d , where F j is the symbolic matrix F n×d The jth column of H j Denotes the arithmetic sharing matrix H n×d The jth column of j The sign bit σ i,d,k+1 = 0, 1≤i≤n, server B uses H j Calculate the corresponding components in the column When F j The sign bit σ i,j =1, 1≤i≤m, calculate Get two vectors g2 + =(g 2,1 + ,g 2,2 + ,…,g 2,d + ) and g2 - =(g 2,1 - ,g 2,2 - ,…,g 2,d - ), and g2 + and g2 - Sent to A; where vector g2 + Yes H j The vector consisting of the sum of all positive numbers in the corresponding components of the column, vector g2 - Yes H j A vector consisting of the sum of all negative numbers of the corresponding components in the column;
[0129] S804, server A is represented by vector g1 + ,g2 + ,g1 - and g2 -For each component of and the scaling factor λ, calculate:
[0130] g j + =(g 1,j + +g 2,j + mod p) / 10 λ ,
[0131] g j - =(g 1,j - +g 2,j - mod p) / 10 λ ,
[0132] Get two vectors g + =(g1 + ,g2 + ,…,g d + ) and vector g - =(g1 - ,g1 - ,…,g d - ); Server A calculates and updates the global aggregate gradient: g k+1 =g k +(g + -g - ) / n.
[0133] S805, A uses g k+1 Update the global model parameters w k+1 =w k -ηg k+1。
[0134] S806: Server A calculates the quantization level s obtained in S30. k+1 ,pass Get auxiliary quantization level s' k+1 , and according to step S305, the auxiliary quantization level s' k+1 Assigned to each user;
[0135] S807, A will g k+1 and w k+1 Sent to each user.
[0136] The step S90 specifically includes the following steps:
[0137] S901, when the model training round k≤T, user C iRepeat steps S20 to S90, otherwise the user ends the federated learning task, and the system administrator SM and all users obtain the final global aggregate gradient g T and the global model parameter w T .
[0138] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A heterogeneous adaptive quantitative privacy-preserving federated learning method, including three types of entities: system administrator, user and server, characterized in that: The following steps are included S10, system initialization phase, the system administrator SM builds the system platform, generates public system parameters PP, and publicly releases PP and related parameters FP of federated learning; each user, server A and B uses the public parameters to generate their own public key and private key pair; users apply to participate in the training of certain federated learning tasks on the platform, and all users’ quantitative levels s i,0 Initialize s0, the initial model vector w for each user i,0 =w0; S20, user updates local model stage, each user C i Use the global aggregate gradient g sent by server A k Update local model weights w i,k+1 , and according to the received quantitative level s i,k and auxiliary quantization s' i,k Quantify the gradient g' i,k and g" i,k , update the model parameters to w' according to the quantized gradient i and w" i , through the model parameter w' on the local test set i and w" i Predict the loss value L i,k and L' i,k ; The loss value L calculated based on the quantization level and the auxiliary quantization level i,k ,L' i,k , download time dt i,k , calculation time ct i,k , communication time mt i,k Sent to the server for calculating the next round of quantization level; S30, server A calculates the quantization level and receives the loss value L from all users i,k ,L' i,k , download time dt i,k , calculation time ct i,k and communication time mt i,k , estimate the two loss reduction rates R k ,R' k , calculate the derivative of the loss function to determine the quantization level s for the k+1th round k+1 The update direction of the aggregated gradient is further adjusted according to the gradient norm of the aggregated gradient. k+1 ; Server A estimates the computing time and communication time of each user and allocates an appropriate number of quantization bits b to each user i,k+1 , so that the local training time of all users is equal; S40, the user calculates the quantized gradient and receives s from server A i,k+1 Perform gradient quantization and convert the gradient g i,k+1 Quantify It forms a triple with its norm and sign vector And set the download time of this round dt i,k+1 , calculation time ct i,k+1 , communication time mt i,k+1 Keep it; S50, user protection gradient privacy, each user obtains the public key of server A, B, and calculates the session key between the server and the user with his own private key, inputs the two session keys into the pseudo-random generator, generates two random numbers, and adds the two random numbers to the quantized gradient Qs i,k+1 (g i,k+1 ) performs XOR operation to calculate the quantized gradient after blinding Then its sign bit and norm form a triple Then send it to server A; S60, the server calculates the Boolean share, and server A receives the triple sent by the user According to the quantization level of each user, verify whether the quantization gradient is complete. If it is complete, (||g i,k+1 ||2,σ i,k+1 ) is sent to server B, otherwise it is discarded. Server A uses its own private key and the verified user public key to calculate the corresponding session key, and puts it into the random generator to obtain a binary random number. The binary random number is XORed with the blinded quantization gradient to obtain the Boolean shared vector Server B uses its own private key and the verified user public key to calculate the corresponding session key, and puts the session key into the random generator to obtain a binary number, that is, the Boolean shared value h i,2 ; S70, the server converts the Boolean share to the arithmetic share. Servers A and B convert the Boolean share value by generating a public key and a ciphertext, and use oblivious transfer to calculate the corresponding double verification bit. Servers A and B convert the Boolean share value to the arithmetic share value respectively, and complete the conversion of each bit by exchanging the calculation results, and finally generate the user's arithmetic share vector; S80, calculating global model parameters and auxiliary quantization level stage, servers A and B combine the user's symbol vector into a symbol matrix, and arithmetic sharing into an arithmetic sharing matrix, and use the arithmetic sharing matrix and the symbol matrix to calculate their own aggregation vectors; server B sends its own aggregation vector to server A; A uses B's aggregation vector to calculate the global aggregation gradient, and uses it to calculate the global model parameter w k+1 , calculate the auxiliary quantization level according to the quantization level obtained in S40 And the auxiliary quantization level s' i,k+1 Send it to the corresponding users, and at the same time send the global aggregate gradient and global model parameters of this round to all users; S90, model training phase, when the model training round k≤T, user C i Repeat steps S20 to S80, otherwise the user ends the federated learning task, and the system administrator SM and all users obtain the final global aggregate gradient g T and the global model parameter w T .
2. The heterogeneous adaptive quantitative privacy-preserving federated learning method according to claim 1, characterized in that: Described step S10 comprises the following steps: S101. The system administrator builds the platform. All participants register with the aggregation server. The system administrator selects a prime number p and a random number f∈Z p * , Z p * ={1, 2, ..., p-1}, set the initial quantization level of all users to s0, the initial model parameters of the users to w0, a scaling factor λ, select a pseudo-random generator PRG(.), η is the learning rate, and obtain the system public parameters PP={p,f,PRG(.)}, and publish the system public parameters PP and the related parameters of the federated learning task FP={s0,w0,λ} on a bulletin board; S102: Assume that the i-th user participating in the federated learning task is C i , C i Choose a random number r i ∈Z p * , r i As its private key sk i And keep it secret, calculate the public key Get a pair of public and private keys (pk i ,sk i ); S103, server A selects a random number r a ∈Z p * , will r a As server A's private key ask, calculate the public key After getting a pair of public and private keys (ask, apk), server B selects a random number r b ∈Z p * , r b As its private key bsk, calculate the public key A pair of public and private keys (bsk, bpk) is obtained, and the server and the user use their public and private key pairs to build a secure data transmission channel.
3. The heterogeneous adaptive quantitative privacy-preserving federated learning method according to claim 1, characterized in that: Described step S20 comprises the following steps: S201: Assume user C i Execute the k+1th round (0≤k≤T). When k=0, the system model parameter w0 is obtained. When k>0, the user obtains the global aggregate gradient g k , w i,k is the model parameter of the kth round, and the global aggregate gradient broadcast by A is g k , C i Received k Then update the local model parameters w i,k+1 =w k -ηg k ; S202. Assume that Qs(·) is a random uniform quantization function, the quantization level s∈N={1, 2, ...}, the sign function sgn(x)∈{0, 1}, when x≥0, sgn(x)=0, when x<0, sgn(x)=1, that is, when x is a non-negative number, sgn(x) outputs bit 0, when x is a negative number, sgn(x) outputs bit 1; ζ(v,s) is a probability function, v=(v 1, v 2,… v d )∈R and v≠0, there exists an integer l(0≤l<s) such that |v j | / ||v||2∈[l / s,(l+1) / s], define the probability function ζ(v,s)→{l / s,(l+1) / s}, which is 1-(s·|v j | / ||v||2+l) is equal to l / s, with s·|v j The probability value of | / ||v||2+l is equal to (l+1) / s, j=1,2,···,d, loss function Where w is the model parameter, l h (w) is the loss value of data sample h, D is the number of data samples; S203, assuming s i,k It is C i The quantization level of the kth round, s' i,k is the auxiliary quantization level, ||g k ||2 is g k The second norm of C i For g k Each component of i,k To quantify, g k,j =Qs i,k (g k,j )=||g k ||2·sgn(g k,j )·ζ(g k ,s i,k ), where 0≤j≤d, so quantization is g' i,k =(g k,1 ,g k,2 ,…,g k,d );C i For g k Each component of s' i,k Quantify, g' k,j =Qs' i,k (g k,j )=||g k ||2·sgn(g k,j )·ζ(g k ,s i,k ), so quantized to get g" i,k =(g' k,1 ,g' k,2 ,…,g' k,d ), using the quantized gradient g' i,k Update model parameters w' i =w k -ηg' i,k and w" i =w k -ηg" i,k , and use the two model parameters to calculate the corresponding loss value L on the local test set i,k =L(w' i ),L' i,k =L(w” i ); S204, User C i L i,k ,L' i,k , the time dt used for downloading parameters in this round i,k , local computing time ct i,k and communication time mt i,k Send to A; S205. Assume that g(w) is the gradient of model parameter w, which is the value of user C. i Perform stochastic gradient descent on the local training data to further optimize the model parameters w i,k+1 =w i,k -ηg(w i,k ), and retain the gradient value g i,k+1 =g(w i,k+1 ).
4. The heterogeneous adaptive quantitative privacy-preserving federated learning method according to claim 1, characterized in that: Described step S30 comprises the following steps: S301: After receiving the loss values sent by all users, server A calculates the average loss value. and auxiliary user loss value S302: Server A calculates the real L by using the model parameters and gradients saved in the kth round. k-1 ; S303: Server A estimates the k-th round user's quantization level s k and auxiliary quantization level s' k The average time T when quantizing the gradient k-1,k and auxiliary average time T' k-1,k , where st k is the time spent by the server in round k, so Server A calculates the number of quantization bits of the user at different quantization levels Estimate the communication time mt at the auxiliary quantization level i ' ,k = b′ i,k / b i,k mt i,k , calculate S304, A calculates two loss reduction rates pass To obtain the derivative sign, replace s k Update to the opposite direction of sign if Initial quantization level of the k+1th round if get Server A calculates the global aggregate gradient g for round k k The norm of ||g k ||, and calculate the final quantization level of the k+1th round through the gradient norm S305. Assumption Y i,k User C i The transmission time coefficient of the k+1th round, b i,k+1 For user C i The number of quantization bits, A is based on the previous k rounds of user C i The local computation time ct i,k Estimate the local computation time for k+1 rounds The communication time is estimated using the communication time of the kth round, where Transmission time coefficient Y i,k =mt i,k / b i,k , A calculates C i The local training time t i,k+1 =ct i,k+1 +mt i,k+1 ≈ct i,k+1 +b i,k+1 ×Y i,k+1 , since any two users C i and C j Quantization bit b i,k+1 , b j,k+1 Satisfy b j,k+1 =1 / Y j,k (ct i,k+1 -ct j,k+1 +b i,k+1 ×Y i,k+1 ), by allocating the number of quantization bits, the local training time of n users meets t 1,k+1 =t 2,k+1 =…=t n,k+1 ,and So suppose user C i The quantization level s i,k+1 =s k+1 and but The output quantization level of the k+1th round is calculated accordingly and sent to each user.
5. The heterogeneous adaptive quantitative privacy-preserving federated learning method according to claim 1, characterized in that: Described step S40 comprises the following steps: S401, User C i Receive the quantization level s from server A i,k+1 , let g i,j,k+1 is the gradient g i,k+1 The jth component of 1≤j≤d, let the sign function sgn(x)∈{0,1}, when x≥0, sgn(x)=0, when x<0, sgn(x)=1, that is, when x is a non-negative number, sgn(x) outputs bit 0, when x is a negative number, sgn(x) outputs bit 1; S402, User C i Using the sign function sgn(x), the gradient vector g i,k+1 Each component of σ is calculated with the corresponding symbol value σ i,j,k+1 =sgn(g i,j,k+1 ), we get the vector g i,k+1 The symbol vector σ i,k+1 =(σ i,1,k+1, σ i,2,k+1, ··· , σ i,d,k+1 ); S403, User C i Calculate the gradient norm of this round ||g i,k+1 ||2, and calculate each gradient classification g i,j,k+1 The absolute value of |gi,j,k+1| will be the interval [0,||g i,k+1 ||2] The interval is divided into s i,k+1 -1 interval of equal length, that is, 0 = τ0 < τ1 < τ2 < ... < τs i,k+1 =||g i,k+1 ||2, when the gradient g i,j,k+1 In the interval [τ i ,τ i+1 ), which falls on τ i The probability of the endpoint is p = 1-(|g i,j,k+1 |-τ i ) / (τ i+1 -τ i ), falls on τ i+1 The probability of is (1-p), so each gradient component is quantized as Get quantized gradients Form a triple Each portion The length is S404, User C i Set the download time of this round dt i,k+1 , calculation time ct i,k+1 , the communication time is retained mt i,k+1 .
6. The heterogeneous adaptive quantitative privacy-preserving federated learning method according to claim 1, characterized in that: Described step S50 comprises the following steps: S501, User C i Use your own private key sk i Calculate the random number with the public keys apk and bpk of servers A and B respectively Then use the pseudo-random generator PRG(.) to generate two random binary bits h of length Li i,a =PRG(r i,a ) and h i,b =PRG(r i,b ); S502: Quantized gradient vector Each component Blindness is performed to protect privacy, that is, Composition blindness Get triples And send it to server A.
7. The heterogeneous adaptive quantitative privacy-preserving federated learning method according to claim 1, characterized in that: Described step S60 comprises the following steps: S601, server A receives triplet verify Is the binary length of d·L i , and ||g i,k+1 ||2 is greater than zero; if The length is equal to d·L i And||g i,k+1 ||2 is greater than zero, then (||g i,k+1 ||2,σ i,k+1 ) is sent to server B, otherwise it is discarded; S602, server A uses its private key ask and the user's public key pk i , calculate the random number r i,a Put it into the pseudo-random generator PRG(.) and generate a random binary bit h i,a =PRG(r i,a ), and then blind the gradient Each component Perform a Boolean transformation Get Boolean shared vector S603, server B receives (||g i,k+1 ||2,σ i,k+1 ), using its private key bsk and the user's public key pk i Calculate a random number And put it into the pseudo-random generator PRG(.) to get a length of L i The binary random number h i,b =PRG(r i,b ).
8. The heterogeneous adaptive quantitative privacy-preserving federated learning method according to claim 1, characterized in that: The step S70 comprises the following steps: S701. Server A selects a random bit b1∈{1,0} and two random numbers z. And send C to server B, B also selects a random bit b2∈{1,0}, and chooses a random public-private key pair (pk,sk), let pk'=C-pk, when b2=1, let pk1 * =pk',pk2 * =pk, when b2 = 0, let pk1 * =pk,pk2 * =pk', and the public key pair (pk1 * ,pk2 * ) to server A; S702, A receives the public key pair (pk1 * ,pk2 * ), calculate the ciphertext (e1,e2) = (Enc(z,pk1 * ),Enc(z+b1,pk2 * )), and sends the ciphertext (e1, e2) to B. After B receives the ciphertext (e1, e2), when b2 = 1, it uses sk to decrypt e2: Dec(e2, sk) = Dec(Enc(z+b1, pk2 * ),sk)=Dec(Enc(z+b1,pk),sk)=z+b1, otherwise when b2=0, decrypt e1 with sk:Dec(e1,sk)=Dec(Enc(z,pk1 * ),sk)=Dec(Enc(z,pk),sk)=z, B gets one of z and z+b1, then let a=z+b1b2(mod p); S703, A calculates b1'=b1+2z(mod p), that is, converts the Boolean share b1 into the corresponding arithmetic share b1', and generates a double verification bit (b1, b1'). Server B calculates b2'=b2-2a(mod p)=b2-2z-2b1b2(mod p), that is, converts the Boolean share b2 into the corresponding arithmetic share b2', and generates a double verification bit (b2, b2'). Therefore, the two servers perform steps S701 to S703 to convert Boolean shares b1 and b2 into corresponding arithmetic shares b1' and b2'; S704, due to is a vector The jth component of i To convert the Boolean shared value of bit into the corresponding arithmetic shared value, server A needs L i double verification bit, let (b 1,t ,b 1,t ')yes The t-th double verification bit (1≤t≤L i ), A executes steps S701 to S703, and each Boolean share b 1,t Transformed into the corresponding arithmetic share b 1,t ';Server B command (b 2,t ,b 2,t ') is h i,b The t-th double verification bit 1≤t≤L i , in order to make the length L i The Boolean shared value h i,b Convert to the corresponding arithmetic shared value, B executes steps S701 to S703, converting each Boolean share b 2,t Transformed into the corresponding arithmetic share b 2,t '; S705, Order is a vector The tth binary bit of h i,b,t is a Boolean value h i,b The t-th binary bit of 1≤t≤L i , server A uses double authentication bit (b 1,t ,b 1,t ') and Boolean shared bits calculate Send v1 to B; Server B uses a double verification bit (b 2,t ,b 2,t ') and a Boolean shared bit h i,b,t ∈{0,1}, calculate Send v2 to A; A and B calculate A gets the arithmetic shared value g′ of the tth bit i,j,t,k+1 =v+b 1,t '-2vb 1,t '(mod p), B obtains the arithmetic shared value h' of the tth bit i,j,t =b 2,t '-2vb 2,t '(mod p); because Calculate Servers A and B implement the conversion of single-bit Boolean shares to corresponding arithmetic shares; S706, A uses each arithmetic shared value g′ i,j,t,k+1 (1≤t≤L i )calculate modp, calculate user C i The arithmetic shared vector g′ i,k+1 =(g′ i,1,k+1 ,g′ i,2,k+1 ,···,g′ i,d,k+1 ); B will share the arithmetic value of each bit Calculate user C i The arithmetic shared vector h′ i =(h′ i,1 ,h′ i,2 ,···,h′ i,d ).
9. The heterogeneous adaptive quantitative privacy-preserving federated learning method according to claim 1, characterized in that: Described step S80 comprises the following steps: S801, Server A and User C i The arithmetic shared vector g′ i,k+1 Form an n-row d-column arithmetic shared matrix G n×d , 1≤i≤n; server B and user C i The arithmetic shared vector h′ i Form an n-row d-column arithmetic shared matrix H n×d , 1≤i≤m; A takes the symbol vector σ of n users i,k+1 =(σ i,1,k+1, σ i,2,k+1, ··· , σ i,d,k+1 ), forming a symbol matrix F with n rows and d columns n×d , let F j Represents the symbol matrix F n×d The jth column of G j Denotes the arithmetic sharing matrix G n×d The jth column of S802, for 1≤j≤d, when F j The sign bit σ i,j,k+1 = 0, 1≤i≤n, server A uses G j Calculate the corresponding components in the column When F j The sign bit σ i,j,k+1 =1, 1≤i≤n, calculate Get two vectors g1 + =(g 1,1 + ,g 1,2 + ,···,g 1,d + ) and g1 - =(g 1,1 - ,g 1,2 - ,···,g 1,d - ), where vector g1 + It's G j The vector consisting of the sum of all positive numbers in the corresponding components of the column, vector g1 - It's G j A vector consisting of the sum of all negative numbers of the corresponding components in the column; S803, server B sends the symbol vector σ of n participants i,k+1 =(σ i,1,k+1, σ i,2,k+1, ··· , σ i,d,k+1 ), forming a symbol matrix F with n rows and d columns n×d , where F j is the symbolic matrix F n×d The jth column of H j Denotes the arithmetic sharing matrix H n×d The jth column of j The sign bit σ i,d,k+1 = 0, 1≤i≤n, server B uses H j Calculate the corresponding components in the column When F j The sign bit σ i,j =1, 1≤i≤m, calculate Get two vectors g2 + =(g 2,1 + ,g 2,2 + ,···,g 2,d + ) and g2 - =(g 2,1 - ,g 2,2 - ,···,g 2,d - ), and g2 + and g2 - Sent to A; where vector g2 + Yes H j The vector consisting of the sum of all positive numbers in the corresponding components of the column, vector g2 - Yes H j A vector consisting of the sum of all negative numbers of the corresponding components in the column; S804, server A is represented by vector g1 + ,g2 + ,g1 - and g2 - For each component of and the scaling factor λ, calculate: g j + =(g 1,j + +g 2,j + mod p) / 10 λ , g j - =(g 1,j - +g 2,j - mod p) / 10 λ , Get two vectors g + =(g1 + ,g2 + ,···,g d + ) and vector g - =(g1 - ,g1 - ,···,g d - ); Server A calculates and updates the global aggregate gradient: g k+1 =g k +(g + -g - ) / n; S805, A uses g k+1 Update the global model parameters w k+1 =w k -ηg k+1 ; S806: Server A calculates the quantization level s obtained in S30. k+1 ,pass Get auxiliary quantization level s' k+1 , and according to step S305, the auxiliary quantization level s' k+1 Assigned to each user; S807, A will g k+1 and w k+1 Sent to each user.
10. The heterogeneous adaptive quantitative privacy-preserving federated learning method according to claim 1, characterized in that: The step S90 comprises the following steps: S901, when the model training round k≤T, user C i Repeat steps S20 to S90, otherwise the user ends the federated learning task, and the system administrator SM and all users obtain the final global aggregate gradient g T and the global model parameter w T .