Использование функции мудреца Полларда - PullRequest
0 голосов

Я пытаюсь использовать 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'

Я понятия не имею, почему "+" является неподдерживаемым операндом в абелевомгруппа, так как на странице Sagemath они используют его поверх эллиптических кривых, и все работает нормально, я также попробовал их пример самостоятельно, и это сработало.

http://doc.sagemath.org/html/en/reference/groups/sage/groups/generic.html

...