From 00395126daaf73626d7864dfc3c7a70585dbb076 Mon Sep 17 00:00:00 2001 From: Barry Mead Date: Fri, 19 Feb 2010 15:45:11 -0700 Subject: Better comments about fast_exponentiation --- rsa/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rsa/__init__.py') 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 -- cgit v1.2.1