Aleo for Agents is offline at present

blog·2026-10-28·10 min read

Deep Dive: Why Aleo's wasm64 SDK Is an Escape Hatch, Not a Drop-In Upgrade

A browser prover can run perfectly for months, then fall over when one larger circuit, a warm key cache, or two concurrent jobs pushes its WebAssembly heap past 4 GiB. The failure often looks like an allocation error or a generic Wasm trap. By then, the application has already accepted work it cannot finish.

Provable SDK 0.14.0-rc offers another route. Its opt-in wasm64 build raises the configured linear-memory maximum to 8 GiB and keeps threaded proving through shared memory, atomics, and Rayon. That extra room is useful. It also changes what your application must promise about its packages, runtime, HTTP headers, fallback path, and object lifetime.

The 4 GiB wall has teeth.

Why wasm32 runs out

Ordinary WebAssembly uses 32-bit indexes for linear memory. A pointer can address at most 2^32 bytes, which creates a hard 4 GiB address-space ceiling even when the machine has 32 GiB of physical RAM sitting idle.

Local Aleo proving puts unusual pressure on that space. The prover may hold program data, circuit structures, proving keys, witness values, serialization buffers, and worker state at the same time. JavaScript allocations live outside the Wasm heap, but they still compete for the process's physical memory.

A workload can cross the line in several ways:

  • One large function needs a witness and proving key whose combined peak exceeds the available linear memory.
  • Several proofs run against one Wasm instance at once.
  • A record scanner retains a large ciphertext set while cryptographic work is active.
  • Prepared processes and key caches keep useful data alive between calls, raising the baseline before the next proof starts.

That final case matters for applications using the reusable contexts described in Build a Reusable Proving Context with the Provable SDK. Reuse saves setup time, but retained state still occupies memory. A context that makes the tenth proof faster may also leave less headroom for it.

Garbage collection cannot rescue an allocation that must exist inside the Wasm linear memory. Nor can adding RAM to the host change the wasm32 pointer width. Once a live allocation needs an address beyond the 4 GiB boundary, the instance is done.

What wasm64 changes

Memory64 widens WebAssembly memory indexes to 64 bits. The Provable build targets wasm64-unknown-unknown, compiles the same Rust sources and snarkVM 4.12.0 used by the wasm32 package, and publishes the result separately as @provablehq/wasm64.

The preview configures an 8 GiB maximum. That is the usable ceiling chosen by the SDK build, rather than the theoretical range of a 64-bit pointer. Browsers and JavaScript engines impose their own limits, so wasm64 should never be read as permission to allocate arbitrary amounts of memory.

An 8 GiB maximum is also not a guarantee that 8 GiB will be available. The operating system may reject a reservation, a browser process may hit a lower policy limit, or physical memory pressure may kill the tab before the Wasm heap reaches its declared maximum. Treat the number as an upper bound.

More address space costs performance. Provable's measurements on Node.js 24 and an Apple M2 found benchmarked wasm64 operations were 9 to 21 percent slower than wasm32. Proving was 13 to 18 percent slower. Wider pointers increase memory traffic and can make generated code less efficient, so wasm64 is a poor default for jobs that fit comfortably inside wasm32.

My preference is blunt: keep wasm32 for ordinary work. Route only measured memory outliers to wasm64.

The packages make that choice explicit:

bash
npm install @provablehq/sdk@rc @provablehq/wasm64@rc
typescript
import {
  Account,
  ProgramManager,
  initThreadPool,
} from "@provablehq/sdk/wasm64/mainnet.js";

await initThreadPool();

Installing @provablehq/sdk@rc brings in the matching wasm32 package. It does not download @provablehq/wasm64. The latter is an optional peer dependency and must be installed before a static wasm64/ entry point can work.

That packaging decision is good architecture. Existing applications keep their current binary size and runtime requirements. A normal SDK update cannot quietly switch them onto a slower module that fails on Safari.

The new deployment contract

Choosing wasm64 binds the application to several conditions that wasm32 callers may never have considered together.

Runtime support

