Classes
SecaggBaseSetup
SecaggBaseSetup(researcher_id, secagg_id, parties, experiment_id)
Bases: ABC
Sets up a Secure Aggregation context element on the node side.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
researcher_id | str | ID of the researcher that requests setup | required |
secagg_id | str | ID of secagg context element for this setup request | required |
parties | List[str] | List of parties participating in the secagg context element setup | required |
experiment_id | Union[str, None] | ID of the experiment to which this secagg context element is attached | required |
Raises:
Type | Description |
---|---|
FedbiomedSecaggError | bad argument type or value |
Source code in fedbiomed/node/secagg/_secagg_setups.py
def __init__(
self,
researcher_id: str,
secagg_id: str,
parties: List[str],
experiment_id: Union[str, None],
):
"""Constructor of the class.
Args:
researcher_id: ID of the researcher that requests setup
secagg_id: ID of secagg context element for this setup request
parties: List of parties participating in the secagg context element setup
experiment_id: ID of the experiment to which this secagg context element
is attached
Raises:
FedbiomedSecaggError: bad argument type or value
"""
errmess: str = ""
if len(parties) < self._min_num_parties:
errmess = (
f"{ErrorNumbers.FB318.value}: bad parameter `parties` : {parties} : need "
f"at least {self._min_num_parties} parties for secure aggregation, but got "
f"{len(parties)}"
)
if researcher_id is None:
errmess = (
f"{ErrorNumbers.FB318.value}: argument `researcher_id` must be a non-None value"
)
if errmess:
# if one of the above condition is met, raise error
logger.error(errmess)
raise FedbiomedSecaggError(errmess)
# assign argument values
self._researcher_id = researcher_id
self._secagg_id = secagg_id
self._experiment_id = experiment_id
self._parties = parties
self._element: SecaggElementTypes = None
Attributes
element property
element
experiment_id property
experiment_id
Getter for experiment_id
Returns:
Type | Description |
---|---|
str | ID of the experiment to which this secagg context element is attached |
researcher_id property
researcher_id
secagg_id property
secagg_id
Functions
setup
setup()
Set up a secagg context element.
Returns:
Type | Description |
---|---|
Message | message to return to the researcher after the setup |
Source code in fedbiomed/node/secagg/_secagg_setups.py
def setup(self) -> Message:
"""Set up a secagg context element.
Returns:
message to return to the researcher after the setup
"""
try:
return self._setup_specific()
except FedbiomedError as e:
logger.debug(f"{e}")
return self._create_secagg_reply(
False,
"Can not setup secure aggregation context "
f"on node for {self._secagg_id}. {e}",
)
SecaggDHSetup
SecaggDHSetup(*args, n2n_router, grpc_client, pending_requests, controller_data, **kwargs)
Bases: _SecaggNN
Sets up a server key Secure Aggregation context element on the node side.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n2n_router | NodeToNodeRouter | object managing node to node messages | required |
grpc_client | GrpcController | object managing the communication with other components | required |
pending_requests | EventWaitExchange | object for receiving overlay node to node messages | required |
controller_data | EventWaitExchange | object for passing data to the node controller | required |
*args | Please see [SecaggBaseSetup] | () | |
**kwargs | Please see [SecaggBaseSetup] | {} |
Raises: FedbiomedSecaggError: bad argument type or value
Source code in fedbiomed/node/secagg/_secagg_setups.py
def __init__(
self,
*args,
n2n_router: NodeToNodeRouter,
grpc_client: GrpcController,
pending_requests: EventWaitExchange,
controller_data: EventWaitExchange,
**kwargs,
):
"""Constructor of the class.
Args:
n2n_router: object managing node to node messages
grpc_client: object managing the communication with other components
pending_requests: object for receiving overlay node to node messages
controller_data: object for passing data to the node controller
*args: Please see [SecaggBaseSetup]
**kwargs: Please see [SecaggBaseSetup]
Raises:
FedbiomedSecaggError: bad argument type or value
"""
super().__init__(*args, **kwargs)
# self._secagg_manager = SKManager
self._n2n_router = n2n_router
self._grpc_client = grpc_client
self._pending_requests = pending_requests
self._controller_data = controller_data
SecaggRound
SecaggRound(secagg_arguments, experiment_id)
This class wraps secure aggregation schemes
Attributes:
Name | Type | Description |
---|---|---|
scheme | _SecaggSchemeRound | None | Secure aggregation scheme |
use_secagg | bool | True if secure aggregation is activated for round |
Source code in fedbiomed/node/secagg/_secagg_round.py
def __init__(
self,
secagg_arguments: Dict[str, Any],
experiment_id: str
) -> None:
"""Constructor of the class"""
self.use_secagg: bool = False
self.scheme: _SecaggSchemeRound | None = None
if not secagg_arguments and environ["FORCE_SECURE_AGGREGATION"]:
raise FedbiomedSecureAggregationError(
f"{ErrorNumbers.FB318.value}: Node requires to apply secure aggregation but "
f"training request does not define it.")
if secagg_arguments:
if not environ["SECURE_AGGREGATION"]:
raise FedbiomedSecureAggregationError(
f"{ErrorNumbers.FB318.value} Requesting secure aggregation while "
"it's not activated on the node."
)
sn = secagg_arguments.get('secagg_scheme')
if sn is None:
raise FedbiomedSecureAggregationError(f"{ErrorNumbers.FB318.value}: Secagg scheme value missing in "
"the argument `secagg_arguments`")
try:
_scheme = SecureAggregationSchemes(sn)
except ValueError as e:
raise FedbiomedSecureAggregationError(
f"{ErrorNumbers.FB318.value}: Bad secagg scheme value in train request: {sn}"
) from e
self.scheme = SecaggRound.element2class[_scheme.value](secagg_arguments, experiment_id)
self.use_secagg = True
Attributes
element2class class-attribute
instance-attribute
element2class = {value: _JLSRound, value: _LomRound}
scheme instance-attribute
scheme = None
use_secagg instance-attribute
use_secagg = False
SecaggServkeySetup
SecaggServkeySetup(*args, n2n_router, grpc_client, pending_requests, controller_data, **kwargs)
Bases: _SecaggNN
Secure aggregation setup phase for ServerKey generation on the node side
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n2n_router | NodeToNodeRouter | object managing node to node messages | required |
grpc_client | GrpcController | object managing the communication with other components | required |
pending_requests | EventWaitExchange | object for receiving overlay node to node messages | required |
controller_data | EventWaitExchange | object for passing data to the node controller | required |
*args | Please see [SecaggBaseSetup] | () | |
**kwargs | Please see [SecaggBaseSetup] | {} |
Raises: FedbiomedSecaggError: bad argument type or value
Source code in fedbiomed/node/secagg/_secagg_setups.py
def __init__(
self,
*args,
n2n_router: NodeToNodeRouter,
grpc_client: GrpcController,
pending_requests: EventWaitExchange,
controller_data: EventWaitExchange,
**kwargs,
):
"""Constructor of the class.
Args:
n2n_router: object managing node to node messages
grpc_client: object managing the communication with other components
pending_requests: object for receiving overlay node to node messages
controller_data: object for passing data to the node controller
*args: Please see [SecaggBaseSetup]
**kwargs: Please see [SecaggBaseSetup]
Raises:
FedbiomedSecaggError: bad argument type or value
"""
super().__init__(*args, **kwargs)
# self._secagg_manager = SKManager
self._n2n_router = n2n_router
self._grpc_client = grpc_client
self._pending_requests = pending_requests
self._controller_data = controller_data
SecaggSetup
SecaggSetup(element, **kwargs)
Factory class for instantiating any type of node secagg context element setup class
Source code in fedbiomed/node/secagg/_secagg_setups.py
def __init__(self, element: int, **kwargs):
"""Constructor of the class"""
self._element = element
self.kwargs = kwargs
Attributes
element2class class-attribute
instance-attribute
element2class = {name: SecaggServkeySetup, name: SecaggDHSetup}
kwargs instance-attribute
kwargs = kwargs