Algorithm overview - DevsDaddy/quarkdash GitHub Wiki
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:
- Asymmetric key exchange based on Ring-LWE (resistant to quantum attacks);
- Symmetric encryption with a choice of stream ciphers (ChaCha20 or Gimli);
- Quantum-resistant KDF based on SHAKE256;
- Message authentication via SHAKE256-MAC;
- 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), 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 ~10 ms;
- Forward secrecy β compromising a long-term key does not reveal past sessions.
- Built-in protection against replay, timing attacks, and counterfeiting.
- Flexibility β choice of cipher (ChaCha20/Gimli), synchronous and asynchronous API.
Brief description of the algorithm steps
Let's look at Step-by-step algorithm:
- Key pair generation (Ring-LWE):
- Select polynomials:
uniform a, smallsande. - Calculate
b = a β s + e. - Public key:
(a, b), private:s.
- Session establishment (KEM):
- Initiator (for example client):
-
- Generates small
s',e', calculatesu = a β s' + e'.
- Generates small
-
- Calculates
w = b β s', rounds to bits β shared secret ss.
- Calculates
-
- Sends
u(ciphertext).
- Sends
- Recipient (for example server):
-
- Given
s, calculatesw' = u β s, rounds to bits β same ss.
- Given
- Session Key Derivation (KDF):
keyMaterial= SHAKE256(salt || ss || "session-key", 64).- Split into
sessionKey (32 bytes)andmacKey (32 bytes).
- 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.
- 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.