@@ -125,7 +125,7 @@ def raw_encrypt(self, plaintext, r_value=None):
125125 neg_ciphertext = (self .n * neg_plaintext + 1 ) % self .nsquare
126126 nude_ciphertext = invert (neg_ciphertext , self .nsquare )
127127 else :
128- # we chose g = n + 1, so that we can exploit the fact that
128+ # we chose g = n + 1, so that we can exploit the fact that
129129 # (n+1)^plaintext = n*plaintext + 1 mod n^2
130130 nude_ciphertext = (self .n * plaintext + 1 ) % self .nsquare
131131
@@ -217,14 +217,14 @@ def __init__(self, public_key, p, q):
217217 # check that p and q are different, otherwise we can't compute p^-1 mod q
218218 raise ValueError ('p and q have to be different' )
219219 self .public_key = public_key
220- if q < p : #ensure that p < q.
220+ if q < p : #ensure that p < q.
221221 self .p = q
222222 self .q = p
223223 else :
224224 self .p = p
225225 self .q = q
226226 self .psquare = self .p * self .p
227-
227+
228228 self .qsquare = self .q * self .q
229229 self .p_inverse = invert (self .p , self .q )
230230 self .hp = self .h_function (self .p , self .psquare )
@@ -233,18 +233,18 @@ def __init__(self, public_key, p, q):
233233 @staticmethod
234234 def from_totient (public_key , totient ):
235235 """given the totient, one can factorize the modulus
236-
236+
237237 The totient is defined as totient = (p - 1) * (q - 1),
238238 and the modulus is defined as modulus = p * q
239-
239+
240240 Args:
241241 public_key (PaillierPublicKey): The corresponding public
242242 key
243243 totient (int): the totient of the modulus
244-
244+
245245 Returns:
246246 the :class:`PaillierPrivateKey` that corresponds to the inputs
247-
247+
248248 Raises:
249249 ValueError: if the given totient is not the totient of the modulus
250250 of the given public key
@@ -256,7 +256,7 @@ def from_totient(public_key, totient):
256256 if not p * q == public_key .n :
257257 raise ValueError ('given public key and totient do not match.' )
258258 return PaillierPrivateKey (public_key , p , q )
259-
259+
260260 def __repr__ (self ):
261261 pub_repr = repr (self .public_key )
262262 return "<PaillierPrivateKey for {}>" .format (pub_repr )
@@ -342,20 +342,20 @@ def raw_decrypt(self, ciphertext):
342342 decrypt_to_p = self .l_function (powmod (ciphertext , self .p - 1 , self .psquare ), self .p ) * self .hp % self .p
343343 decrypt_to_q = self .l_function (powmod (ciphertext , self .q - 1 , self .qsquare ), self .q ) * self .hq % self .q
344344 return self .crt (decrypt_to_p , decrypt_to_q )
345-
345+
346346 def h_function (self , x , xsquare ):
347- """Computes the h-function as defined in Paillier's paper page 12,
347+ """Computes the h-function as defined in Paillier's paper page 12,
348348 'Decryption using Chinese-remaindering'.
349349 """
350350 return invert (self .l_function (powmod (self .public_key .g , x - 1 , xsquare ),x ), x )
351351
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
355-
355+
356356 def crt (self , mp , mq ):
357357 """The Chinese Remainder Theorem as needed for decryption. Returns the solution modulo n=pq.
358-
358+
359359 Args:
360360 mp(int): the solution modulo p.
361361 mq(int): the solution modulo q.
0 commit comments