{"_id":"@brave/poprf-ristretto-wasm","name":"@brave/poprf-ristretto-wasm","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@brave/poprf-ristretto-wasm","type":"module","description":"wasm-bindgen bindings for poprf-ristretto (RFC 9497 POPRF / ristretto255-SHA512)","version":"0.1.0","license":"MIT OR Apache-2.0","repository":{"type":"git","url":"git+https://github.com/brave/poprf-ristretto.git"},"main":"poprf_ristretto_wasm.js","homepage":"https://github.com/brave/poprf-ristretto","types":"poprf_ristretto_wasm.d.ts","sideEffects":["./snippets/*"],"keywords":["poprf","rfc9497","ristretto255","wasm","crypto"],"_id":"@brave/poprf-ristretto-wasm@0.1.0","bugs":{"url":"https://github.com/brave/poprf-ristretto/issues"},"_integrity":"sha512-nyP//rvO70LNPFuWLGIz0YRCK8Fn+c5tZ0CSxK+NeRGcXhWathr+hHFD+CyOrqrV/64SYXVL2htKaGoq2XKlgQ==","_resolved":"/Users/sofiaceli/code/poprf-ristretto-search/poprf-ristretto-wasm/pkg/brave-poprf-ristretto-wasm-0.1.0.tgz","_from":"file:brave-poprf-ristretto-wasm-0.1.0.tgz","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-nyP//rvO70LNPFuWLGIz0YRCK8Fn+c5tZ0CSxK+NeRGcXhWathr+hHFD+CyOrqrV/64SYXVL2htKaGoq2XKlgQ==","shasum":"050f161076db2e571fa9464c910182c448fad083","tarball":"https://registry.npmjs.org/@brave/poprf-ristretto-wasm/-/poprf-ristretto-wasm-0.1.0.tgz","fileCount":7,"unpackedSize":182031,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCeJjzw3C36DLM+W7gZ282aHIW37bT0yfViSvjUcjfu9AIgXeBY7vtRFh7GPfIMMFszGvBr1i1uf/lR1eJ6vYqxd24="}]},"_npmUser":{"name":"claucece9","email":"sceli@brave.com"},"directories":{},"maintainers":[{"name":"bcrypt","email":"yan@mit.edu"},{"name":"brianbondy","email":"bbondy@gmail.com"},{"name":"brave.com","email":"devops@brave.com"},{"name":"darkdh","email":"darkdh@gmail.com"},{"name":"mrose17","email":"mrose17@gmail.com"},{"name":"petemill","email":"miller.pete+npm@gmail.com"},{"name":"claucece9","email":"sceli@brave.com"},{"name":"pes10k","email":"pes@peteresnyder.com"},{"name":"jonathansampson","email":"jjdsampson@gmail.com"},{"name":"antonok","email":"alazarev@brave.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/poprf-ristretto-wasm_0.1.0_1781805763791_0.253675514296158"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-18T18:02:43.606Z","0.1.0":"2026-06-18T18:02:44.005Z","modified":"2026-06-18T18:02:44.522Z"},"maintainers":[{"name":"bcrypt","email":"yan@mit.edu"},{"name":"brianbondy","email":"bbondy@gmail.com"},{"name":"brave.com","email":"devops@brave.com"},{"name":"darkdh","email":"darkdh@gmail.com"},{"name":"mrose17","email":"mrose17@gmail.com"},{"name":"petemill","email":"miller.pete+npm@gmail.com"},{"name":"claucece9","email":"sceli@brave.com"},{"name":"pes10k","email":"pes@peteresnyder.com"},{"name":"jonathansampson","email":"jjdsampson@gmail.com"},{"name":"antonok","email":"alazarev@brave.com"}],"description":"wasm-bindgen bindings for poprf-ristretto (RFC 9497 POPRF / ristretto255-SHA512)","homepage":"https://github.com/brave/poprf-ristretto","keywords":["poprf","rfc9497","ristretto255","wasm","crypto"],"repository":{"type":"git","url":"git+https://github.com/brave/poprf-ristretto.git"},"bugs":{"url":"https://github.com/brave/poprf-ristretto/issues"},"license":"MIT OR Apache-2.0","readme":"# poprf-ristretto-wasm\n\n[![License](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](#license)\n\n`wasm-bindgen` bindings for [`poprf-ristretto`](../poprf-ristretto) —\nthe RFC 9497 POPRF over `ristretto255-SHA512`. Use from a browser,\nNode.js, or any JavaScript runtime by building with [`wasm-pack`].\n\n[`wasm-pack`]: https://rustwasm.github.io/wasm-pack/\n\n## API\n\n**Client-side batched** POPRF operations — two free functions:\n\n| JS name | Direction |\n|---------|-----------|\n| `blindBatch(publicKeyB64, inputs, info)` | client blind |\n| `finalizeBatch(publicKeyB64, inputs, states, blindedMessages, evaluatedElements, proof, info)` | proof verify + unblind |\n\nWire-format bytes are passed as base64 strings; per-token preimages and\n`info` are `Uint8Array` / raw bytes. Errors are thrown as JS `Error`s.\n\nServer-side operations (key generation, `BlindEvaluate`, offline\n`Evaluate`) are not exposed; use\n[`poprf-ristretto-ffi`](../poprf-ristretto-ffi) (C ABI) or the core\n[`poprf-ristretto`](../poprf-ristretto) Rust crate on the server.\n\n## Build\n\n```sh\nrustup target add wasm32-unknown-unknown\ncargo install wasm-pack\n```\n\nFrom the workspace root:\n\n```sh\nmake wasm         # wasm-pack build --target web     → poprf-ristretto-wasm/pkg/\nmake wasm-nodejs  # wasm-pack build --target nodejs  → poprf-ristretto-wasm/pkg-node/\n```\n\nEach output directory contains `package.json`, JS glue, TypeScript\ndeclarations, and the `.wasm` binary, importable as a local package.\n\nThe wasm crate depends on `poprf-ristretto` with `default-features =\nfalse` plus `[\"std\", \"fast-dleq\"]`; the core crate's\n`precomputed-tables` feature is **not** enabled, keeping the wasm\nbinary smaller at the cost of slower base-point scalar multiplication.\nEdit [`Cargo.toml`](./Cargo.toml) to add it back if size is not a\nconcern.\n\n## Usage\n\n### Browser / bundler\n\nAfter `make wasm`, import from the generated `pkg/` directory:\n\n```js\nimport init, { blindBatch, finalizeBatch } from \"./pkg/poprf_ristretto_wasm.js\";\n\nawait init();\n\nconst info  = new TextEncoder().encode(\"example-context\");\nconst input = new TextEncoder().encode(\"user-identifier\");\n\n// 1) Blind one or more inputs.\nconst { states, blindedMessages } = blindBatch(\n  serverPublicKeyB64,\n  [input],\n  info,\n);\n\n// 2) Send `blindedMessages[i]` to the server. The server returns\n//    `evaluatedElements[i]` (base64) and a single batched DLEQ `proof`.\n\n// 3) Verify the proof and unblind.\nconst outputs = finalizeBatch(\n  serverPublicKeyB64,\n  [input],\n  states,\n  blindedMessages,\n  evaluatedElements,\n  proof,\n  info,\n);\n// outputs[i] is the base64-encoded 64-byte POPRF output for input i.\n```\n\n`init()` (the default export) fetches and instantiates the `.wasm`\nbinary. A synchronous variant `initSync({ module: wasmBytes })` is also\nexported for environments where the bytes are already in memory.\n\n### Node.js\n\nAfter `make wasm-nodejs`, require from the generated `pkg-node/` directory:\n\n```js\nconst { blindBatch, finalizeBatch } = require(\"./pkg-node/poprf_ristretto_wasm.js\");\n// no init() call needed for the nodejs target\n```\n\n## Troubleshooting\n\n### `wasm-bindgen` CLI version pinning\n\nThe `wasm-bindgen` CLI must match the `wasm-bindgen` crate version pinned\nin `Cargo.lock`. A mismatch causes `wasm-pack` to fail with\n\"`error: failed to generate bindings`\". Install the CLI at the exact\npinned version:\n\n```sh\nWBVER=$(grep -A1 'name = \"wasm-bindgen\"' Cargo.lock | grep version | head -1 | sed 's/.*= \"//;s/\"//')\ncargo install wasm-bindgen-cli --version \"$WBVER\" --force\n```\n\n### `+reference-types` rustflag\n\n`wasm-bindgen` ≥ 0.2.100 requires the WebAssembly **reference-types**\nproposal so it can emit its externref table management functions\n(`__externref_table_alloc` / `__externref_table_dealloc`). Without this\nthe linker dead-code-eliminates those symbols and the build fails with:\n\n```\nerror: failed to find the __wbindgen_externref_table_dealloc function\n```\n\nThe flag is set in this workspace's `.cargo/config.toml`. If you build\nthis crate from a **parent** workspace that also sets\n`[build] rustflags = ...`, mirror the override there:\n\n```toml\n[target.wasm32-unknown-unknown]\nrustflags = [\"-C\", \"target-feature=+reference-types\"]\n```\n\n## License\n\nLicensed under either of [Apache-2.0](./LICENSE-APACHE) or\n[MIT](./LICENSE-MIT) at your option.\n","readmeFilename":"README.md","_rev":"1-f3f57f8b6f2d9432ab83f84851bba6df"}