diff --git a/fedbiomed/common/secagg/_secagg_crypter.py b/fedbiomed/common/secagg/_secagg_crypter.py index 021efd85d..8b4126710 100644 --- a/fedbiomed/common/secagg/_secagg_crypter.py +++ b/fedbiomed/common/secagg/_secagg_crypter.py @@ -22,7 +22,7 @@ class SecaggCrypter: - """Secure aggregation encryption and decryiton manager. + """Secure aggregation encryption and decryption manager. This class is responsible for encrypting model parameters using Joye-Libert secure aggregation scheme. It also aggregates encrypted model parameters and decrypts @@ -101,7 +101,7 @@ def encrypt( f"{ErrorNumbers.FB624.value}: The argument `key` must be integer" ) - params = self.apply_weighing(params, weight) + params = self._apply_weighing(params, weight) params = quantize(weights=params, clipping_range=clipping_range) @@ -193,7 +193,7 @@ def aggregate( # TODO implement weighted averaging here or in `self._jls.aggregate` # Reverse quantize and division (averaging) aggregated_params: List[float] = reverse_quantize( - self.apply_average(sum_of_weights, num_nodes, total_sample_size), + self._apply_average(sum_of_weights, num_nodes, total_sample_size), clipping_range=clipping_range ) @@ -203,7 +203,7 @@ def aggregate( return aggregated_params @staticmethod - def apply_average( + def _apply_average( params: List[int], num_nodes: int, total_sample_size: int @@ -222,7 +222,7 @@ def apply_average( return [param / num_nodes for param in params] @staticmethod - def apply_weighing( + def _apply_weighing( params: List[float], weight: int, ) -> List[float]: diff --git a/tests/test_secagg_crypter.py b/tests/test_secagg_crypter.py index 814b53c54..fa0ad8e2d 100644 --- a/tests/test_secagg_crypter.py +++ b/tests/test_secagg_crypter.py @@ -51,7 +51,7 @@ def test_secagg_crypter_03_apply_average(self): """Tests quantized divide""" vector = [4, 8, 12] - result = self.secagg_crypter.apply_average(vector, 2, 0) + result = self.secagg_crypter._apply_average(vector, 2, 0) # Test division self.assertListEqual(result, [v / 2 for v in vector])