Figure 1. Overall system architecture of the proposed FDSH framework.
This repository provides the reference implementation of FDSH (Federated Distillation with Selective Homomorphic Encryption), an adaptive, privacy-preserving, and energy-aware federated learning framework designed for heterogeneous and resource-constrained edge devices.
FDSH addresses critical limitations of existing Federated Learning (FL) systems, namely membership inference attacks (MIA), non-IID data, energy constraints, and high cryptographic overhead, by combining:
- Entropy-aware Selective Homomorphic Encryption (SHE)
- Hierarchical Federated Knowledge Distillation (KD)
- Energy-aware adaptive client participation
- Cluster-based aggregation and resilience-aware training
The framework is evaluated primarily on Human Activity Recognition (HAR) tasks, but is designed to be extensible to other edge AI domains such as healthcare, speech, and IoT analytics.
If you use this code, please cite the following paper:
bibtex @article{RAHBARI2025131002,
title = {Adaptive and Efficient Federated Distillation with Selective Homomorphic Encryption for Edge AI},
journal = {Expert Systems with Applications},
pages = {131002},
year = {2025},
issn = {0957-4174},
doi = {https://doi.org/10.1016/j.eswa.2025.131002 },
url = {https://www.sciencedirect.com/science/article/pii/S0957417425046172 },
author = {Dadmehr Rahbari and Masoud Daneshtalab and Maksim Jenihhin} }
Adaptive client participation based on real-time energy availability
Entropy-guided selective HE, encrypting only high-risk logits
Cluster-level knowledge distillation for scalability and personalization
Built-in MIA evaluation with near-random attack accuracy (~50%)
Unified Efficiency Index (UEI) for holistic system assessment
The FDSH framework operates in three layers:
Client Layer
Energy-aware training modes (full / partial / offload) Model size adaptation (TinyCNN, MobileNetV2, ResNet) Soft-logit generation with uncertainty estimation Selective encryption via HE
Cluster Aggregation Layer Homomorphic aggregation of encrypted logits Weighted KD within clusters Resilience-aware client handling
Global Server Layer Inter-cluster distillation Global model update and broadcast
Requirements Python ≥ 3.9
PyTorch ≥ 2.0
NumPy, SciPy, scikit-learn
Pyfhel (for CKKS-based HE)
Matplotlib / Seaborn
File "HAR.rar" must be extracted in the same directory as "dataset". This is the dataset file from (https://archive.ics.uci.edu/dataset/240/human+activity+recognition+using+smartphones).
Run Federated Training bash Copy code python scripts/run_federated.py --config configs/config.yaml Reproduce Paper Results bash Copy code python scripts/reproduce_results.py
Highlights +7% accuracy over baseline FL methods
~30% reduction in energy consumption
~25% lower communication overhead
Up to 34% higher Unified Efficiency Index (UEI)
MIA accuracy ≈ 50%, indicating strong privacy protection
Selective HE applied only to high-entropy logits
Homomorphic aggregation without decryption
Integrated MIA testing pipeline
Quantified privacy–utility–efficiency tradeoffs
UEI combines:
Model accuracy Energy consumption Computation cost Communication overhead Privacy/security score
This enables holistic evaluation beyond accuracy-centric FL benchmarks.
While evaluated on HAR, FDSH is designed for:
Wearable & mobile sensing
Healthcare & medical imaging
Smart cities & IoT analytics
Edge AI under strict privacy constraints
Deterministic seeds used in all experiments
Config-driven experiment management
Modular, extensible design
Clear separation of client, server, and security logic
Contributions are welcome:
New datasets or modalities
Improved HE backends
Energy models for new devices
Large-scale deployment studies
This project is released for academic and research use. For commercial usage, please contact the authors.
FDSH bridges the gap between privacy, efficiency, and accuracy in real-world federated edge intelligence.