Skip to content

SOVEREIGN-NET/zhtp

Repository files navigation

ZHTP - Zero-Knowledge Hypertext Transfer Protocol

Rust License: MIT Version

Internet Replacement System

Complete β€’ Zero-Knowledge Privacy β€’ Universal Basic Income β€’ Post-Quantum Security

Overview

ZHTP is a network node that orchestrates a complete internet replacement system. It coordinates 9 specialized library packages to provide through mesh networking, zero-knowledge privacy for all communications, universal basic income distribution, and quantum-resistant cryptographic security.

Key Features

  • Complete ISP Replacement - Pure mesh networking with Bluetooth LE, WiFi Direct, and LoRaWAN
  • Zero-Knowledge Privacy - All communications protected with ZK proofs and post-quantum cryptography
  • Universal Basic Income - 33 ZHTP daily, 1000 ZHTP monthly for all verified citizens
  • Decentralized Governance - DAO-based decision making with liquid democracy
  • Web4 Protocol Stack - Next-generation internet protocols
  • Real-time Monitoring - Comprehensive system health and performance metrics

##Architecture

ZHTP operates as a Level 1 Orchestrator that coordinates Level 2 Components:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    ZHTP Orchestrator                    β”‚
β”‚                    (Level 1 - Main)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚           β”‚           β”‚
    β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β–Όβ”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
    β”‚Protocols  β”‚ β”‚Networkβ”‚ β”‚Blockchain β”‚
    β”‚           β”‚ β”‚       β”‚ β”‚           β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚           β”‚           β”‚
    β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β–Όβ”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
    β”‚Storage    β”‚ β”‚Economyβ”‚ β”‚Consensus  β”‚
    β”‚           β”‚ β”‚       β”‚ β”‚           β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚           β”‚           β”‚
    β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β–Όβ”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
    β”‚Identity   β”‚ β”‚Proofs β”‚ β”‚Crypto     β”‚
    β”‚           β”‚ β”‚       β”‚ β”‚           β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Modules

Required ZHTP Library Dependencies

The ZHTP node requires all 9 specialized libraries to function:

Library Purpose Status
lib-crypto Post-quantum cryptography (CRYSTALS-Dilithium/Kyber) -
lib-proofs Zero-knowledge system (Plonky2) Required
lib-identity Privacy-preserving identity management Required
lib-storage Distributed storage with encryption Required
lib-network Mesh networking (BLE, WiFi Direct, LoRaWAN) Required
lib-blockchain Blockchain layer with UBI support Required
lib-consensus Consensus mechanism Required
lib-economy Economic incentives and DAO governance Required
lib-protocols High-level protocol implementations Required

Internal Modules

The ZHTP orchestrator contains sophisticated internal systems:

Configuration System (src/config/)

  • aggregation.rs - Cross-package configuration coordination
  • validation.rs - Configuration conflict detection and resolution
  • environment.rs - Environment-specific settings (dev/staging/prod)
  • mesh_modes.rs - Mesh networking mode management
  • security.rs - Security level configurations

πŸ–₯️ CLI Interface (src/cli/)

  • argument_parsing.rs - Command-line argument processing
  • command_execution.rs - Command handling and orchestration
  • interactive_shell.rs - Interactive shell with auto-completion
  • commands/ - Specialized command handlers for each subsystem

Runtime Orchestration (src/runtime/)

  • components.rs - Component lifecycle management
  • blockchain_provider.rs - Blockchain integration layer
  • shared_blockchain.rs - Shared blockchain state management

Monitoring System (src/monitoring/)

  • metrics.rs - Real-time system metrics collection
  • health_check.rs - Component health monitoring
  • alerting.rs - Alert management and notifications
  • dashboard.rs - Web dashboard with live visualization

Integration Layer (src/integration/)

  • service_container.rs - Dependency injection container
  • event_bus.rs - Inter-component messaging system
  • component_manager.rs - Component startup and shutdown coordination
  • dependency_injection.rs - Advanced dependency resolution

API Server (src/api/)

  • server.rs - HTTP API server for external integration
  • endpoints.rs - RESTful API endpoint definitions
  • handlers/ - Request handlers for each functional area

Getting Started

Prerequisites

  1. Rust 1.70+ - Install from rustup.rs
  2. All ZHTP Libraries - Ensure all 9 lib-* packages are available in parent directory
  3. System Requirements - 4GB RAM, 10GB storage minimum

Installation

  1. Clone the ZHTP repository structure:
git clone https://github.com/SOVEREIGN-NET/SOVEREIGN_NET.git
cd SOVEREIGN_NET/zhtp
  1. Verify dependencies are available:
