Files
quicproquo/docs/src/getting-started/wasm.md
Christian Nennemann 2e081ead8e chore: rename quicproquo → quicprochat in docs, Docker, CI, and packaging
Rename all project references from quicproquo/qpq to quicprochat/qpc
across documentation, Docker configuration, CI workflows, packaging
scripts, operational configs, and build tooling.

- Docker: crate paths, binary names, user/group, data dirs, env vars
- CI: workflow crate references, binary names, artifact names
- Docs: all markdown files under docs/, SDK READMEs, book.toml
- Packaging: OpenWrt Makefile, init script, UCI config (file renames)
- Scripts: justfile, dev-shell, screenshot, cross-compile, ai_team
- Operations: Prometheus config, alert rules, Grafana dashboard
- Config: .env.example (QPQ_* → QPC_*), CODEOWNERS paths
- Top-level: README, CONTRIBUTING, ROADMAP, CLAUDE.md
2026-03-21 19:14:06 +01:00

2.9 KiB

WASM Integration

The quicprochat-core crate supports compilation to wasm32-unknown-unknown when the native feature is disabled. This exposes the pure-crypto subset of the library for use in browsers or other WASM runtimes.

Building for WASM

rustup target add wasm32-unknown-unknown

cargo build -p quicprochat-core \
    --target wasm32-unknown-unknown \
    --no-default-features

The --no-default-features flag disables the native feature, which gates MLS (openmls), OPAQUE, Cap'n Proto, and tokio -- all of which have dependencies that do not compile to WASM.

What is available in WASM mode

The following modules compile to WASM and are fully functional:

Module Description
identity Ed25519 identity keypair (generate, sign, verify)
hybrid_kem X25519 + ML-KEM-768 hybrid key encapsulation
safety_numbers Signal-style safety number computation
sealed_sender Sender identity + Ed25519 signature envelope
app_message Rich application message serialisation/parsing
padding Message padding to hide plaintext lengths
transcript Encrypted tamper-evident message transcript
error CoreError type

What is NOT available in WASM mode

The following require the native feature and will not compile to WASM:

  • group -- MLS group state machine (openmls)
  • keypackage -- MLS KeyPackage generation
  • hybrid_crypto -- hybrid HPKE provider for OpenMLS
  • keystore -- OpenMLS key store with disk persistence
  • opaque_auth -- OPAQUE cipher suite configuration

Networking (quicprochat-client, quicprochat-server) is not available in WASM.

Random number generation

On wasm32, the getrandom crate is configured with the js feature to use the browser's crypto.getRandomValues() API. This is set automatically in quicprochat-core/Cargo.toml:

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }

This means the WASM build works in browser environments out of the box. For non-browser WASM runtimes (WASI, etc.), you may need to adjust the getrandom backend.

wasm-bindgen and the TypeScript SDK

The wasm-bindgen JS bindings are now implemented in sdks/typescript/wasm-crypto/. This provides 13 JavaScript-callable functions wrapping the WASM-compatible crypto modules:

cd sdks/typescript/wasm-crypto
wasm-pack build --target web --out-dir ../pkg

The resulting 175 KB WASM bundle is used by the @quicprochat/client TypeScript SDK and the interactive browser demo.

See the TypeScript SDK and Browser Demo guide for full details on building and running the browser demo.