# FedCrow: Federated-Learning-Based Data Privacy Preservation in Crowd Sensing
## 3 FedCrow Design
### Analysis and Selection of Encryption Algorithm in Federated Learning  
Based on the analysis of commonly used encryption methods in federated learning, suitable encryption algorithms for crowd-sensing applications were selected to enhance the data security during information exchange. By analyzing the encryption effectiveness and computational overhead, encryption algorithms were flexibly chosen based on the data volume in crowd-sensing applications. Generally, federated learning employs homomorphic encryption and a differential privacy encryption algorithm. The following section mainly introduces these two encryption methods.  
Homomorphic encryption algorithms are widely used in federated learning. According to the characteristics of homomorphic encryption, it is most effective to use this algorithm when dealing with small data volumes. It not only effectively enhances the data security but also does not compromise the data availability. However, when dealing with exceptionally large data volumes, using homomorphic encryption significantly increases the computational overhead, leading to longer processing times. Currently, federated-learning applications for crowd sensing are mainly focused on large-scale industrial scenarios, where most clients are mobile smart devices with limited resources. Therefore, in federated-learning-based crowd-sensing systems, using homomorphic encryption is not suitable when dealing with large data volumes.  
Differential privacy adds noise to data to mitigate the risk of data leakage. However, adding noise inevitably reduces the data availability, which is an unavoidable factor of differential privacy. In cases of small data volumes, adding noise can significantly impact the data availability, leading to a substantial decrease in the model accuracy.  
When the data volume in a crowd-sensing system is large, adding noise not only reduces the security risks associated with data leakage but also, due to the larger data volume, the impact of the added noise on the overall data is relatively minor. Tables 1 and 2 present the encryption results for matrices of sizes 4 \(\times\) 8 and 4 \(\times\) 8 \(\times\) 30, respectively. According to these tables, it can be observed that when the data volume was large, both the addition and multiplication homomorphic encryptions required significant encryption and decryption times. Conversely, in scenarios with smaller data volumes, the differential privacy method resulted in a substantial loss of model accuracy.  
After studying the data encryption methods used in federated learning and conducting a thorough analysis of the principles and characteristics of additive homomorphic  
\begin{table}
\begin{tabular}{c c c} \hline
**Encryption Method** & **Encryption/Decryption Time** & **Model Accuracy** \\ \hline Additive homomorphic encryption & 8.69 s & 97.48\% \\ Multiplicative homomorphic encryption & 28.57 s & 97.32\% \\ Differential privacy & None & 69.56\% \\ \hline \end{tabular}
\end{table}
Table 1: Comparison of encryption methods for matrices of size \(4\times 8\).  
\begin{table}
\begin{tabular}{c c c} \hline
**Encryption Method** & **Encryption/Decryption Time** & **Model Accuracy** \\ \hline Additive homomorphic encryption & 320.78 s & 97.44\% \\ Multiplicative homomorphic encryption & 1125.82 s & 97.19\% \\ Differential privacy & None & 95.45\% \\ \hline \end{tabular}
\end{table}
Table 2: Comparison of encryption methods for a \(4\times 8\times 30\) matrix.  
encryption, multiplicative homomorphic encryption, and differential privacy, we concluded, in light of the application scenarios of crowd sensing, that when dealing with large data volumes, it is advisable to opt for the differential privacy method to safeguard the data security. Conversely, when the data volume is relatively small, consideration should be given to employing homomorphic encryption methods.