scipr-lab / ecfactory

SageMath library for constructing elliptic curves
Other
65 stars 17 forks source link

Pell equation solver bugfix #7

Closed johannes-reinhart closed 1 year ago

johannes-reinhart commented 1 year ago

The pell equation solver sometimes outputs wrong solutions, for example:

def test_pell_equation(d, m):
    gen, sols = pell_solve(d, m)

    assert gen[0]**2 - d*gen[1]**2 == 1
    for sol in sols:
        assert sol[0]**2 - d*sol[1]**2 == m

test_pell_equation(34, 4)

fails.

A comparison with reference Karabina, Teske (2017): "On prime-order elliptic curves with embedding degrees k = 3, 4 and 6" shows, that a sqrt() is missing.

This pull requests proposes a bugfix and also includes a test for confirming the issue.