Skip to content

Instantly share code, notes, and snippets.

@tscholl2
Last active July 14, 2020 18:31
Show Gist options
  • Save tscholl2/666ed35603c3813d29c61e7a67e37639 to your computer and use it in GitHub Desktop.
Save tscholl2/666ed35603c3813d29c61e7a67e37639 to your computer and use it in GitHub Desktop.
def cm_method(q,t):
"""
Given a prime power q and integer t with |t| <= 2sqrt(q),
returns an Elliptic curve over GF(q) with q + 1 - t points.
"""
n = q + 1 - t
d = t^2 - 4*q
K = QuadraticField(d)
j = K.hilbert_class_polynomial().any_root()
E = EllipticCurve_from_j(GF(q)(j))
while E.count_points() != n:
if d == -3:
E = E.sextic_twist(randint(1,q-1))
elif d == -4:
E = E.quartic_twist(randint(1,q-1))
else:
E = E.quadratic_twist()
return E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment