@kashscript/identity-zkp
v0.2.2
Published
Zero-knowledge primitives for did:kash — selective disclosure via Merkle commitments, plus a Web Worker-dispatched prover/verifier for Groth16 / PLONK circuits.
Readme
@kashscript/identity-zkp
Zero-knowledge primitives for
did:kash. Selective disclosure via Merkle commitments + a Web-Worker-dispatched prover/verifier for Groth16 / PLONK circuits.
⚠ Partial Schedule B. The Merkle / selective-disclosure layer is permissive. The SNARK prover is a Commercial component requiring a paid Plan for Production Use. See LICENSE.
bun add @kashscript/identity-zkp @kashscript/identity-core
# optional: snarkjs as a peer dep for the prover
bun add snarkjsTwo layers, two licences
| Layer | Licence | Purpose | |---------------------------------|---------------|------------------------------------------------------| | Selective disclosure (Merkle) | Permissive | Prove one field of a DID Document without revealing the rest | | SNARK prover (Groth16 / PLONK) | Commercial | Generate succinct proofs of arbitrary predicates over identity data |
Most apps need only the Merkle layer; the SNARK prover is for compliance attestations, age-gating, KYC-once-prove-many flows, and similar high-assurance use cases.
Quickstart — selective disclosure
import { commitDocument, openCommitment } from "@kashscript/identity-zkp/disclosure";
// Holder: commit to the full DID Document, share only the commitment
const commitment = commitDocument(myDidDocument);
// Verifier: ask for a specific field
const proof = openCommitment(myDidDocument, commitment, ["country"]);
// Verifier: verify just that field
const ok = verifyOpening(commitment, proof); // true iff country was in the original docThe verifier learns only the requested field + a proof of inclusion in the original document — nothing about any other field.
Quickstart — SNARK proving (Commercial)
import { Worker } from "node:worker_threads";
import { ProverClient } from "@kashscript/identity-zkp/prover";
const prover = new ProverClient({
worker: new Worker(new URL("@kashscript/identity-zkp/worker", import.meta.url)),
});
const proof = await prover.prove("age-over-18", { dob: "1992-05-14" });The worker dispatch is mandatory: SNARK proving is CPU-expensive and
must not block the main thread. The worker uses snarkjs under the
hood (peer dep, optional install).
What's in the box
| Subpath | Purpose |
|----------------------------------------|----------------------------------------------------|
| @kashscript/identity-zkp | Default — re-exports Merkle + prover |
| @kashscript/identity-zkp/merkle | Merkle tree primitives |
| @kashscript/identity-zkp/disclosure | Selective-disclosure commit / open / verify |
| @kashscript/identity-zkp/prover | SNARK prover client (Commercial) |
| @kashscript/identity-zkp/verifier | SNARK verifier — permissive |
| @kashscript/identity-zkp/worker | Web-Worker entry point for the prover |
| @kashscript/identity-zkp/circuits | Bundled circuits (age-over-18, country-in-set, …) |
| @kashscript/identity-zkp/errors | Typed error classes |
Licensing
See LICENSE. The licence file inlines the SSLA Schedule B terms that apply to the SNARK prover. The Merkle layer is at-least-as- permissive as Apache-2.0.
