@sebastienrousseau/crypto-wasm 0.0.33 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +47 -102
  2. package/package.json +10 -4
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  <h1 align="center">@sebastienrousseau/crypto-wasm</h1>
8
8
 
9
9
  <p align="center">
10
- WebAssembly performance accelerator for crypto-lib — near-native speed for SHA-256, AES-GCM, Argon2, Ed25519, and X25519.
10
+ 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.
11
11
  </p>
12
12
 
13
13
  <p align="center">
@@ -32,7 +32,7 @@
32
32
 
33
33
  **The Crypto Service ecosystem**
34
34
 
35
- - [The Crypto Service ecosystem](#the-crypto-service-ecosystem) — full 14-package suite overview
35
+ - [The Crypto Service ecosystem](#the-crypto-service-ecosystem) — full 18-package suite overview
36
36
 
37
37
  **Package reference**
38
38
 
@@ -97,22 +97,26 @@ console.log(Buffer.from(digest).toString("hex"));
97
97
 
98
98
  Crypto Service provides a complete cryptography stack across 14 specialized packages:
99
99
 
100
- | Package | Role | Description |
101
- | :---------------------------------------------------------------------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------- |
102
- | [`@sebastienrousseau/crypto-api`](../crypto-api) | API Schemas | Shared TypeScript types and utilities for the Crypto Service Suite, defining the canonical API surface. |
103
- | [`@sebastienrousseau/crypto-cli`](../crypto-cli) | Terminal CLI | An interactive command-line interface for cryptographic operations, supporting both legacy OpenPGP and modern post-quantum algorithms. |
104
- | [`@sebastienrousseau/crypto-edge`](../crypto-edge) | Edge Runtime | Edge-runtime cryptographic operations using the Web Crypto API, optimized for Cloudflare Workers, Vercel Edge, and Deno. |
105
- | [`@sebastienrousseau/crypto-kms`](../crypto-kms) | Cloud KMS | Unified Key Management Service interface for AWS KMS, GCP Cloud KMS, Azure Key Vault, and HashiCorp Vault. |
106
- | [`@sebastienrousseau/crypto-lib`](../crypto-lib) | Core Library | A modern cryptographic library for TypeScript, with post-quantum support, zero unsafe dependencies, and 100% test coverage. |
107
- | [`@sebastienrousseau/crypto-middleware`](../crypto-middleware) | Middleware | Framework-agnostic cryptographic middleware for Express, Fastify, and Koa applications. |
108
- | [`@sebastienrousseau/crypto-prisma`](../crypto-prisma) | ORM Adapter | Transparent field-level encryption extension for Prisma Client, using XChaCha20-Poly1305. |
109
- | [`@sebastienrousseau/crypto-react`](../crypto-react) | React Hooks | React hooks and context provider for client-side cryptographic operations with zero boilerplate. |
110
- | [`@sebastienrousseau/crypto-sdk`](../crypto-sdk) | Client SDK | A zero-dependency, typed HTTP client for the Crypto Service REST API, with full post-quantum support. |
111
- | [`@sebastienrousseau/crypto-server`](../crypto-server) | HTTP API | A hardened Fastify REST API for cryptographic operations, with rate limiting, OpenAPI schemas, and post-quantum endpoints. |
112
- | [`@sebastienrousseau/crypto-testing`](../crypto-testing) | Test Support | Deterministic keys, fast mocks, and test fixtures for crypto-lib |
113
- | [`@sebastienrousseau/crypto-typeorm`](../crypto-typeorm) | ORM Adapter | TypeORM column-level encryption with a single decorator, powered by crypto-lib. |
114
- | [`@sebastienrousseau/crypto-vue`](../crypto-vue) | Vue Composables | Vue 3 composables for client-side cryptography |
115
- | **[`@sebastienrousseau/crypto-wasm`](../crypto-wasm)** _(this package)_ | **Acceleration** | **WebAssembly performance accelerator for crypto-lib** |
100
+ | Package | Role | Description |
101
+ | :------------------------------------------------------------------------------------------------------------------------------------------ | :--------------- | :----------------------------------------------------------------------------------------------------------------------------- |
102
+ | [`@sebastienrousseau/crypto-api`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-api) | API Schemas | Shared TypeScript types and utilities for the Crypto Service Suite, defining the canonical API surface. |
103
+ | [`@sebastienrousseau/crypto-benchmarks`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-benchmarks) | Benchmarks | Benchmarks comparing classical and post-quantum cryptography: ops/sec, latency and throughput. |
104
+ | [`@sebastienrousseau/crypto-cbom`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-cbom) | CBOM | Cryptographic Bill of Materials generator and auditor (CycloneDX 1.6, SPDX 3.0). |
105
+ | [`@sebastienrousseau/crypto-cli`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-cli) | Terminal CLI | Command-line interface: hashing, key generation, encryption, signing, HPKE, Argon2id and CBOM scans, with an interactive menu. |
106
+ | [`@sebastienrousseau/crypto-edge`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-edge) | Edge Runtime | Edge-runtime cryptographic operations using the Web Crypto API, optimized for Cloudflare Workers, Vercel Edge, and Deno. |
107
+ | [`@sebastienrousseau/crypto-kms`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-kms) | Cloud KMS | Unified KMS interface: AWS KMS and local providers implemented; GCP, Azure and Vault are stubs. |
108
+ | [`@sebastienrousseau/crypto-lib`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-lib) | Core Library | Core library: post-quantum ML-KEM, ML-DSA and SLH-DSA, plus classical, modern and OpenPGP cryptography for TypeScript. |
109
+ | [`@sebastienrousseau/crypto-lsp`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-lsp) | IDE Analysis | Language server that flags weak and quantum-vulnerable cryptography in the editor, with quick fixes. |
110
+ | [`@sebastienrousseau/crypto-mcp`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-mcp) | AI Agents | Model Context Protocol server exposing cryptography tools to AI assistants and agents. |
111
+ | [`@sebastienrousseau/crypto-middleware`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-middleware) | Middleware | Cryptographic middleware for Express and Fastify: decrypt requests, encrypt responses, verify HMAC signatures and JWTs. |
112
+ | [`@sebastienrousseau/crypto-prisma`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-prisma) | ORM Adapter | Transparent field-level encryption extension for Prisma Client, using XChaCha20-Poly1305. |
113
+ | [`@sebastienrousseau/crypto-react`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-react) | React Hooks | React hooks and context provider for client-side cryptographic operations with zero boilerplate. |
114
+ | [`@sebastienrousseau/crypto-sdk`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-sdk) | Client SDK | A zero-dependency, typed HTTP client for the Crypto Service REST API, with full post-quantum support. |
115
+ | [`@sebastienrousseau/crypto-server`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-server) | HTTP API | A hardened Fastify REST API for cryptographic operations, with rate limiting, OpenAPI schemas, and post-quantum endpoints. |
116
+ | [`@sebastienrousseau/crypto-testing`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-testing) | Test Support | Deterministic keys, fast mocks, and test fixtures for crypto-lib |
117
+ | [`@sebastienrousseau/crypto-typeorm`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-typeorm) | ORM Adapter | TypeORM column-level encryption with a single decorator, powered by crypto-lib. |
118
+ | [`@sebastienrousseau/crypto-vue`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-vue) | Vue Composables | Vue 3 composables for client-side cryptography |
119
+ | **[`@sebastienrousseau/crypto-wasm`](https://github.com/sebastienrousseau/crypto-service/tree/main/packages/crypto-wasm)** _(this package)_ | **Acceleration** | **Placeholder for a WebAssembly accelerator; no WebAssembly module ships yet.** |
116
120
 
117
121
  <p align="right"><a href="#contents">Back to Top</a></p>
118
122
 
@@ -120,40 +124,30 @@ Crypto Service provides a complete cryptography stack across 14 specialized pack
120
124
 
121
125
  ## Overview
122
126
 
123
- crypto-wasm is an optional performance accelerator for the Crypto
124
- Service Suite. When installed alongside crypto-lib, heavy
125
- cryptographic operations are automatically routed through a
126
- WebAssembly module compiled from Rust, delivering near-native speed
127
- for hashing, AES-GCM encryption, Argon2 password hashing, and
128
- Ed25519/X25519 operations. If the WASM module is unavailable, every
129
- operation transparently falls back to the equivalent pure-JavaScript
130
- implementation.
127
+ crypto-wasm is a placeholder. It ships WebAssembly runtime detection
128
+ and a `WasmAccelerator` class that can load a `.wasm` module you
129
+ supply, but the package contains no WebAssembly module, and no Rust
130
+ or other source for one exists in this repository. crypto-lib does
131
+ not use it. Without a module, every method runs the JavaScript
132
+ implementation, so there is no speed-up today.
131
133
 
132
134
  <p align="right"><a href="#contents">Back to Top</a></p>
133
135
 
134
136
  ## How It Works
135
137
 
136
- ### Auto-Detection
138
+ ### Loading a module
137
139
 
138
- When crypto-lib detects `@sebastienrousseau/crypto-wasm` as an
139
- installed dependency, it automatically routes heavy cryptographic
140
- operations through the WASM module. No configuration is needed.
140
+ `init()` with no argument looks for `wasm/crypto_accel.wasm` inside
141
+ the package, which is not shipped. `init(source)` instantiates a
142
+ module from a `BufferSource` or a `Response`. A failed load is not an
143
+ error: `isAvailable` stays `false` and the JavaScript path is used.
141
144
 
142
- ```
143
- crypto-lib --> crypto-wasm installed?
144
- | |
145
- YES NO
146
- | |
147
- WASM path JS fallback
148
- (near-native) (pure JS)
149
- ```
150
-
151
- ### Transparent Fallback
145
+ ### JavaScript fallback
152
146
 
153
- If the WASM module is not compiled or not available in the current
154
- runtime, every operation falls back to the equivalent
155
- pure-JavaScript implementation. Your application code does not need
156
- to handle either case differently.
147
+ While no module is loaded, `hash()` uses Node.js `crypto`, and the
148
+ ML-KEM-768 and ML-DSA-65 methods call crypto-lib. When a module is
149
+ loaded, each method calls the matching export and throws if the
150
+ module does not provide it.
157
151
 
158
152
  ### Runtime Detection
159
153
 
@@ -168,69 +162,20 @@ const caps = detectCapabilities();
168
162
 
169
163
  ## Supported Operations
170
164
 
171
- | Operation | ID | Description |
172
- | :-------------- | :---------------- | :----------------------------------- |
173
- | SHA-256 | `hash-sha256` | SHA-256 hash computation |
174
- | SHA-512 | `hash-sha512` | SHA-512 hash computation |
175
- | BLAKE3 | `hash-blake3` | BLAKE3 hash computation |
176
- | AES-GCM Encrypt | `aes-gcm-encrypt` | AES-256-GCM authenticated encryption |
177
- | AES-GCM Decrypt | `aes-gcm-decrypt` | AES-256-GCM authenticated decryption |
178
- | Argon2 | `argon2-hash` | Argon2id/i/d password hashing |
179
- | Ed25519 Sign | `ed25519-sign` | Ed25519 signature generation |
180
- | Ed25519 Verify | `ed25519-verify` | Ed25519 signature verification |
181
- | X25519 | `x25519-exchange` | X25519 Diffie-Hellman key exchange |
182
-
183
- <p align="right"><a href="#contents">Back to Top</a></p>
184
-
185
- ## Building from Source
186
-
187
- The WASM module is compiled from Rust. A Rust toolchain with
188
- `wasm32-unknown-unknown` target is required.
189
-
190
- ```bash
191
- # Install Rust (if not already installed)
192
- curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
193
-
194
- # Add the WASM target
195
- rustup target add wasm32-unknown-unknown
196
-
197
- # Install wasm-pack
198
- cargo install wasm-pack
199
-
200
- # Build the WASM module
201
- pnpm run build:wasm
202
- ```
203
-
204
- The compiled `.wasm` file is placed in `wasm/crypto_accel.wasm`.
165
+ | Method | Fallback without a module | Export expected from a module |
166
+ | :-------------------------------------- | :------------------------ | :------------------------------------------ |
167
+ | `hash(algorithm, data)` | Node.js `crypto` | `hash_<algorithm>` |
168
+ | `mlKemEncapsulate` / `mlKemDecapsulate` | crypto-lib ML-KEM-768 | `ml_kem_encapsulate` / `ml_kem_decapsulate` |
169
+ | `mlDsaSign` / `mlDsaVerify` | crypto-lib ML-DSA-65 | `ml_dsa_sign` / `ml_dsa_verify` |
205
170
 
206
171
  <p align="right"><a href="#contents">Back to Top</a></p>
207
172
 
208
173
  ## Benchmarks
209
174
 
210
- Run the built-in benchmark to compare JS and WASM performance:
211
-
212
- ```ts
213
- import { WasmAccelerator } from "@sebastienrousseau/crypto-wasm";
214
-
215
- const accel = new WasmAccelerator();
216
- await accel.init();
217
-
218
- const result = await accel.benchmark("hash-sha256", 10000);
219
- console.log(`JS: ${result.jsTimeMs.toFixed(2)} ms`);
220
- console.log(`WASM: ${result.wasmTimeMs.toFixed(2)} ms`);
221
- console.log(`Speedup: ${result.speedup.toFixed(2)}x`);
222
- ```
223
-
224
- **Expected speedups** (once Rust WASM module is compiled):
225
-
226
- | Operation | Expected Speedup |
227
- | :-------------------- | :--------------- |
228
- | SHA-256 (large input) | 2-5x |
229
- | AES-GCM | 3-8x |
230
- | Argon2 | 5-15x |
231
- | Ed25519 Sign | 2-4x |
232
- | Ed25519 Verify | 2-4x |
233
- | X25519 | 2-4x |
175
+ `benchmark()` times SHA-256 hashing of a 1 KiB buffer through Node.js
176
+ `crypto` and through `hash()`. Without a module both paths are
177
+ JavaScript, so it measures no acceleration. No benchmark results are
178
+ published.
234
179
 
235
180
  <p align="right"><a href="#contents">Back to Top</a></p>
236
181
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sebastienrousseau/crypto-wasm",
3
- "version": "0.0.33",
4
- "description": "WebAssembly performance accelerator for crypto-lib — near-native speed for heavy cryptographic operations.",
3
+ "version": "0.0.34",
4
+ "description": "Placeholder for a WebAssembly accelerator for crypto-lib. It ships runtime detection and an accelerator interface only; no WebAssembly module yet, so operations run in JavaScript.",
5
5
  "author": "Sebastien Rousseau <sebastienrousseau@users.noreply.github.com>",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "engines": {
@@ -26,7 +26,7 @@
26
26
  "wasm/"
27
27
  ],
28
28
  "dependencies": {
29
- "@sebastienrousseau/crypto-lib": "0.0.33"
29
+ "@sebastienrousseau/crypto-lib": "0.0.34"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/chai": "^5.2.3",
@@ -52,9 +52,15 @@
52
52
  "access": "public"
53
53
  },
54
54
  "private": false,
55
+ "keywords": [
56
+ "webassembly",
57
+ "wasm",
58
+ "cryptography",
59
+ "crypto-lib"
60
+ ],
55
61
  "scripts": {
56
62
  "build": "tsc --build tsconfig.json",
57
- "build:wasm": "echo 'WASM build requires Rust toolchain — see README'",
63
+ "build:wasm": "echo 'No WebAssembly module source exists yet; see README'",
58
64
  "clean": "rimraf ./coverage ./dist ./docs",
59
65
  "test": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --reporter=lcov --reporter=text mocha --config=.mocharc.cjs",
60
66
  "docs": "typedoc",