summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Mead <barrymead@cox.net>2010-02-19 15:45:45 -0700
committerBarry Mead <barrymead@cox.net>2010-02-19 15:45:45 -0700
commitf5f1af2f8681262425dcaa6f247ae2ea46b13d03 (patch)
treec995f64dbe04074566d469075274dce4ad85db73
parent00395126daaf73626d7864dfc3c7a70585dbb076 (diff)
downloadrsa-f5f1af2f8681262425dcaa6f247ae2ea46b13d03.tar.gz
Better comments about fast_exponentiation
-rw-r--r--rsa/fastrsa.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/rsa/fastrsa.py b/rsa/fastrsa.py
index 8f0617c..a8f2ab6 100644
--- a/rsa/fastrsa.py
+++ b/rsa/fastrsa.py
@@ -168,8 +168,8 @@ def fast_exponentiation(a, e, n):
#Single loop version is faster and uses less memory
#MSB is always 1 so skip testing it and start with result = a
msbe = int(math.ceil(math.log(e,2))) - 2 #Find MSB-1 of exponent
- test = long(1 << msbe)
- a %= n #Throw away any overflow
+ test = long(1 << msbe) #Isolate each exponent bit with test value
+ a %= n #Throw away any overflow modulo n
result = a #Start with result = a (skip MSB test)
while test != 0:
if e & test != 0: #If exponent bit 1 square and mult by a