Skip to content

Commit 07500a9

Browse files
authored
Merge pull request #58 from n1analytics/remove-gmpy2-as-dependency
Remove gmpy2 as dependency
2 parents 8269381 + e0455ab commit 07500a9

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ Or use nose::
2828

2929
nosetests
3030

31+
Note related to gmpy2
32+
---------------------
33+
34+
`gmpy2` is not required to use the library, but is preferred. A pure Python implementation is available but
35+
`gmpy2` drastically improves performances. As indication on a laptop not dedicated to benchmarking, running the example
36+
`examples/federated_learning_with_encryption.py` provided in the library took:
37+
- 4.5s with `gmpy2` installed
38+
- 35.7s without `gmpy2` installed
39+
40+
However, `gmpy2` is a requirement to run the tests.
3141

3242
Code History
3343
------------

examples/federated_learning_with_encryption.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class Server:
138138
"""Private key holder. Decrypts the average gradient"""
139139

140140
def __init__(self, key_length):
141-
keypair = paillier.generate_paillier_keypair(key_length)
141+
keypair = paillier.generate_paillier_keypair(n_length=key_length)
142142
self.pubkey, self.privkey = keypair
143143

144144
def decrypt_aggregate(self, input_model, n_clients):

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
},
5757
extras_require={
5858
'cli': ['click'],
59-
'examples': ['sklearn']
59+
'examples': ['numpy', 'scipy', 'sklearn']
6060
},
61-
install_requires=['gmpy2'],
62-
tests_require=['numpy', 'click'],
61+
install_requires=[],
62+
tests_require=['click', 'gmpy2', 'numpy'],
6363
test_suite="phe.tests"
6464
)

0 commit comments

Comments
 (0)