Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Secure Aggregation functionalities #2159

Merged
merged 27 commits into from
Aug 16, 2023
Merged

Add Secure Aggregation functionalities #2159

merged 27 commits into from
Aug 16, 2023

Conversation

panh99
Copy link
Contributor

@panh99 panh99 commented Jul 24, 2023

Issue

Description

The current Flower framework does not have intrinsic support for Secure Aggregation (SA).

Related issues/PRs

This PR is copied from #2132 , to change the source branch to secaggplus in adap/flower other than the forked repo.

This PR is based on the following PRs:
Add SecureAggregation field to Task message #1893
Adopt TaskIns/TaskRes-based communications on the client side #2007
Update serde.py for Secure Aggregation #2008
Update validator.py for SA #2151
Add PyCryptoDome and Cryptograhpy dependencies #2154

Proposal

Explanation

> Structure

Add the following python files and modules for SA functionalities.

├── client
|   └── secure_aggregation
|       ├── __init__.py
|       ├── handler.py
|       └── secaggplus_handler.py
└── common
    └── secure_aggregation
        ├── __init__.py
        ├── quantization.py
        ├── secaggplus_constants.py
        ├── secaggplus_utils.py
        ├── weights_arithmetic.py
        └── crypto
            ├── __init__.py
            ├── shamir.py
            └── symmetric_encryption.py

> Message Handler for the SecAgg+ protocol

Add abstract class SecureAggregationHandler in client/secure_aggregation/handler.py. To enable SA, a client class can inherit a subclass of SecureAggregationHandler.

Add subclass SecAggPlusHandler in client/secure_aggregation/secaggplus_handler.py for the SecAgg+ protocol.

> Utils

Modify message_handler.py to route a Task message to SA message handler if its sa field is set.

Add basic quantization utils in common/secure_aggregation/quantization.py

Add weights operations in common/secure_aggregation/weights_arithmetic.py

Add wrapper functions for Shamir's secret sharing APIs from PyCryptoDome in common/secure_aggregation/crypto/shamir.py

Add wrapper functions for ECDH key agreement and symmetric encryption APIs from Cryptography in common/secure_aggregation/crypto/symmetric_encryption.py

> Constants

Constants for the secagg/secagg+ protocols are all stored in common/secure_aggregation/secaggplus_constants.py.

Blocker

The PyCryptoDome package and the Cryptography package are not in the dependencies.

No blockers

Checklist

  • Implement proposed change
  • Write tests
  • Update documentation
  • Update changelog
  • Make CI checks pass
  • Ping maintainers on Slack (channel #contributions)

Any other comments?

* update validator.py & serde.py for SA

add serde functions

fix type checking errors

fix check errors

fix check err in serde.py

fix validation for TaskRes

* init

* init SA

* fix format

* fix mypy check errors

* add SA demo

* add unit tests for SA serde

* fix pylint errors

* ignore plint no-member error for numpy

* rename to secaggplus_utils.py

* fix bug in quantization, update secagg+ handler

* update secagg example

* update files from main

* update secaggplus

* fix a bug is type hint
src/py/flwr/client/secure_aggregation/__init__.py Outdated Show resolved Hide resolved
src/py/flwr/common/secure_aggregation/quantization.py Outdated Show resolved Hide resolved
src/py/flwr/common/serde.py Outdated Show resolved Hide resolved
examples/secagg-mt-pytorch/README.md Outdated Show resolved Hide resolved
@panh99 panh99 changed the title Add Secure Aggregation functionalities and Secaggplus demo Add Secure Aggregation functionalities Aug 2, 2023
@panh99 panh99 mentioned this pull request Aug 2, 2023
6 tasks
Copy link
Member

@danieljanes danieljanes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! 🎉

@danieljanes danieljanes enabled auto-merge (squash) August 16, 2023 14:03
@danieljanes danieljanes merged commit 3272c55 into main Aug 16, 2023
27 checks passed
@danieljanes danieljanes deleted the secaggplus branch August 16, 2023 14:08
tanertopal added a commit that referenced this pull request Aug 21, 2023
* main:
  Prepare framework docs restructuring (#2219)
  Update logos in documentation (#2223)
  fix a bug in serde (#2222)
  Restructure Baselines docs (#2122)
  Wrap VCE's `run_fl` in try/except (#2218)
  Add Secure Aggregation functionalities (#2159)
  Add updated architecture diagrams (#2215)
alessiomora pushed a commit to alessiomora/flower that referenced this pull request Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants