@0xcurvy/rs-core-wasm

中文文档
0.1.5发布于 2026/11/06MITTypeScriptES Module零依赖近 30 天下载 2016

Browser WebAssembly builds of the Curvy Rust core and Groth16 prover

原始使用文档
文档目录5 节
  1. Entry points
  2. Bundler setup
  3. Threads
  4. Node
  5. Versioning

@0xcurvy/rs-core-wasm

Browser WebAssembly builds of the Curvy Rust core - stealth-address crypto (Poseidon, BabyJubjub/EdDSA, the note cipher, Merkle state, scanning) and the Groth16 prover.

Generated with wasm-bindgen --target web from a tagged rs-core release and published unmodified. The Rust crates are on crates.io (curvy-core, curvy-witness, curvy-prover, curvy-wasm).

Most applications should use @0xcurvy/curvy-sdk instead of consuming these bindings directly.

Entry points

SubpathBuildNotes
@0xcurvy/rs-core-wasm/coresingle-threadedcrypto core; works everywhere
@0xcurvy/rs-core-wasm/core-threadsRayonrequires cross-origin isolation
@0xcurvy/rs-core-wasm/proversingle-threadedwitness + Groth16
@0xcurvy/rs-core-wasm/prover-threadsRayonrequires cross-origin isolation

Each entry also exports its raw binary (@0xcurvy/rs-core-wasm/core/curvy_wasm_bg.wasm) for ?url-style imports and for Node.

import init, { poseidon } from "@0xcurvy/rs-core-wasm/core";

await init(); // resolves curvy_wasm_bg.wasm relative to this module

Both prover entries load a proving key from a snarkjs .zkey or a compact .czkey (curvy-prover's compact zkeys). new WasmResidentProver(zkey, zkeySha256, graph, graphSha256) tells them apart by their first bytes; zkeySha256 is the SHA-256 of the file passed, whichever it is. A compact key is about a quarter of the size and costs about 3 s more to load single-threaded for a 40 MB key.

The witness graph is a SIGNET artifact (SIGNET01 or CVYWIT01) at body version 1 or 2, raw or zstd-compressed; graphSha256 is the SHA-256 of the bytes passed. Version 2 (signet transcode) computes the same witness as version 1 in a smaller file. Version 2 needs 0.1.5 or later; earlier releases refuse it with "unsupported witness graph format version 2".

Bundler setup

The generated glue locates its binary with new URL('curvy_wasm_bg.wasm', import.meta.url), and the threaded builds spawn their Rayon workers with new Worker(new URL('./workerHelpers.js', import.meta.url), { type: 'module' }). Both require the files to stay where they are in the package.

Vite - exclude this package from dependency pre-bundling, which moves the code to node_modules/.vite/deps/ and breaks those relative URLs:

export default defineConfig({
  optimizeDeps: { exclude: ["@0xcurvy/rs-core-wasm"] },
});

webpack 5 resolves both patterns; no configuration is needed.

For other bundlers, pass the binary in yourself - init({ module_or_path: url }) accepts a URL, a Response, bytes, or a compiled WebAssembly.Module.

Threads

The *-threads entries are built with atomics and shared memory. They need a cross-origin-isolated page:

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

or, where third-party embeds must keep working, Document-Isolation-Policy: isolate-and-credentialless. Call initThreadPool(n) after init(). Feature-detect with crossOriginIsolated and fall back to the single-threaded entry - the two expose the same API.

The threaded entries do not run on Safari releases with WebKit bug 303387, such as Safari 26.2, or in any iOS browser built on such a release: initThreadPool rejects, or a later threaded call throws, RuntimeError: Out of bounds memory access. Safari 26.5 and 27.0.1 run them. When that error occurs, use the single-threaded entry.

Node

fetch cannot read file: URLs, so pass the bytes explicitly:

import { readFile } from "node:fs/promises";
import init from "@0xcurvy/rs-core-wasm/core";

const wasm = await readFile(
  new URL(import.meta.resolve("@0xcurvy/rs-core-wasm/core/curvy_wasm_bg.wasm")),
);
await init({ module_or_path: wasm });

Versioning

@0xcurvy/[email protected] is built from tag vx.y.z of rs-core, and all four entries come from that single commit.

Licensed MIT. See THIRD-PARTY-NOTICES.md for the dependencies compiled into the binaries.

版本与发布记录

@0xcurvy/rs-core-wasm 共发布 9 个版本,首次发布于 2026/08/04;过去 12 个月发布了 9 个版本。

版本发布日期距今
0.1.5latest2026/11/061 天前
0.1.42026/10/2810 天前
0.1.22026/10/1622 天前
0.1.12026/10/0830 天前
0.1.0-rc.7rc2026/10/0830 天前
0.1.0-rc.52026/08/172 个月前

关于 @0xcurvy/rs-core-wasm 的常见问题

@0xcurvy/rs-core-wasm 是什么?

Browser WebAssembly builds of the Curvy Rust core and Groth16 prover

如何安装 @0xcurvy/rs-core-wasm?

在项目目录运行 npm install @0xcurvy/rs-core-wasm,或使用 pnpm add / yarn add / bun add。

@0xcurvy/rs-core-wasm 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@0xcurvy/rs-core-wasm 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@0xcurvy/rs-core-wasm 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@0xcurvy/rs-core-wasm 可以商用吗?

@0xcurvy/rs-core-wasm 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@0xcurvy/rs-core-wasm 的下载量有多少?

根据 npm 官方下载统计,@0xcurvy/rs-core-wasm 在 2026/10/04 – 2026/11/02 这 30 天内被下载 2,016 次,日均约 67 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@0xcurvy/rs-core-wasm 还在维护吗?

最新版本 0.1.5 发布于 2026/11/06(1 天前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/08/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。