Does Flower support differential privacy?

A frequently asked question we get is:

Does Flower support differential privacy? :lock:

Flower supports central differential privacy (known as user-level DP) and local DP. In central DP, the noising part is on the server side, with options for fixed and adaptive clipping. The clipping phase can be decided to be on the client or server side. For example, if you want to implement it with server-side fixed clipping:

from flwr.server.strategy.dp_fixed_clipping import DifferentialPrivacyServerSideFixedClipping
# Configure the strategy
strategy = fl.server.strategy.FedAvg( ... )
# Wrap the strategy with the DifferentialPrivacyServerSideFixedClipping wrapper
dp_strategy = DifferentialPrivacyServerSideFixedClipping(strategy, cfg.noise_multiplier, cfg.clipping_norm, cfg.num_sampled_clients)

Moreover, if you want to perform it with client-side fixed clipping:

# Server-side:
from flwr.server.strategy.dp_fixed_clipping import DifferentialPrivacyClientSideFixedClipping
# Configure the strategy
strategy = fl.server.strategy.FedAvg( ... )
# Wrap the strategy with the DifferentialPrivacyClientSideFixedClipping wrapper
dp_strategy = DifferentialPrivacyClientSideFixedClipping(strategy, cfg.noise_multiplier, cfg.clipping_norm, cfg.num_sampled_clien

# Client-side:
from flwr.client.mod.centraldp_mods import fixedclipping_mod
# Add fixedclipping_mod to the client-side mods
app = fl.client.ClientApp(client_fn=client_fn, mods=[fixedclipping_mod])

For local DP, LocalDpMod can be utilized where it clips the client model updates and adds noise to the params before sending them to the server:

local_dp_mod = LocalDpMod( ... )
app = fl.client.ClientApp(client_fn=client_fn, mods=[local_dp_mod])

Furthermore, for sample-level DP, privacy engines like Opacus and TensorFlowPrivacy can be used on the client side. You can refer to examples of such implementations in the repository.

For more info, please refer to Flower docs about differential privacy.

1 Like