BRC-78 message encryption and decryption.
Wire format:
version (4 bytes) || sender_pubkey (33 bytes) || recipient_pubkey (33 bytes) || key_id (32 bytes) || ciphertext
See: https://github.com/bitcoin-sv/BRCs/blob/master/peer-to-peer/0078.md
Migration Notice (v0.2)
The symmetric key derivation was changed from raw ECDH x-coordinate to
SHA-256(x-coordinate) for improved security. Decryption automatically
falls back to the legacy derivation if the new key fails, ensuring
backward compatibility with messages encrypted by v0.1.
New encryptions always use the secure SHA-256 derivation.
Summary
Functions
Decrypt a BRC-78 encrypted message using the recipient's private key.
Encrypt a message using the sender's private key and the recipient's public key.
Functions
@spec decrypt(binary(), BSV.PrivateKey.t()) :: {:ok, binary()} | {:error, String.t()}
Decrypt a BRC-78 encrypted message using the recipient's private key.
@spec encrypt(binary(), BSV.PrivateKey.t(), BSV.PublicKey.t()) :: {:ok, binary()} | {:error, String.t()}
Encrypt a message using the sender's private key and the recipient's public key.