vcl-protocol 0.1.0

Verified Commit Link Protocol
Documentation

VCL Protocol

Verified Commit Link โ€” Cryptographically chained packet transport protocol


๐Ÿ“š Documentation

README | Usage Guide | API Reference | Examples


Rust Build Tests License Status


๐Ÿ“– About

VCL Protocol is a transport protocol where each packet cryptographically links to the previous one, creating an immutable chain of data transmission. Inspired by blockchain principles, optimized for real-time networking.

Now with X25519 Handshake + XChaCha20-Poly1305 Encryption + Replay Protection โ€” secure key exchange, authenticated encryption, and protection against packet replay attacks!


โœจ Features

Feature Description
๐Ÿ” Cryptographic Chain Each packet references hash of previous packet
โœ๏ธ Ed25519 Signatures Fast and secure digital signatures
๐Ÿ”‘ X25519 Handshake Ephemeral key exchange, no pre-shared keys needed
๐Ÿ”’ XChaCha20-Poly1305 Authenticated encryption for all payloads
๐Ÿ›ก๏ธ Replay Protection Sequence number + nonce tracking prevents packet replay
โœ… Chain Validation Automatic integrity checking
โšก UDP Transport Low latency, high performance
๐Ÿงช Full Test Suite 14 passing tests (unit + integration)

๐Ÿ—๏ธ Architecture

Packet N        Packet N+1      Packet N+2
+--------+     +--------+     +--------+
| hash   |     | prev   |     | prev   |
| 0x00.. | --> | 0x00.. | --> | 0x3a.. |
| sig    |     | sig    |     | sig    |
+--------+     +--------+     +--------+

hash(Packet N) -> stored in prev_hash of Packet N+1
hash(Packet N+1) -> stored in prev_hash of Packet N+2

Handshake Flow

Client                          Server
   |                               |
   | -- ClientHello (pubkey) ----> |
   |                               |
   | <---- ServerHello (pubkey) -- |
   |                               |
   | [Shared secret computed]      |
   | [Secure channel established]  |

Encryption Flow

Send: plaintext โ†’ encrypt(XChaCha20) โ†’ sign(Ed25519) โ†’ send
Recv: receive โ†’ verify(Ed25519) โ†’ decrypt(XChaCha20) โ†’ plaintext

Replay Protection

1. Check sequence number (must be > last received)
2. Check nonce (must not be in seen_nonces set)
3. Store nonce in sliding window (1000 entries)
4. Reject packet if either check fails

๐Ÿš€ Quick Start

Installation

# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Clone repository
git clone https://github.com/ultrakill148852-collab/vcl-protocol.git
cd vcl-protocol

Run Demo

cargo run

Run Tests

cargo test

Expected Output (Demo)

=== VCL Protocol Demo ===

Server started on 127.0.0.1:8080
Handshake completed
Client connected (handshake complete)
Client sent: Message 1
Server received packet 1: Message 1
Client sent: Message 2
Server received packet 2: Message 2
Client sent: Message 3
Server received packet 3: Message 3
Client sent: Message 4
Server received packet 4: Message 4
Client sent: Message 5
Server received packet 5: Message 5

=== Demo Complete ===

Expected Output (Tests)

running 10 tests
test crypto::tests::test_hash_data ... ok
test crypto::tests::test_decrypt_wrong_key_fails ... ok
...
test result: ok. 10 passed; 0 failed

running 4 tests
test test_client_server_basic ... ok
test test_encryption_integrity ... ok
test test_chain_validation ... ok
test test_replay_protection ... ok
test result: ok. 4 passed; 0 failed

๐Ÿ“ฆ Packet Structure

pub struct VCLPacket {
    pub version: u8,           // Protocol version
    pub sequence: u64,         // Packet sequence number (monotonic)
    pub prev_hash: Vec<u8>,    // SHA-256 hash of previous packet
    pub nonce: [u8; 24],       // XChaCha20 nonce for encryption
    pub payload: Vec<u8>,      // Encrypted data payload
    pub signature: Vec<u8>,    // Ed25519 signature
}

๐ŸŽฏ Use Cases

๐Ÿ’ฐ Financial Transactions

Immutable audit log of all transactions with cryptographic proof of integrity.

๐ŸŽฎ Anti-Cheat Systems

Verify integrity of game events and detect tampering in real-time.

๐Ÿ“‹ Audit Logging

Cryptographically proven data integrity for compliance and debugging.

๐Ÿ” Secure Communications

Authenticated and encrypted channel with end-to-end verification, ephemeral key exchange, and replay protection.


๐Ÿ”ฌ Technical Details

Cryptography

  • Hashing: SHA-256
  • Signatures: Ed25519 (Edwards-curve Digital Signature Algorithm)
  • Key Exchange: X25519 (Elliptic-curve Diffie-Hellman)
  • Encryption: XChaCha20-Poly1305 (AEAD)
  • Key Generation: CSPRNG (Cryptographically Secure PRNG)
  • Replay Protection: Sequence number validation + nonce tracking (1000-entry window)

Transport

  • Protocol: UDP
  • Runtime: Tokio async
  • Max Packet Size: 65535 bytes

Serialization

  • Format: Bincode
  • Efficiency: Minimal overhead, fast serialization

Dependencies

  • ed25519-dalek โ€” Ed25519 signatures
  • x25519-dalek โ€” X25519 key exchange
  • chacha20poly1305 โ€” XChaCha20-Poly1305 AEAD encryption
  • sha2 โ€” SHA-256 hashing
  • tokio โ€” Async runtime
  • serde + bincode โ€” Serialization

๐Ÿ› ๏ธ Development

# Run all tests
cargo test

# Run unit tests only
cargo test --lib

# Run integration tests only
cargo test --test integration_test

# Format code
cargo fmt

# Linting
cargo clippy

# Build release
cargo build --release

# Generate docs
cargo doc --open

๐Ÿ“„ License

MIT License โ€” see LICENSE file for details.


๐Ÿ‘ค Author

ultrakill148852-collab โ€” Creator of the VCL Protocol

GitHub: @ultrakill148852-collab


๐Ÿ™ Acknowledgments

  • Ed25519 โ€” Fast and secure cryptography
  • X25519 โ€” Efficient elliptic-curve key exchange
  • XChaCha20-Poly1305 โ€” Modern authenticated encryption
  • Tokio โ€” Asynchronous runtime for Rust
  • Rust โ€” The language that makes the impossible possible

Made with โค๏ธ using Rust

โฌ†๏ธ Back to top