Skip to content

Commit

Permalink
Merge pull request FederatedAI#1342 from FederatedAI/feature-1.4-fix_…
Browse files Browse the repository at this point in the history
…dead_loop_in_affine

update affine encryption's code to avoid dead loop in low probability
  • Loading branch information
mgqa34 authored May 8, 2020
2 parents 5b26eac + b7b6a51 commit 16e7d70
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
[submodule "eggroll"]
path = eggroll
url = https://github.com/WeBankFinTech/eggroll.git
branch = release-2.0.1-build-10
branch = release-2.0.1-build-11
2 changes: 1 addition & 1 deletion federatedml/secureprotol/affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def generate_keypair(key_size=2048, encode_precision=2 ** 100, a_ratio=None, b_r
a = random.SystemRandom().getrandbits(int(key_size * a_ratio))
if math.gcd(n, a) == 1:
break
b = random.SystemRandom().getrandbits(int(key_size * b_ratio))
b = random.SystemRandom().getrandbits(max(1, int(key_size * b_ratio)))
return AffineCipherKey(a, b, n, encode_precision)


Expand Down
2 changes: 1 addition & 1 deletion federatedml/secureprotol/iterative_affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def generate_keypair(key_size=1024, key_round=5, encode_precision=2 ** 100):
i = 0
for key_size in key_size_array:
n = random.SystemRandom().getrandbits(key_size)
a_ratio = random.SystemRandom().random()
a = 0
while True:
a_ratio = random.SystemRandom().random()
a_size = int(key_size * a_ratio)
if a_size is 0:
continue
Expand Down

0 comments on commit 16e7d70

Please sign in to comment.