Get Started - DevsDaddy/quarkdash GitHub Wiki

Installation

You can use the QuarkDash library as a regular library for both Backend and Frontend applications without any additional dependencies.

Installation using NPM:

npm install quarkdash

Or using GitHub:

git clone https://github.com/devsdaddy/quarkdash
cd ./quarkdash

QuarkDash can be used at client and server. The library is written on typescript.

Library structure

/benchmarks/      # Benchmarks folder
/src/             # Source code folder
  cipher.ts       # Different cipher implementations (Gimli and ChaCha20 out-of-the-box)
  crypto.ts       # General QuarkDash module
  index.ts        # Main module
  kdf.ts          # KDF (based on SHAKE256) implementation
  mac.ts          # MAC (based on SHAKE256) implementation
  ringlwe.ts      # Ring-LWE implementation
  types.ts        # QuarkDash basic types
  utils.ts        # Crypto utils for QuarkDash
  shake.ts        # Shake-256 Keccak implementation
/dist/            # Builded library
/test/            # General tests (can be launched with jest)

Basic example

/* Import modules */
import {CipherType, QuarkDash, QuarkDashUtils} from "../src";

/* Alice - client, bob - server, for example for key-exchange */
const alice = new QuarkDash({ cipher: CipherType.Gimli });
const bob = new QuarkDash({ cipher: CipherType.Gimli });

/* Generate key pair */
const alicePub = await alice.generateKeyPair();
const bobPub = await bob.generateKeyPair();

/* Initialize session at bob and jpin alice public key */
const ciphertext = await alice.initializeSession(bobPub, true) as Uint8Array;
await bob.initializeSession(alicePub, false);
await bob.finalizeSession(ciphertext);

/* Encrypt by alice and decrypt by bob */
const plain = QuarkDashUtils.textToBytes('Hello QuarkDash 🔒!');
const enc = await alice.encrypt(plain);
const dec = await bob.decrypt(enc);
console.log("Decrypted:", QuarkDashUtils.bytesToText(dec));

NPM Commands

Command Usage
npm run clean Clean build
npm run build Main build exec
npm run build:esm Build esm module
npm run build:cjs Build commonjs module
npm run build:types Build types only
npm run test Run basic tests
npm run bench Run basic benchmakr

Need more examples? Visit an examples page