Last active
October 24, 2020 17:09
-
-
Save hellman/e6352b9f12c9759ef23dcd87b64ec8c0 to your computer and use it in GitHub Desktop.
RCTF 2020 - infantECC
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
from Crypto.Util.number import getStrongPrime, bytes_to_long, long_to_bytes | |
from hashlib import sha256 | |
flag = open("flag.txt","rb").read() | |
p=getStrongPrime(512) | |
q=getStrongPrime(512) | |
R=Zmod(p*q) | |
Mx=R.random_element() | |
My=R.random_element() | |
b=My^2-Mx^3 | |
E=EllipticCurve(R, [0,b]) | |
Ep=EllipticCurve(GF(p), [0,b]) | |
Eq=EllipticCurve(GF(q), [0,b]) | |
Ecard=Ep.cardinality()*Eq.cardinality() | |
r=random_prime((p^^q)>>100) | |
s=inverse_mod(r, Ecard) | |
print((s,b)) | |
print(s*E(Mx,My)) | |
print(randint(0,Ecard)*E(Mx,My)) | |
print(r^^(bytes_to_long(sha256(long_to_bytes(Mx)).digest())^^bytes_to_long(flag))<<256) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A lot of weird stuff going on!