# Check that all required libraries exist
ls -la ../lib-*
# Should show: lib-blockchain, lib-consensus, lib-crypto, lib-economy, 
#              lib-identity, lib-network, lib-proofs, lib-protocols, lib-storage
  1. Build the ZHTP node:
cargo build --release
  1. Run initial setup:
# Create default configuration
cargo run -- node start --dev

Quick Start

Method 1: Interactive CLI Mode (Recommended)

# Start the interactive ZHTP shell
cargo run

# Available commands in the shell(not all of them work):
zhtp> help                    # Show all available commands
zhtp> node start --port 9333  # Start the orchestrator node
zhtp> node status             # Check node health
zhtp> monitor system          # View system metrics
zhtp> wallet create --name "MyWallet" --type citizen
zhtp> dao info                # Check DAO status
zhtp> identity create TestUser # Create new DID identity
zhtp> network status          # Check mesh network status

Method 2: Server Mode

# Start ZHTP server (API mode)
cargo run -- --server

# Server will be available at http://127.0.0.1:9333
# API documentation: http://127.0.0.1:9333/docs

Method 3: Direct Commands

# Execute single commands directly
cargo run -- node start --config config.toml
cargo run -- wallet balance <address>
cargo run -- dao claim-ubi
cargo run -- network peers

πŸ“– Usage Examples

Starting a Complete ZHTP Node

# Start with default settings
cargo run -- node start

# Start with custom configuration
cargo run -- node start --config custom.toml --port 9333 --dev

# Start in pure mesh mode (no TCP/IP fallback)
cargo run -- node start --pure-mesh

Identity Management

# Create a new Zero-Knowledge DID identity
cargo run -- identity create-did Alice \
  --type human \
  --recovery-options "phrase1,phrase2"

# Verify an existing identity
cargo run -- identity verify <identity_id>

# List all identities
cargo run -- identity list

Wallet Operations

# Create a new citizen wallet
cargo run -- wallet create --name "CitizenWallet" --type citizen

# Check wallet balance
cargo run -- wallet balance <wallet_address>

# Transfer funds between wallets
cargo run -- wallet transfer \
  --from <from_wallet> \
  --to <to_wallet> \
  --amount 1000

# View transaction history
cargo run -- wallet history <wallet_address>

DAO Governance

# Get DAO information
cargo run -- dao info

# Create a new proposal
cargo run -- dao propose \
  --title "Network Upgrade" \
  --description "Implement new features"

# Vote on a proposal
cargo run -- dao vote --proposal-id <id> --choice yes

# Claim your Universal Basic Income
cargo run -- dao claim-ubi

Network Operations

# Check network status
cargo run -- network status

# View connected peers
cargo run -- network peers

# Test network connectivity
cargo run -- network test

Monitoring and Diagnostics

# View system metrics
cargo run -- monitor system

# Check component health
cargo run -- monitor health

# View performance metrics
cargo run -- monitor performance

# Check system logs
cargo run -- monitor logs

Component Management

# List all components
cargo run -- component list

# Start a specific component
cargo run -- component start lib-blockchain

# Check component status
cargo run -- component status lib-network

# Restart a component
cargo run -- component restart lib-consensus

Configuration

Default Configuration File (lib-node.toml)

[node]
name = "zhtp-node"
mesh_port = 33444
api_port = 9333
environment = "development"
data_dir = "./data"

[mesh]
mode = "hybrid"              # hybrid, pure-mesh, offline
enable_bluetooth = true
enable_wifi_direct = true
enable_lorawan = false

[security]
level = "enhanced"           # basic, enhanced, paranoid
quantum_resistant = true
zero_knowledge = true

[economy]
ubi_enabled = true
dao_participation = true
daily_ubi_amount = 33000000000000000000    # 33 ZHTP tokens
monthly_ubi_amount = 1000000000000000000000 # 1000 ZHTP tokens

[monitoring]
enable_dashboard = true
dashboard_port = 9334
metrics_interval = 30
health_check_interval = 60

[logging]
level = "info"
output = "console"
file_path = "./logs/zhtp.log"

Environment Variables

export ZHTP_CONFIG_PATH="./config.toml"
export ZHTP_DATA_DIR="./data"
export ZHTP_LOG_LEVEL="info"
export ZHTP_MESH_PORT="33444"
export ZHTP_API_PORT="9333"
export ZHTP_ENVIRONMENT="development"

API Reference

REST API Endpoints

The ZHTP node provides a comprehensive REST API on port 9333:

Base URL: http://127.0.0.1:9333/api/v1

Identity Management

  • POST /identity/create - Create new DID identity
  • POST /identity/verify - Verify identity
  • GET /identity/list - List all identities

