前言:剧情十(我没看见还有一个。。。。)
提示:
下载:
参数有了,直接搞就行。。。
参考:
*crypto*练2--攻防世界--easy_ECC - kubopiy - 博客园 (cnblogs.com)
大佬的脚本:
攻防世界 easy_ECC - diakla - 博客园 (cnblogs.com)
p = 15424654874903
a = 16546484
b = 4548674875
k = 546768
gx = 6478678675
gy = 5636379357093
def ksm(a, b):
# print(a)
r = 1
a = (a % p + p) % p
aa = a
while b:
if b & 1:
r = r * a % p
a = a * a % p
b >>= 1
print(aa * r % p)
return r
def add(x1, y1, x2, y2):
# k=((ay-by)*ksm((ax-bx+p)%p,p-1)%p+p)%p;
# a=((k*k-ax-bx)%p+p)%p
# b=(k*(ax-(a-p))%p+p)%p
# print(x1,end=" ")
# print(y1);
# print(x2,end=" ")
# print(y2);
if x1 == None:
return x2, y2
if x2 == None:
return x1, y1
if x1 == x2 and y1 != y2:
return None, None
if x1 == x2:
m = (3 * x1 * x1 + a) * ksm(2 * y1 % p, p - 2)
else:
m = (y1 - y2) * ksm((x1 - x2) % p, p - 2)
# print(m%p)
x3 = m * m - x1 - x2
y3 = y1 + m * (x3 - x1)
return x3 % p, -y3 % p
# k=k-1
rx = None
ry = None
while k:
if k & 1:
rx, ry = add(rx, ry, gx, gy)
# print(gx,end=" ")
# print(gy)
gx, gy = add(gx, gy, gx, gy)
k >>= 1
# print(rx,end=" ")
# print(ry)
print(rx + ry)
# 19477226185390
。。。牛逼。
cyberpeace{19477226185390}
ECC椭圆曲线加解密原理详解(配图)_ecc解密-CSDN博客