Skip to main content

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zerotrust_framework-0.1.0.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zerotrust_framework-0.1.0-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

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

Hashes for zerotrust_framework-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c8595e937c30bd3607cd1d99e6a7f10972919eb371af590d41b5a6c3e504a39
MD5 b3978af895ee4d3ec30d47f1739383d8
BLAKE2b-256 a77999b1732d76580306704dea79c768687fc9c7075e16484e84521d4a34483f

See more details on using hashes here.

File details

Details for the file zerotrust_framework-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for zerotrust_framework-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fdc4021f4a338671480d4a985ef4904a36b44d2c78080fe9e872c0621715d22
MD5 cc5912ec6653fcf9576ad78875b83da5
BLAKE2b-256 8c8f47de02689e7d50da7ec631478b0cf49844eaaecdceae5771ed82ef137666

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page