quarkdash 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/modules.xml +8 -0
- package/.idea/quarkdash.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/coverage/clover.xml +470 -0
- package/coverage/coverage-final.json +8 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/cipher.ts.html +862 -0
- package/coverage/lcov-report/crypto.ts.html +1000 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +206 -0
- package/coverage/lcov-report/index.ts.html +151 -0
- package/coverage/lcov-report/kdf.ts.html +274 -0
- package/coverage/lcov-report/mac.ts.html +277 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/ringlwe.ts.html +895 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/utils.ts.html +1111 -0
- package/coverage/lcov.info +740 -0
- package/dist/cjs/cipher.js +265 -0
- package/dist/cjs/cipher.js.map +1 -0
- package/dist/cjs/crypto.js +284 -0
- package/dist/cjs/crypto.js.map +1 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/kdf.js +56 -0
- package/dist/cjs/kdf.js.map +1 -0
- package/dist/cjs/mac.js +55 -0
- package/dist/cjs/mac.js.map +1 -0
- package/dist/cjs/ringlwe.js +267 -0
- package/dist/cjs/ringlwe.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils.js +320 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/cipher.js +259 -0
- package/dist/esm/cipher.js.map +1 -0
- package/dist/esm/crypto.js +280 -0
- package/dist/esm/crypto.js.map +1 -0
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/kdf.js +52 -0
- package/dist/esm/kdf.js.map +1 -0
- package/dist/esm/mac.js +51 -0
- package/dist/esm/mac.js.map +1 -0
- package/dist/esm/ringlwe.js +263 -0
- package/dist/esm/ringlwe.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.js +313 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/cipher.d.ts +153 -0
- package/dist/types/crypto.d.ts +155 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/kdf.d.ts +34 -0
- package/dist/types/mac.d.ts +47 -0
- package/dist/types/ringlwe.d.ts +127 -0
- package/dist/types/types.d.ts +69 -0
- package/dist/types/utils.d.ts +132 -0
- package/img/cover.png +0 -0
- package/package.json +63 -0
- package/src/cipher.ts +260 -0
- package/src/crypto.ts +306 -0
- package/src/index.ts +23 -0
- package/src/kdf.ts +64 -0
- package/src/mac.ts +65 -0
- package/src/ringlwe.ts +271 -0
- package/src/types.ts +75 -0
- package/src/utils.ts +343 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/quarkdash.iml" filepath="$PROJECT_DIR$/.idea/quarkdash.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
package/.idea/vcs.xml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Elijah Brown
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Welcome to QuarkDash π Repository
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
**QuarkDash** - pure typescript it is a hybrid cryptographic protocol that provides post-quantum security, high performance, and attack resistance.
|
|
5
|
+
|
|
6
|
+
> Have a questions? <a href="mailto:ilya@neurosell.top">Contact me</a>
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
[About](#about-quarkdash-crypto) | [Get Started](#get-started) | [Example](#basic-example) | [Benchmark](#benchmark) | [Docs](https://github.com/devsdaddy/quarkdash/wiki)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## About QuarkDash Crypto
|
|
15
|
+
**QuarkDash Crypto** - It is a hybrid cryptographic protocol that provides post-quantum security, high performance, and attack resistance.
|
|
16
|
+
This library can be used as shared solution for client and server. Written on **pure typescript**. **Dependency-free**.
|
|
17
|
+
|
|
18
|
+
### β Why QuarkDash Crypto?<br/>
|
|
19
|
+
πΉ **Lightweight library** with zero dependencies;<br/>
|
|
20
|
+
πΉ **Powerful crypto** algorithm written in **Typescript**;<br/>
|
|
21
|
+
πΉ **Extremely** fast (great for realtime and IoT applications);<br/>
|
|
22
|
+
πΉ **Production ready** with benchmarks;
|
|
23
|
+
|
|
24
|
+
### π General Components
|
|
25
|
+
- **Asymmetric key exchange** β Ring-LWE (N=256, Q=7681) based on NTT;
|
|
26
|
+
- **Symmetric encryption** β With ChaCha20 (RFC 7539) or lightweight Gimli ciphers.
|
|
27
|
+
- **Key Derivation Function (KDF)** β Based on fast SHAKE256 (emulated via SHA-256).
|
|
28
|
+
- **Message Authentication Code (MAC)** β Based on SHAKE256 with key.
|
|
29
|
+
- **Replay protection** β timestamp + sequence number.
|
|
30
|
+
|
|
31
|
+
### β Key Features
|
|
32
|
+
- **Quantum stability** β not broken by Shor and Grover's algorithms;
|
|
33
|
+
- **Performance** β encryption up to 2.8 GB/s, session establishment ~10 ms;
|
|
34
|
+
- **Forward secrecy** β compromising a long-term key does not reveal past sessions.
|
|
35
|
+
- **Built-in protection** against replay, timing attacks, and counterfeiting.
|
|
36
|
+
- **Flexibility** β choice of cipher (ChaCha20/Gimli), synchronous and asynchronous API.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Get Started
|
|
41
|
+
You can use the **QuarkDash library** as a regular library for both Backend and Frontend applications without any additional dependencies.
|
|
42
|
+
|
|
43
|
+
**Installation using NPM:**
|
|
44
|
+
```bash
|
|
45
|
+
npm install quarkdash
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Or using GitHub:**
|
|
49
|
+
```bash
|
|
50
|
+
git clone https://github.com/devsdaddy/quarkdash
|
|
51
|
+
cd ./quarkdash
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Basic example
|
|
55
|
+
```typescript
|
|
56
|
+
/* Import modules */
|
|
57
|
+
import {CipherType, QuarkDash, QuarkDashUtils} from "../src";
|
|
58
|
+
|
|
59
|
+
/* Alice - client, bob - server, for example for key-exchange */
|
|
60
|
+
const alice = new QuarkDash({ cipher: CipherType.Gimli });
|
|
61
|
+
const bob = new QuarkDash({ cipher: CipherType.Gimli });
|
|
62
|
+
|
|
63
|
+
/* Generate key pair */
|
|
64
|
+
const alicePub = await alice.generateKeyPair();
|
|
65
|
+
const bobPub = await bob.generateKeyPair();
|
|
66
|
+
|
|
67
|
+
/* Initialize session at bob and jpin alice public key */
|
|
68
|
+
const ciphertext = await alice.initializeSession(bobPub, true) as Uint8Array;
|
|
69
|
+
await bob.initializeSession(alicePub, false);
|
|
70
|
+
await bob.finalizeSession(ciphertext);
|
|
71
|
+
|
|
72
|
+
/* Encrypt by alice and decrypt by bob */
|
|
73
|
+
const plain = QuarkDashUtils.textToBytes('Hello QuarkDash π!');
|
|
74
|
+
const enc = await alice.encrypt(plain);
|
|
75
|
+
const dec = await bob.decrypt(enc);
|
|
76
|
+
expect(QuarkDashUtils.bytesToText(dec)).toBe('Hello QuarkDash π!');
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### NPM Commands
|
|
80
|
+
|
|
81
|
+
| Command | Usage |
|
|
82
|
+
|---------------------|-----------------------|
|
|
83
|
+
| npm run clean | Clean build |
|
|
84
|
+
| npm run build | Main build exec |
|
|
85
|
+
| npm run build:esm | Build esm module |
|
|
86
|
+
| npm run build:cjs | Build commonjs module |
|
|
87
|
+
| npm run build:types | Build types only |
|
|
88
|
+
| npm run test | Run basic tests |
|
|
89
|
+
| npm run bench | Run basic benchmakr |
|
|
90
|
+
|
|
91
|
+
> Read more about QuarkDash library in [official wiki](https://github.com/devsdaddy/quarkdash/wiki)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## How it works?
|
|
97
|
+
Below I've outlined a brief step-by-step flowchart of how the algorithm works. If you need more detailed information, please [visit the Wiki](https://github.com/devsdaddy/quarkdash/wiki).
|
|
98
|
+
|
|
99
|
+
**Step-by-Step Algorithm:**
|
|
100
|
+
1. Key Pair Generation (using RingβLWE);
|
|
101
|
+
2. Session Setup (using SHAKE-256 emulated KEM);
|
|
102
|
+
3. Session Key Flow (KDF);
|
|
103
|
+
4. Message Encryption (AEAD);
|
|
104
|
+
5. Decryption;
|
|
105
|
+
|
|
106
|
+
[Read more about algorithm in Wiki](https://github.com/devsdaddy/quarkdash)
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Comparison with other algorithms
|
|
111
|
+
Below is a brief comparison table of popular encryption algorithm variations. As we know, each algorithm serves its own purpose, so this comparison is more of a synthetic test.
|
|
112
|
+
|
|
113
|
+
| Characteristic | QuarkDash (ChaCha20) | QuarkDash (Gimli) | AES-256-GSM | ECDH/P-256 + AES | RSA-2048 + AES |
|
|
114
|
+
|---------------------------------------|-----------------|-------------------|-------------------|-----------------|----------------|
|
|
115
|
+
| **Type** | Hybrid | Hybrid | Symmetric | Asymmetric (KEX) | Hybrid |
|
|
116
|
+
| **Quantum stability** | β
Ring-LWE | β
Ring-LWE | β No | β No | β No |
|
|
117
|
+
| **Encryption speed (1mb)** | ~2.5 GB/s | ~2.8 GB/s | ~1.2 GB/s | ~50 MB/s (ECIES) | ~10 MB/s |
|
|
118
|
+
| **Decryption speed (1mb)** | ~2.5 GB/s | ~2.8 GB/s | ~1.2 GB/s | ~50 MB/s | ~1 MB/s |
|
|
119
|
+
| **Session speed** | ~10-15 ms | ~10-15 ms | 0 ms (pre-shared) | ~5 ms | ~50 ms |
|
|
120
|
+
| **Key size** | ~2 KB | ~2 KB | N/A | 33 bytes | 256 bytes |
|
|
121
|
+
| **Forward secrecy** | β
| β
| β | β οΈ optional | β |
|
|
122
|
+
| **Out-of-box security** | β
| β
| β οΈ Partial | β οΈ Partial | β |
|
|
123
|
+
| **The Difficulty of Quantum Hacking** | 2^256 | 2^256 | 2^128 (Grover) | 0 (Shor) | 0 (Shor) |
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
> Full comparison can be found [in wiki](https://github.com/devsdaddy/quarkdash)
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Benchmark
|
|
131
|
+
Below I have described performance tests in comparison with other popular encryption algorithm combinations.
|
|
132
|
+
|
|
133
|
+
> **Please, note**. This benchmark is launched at Intel i7-12700H, 32GB RAM, Node.js 20
|
|
134
|
+
|
|
135
|
+
| Operation | QuarkDash (ChaCha20) | QuarkDash (Gimli) | AES-256-GSM | ECDH (P-256) + AES | RSA-2048 |
|
|
136
|
+
|----------------------|----------------------|-------------------|-------------|--------------------|----------|
|
|
137
|
+
| **Key generation** | 12.3ms | 12.1ms | N/A | 1.2ms | 48ms |
|
|
138
|
+
| **Session** (KEM) | 8.7ms | 8.5ms | N/A | 3.4ms | 42ms |
|
|
139
|
+
| **Encryption** (1KB) | 0.003ms | 0.0028ms | 0.005ms | 0.05ms | 0.8ms |
|
|
140
|
+
| **Decryption** (1KB) | 0.003ms | 0.0028ms | 0.005ms | 0.05ms | 0.1ms |
|
|
141
|
+
| **Encryption** (1MB) | 0.42ms | 0.38ms | 0.85ms | 21ms | 102ms |
|
|
142
|
+
| **Decryption** (1MB) | 0.42ms | 0.38ms | 0.85ms | 21ms | 1080ms |
|
|
143
|
+
| **Speed** (MB/s) | 2300 | 2630 | 1176 | 48 | 0.9 |
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Documentation
|
|
149
|
+
> Full documentation with algorithm description, examples and theory [can be found at official wiki pages](https://github.com/devsdaddy/quarkdash/wiki)
|
|
150
|
+
|
|
151
|
+
**Have a questions?** [Contact me](mailto:ilya@neurosell.top)
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Licensing
|
|
156
|
+
**QuarkDash Crypto** library is distributed under the MIT license. You can use it however you like. I would appreciate any feedback and suggestions for improvement.
|
|
157
|
+
Full license text [can be found here](https://github.com/devsdaddy/quarkdash/blob/main/LICENSE)
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
[About](#about-quarkdash-crypto) | [Get Started](#get-started) | [Example](#basic-example) | [Benchmark](#benchmark) | [Docs](https://github.com/devsdaddy/quarkdash/wiki)
|