encryptForViewing()
SIP Protocol API Reference v0.7.0
SIP Protocol API Reference / encryptForViewing
Function: encryptForViewing()
Section titled “Function: encryptForViewing()”encryptForViewing(
data,viewingKey):EncryptedTransaction
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:3261
Encrypt transaction data for viewing key holders
Uses XChaCha20-Poly1305 authenticated encryption with:
- 24-byte random nonce (nonce-misuse resistant)
- HKDF-derived encryption key
- 16-byte authentication tag (included in ciphertext)
Parameters
Section titled “Parameters”Transaction data to encrypt
viewingKey
Section titled “viewingKey”Viewing key for encryption
Returns
Section titled “Returns”EncryptedTransaction
Encrypted transaction with nonce and key hash
Example
Section titled “Example”const encrypted = encryptForViewing( { sender: '0x...', recipient: '0x...', amount: '100', timestamp: 123 }, viewingKey)// encrypted.ciphertext contains the encrypted data// encrypted.nonce is needed for decryption// encrypted.viewingKeyHash identifies which key can decrypt