This GitHub repository contains the code and resources for simulating Federated Learning with Homomorphic Encryption using a Streamlit app and Flask. This project demonstrates how to train machine learning models across clients while preserving data privacy through homomorphic encryption. The Streamlit app serves as the user interface for managing and monitoring the federated learning process
Before using this project, ensure you have the following dependencies installed:
You can install these dependencies using pip:
pip install streamlit flask tenseal torch
In this project, we leverage the power of TenSEAL, a cutting-edge library for homomorphic encryption. TenSEAL enables us to perform secure and privacy-preserving computations on encrypted data.
Run the below command to generate a private - public key pair in the keys
folder.
python3 generatekeys.py
A basic Federated Learning with Homomorphic Encryption architecture is shown below. Here we have an Umbrella of Clients, who are trustworthy and related. They share a secret key with eachother. This key is used to encrypt their data and then sent to an aggregation Server. The Server averages out the encrypted data using the Public Key and returns the new weights. The new weights are decrypted by all clients and their models are updated.
Streamlit is used to create a simple application where you can perform the entire federated learning process from the client and server, and perform a prediction using the new updated model after a federated learning.
Use the below command to run the streamlit application -
streamlit run client/app.py
The requests to the server is handled using Flask.
To run the flask app do -
flask --app server/server.py run
Server - Registered Clients will be displayed, upload the Public Key & perform Federated Learning on click of a button
A Simple Logistic Regression model was used on the Breast Cancer Classification Dataset.
- User Interface
- More Sophisticated Model and Dataset
- Hyperparameter Tuning