@cedoor/squid
v0.1.0
Published
Browser FHE client and Node evaluator over Squid. `@cedoor/squid/client` uses wasm; `@cedoor/squid/server` uses a napi-rs native addon.
Downloads
33
Readme
Squid JS
JavaScript bindings for Squid (ergonomic Rust wrapper for Poulpy FHE): a browser client (WebAssembly in a dedicated worker so keygen and crypto stay off the UI thread) and a Node evaluator (napi-rs). The client holds the secret key; the server only receives the evaluation key and ciphertexts.
Install
npm install @cedoor/squidUse pnpm add @cedoor/squid or yarn add @cedoor/squid if you prefer. The server entry point ships a native addon; install on the platform you run Node on.
Usage
Browser — import @cedoor/squid/client:
import { PoulpyClient } from "@cedoor/squid/client";
const client = await PoulpyClient.create({ paramsSet: "test" }); // or "unsecure" — must match the server
const ct = await client.encryptU32(42);
// Send `client.evaluationKey` and `ct` to the server; decrypt results with `await client.decryptU32(...)`.Node — import @cedoor/squid/server (native addon; not for bundlers targeting the browser):
import { Evaluator } from "@cedoor/squid/server";
const ev = Evaluator.load(evaluationKeyBytes, "test");
const sum = ev.addU32(ctA, ctB);The ./wasm/* export serves the built .wasm assets for hosting or custom init() URLs. Call init() only if you use the wasm Session on the main thread (no Worker); otherwise wasm loads inside the worker when you call PoulpyClient.create().
Build
Requires Rust (wasm-pack), and for the server target, a normal napi build environment.
pnpm run buildThis runs build:wasm, build:napi, and build:ts in order (emitting dist/squid-worker.js next to dist/client.js). Node ≥ 20 is required.
