Skip to content

Commit f115dfc

Browse files
committed
Fix mod_sqrt for a = 1, p = 2
1 parent d6d3efc commit f115dfc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pyrival/algebra/mod_sqrt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
def mod_sqrt(a, p):
22
"""returns x s.t. x**2 == a (mod p)"""
33
a %= p
4-
if a == 0:
5-
return 0
4+
if a < 2:
5+
return a
66
assert pow(a, (p - 1) // 2, p) == 1
77
if p & 3 == 3:
88
return pow(a, (p + 1) // 4, p)

0 commit comments

Comments
 (0)