Skip to content

Commit 553f431

Browse files
committed
Fix a few code format issues
1 parent e802c44 commit 553f431

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

examples/alternative_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ExampleEncodedNumber(paillier.EncodedNumber):
1313

1414

1515
def encode_and_encrypt_example():
16-
print("Encoding a large positive number. With a BASE 64 encoding scheme")
16+
print("Encoding a large positive number. With a BASE {} encoding scheme".format(ExampleEncodedNumber.BASE))
1717
encoded = ExampleEncodedNumber.encode(public_key, 2.1 ** 20)
1818
print("Checking that decoding gives the same number...")
1919
assert 2.1 ** 20 == encoded.decode()
@@ -30,14 +30,14 @@ def encode_and_encrypt_example():
3030

3131

3232
def math_example():
33-
print("Encoding two large positive numbers. With a BASE 64 encoding "
34-
"scheme")
33+
print("Encoding two large positive numbers. BASE={}".format(ExampleEncodedNumber.BASE))
3534

3635
a = 102545 + (64 ** 8)
3736
b = 123 + (8 ** 20)
3837

3938
encoded_a = ExampleEncodedNumber.encode(public_key, a)
4039
encoded_b = ExampleEncodedNumber.encode(public_key, b)
40+
4141
print("Checking that decoding gives the same number...")
4242
assert a == encoded_a.decode()
4343
assert b == encoded_b.decode()

phe/paillier.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ class PaillierPrivateKey(object):
213213
def __init__(self, public_key, p, q):
214214
if not p*q == public_key.n:
215215
raise ValueError('given public key does not match the given p and q.')
216-
if p == q: #check that p and q are different, otherwise we can't compute p^-1 mod q
216+
if p == q:
217+
# check that p and q are different, otherwise we can't compute p^-1 mod q
217218
raise ValueError('p and q have to be different')
218219
self.public_key = public_key
219220
if q < p: #ensure that p < q.
@@ -226,8 +227,8 @@ def __init__(self, public_key, p, q):
226227

227228
self.qsquare = self.q * self.q
228229
self.p_inverse = invert(self.p, self.q)
229-
self.hp = self.h_function(self.p, self.psquare);
230-
self.hq = self.h_function(self.q, self.qsquare);
230+
self.hp = self.h_function(self.p, self.psquare)
231+
self.hq = self.h_function(self.q, self.qsquare)
231232

232233
@staticmethod
233234
def from_totient(public_key, totient):
@@ -347,8 +348,7 @@ def h_function(self, x, xsquare):
347348
'Decryption using Chinese-remaindering'.
348349
"""
349350
return invert(self.l_function(powmod(self.public_key.g, x - 1, xsquare),x), x)
350-
351-
351+
352352
def l_function(self, x, p):
353353
"""Computes the L function as defined in Paillier's paper. That is: L(x,p) = (x-1)/p"""
354354
return (x - 1) // p
@@ -364,11 +364,12 @@ def crt(self, mp, mq):
364364
return mp + (u * self.p)
365365

366366
def __eq__(self, other):
367-
return (self.p == other.p and self.q == other.q)
367+
return self.p == other.p and self.q == other.q
368368

369369
def __hash__(self):
370370
return hash((self.p, self.q))
371371

372+
372373
class PaillierPrivateKeyring(Mapping):
373374
"""Holds several private keys and can decrypt using any of them.
374375

0 commit comments

Comments
 (0)