Skip to main content
ChaCha20Poly1305 implements RFC 8439 authenticated encryption (ChaCha20 stream cipher + Poly1305 MAC) backed by @noble/ciphers/chacha.js. Unlike AesGcm, every operation is synchronous, takes a raw 32-byte Uint8Array key, and runs in constant time without hardware AES instructions.

Encryption Pipeline

Quick Start

API Reference

All functions are exported on ChaCha20Poly1305 and as named exports from @tevm/voltaire/ChaCha20Poly1305.

Constants

Errors and Security Invariants

Never reuse a (key, nonce) pair. Reusing a nonce reveals the XOR of plaintexts and leaks the one-time Poly1305 key, allowing an attacker to forge tags on arbitrary messages.
  • Error types: Invalid key length throws InvalidKeyError; invalid nonce length throws InvalidNonceError; authentication failure or truncated ciphertext throws DecryptionError; unexpected errors throw ChaCha20Poly1305Error.
  • Constant-time ARX design: ChaCha20 uses only 32-bit addition, rotation, and XOR (no S-box lookup tables), eliminating cache-timing channels on platforms without AES-NI.
  • Message limit: RFC 8439 uses a 32-bit block counter, limiting a single message to 2^32 - 1 64-byte blocks (~256 GiB). Rotate keys before 2^32 random-nonce messages.