Crypto Wasm
    Preparing search index...

    Crypto Wasm

    crypto-wasm logo

    @sebastienrousseau/crypto-wasm

    Placeholder for a WebAssembly accelerator for crypto-lib: runtime detection and a loader for a caller-supplied module. No WebAssembly module ships yet; every operation runs in JavaScript.

    Build Coverage Registry Docs OpenSSF Scorecard License: Apache-2.0 OR MIT Node.js 22 or newer


    Getting started

    • Install — installation via pnpm, npm, or yarn
    • Requirements — runtime floor and environment prerequisites
    • Quick Start — minimal working usage sample

    The Crypto Service ecosystem

    Package reference

    Operational


    pnpm add @sebastienrousseau/crypto-wasm
    # or
    npm install @sebastienrousseau/crypto-wasm
    # or
    yarn add @sebastienrousseau/crypto-wasm

    Back to Top


    • Node.js: ^22.0.0 or >=24.0.0 (active and maintenance LTS releases)
    • Package Manager: pnpm >=9 (recommended) or npm >=10
    • TypeScript: >=5.0 (when compiling with TypeScript)

    Back to Top


    import {
    WasmAccelerator,
    isWasmSupported,
    } from "@sebastienrousseau/crypto-wasm";

    const accel = new WasmAccelerator();
    await accel.init();

    // Hash data -- uses WASM when available, JS fallback otherwise
    const digest = await accel.hash("sha256", new TextEncoder().encode("hello"));
    console.log(Buffer.from(digest).toString("hex"));

    Back to Top


    Crypto Service provides a complete cryptography stack across 14 specialized packages:

    Package Role Description
    @sebastienrousseau/crypto-api API docs Postman collection types and a Postman-to-Markdown converter; the server's API contract is its OpenAPI document.
    @sebastienrousseau/crypto-benchmarks Benchmarks Benchmarks comparing classical and post-quantum cryptography: ops/sec, latency and throughput.
    @sebastienrousseau/crypto-cbom CBOM Cryptographic Bill of Materials generator and auditor (CycloneDX 1.6, SPDX 3.0).
    @sebastienrousseau/crypto-cli Terminal CLI Command-line interface: hashing, key generation, encryption, signing, HPKE, Argon2id and CBOM scans, with an interactive menu.
    @sebastienrousseau/crypto-edge Edge Runtime Edge-runtime cryptographic operations using the Web Crypto API, optimized for Cloudflare Workers, Vercel Edge, and Deno.
    @sebastienrousseau/crypto-kms Cloud KMS Unified KMS interface: AWS KMS, Google Cloud KMS, Vault Transit and local providers; Azure is a stub.
    @sebastienrousseau/crypto-lib Core Library Core library: post-quantum ML-KEM, ML-DSA and SLH-DSA, plus classical, modern and OpenPGP cryptography for TypeScript.
    @sebastienrousseau/crypto-lsp IDE Analysis Language server that flags weak and quantum-vulnerable cryptography in the editor, with quick fixes.
    @sebastienrousseau/crypto-mcp AI Agents Model Context Protocol server exposing cryptography tools to AI assistants and agents.
    @sebastienrousseau/crypto-middleware Middleware Cryptographic middleware for Express and Fastify: decrypt requests, encrypt responses, verify HMAC signatures and JWTs.
    @sebastienrousseau/crypto-prisma ORM Adapter Transparent field-level encryption extension for Prisma Client, using XChaCha20-Poly1305.
    @sebastienrousseau/crypto-react React Hooks React hooks and context provider for client-side cryptographic operations with zero boilerplate.
    @sebastienrousseau/crypto-sdk Client SDK A zero-dependency, typed HTTP client for the Crypto Service REST API, with full post-quantum support.
    @sebastienrousseau/crypto-server HTTP API A hardened Fastify REST API for cryptographic operations, with rate limiting, OpenAPI schemas, and post-quantum endpoints.
    @sebastienrousseau/crypto-testing Test Support Deterministic keys, fast mocks, and test fixtures for crypto-lib
    @sebastienrousseau/crypto-typeorm ORM Adapter TypeORM column-level encryption with a single decorator, powered by crypto-lib.
    @sebastienrousseau/crypto-vue Vue Composables Vue 3 composables for client-side cryptography
    @sebastienrousseau/crypto-wasm (this package) Acceleration Placeholder for a WebAssembly accelerator; no WebAssembly module ships yet.

    Back to Top


    crypto-wasm is a placeholder. It ships WebAssembly runtime detection and a WasmAccelerator class that can load a .wasm module you supply, but the package contains no WebAssembly module, and no Rust or other source for one exists in this repository. crypto-lib does not use it. Without a module, every method runs the JavaScript implementation, so there is no speed-up today.

    Back to Top

    init() with no argument looks for wasm/crypto_accel.wasm inside the package, which is not shipped. init(source) instantiates a module from a BufferSource or a Response. A failed load is not an error: isAvailable stays false and the JavaScript path is used.

    While no module is loaded, hash() and the ML-KEM-768 and ML-DSA-65 methods call crypto-lib. hash() takes crypto-lib's hash names (sha256, sha384, sha512, sha3-256, sha3-512, blake2b, blake3; SHA-256 and sha-512 are read as sha256 and sha512). When a module is loaded, each method calls the matching export and throws if the module does not provide it.

    import { detectCapabilities } from "@sebastienrousseau/crypto-wasm";

    const caps = detectCapabilities();
    // { wasmSupported: true, streamingSupported: true, simdSupported: true }

    Back to Top

    Method Fallback without a module Export expected from a module
    hash(algorithm, data) crypto-lib hash hash_<algorithm>
    mlKemEncapsulate / mlKemDecapsulate crypto-lib ML-KEM-768 ml_kem_encapsulate / ml_kem_decapsulate
    mlDsaSign / mlDsaVerify crypto-lib ML-DSA-65 ml_dsa_sign / ml_dsa_verify

    Back to Top

    benchmark(operation) times the requested hash (hash-sha256, hash-sha512 or hash-blake3) of a 1 KiB buffer through crypto-lib and through hash(), and throws for any other operation. Without a module both paths are crypto-lib, so it measures no acceleration. No benchmark results are published.

    Back to Top

    All examples are self-contained TypeScript files in the examples/ directory. Run any example with:

    npx ts-node examples/<name>.ts
    
    Category Example Purpose
    Accelerate accelerate.ts Basic WASM acceleration for hashing
    Benchmark benchmark.ts Compare JS vs WASM performance
    Detect detect.ts Check WASM availability and capabilities
    Fallback fallback.ts Graceful fallback when WASM is unavailable

    Back to Top

    Back to Top


    pnpm --filter @sebastienrousseau/crypto-wasm run build
    pnpm --filter @sebastienrousseau/crypto-wasm run test
    pnpm --filter @sebastienrousseau/crypto-wasm run lint
    pnpm --filter @sebastienrousseau/crypto-wasm run format

    All 18 packages in the Crypto Service workspace maintain a 100% coverage floor across statements, branches, functions, and lines.

    Back to Top


    Report vulnerabilities privately via GitHub Security Advisories or according to SECURITY.md. Never report security issues publicly.

    Cryptographic operations use the @noble/* libraries, Node.js crypto and OpenPGP.js. @noble/post-quantum has not been independently audited and does not guarantee constant-time execution, and no module in this suite is FIPS 140-3 validated. Key zeroization is limited: JavaScript strings and garbage-collected buffers cannot be reliably wiped. See SECURITY.md.

    Back to Top


    Back to Top


    Versions advance strictly one step at a time on the 0.0.x line (v0.0.1 → v0.0.2 → v0.0.3 ... → v0.0.999 → v0.1.0). Work for every release iteration begins on a dedicated feat/v<version> branch.

    All 18 packages in the workspace move in lockstep. Public API signatures, cipher output formats, and serialization schemas are strictly versioned. Breaking changes to serialized formats or algorithm defaults are considered major breaking changes. Minimum toolchain upgrades (e.g. Node.js LTS floor) are governed by POLICIES.md.

    Back to Top


    Dual-licensed under Apache 2.0 or MIT, at your option.

    Copyright (c) 2022-2026 Sebastien Rousseau and The Crypto Service Suite contributors.

    Back to Top