This repository was archived by the owner on Apr 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 88- Added marker file for PEP 561. This will allow type checking tools in dependent projects
99 to use type annotations from Python-RSA
1010 ([ #136 ] ( https://github.com/sybrenstuvel/python-rsa/pull/136 ) ).
11+ - Use the Chinese Remainder Theorem when decrypting with a private key. This
12+ makes decryption 2-4x faster
13+ ([ #163 ] ( https://github.com/sybrenstuvel/python-rsa/pull/163 ) ).
1114
1215## Version 4.7.2 - released 2021-02-24
1316
Original file line number Diff line number Diff line change @@ -473,7 +473,16 @@ def blinded_decrypt(self, encrypted: int) -> int:
473473
474474 # Blinding and un-blinding should be using the same factor
475475 blinded , blindfac_inverse = self .blind (encrypted )
476- decrypted = rsa .core .decrypt_int (blinded , self .d , self .n )
476+
477+ # Instead of using the core functionality, use the Chinese Remainder
478+ # Theorem and be 2-4x faster. This the same as:
479+ #
480+ # decrypted = rsa.core.decrypt_int(blinded, self.d, self.n)
481+ s1 = pow (blinded , self .exp1 , self .p )
482+ s2 = pow (blinded , self .exp2 , self .q )
483+ h = ((s1 - s2 ) * self .coef ) % self .p
484+ decrypted = s2 + self .q * h
485+
477486 return self .unblind (decrypted , blindfac_inverse )
478487
479488 def blinded_encrypt (self , message : int ) -> int :
You can’t perform that action at this time.
0 commit comments