decrypt

fun decrypt(payload: Nip44CipherText, conversationKey: ByteArray): String

Decrypts a NIP-44 encrypted message.

Decrypts the message with the following steps:

  1. Derives message keys from conversation key and payload nonce

  2. Verifies HMAC-SHA256 using constant-time comparison

  3. Decrypts ciphertext with ChaCha20

  4. Removes NIP-44 padding

  5. Securely clears derived keys from memory

Return

The decrypted plaintext message

Parameters

payload

The encrypted message payload

conversationKey

The 32-byte conversation key

Throws

if MAC verification fails, padding is invalid, or keys are wrong size