Commits

Anonymous committed 34f97dc

better comments about safe bit

Comments (0)

Files changed (1)

         raise OverflowError("The message is too long")
 
     #Note: Bit exponents start at zero (bit counts start at 1) this is correct
-    safebit = int(math.floor(math.log(key['n'],2))) - 1 #compute safe bit (MSB - 1)
+    safebit = int(math.floor(math.log(key['n'],2))) - 1 #safe bit is (MSB - 1)
     message += (1 << safebit)                    #add safebit to ensure folding
 
     return fast_exponentiation(message, key['e'], key['n'])
     message = fast_exponentiation(cyphertext, key['e'], key['n'])
 
     #Note: Bit exponents start at zero (bit counts start at 1) this is correct
-    safebit = int(math.floor(math.log(key['n'],2))) - 1 #safe bit (MSB - 1)
+    safebit = int(math.floor(math.log(key['n'],2))) - 1 #safe bit is (MSB - 1)
     message -= (1 << safebit)                  #remove safe bit before decode
 
     return message
     h = (key['qi'] * dif) % key['p']
     message = m2 + (h * key['q'])
 
-    safebit = int(math.floor(math.log(n,2))) - 1 #compute safe bit (MSB - 1)
+    safebit = int(math.floor(math.log(n,2))) - 1 #safe bit is (MSB - 1)
     message -= (1 << safebit)                    #remove safebit before decode
 
     return message
     if message < 0 or message > n:
         raise OverflowError("The message is too long")
 
-    safebit = int(math.floor(math.log(n,2))) - 1 #compute safe bit (MSB - 1)
+    safebit = int(math.floor(math.log(n,2))) - 1 #safe bit is (MSB - 1)
     message += (1 << safebit)                    #add safebit before encrypt
 
     #Encrypt in 2 parts, using faster Chinese Remainder Theorem method