You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
624 B
20 lines
624 B
from sympy.ntheory.elliptic_curve import EllipticCurve
|
|
|
|
|
|
def test_elliptic_curve():
|
|
# Point addition and multiplication
|
|
e3 = EllipticCurve(-1, 9)
|
|
p = e3(0, 3)
|
|
q = e3(-1, 3)
|
|
r = p + q
|
|
assert r.x == 1 and r.y == -3
|
|
r = 2*p + q
|
|
assert r.x == 35 and r.y == 207
|
|
r = -p + q
|
|
assert r.x == 37 and r.y == 225
|
|
# Verify result in http://www.lmfdb.org/EllipticCurve/Q
|
|
# Discriminant
|
|
assert EllipticCurve(-1, 9).discriminant == -34928
|
|
assert EllipticCurve(-2731, -55146, 1, 0, 1).discriminant == 25088
|
|
# Torsion points
|
|
assert len(EllipticCurve(0, 1).torsion_points()) == 6
|