观察曲线的阶,存在一些小因子可以利用,因此使用PH+BSGS求出子群上的DLP,并爆破一些子群阶,即可得到key
然后AES-CBC解密得到flag
但是由于题目给出了曲线上的两个点,因此可以在GFp上解方程得到曲线参数
观察曲线的阶,存在一些小因子可以利用,因此使用PH+BSGS求出子群上的DLP,并爆破一些子群阶,即可得到key
然后AES-CBC解密得到flag
from sage.all import *
from Crypto.Util.number import *
from Crypto.Cipher import AES
import hashlib
G = (584273268656071313022845392380, 105970580903682721429154563816)
P = (401055814681171318348566474726, 293186309252428491012795616690)
data = {'iv': 'bae1b42f174443d009c8d3a1576f07d6', 'cipher': 'ff34da7a65854ed75342fd4ad178bf577bd622df9850a24fd63e1da557b4b8a4'}
p = 770311352827455849356512448287
R = PolynomialRing(GF(p), 'x,y')
x, y = R.gens()
B = Ideal([
G[1]**2 - G[0]**3 - x*G[0] - y,
P[1]**2 - P[0]**3 - x*P[0] - y
]).groebner_basis()
a = ZZ(-B[0].univariate_polynomial()(0))
b = ZZ(-B[1].univariate_polynomial()(0))
E = EllipticCurve(GF(p), [a, b])
G, P = E(G), E(P)
order = G.order()
subs = [2**5, 7, 1135963, 1249861]
sks = list()
for sub in subs:
sk = discrete_log_lambda(order//sub * P, order//sub * G, (0, sub), operation='+')
sks.append(sk)
print(sub, sk)
sk = crt(sks, subs)
while True:
if sk*G == P:
print(sk)
iv, ct = [bytes.fromhex(_) for _ in [data["iv"], data["cipher"]]]
key = hashlib.sha256(str(sk).encode()).digest()[:16]
cipher = AES.new(key, AES.MODE_CBC, iv)
flag = cipher.decrypt(ct)
print(flag)
break
sk += prod(subs)