@zk-email/sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.93 • Public • Published

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: "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);

Readme

Keywords

Package Sidebar

Install

npm i @zk-email/sdk

Weekly Downloads

258

Version

0.0.93

License

MIT

Unpacked Size

26 MB

Total Files

33

Last publish

Collaborators

  • sora_suegami
  • johnguilding
  • metachaser
  • jp4g
  • dimidumo
  • shreyas-londhe
  • shinanonozenji
  • bisht13
  • atheartengineer
  • saleel
  • yushg
  • wryonik
  • zkfriendly
  • javiersuweijie