8000 Use math.gcd if available · tlsfuzzer/python-ecdsa@4b95c2a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b95c2a

Browse files
committed
Use math.gcd if available
1 parent 8a4a1f9 commit 4b95c2a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/ecdsa/numbertheory.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,14 @@ def inverse_mod(a, m):
225225
return ud + m
226226

227227

228-
def gcd2(a, b):
229-
"""Greatest common divisor using Euclid's algorithm."""
230-
while a:
231-
a, b = b % a, a
232-
return b
228+
try:
229+
gcd2 = math.gcd
230+
except AttributeError:
231+
def gcd2(a, b):
232+
"""Greatest common divisor using Euclid's algorithm."""
233+
while a:
234+
a, b = b % a, a
235+
return b
233236

234237

235238
def gcd(*a):
@@ -567,4 +570,3 @@ def next_prime(starting_value):
567570
1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229]
568571

569572
miller_rabin_test_count = 0
570-

0 commit comments

Comments
 (0)
0