Elliptic Curve Arithmetic
Types
BinaryECC.EC — TypeEC{B}Represents a non-supersingular elliptic curve over the binary field B.
Contains fields a::B and b::B, where:
$y^2 + xy = x^3 + ax^2 + b$
BinaryECC.AbstractECPoint — TypeAbstractECPoint{B}Abstract type for points on an elliptic curve defined over the binary field B.
BinaryECC.ECPointAffine — TypeECPointAffine{B} <: AbstractECPoint{B}Represents a point on an elliptic curve over the binary B. Contains fields x::B, y::B, and ec::EC{B}.
$E: y^2 + xy = x^3 + ax^2 + b$
BinaryECC.ECPointJacobian — TypeECPointJacobian{B} <: AbstractECPoint{B}Represents a point on an elliptic curve over the binary B. Contains fields x::B, y::B, z::B and ec::EC{B}.
$E: y^2 + xyz = x^3 + ax^2z^2 + bz^6$
Each point $(x, y)$ on the curve is represented by a set of equivalent Jacobian points, $\{(\lambda^2 x, \lambda^3 y, \lambda) : \lambda \in K^* \}$ (where $K^*$ is the binary field that the curve is based on).
BinaryECC.ECPointLD — TypeECPointLD{B} <: AbstractECPoint{B}Represents a point on an elliptic curve over the binary B. Contains fields x::B, y::B, z::B and ec::EC{B}.
$E: y^2 + xyz = x^3z + ax^2z^2 + bz^4$
Each (affine) point $(x, y)$ is represented by a set of Lopez-Dahab points, $\{(\lambda x, \lambda^2 y, \lambda) : \lambda \in K^* \}$ (where $K^*$ is the binary field that the curve is based on).
BinaryECC.ECMismatchException — TypeECMismatchException <: ExceptionIndicates that an operation has been attempted on several points that are not on the same curve.
Curve Functions
Base.:== — Method==(ec1::EC{B}, ec2::EC{B}) where BTwo elliptic curves are equal if they have the same parameters a and b, and are defined over the same field.
Base.repr — Methodrepr(ec::EC)Returns a string representation of an elliptic curve equation, "$y^2 + xy = x^3 + ax^2 + b$".
Point Arithmetic
Base.:== — Method==(p1::ECPointAffine{B}, p2::ECPointAffine{B}) where BTwo points are equal iff they have the same $x$ and $y$ coordinate, and are on the same elliptic curve.
Base.:+ — Method+(p1::ECPointAffine{B}, p2::ECPointAffine{B}) where BReturns $p_1+p_2$.
If the points are not on the same curve, this will throw an ECMismatchException.
BinaryECC.double — Methoddouble(p::ECPointAffine{B})::ECPointAffine{B} where BReturns the result of doubling the point p, using a standard method that assumes p is a random unknown point.
Base.:- — Method-(p::ECPointAffine{B}) where BReturns additive inverse of the given point, $-p$.
Base.:- — Method-(p1::AbstractECPoint, p2::AbstractECPoint)Returns $p_1-p_2$.
Base.:* — Method*(p::AbstractECPoint{B}, k) where BReturns the result of the scalar multiplication $p \cdot k$, using a default high performance method. Commutative, so that either p * k or k * p can be written, in addition to p \cdot k or k \cdot p. k must be an integer or a PFieldElt.
Scalar Point Addition
BinaryECC.double_standard — Methoddouble_standard(p::ECPointAffine{B})::ECPointAffine{B} where BPerforms a standard version of the point doubling routine.
BinaryECC.double_memo — Methoddouble_memo(p::ECPointAffine{B})::ECPointAffine{B} where BPerforms memoised point doubling: if the point p has previously been calculated by this routine, it will be fetched from a dictionary rather than recalculated. If the point has not yet been seen, it will be doubled with the double_standard routine and stored into a dictionary.
BinaryECC.double_threaded — Methoddouble_threaded(p::ECPointAffine{B})::ECPointAffine{B} where BDoubles the point p by spawning an additional thread to perform extra work on.
Scalar Point Multiplication
BinaryECC.mult_standard_rtl — Methodmult_standard_rtl(P::AbstractECPoint{B}, k::Integer) where BPerforms scalar point multiplication using a right-to-left double-and-add method.
BinaryECC.mult_standard_ltr — Methodmult_standard_ltr(P::AbstractECPoint{B}, k::Integer) where BPerforms scalar point multiplication using a left-to-right double-and-add method.
BinaryECC.mult_window — Methodmult_window(P::AbstractECPoint{B}, k::Integer, w::Int) where BPerforms scalar point multiplication using a windowed left-to-right double-and-add method.
BinaryECC.mult_bnaf — Methodmult_bnaf(P::AbstractECPoint{B}, k::Integer) where BPerforms scalar point multiplication using a right-to-left double-and-add method with the binary NAF of k.
BinaryECC.mult_memo — Methodmult_memo(P::AbstractECPoint{B}, k::Integer) where BPerforms scalar point multiplication using a right-to-left double-and-add method with the binary NAF of k. This function uses the memoised point doubling routine double_memo, and so it should only called with a known point P (i.e. one which will likely be seen again, such as a generating point).
BinaryECC.mult_bnaf_threaded — Methodmult_bnaf_threaded(P::AbstractECPoint{B}, k::Integer) where BPerforms scalar point multiplication using a right-to-left double-and-add method with the binary NAF of k, by spawning an extra thread where useful.
BinaryECC.mult_bnaf_window — Methodmult_bnaf_window(P::AbstractECPoint{B}, k::Integer, w::Int) where BPerforms scalar point multiplication using a windowed left-to-right double-and-add method with the binary NAF of k. Performs best with a window size of 8.
BinaryECC.mult_wnaf — Methodmult_wnaf(P::AbstractECPoint{B}, k::Integer, w::Int) where BPerforms scalar point multiplication using a left-to-right double-and-add method with the width-w NAF of k. Performs best with a width of 6.
BinaryECC.mult_mont_general — Methodmult_mont_general(p::AbstractECPoint, n::Integer)Performs $p \cdot n$ with a fixed sequence of curve and field operations. More resistant to timing attacks than the standard double and add algorithm.
BinaryECC.mult_mont_affine — Methodmult_mont_affine(p::ECPointAffine{B}, n::Integer) where BReturns $p \cdot n$.
More resistant to timing attacks than the standard double and add algorithm.
Fast Multiplication on Elliptic Curves over $GF(2^m)$ without Precomputation, Algorithm 2A: Montgomery Scalar Multiplication.
Additive Identity
Base.iszero — Methodiszero(p::ECPointAffine)Returns true if $p = \mathcal{O}$, i.e it is the point at infinity.
Base.zero — Methodzero(::Type{ECPointAffine{B}, ec::EC{B}) where BReturns an object representing the point at infinity on the given curve.
Base.zero — Methodzero(::Type{ECPointAffine, ec::EC{B}) where BReturns an object representing the point at infinity on the given curve.
Base.iszero — Methodiszero(p::ECPointJacobian)Returns true if $p = \mathcal{O}$, i.e it is the point at infinity.
Base.zero — Methodzero(::Type{ECPointJacobian{B}}, ec::EC{B}) where BReturns an object representing the point at infinity on the given curve.
Base.zero — Methodzero(::Type{ECPointJacobian}, ec::EC{B}) where BReturns an object representing the point at infinity on the given curve.
Base.iszero — Methodiszero(p::ECPointLD)Returns true if $p = \mathcal{O}$, i.e it is the point at infinity.
Base.zero — Methodzero(::Type{ECPointLD{B}}, ec::EC{B}) where BReturns an object representing the point at infinity on the given curve.
Base.zero — Methodzero(::Type{ECPointLD}, ec::EC{B}) where BReturns an object representing the point at infinity on the given curve.
Mixed Representation Functions
Base.:+ — Method+(::Type{ECPointJacobian{B}}, p1::ECPointLD{B}, p2::ECPointJacobian{B}) where BReturns $p_1 +p_2$ in Jacobian coordinates.
Base.:+ — Method+(::Type{ECPointJacobian{B}}, p1::ECPointJacobian{B}, p2::ECPointLD{B}) where BReturns $p_1 +p_2$ in Jacobian coordinates.
Base.:+ — Method+(::Type{ECPointLD{B}}, p1::ECPointLD{B}, p2::ECPointJacobian{B}) where BReturns $p_1 +p_2$ in Lopez-Dahab coordinates.
Base.:+ — Method+(::Type{ECPointLD{B}}, p1::ECPointJacobian{B}, p2::ECPointLD{B}) where BReturns $p_1 +p_2$ in Lopez-Dahab coordinates.
Base.convert — Methodconvert(::Type{ECPointAffine}, p::ECPointJacobian{B}) where BConverts a point from Jacobian coordinates to affine coordinates.
Base.convert — Methodconvert(::Type{ECPointAffine}, p::ECPointLD{B}) where BConverts a point from Lopez-Dahab coordinates to affine coordinates.
Base.convert — Methodconvert(::Type{ECPointJacobian}, p::ECPointAffine{B}) where BConverts a point from affine coordinates to Jacobian coordinates.
Base.convert — Methodconvert(::Type{ECPointJacobian}, p::ECPointLD{B}) where BConverts a point from Lopez-Dahab coordinates to Jacobian coordinates.
Base.convert — Methodconvert(::Type{ECPointLD}, p::ECPointAffine{B}) where BConverts a point from affine coordinates to Lopez-Dahab coordinates.
Base.convert — Methodconvert(::Type{ECPointLD}, p::ECPointJacobian{B}) where BConverts a point from Jacobian coordinates to Lopez-Dahab coordinates.
Miscellaneous Point Functions
BinaryECC.ECPointAffine — MethodECPointAffine(s::String, ec::EC{B}) where BConvert a hex string to a point on the given elliptic curve using the procedure in SEC 2 (version 2), section 2.3.4.
Base.isvalid — Methodisvalid(p::ECPointAffine)Returns true if p is a point on the elliptic curve that it is associated with.
Base.repr — Methodrepr(p::ECPointAffine)Returns a string representation of an elliptic curve point, i.e. "$(x, y)$".
Base.repr — Methodrepr(p::ECPointJacobian)Returns a string representation of an elliptic curve point, "$(x, y, z)$".
Base.repr — Methodrepr(p::ECPointLD)Returns a string representation of an elliptic curve point, "$(x, y, z)$".
BinaryECC.naf — Functionnaf(k::T) where T<:IntegerComputes the binary NAF of an integer k.
naf(k::Integer, w::Int)Computes the width-w NAF of integer k.