Secp256k1.jl
Julia library for EC operations on curve secp256k1.
Types
Secp256k1.Point
โ Type.Point{T<:xField}
Point{T<:xField}(๐ฅ::T, ๐ฆ::T)
represents a point in an scep256k1 field. xField
is equal to Union{FieldElement, Infinity}
Secp256k1.KeyPair
โ Type.KeyPair{T}(๐::BigInt, ๐::Point)
represents a private-public key pair in which
๐
is the secret key๐
the public key
= T
represents key pair scheme
KeyPair{:ECDSA}(๐::Integer)
instantiate a KeyPair
such as ๐ = ๐๐บ and where
- {๐ โ โค | ๐ < ๐}
- ๐บ is the secp256k1 base point.
- ๐ is the order of ๐บ
Secp256k1.Signature
โ Type.Signature{T}(๐::BigInt, ๐ ::BigInt) represents a following scheme T
T
can be set to:ECDSA
Functions
Secp256k1.serialize
โ Method.serialize(P::Point; compressed::Bool) -> Vector{UInt8}
Serialize a Point
to its SEC format
compressed=true
by default
Secp256k1.Point
โ Method.Point(io::IOBuffer) -> Point
Parse a SEC binary to an Point
Secp256k1.serialize
โ Method.serialize(x::Signature) -> Vector{UInt8}
Serialize a Signature
to DER format
Secp256k1.Signature
โ Method.Signature(x::Vector{UInt8}; scheme::Symbol) -> Signature
Parse a DER binary to a Signature{scheme}
scheme
is optional and set to:ECDSA
by default.
Secp256k1.ECDSA.sign
โ Function.ECDSA.sign(kp::KeyPair{:ECDSA}, ๐ง::Integer) -> Signature{:ECDSA}
Returns a Signature{:ECDSA} for a given KeyPair{:ECDSA}
and data ๐ง
and in which ๐ = (๐ง + ๐๐) / ๐, ๐ being a random integer.
Secp256k1.ECDSA.verify
โ Function.verify(๐::Point, ๐ง::Integer, sig::Signature{:ECDSA}) -> Bool
Returns true if Signature{:ECDSA} is valid for ๐ง given ๐, false if not