Skip to content

FedAvg code with privacy protection function, the application of Paillier homomorphic encryption algorithm and differential privacy, differential privacy includes Laplacian mechanism differential privacy and Gaussian mechanism differential privacy.

Notifications You must be signed in to change notification settings

heroding77/fedavg_encrypt

Repository files navigation

1. Introduction

This project is based on PyTorch 1.11.0 and Python 3.9.7. It uses a GPU, and of course it can run without one (it requires a simple change to the GPU part of the code). The hyperparameter information is encapsulated in conf. Json of utils and can be invoked directly by modifying the JSON file.The data set currently adopts MNIST data set and CIFAR-10 data set, and the model is built to realize FedAvg based on gray and white pictures (single channel) and color pictures (three channels). The project code is simple and the notes are clear. If my project is helpful to you, please light up a small star, which will be the biggest encouragement and support for me!

2. How to use

2.1 FedAvg

If you want pure FedAvg, Utils file set noise to 0, run the following code:

python server.py -c ./utils/conf.json

2.2 DP

If you want DP FedAvg, Utils file set noise to 1(laplace) or 2(gaussian), run the following code:

python server.py -c ./utils/conf.json

2.3 DP+paillier

If you want DP+paillier FedAvg, Utils file set noise to 1(laplace) or 2(gaussian), run the following code:

python server_encrypt.py -c ./utils/conf.json

3. Other documents

The encryption algorithm in the new_paillier.py file is used for encrypting and decrypting text information. The test.py file is used to test the usage of Paillier and can be ignored.

About

FedAvg code with privacy protection function, the application of Paillier homomorphic encryption algorithm and differential privacy, differential privacy includes Laplacian mechanism differential privacy and Gaussian mechanism differential privacy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages