Secp256k1.jl

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

Buy me a cup of coffee

Donate Bitcoin

Index