Curves

CryptoGroups.Curves.AbstractPointType
abstract type AbstractPoint end

An elliptic curve interface type. It is not expected that constructor of the group does instance validation and hence is unsafe. For safe use see ECPoint. The elliptic curve interface expects *, +, -, gx, gy and zero element to be implemented wheras the order and cofactor methods are added with the ECPoint subtype. In addition oncurve method is expected when used in combination with ECPoint.

It is expected that a point::AbstractPoint can be constructed back from it's coordinates and also from their octet representations:

P = typeof(point)
x, y = gx(point), gy(point)
point == P(x, y) == P(octet(x), octet(y))

Point compression is automatically supported through using octet on gx(point) and gy(point). For point decompression from a compressed octet the user must implement a constructor for the point type P(x::Vector{UInt8}, ỹ::Bool) or a direct method P(po::Vector{UInt8}).

source
CryptoGroups.Curves.AffinePointType
struct AffinePoint{E <: EllipticCurve, T <: Field} <: AbstractPoint
    x::T
    y::T
end

Affine represantion of elliptic curve point. (Alternative represnations are Jacobi and projective coordinates which are currently unimplemented.) Operations *, + and - are unsafe and hence this type shall not be used outside ECPoint wrapping. See also AbstractPoint for supported methods.

source
CryptoGroups.Curves.ECPointType
struct ECPoint{P<:AbstractPoint, S} <: AbstractPoint
    p::P
end

A wrapper type for elliptic curve points ensuring their safe use. The constructor validates that the point is on the curve and that it is not in cofactor subgroup. This check can be bypassed by specializing on validate method. Also adds safety checks when doing a point summation in case when points are equal, inverse of each other and treats zero properly.

In addition to AbstractPoint methods *, +, -, gx, gy and zero, ECPoint implements order, cofactor

source
Base.remMethod
rem(p::AbstractPoint, q::T)::T where T <: Integer

Computes a remainder of point x coordinate for a modulus q. The output is such that DSA and ECDSA of FIPS 186-4 standart can be combined into single imlementation

source
Base.zeroMethod
zero(::Union{P, Type{P}}) where P <: AbstractPoint

Constructs a zero element representation of a point type. Implementation of arithmetic can be delegated to ECPoint wrapper that treats the cases safely.

source
CryptoGroups.concretize_typeMethod
concretize_type(::Type{ECPoint{P}}, order::Integer, cofactor::Integer; name=nothing) where P <: AbstractPoint

Constructs an ECPoint for a concrete point type P <: AbstractPoint with specified order and cofactor. The name is used for aliasing group parameters with @ECPoint{name} display semantics.

source
CryptoGroups.orderMethod
order(::Union{P, Type{P}}) where P <: ECPoint

Gets an order of a point type or instance.

source