BSV.Tokens.SigningKey (bsv_sdk v1.4.0)

Copy Markdown View Source

Signing credentials for a UTXO — either a single key (P2PKH) or threshold keys with a multisig script (P2MPKH).

Variants

{:single, PrivateKey.t()}
{:multi, [PrivateKey.t()], P2MPKH.multisig_script()}

Examples

# P2PKH signing
signing_key = SigningKey.single(private_key)

# 2-of-3 P2MPKH signing
{:ok, ms} = P2MPKH.new_multisig(2, [pk1, pk2, pk3])
signing_key = SigningKey.multi([key1, key2], ms)

Summary

Functions

Compute the 20-byte hash for this signing key.

Create a P2MPKH signing key.

Returns true if this is a P2MPKH signing key.

Create a P2PKH signing key.

Wrap a PrivateKey as a signing key (convenience for migration).

Types

t()

@type t() ::
  {:single, BSV.PrivateKey.t()}
  | {:multi, [BSV.PrivateKey.t()], BSV.Transaction.P2MPKH.multisig_script()}

Functions

hash160(arg)

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

Compute the 20-byte hash for this signing key.

  • P2PKH: HASH160 of compressed public key
  • P2MPKH: HASH160 of serialized multisig script (the MPKH)

multi(private_keys, multisig)

Create a P2MPKH signing key.

multi?(arg1)

@spec multi?(t()) :: boolean()

Returns true if this is a P2MPKH signing key.

single(key)

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

Create a P2PKH signing key.

wrap(key)

@spec wrap(BSV.PrivateKey.t() | t()) :: t()

Wrap a PrivateKey as a signing key (convenience for migration).

Accepts either a PrivateKey struct or an existing SigningKey tuple.