Curves
CryptoGroups.Curves.AbstractPoint
— Typeabstract 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})
.
CryptoGroups.Curves.AffinePoint
— Typestruct 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.
CryptoGroups.Curves.ECPoint
— Typestruct 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
Base.rem
— Methodrem(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
Base.zero
— Methodzero(::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.
CryptoGroups.Curves.cofactor
— Methodcofactor(::Union{P, Type{P}}) where P <: ECPoint
Gets a cofactor of a point type or instance.
CryptoGroups.Curves.gx
— Methodgx(p::AbstractPoint)::Field
Returns x
coordinate of a point instance. See also gy
, value
, octet
.
CryptoGroups.Curves.gy
— Methodgy(p::AbstractPoint)::Field
Returns y
coordinate of a point instance. See also gx
, value
, octet
.
CryptoGroups.Curves.oncurve
— Methodoncurve(p::AbstractPoint)::Bool
Checks if a point coordinates satisfy elliptic curve equation.
CryptoGroups.concretize_type
— Methodconcretize_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.
CryptoGroups.order
— Methodorder(::Union{P, Type{P}}) where P <: ECPoint
Gets an order of a point type or instance.