zks

Crates.iozks
lib.rszks
version0.1.1
created_at2026-01-06 19:25:24.048268+00
updated_at2026-01-06 19:39:19.512225+00
descriptionZero Knowledge Swarm - Post-quantum secure networking SDK with built-in anonymity
homepagehttps://zks-protocol.org
repositoryhttps://github.com/zks-protocol/zks
max_upload_size
id2026579
size155,467
Wasif Faisal (cswasif)

documentation

https://docs.rs/zks

README

ZKS Protocol

πŸ” ZKS Protocol

Zero Knowledge Swarm β€” Post-Quantum Encryption with Built-in Anonymity

Build Status Crates.io Docs License Rust

Linux macOS Windows WASM


🌟 Why ZKS?

ZKS Protocol is the first post-quantum secure networking SDK with built-in anonymity through onion routing. Built with 100% safe Rust, it provides unbreakable encryption for the quantum computing era.

Protocol Description Security Model
zk:// Direct encrypted connection Post-quantum secure, low latency
zks:// Swarm-routed anonymous connection Post-quantum + onion routing

πŸ“‘ Table of Contents


🌟 Key Features

πŸ” Post-Quantum Cryptography

  • ML-KEM-768 (Kyber) β€” NIST Level 3 key exchange
  • ML-DSA-65 (Dilithium) β€” Post-quantum signatures
  • Resistant to quantum computer attacks

πŸ§… Onion Routing

  • Multi-hop anonymous connections
  • Traffic analysis resistance
  • Built-in swarm networking

⚑ High Performance

  • Async/await native design
  • Zero-copy message handling
  • Minimal memory footprint

🌐 Cross-Platform

  • Native Linux, macOS, Windows
  • WebAssembly for browsers
  • Mobile-ready architecture

πŸš€ Quick Start

πŸ“‹ Prerequisites

  • Rust 1.70+ toolchain
  • OpenSSL (for development)

πŸ“₯ Installation

Add to your Cargo.toml:

[dependencies]
zks_sdk = "0.1"
tokio = { version = "1", features = ["full"] }

πŸ’» Basic Connection (ZK://)

use zks_sdk::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Build a post-quantum secure connection
    let connection = ZkConnectionBuilder::new()
        .url("zk://secure-server.example.com:8443")
        .security(SecurityLevel::PostQuantum)
        .build()
        .await?;
    
    println!("βœ… Connected with post-quantum encryption!");
    
    // Send encrypted data
    connection.send(b"Hello, quantum-proof world!").await?;
    
    // Receive response
    let response = connection.recv().await?;
    println!("πŸ“© Received: {:?}", response);
    
    connection.close().await?;
    Ok(())
}

πŸ§… Anonymous Connection (ZKS://)

use zks_sdk::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Build an anonymous swarm-routed connection
    let connection = ZksConnectionBuilder::new()
        .url("zks://hidden-service.example.com:8443")
        .min_hops(3)  // Route through 3+ relay nodes
        .security(SecurityLevel::TrueVernam)
        .build()
        .await?;
    
    println!("πŸ§… Anonymous connection established!");
    println!("   Your IP is hidden from the destination server.");
    
    // Send anonymous message
    connection.send(b"Confidential message").await?;
    
    connection.close().await?;
    Ok(())
}

🌐 Browser (WebAssembly)

import init, { ZksWasmUtils } from 'zks-wasm';

await init();

// Generate post-quantum keypair
const keypair = ZksWasmUtils.generate_ml_dsa_keypair();
console.log("πŸ”‘ Generated ML-DSA keypair");

// Sign a message
const message = new TextEncoder().encode("Hello from the browser!");
const signature = ZksWasmUtils.ml_dsa_sign(message, keypair.signing_key);
console.log("✍️ Signature created");

// Verify signature
const isValid = ZksWasmUtils.ml_dsa_verify(message, signature, keypair.verifying_key);
console.log("βœ… Signature valid:", isValid);

πŸ”’ Security Architecture

πŸ” Cryptographic Primitives

Component Algorithm Security Level
Key Exchange ML-KEM-768 (Kyber) NIST Level 3 (IND-CCA2)
Signatures ML-DSA-65 (Dilithium) NIST Level 3 (EUF-CMA)
Symmetric Encryption Wasif-Vernam Cipher ChaCha20-Poly1305 + XOR
Random Entropy drand beacon + local TRUE random (not pseudo)

πŸ›‘οΈ Security Levels

pub enum SecurityLevel {
    /// Classical cryptography (for testing only)
    Classical,
    
    /// Post-quantum secure (recommended for production)
    PostQuantum,
    
    /// Maximum security with TRUE random entropy
    TrueVernam,
}
Level Key Exchange Encryption Use Case
Classical Random ChaCha20 Testing/Development
PostQuantum ML-KEM Wasif-Vernam Production
TrueVernam ML-KEM + drand OTP-style Maximum Security

