A production-ready, generic zero-trust cryptographic protocol framework
Project description
ZeroTrust Framework
A production-ready, generic zero-trust cryptographic protocol framework for building verifiable peer-to-peer applications. The framework provides complete cryptographic guarantees without requiring trust in any participant.
๐ฏ What Is This?
A complete framework providing:
- Zero-knowledge proofs - Prove facts without revealing data (Merkle trees)
- Digital signatures - Authenticate all actions (ECDSA)
- Synchronized blockchain - Immutable shared history
- Cheat detection - Detect & invalidate cheaters
- Commitment schemes - Cryptographically bind to state
- Complete verification - Anyone can independently audit
- Protocol enforcement - Automatic timeout and turn order enforcement
- State persistence - Save/load protocol state
- Reconnection handling - Automatic state recovery
Zero-Trust Properties
- โ No trust in opponent - All claims cryptographically verified
- โ No trust in network - All messages digitally signed
- โ No central authority - Pure P2P, fully decentralized
- โ Zero-knowledge - Reveal only what's necessary
- โ Independently verifiable - Third-party auditing possible
- โ Cheat detection - Cheaters automatically invalidated with proof
๐ Quick Start
Installation
# From source (development)
git clone https://github.com/yourusername/zerotrust-framework
cd zerotrust-framework
pip install -e .
# Or install from PyPI (when published)
pip install zerotrust-framework
Basic Usage
from zerotrust import ZeroTrustProtocol
# Initialize protocol with your commitment data
protocol = ZeroTrustProtocol(
my_commitment_data=your_data,
enable_enforcement=True,
enable_persistence=True
)
# Get your commitment to share with opponent
commitment_data = protocol.get_my_commitment()
# Set opponent's commitment
protocol.set_opponent_commitment(opponent_commitment)
# Record an action (automatically signed)
success, action_data, signature = protocol.record_my_action(
action_type="your_action",
data={"key": "value"}
)
# Verify opponent's action
result = protocol.verify_opponent_action(action_data, signature)
if result.valid:
print("Action verified!")
# Generate zero-knowledge proof
proof, proof_sig = protocol.generate_proof(
commitment_obj=your_commitment,
query=your_query
)
# Verify proof
is_valid = protocol.verify_proof(proof, proof_sig, committed_root)
# Check blockchain integrity
is_valid = protocol.verify_blockchain_integrity()
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Application โ
โ (Games, Voting, Auctions, etc.) โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโ
โ ZeroTrustProtocol โ
โ (Main Framework Class) โ
โโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโโ
โ โ โ
โโโโโโโผโโโโ โโโโโผโโโโโ โโโโโผโโโโโโโ
โBlockchainโ โMerkle โ โIdentity โ
โ โ โProofs โ โ&Signaturesโ
โโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโ
๐ฆ Core Components
ZeroTrustProtocol
Main framework class - handles all cryptography:
class ZeroTrustProtocol:
def get_my_commitment() -> Dict # Get commitment to share
def set_opponent_commitment(commit) -> bool # Verify opponent's commitment
def record_my_action(type, data) -> tuple # Sign and record action
def verify_opponent_action(data, sig) -> bool # Verify signature
def generate_proof(commitment, query) -> tuple # Generate ZK proof
def verify_proof(proof, sig, root) -> bool # Verify ZK proof
def verify_blockchain_integrity() -> bool # Verify chain
def verify_all_signatures() -> bool # Verify all sigs
def replay_from_blockchain() -> bool # Complete replay
Commitment Schemes
Generic interface for commitments:
from zerotrust import CommitmentScheme, GridCommitment
# Use built-in GridCommitment for grid-based apps
commitment = GridCommitment(grid_data, seed)
root = commitment.get_commitment_root()
proof = commitment.generate_proof(query)
Blockchain
Immutable history ledger:
from zerotrust import Blockchain, Transaction, MoveType
blockchain = Blockchain()
tx = Transaction(
move_type=MoveType.ACTION,
participant_id="alice",
data={"action": "fire"},
timestamp=time.time(),
signature="..."
)
blockchain.add_transaction(tx)
blockchain.mine_block()
Enforcement
Automatic protocol enforcement:
protocol = ZeroTrustProtocol(
my_commitment_data=data,
enable_enforcement=True # Enable automatic enforcement
)
# Timeouts are automatically detected
# Turn order is automatically enforced
# Violations are automatically handled
๐ Security Features
- ECDSA Signatures - All actions cryptographically signed
- Merkle Proofs - Zero-knowledge proofs with full cryptographic paths
- Blockchain Integrity - Tamper-proof immutable ledger
- Cheat Detection - Comprehensive detection of all cheat types
- Protocol Enforcement - Automatic timeout and turn order enforcement
- State Persistence - Secure state save/load
- Reconnection - Automatic state recovery
๐ Examples
See the p2p-battleship repository for a complete example application using this framework.
๐งช Testing
# Run tests
pytest tests/
# With coverage
pytest --cov=zerotrust tests/
๐ License
MIT License - see LICENSE file for details.
๐ค Contributing
Contributions welcome! Please open an issue or submit a pull request.
๐ Links
- Documentation: Full API Documentation
- Example Application: p2p-battleship
- Issues: GitHub Issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zerotrust_framework-0.1.0.tar.gz.
File metadata
- Download URL: zerotrust_framework-0.1.0.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c8595e937c30bd3607cd1d99e6a7f10972919eb371af590d41b5a6c3e504a39
|
|
| MD5 |
b3978af895ee4d3ec30d47f1739383d8
|
|
| BLAKE2b-256 |
a77999b1732d76580306704dea79c768687fc9c7075e16484e84521d4a34483f
|
File details
Details for the file zerotrust_framework-0.1.0-py3-none-any.whl.
File metadata
- Download URL: zerotrust_framework-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fdc4021f4a338671480d4a985ef4904a36b44d2c78080fe9e872c0621715d22
|
|
| MD5 |
cc5912ec6653fcf9576ad78875b83da5
|
|
| BLAKE2b-256 |
8c8f47de02689e7d50da7ec631478b0cf49844eaaecdceae5771ed82ef137666
|