Skip to content

Instantly share code, notes, and snippets.

@theoremoon

theoremoon/task.sage Secret

Created Oct 11, 2020
Embed
What would you like to do?
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