Skip to content

Instantly share code, notes, and snippets.

@theoremoon
Created October 11, 2020 01:51
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/5aa07876fb095f9b5648208441ea4ae3 to your computer and use it in GitHub Desktop.
Save theoremoon/5aa07876fb095f9b5648208441ea4ae3 to your computer and use it in GitHub Desktop.
SECCON 2020 Online CTF - urara
from flag import flag
p = random_prime(1 << 1024)
q = random_prime(1 << 1024)
n = p * q
print("n =", n)
# ---
x = int.from_bytes(flag, "big")
y = randint(0, n-1)
a = randint(0, n-1)
b = (y^2 - (x^3 + a*x)) % n
EC = EllipticCurve(Zmod(n), [a, b])
P = EC((x, y))
Q = 2 * P
print("a, b =", [a, b])
print("Q =", Q.xy())
# ---
m = int.from_bytes(flag, "big")
t = randint(0, n-1)
c = power_mod(m + t, 65537, n)
print("t =", t)
print("c =", c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment