A Python implementation of zero-knowledge range proofs, allowing a prover to convince a verifier that a secret number lies within a specific range without revealing the number itself.
run.py: Main script demonstrating the range proof protocolprover.pyandverifier.py: Prover and Verifier class implementationsutils.py: Helper functions for elliptic curve operations, vector arithmetic and such.
This repo is based on learnings from the free-to-read Rareskills ZK Book (Bulletproofs).
- Python 3.8 or higher
- (Recommended)
uvPython package manager
- Clone the repository:
git clone https://github.com/nkrishang/zk-range-proof.git
cd zk-range-proof- Create and activate a virtual environment:
# Using uv (recommended)
uv venv- Install dependencies
# Using uv (recommended)
uv pip install libnum py-ecc# Using uv (recommended)
uv run run.pyThis will create a zero knowledge proof that the provided v and n are such that v < 2^n and verify the proof. It prints "accepted" if the verification is successful.