Skip to content

Installation

Package Manager

bash
npm install @zkprivacy/sdk
bash
yarn add @zkprivacy/sdk
bash
pnpm add @zkprivacy/sdk

Bundle Options

The SDK offers two import paths:

Full SDK (~2MB)

For complete wallets with transfer and unshield capabilities:

typescript
import { PrivacyClient, createProver } from '@zkprivacy/sdk';

Includes:

  • PrivacyClient - Full privacy client
  • Prover - ZK proof generation (NoirJS + bb.js)
  • Shield utilities
  • Key management

Shield Only (~150KB)

For deposit widgets that don't need proof generation:

typescript
import { shieldTo } from '@zkprivacy/sdk/shield';

Includes:

  • shieldTo() - Direct deposits
  • encryptNoteForRecipient() - Note encryption
  • Address utilities

Peer Dependencies

The SDK requires viem for blockchain interaction:

bash
npm install viem

TypeScript

The SDK is written in TypeScript and includes type definitions. No additional @types/* packages needed.

json
// tsconfig.json
{
  "compilerOptions": {
    "moduleResolution": "bundler", // or "node16"
    "target": "ES2020"
  }
}

Framework Setup

Vite

Add WASM support to your Vite config:

typescript
// vite.config.ts
export default defineConfig({
  optimizeDeps: {
    exclude: ['@aztec/bb.js']
  },
  assetsInclude: ['**/*.wasm']
});

Next.js

For Next.js, you need to handle WASM files:

javascript
// next.config.js
module.exports = {
  webpack: (config) => {
    config.experiments = { ...config.experiments, asyncWebAssembly: true };
    return config;
  }
};

Node.js

For Node.js scripts, add the WebSocket polyfill:

typescript
import WebSocket from 'ws';
(globalThis as any).WebSocket = WebSocket;

Circuit Files

The prover needs circuit artifacts. Host these on your server:

  1. Download from the deployed app: https://devtools.zkprivacy.dev/circuits/
  2. Or build from source: just build-circuits

Required files:

  • transfer.json (~500KB)
  • unshield.json (~400KB)

Place in your public/circuits/ folder.

Verify Installation

typescript
import { DEPLOYMENTS } from '@zkprivacy/sdk';

console.log('Pool address:', DEPLOYMENTS.remote.pool);
// Should print: 0x...

Next Steps

Continue to Quick Start to create your first private transaction.

Released under the MIT License.