diff options
author | Barry Mead <barrymead@cox.net> | 2010-02-19 15:45:11 -0700 |
---|---|---|
committer | Barry Mead <barrymead@cox.net> | 2010-02-19 15:45:11 -0700 |
commit | 00395126daaf73626d7864dfc3c7a70585dbb076 (patch) | |
tree | 1d438b54c727dd56e0ff2df72fc9e6a8372815df | |
parent | 1c9a04ec4a16679c74d17645421607ffafb5ff6f (diff) | |
download | rsa-00395126daaf73626d7864dfc3c7a70585dbb076.tar.gz |
Better comments about fast_exponentiation
-rw-r--r-- | rsa/__init__.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rsa/__init__.py b/rsa/__init__.py index 04eecde..de29ec9 100644 --- a/rsa/__init__.py +++ b/rsa/__init__.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 expoent 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 |