A zero-knowledge proof-based identity verification system built with Circom and Solana. This project enables privacy-preserving identity verification where users can prove they know their credentials without revealing the actual ID or password.
ZK-ID-Verifier uses zero-knowledge proofs (ZKP) to verify user identities on the Solana blockchain. The system leverages the Poseidon hash function within a Circom circuit to create cryptographic proofs that validate user credentials without exposing sensitive information.
- Privacy-Preserving: Verify identity without revealing credentials
- Zero-Knowledge Proofs: Built using Circom circuits and Groth16 proving system
- Solana Integration: On-chain verification using a custom Solana program
- Poseidon Hashing: Efficient cryptographic hashing optimized for ZK circuits
- Verifiable Credentials: Generate and verify cryptographic proofs of identity
The project consists of three main components:
-
Circom Circuit (
id-verifier.circom)- Implements the identity verification logic
- Uses Poseidon hash function for efficient ZK-friendly hashing
- Takes user ID and password as private inputs
- Verifies against an expected hash
-
Input Generator (
generate_input.js)- JavaScript utility to generate test inputs
- Creates Poseidon hash of ID and password
- Outputs formatted JSON for circuit witness generation
-
Solana Program (
Zkp.rs)- On-chain verification program written in Rust
- Validates ZK proofs on Solana blockchain
- Manages verification records using PDAs (Program Derived Addresses)
- Prevents double verification
- Node.js (v14 or higher)
- Rust (latest stable version)
- Circom (v2.2.2 or higher)
- SnarkJS (for proof generation and verification)
- Solana CLI (for deploying the on-chain program)
-
Clone the repository
git clone https://github.com/yourusername/zk-id-verifier.git cd zk-id-verifier -
Install Node.js dependencies
cd circom npm install circomlibjs ethers -
Install Circom compiler
# Follow instructions at https://docs.circom.io/getting-started/installation/ -
Install Rust and Solana CLI
# Install Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Install Solana CLI sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
cd circom
node generate_input.jsThis creates input/input.json with sample ID, password, and expected hash.
circom id-verifier.circom --r1cs --wasm --symThis generates:
id-verifier.r1cs- Rank-1 Constraint Systemid-verifier.wasm- WebAssembly witness generatorid-verifier.sym- Symbol file for debugging
cd id-verifier_js
node generate_witness.js id-verifier.wasm ../input/input.json ../witness.wtns# Download or generate powers of tau
snarkjs powersoftau new bn128 12 pot12_0000.ptau -v
snarkjs powersoftau contribute pot12_0000.ptau pot12_0001.ptau --name="First contribution" -v
snarkjs powersoftau prepare phase2 pot12_0001.ptau pot12_final.ptau -vsnarkjs groth16 setup id-verifier.r1cs pot12_final.ptau id-verifier_0000.zkey
snarkjs zkey contribute id-verifier_0000.zkey id-verifier_final.zkey --name="Contribution" -v
snarkjs zkey export verificationkey id-verifier_final.zkey verifier_key.jsonsnarkjs groth16 prove id-verifier_final.zkey witness.wtns proof.json public.jsonsnarkjs groth16 verify verifier_key.json public.json proof.json# Build the Solana program
cargo build-bpf
# Deploy to devnet
solana program deploy target/deploy/zkp.so --url devnetzk-id-verifier/
βββ circom/
β βββ id-verifier.circom # Main circuit definition
β βββ generate_input.js # Input generation script
β βββ Zkp.rs # Solana verification program
β βββ circuits/
β β βββ circomlib/ # Circom library (Poseidon, etc.)
β βββ input/
β β βββ input.json # Generated test inputs
β βββ id-verifier_js/ # Compiled WASM witness generator
β βββ proof.json # Generated ZK proof
β βββ public.json # Public inputs
β βββ verifier_key.json # Verification key
β βββ Cargo.toml # Rust workspace configuration
βββ README.md
The IDVerifier circuit performs the following steps:
-
Takes three inputs:
id(private): User's identifierpassword(private): User's passwordexpectedHash(public): Expected Poseidon hash
-
Computes
Poseidon([id, password]) -
Verifies that the computed hash matches the expected hash
-
Generates a zero-knowledge proof that the verification succeeded
The on-chain program:
- Receives a ZK proof and verification key
- Validates the proof using Groth16 verification
- Creates a verification record PDA for the user
- Stores verification status and timestamp
- Prevents duplicate verifications
- Private Inputs: ID and password never leave the client
- Zero-Knowledge: Proofs reveal nothing about the actual credentials
- Immutable Records: Verification records are stored on-chain
- Replay Protection: Each user can only verify once
- Trusted Setup: Requires a secure multi-party computation ceremony
# Test Rust program
cd circom
cargo test- Edit
id-verifier.circom - Recompile the circuit
- Regenerate proving/verification keys
- Update the Solana program if needed
This project uses the Circom compiler which is licensed under GPL-3.0. See the circom/COPYING file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
This is a demonstration project. For production use, ensure proper security audits and use production-grade trusted setup ceremonies.
For questions or support, please open an issue on GitHub.
Built with β€οΈ using Circom, Solana, and Zero-Knowledge Proofs