Skip to content

zkemail/zk-email-sdk-js

Repository files navigation

ZKEmail SDK

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.

Install

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

Create a blueprint

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.

Generate a proof

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.

Copy Slug

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: "[email protected]", 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);

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •