# Privacy-Preserving Federated Learning Using Homomorphic Encryption
## 5 Privacy Preserving Federated Learning
### Secure Global Model Update with DHC  
We propose a secure averaging local model vector algorithm that updates the global model vector by calculating the average of the local model vectors received from the clients. The CS utilizes the cooperative decryption scheme to obtain the average local model vector encrypted with different public keys in the same FL-based system through cooperation with the CP, as shown in step 5 of Figure 2.  
Figure 3 illustrates the procedure of cooperative decryption and secure local model vector updates. First, the client sends an encrypted local value \(E_{pk_{i}}(m)\) to the CS. The CS adds the encrypted random variable \(E_{pk_{i}}(r)\) to the received ciphertext using homomorphic  
addition, where \(r\) is a random integer number, and then the CS can obtain \(E_{pk_{i}}(m+r)\). The CS then forwards the ciphertext to the CPs. The \((N_{s}-1)\) CPs perform partial decryptions, and the other CP performs the combined decryption to obtain the sum of the local value and random noise \((m+r)\). As explained in Figure 3, the CP can calculate the average of the sum of the local value and random noise \((m_{ave}+r_{ave})\) when receiving the sum from multiple clients. The sum's average is encrypted and sent back to the CS. Finally, the CS can remove the average of random values from the sum's average through homomorphic addition and obtain the encrypted average local value \(E_{pk_{i}}(m_{ave})\) since the CS has the random values. Algorithm 1 describes the proposed secure averaging local model algorithm where one CS and one CP exist. In the proposed algorithm, local model parameters encrypted with different keys are input, and global model parameters encrypted with different keys are output. The CS and CP have the partial private keys \(psk_{i}^{(1)}\) and \(psk_{i}^{(2)}\), respectively. The detailed procedure of the secure averaging local model vector algorithm is as follows:  
1. The CS receives the encrypted local model vectors from the clients participating in the training process. Note that the local model vector encrypted with the public key of the \(i\)-th client is represented as \([W_{i}^{i}]_{i}\). Thereafter, the CS generates \(N_{c}\) random vectors with the same size as the local model vector and encrypts them using the client's public key, as shown in lines 2-3 of Algorithm 1;
2. The CS performs homomorphic addition operations with the encrypted local model vectors using the encrypted random vectors in line 5. The result of homomorphic addition between \([W_{i}^{i}]_{i}\) and \([R_{i}]_{i}\) is represented as \([S_{i}]_{i}\). Then, the CS partially decrypts the result of the homomorphic addition using the partial private key \(psk_{i}^{(1)}\) in line 6. This process is repeated for \(N_{c}\) local model vectors. Subsequently, the CP sends the partially decrypted vectors \([PD^{1}([S_{1}]_{1}),PD^{1}([S_{2}]_{2}),\cdots,PD^{1}([S_{N_{c}}]_{N_{c}})]\) to the CP, as shown in lines 8-9;
3. As shown in lines 10-11, the CP partially decrypts the partially decrypted vectors using the partial private key \(psk_{i}^{(2)}\) and obtains \([(W_{I}^{1}+R_{1}),\cdots,(W_{I}^{N_{c}}+R_{N_{c}})]\). Afterwards, the CP adds all the decrypted vectors and divides the sum by the number of clients \(N_{c}\) to obtain a vector containing the average parameters in line 12. The result is represented as \(W_{sum}\);
4. The CP encrypts \(W_{sum}\) using the public keys of the \(N_{c}\) clients in lines 13-15 and sends the encrypted vectors \([[W_{sum}]_{1},\ \ \ [W_{sum}]_{2},\cdots,[W_{sum}]_{N_{c}}]\) to the CS in line 16;
5. Finally, the CS calculates the encrypted average global model vectors for the clients by performing the homomorphic addition operation with the encrypted sum of random noises \([\frac{\sum_{k}-R_{k}}{N_{c}}]_{i}\), as shown in lines 17-19. Figure 3: Diagram for secure averaging local model vector algorithm. ```
1:Input: \([W_{I}^{1}]_{1},[W_{I}^{2}]_{2},\ldots,[W_{I}^{N_{c}}]_{N_{c}}\).