如何针对小整数测试在SageMath中求解ECDL的算法?

时间:2019-07-05 18:55:08

标签: python sage

我的问题是在SageMath或Python中实现婴儿步巨型步或Pollard Rho,以针对给定的P生成G的小乘数x,从而P = x *G。

这是较大项目的分配部分。

modi =  115792089237316195423570985008687907853269984665640564039457584007908834671663

E=EllipticCurve(GF(modi), [0,7])

G=E(55066263022277343669578718895168534326250603453777594175500187360389116729240, 32670510020758816978083085130507043184471273380659243275938904335757337482424)

P=E(69335761065767984070318781108127416310968753866933119760392423089576366173459, 113425617697416972613102767146321902225172329004525144463444008550345431352693)

x = 24734216105351567

对于x的搜索应限制在2 ^ 54点的空间内,并求解P = x * G并保持上面的所有其他参数。

我尝试了https://github.com/qubd/mini_ecdsa,但出现以下错误。

>>>C = CurveOverFp(0, 0, 7, 2**256-2**32-2**9-2**8-2**7-2**6-2**4-1)
y^2 = x^3 + 7 over F_115792089237316195423570985008687907853269984665640564039457584007908834671663

>>> P = Point(55066263022277343669578718895168534326250603453777594175500187360389116729240,
... 32670510020758816978083085130507043184471273380659243275938904335757337482424)

>>> n = 2^54

>>> Q = (69335761065767984070318781108127416310968753866933119760392423089576366173459, 113425617697416972613102767146321902225172329004525144463444008550345431352693)

>>>crack_baby_giant(C, P, n, Q)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mini_ecdsa.py", line 470, in crack_baby_giant
    R = curve.add(Q, curve.invert(curve.mult(P, g*m)))
  File "mini_ecdsa.py", line 321, in add
    y_diff = (P_2.y - P_1.y) % self.char
AttributeError: 'tuple' object has no attribute 'y'

1 个答案:

答案 0 :(得分:0)

您正在尝试仅对Q使用元组。但是,如果期望使用Point,这是行不通的,正如Github链接上的文档所示。尝试做Q = Point(... , ...),希望能奏效。


顺便说一句,可能您应该自己实现它,而不用其他代码实现-还是作为示例提供的?祝你好运。