Cryptographic Primitives
Prime Order Fields
BinaryECC.PFieldElt — TypePFieldEltRepresents an element of a prime order field, with the named field value::BigInt holding the element itself, and p::BigInt holding the field order.
Supports all standard arithmetic operations, such as ==, +, -, *, /, inv, ^, isone, iszero, one, zero, isvalid.
Curve Domain Parameters
BinaryECC.CurveDomainParams — TypeCurveDomainParams{B}Represents the elliptic curve domain parameters for elliptic curve groups defined over binary field B, as described in SEC 1 (version 2), 3.1.2.
It contains three fields:
G::ECPointAffine{B}, a generating point, in affine coordinatesn::BigInt, the order ofG(i.e. the smallestnsatisfying $G \cdot n = \mathcal{O}$)h::BigInt, the cofactor, $h = \#E(\mathbb{F}_{2^m}) / n$
The other elements of the septuple described in 3.1.2 are accessible through the fields of G.
Several standard curves domain parameters (taken from SEC 2, section 3) can be created by calling the following functions with a word type T:
SECT163K1(T::Type{U}) where U<:UnsignedSECT163R1(T::Type{U}) where U<:UnsignedSECT233K1(T::Type{U}) where U<:UnsignedSECT233R1(T::Type{U}) where U<:UnsignedSECT283K1(T::Type{U}) where U<:UnsignedSECT283R1(T::Type{U}) where U<:UnsignedSECT409K1(T::Type{U}) where U<:UnsignedSECT409R1(T::Type{U}) where U<:UnsignedSECT571K1(T::Type{U}) where U<:UnsignedSECT571R1(T::Type{U}) where U<:Unsigned
Base.isvalid — Methodisvalid(T::CurveDomainParams{B}, t::Int) where BReturns true if the curve domain parameters $T$ meet the security level $t$, using the procedure in SEC 1 (version 2) 3.1.2.2.1, and false otherwise.
Note: does not currently perform step 6 (checking that $n$ is prime).
Elliptic Curve Key Pairs
BinaryECC.ECKeyPair — TypeECKeyPair{B}Represents an elliptic curve key pair (described in SEC 1, version 2, 3.2) with fields $d$ and $Q$ (where $Q = d \cdot G$, and $G$ is the generator of the curve domain paramters used to generate this key pair). Contains named fields d::PFieldElt and Q::ECPointAffine{B}.
BinaryECC.generate_keypair — Methodgenerate_keypair(T::CurveDomainParams{B}) where BGnerates a new random ECKeyPair associated with T, as described in SEC 1 (version 2) 3.2.1.
Base.isvalid — Methodisvalid(T::CurveDomainParams{B}, Q::ECPointAffine{B}) where BReturns true if Q is a valid public key associated with the curve domain parameters T, using the procedure in SEC 1 (version 2) 3.2.2.1, and false otherwise.
ECDSA
BinaryECC.ECDSASignature — TypeECDSASignatureRepresents a signature produced by ECDSA (Elliptic Curve DSA), with the fields r::PFieldElt and s::PFieldElt.
BinaryECC.ecdsa_sign — Methodecdsa_sign(T::CurveDomainParams{B}, U::ECKeyPair{B}, M::String) where BCreates an ECDSASignature using the key pair U (associated with the curve domain parameters T) for the message M.
This follows the signing procedure described in SEC 1 (version 2) 4.1.3.
BinaryECC.ecdsa_verify — Methodecdsa_verify(T::CurveDomainParams{B}, Q::ECPointAffine{B}, sig::ECDSASignature, M::String) where BReturns true if sig is valid signature for message M and public key Q (associated with curve domain parameters T), following the verifying operation described in SEC 1 (version 2) 4.1.4, and false otherwise.
ECDH
BinaryECC.ecdh_calculate — Methodecdh_calculate(T::CurveDomainParams{B}, dU::PFieldElt, QV::ECPointAffine{B}) where BCalculates the shared secret value for entity "U"'s private key ({dU) and entity "V"'s public key (QV), which are associated with curve domain parameters T.
This follows the procedure described in SEC 1 (version 2) 3.3.1.
BinaryECC.ecdh_deployment1 — Methodecdh_deployment1(T::CurveDomainParams)Performs the first stage of the ECDH deployment operation (described in SEC 1, version 2, 6.1.2) from the perspective of entity "U".
BinaryECC.ecdh_deployment2 — Methodecdh_deployment2(T::CurveDomainParams{B}, QV::ECPointAffine{B}) where BPerforms the second stage of the ECDH deployment operation (described in SEC 1, version 2, 6.1.2) from the perspective of entity "U", using entity "V"'s public key (QV).
BinaryECC.ecdh_agreement — Methodecdh_agreement(T::CurveDomainParams{B}, ukey::ECKeyPair{B}, QV::ECPointAffine{B}) where BThis performs the ECDH key agreement operation as described in SEC 1 (version 2) 6.1.3.
It is performed from the perspective of entity "U", using their ECKeyPair ukey and the public key of entity "V" (QV).