Skip to content

Algorithm overview

Elijah Brown edited this page Aug 28, 2026 · 4 revisions

About algorithm

QuarkDash it is a hybrid cryptographic protocol (algorithm) that provides post-quantum security using Ring‑LWE, high performance, and attack resistance. QuarkDash Crypto combines asymmetric key exchange (sessions) and symmetric encryption via ChaCha20 (best for cross-platform development) or Gimli (best for IoT).

QuarkDash it is a hybrid post-quantum protocol that combines:

  1. Asymmetric key exchange based on Ring-LWE (resistant to quantum attacks);
  2. Symmetric encryption with a choice of stream ciphers (ChaCha20 or Gimli);
  3. Quantum-resistant KDF based on SHAKE256;
  4. Message authentication via SHAKE256-MAC;
  5. Protection against replay attacks using timestamps and sequence numbers;

This protocol is recommended for systems that require long-term data confidentiality (archives, financial transactions, government communications, AI RAG), as well as for high-load real-time applications.

⭐ Key Features

  • Quantum stability: not broken by Shor and Grover's algorithms;
  • Performance: encryption up to 2.8 GB/s, session establishment ~3 ms;
  • Forward secrecy: compromising a long-term key does not reveal past sessions;
  • Lazy keystream: seekable, cached, zero-copy XOR via ChaChaKeystream / GimliKeystream;
  • Re-keying (Key rotation): rekey() / applyRekey() with policy by bytes / messages / time limit (order fixed: encrypt-then-derive);
  • Passphrase: Human-readable pbkdf2 / argon2id lite keys and generateSalt();
  • Hardened Secured NTT: blinding, double-check, constant-time, polynome validation, correct primitive roots, bit-reversed Cooley-Tukey and cross-rounding hint;
  • Transports: native simple wrappers for WebSocket / gRPC / HTTP transport;
  • Flexibility – ChaCha20/Gimli, sync and async API, per-message nonce;

Brief description of the algorithm steps

Let's look at Step-by-step algorithm:

  1. Key pair generation (Ring-LWE):
  • Select polynomials: uniform a, small s and e.
  • Calculate b = a ⊗ s + e.
  • Public key: (a, b), private: s.
  1. Session establishment (KEM):
  • Initiator (for example client):
    • Generates small s', e', calculates u = a ⊗ s' + e'.
    • Calculates w = b ⊗ s', rounds to bits → shared secret ss.
    • Sends u (ciphertext + 32B hint) = 544 bytes.
  • Recipient (for example server):
    • Given s, calculates w' = u ⊗ s, rounds to bits → same ss.
    • Extract hint to apply for some errors.
  1. Session Key Derivation (KDF):
  • keyMaterial = SHAKE256(salt || ss || "session-key", 64) with HKDF-like Extenstion: T(i) = SHAKE256(PRK || T(i-1) || info || i).
  • Apply deterministic salt (32 zero bytes).
  • Split into sessionKey (32 bytes) and macKey (32 bytes).
  • When a session is finalized, the recipient's own public key is hashed (decapsulate(myPublicKey)).
  1. Message Encryption (AEAD):
  • A header (12 bytes) is generated: timestamp (8) + sequence (4).
  • Encryption: ciphertext = streamCipher.encrypt(plaintext) (XOR with gamma).
  • mac = SHAKE256(macKey || header || ciphertext, 32).
  • Resulting message: header || ciphertext || mac.
  • Key rotation (rekeying) is performed in the encrypt-then-derive order, which ensures that the token can be decrypted using old keys on both sides.
  1. Decryption:
  • Header, ciphertext, and mac are extracted.
  • The mac (constant-time) is checked.
  • The timestamp (with a 5-minute tolerance) and sequence (for replay protection) are checked.
  • plaintext = streamCipher.decrypt(ciphertext).

More detailed infomration can be found here


Difference in ciphers

Below is a simple explanation of the differences in cipher you can use in QuarkDash.

ChaCha20

  • State: 16 words of 32 bits.
  • Rounds: 20.
  • Gamma: 64 bytes per block.
  • Features: Standardized (RFC 7539), high speed on all platforms, protection against timing attacks.

Gimli

  • State: 12 words of 32 bits.
  • Rounds: 24.
  • Gamma: 48 bytes per block.
  • Features: Lightweight, designed for embedded systems, yet provides 256-bit security. NIST-audited.

Clone this wiki locally