This repository provides the implementation of the paper "Adaptive Batch Homomorphic Encryption for Joint Federated Learning in Cross-Device Scenarios", which is published in IEEE INTERNET OF THINGS JOURNAL. In this paper, we propose an adaptive batch HE framework for cross-device FL, which determines cost-efficient and sufficiently secure encryption strategies for clients with heterogeneous data and system capabilities. Our framework can achieve comparable accuracy to plain HE (i.e., encryption applied per gradient), while reducing training time by 3×-31×, and communication cost by 45×-66×.
Training time over 100 epochs | Testing accuracy over epochs | Communication cost in one epoch | Cost efficiency under various HE key sizes |
Our framework consists of the following three key components:
The code in the folder CNN Sparisty is for determining the sparsity vectors of clients.
federated_main.py
is the main function.
The input is the path of the dataset.
The code in the folder fuzzy logic is for determining the HE key size of clients.
fuzzy_logic_main.py
is the main function.
There are three inputs: input_NS
, input_TR
, and input_CC
.
Their values are between 0 and 1.
The code in the folder batch encryption is for accuracy-lossless batch encryption and aggregation of model parameters for FL training.
federated_experiment_main.py
is the main function.
The code needs a proper hyperparameter K to run correctly, of which reason has been explained with detail in the paper. The default K value is 4. For specific settings, please refer to the comments in the code.
To run the code, it needs some libraies:
- Python >= 3.8
- Pytorch >= 1.10
- torchvision >= 0.11
- phe >= 1.5
- skfuzzy >= 0.4
Our environment is shown in the file, named environment.yaml
.
If you use this repository, please cite:
@article{han2023adaptiveBatchHE,
title={Adaptive Batch Homomorphic Encryption for Joint Federated Learning in Cross-Device Scenarios},
author={Han, Junhao and Yan, Li},
journal={IEEE Internet of Things Journal},
volume={Early Access},
year={2023},
publisher={IEEE}
}