Package Exports
- ava-zk
- ava-zk/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ava-zk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ava-zk
Cross-chain ZK proof system using Circom, snarkjs, and Solidity smart contracts with Teleporter bridge integration for Avalanche subnets.
Overview
This package provides a complete workflow for generating zero-knowledge proofs with Circom circuits and sending them cross-chain between Avalanche subnets using the Teleporter bridge.
Installation
npm install ava-zkPrerequisites
Make sure you have the following tools installed:
- Circom - Circuit compiler
- Foundry - Ethereum development toolkit (forge, cast)
- Python 3 - For proof data parsing
- Node.js >= 16.0.0
Environment Setup
Create a .env file in your project root:
PRIVATE_KEY=your_private_key_without_0x_prefix
CHAIN1_RPC_URL=https://subnets.avax.network/dispatch/testnet/rpc
CHAIN2_RPC_URL=https://api.avax-test.network/ext/bc/C/rpc
TELEPORTER_MESSENGER_CHAIN1=0x253b2784c75e510dD0fF1da844684a1aC0aa5fcf
TELEPORTER_MESSENGER_CHAIN2=0x253b2784c75e510dD0fF1da844684a1aC0aa5fcfUsage
The workflow consists of 4 simple commands:
1. Compile Circuit & Generate Proof
npm run compileThis command:
- Compiles the Circom circuit (
multiplier2.circom) - Sets up the trusted ceremony (Powers of Tau)
- Generates ZK proof from
input.json - Creates Solidity verifier contract
- Outputs
proof.json,public.json, and verification files
2. Deploy Contracts
npm run deployThis command:
- Deploys
Groth16Verifiercontracts on both chains - Deploys
ZKProofSenderon Chain 1 (Dispatch Testnet) - Deploys
ZKProofReceiveron Chain 2 (Avalanche Fuji) - Logs all contract addresses for reference
3. Send Proof Cross-Chain
npm run sendThis command:
- Reads the generated proof from
proof.json - Sends the ZK proof from Chain 1 to Chain 2 via Teleporter
- Returns transaction hash and details
4. Verify Received Proof
npm run verifyThis command:
- Monitors Chain 2 for received proofs
- Retrieves the latest stored proof
- Verifies the proof on-chain
- Shows verification results and event logs
Example Workflow
# 1. Generate ZK proof from circuit
npm run compile
# 2. Deploy contracts to both chains
npm run deploy
# 3. Send proof cross-chain
npm run send
# 4. Verify received proof
npm run verifyInput Configuration
Modify input.json to change the circuit inputs:
{
"a": 3,
"b": 11
}The circuit proves that a * b = 33 without revealing the values of a and b.
Chain Configuration
- Chain 1 (Sender): Dispatch Testnet
- Chain 2 (Receiver): Avalanche Fuji Testnet
- Bridge: Teleporter Messenger
CLI Binaries
After installation, you can also use the CLI commands directly:
zk-compile # Compile circuit and generate proof
zk-deploy # Deploy contracts
zk-send # Send proof cross-chain
zk-receive # Verify received proofLicense
MIT