Skip to main content

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 designed to run anywhere modern JavaScript runs. The library has been tested and confirmed working on Node.js, Bun, Deno, all major modern browsers, and React Native. The same encrypt / decrypt API works identically across all platforms — only the setup steps differ slightly per environment.

Platform support

PlatformStatusMinimum Version
Node.js✅ Fully supported16
Bun✅ Fully supported1
Deno✅ Supported (see notes)2
Browser✅ Fully supportedmodern
React Native✅ Supported (see notes)

Node.js

Node.js 16 and later are fully supported with no extra configuration. The library automatically uses node:crypto’s native AES-256-GCM implementation when it is available, giving you hardware-accelerated symmetric encryption with no code changes. Install the package and run your script as you would any ESM package:
npm install @ecies/post-quantum
node main.js
A complete working example taken directly from the repository:
// example/runtime/main.js
import { DEFAULT_CONFIG, decrypt, encrypt } from "@ecies/post-quantum";

const encoder = new TextEncoder();
const decoder = new TextDecoder();
const msg = encoder.encode("hello world🌍");

const { secretKey, publicKey } = DEFAULT_CONFIG.asymmetricModule.keygen();
const encrypted = encrypt(publicKey, msg);
const decrypted = decrypt(secretKey, encrypted);

console.log(decoder.decode(decrypted));

Bun

Bun works identically to Node.js. Install with bun add @ecies/post-quantum and run with bun main.js. The same example code used for Node.js runs unchanged.
bun add @ecies/post-quantum
bun main.js

Deno

Deno 2 and later are supported. Because of how Deno resolves Node.js compatibility conditions, you need to pass an extra flag when running scripts that depend on this library.
deno run --conditions deno main.js
The runtime code itself is identical to the Node.js example — no Deno-specific imports or shims are required.

Browser

The library is fully browser-compatible and relies on the Web Crypto API, which is available in all modern browsers. There are no Node.js-specific APIs in the hot path for browser builds. You can try an interactive demo at post-quantum-demo.ecies.org. Bundlers including Vite, webpack, and esbuild are all supported. Install and import the package as usual:
npm install @ecies/post-quantum
import { DEFAULT_CONFIG, decrypt, encrypt } from "@ecies/post-quantum";

const { secretKey, publicKey } = DEFAULT_CONFIG.asymmetricModule.keygen();
const encoder = new TextEncoder();

const encrypted = encrypt(publicKey, encoder.encode("secret message"));
const decrypted = decrypt(secretKey, encrypted);
The browser example in the repository uses XChaCha20-Poly1305, which is a good choice for browser environments on devices without hardware AES acceleration:
import { DEFAULT_CONFIG, decrypt, encrypt } from "@ecies/post-quantum";

// Switch to XChaCha20-Poly1305 for the browser demo
DEFAULT_CONFIG.symmetricAlgorithm = "xchacha20";

const { secretKey, publicKey } = DEFAULT_CONFIG.asymmetricModule.keygen();

React Native

React Native is supported, but you must polyfill crypto.getRandomValues because the standard React Native environment does not expose it. The react-native-get-random-values package provides this polyfill.
npm install react-native-get-random-values
Import the polyfill at the very top of your entry file, before any import from @ecies/post-quantum:
import 'react-native-get-random-values';
import { encrypt, decrypt } from '@ecies/post-quantum';
The react-native-get-random-values import must come first. If @ecies/post-quantum is evaluated before the polyfill is in place, random byte generation will fail at runtime.

Native crypto acceleration

Via @ecies/ciphers, the library automatically selects node:crypto’s native AES-256-GCM implementation on Node.js and Bun when it is available, falling back transparently to the pure-JavaScript implementation from @noble/ciphers on platforms where node:crypto is not present (browsers, React Native). No configuration is required — the right implementation is chosen at runtime.

Build docs developers (and LLMs) love