BSV.KeyPair (bsv_sdk v1.5.0)

Copy Markdown View Source

Convenience struct pairing a BSV.PrivateKey with its corresponding BSV.PublicKey.

Example

kp = BSV.KeyPair.new()
kp.privkey  #=> %BSV.PrivateKey{...}
kp.pubkey   #=> %BSV.PublicKey{...}

# From an existing private key
kp = BSV.KeyPair.from_private_key(privkey)

Summary

Functions

Build a key pair from an existing private key.

Generate a new random key pair.

Return the compressed public key bytes (33 bytes).

Return the 20-byte public key hash (HASH160).

Types

t()

@type t() :: %BSV.KeyPair{privkey: BSV.PrivateKey.t(), pubkey: BSV.PublicKey.t()}

Functions

from_private_key(privkey)

@spec from_private_key(BSV.PrivateKey.t()) :: t()

Build a key pair from an existing private key.

new()

@spec new() :: t()

Generate a new random key pair.

pubkey_bytes(key_pair)

@spec pubkey_bytes(t()) :: binary()

Return the compressed public key bytes (33 bytes).

pubkey_hash(kp)

@spec pubkey_hash(t()) :: <<_::160>>

Return the 20-byte public key hash (HASH160).