Skip to content
SIVA-RAJAPublic

Repository files navigation

UXSP — Universal Exchange Security Protocol

Version: 1.3.2 Python: 3.11+ License: MIT Coverage: 100% Type Checking: mypy strict NIST FIPS 203 & 204

UXSP (Universal Exchange Security Protocol) is an enterprise-grade, hybrid post-quantum security framework. It provides application-layer zero-trust encryption, progressive protocol negotiation with automatic fallback, multi-gigabyte streaming in constant memory, and framework middlewares—all designed to protect APIs, data pipelines, messaging, and live media against classical eavesdroppers and future quantum supercomputers.


How UXSP Works

Imagine you want to send a secret drawing to your friend Bob across a playground full of snoopy kids:

  Alice's Drawing                        Locked Safe                         Bob Reads Drawing
┌─────────────────┐             ┌───────────────────────────┐             ┌─────────────────┐
│                 │             │  [Lock 1: Classical]      │             │                 │
│   "Top Secret   │ ──(Sealed)─▶│   X25519 + Ed25519        │──(Opened)──▶│   "Top Secret   │
│    Playground   │             │  [Lock 2: Quantum-Proof]  │             │    Playground   │
│     Plan!"      │             │   ML-KEM-768 + ML-DSA-65  │             │     Plan!"      │
└─────────────────┘             └───────────────────────────┘             └─────────────────┘
  1. The Classical Lock (Today's Security): Standard internet encryption (like RSA and ECC) is like a good metal padlock. Normal computers today cannot pick it.
  2. The Quantum Monster (Tomorrow's Threat): Mathematicians have proven that future Quantum Computers will be able to pick all classical locks instantly! Even worse, bad actors are collecting encrypted internet traffic right now ("Harvest Now, Decrypt Later") to unlock it once their quantum computers are ready.
  3. The UXSP Double Safe: UXSP puts your message inside a safe with TWO different locks:
    • Lock 1: Modern classical cryptography (X25519 ECDH and Ed25519 digital signatures).
    • Lock 2: Quantum-proof lattice mathematics standardized by NIST (ML-KEM-768 / CRYSTALS-Kyber and ML-DSA-65 / CRYSTALS-Dilithium).
  4. Unbreakable Guarantee: An attacker must break BOTH locks at the same time to read your message or impersonate the sender. If either lock remains intact, your data is 100% safe!

⚡ Key Highlights in v1.3.1

  • 🔄 Autonomous Protocol-Switching HTTP Client (uxsp.client):
    • UXSPClient (sync) and AsyncUXSPClient (async) automatically probe remote servers using negotiation headers (X-UXSP-Accept, X-UXSP-Version, X-UXSP-Identity).
    • Automatic Encryption: If the server speaks UXSP, the client automatically seals the request and decrypts the response.
    • Automatic Plaintext Fallback: If the server is standard HTTP/REST (like Stripe, GitHub, or legacy microservices), the client seamlessly communicates in standard plaintext HTTP without errors.
    • Zero-Trust Enforcement: Set allow_fallback=False / force_uxsp=True to immediately reject any unencrypted endpoints.
    • Pluggable Capability Caching: Cache server capabilities in Memory, Redis, or PostgreSQL to avoid per-request discovery round-trips.
  • 🛡️ 1-Line Polymorphic Cryptography (uxsp.secure):
    • Direct 1-line operations across 14 polymorphic data types: Text, File, JSON, Binary, PDF, Document, Voice, Video, Photo, Location, Contact, HTML, Archive, and LiveVoiceCall.
  • 🌐 Web Framework Middlewares (uxsp.contrib):
    • Drop-in middlewares and route decorators (@protect, @protect_route) for FastAPI, Django, and Flask with opportunistic negotiation headers.
  • 📦 Ultra-Low Memory Streaming (SendStream / ReceiveStream):
    • Encrypt and transfer 100GB+ files chunk-by-chunk in a fixed O(chunk_size) RAM footprint without event loop blocking.
  • ⏱️ Durable Replay Protection (NonceStore):
    • Sliding-window sequencing, timestamp bounds (≤ 300s freshness), and TTL noncestores backed by Memory, Redis, or PostgreSQL.
  • 🎥 Live Media & WebRTC (LiveSession / LiveVoiceSession):
    • High-performance real-time video, voice calls, and CCTV feed protection with ratcheting directional session keys.
  • 💻 Cross-Platform CLI (uxsp):
    • Terminal utility for key management, identity generation, sealing/opening envelopes, and uxsp client for probing and querying remote endpoints.
  • 📜 Formal Standards & Exact Wire Format (docs/):
    • Complete RFC 2119 mathematical specifications (docs/protocol_specification.md) and bit-level binary wire format manuals with hex vectors (docs/wire_format.md).
  • 💎 100% Strict Type Safety & Test Coverage:
    • Verified mypy strict mode (strict = true) across all 78 source files with 0 errors.
    • Verified 100% test coverage (7,084 / 7,084 statements) across 1,758 tests with 0 warnings.

🏛️ System Architecture

flowchart TD
    subgraph AppLayer["Application Layer"]
        APP["Web App / Microservice / CLI"]
        CLIENT["UXSPClient / AsyncUXSPClient"]
        MW["FastAPI / Django / Flask Middleware"]
    end

    subgraph ProtoLayer["Protocol Switching & Negotiation"]
        PROBE{"Server Supports UXSP?"}
        PROBE -->|"Yes"| UXSP_PATH["Seal into SecurePackage"]
        PROBE -->|"No (Fallback)"| PLAIN_PATH["Standard HTTP / REST"]
        CACHE[("HostCapabilityCache<br/>Memory / Redis / DB")]
        CLIENT <--> CACHE
    end

    subgraph CoreLayer["UXSP Secure Core"]
        DISPATCH["Polymorphic Dispatcher<br/>14 Data Types"]
        STATE["Session State Machine<br/>Monotonic Seq + Sliding AD"]
        REPLAY["ReplayGuard + NonceStore<br/>Timestamp Window + TTL"]
        CRYPTO["Hybrid Cryptographic Engine<br/>X25519 + ML-KEM-768<br/>Ed25519 + ML-DSA-65<br/>AES-256-GCM + HKDF"]
    end

    APP --> CLIENT
    APP --> MW
    CLIENT --> PROBE
    UXSP_PATH --> DISPATCH
    DISPATCH --> STATE
    STATE --> REPLAY
    REPLAY --> CRYPTO
Loading

⚙️ Installation

# Base package
pip install uxsp

UXSP is highly modular. You only need to install the dependencies required for your specific framework and storage needs.

Installation Command Included Components & Dependencies
pip install uxsp Base uxsp.secure (cryptography, liboqs-python, argon2-cffi)
pip install uxsp[aio] uxsp.secure + uxsp.aio (Asynchronous capabilities)
pip install uxsp[django] uxsp.secure + Django Integrations
pip install uxsp[flask] uxsp.secure + Flask Integrations
pip install uxsp[fastapi] uxsp.secure + FastAPI, Starlette, HTTPX2 Integrations
pip install uxsp[postgres] uxsp.secure + Postgres (psycopg2-binary)
pip install uxsp[redis] uxsp.secure + Redis (redis)
pip install "uxsp[aio, django]" uxsp.secure + uxsp.aio + Django
pip install "uxsp[aio, postgres]" uxsp.secure + uxsp.aio + Postgres
pip install "uxsp[aio, redis]" uxsp.secure + uxsp.aio + Redis
pip install "uxsp[aio, django, postgres]" uxsp.secure + uxsp.aio + Django + Postgres
pip install "uxsp[aio, django, redis]" uxsp.secure + uxsp.aio + Django + Redis
pip install uxsp[all-django] uxsp.secure + uxsp.aio + Django + Postgres + Redis
pip install uxsp[all-flask] uxsp.secure + uxsp.aio + Flask + Postgres + Redis
pip install uxsp[all-fastapi] uxsp.secure + uxsp.aio + FastAPI + Postgres + Redis
pip install uxsp[all] Complete stack with all web frameworks and storage backends

System Prerequisites (liboqs)

UXSP utilizes liboqs for C-native Post-Quantum Cryptography acceleration. You must install the required build tools for your platform:

  • Ubuntu / Debian / Mint:
    sudo apt update && sudo apt install -y build-essential cmake ninja-build libssl-dev git
  • Fedora / RHEL / CentOS:
    sudo dnf groupinstall -y "Development Tools" && sudo dnf install -y cmake ninja-build openssl-devel git
  • macOS:
    brew install cmake ninja openssl@3
  • Windows: Requires Visual Studio Build Tools (C++), CMake, and Git. (Note: Windows support is experimental and falls back to msvcrt for certain operations).

Note

Automatic Pure-Python Fallback: If liboqs fails to compile on your system, UXSP will automatically fall back to its built-in pure Python Post-Quantum Cryptography implementations, ensuring it always runs!


📚 Complete Documentation Directory

📜 Formal Engineering Standards (docs/)

For cryptographers, security auditors, and engineers implementing UXSP in other languages (Rust, Go, C/C++, Swift, Zig):

📖 Developer Tutorials & Framework Guides (tutorial/)

For software engineers building applications with UXSP:


🛡️ Security Policy

We take security seriously. Please report any potential vulnerabilities privately to sivaraja5401@gmail.com with subject [UXSP SECURITY]. See SECURITY.md for our coordinated vulnerability disclosure policy.


📄 License

UXSP is licensed under the MIT License.

UXSP v1.3.2

Maintained by SIVA RAJA S