BSV.Message.Signed (bsv_sdk v1.1.0)

Copy Markdown View Source

BRC-77 message signing and verification.

Wire format: version (4 bytes) || sender_pubkey (33 bytes) || verifier (1 or 33 bytes) || key_id (32 bytes) || signature_der

For "anyone" verification, verifier is a single 0x00 byte. For specific-recipient verification, verifier is the 33-byte compressed public key.

See: https://github.com/bitcoin-sv/BRCs/blob/master/peer-to-peer/0077.md

Summary

Functions

Sign a message. If verifier is nil, anyone can verify the signature.

Verify a signed message. For "anyone" signatures, pass nil as recipient. For specific-recipient signatures, pass the recipient's private key.

Functions

sign(message, signer, verifier \\ nil)

@spec sign(binary(), BSV.PrivateKey.t(), BSV.PublicKey.t() | nil) ::
  {:ok, binary()} | {:error, String.t()}

Sign a message. If verifier is nil, anyone can verify the signature.

verify(message, sig, recipient \\ nil)

@spec verify(binary(), binary(), BSV.PrivateKey.t() | nil) ::
  {:ok, boolean()} | {:error, String.t()}

Verify a signed message. For "anyone" signatures, pass nil as recipient. For specific-recipient signatures, pass the recipient's private key.