{"_id":"@blueshift-gg/xark-wasm","_rev":"3-7427d714a05c2fe43f19d77320105a9f","name":"@blueshift-gg/xark-wasm","dist-tags":{"latest":"0.2.0"},"versions":{"0.0.0":{"name":"@blueshift-gg/xark-wasm","version":"0.0.0","license":"MIT","_id":"@blueshift-gg/xark-wasm@0.0.0","maintainers":[{"name":"deanmlittle","email":"hi@deanlittle.com"},{"name":"jyezy","email":"webjyezy@gmail.com"},{"name":"dhkl","email":"david@davidslab.com"}],"homepage":"https://github.com/blueshift-gg/xark#readme","bugs":{"url":"https://github.com/blueshift-gg/xark/issues"},"dist":{"shasum":"1a2f646bc1421316ea85283428c2e20f77cce8c0","tarball":"https://registry.npmjs.org/@blueshift-gg/xark-wasm/-/xark-wasm-0.0.0.tgz","fileCount":14,"integrity":"sha512-48csbg3UVXby5TX1tz2uhvhX/0I8F5S3DRLO6sLa1+9upEjDmSaRKMMAR8U4zoMR+7OSOIrQ+xGEYfbCgAAoFg==","signatures":[{"sig":"MEUCIQC+DdqxRJUGPB4JAQpam/DtXiVLg19RfuzoZsDryI7JQgIgV1/KiDSOHxpMNvd7ls3GwtdsDpj//K6HSvSaQTprfg0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@blueshift-gg%2fxark-wasm@0.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":3240204},"main":"./dist/node/xark_wasm.js","types":"./dist/node/xark_wasm.d.ts","exports":{".":{"node":{"types":"./dist/node/xark_wasm.d.ts","default":"./dist/node/xark_wasm.js"},"browser":{"types":"./dist/web/xark_wasm.d.ts","default":"./dist/web/xark_wasm.js"},"default":{"types":"./dist/web/xark_wasm.d.ts","default":"./dist/web/xark_wasm.js"},"workerd":{"types":"./dist/module/xark_wasm.d.ts","default":"./dist/module/xark_wasm.js"}}},"gitHead":"81d3923110ef6918023d13549d056d5d5935ed4e","scripts":{"test":"node --test tests/wasm-smoke.test.cjs"},"_npmUser":{"name":"dhkl","email":"david@davidslab.com"},"repository":{"url":"git+https://github.com/blueshift-gg/xark.git","type":"git","directory":"crates/wasm"},"_npmVersion":"11.16.0","description":"Generate and verify **Groth16 (BN254) zero knowledge proofs** in the browser or other JavaScript environments with [xark](https://github.com/blueshift-gg/xark).","directories":{},"_nodeVersion":"24.18.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/xark-wasm_0.0.0_1784896516709_0.8841278100322374","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@blueshift-gg/xark-wasm","version":"0.1.0","license":"MIT","_id":"@blueshift-gg/xark-wasm@0.1.0","maintainers":[{"name":"deanmlittle","email":"hi@deanlittle.com"},{"name":"jyezy","email":"webjyezy@gmail.com"},{"name":"dhkl","email":"david@davidslab.com"}],"homepage":"https://github.com/blueshift-gg/xark#readme","bugs":{"url":"https://github.com/blueshift-gg/xark/issues"},"dist":{"shasum":"262907fa5b54c08528a24a8e9e0023519e18da70","tarball":"https://registry.npmjs.org/@blueshift-gg/xark-wasm/-/xark-wasm-0.1.0.tgz","fileCount":14,"integrity":"sha512-xo5BdLLYMmj84woL2EzxNJevoC3TAnNJVxu2hibLK2qAPAHWEbcay0hOL3DYlSjdEbaspU//qNAA3LPiFZtL6g==","signatures":[{"sig":"MEUCIC9W5FmQC3SyVolY4rWmYAYS4rK05va1J8Dmb+5PLYTCAiEA/LK2Tllxu/JbTuRTqT769izei4ydMGGLAcPRFrmKpJA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@blueshift-gg%2fxark-wasm@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":3240204},"main":"./dist/node/xark_wasm.js","types":"./dist/node/xark_wasm.d.ts","exports":{".":{"node":{"types":"./dist/node/xark_wasm.d.ts","default":"./dist/node/xark_wasm.js"},"browser":{"types":"./dist/web/xark_wasm.d.ts","default":"./dist/web/xark_wasm.js"},"default":{"types":"./dist/web/xark_wasm.d.ts","default":"./dist/web/xark_wasm.js"},"workerd":{"types":"./dist/module/xark_wasm.d.ts","default":"./dist/module/xark_wasm.js"}}},"gitHead":"39138167d3ddd8042e019985ec830586fd08cb23","scripts":{"test":"node --test tests/wasm-smoke.test.cjs"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:954ad1de-14da-409f-b86e-cfdbce583879"}},"repository":{"url":"git+https://github.com/blueshift-gg/xark.git","type":"git","directory":"crates/wasm"},"_npmVersion":"11.16.0","description":"Generate and verify **Groth16 (BN254) zero knowledge proofs** in the browser or other JavaScript environments with [xark](https://github.com/blueshift-gg/xark).","directories":{},"_nodeVersion":"24.18.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/xark-wasm_0.1.0_1784898694219_0.844213224632157","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@blueshift-gg/xark-wasm","version":"0.2.0","license":"MIT","repository":{"type":"git","url":"git+https://github.com/blueshift-gg/xark.git","directory":"crates/wasm"},"main":"./dist/node/xark_wasm.js","types":"./dist/node/xark_wasm.d.ts","scripts":{"test":"node --test tests/wasm-smoke.test.cjs"},"exports":{".":{"node":{"types":"./dist/node/xark_wasm.d.ts","default":"./dist/node/xark_wasm.js"},"workerd":{"types":"./dist/module/xark_wasm.d.ts","default":"./dist/module/xark_wasm.js"},"browser":{"types":"./dist/web/xark_wasm.d.ts","default":"./dist/web/xark_wasm.js"},"default":{"types":"./dist/web/xark_wasm.d.ts","default":"./dist/web/xark_wasm.js"}}},"gitHead":"788436d8136c9270a7076613b94c65b247270bd2","_id":"@blueshift-gg/xark-wasm@0.2.0","description":"Generate and verify **Groth16 (BN254) zero knowledge proofs** in the browser or other JavaScript environments with [xark](https://github.com/blueshift-gg/xark).","bugs":{"url":"https://github.com/blueshift-gg/xark/issues"},"homepage":"https://github.com/blueshift-gg/xark#readme","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-/0kdgnP66EuULlnhmubicZPFRR0xBZAKfWDWPHTXhSSTE0lHhbQsN7DEC4wsfuvfOrqhsTpZqvX+t1XdQdrFkA==","shasum":"28b9aae6540ac07b3d9c4c7e2b656dd45ac42e7f","tarball":"https://registry.npmjs.org/@blueshift-gg/xark-wasm/-/xark-wasm-0.2.0.tgz","fileCount":14,"unpackedSize":3238284,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@blueshift-gg%2fxark-wasm@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD3WjtZ/9wila+44WhFtXDN/wMTRY7hW9Yk5XkhZRfzGQIgFbj6QEFFjMyLLwDNc0GxNhphaVk14Y+px8oAVy0x+L4="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:954ad1de-14da-409f-b86e-cfdbce583879"}},"directories":{},"maintainers":[{"name":"deanmlittle","email":"hi@deanlittle.com"},{"name":"jyezy","email":"webjyezy@gmail.com"},{"name":"dhkl","email":"david@davidslab.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/xark-wasm_0.2.0_1784910791216_0.2802953410482176"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-24T12:35:16.576Z","modified":"2026-07-24T16:33:12.070Z","0.0.0":"2026-07-24T12:35:16.948Z","0.1.0":"2026-07-24T13:11:34.427Z","0.2.0":"2026-07-24T16:33:11.561Z"},"bugs":{"url":"https://github.com/blueshift-gg/xark/issues"},"license":"MIT","homepage":"https://github.com/blueshift-gg/xark#readme","repository":{"type":"git","url":"git+https://github.com/blueshift-gg/xark.git","directory":"crates/wasm"},"description":"Generate and verify **Groth16 (BN254) zero knowledge proofs** in the browser or other JavaScript environments with [xark](https://github.com/blueshift-gg/xark).","maintainers":[{"name":"deanmlittle","email":"hi@deanlittle.com"},{"name":"jyezy","email":"webjyezy@gmail.com"},{"name":"dhkl","email":"david@davidslab.com"}],"readme":"# xark-wasm\n\nGenerate and verify **Groth16 (BN254) zero knowledge proofs** in the browser\nor other JavaScript environments with [xark](https://github.com/blueshift-gg/xark).\n\n```js\nimport init, { prove, verify } from \"@blueshift-gg/xark-wasm\";\n\nawait init();\n\nconst [circuit, pk, vk] = await Promise.all([\n  fetch(\"/circuit/circuit.xbc\").then((r) => r.arrayBuffer()),\n  fetch(\"/circuit/pk.bin\").then((r) => r.arrayBuffer()),\n  fetch(\"/circuit/vk.bin\").then((r) => r.arrayBuffer()),\n]);\n\nconst { proof, publicInputs } = prove(circuit, pk, { secret: \"3\", result: \"27\" });\nverify(vk, proof, publicInputs); // true\n```\n\nRuns anywhere with Web Crypto: **browsers**, **Node 20+**, **Cloudflare Workers**,\n**Vercel Edge**, **Deno**. The circuit, proving/verifying keys, proof, and public\ninputs are all **binary** — only the witness inputs (a tiny `name → value` map)\ncross the boundary as a plain object. Every binary argument accepts a\n`Uint8Array` **or** an `ArrayBuffer`, so the result of `response.arrayBuffer()`\n(or a Node `Buffer`) can be passed straight in — no `new Uint8Array(...)` wrap.\n\n## Producing circuit artifacts\n\nBefore proving, you need the circuit bytecode and proving/verifying keys.\nProduce them with the `xark` CLI:\n\n```sh\nxark build    # → target/xark/<name>/circuit.xbc   (binary, self-contained)\nxark setup    # → target/xark/<name>/{pk.bin, vk.bin}\n```\n\n`circuit.xbc` is the single self-contained build artifact: it encodes both the\nsolver view (witness generation) and the backend view (the minimized R1CS the\nproving key is keyed to)\n\n## Usage\n\n### Browser\n\n```js\nimport init, { prove, verify } from \"@blueshift-gg/xark-wasm\";\n\nawait init();\n\nconst [circuit, pk, vk] = await Promise.all([\n  fetch(\"/circuit/circuit.xbc\").then((r) => r.arrayBuffer()),\n  fetch(\"/circuit/pk.bin\").then((r) => r.arrayBuffer()),\n  fetch(\"/circuit/vk.bin\").then((r) => r.arrayBuffer()),\n]);\n\nconst { proof, publicInputs } = prove(circuit, pk, { secret: \"3\", result: \"27\" });\n\nconsole.log(verify(vk, proof, publicInputs)); // true\n```\n\n### Node.js\n\nThe Node build does not require a separate `init()` step.\n\n```js\nimport { readFileSync } from \"node:fs\";\nimport { prove, verify } from \"@blueshift-gg/xark-wasm\";\n\n// `readFileSync` returns a Buffer, which is a Uint8Array — pass it straight in.\nconst xbc = readFileSync(\"examples/cube/target/xark/cube/circuit.xbc\");\nconst pk  = readFileSync(\"examples/cube/target/xark/cube/pk.bin\");\nconst vk  = readFileSync(\"examples/cube/target/xark/cube/vk.bin\");\n\nconst { proof, publicInputs } = prove(xbc, pk, { secret: \"3\", result: \"27\" });\n\nconsole.log(verify(vk, proof, publicInputs)); // true\n```\n\n### Performance optimization (preloading)\n\n`prove` re-expands the `.xbc` and re-minimizes the R1CS on every call. For\nrepeated proofs against the same circuit + key, parse them once with `preload`\nand call `prove_preloaded`:\n\n```js\npreload(circuit, pk);\nconst a = prove_preloaded({ secret: \"3\", result: \"27\" });\nconst b = prove_preloaded({ secret: \"2\", result: \"8\" });\n```\n\n## API\n\n### `prove(circuitXbc, pkBytes, inputs)`\n\nGenerates a Groth16 proof entirely in memory.\n\n| argument     | type                          | description                                           |\n|--------------|-------------------------------|-------------------------------------------------------|\n| `circuitXbc` | `Uint8Array` \\| `ArrayBuffer` | `circuit.xbc` (binary, self-contained build artifact) |\n| `pkBytes`    | `Uint8Array` \\| `ArrayBuffer` | Proving key (`pk.bin`, binary)                        |\n| `inputs`     | `object`                      | Witness values as `{ name: \"value\" }`                 |\n\nReturns a `ProofBundle`:\n\n| field             | type         |\n|-------------------|--------------|\n| `proof`           | `Uint8Array` |\n| `publicInputs`    | `Uint8Array` |\n| `numPublicInputs` | `number`     |\n\nInput values are **decimal strings** (`\"3\"`, `\"-7\"`), keyed by the circuit's\ndeclared input names. Throws on a malformed `.xbc`, unknown input, unsatisfiable\nwitness, or malformed key.\n\n`proof` and `publicInputs` are the canonical compressed bytes (identical to the\nhost's `proof.bin` / `public_inputs.bin`) — pass them straight to `verify`. For\nsnarkjs interop, convert them on demand (see `proof_to_snarkjs` below).\n\n> `prove` does **not** self-verify. Call `verify` on the result if you want\n> that check.\n\n### `preload(circuitXbc, pkBytes)`\n\nParse + cache the `.xbc` and proving key once (replaces prior cached state).\n\n### `prove_preloaded(inputs)`\n\nLike `prove` but reuses the artifacts cached by `preload`. Throws if `preload`\nhasn't been called.\n\n### `verify(vkBytes, proofBytes, publicInputsBytes)`\n\n| argument            | type                          |\n|---------------------|-------------------------------|\n| `vkBytes`           | `Uint8Array` \\| `ArrayBuffer` |\n| `proofBytes`        | `Uint8Array` \\| `ArrayBuffer` |\n| `publicInputsBytes` | `Uint8Array` \\| `ArrayBuffer` |\n\nReturns `true` if valid, `false` if well-formed but not verifying. Throws on\ndeserialization errors.\n\n### `proof_to_snarkjs(proofBytes)` → `object`\n\nConverts the `proof` `Uint8Array` from `prove()` into the snarkjs proof object.\n\n### `public_inputs_to_snarkjs(publicInputsBytes)` → `string[]`\n\nConverts the `publicInputs` `Uint8Array` from `prove()` into the snarkjs\n`public.json` array of decimal strings.\n\n```js\nconst { proof, publicInputs } = prove(xbc, pk, { secret: \"3\", result: \"27\" });\nconst snarkjsProof  = proof_to_snarkjs(proof);\nconst snarkjsPublic = public_inputs_to_snarkjs(publicInputs);\n```\n\n## Security\n\nProver randomness comes from the platform CSPRNG (`crypto.getRandomValues`).\n\n## Build\n\n```sh\ncargo install wasm-pack\nrustup target add wasm32-unknown-unknown\n./build.sh                 # default target: bundler (webpack, vite, …)\n./build.sh web             # or: nodejs | bundler | module\n```\n\nThe `module` target (Cloudflare Workers / `workerd`) is built with\n`wasm-bindgen` directly, since wasm-pack can't emit `--target module`. A\n`release` build of the `module` target will **also rebuild `dist/bundler/`**\nand copies its optimized wasm (the raw wasm is byte-identical across targets —\nonly the JS glue differs).\n","readmeFilename":"README.md"}