QuarkDash: Hybrid Post-Quantum Protocol in TypeScript for High-Load Systems
QuarkDash combines Ring-LWE for post-quantum key exchange, stream ciphers ChaCha20 or Gimli, SHAKE-256 for key derivation and MAC, plus protection against replay and timing attacks. Public key size ~2 KB, private ~1 KB. Session setup takes ~8-9 ms on average CPUs. Ideal for client-server systems without architecture lock-in.
Primitive Selection in QuarkDash
Ring-LWE for Key Exchange
Ring-LWE uses polynomial rings with parameters N=256, Q=7681, ω=7. Delivers 128-bit post-quantum security. Polynomial multiplication via NTT at O(N log N). Key generation: ~12 ms, encapsulation/decapsulation ~8-9 ms.
Symmetric Encryption
- ChaCha20: 20 rounds, 256-bit key, 12-byte nonce. Blazing fast in software, resistant to timing attacks.
- Gimli: 24 rounds, 384-bit state, 256-bit security. Outpaces ChaCha20 on 32-bit architectures, leaner code for IoT.
KDF and MAC with SHAKE-256
SHAKE-256 (Keccak-based) for quantum-resistant key derivation and authentication. KDF: SHAKE256(salt || sharedSecret || "session-key", 64) → sessionKey (32 bytes) + macKey (32 bytes). MAC: SHAKE256(macKey || header || ciphertext, 32) with constant-time verification.
Step-by-Step Protocol Flow
Key Generation
- Pick a ∈ Z_Q^N.
- Small s, e with coefficients {-1,0,1}.
- b = a ⊗ s + e (NTT).
- Public: (a, b), private: s.
KEM for Session
Initiator:
- u = a ⊗ s' + e'.
- sharedSecret from b ⊗ s'.
Recipient: sharedSecret from u ⊗ s.
Message Encryption
- header = timestamp (8 bytes) || sequence (4 bytes).
- ciphertext = streamCipher.encrypt(plaintext, sessionKey, nonce).
- mac = SHAKE256(macKey || header || ciphertext, 32).
- Packet: header || ciphertext || mac.
Message Decryption
- Parse packet.
- Verify MAC (constant-time).
- Check timestamp within 5 minutes.
- Ensure sequence is unique (window of 1000).
- plaintext = streamCipher.decrypt(ciphertext).
Security Measures
- Post-Quantum Resistance: Ring-LWE with no known quantum breaks, SHAKE-256 holds against Grover's algorithm.
- Side-Channel Protection: Constant-time comparisons, secure key zeroing, no secret-dependent branches.
- Forward Secrecy: Ephemeral session keys.
- Replay Protection: Timestamp + sequence.
Overall security: 128-256 bits against classical/quantum threats.
Performance Benchmarks
Session Setup (ms, avg of 1000 runs)
| Operation | QuarkDash (ChaCha20) | QuarkDash (Gimli) | ECDH P-256 | RSA-2048 |
|----------|----------------------|-------------------|------------|----------|
| Key Generation | 12.3 | 12.1 | 1.2 | 48 |
| KEM Encapsulation | 8.7 | 8.5 | 3.4 | 42 |
| KEM Decapsulation | 9.2 | 9.0 | 3.4 | 0.1 |
Throughput (MB/s)
| Size | ChaCha20 | Gimli | AES-256-GCM | ECIES |
|--------|----------|-------|-------------|-------|
| 1 KB | 125 | 132 | 117 | 10 |
| 1 MB | 2380 | 2630 | 1176 | 48 |
| 10 MB | 2450 | 2710 | 1200 | 50 |
Overhead: public key 2 KB, private 1 KB, packet overhead 44 bytes.
Comparison with Alternatives
- Vs AES: QuarkDash adds built-in KEM, forward secrecy, replay protection. ChaCha20 beats AES in software without hardware accel.
- Vs ECC: Shor-resistant, lower packet overhead (44 vs 61 bytes), faster for large payloads.
The protocol is optimized for TypeScript in web apps, with SHAKE-256 emulated on Keccak.
Key Takeaways
- Ring-LWE (N=256, Q=7681) for 128-bit PQC with NTT multiplication.
- Dual ciphers: ChaCha20 for software, Gimli for IoT.
- SHAKE-256 KDF/MAC with constant-time ops.
- Replay protection via timestamp + sequence (window 1000).
- Benchmarks: up to 2710 MB/s encryption, sessions ~9 ms.
— Editorial Team
No comments yet.