npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stenvault/pqc-wasm

v0.4.1

Published

ML-KEM-768/1024 + ML-DSA-65/87 WASM wrapper — RustCrypto compiled to WebAssembly

Readme

@stenvault/pqc-wasm

Post-quantum cryptography WASM wrapper for StenVault — ML-KEM-768 and ML-KEM-1024 (FIPS 203), ML-DSA-65 and ML-DSA-87 (FIPS 204), compiled from RustCrypto crates to WebAssembly.

Why

Replaces @openforge-sh/liboqs, an unofficial wrapper of the liboqs C library, with a self-maintained Rust→WASM build of the RustCrypto ml-kem and ml-dsa crates.

RustCrypto writes these crates to run in constant time, with ctutils for selections and comparisons. Neither WebAssembly nor a JavaScript engine guarantees that compiled code keeps that property, and this package has not verified it on the final .wasm. npm run test:timing checks total running time statistically; see Security for what it does not cover.

Build

Requires Rust toolchain with wasm32-unknown-unknown target and wasm-pack:

rustup target add wasm32-unknown-unknown
cargo install wasm-pack

# Build both targets
wasm-pack build --target bundler --release --out-dir pkg-bundler
wasm-pack build --target nodejs  --release --out-dir pkg-nodejs

Test

cargo test                 # Rust unit tests (native target)
npm test                   # copies of secrets in the JS layer (fake bindings), then interop, FIPS 203 input checks, Wycheproof vectors and memory wiping against the pkg-nodejs build
npm run test:fips203-scan  # every single-byte change of one public key per ML-KEM parameter set, checked against noble
npm run test:timing        # dudect-style timing test of decapsulation and signing, not part of npm test

The Kani proofs in proofs/ (CI, on pull requests and main) check that the key and ciphertext types have the sizes the wrapper converts into, that ML-DSA verifying keys and signatures one byte short are rejected, and that two 32-byte seed conversions cannot panic. They prove nothing about the cryptography or its timing. Key and ciphertext decoding is fuzzed instead, by the cargo-fuzz targets in fuzz/ (ML-KEM-768 and ML-DSA-65). The global allocator, the crate's only unsafe code, is tested under Miri in CI.

The FIPS 203 tests draw their samples from a seed that is printed in the output. FIPS203_SEED=<n> npm test replays a run.

API

import {
  generateKemKeyPair,
  encapsulate,
  decapsulate,
  generateSignatureKeyPair,
  sign,
  verify,
} from '@stenvault/pqc-wasm'

// ML-KEM-768
const kp = await generateKemKeyPair()
// kp.publicKey: Uint8Array (1,184 bytes)
// kp.secretKey: Uint8Array (2,400 bytes)

const { ciphertext, sharedSecret } = await encapsulate(kp.publicKey)
const decrypted = await decapsulate(ciphertext, kp.secretKey)
// sharedSecret === decrypted (32 bytes)

// ML-DSA-65
const sigKp = await generateSignatureKeyPair()
// sigKp.publicKey: Uint8Array (1,952 bytes)
// sigKp.secretKey: Uint8Array (32 bytes, FIPS 204 seed)

const signature = await sign(message, sigKp.secretKey)
// signature: Uint8Array (3,309 bytes)

const valid = await verify(message, signature, sigKp.publicKey)

Every parameter set is also an object with the same methods, so moving to another security level means passing another object. The top-level functions above are ML-KEM-768 and ML-DSA-65.

import { mlKem768, mlKem1024, mlDsa65, mlDsa87, type Kem, type SignatureScheme } from '@stenvault/pqc-wasm'

const kem: Kem = mlKem1024
const kp = await kem.generateKeyPair()
const { ciphertext, sharedSecret } = await kem.encapsulate(kp.publicKey)
const decrypted = await kem.decapsulate(ciphertext, kp.secretKey)

const dsa: SignatureScheme = mlDsa87
const sigKp = await dsa.generateKeyPair()
const signature = await dsa.sign(message, sigKp.secretKey)
const valid = await dsa.verify(message, signature, sigKp.publicKey)

A key belongs to one parameter set: an ML-KEM-768 key passed to mlKem1024 fails its length check, and the same holds for ML-DSA.

ML-KEM input errors

encapsulate and decapsulate reject (the promise throws) on malformed keys. The lengths are those of the parameter set (see Key sizes); the messages below are ML-KEM-768's.