πŸ”„ 3-Message Handshake

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Initiator  β”‚                           β”‚  Responder   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                           β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                                          β”‚
       β”‚  1. HandshakeInit                        β”‚
       β”‚  ─────────────────────────────────────►  β”‚
       β”‚  [ephemeral_pk, nonce]                   β”‚
       β”‚                                          β”‚
       β”‚  2. HandshakeResponse                    β”‚
       β”‚  ◄─────────────────────────────────────  β”‚
       β”‚  [ephemeral_pk, ciphertext, signature]   β”‚
       β”‚                                          β”‚
       β”‚  3. HandshakeFinish                      β”‚
       β”‚  ─────────────────────────────────────►  β”‚
       β”‚  [confirmation_hash]                     β”‚
       β”‚                                          β”‚
       β–Ό                                          β–Ό
   [shared_secret derived]                [shared_secret derived]

πŸ“¦ Crate Structure

zks/
β”œβ”€β”€ zks_sdk        # High-level SDK (start here!)
β”œβ”€β”€ zks_crypt      # Wasif-Vernam cipher, drand integration
β”œβ”€β”€ zks_pqcrypto   # ML-KEM-768, ML-DSA-65
β”œβ”€β”€ zks_proto      # Handshake protocol, URL parsing
β”œβ”€β”€ zks_wire       # Swarm networking, NAT traversal
β”œβ”€β”€ zks_types      # Common type definitions
└── zks_wasm       # WebAssembly bindings
Crate Description Key Features
zks_sdk High-level developer API Connection builders, prefabs
zks_crypt Core cryptographic operations Wasif-Vernam, scrambling, drand
zks_pqcrypto Post-quantum primitives ML-KEM, ML-DSA, Zeroizing
zks_proto Protocol implementation 3-message handshake, messages
zks_wire Network layer STUN, NAT traversal, swarm
zks_types Shared types Error types, crypto params
zks_wasm Browser support JS bindings via wasm-bindgen

πŸ§… Anonymous Routing

The zks:// protocol provides onion routing through a decentralized swarm network:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Client │───►│ Entry   │───►│ Middle  │───►│ Exit    │───►│ Destinationβ”‚
β”‚        β”‚    β”‚ Relay   β”‚    β”‚ Relay   β”‚    β”‚ Relay   β”‚    β”‚            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚              β”‚              β”‚              β”‚               β”‚
     └──encrypted──►└──encrypted──►└──encrypted──►└──plaintext───►│

Features

  • Multi-hop routing: Configurable number of relay hops (default: 3)
  • Layered encryption: Each hop can only decrypt its layer
  • Traffic analysis resistance: Optional scrambling mode
  • Peer discovery: Automatic swarm network formation

πŸ“± Platform Support

Platform Status Notes
Linux βœ… Full Support Primary development platform
macOS βœ… Full Support Intel and Apple Silicon
Windows βœ… Full Support Windows 10/11
WebAssembly βœ… Full Support Chrome, Firefox, Safari
iOS πŸ”„ Planned Via Rust FFI
Android πŸ”„ Planned Via Rust FFI

πŸ“– Examples

The examples/ directory contains complete working examples:

# Basic encrypted connection
cargo run --example basic_connection

# Anonymous swarm-routed connection
cargo run --example anonymous_connection

# Secure file transfer
cargo run --example file_transfer

🌐 What Can You Build?

Application Protocol Description
Encrypted Messenger zks:// Quantum-proof end-to-end chat
Secure File Sharing zk:// Unbreakable file transfer
Anonymous APIs zks:// Hide client IP addresses
VPN Replacement zks:// Better than VPN + Tor combined
Whistleblowing Platform zks:// Source protection
Healthcare/Finance zk:// HIPAA/PCI compliance

πŸ›‘οΈ Security

Security Model

  • Post-quantum resistance: All key exchanges use NIST-standardized algorithms
  • Forward secrecy: Session keys are derived per-connection
  • Zero trust: End-to-end encryption with mutual authentication
  • Memory safety: 100% safe Rust, no unsafe code in core crates

Responsible Disclosure

Please report security vulnerabilities to: security@zks-protocol.org

See SECURITY.md for our full security policy.


πŸ§ͺ Testing

# Run all tests
cargo test --workspace

# Run specific crate tests
cargo test -p zks_sdk
cargo test -p zks_crypt

# Run integration tests
cargo test --test integration_tests

🀝 Contributing

Contributions are welcome! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code:

  • βœ… Follows Rust best practices
  • βœ… Includes appropriate tests
  • βœ… Has documentation for public APIs
  • βœ… Passes all CI checks

πŸ“œ License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

See LICENSE for the full license text.


πŸ“ž Contact


Built with ❀️ for a quantum-safe future

Protecting your privacy today, and tomorrow.

Commit count: 31

cargo fmt