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

[WIP]: Secure Aggregation cleanup #1420

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

theakshaypant
Copy link
Collaborator

@theakshaypant theakshaypant commented Mar 3, 2025

Summary

Perform cleanup of secure aggregation code in openfl based on the checklist below.

Type of Change (Mandatory)

Specify the type of change being made.

  • Documentation update
  • Security improvement
  • Restructuring

Description (Mandatory)

  • Remove pycryptodome from openfl dependencies.
  • Rename openfl.utilities.secagg.setup
  • Remove "bloat" from aggregator and collaborator.

Testing

TODO

Copy link
Collaborator

@teoparvanov teoparvanov left a comment

Choose a reason for hiding this comment

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

Thanks @theakshaypant, I believe these changes are a move in the right direction! A couple of comments from my initial read-through:

Comment on lines +20 to +24
except Exception as error:
raise Exception(
"'pycryptodome' not installed."
f"This package is necessary when secure aggregation is enabled: {error}"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

How do we know this general Exception is caused by a missing pycryptodome dependency?

Comment on lines +233 to +242
# Fetch private mask from tensor db if not already fetched.
if not private_mask:
private_mask = tensor_db.get_tensor_from_cache(
TensorKey("private_mask", collaborator_name, -1, False, ("secagg",))
)[0]
# Fetch shared mask from tensor db if not alreday fetched.
if not shared_mask:
shared_mask = tensor_db.get_tensor_from_cache(
TensorKey("shared_mask", collaborator_name, -1, False, ("secagg",))
)[0]
Copy link
Collaborator

@teoparvanov teoparvanov Mar 4, 2025

Choose a reason for hiding this comment

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

IMHO it's not great to have a dependency on the TensorDB in a module dedicated to cryptography. Could you consider moving the code for retrieving the private and shared masks back to the collaborator module?

@@ -12,6 +12,7 @@ TaskRunner API
-------------------------------------

OpenFL treats SecAgg as a core security feature and can be enabled for any experiment by simply modifying the plan.
**NOTE**: `pycryptodome <https://pypi.org/project/pycryptodome/>`_ is a required dependency that must be installed on the participant nodes before starting the experiment.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add limitations as well i.e Straggler policies will not work with secure aggregation. Also resiliency or restart of aggregator or collaborator during experiment may cause issues.

@psfoley
Copy link
Contributor

psfoley commented Mar 6, 2025

@theakshaypant I haven't completed a full review yet (as this is still WIP), but it's clearly moving in the right direction. I have a question about pycryptodome. I see it's use in

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad

for ciphertext and mask generation. Instead could you use the cryptography package primitives that we already import? https://cryptography.io/en/latest/hazmat/primitives/

That would eliminate the need for the package detection code and make user's lives a bit easier

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.

4 participants