Skip to content

surya00008/zero-knowledge-proof-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Zero Knowledge Proof Cryptographic System

Secure Authentication & Integrity Verification Using Zero Knowledge Proofs


πŸ“‹ Project Overview

This project demonstrates a practical implementation of Zero Knowledge Proof (ZKP) cryptographic algorithms using a Schnorr-like protocol, applied to real-world security use cases.

The system shows how secrets can be cryptographically proven without ever being transmitted or stored.

Implemented Use Cases

  1. Secure Authentication β€” prove password knowledge without revealing it
  2. Digital Forensics β€” verify file integrity without exposing file contents

🎯 Problem Statement

Issues with Traditional Authentication

  • Passwords are transmitted over networks
  • Servers store password hashes that may be leaked
  • Man-in-the-middle attacks can capture credentials
  • Data breaches expose sensitive secrets

Proposed Solution

Zero Knowledge Proof–based authentication
A cryptographic approach that allows a user to prove knowledge of a secret without ever revealing the secret itself.


πŸ“ Mathematical Foundation

Schnorr-like Zero Knowledge Proof Protocol

The implementation is based on a Schnorr-style ZKP using the discrete logarithm problem.

Parameters:
- p = 256-bit prime number (secp256k1 prime)
- g = 2 (generator)
- x = secret (derived from password/file hash via SHA-256)
- y = g^x mod p (public value - safe to share)

Protocol Steps:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     PROVER      β”‚                    β”‚    VERIFIER     β”‚
β”‚   (Client)      β”‚                    β”‚    (Server)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                                      β”‚
         β”‚  1. Commitment: t = g^r mod p        β”‚
         β”‚ ────────────────────────────────────>β”‚
         β”‚                                      β”‚
         β”‚  2. Challenge: c (random)            β”‚
         β”‚ <────────────────────────────────────│
         β”‚                                      β”‚
         β”‚  3. Response: s = r + c*x mod (p-1)  β”‚
         β”‚ ────────────────────────────────────>β”‚
         β”‚                                      β”‚
         β”‚  4. Verify: g^s β‰Ÿ t * y^c mod p      β”‚
         β”‚                                      β”‚

Why This is Zero Knowledge:

Transmitted (Safe) Never Transmitted
Commitment (t) Password
Challenge (c) Secret (x)
Response (s) Random nonce (r)
Public value (y) File contents

Security Basis: Discrete Logarithm Problem - Computing x from y = g^x mod p is computationally infeasible.


πŸ—οΈ Project Architecture

zkp-capstone-final/
β”‚
β”œβ”€β”€ main.py                 # CLI demo runner
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ README.md               # This documentation
β”‚
β”œβ”€β”€ authentication/         # Use Case 1: ZKP Authentication
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ prover.py          # Prover: generates proofs
β”‚   β”œβ”€β”€ verifier.py        # Verifier: validates proofs
β”‚   └── auth_flow.py       # Complete auth workflow
β”‚
β”œβ”€β”€ forensics/             # Use Case 2: File Integrity
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ prover.py          # Prover: file-based proofs
β”‚   β”œβ”€β”€ verifier.py        # Verifier: validates file proofs
β”‚   └── file_integrity.py  # Complete file verification flow
β”‚
β”œβ”€β”€ performance/           # Performance Measurement
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ metrics.py         # Timing and logging utilities
β”‚   └── results.csv        # Performance data log
β”‚
β”œβ”€β”€ ui/                    # Streamlit Web Interface
β”‚   └── app.py             # Full-featured web UI
β”‚
└── docs/                  # Documentation
    β”œβ”€β”€ PRESENTATION_GUIDE.md  # How to present the project
    └── ARCHITECTURE.md        # Technical details

πŸš€ How to Run

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)

Installation

# 1. Navigate to project folder
cd zkp-capstone-final

# 2. Install dependencies
pip install -r requirements.txt

# 3. Run CLI demo
python main.py

# 4. Run Web Interface (RECOMMENDED for presentation)
streamlit run ui/app.py

πŸ’» Use Cases

Use Case 1: ZKP Authentication

Scenario: Login to a system without transmitting your password.

Traditional Method (INSECURE):

User β†’ "password123" β†’ Server β†’ Compare with stored hash
❌ Password transmitted
❌ Server sees password

ZKP Method (SECURE):

User β†’ Mathematical Proof β†’ Server β†’ Verify equation
βœ… Password NEVER transmitted
βœ… Server NEVER sees password
βœ… Even if hacked, no passwords leaked

Use Case 2: Digital Forensics File Integrity

Scenario: Prove you have an authentic copy of evidence without sending the file.

Applications:

  • Court evidence verification
  • Chain of custody in forensics
  • Secure backup verification
  • Distributed file validation

πŸ“Š Performance Results

Our system demonstrates excellent performance:

Operation Average Time
Proof Generation < 1 ms
Verification < 1 ms
Total Round-trip < 2 ms

Based on 256-bit prime modular exponentiation


πŸ”’ Security Properties

1. Completeness

If the prover knows the secret, verification always succeeds.

2. Soundness

If the prover does NOT know the secret, they cannot forge a valid proof (probability β‰ˆ 1/p β‰ˆ 0).

3. Zero Knowledge

The verifier learns NOTHING about the secret from the proof values.


πŸ› οΈ Technology Stack

Component Technology
Language Python 3.8+
Cryptography SHA-256, Modular Arithmetic
Protocol Schnorr-like ZKP
Web UI Streamlit
Logging CSV

πŸ“š References

  1. Schnorr, C.P. (1991). Efficient signature generation by smart cards. Journal of Cryptology
  2. Goldwasser, S., Micali, S., & Rackoff, C. (1989). The knowledge complexity of interactive proof systems. SIAM Journal on Computing
  3. RFC 8235 - Schnorr Non-interactive Zero-Knowledge Proof


βœ… Features

  • Schnorr-like ZKP Protocol
  • Secure Password Authentication
  • File Integrity Verification
  • Command-line Interface (CLI)
  • Web-based User Interface (Streamlit)
  • Performance Metrics Logging
  • Comparative Demo (Traditional vs ZKP)
  • Mathematical Visualization

Β© 2026 Surya - Zero Knowledge Proof System

About

A Python-based Zero Knowledge Proof system implementing the Schnorr protocol for secure authentication and file integrity verification. Includes interactive cryptography demos, attack simulations, and performance analysis, demonstrating how secrets can be proven without being revealed.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages