Skip to content

Latest commit

ย 

History

History
101 lines (75 loc) ยท 3.7 KB

File metadata and controls

101 lines (75 loc) ยท 3.7 KB

๐Ÿ” zk-SNARKs Age Verification System

Python
Flutter
FastAPI
Azure
CI/CD
License

A privacy-preserving age verification system built with zk-SNARKs, enabling users to prove they are above a required age (e.g., 18+) without ever revealing their actual age.

This project demonstrates real cryptographic ZKPs โ€” not just hashing tricks โ€” using BN128 elliptic curves, bilinear pairings, and arithmetic circuits.


โœจ Features

  • โœ… Zero-Knowledge: Server never learns your age
  • โœ… Cryptographic Soundness: Proofs cannot be faked
  • โœ… Succinct Proofs: Constant proof size (~1KB)
  • โœ… Fast: Proof generation (~100ms), verification (~10ms)
  • โœ… Non-Interactive: Only one message required
  • โœ… Cloud Ready: Azure deployment templates included

๐Ÿ“– How It Works

  1. Client requests a challenge from the server
  2. Client computes age locally (never sent to server)
  3. zk-SNARK proof is generated using elliptic curve cryptography
  4. Client sends proof only
  5. Server verifies proof with bilinear pairings
  6. โœ… Result: Server confirms โ€œ18+โ€ without seeing actual age

๐Ÿงฎ Example: Circuit Logic

```python``

Circuit: Prove age >= 18 without revealing age

def age_verification_circuit(private_age, public_minimum_age): difference = private_age - public_minimum_age return difference >= 0

ZKP/ โ”œโ”€โ”€ backend/ # Python backend โ”‚ โ”œโ”€โ”€ zksnark_main.py # FastAPI server โ”‚ โ”œโ”€โ”€ zksnark_age_verification.py # Core zk-SNARK implementation โ”‚ โ”œโ”€โ”€ main.py # Educational demo (for learning) โ”‚ โ””โ”€โ”€ requirements.txt # Dependencies (py_ecc, FastAPI) โ”œโ”€โ”€ frontend/ # Flutter frontend โ”‚ โ””โ”€โ”€ zkp_age_app/ โ”‚ โ”œโ”€โ”€ lib/main.dart # UI connected to API โ”‚ โ””โ”€โ”€ pubspec.yaml โ”œโ”€โ”€ azure/ # Azure deployment configs โ””โ”€โ”€ docs/ # Documentation

cd backend pip install -r requirements.txt python zksnark_main.py # Runs on http://localhost:8001

cd frontend/zkp_age_app flutter pub get flutter run -d web-server --web-port 3000

Access Points

๐ŸŒ Web App โ†’ http://localhost:3000

๐Ÿ“š API Docs โ†’ http://localhost:8001/docs

๐Ÿ” ZKP Info โ†’ http://localhost:8001/zkp-info

Security Properties

๐Ÿค Zero-Knowledge: Age never revealed ๐Ÿ›ก๏ธ Soundness: Impossible to fake proof โœ… Completeness: Valid users always verified โšก Succinctness: Small, constant-size proofs

Backend โ†’ Azure App Service

az webapp create --resource-group myResourceGroup
--plan myAppServicePlan --name zksnark-backend
--runtime "PYTHON|3.11"

Frontend โ†’ Azure Static Web Apps

cd frontend/zkp_age_app flutter build web az staticwebapp create --name zksnark-frontend --source .

Backend tests

cd backend pytest -v

Flutter tests

cd frontend/zkp_age_app flutter test

This project is licensed under the MIT License. For educational and research purposes only.