Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ecies/js-post-quantum/llms.txt
Use this file to discover all available pages before exploring further.
@ecies/post-quantum is a TypeScript library that brings post-quantum cryptography to your application. It replaces the elliptic-curve key exchange in classic ECIES with ML-KEM (Module-Lattice Key Encapsulation Mechanism, NIST FIPS 203), making your encrypted messages resistant to attacks from quantum computers — while keeping the familiar encrypt / decrypt API simple enough to use in minutes.
Installation
Install via npm, pnpm, yarn, or bun and get the package into your project.
Quickstart
Generate a key pair and encrypt your first message in under a minute.
Configuration
Choose your ML-KEM variant and symmetric cipher to match your security needs.
API Reference
Full type signatures for
encrypt, decrypt, and the Config class.Why post-quantum?
Classical public-key cryptography (RSA, ECC) is vulnerable to Shor’s algorithm running on a sufficiently powerful quantum computer. ML-KEM is a lattice-based key encapsulation mechanism standardised by NIST that is believed to be secure against both classical and quantum adversaries.@ecies/post-quantum uses ML-KEM purely for key encapsulation — the resulting shared secret is then fed into a fast, authenticated symmetric cipher (AES-256-GCM or XChaCha20-Poly1305) to encrypt the actual payload.
Key features
Three security levels
ML-KEM-512, ML-KEM-768 (NIST recommended default), and ML-KEM-1024 — choose the right trade-off between speed and security margin.
Two AEAD ciphers
AES-256-GCM with native acceleration or XChaCha20-Poly1305 for environments where constant-time guarantees matter more.
Universal runtime support
Works on Node.js ≥16, Bun, Deno, all modern browsers, and React Native out of the box.
Native crypto fallbacks
Delegates to
node:crypto when available via @ecies/ciphers, falling back to pure-JS implementations automatically.Quick example
Install the package
Add
@ecies/post-quantum to your project with your preferred package manager. See Installation for all options.Generate a key pair
Call
DEFAULT_CONFIG.asymmetricModule.keygen() to produce a { publicKey, secretKey } pair using ML-KEM-768.Encrypt and decrypt
Pass the public key to
encrypt() and the secret key to decrypt(). Both functions accept and return raw Uint8Array buffers.Tune the configuration
Optionally create a custom
Config to pick a different ML-KEM variant or swap the symmetric cipher. See Configuration.