decryptWithViewing()
SIP Protocol API Reference v0.7.0
SIP Protocol API Reference / decryptWithViewing
Function: decryptWithViewing()
Section titled “Function: decryptWithViewing()”decryptWithViewing(
encrypted,viewingKey):TransactionData
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:3283
Decrypt transaction data with viewing key
Performs authenticated decryption using XChaCha20-Poly1305. The authentication tag is verified before returning data.
Parameters
Section titled “Parameters”encrypted
Section titled “encrypted”EncryptedTransaction
Encrypted transaction data
viewingKey
Section titled “viewingKey”Viewing key for decryption
Returns
Section titled “Returns”Decrypted transaction data
Throws
Section titled “Throws”If decryption fails (wrong key, tampered data, etc.)
Example
Section titled “Example”try { const data = decryptWithViewing(encrypted, viewingKey) console.log(`Amount: ${data.amount}`)} catch (e) { console.error('Decryption failed - wrong key or tampered data')}