Skip to content

Bug in multiplication of point by integer #373

Description

@fedimser

Version: ecdsa==0.19.2

Repro:

from ecdsa.ellipticcurve import INFINITY, CurveFp, Point, PointJacobi

def multiply_naive(point, a):
    ans = point
    for i in range(a-1):
        ans = ans + point
    return ans

curve = CurveFp(p=31, a=2, b=3)
point = Point(curve, 6, 18)
print("point:", point)
print("11*point:", 11*point)
print("11*point (naive):", multiply_naive(point, 11))
print("10*point+point:", 10*point+point)
print("11*point (via Jacobi):", (11*PointJacobi.from_affine(point)).to_affine())

Output:

point: (6,18)
11*point: (6,13)
11*point (naive): (8,29)
10*point+point: (8,29)
11*point (via Jacobi): (8,29)

As I showed in 3 different ways, for P=(6,18), 11*P=(8,29). However, the library returns (6,13).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunintended behaviour in ecdsa code

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions