With the ZKEmail SDK you can create proofs about emails using blueprints. You can create blueprints with this SDK (documentation pending), or using our registry.
The SDK works for all JavaScript environments. You can find examples for server-side (Node, Deno, Bun) and client-side (Vite, Next.js) usage here.
To install run:
npm i @zk-email/sdk
Go to our registry and create a blueprint there. You can also create one with the SDK, we will provide the documentation for this shortly.
Initialize the SDK:
import zkeSdk from "@zk-email/sdk";
const sdk = zkSdk();
Next, obtain the slug of the blueprint you want to create a proof for from our registry.
Use the slug to get the blueprint:
const blueprint = await sdk.getBlueprint("Bisht13/SuccinctZKResidencyInvite@v2");
Create a prover. Here you can define whether the proof should be generated remotely (faster)
or in the browser (slower but private).
Set isLocal
to true
for proving in the browser.
const prover = blueprint.createProver({ isLocal: true });
Now pass the email as a string
to the prover to generate a proof.
If your blueprint requires external inputs, pass them as a second argument.
You can check out our Next.js example to see how a user can locally upload an email file.
// 2. argument, externalInputs is only required if defined in the blueprint
const proof = await prover.generateProof(emailStr, [
{ name: "email", value: "a@b.de", maxLength: 50 },
]);
console.log("Proof data: ", proof.props.proofData);
console.log("Public data: ", proof.props.publicData);
You can also verify the proof on chain. We currently use a contract deployed to Base Sepolia for this.
const isVerified = await blueprint.verifyProofOnChain(proof);