| Function | Message | Cause | |----------|---------|-------| | encapsulate | invalid encapsulation key length: expected 1184 bytes | wrong length | | encapsulate | encapsulation key is not canonical | a 12-bit coefficient of the public key, all but its last 32 bytes, is ≥ 3329 (FIPS 203 §7.2) | | decapsulate | invalid decapsulation key length: expected 2400 bytes | wrong length | | decapsulate | invalid ciphertext length: expected 1088 bytes | wrong length | | decapsulate | decapsulation key hash check failed | SHA3-256 of the public key inside secretKey differs from the hash stored after it (FIPS 203 §7.3) | | decapsulate | decapsulation key embeds a non-canonical encapsulation key | the hash matches, but a 12-bit coefficient of the public key inside secretKey is ≥ 3329 (the §7.2 check, applied to that key); key generation never produces such a key |

A corrupted ciphertext does not throw. decapsulate returns ML-KEM's implicit-rejection secret, which does not match the sender's.

Architecture

Consumer (StenVault)
    ↓ imports from "@stenvault/pqc-wasm"
index.browser.ts / index.node.ts   ← ensurePqcInit() + re-export
    ↓
core.ts                             ← free() in try/finally, param order normalization, each getter read once and returned as is
    ↓
pkg-bundler/ or pkg-nodejs/         ← wasm-bindgen generated bindings
    ↓
src/lib.rs                          ← 12 exported Rust functions, memory wiped after each call
    ↓
ml-kem + ml-dsa (RustCrypto)        ← FIPS 203/204 implementations

The consumer never calls free(), never calls init(), and never imports from pkg-* directly. The exports field in package.json routes browser to pkg-bundler and node/default to pkg-nodejs automatically.

Key sizes (FIPS)

| Algorithm | Public Key | Secret Key | Ciphertext | Signature | Shared Secret | |-----------|-----------|-----------|-----------|----------|--------------| | ML-KEM-768 | 1,184 B | 2,400 B | 1,088 B | — | 32 B | | ML-KEM-1024 | 1,568 B | 3,168 B | 1,568 B | — | 32 B | | ML-DSA-65 | 1,952 B | 32 B (seed) | — | 3,309 B | — | | ML-DSA-87 | 2,592 B | 32 B (seed) | — | 4,627 B | — |

Security

  • Constant time: RustCrypto writes ml-kem and ml-dsa to run in constant time, with ctutils. Whether the compiled .wasm keeps that is not verified (see SECURITY.md, Known Limitations). npm run test:timing finds no timing difference between valid and invalid ciphertexts in decapsulation, or between seeds in signing, in Node 24.
  • Memory wiping: every heap block is zeroed before it is freed, and each operation then overwrites the part of the stack it used, so no secret key, seed or shared secret is left in the module's memory after a call. tests/memory.ts scans the memory after every operation. Each secret leaves the module's memory once, as the Uint8Array returned to the caller, and the package keeps no other copy (tests/core.ts): that array is the one to overwrite with fill(0) when done. This keeps the copies down but is not a full guarantee: the JavaScript engine's garbage collector and JIT may copy the bytes where no code can reach them. In V8, for example, small arrays such as 32-byte secrets live inside the JavaScript heap, which the garbage collector moves.
  • FIPS 203 input checks: encapsulate runs the §7.2 modulus check; decapsulate runs the §7.3 hash check, then the §7.2 check on the public key inside the secret key. ml-kem 0.3 runs the same checks; this package runs its own first, so the errors do not depend on the crate.
  • No audit: Neither RustCrypto nor this wrapper have been independently audited.
  • CVE-2026-22705: Timing side-channel in ml-dsa Decompose function, patched in >= 0.1.0-rc.3 (Barrett reduction).
  • CVE-2026-24850: Signature malleability via duplicate hint indices in ml-dsa, patched in >= 0.1.0-rc.4.
  • GHSA-h37v-hp6w-2pp8: Off-by-two in ml-dsa use_hint when r0 = 0 (FIPS 204 Alg. 40 deviation), patched in >= 0.1.0-rc.5.
  • RUSTSEC-2026-0385: Non-constant-time mask generation and u128 comparisons in ctutils, which ml-dsa uses for constant-time selection, patched in ctutils >= 0.4.4 (this package: 0.3.1).
  • Cargo.toml requires ml-dsa >= 0.1.2, the first release that pulls a patched ctutils.
  • Cargo.toml requires ml-kem >= 0.3.4, which removed a secret-indexed table lookup from noise sampling and made the conditional subtraction mod q constant-time.
  • Hedged signing: sign uses FIPS 204's default, hedged variant: each signature mixes in 32 fresh bytes from crypto.getRandomValues, so two signatures of the same message differ. That keeps a fault or a side channel from being lined up across repeated signings. With those bytes pinned to zero it gives the deterministic variant, which the tests use to compare against known-answer vectors. If no randomness is available, sign throws instead of signing.
  • Supply chain: Cargo.lock committed, CI runs cargo audit before every build.

License

MIT