Wallet Operations

  • POST /wallet/create - Create new wallet
  • GET /wallet/balance/{address} - Get wallet balance
  • POST /wallet/transfer - Transfer funds
  • GET /wallet/history/{address} - Get transaction history

DAO Operations

  • GET /dao/info - Get DAO information
  • POST /dao/proposal/create - Create proposal
  • POST /dao/proposal/vote - Vote on proposal
  • POST /dao/ubi/claim - Claim UBI

Network Operations

  • GET /network/status - Network status
  • GET /network/peers - Connected peers
  • GET /network/test - Network connectivity test

For complete API documentation, visit: http://127.0.0.1:9333/docs when the server is running.

Monitoring & Debugging

Web Dashboard

Access the live monitoring dashboard at http://127.0.0.1:9334 when the node is running:

  • System Metrics - CPU, memory, network usage
  • Component Health - Status of all 9 ZHTP libraries
  • Network Statistics - Mesh network connectivity and performance
  • Economic Metrics - UBI distribution, transaction volumes
  • Security Status - Cryptographic operations, threat detection

Log Files

Logs are written to ./logs/zhtp.log by default:

# View real-time logs
tail -f ./logs/zhtp.log

# Filter for specific components
grep "lib-network" ./logs/zhtp.log

# View error logs only
grep "ERROR" ./logs/zhtp.log

Health Checks

# Check overall system health
curl http://127.0.0.1:9333/api/v1/health

# Check specific component health
curl http://127.0.0.1:9333/api/v1/health/lib-blockchain

Development

Building from Source

# Development build
cargo build

# Release build with optimizations
cargo build --release

# Build with specific features
cargo build --features "pure-mesh,development"

Running Tests

# Run all tests
cargo test

# Run specific test suite
cargo test integration_tests

# Run with verbose output
cargo test -- --nocapture

Development Mode

# Start in development mode with enhanced logging
cargo run -- node start --dev

# Use custom configuration for development
cargo run -- node start --config dev-config.toml --dev

Security Features

Post-Quantum Cryptography

  • CRYSTALS-Dilithium - Digital signatures
  • CRYSTALS-Kyber - Key encapsulation
  • Quantum-resistant - Protection against future quantum computers

Zero-Knowledge Privacy

  • Plonky2 Proofs - Privacy-preserving transaction validation
  • Selective Disclosure - Reveal only necessary information
  • Anonymous Communications - No metadata leakage

Economic Security

  • Anti-Spam - Economic incentives prevent network abuse
  • Quality Rewards - Better service providers earn more
  • Decentralized Governance - Community-driven security decisions

Network Modes

Hybrid Mode (Default)

  • Uses mesh networking with TCP/IP fallback
  • Gradual transition from traditional internet
  • Best compatibility with existing systems

Pure Mesh Mode

  • Complete using only mesh protocols
  • Maximum privacy and decentralization
  • Requires multiple ZHTP nodes in area

Offline Mode

  • Local-only operations without external connectivity
  • Useful for development and testing
  • Complete functionality simulation

Roadmap

Phase 1: Foundation (Current)

  • Core orchestrator implementation
  • Configuration management system
  • CLI interface and interactive shell
  • Monitoring and health checks
  • API server with REST endpoints

Phase 2: Network Integration

  • Complete mesh networking implementation
  • functionality
  • Multi-protocol support (BLE, WiFi Direct, LoRaWAN)
  • Network topology optimization

Phase 3: Economic System

  • πŸ“… UBI distribution implementation
  • πŸ“… DAO governance mechanics
  • πŸ“… Economic incentive algorithms
  • πŸ“… Quality-based reward system

Phase 4: Production Deployment

  • πŸ“… Production security hardening
  • πŸ“… Scalability optimizations
  • πŸ“… Mobile device support
  • πŸ“… Global network coordination

Contributing

We welcome contributions to the ZHTP project! Please see:

Quick Contribution Setup

# Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/SOVEREIGN_NET.git
cd SOVEREIGN_NET/zhtp

# Create a feature branch
git checkout -b feature/your-feature-name

# Make your changes and test
cargo test
cargo fmt
cargo clippy

# Submit a pull request
git push origin feature/your-feature-name

License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

Documentation

Community

Getting Help

# Built-in help system
cargo run -- help
cargo run -- node --help
cargo run -- wallet --help

# Interactive help in shell mode
zhtp> help
zhtp> help wallet
zhtp> help dao

ZHTP - Revolutionizing Internet Infrastructure

Building the foundation for Web4 and true digital sovereignty

Website β€’ Documentation β€’ Community

About

Zero Knowledge Hypertext Transfer Protocol

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages