> For the complete documentation index, see [llms.txt](https://zka-protocol.gitbook.io/zka-protocol-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zka-protocol.gitbook.io/zka-protocol-docs/developer/installation.md).

# Installation

This section explains how to install the ZKAP development environment, including the SDK, core libraries, and tooling required to build encrypted frames, generate proofs, and interact with the ZKAP Validator.

ZKAP is designed to integrate easily with existing blockchain applications.\
You do not need a new blockchain, VM, or specialized infrastructure — the SDK works directly in Node.js or any agent runtime.

***

### 1. System Requirements

To develop with ZKAP, you need:

* Node.js (v18+ recommended)
* npm or yarn
* A compatible ZK proof backend (Groth16, Plonk, Halo2, or STARK-based)
* A running blockchain RPC endpoint (local or public)
* Access to the ZKAP circuits and proving keys

Optional tools:

* Docker (for isolated environments)
* Circom or other custom ZK circuit compilers
* pnpm for monorepo setups
* WebAssembly support if generating proofs client-side

***

### 2. Install the ZKAP TypeScript SDK

The ZKAP SDK provides utilities for:

* generating anonymous identities
* encoding and encrypting payloads
* generating zero-knowledge proofs
* constructing ZKAP Frames
* submitting frames to the validator contract
* decrypting anonymous events

Install via npm:

```
npm install @zkap/sdk
```

or Yarn:

```
yarn add @zkap/sdk
```

or pnpm:

```
pnpm add @zkap/sdk
```

Once installed, you can import the SDK:

```
import {
generateIdentity,
encryptPayload,
generateProof,
buildFrame
} from "@zkap/sdk";
```

***

### 3. Install a ZK Proof Backend

Depending on your environment, you will need a proof generation backend.

#### Option A — Groth16 (fastest, lowest cost)

```
npm install snarkjs
```

#### Option B — Plonk

```
npm install @zk-kit/plonk
```

#### Option C — Halo2 or STARKs

Implemented via native bindings or WASM depending on the project.

The SDK can be configured to use any of these.

***

### 4. Install the ZKAP Validator Contract Package

If developing in Solidity:

```
npm install @zkap/contracts
```

This package includes:

* ZKAP Validator contract
* interfaces
* event definitions
* ABI files

It can be imported into Hardhat, Foundry, or any EVM framework.

***

### 5. Recommended Tools for Development

#### For EVM developers:

* Hardhat
* Foundry (Forge/Anvil for testing)
* Ethers.js or Viem for RPC calls
* Typescript for SDK integration

#### For Agent developers:

* Node.js
* Secure key management
* Encryption modules
* Event listeners or task schedulers

#### For ZK developers:

* Circom / Noir / Halo2 compiler
* SnarkJS or Plonk toolkits
* WASM runners

***

### 6. Setting up a Local Development Environment

Step 1: Clone or install the SDK\
Step 2: Install your chosen ZK backend\
Step 3: Download proving keys (if required)\
Step 4: Deploy the ZKAP Validator contract locally\
Step 5: Configure your app to listen to validator events\
Step 6: Begin sending encrypted frames for testing

A typical dev environment uses:

* Anvil (Foundry) as a local EVM node
* The ZKAP Validator deployed to Anvil
* The SDK generating frames and proofs against that network

***

### 7. Example Project Setup

1. Create a new project:

```
mkdir zkap-demo
cd zkap-demo
npm init -y
```

2. Install dependencies:

```
npm install @zkap/sdk snarkjs ethers
```

3. Write a simple script to generate and submit a frame:

<pre><code>import { buildFrame } from "@zkap/sdk";
import { ethers } from "ethers";

<strong>(async () => {
</strong>const frame = await buildFrame({ action: "ping" });
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const contract = new ethers.Contract(VALIDATOR_ADDRESS, ABI, provider);
await contract.submitFrame(frame);
})();
</code></pre>

***

### 8. Troubleshooting Common Issues

* Proof generation slow → enable WASM backend
* Invalid proof error → mismatch between circuit + proving key
* Contract rejects frame → nullifier already used
* Expiry validation failed → expiry too low
* Decryption fails → incorrect application key setup

The SDK provides detailed error messages to help with debugging.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://zka-protocol.gitbook.io/zka-protocol-docs/developer/installation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
