@waku/zerokit-rln-wasm-parallel
v1.0.0
Published
[](https://badge.fury.io/js/@waku%2Fzerokit-rln-wasm) [](https://opensource.org/licenses/MIT) [ - for compiling Rust to WebAssemblycargo-make- for running build commandsnvm- to install and manage Node.js (v22.14.0+)
Quick Install
make installdepsManual Installation
# Install wasm-pack
cargo install wasm-pack --version=0.13.1
# Install cargo-make
cargo install cargo-make
# Install Node.js via nvm
nvm install 22.14.0
nvm use 22.14.0
nvm alias default 22.14.0Building the Library
Navigate to the rln-wasm directory:
cd rln-wasmBuild commands:
cargo make build # Default → @waku/zerokit-rln-wasm
cargo make build_parallel # Parallel → @waku/zerokit-rln-wasm-parallel (requires nightly Rust)
cargo make build_utils # Utils only → @waku/zerokit-rln-wasm-utilsAll packages output to pkg/ directory.
Running Tests and Benchmarks
cargo make test # Standard tests
cargo make test_browser # Browser headless mode
cargo make test_utils # Utils-only tests
cargo make test_parallel # Parallel testsExamples
See Node example and README for proof generation, verification, and slashing.
Parallel Computation
Enables multi-threaded browser execution using wasm-bindgen-rayon.
[!NOTE]
- Parallel support is not enabled by default due to WebAssembly and browser limitations.
- Requires
nightlyRust:rustup install nightly- Browser-only (not compatible with Node.js)
- Requires HTTP headers for
SharedArrayBuffer:
Cross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: require-corp
Usage
Direct usage (modern browsers with WebAssembly threads support):
import * as wasmPkg from '@waku/zerokit-rln-wasm-parallel';
await wasmPkg.default();
await wasmPkg.initThreadPool(navigator.hardwareConcurrency);
wasmPkg.nowCallAnyExportedFuncs();Feature Detection for Older Browsers
If you're targeting older browser versions that didn't support WebAssembly threads yet, you'll want to use both builds - the parallel version for modern browsers and the default version as a fallback. Use feature detection to choose the appropriate build on the JavaScript side.
You can use the wasm-feature-detect library for this purpose:
import { threads } from 'wasm-feature-detect';
let wasmPkg;
if (await threads()) {
wasmPkg = await import('@waku/zerokit-rln-wasm-parallel');
await wasmPkg.default();
await wasmPkg.initThreadPool(navigator.hardwareConcurrency);
} else {
wasmPkg = await import('@waku/zerokit-rln-wasm');
await wasmPkg.default();
}
wasmPkg.nowCallAnyExportedFuncs();