Skip to content

Commit

Permalink
misc: make 2 methods private in SecaggCrypter
Browse files Browse the repository at this point in the history
  • Loading branch information
mvesin committed Apr 4, 2023
1 parent 36299fd commit 73b9e12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions fedbiomed/common/secagg/_secagg_crypter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
)

Expand All @@ -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
Expand All @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_secagg_crypter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 73b9e12

Please sign in to comment.