Private, verifiable elections using zero-knowledge cryptography and Self Protocol identity verification.
ZK Vote is a voting platform that combines zero-knowledge proofs with Aadhaar-based identity verification via the Self Protocol. Users must verify their Aadhaar identity before accessing the voting interface, ensuring one-person-one-vote while preserving voter privacy.
Landing Page (/) --> Verify Identity (/vote) --> Cast Vote --> Confirmation
| |
Self SDK QR Code ZK Proof Generated
(Aadhaar verification) (vote privacy)
|
Backend Verifier
(/api/verify)
- User visits the landing page and clicks "Launch App"
- Redirected to
/votewhere they must complete identity verification - Self SDK displays a QR code -- user scans with the Self mobile app (Aadhaar verification)
- Proof is sent to
/api/verifybackend endpoint for verification - On success, the voting interface is unlocked
- User selects a proposal and casts their vote
- Vote is confirmed with a ZK proof
/src/app-- Next.js App Router pages and API routes/src/app/api/verify-- Self SDK backend verifier endpoint/src/app/vote-- Voting page with verification gate/src/components-- React components (hero, features, verification, etc.)/src/components/ui-- Primitive UI components
- Next.js 16 -- App Router, React Server Components
- React 19 -- UI framework
- TypeScript 5 -- Type safety
- Tailwind CSS 4 -- Styling
- Self Protocol SDK -- Identity verification via QR/ZK proofs
- ethers.js -- Ethereum utilities
- Node.js 18+
- pnpm
git clone https://github.com/your-username/zk-vote.git
cd zk-vote
pnpm installCreate a .env.local file in the project root:
NEXT_PUBLIC_SELF_ENDPOINT=https://your-ngrok-url.ngrok.io/api/verifyFor local development, the Self SDK requires a publicly accessible endpoint. Use ngrok to tunnel your local server:
ngrok http 3000Then set NEXT_PUBLIC_SELF_ENDPOINT to the ngrok HTTPS URL followed by /api/verify.
pnpm devOpen http://localhost:3000 to view the application.
pnpm build
pnpm startThe app uses the Self Protocol for privacy-preserving identity verification:
- Frontend:
@selfxyz/qrcoderenders a QR code that users scan with the Self mobile app - Backend:
@selfxyz/coreprovidesSelfBackendVerifierto validate proofs server-side - Accepted Documents: Aadhaar only (configured via
ATTESTATION_ID.AADHAAR) - Verification Config: Minimum age 18, using staging mode for development
The frontend and backend configurations (scope, disclosures) must match exactly for verification to succeed.