nvflare.app_common.homomorphic_encryption.he_intime_accumulate_model_aggregator module

class HEInTimeAccumulateWeightedAggregator(exclude_vars=None, aggregation_weights=None, tenseal_context_file='server_context.tenseal', weigh_by_local_iter=False, expected_data_kind='WEIGHT_DIFF', expected_algorithm='CKKS')[source]

Bases: Aggregator

In time aggregator for Shareables encrypted using homomorphic encryption (HE) with TenSEAL https://github.com/OpenMined/TenSEAL.

Parameters
  • exclude_vars ([list], optional) – variable names that should be excluded from aggregation (use regular expression). Defaults to None.

  • aggregation_weights ([dict], optional) – dictionary of client aggregation. Defaults to None.

  • tenseal_context_file (str, optional) – [description]. Defaults to “server_context.tenseal”.

  • weigh_by_local_iter (bool, optional) – If true, multiply client weights on first in encryption space (default: False which is recommended for HE, first multiply happens in HEModelEncryptor)].

  • expected_data_kind (str, optional) – the data_kind this aggregator can process. Defaults to “WEIGHT_DIFF”.

  • expected_algorithm ([str], optional) – the HE algorithm it can process. Defaults to he.HE_ALGORITHM_CKKS.

Raises

ValueError – mismatched data_kind or HE algorithm

accept(shareable: Shareable, fl_ctx: FLContext) bool[source]

Accepts and adds the client updates to current average in HE encrypted space.

Parameters
  • shareable – a shareable from client

  • fl_ctx – FL Contenxt associated with this shareable

Returns

bool to indicate if this shareable is accepted.

aggregate(fl_ctx: FLContext) Shareable[source]

Perform the aggregation for all the received Shareable from the clients.

Parameters

fl_ctx – FLContext

Returns

shareable

handle_event(event_type: str, fl_ctx: FLContext)[source]

Handles events.

Parameters
  • event_type (str) – event type fired by workflow.

  • fl_ctx (FLContext) – FLContext information.

reset_stats()[source]