This repository was archived by the owner on Apr 20, 2025. It is now read-only.
File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 8
8
- Added marker file for PEP 561. This will allow type checking tools in dependent projects
9
9
to use type annotations from Python-RSA
10
10
([ #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 ) ).
11
14
12
15
## Version 4.7.2 - released 2021-02-24
13
16
Original file line number Diff line number Diff line change @@ -473,7 +473,16 @@ def blinded_decrypt(self, encrypted: int) -> int:
473
473
474
474
# Blinding and un-blinding should be using the same factor
475
475
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
+
477
486
return self .unblind (decrypted , blindfac_inverse )
478
487
479
488
def blinded_encrypt (self , message : int ) -> int :
You can’t perform that action at this time.
0 commit comments