@@ -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+
372373class PaillierPrivateKeyring (Mapping ):
373374 """Holds several private keys and can decrypt using any of them.
374375
0 commit comments