我试图使用sagemath来解决加密问题。我现在所拥有的就是这段代码:
︠# coding: utf-8
# A big prime:
p = power(2,256) - power(2,224) + power(2,192) + power(2,96) - 1
F = GF(p)
#Elliptic curve in normal form: y^2 = x^3 * ax * b
a = -3
b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
E = EllipticCurve(F, (a, b))
#A generator
G = E.point((0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296,0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5))
#The public key:
q1 = 0xbbb041abbc4b2e9973726520c0a47b9db7d7a8d4e534f5c75d58acd68bf413a1
q2 = 0xc567543991c0d7aac45ac9c325f10b62c77189e3f0a34d977a448bde60590e2d
#Now we need to find the private key: q1 = G*privateKey so we do this:
discrete_log_rho(q1, G, ord = E.order(), operation='+')
我一直收到以下错误:
Error in lines 11-11
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1043, in execute
exec compile(block+'\n', '', 'single', flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "/ext/sage/sage-8.1/local/lib/python2.7/site-packages/sage/groups/generic.py", line 623, in discrete_log_rho
M=[mult(power(base,Integer(m[i])),power(a,Integer(n[i]))) for i in range(partition_size)]
File "sage/structure/element.pyx", line 1242, in sage.structure.element.Element.__add__ (build/cythonized/sage/structure/element.c:10884)
return coercion_model.bin_op(left, right, add)
File "sage/structure/coerce.pyx", line 1139, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (build/cythonized/sage/structure/coerce.c:10736)
raise bin_op_exception(op, x, y)
TypeError: unsupported operand parent(s) for +: 'Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 115792089210356248762697446949407573530086143415290314195533631308867097853948*x + 41058363725152142129326129780047268409114441015993725554835256314039467401291 over Finite Field of size 115792089210356248762697446949407573530086143415290314195533631308867097853951' and 'Integer Ring'
我不知道为什么&#34; +&#34;阿贝尔集团中的一个不受支持的操作数,因为在sagemath页面中,他们在椭圆曲线上使用它并且一切运行正常,我也尝试了他自己的例子并且它成功了。
http://doc.sagemath.org/html/en/reference/groups/sage/groups/generic.html