Skip to content

Commit

Permalink
Fix Montgomey Modular Multiplication method.
Browse files Browse the repository at this point in the history
  • Loading branch information
calonso88 committed Apr 14, 2024
1 parent f5cb90b commit 181c126
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

def mmm (a, b, m, nbits):
r = 0
count = 0
while counter < nbits:
idx = 0
while idx < nbits:
r0 = r % 2
b0 = b % 2
a_bit = 1 # tbd update later
a_bit = ( get_bit(a, idx) >> idx )
q0 = r0 + b0 * a_bit
q0 = q0 % 2
r = ( r + a_bit * b + q0 * m ) // 2
counter = counter + 1
idx = idx + 1
return r;

def is_prime(num):
Expand Down

0 comments on commit 181c126

Please sign in to comment.