Prover worker and CLI
Copy the SDK's browser files into your app with the copy-assets command, or bundle the prover yourself and start your own worker.
The SDK builds each proof in a Web Worker, from WebAssembly it ships. Your app serves those files one of two ways:
| Way | When to use it |
|---|---|
Copy the shipped files with copy-assets | Almost always. The SDK starts its own worker and checks every file it runs. |
| Bundle the prover yourself and start your own worker | Only when your build must produce every script and WebAssembly file itself. |
Copy the shipped files
The package installs a command, nimbus-solana-web, with one subcommand:
nimbus-solana-web copy-assets <directory>It copies the browser files the SDK runs into <directory>, which your app serves as static files.
It takes exactly one argument and no options. Run it from a package script, as the example app
does:
{
"scripts": {
"assets": "nimbus-solana-web copy-assets public/nimbus"
}
}Then pass the URL that directory is served at to loadNimbusSdk:
import { } from "@umbra/nimbus-solana-web";
const = await (
{ : "mainnet" },
{ : "/nimbus/" },
);What it copies
nimbus_primitives_wasm_bg.wasm, the WebAssemblyloadNimbusSdkloads.prover-worker.js, the worker each proof runs in.prover/andwitness-graph/, the WebAssembly the worker proves with.
It creates the directory when it does not exist. It overwrites files of the same names and touches no other file. Run it again each time you update the package, so the files match the version you installed.
copy-assets lists its exit codes.
Start your own worker
Skip this section unless your build must bundle the prover's WebAssembly itself.
Your worker module answers each message with proveWorkerRequest, from the package's
./prover-worker entry. Its whole body is:
import initGraph, * as graph from "./umbra_witness_graph.js";
import initProver, * as wasm from "./umbra_prover.js";
import { proveWorkerRequest } from "@umbra/nimbus-solana-web/prover-worker";
self.addEventListener("message", (event) => {
void Promise.all([initGraph(), initProver()])
.then(async () => proveWorkerRequest(event.data, { graph, wasm }))
.then((answer) => self.postMessage(answer));
});This block is not type-checked here. It imports two files that your own build writes: the witness-graph and prover glue code.
Then pass a function that starts your worker as platform.startProverWorker:
import { } from "@umbra/nimbus-solana-web";
const = await (
{ : "mainnet" },
{
: { : "/wasm/nimbus_primitives_wasm_bg.wasm" },
: {
: () => new (, { : "module" }),
},
},
);Without assetsBaseUrl, pass endpoints.primitivesWasm too. It is the URL your app serves the
SDK's main WebAssembly file at.
The SDK starts a fresh worker for each proof and terminates it afterwards. Each request carries the user's private inputs, so a worker is never reused.
Your worker is not checked
The shipped worker checks every file it loads against the SHA-256 the package pins. A worker of your own skips those checks, unless you add them.
Next
Last updated