Skip to content

Rumpa-Dey/PasswordVerification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 Password Verification zkApp (Mina Protocol)

A privacy-preserving password verification zkApp built on Mina Protocol (Devnet).
This project demonstrates how a user can prove knowledge of a correct password using zero-knowledge proofs, without revealing the password or any sensitive data on-chain.


🚀 Project Overview

Traditional smart contracts require inputs to be public.
This zkApp leverages Mina’s zero-knowledge architecture to allow secure authentication where:

  • The password is never revealed
  • Only a cryptographic proof is verified on-chain
  • Incorrect passwords fail locally before any transaction is sent

✨ Key Features

  • 🔒 Zero-knowledge password verification
  • 🧠 Poseidon hashing inside zk circuits
  • 🧾 On-chain storage of password hash only
  • ⚡ Proof-based verification (no re-execution on-chain)
  • 🌐 Deployed and tested on Mina Devnet

🏗️ Architecture

User (Client)

│ Password (private)

Local Proof Generation (prove)

│ Zero-Knowledge Proof

Mina Blockchain (verify proof only)

  • Client: Generates proofs and signs transactions
  • zkApp: Stores password hash and verifies correctness
  • Blockchain: Verifies proofs, not raw inputs

📂 Project Structure

project-root/ │

├── src/

│ ├── PasswordVerifierDevnet.ts

├── scripts/

│ ├── deployDevnetPassword.ts

│ ├── callVerifyPasswordDevnet.ts

│ └── readStatePasswordDevnet.ts

├── package.json

├── tsconfig.json

├──.env

└── README.md


🧠 Smart Contract Logic

The zkApp stores a Poseidon hash of a password on-chain.

verifyPassword(inputPassword)

  1. Reads the stored password hash
  2. Hashes the provided password inside the circuit
  3. Asserts both hashes are equal
  4. Generates a zero-knowledge proof

If the assertion fails:

  • Proof generation fails
  • Transaction is never sent
  • No fees are paid

🔑 Key Concepts Used

  • Zero-Knowledge Proofs
  • Poseidon Hashing
  • zkApp State
  • Private/Public Key Cryptography
  • Proof-based Smart Contracts

🛠️ Setup Instructions

1️⃣ Install dependencies

npm install

2️⃣ Create .env file

FEE_PAYER_KEY=<fee_payer_private_key>
ZKAPP_PRIVATE_KEY=<zkapp_private_key>
ZKAPP_ADDRESS=<zkapp_public_key>

3️⃣ Build the project

npm run build

🚀 Deploy zkApp to Devnet

node build/scripts/deployDevnetPassword.js

Output includes:

  • zkApp address

  • Deployment transaction hash

🔐 Call vertifyPassword

node build/scripts/callVerifyPasswordDevnet.js
  • ✅ Correct password → transaction succeeds

  • ❌ Wrong password → proof fails locally

📖 Read on-chain State

node build/scripts/readStatePasswordDevnet.js

This reads:

The Poseidon hash of the password stored on-chain

🛠 Tech Stack

Mina Protocol (Devnet)

o1js

TypeScript

Node.js

🔐 Security & Privacy

Password is never stored or revealed

Only the Poseidon hash exists on-chain

Proofs ensure correctness without disclosure

Invalid attempts fail before reaching the blockchain

📜 License

Apache 2.0 License

About

A Mina zkApp that enables secure, zero-knowledge password verification without revealing sensitive information on-chain.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors