This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# ~~~ Construction of an Isogeny Between Elliptic Curves ~~~ | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Field and Curve Definitions | |
p = 97 | |
F = GF(p) | |
E1 = EllipticCurve(F, [1, 24]) | |
E2 = EllipticCurve(F, [42, 46]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import libnum | |
from typing import List, Optional | |
def modular_square_roots(a: int, p: int) -> Optional[List[int]]: | |
"""Return all x such that x² ≡ a (mod p), or None if none exist.""" | |
if not libnum.has_sqrtmod_prime_power(a, p): | |
return None | |
return list(libnum.sqrtmod_prime_power(a, p)) |