BSV.PubKey (BSV v2.1.0) View Source
A PubKey is a data structure representing a Bitcoin public key.
Internally, a public key is the x
and y
coordiantes of a point of the
secp256k1
curve. It is derived by performaing elliptic curve multiplication
on a corresponding private key.
Link to this section Summary
Functions
Parses the given binary into a BSV.PubKey.t/0
.
Parses the given binary into a BSV.PubKey.t/0
.
Returns a BSV.PubKey.t/0
derived from the given BSV.PrivKey.t/0
.
Serialises the given BSV.PrivKey.t/0
into a binary.
Link to this section Types
Specs
t() :: %BSV.PubKey{compressed: boolean(), point: Curvy.Point.t()}
Public key struct
Link to this section Functions
Specs
Parses the given binary into a BSV.PubKey.t/0
.
Returns the result in an :ok
/ :error
tuple pair.
Options
The accepted options are:
:encoding
- Optionally decode the binary with either the:base64
or:hex
encoding scheme.
Examples
iex> PubKey.from_binary("03f81f8c8b90f5ec06ee4245eab166e8af903fc73a6dd73636687ef027870abe39", encoding: :hex)
{:ok, %PubKey{
compressed: true,
point: %Curvy.Point{
x: 112229328714845468078961951285525025245993969218674417992740440691709714284089,
y: 691772308660403791193362590139379363593914935665750098177712560871566383255
}
}}
Specs
Parses the given binary into a BSV.PubKey.t/0
.
As from_binary/2
but returns the result or raises an exception.
Specs
from_privkey(BSV.PrivKey.t()) :: t()
Returns a BSV.PubKey.t/0
derived from the given BSV.PrivKey.t/0
.
Specs
Serialises the given BSV.PrivKey.t/0
into a binary.
Options
The accepted options are:
:encoding
- Optionally encode the binary with either the:base64
or:hex
encoding scheme.
Examples
iex> PubKey.to_binary(@pubkey, encoding: :hex)
"03f81f8c8b90f5ec06ee4245eab166e8af903fc73a6dd73636687ef027870abe39"