The preview requires a runtime that can instantiate 64-bit shared WebAssembly memory. Provable lists Node.js 24 or later, Chrome and Edge 133 or later, and Firefox 134 or later. Safari, iOS, and Node.js releases before 24 are unsupported by the wasm64 entry points.

Environmentwasm32Provable wasm64Practical policy
Node.js 24+YesYesPrefer wasm32 until a job exceeds its budget
Chrome or Edge 133+YesYes, with isolationPermit local wasm64 after startup checks
Firefox 134+YesYes, with isolationTest the exact release used by your audience
Safari and iOSYesNoUse wasm32 or delegated proving

Static wasm64 imports throw a documented error on unsupported runtimes. They do not select wasm32 on your behalf.

Shared memory and isolation

Provable's wasm64 artifact is threaded. Its Rayon workers use a shared WebAssembly.Memory, whose JavaScript backing store is a SharedArrayBuffer. Browsers expose that capability only inside a secure, cross-origin-isolated context.

A typical deployment sends these headers with the top-level document:

bash
curl -I [https://app.example.com](https://app.example.com)

# Expected responses:
# Cross-Origin-Opener-Policy: same-origin
# Cross-Origin-Embedder-Policy: require-corp

Check self.crossOriginIsolated inside the worker as well as the page. A CDN, reverse proxy, static host, or error-page handler can strip headers even when the development server sets them correctly.

Cross-Origin-Embedder-Policy: require-corp affects every embedded cross-origin resource. Fonts, analytics scripts, images, wallet frames, and worker files need suitable CORS or Cross-Origin-Resource-Policy responses. Cross-Origin-Opener-Policy: same-origin can also separate cross-origin popup windows from their opener, which deserves testing if a wallet or login flow uses popups.

Cross-origin isolation is therefore part of product integration, not a Vite setting somebody copies once. A third-party script without the right headers can break the page before proving begins.

Selection and fallback

The dynamic entry exposes runtime selection without forcing one static import:

typescript
import {
  loadNetwork,
  supportsThreads,
  supportsWasm64,
} from "@provablehq/sdk/dynamic.js";

const canTryWasm64 = supportsThreads() && supportsWasm64();

const sdk = await loadNetwork("mainnet", {
  variant: canTryWasm64 ? "wasm64" : "wasm32",
});

loadNetwork(name, { variant }) accepts "wasm32", "wasm64", or "auto". The default is wasm32. Auto mode tries wasm64 when the runtime supports it and initialization succeeds, then falls back to wasm32 if the wasm64 package is absent or the build cannot initialize.

Auto mode solves loader compatibility. It does not solve job compatibility.

Suppose a proof is known to peak near 5 GiB. Auto mode may fall back successfully to wasm32 on Safari, only for that proof to trap later. The application still needs a job-level policy that can refuse local proving, send the authorization to a trusted prover, or ask the user to switch environments.

Browser bundlers inspect both dynamic branches. An application that bundles the dynamic entry and may request wasm64 must install @provablehq/wasm64, even if auto mode can fall back at runtime. Otherwise dependency resolution can fail during the build rather than in the user's browser.

Objects cannot cross builds

Loading both variants in one JavaScript realm is possible, but the SDK warns when it happens. Take that warning seriously.

Objects returned through wasm-bindgen belong to the module instance that allocated them. An Account, Program, PrivateKey, prepared context, proving key wrapper, or transaction object from wasm32 carries references into the wasm32 heap. The matching wasm64 class is backed by another module and another heap.

Passing a wasm32 object into wasm64 code is not a conversion. Constructor names may look identical in TypeScript while their internal pointers refer to unrelated address spaces.

Use serialized boundaries instead:

typescript
type ProvingRequest = {
  programSource: string;
  functionName: string;
  inputs: string[];
  privateKey: string;
};

// Send plain data to a worker dedicated to one SDK variant.
worker.postMessage(request satisfies ProvingRequest);

Create SDK objects inside the worker that owns the selected build. Return strings, byte arrays, or other documented serialized forms. If a job must move from wasm32 to wasm64 after a failure, discard the trapped worker and reconstruct everything in a fresh wasm64 worker from plain input data.

Do not reuse a PreparedProgram across variants. Do not move cached wrapper objects between workers. Persistent proving-key bytes may be portable when the SDK documents their serialization, but the live wrapper around those bytes is not.

A production selection pattern

Memory selection belongs before proof generation. A useful scheduler combines a per-function profile with runtime capability checks and a remote fallback.

typescript
import {
  loadNetwork,
  supportsThreads,
  supportsWasm64,
} from "@provablehq/sdk/dynamic.js";

type JobProfile = {
  estimatedPeakBytes: number;
  allowsRemoteProving: boolean;
};

type SelectedProver =
  | { kind: "local-wasm32"; sdk: Awaited<ReturnType<typeof loadNetwork>> }
  | { kind: "local-wasm64"; sdk: Awaited<ReturnType<typeof loadNetwork>> }
  | { kind: "remote" };

const WASM32_BUDGET = 3.25 * 1024 ** 3;

export async function selectProver(
  job: JobProfile,
): Promise<SelectedProver> {
  if (job.estimatedPeakBytes <= WASM32_BUDGET && supportsThreads()) {
    return {
      kind: "local-wasm32",
      sdk: await loadNetwork("mainnet", { variant: "wasm32" }),
    };
  }

  if (supportsThreads() && supportsWasm64()) {
    try {
      return {
        kind: "local-wasm64",
        sdk: await loadNetwork("mainnet", { variant: "wasm64" }),
      };
    } catch {
      // Continue to the explicit remote policy below.
    }
  }

  if (job.allowsRemoteProving) {
    return { kind: "remote" };
  }

  throw new Error("This proof cannot run in the current environment");
}

The 3.25 GiB threshold is an operator policy in this example. It leaves room below the 4 GiB wall for allocator fragmentation, thread stacks, temporary serialization, and variation between inputs. Measure your own functions before choosing a number.

A profile can start with circuit identity, observed peak memory, key state, and permitted concurrency. The Aleo Execution-Key Preflight Planner shows the same scheduling idea on the snarkVM side: inspect expensive requirements before accepting work.

Prepared processes complicate the estimate because warm caches change both latency and retained memory. Record cold and warm peaks separately. If several functions share one prepared process, budget for the largest retained baseline plus the largest temporary proof allocation that may overlap it.

SRS ownership matters too. Why Aleo Proving Keys Should Share the SRS Instead of Owning It explains how duplicate cryptographic material raises process memory. wasm64 gives those copies more address space, but does not make duplication free.

What developers should decide

Aleo applications now have four sensible proving lanes.

LaneBest fitCost
Local wasm32Common browser and Node workloadsBroad support and better speed, with a 4 GiB ceiling
Local wasm64Measured jobs that exceed wasm32 memoryNarrower runtime support and slower operations
Native RustControlled servers and heavy proving workersSeparate deployment stack, without browser portability
Delegated provingUnsupported clients or tightly constrained devicesThe prover sees private execution inputs

Privacy decides whether the final lane is acceptable. An authorization prevents a remote prover from changing the requested execution, but the prover still receives the inputs needed to produce the proof. Applications handling sensitive inputs need a trusted proving service, a user-controlled prover, or a clear refusal path.

Agents need the same boundaries as human-written clients. Give an agent a capability document containing the selected SDK variant, runtime version, isolation status, memory budget, concurrency limit, and remote-proving policy. Do not let it infer that a package called wasm64 works everywhere.

Before shipping, test unsupported browsers deliberately. Remove the isolation headers in staging. Run with @provablehq/wasm64 absent. Start two large jobs at once. Force wasm64 initialization to fail. Confirm that each case reaches the intended user-facing path rather than a generic RuntimeError.

Keep one SDK variant per worker, rebuild objects from serialized data, and select the proving lane before allocating cryptographic state. wasm64 is excellent when a real workload needs it. Treating it as a transparent upgrade turns an 8 GiB escape hatch into a deployment bug.