Prove membership in one of up to four groups with scoped nullifiers and signal binding. UltraHonk's mode is designed to be zero-knowledge; this is experimental cryptography, and the package README states that Noir is not yet for production use.
Install the package from npm. It needs Node 22.13 or later, or a bundler for browser entry points.
ShellInstall
npm install @toip-tools/anon-membership
Runtime: Node and browsers, proving in a Web Worker. Proving takes about 0.15 s on an Apple M1 Max; phones aren't measured.
TypeScriptImport
import { GroupIssuer, enroll, ENROLL } from "@toip-tools/anon-membership";
Usage
Enroll members and publish signed roots
Await initHashing() before constructing trees or computing membership hashes. Create a GroupIssuer, register its admission callback with serve, and let members derive a per-group memberSecret and call enroll. Publish a signed root and snapshot once per epoch after enrollment changes. Enrollment after an epoch's publication becomes usable under a later published root.
Rebuild a snapshot with treeFromRoot, then call membershipInputs with the member secret, ordered groups, verifier-agreed scope and signal, current day, and any required leaf fields/predicates. Reuse a MembershipProver from create() for successive prove calls. In a browser, use the /worker entry's MembershipWorkerClient and serveMembershipWorker to keep proving off the page thread.
Create a MembershipVerifier with accepted artifacts. Call acceptMembership with pinned group issuers and verification-key hashes, verified-policy settings, fetched root logs, and a scope/signal you computed independently. It checks root history, freshness, anonymity-set size, statement, and proof. After acceptance, use NullifierBook.has/label for duplicate or rate-limit handling; acceptance itself does not record nullifier use.
Reuse warmed prover/verifier instances and await their destroy() methods when finished to free Barretenberg resources. For a worker client, await destroy() to free its backends and terminate the worker. Browser threading depends on cross-origin isolation; otherwise proving uses one thread.
Persist GroupIssuer.state(), member secrets and recorded leaf fields, root logs, snapshots, and NullifierBook.state() where continuity matters. The issuer defaults to retaining 30 recent snapshots; its state also contains member DIDs and commitments and needs access controls.
The bundled CRS avoids third-party CRS downloads at proving time; artifacts still need to be packaged and served by the app. Pin verification keys out of band. Changing a circuit or acceptance policy requires coordinating member and verifier inputs.
Error handling
MembershipError
membershipInputs or prove throws when the member is absent or the witness fails membership, validity, predicates, or rate-limit constraints.
Check the published snapshot, enrollment leaf fields, current day, and message index. Refresh membership data rather than retrying the same unsatisfiable witness.
Low-level MembershipVerifier.verify returns ok: false for proof shape, unpinned artifact identity, an unexpected statement, or failed cryptographic verification.
Reject the proof and preserve the reason for diagnostics. Do not replace a pinned key or expected statement with values supplied by the prover.
Acceptance: stale / tooSmall / scope / signal / equivocation
acceptMembership can reject a cryptographically valid proof on policy grounds. equivocation includes two conflicting signed roots as evidence.
Refresh roots for staleness, require the configured minimum set size, and recompute context locally. Preserve equivocation evidence and refuse that acceptance; use the full AcceptReason union for remaining failures.
Limitations
Selective disclosure of individual credential fields (BBS+, SD-JWT). This is group membership only.
API reference
Choose an entry point for the complete export list. Each export has a reference page with its signature, parameter types, return type, fields, and public methods where applicable.