spike(wasm-pqc): PQC-in-browser benchmarks — GO on all exit criteria (task 0.3) #52

Merged
amiryahaya merged 1 commit from spike/wasm-pqc into main 2026-11-04 18:22:40 +01:00
Owner

The biggest Phase-5 risk gate, resolved: GO on all exit criteria.

  • ML-KEM-768 keygen/encaps/decaps: 0.21–0.26 ms/op (~4,200 ops/s), shared secrets match
  • ML-DSA-65 keygen/sign/verify: 1.5 / 11.1 / 1.6 ms
  • Argon2id (real WASM via hash-wasm): 122 ms native tier (m=64MiB), 58 ms web tier (m=32MiB) — matches KEY-13 floors
  • AES-256-GCM 1 MB enc+dec via native WebCrypto: 2,315 MB/s — exit ≥5 MB/s: PASS ×463
  • Tree-shaken gzipped crypto bundle (ML-KEM+ML-DSA+Argon2id): 22 KiB — exit ≤2 MB: PASS ×89

Stack: @noble/post-quantum (audited pure-TS) + hash-wasm (real WASM) + native WebCrypto for bulk. KAZ-KEM-in-WASM deferred (ML family is the default since 29ca92e; noble hybrid.js covers a web-safe X25519+ML-KEM hybrid). Gotcha recorded: noble v0.7 API is sign(msg, secretKey) / verify(sig, msg, publicKey).

Findings table in spike-notes.md §0.3. Closes #16

The biggest Phase-5 risk gate, resolved: **GO on all exit criteria.** - **ML-KEM-768** keygen/encaps/decaps: 0.21–0.26 ms/op (~4,200 ops/s), shared secrets match - **ML-DSA-65** keygen/sign/verify: 1.5 / 11.1 / 1.6 ms - **Argon2id** (real WASM via hash-wasm): 122 ms native tier (m=64MiB), 58 ms web tier (m=32MiB) — matches KEY-13 floors - **AES-256-GCM 1 MB enc+dec via native WebCrypto: 2,315 MB/s** — exit ≥5 MB/s: PASS ×463 - **Tree-shaken gzipped crypto bundle (ML-KEM+ML-DSA+Argon2id): 22 KiB** — exit ≤2 MB: PASS ×89 Stack: `@noble/post-quantum` (audited pure-TS) + `hash-wasm` (real WASM) + native WebCrypto for bulk. KAZ-KEM-in-WASM deferred (ML family is the default since 29ca92e; noble `hybrid.js` covers a web-safe X25519+ML-KEM hybrid). Gotcha recorded: noble v0.7 API is `sign(msg, secretKey)` / `verify(sig, msg, publicKey)`. Findings table in `spike-notes.md` §0.3. Closes #16
spikes/wasm-pqc/: bench.mjs (ML-KEM-768, ML-DSA-65, Argon2id via hash-wasm,
AES-256-GCM via native WebCrypto) + bundle-report.mjs (tree-shaken esbuild
bundle, gzipped) + bundle-entry.mjs.

Measured (Node 22 / V8 = Chromium engine family):
- ML-KEM-768 keygen/encaps/decaps: 0.21-0.26 ms/op (~4200 ops/s)
- ML-DSA-65 keygen/sign/verify: 1.5 / 11.1 / 1.6 ms
- Argon2id: 122 ms native tier (m=64MiB), 58 ms web tier (m=32MiB)
- AES-256-GCM 1 MB enc+dec (WebCrypto): 2315 MB/s — exit >=5 MB/s: PASS x463
- Crypto bundle tree-shaken gzipped: 22 KiB — exit <=2 MB: PASS x89

Go/no-go: GO. Phase 5 web-client scope confirmed (WASM/JS for key ops only;
bulk data on native WebCrypto). Stack: @noble/post-quantum (audited, pure TS)
+ hash-wasm; noble call-order gotcha recorded (sign(msg, secretKey)).

Findings + section in docs/redesign/2026-11-onboarding-passkey/spike-notes.md.
Closes #16 (task 0.3)

🤖 Generated with [ZCode](https://zcode.ai)

Co-Authored-By: ZCode <noreply@anthropic.com>
Author
Owner

ponytail-review (§2.4 AI first-pass) — Verdict: Ship (spike). What this change does: adds benchmark scripts measuring ML-KEM/ML-DSA/Argon2id/AES-GCM performance and the gzipped crypto-bundle size in the browser engine (V8), plus the §0.3 findings table.

Checked: benchmarks measure the shapes FailSulit actually uses (KEM per-file ops, AES bulk path via WebCrypto — the 5 MB/s criterion applies there, passed ×463); sanity assertions (shared-secret equality, signature verify, roundtrip size) run in the bench itself; bundle measurement tree-shakes exactly the web-client imports; private spike — no prod code touched; node_modules/out untracked.

Notes (not blocking): Node V8 ≈ Chromium V8 but browser JIT differs — Phase 2 E2E should re-run the same bench in a real browser tab for final numbers; KAZ-KEM-in-WASM deferred with rationale.

**ponytail-review (§2.4 AI first-pass) — Verdict: Ship (spike).** What this change does: adds benchmark scripts measuring ML-KEM/ML-DSA/Argon2id/AES-GCM performance and the gzipped crypto-bundle size in the browser engine (V8), plus the §0.3 findings table. Checked: benchmarks measure the shapes FailSulit actually uses (KEM per-file ops, AES bulk path via WebCrypto — the 5 MB/s criterion applies there, passed ×463); sanity assertions (shared-secret equality, signature verify, roundtrip size) run in the bench itself; bundle measurement tree-shakes exactly the web-client imports; private spike — no prod code touched; node_modules/out untracked. Notes (not blocking): Node V8 ≈ Chromium V8 but browser JIT differs — Phase 2 E2E should re-run the same bench in a real browser tab for final numbers; KAZ-KEM-in-WASM deferred with rationale.
amiryahaya deleted branch spike/wasm-pqc 2026-11-04 18:22:41 +01:00
Sign in to join this conversation.
No description provided.