Elliptic Curves

Curves

Implementation of Elliptic curves over Finite Fields.

class simula.hecc.curve.EllipticCurveObject(domain, projective=False)

Main class of any Elliptic curve.

add(p1, p2)

Addition of p1 and p2.

base_ring()

Returns the base ring : the domain.

cardinality()

Returns the order of self.

get_point_at_infinity()

Returns the point at infinity of self.

static is_irreducible()

Tests if self is irreducible.

static is_order_finite()

Returns True of the number of points of self is finite and False otherwise.

is_ordinary()

Tests if self is an ordinary elliptic curve.

static is_singular()

Tests if self is singular.

static is_smooth()

Tests if self is smooth.

is_supersingular()

Tests if self is a supersingular elliptic curve.

multiply_by_scalar(P, k=2)

Scalar multiplication \(kP = P + P + \ldots + P\) k times.

order()

Returns the order of self.

random_element()

Returns a random point of self.

random_point()

Returns a random point of self.

rational_points()

Returns the rational points of self.

trace_of_frobenius()

Returns the trace of Frobenius of self.

class simula.hecc.curve.EllipticCurvePoint(curve, x=None, y=None, z=None, *, projective=False, check=True)

Point of an elliptic curve.

cardinality()

Returns the order of self.

get_generated_sub_group()

Returns the additive sub-group generated by self.

is_point()

Tests if self is a point.

is_point_at_infinity()

Tests if self is the point at infinity.

opposite()

Returns the opposite point of self.

order()

Returns the order of self.

xy()

returns th (x, y) coordinates.

class simula.hecc.curve.GroupGeneratedBy(point)

Additive-Sub group of an elliptic curve generated by a point.

all_group_points()

Returns all rational points of self.

is_point(Q)

Tests if Q is a point of self.

order()

Returns the order of self.

random_point()

Returns a random point of self.

rational_points()

Returns all rational points of self.

Weierstrass Curves

Implementation of Elliptic curves over Finite Fields.

  • Elliptic curves defined by a short Weierstrass equation

  • Elliptic curves defined by a long Weierstrass equation

simula.hecc.weirstrass.EllipticCurve(domain, *coeffs, projective=False)

Returns an elliptic curve over a einite field.

Parameters
  • domain (simula.finite_field.finite_field.FiniteField) – a finite field of size p^n.

  • coeffs (Union[Sized, simula.finite_field.finite_field.ElementFiniteField, Iterable]) – the list of coefficients. The size should be either 2 (for a short Weierstrass equation \(y^2=x^3+ax+b\)) or 5 (for a long Weierstrass equation \(y^2+a_3xy+a_1y = x^3+a_2x^2+a_4x+a_6\)).

  • projective – (a boolean) if True the equation and rational points will be printed in projective form.

EXAMPLES:

simula : E = EllipticCurve(GF(11), [1, 5]); E
Elliptic curve defined by : y^2 = x^3 + x + 5 over GF(11)
simula : E.rational_points()
[(0, 4), (0, 7), (2, 2), (2, 9), (5, 5), (5, 6), (7, 5), (7, 6), (10, 5), (10, 6), P_oo]
simula : E.projective = True
simula : E
Elliptic curve defined by : Y^2*Z = X^3 + X*Z^2 + 5Z^3 over GF(11)
simula : E.rational_points()
[(0 : 1 : 0), (0 : 4 : 1), (0 : 7 : 1), (2 : 2 : 1), (2 : 9 : 1), (5 : 5 : 1), (5 : 6 : 1),
 (7 : 5 : 1), (7 : 6 : 1), (10 : 5 : 1), (10 : 6 : 1)]
simula : E2 = EllipticCurve(GF(7), [1, 0, 1, -3, 2]); E2
Elliptic curve defined by : y^2 + y*x + y = x^3 - 3x + 2 over GF(7)
simula : E2.a_invariants()
(1, 0, 1, -3, 2)
simula : E2.b_invariants()
(1, 2, 2, 3)
simula : E2.order()
11
simula : E3 = E2.short_weierstrass_model(); E3
Elliptic curve defined by : y^2 = x^3 + 2x + 6 over GF(7)
simula : E3.order()
11
simula : E3.rational_points()
[(1, 3), (1, 4), (2, 2), (2, 5), (3, 2), (3, 5), (4, 1), (4, 6), (5, 1), (5, 6), P_oo]
simula : P = E3(1, 4); P
(1, 4)
simula : 7P
(3, 5)
simula : Q = E3(3, 2); Q
(3, 2)
simula : P-Q
(5, 1)
simula : P.order()
11
simula : 11P
P_oo
simula : P.projective = True
simula : 11P
(0 : 1 : 0)
class simula.hecc.weirstrass.WeierstrassCurve(domain, projective=False)

Bases: simula.hecc.curve.EllipticCurveObject

b_invariants()

Returns the b-invariant of self.

c_invariants()

Returns the c-invariant of self.

discriminant()

Returns the discriminant of self.

j_invariant()

Returns the j-invariant of self.

order()

Returns the order of self i.e the number of elements of self.

Montgomery Curves

Implementation of Montgomery Curves.

class simula.hecc.montgomery.MontgomeryCurve(domain, b=None, a=None, *, projective=False)

Bases: simula.hecc.curve.EllipticCurveObject

Elliptic curve defined by a Montgomery curve in the form \(by^2=x^3+ax^2+x\) over a finite field.

Parameters
  • domain – a finite field

  • b – a non-square in the domain

  • a – an element of the domain

  • projective – (a boolean) if True the equation and rational points will be printed in projective form.

simula : E = MontgomeryCurve(GF(11), 2, 5); E
Elliptic curve in Montgomery form defined by : 2y^2 = x^3 + 5x^2 + x over GF(11)
simula : E.rational_points()
[(0, 0), (1, 3), (1, 8), (2, 2), (2, 9), (5, 1), (5, 10), (6, 5), (6, 6), (9, 4), (9, 7), P_oo]
simula : E.order()
12
simula : E2 = E.short_weierstrass_model(); E2
Elliptic curve defined by : y^2 = x^3 + 7 over GF(11)
simula : E2.order()
12
add_distinct_points(p1, p2)

Addition of p1 and p2 with p1 != p2 != POINT_INFINI and p1 != - p2.

doubling(P)

Doubling of point P.

is_point(Q)

Tests if Q is a point of self.

j_invariant()

Returns the j-invariant of self.

short_weierstrass_model()

Returns an elliptic curve defined by a short Weierstrass equation \(y^2=x^3+ax+b\) which is birationaly equivalent to self.