Blockchain Commons Crypto TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Function aeadChaCha20Poly1305Encrypt

    • Encrypt data using ChaCha20-Poly1305 AEAD cipher.

      Security Warning: The nonce MUST be unique for every encryption operation with the same key. Reusing a nonce completely breaks the security of the encryption scheme and can reveal plaintext.

      Parameters

      • plaintext: Uint8Array

        The data to encrypt

      • key: Uint8Array

        32-byte encryption key

      • nonce: Uint8Array

        12-byte nonce (MUST be unique per encryption with the same key)

      Returns [Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>]

      Tuple of [ciphertext, authTag] where authTag is 16 bytes

      If key is not 32 bytes or nonce is not 12 bytes