High-performance C++ implementation of the Chaum-Pedersen Zero-Knowledge Proof authentication system.
- Fast cryptographic operations using Crypto++
- 2048-bit safe prime generation
- SQLite database for user storage
- RESTful API server using cpp-httplib
- Low memory footprint (~20MB)
- Optimal performance for evaluations and integrations
sudo apt-get update
sudo apt-get install -y \
build-essential \
cmake \
libcrypto++-dev \
libsqlite3-dev \
libcatch2-dev \
pkg-configsudo dnf install -y \
gcc-c++ \
cmake \
cryptopp-devel \
sqlite-devel \
catch-devel \
pkg-config# From the cpp directory
mkdir build && cd build
cmake ..
make -j$(nproc)This will create:
auth_server- Authentication serverauth_client- CLI clienttest_zkp- Test suite (if Catch2 is installed)
cd build
./auth_server
# With custom options
./auth_server --port 9000 --db custom_users.db# Register a user
./auth_client register alice password123
# Authenticate
./auth_client login alice password123
# Verify session token
./auth_client verify <token>
# Connect to custom server
./auth_client register alice password --host 192.168.1.100 --port 9000./test_zkp
# Or using CTest
ctest --output-on-failurecpp/
├── CMakeLists.txt # Build configuration
├── src/ # Source code
│ ├── zkp/ # Zero-knowledge proof implementation
│ │ ├── chaum_pedersen.hpp
│ │ └── chaum_pedersen.cpp
│ ├── db/ # Database layer
│ │ ├── user_database.hpp
│ │ └── user_database.cpp
│ ├── server/ # HTTP server
│ │ ├── auth_server.hpp
│ │ ├── auth_server.cpp
│ │ └── main.cpp
│ └── client/ # CLI client
│ └── cli_client.cpp
├── tests/ # Test suite
│ └── test_zkp.cpp
└── third_party/ # Header-only libraries
├── httplib.h
└── nlohmann/
└── json.hpp
GET /params- Retrieve group parameters (hex)POST /register- Register by submitting client-computedy1, y2, saltPOST /challenge- Obtain a one-timenoncePOST /authenticate- Submit{a1, a2, s, nonce}to authenticateGET /verify- Verify session token
See ../docs/API.md for complete API documentation.
- Parameter Generation: ~1 second (one-time on startup)
- Registration: ~0.1 seconds per user
- Authentication: ~0.1 seconds per request
- Throughput: ~500 requests/second (concurrent)
- Memory: ~20 MB resident
- 2048-bit Safe Primes: p = 2q + 1
- Cryptographically Secure RNG: AutoSeededRandomPool
- SHA-256 Hashing: For password derivation and challenges
- Timestamp Validation: 5-minute window prevents replay attacks
- Session Management: 1-hour expiry with secure tokens
- Zero-Knowledge: Server never learns passwords
The project uses:
- C++17 standard
-Wall -Wextrafor warnings- Link-time optimization when available
# Build release version
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
# Deploy binary
cp auth_server /usr/local/bin/FROM ubuntu:22.04
RUN apt-get update && apt-get install -y libcrypto++ libsqlite3
COPY build/auth_server /app/
WORKDIR /app
CMD ["./auth_server", "--port", "8080"]Problem: Package 'libcrypto++' not found
sudo apt-get install libcrypto++-devProblem: fatal error: httplib.h: No such file or directory
cd third_party
curl -L -o httplib.h https://raw.githubusercontent.com/yhirose/cpp-httplib/master/httplib.hProblem: CMake can't find libraries
# Make sure pkg-config is installed
sudo apt-get install pkg-configProblem: error while loading shared libraries: libcryptopp.so
sudo ldconfigProblem: Server crashes on startup
- Check if port 8080 is already in use
- Ensure write permissions for database file
- Python Implementation:
../python/README.md - ZKP Theory:
../docs/ZKP_THEORY.md - API Documentation:
../docs/API.md - Quick Start Guide:
../QUICKSTART.md
- Crypto++ Library: https://www.cryptopp.com/
- cpp-httplib: https://github.com/yhirose/cpp-httplib
- Chaum-Pedersen Protocol: See
../docs/CHAUM_PEDERSEN.md