VCL Protocol
Verified Commit Link โ Cryptographically chained packet transport protocol
๐ Documentation
README | Usage Guide | API Reference | Examples
๐ 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 signaturesx25519-dalekโ X25519 key exchangechacha20poly1305โ XChaCha20-Poly1305 AEAD encryptionsha2โ SHA-256 hashingtokioโ Async runtimeserde+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