Skip to content

Instantly share code, notes, and snippets.

@theoremoon
Created February 13, 2023 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theoremoon/23e4335a43c59de1839bacdb83cd6826 to your computer and use it in GitHub Desktop.
Save theoremoon/23e4335a43c59de1839bacdb83cd6826 to your computer and use it in GitHub Desktop.
hell - SECCON CTF 2022 Final (domestic/international)
import os
flag = os.environ.get("FLAG", "neko{the_neko_must_fit_to_the_hyperelliptic}")
p = random_prime(2 ** 512)
xv = randint(0, p-1)
yv = int(flag.encode().hex(), 16)
assert yv < p
g = 2
PR.<x> = PolynomialRing(GF(p))
f = sum(randint(0, p-1)*x**i for i in range(2*g + 1 + 1))
F = f + (yv**2 - f.subs({x: xv}))
HC = HyperellipticCurve(F, 0)
J = HC.jacobian()(GF(p))
D = J(HC((xv, yv)))
print(f"p = {p}")
for i in range(2, 5):
k = i*(i+1)
print(k*D)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment