Skip to content

This repository contains the code for the M2 thesis on Homomorphic Encryption, Federated Learning and Secure Aggregation. Implemented Homomorphic Encryption schemes are CKKS and Gentry's.

Notifications You must be signed in to change notification settings

azezezaaa/MIAR_M2

Repository files navigation

MIAR_M2

This repository contains the code for the implementation on Homomorphic Encryption, Federated Learning and Secure Aggregation. Implemented Homomorphic Encryption schemes are Tenseal's CKKS and a simple modfified version of Gentry's HE.

Brief

There are 4 jupyter notebooks:

  1. server_training.ipynb
  2. > server_training.ipynb contains the code to generate the base model and saves it in the current directory.
  3. Bob_training.ipynb
  4. > Bob_training.ipynb contains the code to generate Bob's part of the MNIST dataset, run the base model, extract, encrypt and serialize weights, and store these weights in a pickle file.
  5. Alice_training.ipynb
  6. > Alice_training.ipynb contains the code to generate Alice's part of the MNIST dataset, run the base model, extract, encrypt and serialize weights, and store these weights in a pickle file.
  7. server_training_new_weights.ipynb
  8. > server_training_new_weights.ipynb reads the encrypted weights, average the two users' encrypted weights and updates the base model.

Notes

When serializing tensor proto, there is a hardlimit of 2GB. This issue is obtained when trying to encrypt weights directly. To solve this, use np.dsplit() to split the weights into equal arrays, and then encrypt each array individually. To combine them into the original weights, use np.dstack(). Due to limited RAM, I used a dsplit indice of 16.
This is applicable for Bob_training.ipynb and Alice_training.ipynb.

Dependencies

See requirements.txt. Can be installed with pip.

Please cite the following if you use the code:

@misc{miarM2DAJR,
  title={Notebook for implementing a simple 2-client model of homomorphic encryption and secure aggregation in Federated Learning},
  author={Dave, Appadoo and Jyotika, Rughoo},
  journal={https://https://github.com/azezezaaa/MIAR_M2/},
  year={2021}
}

About

This repository contains the code for the M2 thesis on Homomorphic Encryption, Federated Learning and Secure Aggregation. Implemented Homomorphic Encryption schemes are CKKS and Gentry's.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published