Module BSV::Primitives::SignedMessage ¶
BRC-77 signed messages.
Provides authenticated messaging using BRC-42 derived signing keys. The sender proves their identity to a specific recipient (or anyone) without encrypting the message content.
- @see
https://github.com/bitcoin-sv/BRCs/blob/master/peer-to-peer/0077.md
@example Sign and verify for a specific recipient
sig = SignedMessage.sign(message, sender_priv, recipient_pub)
SignedMessage.verify(message, sig, recipient_priv) #=> true
@example Sign for anyone to verify
Constants¶
VERSION ¶
Protocol version bytes: "BB3x01"
Public Class Methods¶
sign(message, signer, verifier = nil) ¶
Sign a message using the BRC-77 protocol. - @param message [String] the message to sign - @param signer [PrivateKey] the sender's private key - @param verifier [PublicKey, nil] the recipient's public key (nil for anyone-can-verify) - @return [String] binary signed message (version + keys + key_id + DER signature)
verify(message, sig, recipient = nil) ¶
Verify a BRC-77 signed message. - @param message [String] the original message - @param sig [String] the binary signature (from {.sign}) - @param recipient [PrivateKey, nil] the recipient's private key (nil for anyone-can-verify) - @raise [ArgumentError] if the version is wrong, recipient is required but missing, or recipient doesn't match - @return [Boolean] true if the signature is valid