Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The following works for me in the sage interpreter:

E = EllipticCurve( GF(71), [41, 18] )
p = E( 63, 32 )
k = 2

def mult(P, k):
    if k == 0:
        return E(0)
    elif k<0:
        return -mult(P, -k)
    elif k%2 == 1:
        return P + mult(P+P, k//2)
    else:
        return mult(P+P, k//2)

Test:

sage: mult(p, k)
(43 : 63 : 1)
sage: k*p
(43 : 63 : 1)
sage: mult(p, 2017)
(27 : 54 : 1)
sage: 2017*p
(27 : 54 : 1)
sage: mult(p, 2018)
(0 : 36 : 1)
sage: 2018*p
(0 : 36 : 1)
sage: mult(p, -2017)
(27 : 17 : 1)
sage: (-2017)*p
(27 : 17 : 1)