quarkdash 1.0.8 → 1.1.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/README.md +4 -2
- package/dist/cjs/cipher/chacha.js +154 -0
- package/dist/cjs/cipher/chacha.js.map +1 -0
- package/dist/cjs/cipher/cipher.js +34 -0
- package/dist/cjs/cipher/cipher.js.map +1 -0
- package/dist/cjs/cipher/gimli.js +143 -0
- package/dist/cjs/cipher/gimli.js.map +1 -0
- package/dist/cjs/core/kdf.js.map +1 -0
- package/dist/cjs/{mac.js → core/mac.js} +37 -1
- package/dist/cjs/core/mac.js.map +1 -0
- package/dist/cjs/{types.js.map → core/types.js.map} +1 -1
- package/dist/cjs/{utils.js → core/utils.js} +25 -8
- package/dist/cjs/core/utils.js.map +1 -0
- package/dist/cjs/core/wasm_loader.js +100 -0
- package/dist/cjs/core/wasm_loader.js.map +1 -0
- package/dist/cjs/crypto.js +30 -13
- package/dist/cjs/crypto.js.map +1 -1
- package/dist/cjs/{sha.js → hash/sha.js} +3 -2
- package/dist/cjs/hash/sha.js.map +1 -0
- package/dist/cjs/hash/shake.js +318 -0
- package/dist/cjs/hash/shake.js.map +1 -0
- package/dist/cjs/index.js +16 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/{ringlwe.js → session/baselwe.js} +186 -177
- package/dist/cjs/session/baselwe.js.map +1 -0
- package/dist/cjs/session/ringlwe.js +19 -0
- package/dist/cjs/session/ringlwe.js.map +1 -0
- package/dist/cjs/session/rringlwe.js +42 -0
- package/dist/cjs/session/rringlwe.js.map +1 -0
- package/dist/esm/cipher/chacha.js +150 -0
- package/dist/esm/cipher/chacha.js.map +1 -0
- package/dist/esm/cipher/cipher.js +30 -0
- package/dist/esm/cipher/cipher.js.map +1 -0
- package/dist/esm/cipher/gimli.js +139 -0
- package/dist/esm/cipher/gimli.js.map +1 -0
- package/dist/esm/core/kdf.js.map +1 -0
- package/dist/esm/core/mac.js +87 -0
- package/dist/esm/core/mac.js.map +1 -0
- package/dist/esm/{types.js.map → core/types.js.map} +1 -1
- package/dist/esm/{utils.js → core/utils.js} +24 -4
- package/dist/esm/core/utils.js.map +1 -0
- package/dist/esm/core/wasm_loader.js +64 -0
- package/dist/esm/core/wasm_loader.js.map +1 -0
- package/dist/esm/crypto.js +30 -13
- package/dist/esm/crypto.js.map +1 -1
- package/dist/esm/{sha.js → hash/sha.js} +3 -2
- package/dist/esm/hash/sha.js.map +1 -0
- package/dist/esm/hash/shake.js +311 -0
- package/dist/esm/hash/shake.js.map +1 -0
- package/dist/esm/index.js +16 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{ringlwe.js → session/baselwe.js} +184 -175
- package/dist/esm/session/baselwe.js.map +1 -0
- package/dist/esm/session/ringlwe.js +15 -0
- package/dist/esm/session/ringlwe.js.map +1 -0
- package/dist/esm/session/rringlwe.js +38 -0
- package/dist/esm/session/rringlwe.js.map +1 -0
- package/dist/shake.wasm +0 -0
- package/dist/types/cipher/chacha.d.ts +67 -0
- package/dist/types/cipher/cipher.d.ts +31 -0
- package/dist/types/cipher/gimli.d.ts +64 -0
- package/dist/types/{kdf.d.ts → core/kdf.d.ts} +3 -2
- package/dist/types/{mac.d.ts → core/mac.d.ts} +21 -2
- package/dist/types/{types.d.ts → core/types.d.ts} +5 -2
- package/dist/types/{utils.d.ts → core/utils.d.ts} +13 -0
- package/dist/types/core/wasm_loader.d.ts +5 -0
- package/dist/types/crypto.d.ts +8 -4
- package/dist/types/{sha.d.ts → hash/sha.d.ts} +3 -2
- package/dist/types/hash/shake.d.ts +85 -0
- package/dist/types/index.d.ts +15 -10
- package/dist/types/{ringlwe.d.ts → session/baselwe.d.ts} +49 -59
- package/dist/types/session/ringlwe.d.ts +21 -0
- package/dist/types/session/rringlwe.d.ts +27 -0
- package/package.json +12 -4
- package/wasm/shake.wasm +0 -0
- package/dist/cjs/cipher.js +0 -265
- package/dist/cjs/cipher.js.map +0 -1
- package/dist/cjs/kdf.js.map +0 -1
- package/dist/cjs/mac.js.map +0 -1
- package/dist/cjs/ringlwe.js.map +0 -1
- package/dist/cjs/sha.js.map +0 -1
- package/dist/cjs/shake.js +0 -159
- package/dist/cjs/shake.js.map +0 -1
- package/dist/cjs/utils.js.map +0 -1
- package/dist/esm/cipher.js +0 -259
- package/dist/esm/cipher.js.map +0 -1
- package/dist/esm/kdf.js.map +0 -1
- package/dist/esm/mac.js +0 -51
- package/dist/esm/mac.js.map +0 -1
- package/dist/esm/ringlwe.js.map +0 -1
- package/dist/esm/sha.js.map +0 -1
- package/dist/esm/shake.js +0 -155
- package/dist/esm/shake.js.map +0 -1
- package/dist/esm/utils.js.map +0 -1
- package/dist/types/cipher.d.ts +0 -153
- package/dist/types/shake.d.ts +0 -53
- package/docutil.ts +0 -84
- package/img/cover.png +0 -0
- package/src/cipher.ts +0 -260
- package/src/crypto.ts +0 -306
- package/src/index.ts +0 -27
- package/src/kdf.ts +0 -64
- package/src/mac.ts +0 -65
- package/src/ringlwe.ts +0 -340
- package/src/sha.ts +0 -265
- package/src/shake.ts +0 -163
- package/src/types.ts +0 -75
- package/src/utils.ts +0 -290
- package/tsconfig.cjs.json +0 -7
- package/tsconfig.json +0 -18
- /package/dist/cjs/{kdf.js → core/kdf.js} +0 -0
- /package/dist/cjs/{types.js → core/types.js} +0 -0
- /package/dist/esm/{kdf.js → core/kdf.js} +0 -0
- /package/dist/esm/{types.js → core/types.js} +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ICipher } from "../core/types";
|
|
2
|
+
/**
|
|
3
|
+
* Gimli Cipher
|
|
4
|
+
*/
|
|
5
|
+
export declare class QuarkDashGimli implements ICipher {
|
|
6
|
+
private readonly key;
|
|
7
|
+
private readonly nonce;
|
|
8
|
+
private static readonly BLOCK_SIZE;
|
|
9
|
+
private static readonly BLOCKS_PER_BATCH;
|
|
10
|
+
private static readonly BATCH_SIZE;
|
|
11
|
+
/**
|
|
12
|
+
* Create Gimli Cipher
|
|
13
|
+
* @param key {Uint8Array} Key buffer
|
|
14
|
+
* @param nonce {Uint8Array} Nonce buffer
|
|
15
|
+
*/
|
|
16
|
+
constructor(key: Uint8Array, nonce: Uint8Array);
|
|
17
|
+
/**
|
|
18
|
+
* Encrypt data async using Gimli
|
|
19
|
+
* @param data {Uint8Array} Raw data buffer
|
|
20
|
+
* @returns {Promise<Uint8Array>} Result buffer
|
|
21
|
+
* TODO: GPU Calculations
|
|
22
|
+
*/
|
|
23
|
+
encrypt(data: Uint8Array): Promise<Uint8Array>;
|
|
24
|
+
/**
|
|
25
|
+
* Decrypt data async using Gimli
|
|
26
|
+
* @param data {Uint8Array} Encrypted raw data buffer
|
|
27
|
+
* @returns {Promise<Uint8Array>} Result buffer
|
|
28
|
+
* TODO: GPU Calculations
|
|
29
|
+
*/
|
|
30
|
+
decrypt(data: Uint8Array): Promise<Uint8Array>;
|
|
31
|
+
/**
|
|
32
|
+
* Encrypt data sync using Gimli
|
|
33
|
+
* @param data {Uint8Array} Raw data buffer
|
|
34
|
+
* @returns {Uint8Array} Result buffer
|
|
35
|
+
*/
|
|
36
|
+
encryptSync(data: Uint8Array): Uint8Array;
|
|
37
|
+
/**
|
|
38
|
+
* Decrypt data sync using Gimli
|
|
39
|
+
* @param data {Uint8Array} Encrypted raw data buffer
|
|
40
|
+
* @returns {Uint8Array} Result buffer
|
|
41
|
+
*/
|
|
42
|
+
decryptSync(data: Uint8Array): Uint8Array;
|
|
43
|
+
/**
|
|
44
|
+
* Process Gimli Cipher
|
|
45
|
+
* @param data {Uint8Array} Input buffer
|
|
46
|
+
* @returns {Uint8Array} Output buffer
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
private process;
|
|
50
|
+
/**
|
|
51
|
+
* Generate keystream batch
|
|
52
|
+
* @param startCounter {number} Start counter
|
|
53
|
+
* @param count {number} Count
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
private generateKeystreamBatch;
|
|
57
|
+
/**
|
|
58
|
+
* Gimli Round
|
|
59
|
+
* @param state {Uint32Array} State buffer
|
|
60
|
+
* @param round {number} Round number
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
private gimliRound;
|
|
64
|
+
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* QuarkDash Shake256 Based KDF
|
|
3
3
|
*
|
|
4
4
|
* @git https://github.com/devsdaddy/quarkdash
|
|
5
|
-
* @version 1.
|
|
5
|
+
* @version 1.1.0
|
|
6
6
|
* @author Elijah Rastorguev
|
|
7
|
-
* @build
|
|
7
|
+
* @build 1001
|
|
8
8
|
* @website https://dev.to/devsdaddy
|
|
9
|
+
* @updated 13.04.2026
|
|
9
10
|
*/
|
|
10
11
|
import type { IKDF } from "./types";
|
|
11
12
|
/**
|
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
* QuarkDash Shake256 Based MAC
|
|
3
3
|
*
|
|
4
4
|
* @git https://github.com/devsdaddy/quarkdash
|
|
5
|
-
* @version 1.
|
|
5
|
+
* @version 1.1.0
|
|
6
6
|
* @author Elijah Rastorguev
|
|
7
|
-
* @build
|
|
7
|
+
* @build 1003
|
|
8
8
|
* @website https://dev.to/devsdaddy
|
|
9
|
+
* @updated 14.04.2026
|
|
9
10
|
*/
|
|
10
11
|
import { IMAC } from "./types";
|
|
11
12
|
/**
|
|
12
13
|
* MAC implementation using Shake-256
|
|
13
14
|
*/
|
|
14
15
|
export declare class QuarkDashMAC implements IMAC {
|
|
16
|
+
private tempBuffer;
|
|
17
|
+
constructor();
|
|
15
18
|
/**
|
|
16
19
|
* Sign data async
|
|
17
20
|
* @param data {Uint8Array} Data buffer
|
|
@@ -29,6 +32,22 @@ export declare class QuarkDashMAC implements IMAC {
|
|
|
29
32
|
* TODO: GPU Calculations
|
|
30
33
|
*/
|
|
31
34
|
verify(data: Uint8Array, key: Uint8Array, tag: Uint8Array): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Sign two async
|
|
37
|
+
* @param data1 {Uint8Array} First buffer
|
|
38
|
+
* @param data2 {Uint8Array} Second buffer
|
|
39
|
+
* @param key {Uint8Array} Key
|
|
40
|
+
* @returns {Promise<Uint8Array>}
|
|
41
|
+
*/
|
|
42
|
+
signTwo(data1: Uint8Array, data2: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
|
|
43
|
+
/**
|
|
44
|
+
* Sign two sync
|
|
45
|
+
* @param data1 {Uint8Array} First buffer
|
|
46
|
+
* @param data2 {Uint8Array} Second buffer
|
|
47
|
+
* @param key {Uint8Array} Key
|
|
48
|
+
* @returns {Uint8Array}
|
|
49
|
+
*/
|
|
50
|
+
signTwoSync(data1: Uint8Array, data2: Uint8Array, key: Uint8Array): Uint8Array;
|
|
32
51
|
/**
|
|
33
52
|
* Sign data sync
|
|
34
53
|
* @param data {Uint8Array} Data buffer
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* QuarkDash Crypto Types
|
|
3
3
|
*
|
|
4
4
|
* @git https://github.com/devsdaddy/quarkdash
|
|
5
|
-
* @version 1.
|
|
5
|
+
* @version 1.1.0
|
|
6
6
|
* @author Elijah Rastorguev
|
|
7
|
-
* @build
|
|
7
|
+
* @build 1001
|
|
8
8
|
* @website https://dev.to/devsdaddy
|
|
9
|
+
* @updated 13.04.2026
|
|
9
10
|
*/
|
|
10
11
|
/**
|
|
11
12
|
* Crypto methods async interface
|
|
@@ -38,8 +39,10 @@ export interface IKDF {
|
|
|
38
39
|
*/
|
|
39
40
|
export interface IMAC {
|
|
40
41
|
sign(data: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
|
|
42
|
+
signTwo(data1: Uint8Array, data2: Uint8Array, key: Uint8Array): Promise<Uint8Array>;
|
|
41
43
|
verify(data: Uint8Array, key: Uint8Array, tag: Uint8Array): Promise<boolean>;
|
|
42
44
|
signSync(data: Uint8Array, key: Uint8Array): Uint8Array;
|
|
45
|
+
signTwoSync(data1: Uint8Array, data2: Uint8Array, key: Uint8Array): Uint8Array;
|
|
43
46
|
verifySync(data: Uint8Array, key: Uint8Array, tag: Uint8Array): boolean;
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
@@ -117,4 +117,17 @@ export declare class QuarkDashUtils {
|
|
|
117
117
|
* @returns {bigint} Bigint
|
|
118
118
|
*/
|
|
119
119
|
static readUint64(arr: Uint8Array, off: number): bigint;
|
|
120
|
+
/**
|
|
121
|
+
* Read Uint32 Little Endian Value
|
|
122
|
+
* @param arr {Uint8Array} Buffer
|
|
123
|
+
* @param off {number} Offset
|
|
124
|
+
*/
|
|
125
|
+
static readUint32LE(arr: Uint8Array, off: number): number;
|
|
126
|
+
/**
|
|
127
|
+
* Write Uint32 Little Endian Value
|
|
128
|
+
* @param v {number} Value
|
|
129
|
+
* @param arr {Uint8Array} Buffer
|
|
130
|
+
* @param off {number} Offset
|
|
131
|
+
*/
|
|
132
|
+
static writeUint32LE(v: number, arr: Uint8Array, off: number): void;
|
|
120
133
|
}
|
package/dist/types/crypto.d.ts
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* @git https://github.com/devsdaddy/quarkdash
|
|
5
5
|
* @version 1.0.0
|
|
6
6
|
* @author Elijah Rastorguev
|
|
7
|
-
* @build
|
|
7
|
+
* @build 1105
|
|
8
8
|
* @website https://dev.to/devsdaddy
|
|
9
|
+
* @updated 14.04.2026
|
|
9
10
|
*/
|
|
10
|
-
import { CipherType } from "./cipher";
|
|
11
|
-
import { ICryptoMethodAsync, ICryptoMethodSync, IKDF, IKeyExchange, IMAC } from "./types";
|
|
11
|
+
import { CipherType } from "./cipher/cipher";
|
|
12
|
+
import { ICryptoMethodAsync, ICryptoMethodSync, IKDF, IKeyExchange, IMAC } from "./core/types";
|
|
12
13
|
/**
|
|
13
14
|
* Quark Dash parsed encrypted packet
|
|
14
15
|
*/
|
|
@@ -27,6 +28,10 @@ export interface QuarkDashOptions {
|
|
|
27
28
|
keyExchange: IKeyExchange;
|
|
28
29
|
maxPacketWindow: number;
|
|
29
30
|
timestampToleranceMs: number;
|
|
31
|
+
WASM: {
|
|
32
|
+
isEnabled: boolean;
|
|
33
|
+
shakePath: string;
|
|
34
|
+
};
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
32
37
|
* QuarkDash Crypto Algorithm Implementation
|
|
@@ -37,7 +42,6 @@ export declare class QuarkDash implements ICryptoMethodAsync, ICryptoMethodSync
|
|
|
37
42
|
private cipher;
|
|
38
43
|
private macKey;
|
|
39
44
|
private sendSeq;
|
|
40
|
-
private recvSeq;
|
|
41
45
|
private receivedPackets;
|
|
42
46
|
private myKeyPair?;
|
|
43
47
|
private peerPublicKey?;
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* QuarkDash SHA Implementations
|
|
3
3
|
*
|
|
4
4
|
* @git https://github.com/devsdaddy/quarkdash
|
|
5
|
-
* @version 1.
|
|
5
|
+
* @version 1.1.0
|
|
6
6
|
* @author Elijah Rastorguev
|
|
7
|
-
* @build
|
|
7
|
+
* @build 1001
|
|
8
8
|
* @website https://dev.to/devsdaddy
|
|
9
|
+
* @updated 13.04.2026
|
|
9
10
|
*/
|
|
10
11
|
/**
|
|
11
12
|
* SHA-256 Implementation
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shake-256 Web Assembly Implementation
|
|
3
|
+
*/
|
|
4
|
+
export declare class Shake256Wasm {
|
|
5
|
+
static initializedWasm: boolean;
|
|
6
|
+
private static instance;
|
|
7
|
+
private static memory;
|
|
8
|
+
private static shake256Func;
|
|
9
|
+
private static nextPtr;
|
|
10
|
+
/**
|
|
11
|
+
* Alloc
|
|
12
|
+
* @param size
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
private static alloc;
|
|
16
|
+
/**
|
|
17
|
+
* Initialize WASM Module
|
|
18
|
+
* @param wasmUrl {string} Path to module
|
|
19
|
+
*/
|
|
20
|
+
static initWasm(wasmUrl: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Shake 256 Using WASM
|
|
23
|
+
* @param input {Uint8Array} Input buffer
|
|
24
|
+
* @param outputLen {number} Output length
|
|
25
|
+
* @returns {Uint8Array} Output buffer
|
|
26
|
+
*/
|
|
27
|
+
static shake256Wasm(input: Uint8Array, outputLen: number): Uint8Array;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns is wasm shake or not
|
|
31
|
+
*/
|
|
32
|
+
export declare function isWasmShake(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Keccak State
|
|
35
|
+
*/
|
|
36
|
+
export declare class KeccakState {
|
|
37
|
+
private readonly stateLow;
|
|
38
|
+
private readonly stateHigh;
|
|
39
|
+
/**
|
|
40
|
+
* Create Keccak State
|
|
41
|
+
*/
|
|
42
|
+
constructor();
|
|
43
|
+
/**
|
|
44
|
+
* XOR of byte to state
|
|
45
|
+
* @param byte
|
|
46
|
+
* @param index
|
|
47
|
+
*/
|
|
48
|
+
absorbByte(byte: number, index: number): void;
|
|
49
|
+
/**
|
|
50
|
+
* Extract byte from state
|
|
51
|
+
* @param index {number}
|
|
52
|
+
*/
|
|
53
|
+
extractByte(index: number): number;
|
|
54
|
+
/**
|
|
55
|
+
* Permute Keccak-f[1600]
|
|
56
|
+
*/
|
|
57
|
+
permute(): void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Shake-256 Hash
|
|
61
|
+
*/
|
|
62
|
+
export declare class Shake256 {
|
|
63
|
+
/**
|
|
64
|
+
* Shake-256 async
|
|
65
|
+
* @param input {Uint8Array} Input buffer
|
|
66
|
+
* @param outputLength {number} Output buffer length
|
|
67
|
+
* @returns {Uint8Array} Output buffer
|
|
68
|
+
*/
|
|
69
|
+
static hash(input: Uint8Array, outputLength: number): Promise<Uint8Array>;
|
|
70
|
+
/**
|
|
71
|
+
* Shake-256 sync
|
|
72
|
+
* @param input {Uint8Array} Input buffer
|
|
73
|
+
* @param outputLength {number} Output buffer length
|
|
74
|
+
* @returns {Uint8Array} Output buffer
|
|
75
|
+
*/
|
|
76
|
+
static hashSync(input: Uint8Array, outputLength: number): Uint8Array;
|
|
77
|
+
/**
|
|
78
|
+
* Process SHAKE-256
|
|
79
|
+
* @param input {Uint8Array} Input buffer
|
|
80
|
+
* @param outputLength {number} Output length
|
|
81
|
+
* @returns {Uint8Array} Output buffer
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
private static process;
|
|
85
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,17 +2,22 @@
|
|
|
2
2
|
* QuarkDash Crypto Library
|
|
3
3
|
*
|
|
4
4
|
* @git https://github.com/devsdaddy/quarkdash
|
|
5
|
-
* @version 1.
|
|
5
|
+
* @version 1.1.0
|
|
6
6
|
* @author Elijah Rastorguev
|
|
7
|
-
* @build
|
|
7
|
+
* @build 1003
|
|
8
8
|
* @website https://dev.to/devsdaddy
|
|
9
|
+
* @updated 14.04.2026
|
|
9
10
|
*/
|
|
10
|
-
export * from "./types";
|
|
11
|
-
export * from "./utils";
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./
|
|
17
|
-
export * from "./
|
|
11
|
+
export * from "./core/types";
|
|
12
|
+
export * from "./core/utils";
|
|
13
|
+
export * from "./core/wasm_loader";
|
|
14
|
+
export * from "./core/kdf";
|
|
15
|
+
export * from "./core/mac";
|
|
16
|
+
export * from "./hash/shake";
|
|
17
|
+
export * from "./hash/sha";
|
|
18
|
+
export * from "./cipher/cipher";
|
|
19
|
+
export * from "./cipher/chacha";
|
|
20
|
+
export * from "./cipher/gimli";
|
|
21
|
+
export * from "./session/ringlwe";
|
|
22
|
+
export * from "./session/rringlwe";
|
|
18
23
|
export * from "./crypto";
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
+
import { ICryptoEncapsulated, ICryptoKeyPair } from "../core/types";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @git https://github.com/devsdaddy/quarkdash
|
|
5
|
-
* @version 1.0.0
|
|
6
|
-
* @author Elijah Rastorguev
|
|
7
|
-
* @build 1002
|
|
8
|
-
* @website https://dev.to/devsdaddy
|
|
9
|
-
* @updated 12.04.2026
|
|
3
|
+
* Base Ring-LWE Function
|
|
10
4
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private static readonly N;
|
|
17
|
-
private static readonly Q;
|
|
18
|
-
private static readonly ROOT;
|
|
19
|
-
private static readonly INV_N;
|
|
5
|
+
export declare class BaseRingLWE {
|
|
6
|
+
protected readonly N = 256;
|
|
7
|
+
protected readonly Q: any;
|
|
8
|
+
protected readonly ROOT = 7n;
|
|
9
|
+
protected readonly INV_N: bigint;
|
|
20
10
|
/**
|
|
21
11
|
* Generate crypto key pair async
|
|
22
12
|
* @returns {ICryptoKeyPair} Crypto key pair
|
|
@@ -59,86 +49,86 @@ export declare class QuarkDashKeyExchange implements IKeyExchange {
|
|
|
59
49
|
*/
|
|
60
50
|
decapsulateSync(privateKey: Uint8Array, peerPublicKey: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
61
51
|
/**
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
52
|
+
* Modular inverse
|
|
53
|
+
* @param a {bigint}
|
|
54
|
+
* @param m {bigint}
|
|
55
|
+
* @returns {bigint} Inversion result
|
|
64
56
|
* @private
|
|
65
57
|
*/
|
|
66
|
-
|
|
58
|
+
protected modInverse(a: bigint, m: bigint): bigint;
|
|
67
59
|
/**
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
60
|
+
* Modular exponentiation
|
|
61
|
+
* @param base {bigint} Base
|
|
62
|
+
* @param exp {bigint} exponential
|
|
63
|
+
* @param mod {bigint} module
|
|
64
|
+
* @returns {bigint} Result of modular exponentiation
|
|
70
65
|
* @private
|
|
71
66
|
*/
|
|
72
|
-
|
|
67
|
+
protected powMod(base: bigint, exp: bigint, mod: bigint): bigint;
|
|
73
68
|
/**
|
|
74
|
-
*
|
|
69
|
+
* Round to bits
|
|
70
|
+
* @param poly {bigint[]} Polygon
|
|
71
|
+
* @returns {Uint8Array} rounded buffer
|
|
75
72
|
* @private
|
|
76
73
|
*/
|
|
77
|
-
|
|
74
|
+
protected roundToBits(poly: bigint[]): Uint8Array;
|
|
78
75
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @param
|
|
76
|
+
* Deserialize Polygon
|
|
77
|
+
* @param bytes {Uint8Array} Polygon buffer
|
|
78
|
+
* @returns {bigint[]} Polygon
|
|
81
79
|
* @private
|
|
82
80
|
*/
|
|
83
|
-
|
|
81
|
+
protected deserializePoly(bytes: Uint8Array): bigint[];
|
|
84
82
|
/**
|
|
85
|
-
*
|
|
83
|
+
* Serialize polygon
|
|
86
84
|
* @param poly {bigint[]} Polygon
|
|
85
|
+
* @returns {Uint8Array} Polygon buffer
|
|
87
86
|
* @private
|
|
88
87
|
*/
|
|
89
|
-
|
|
88
|
+
protected serializePoly(poly: bigint[]): Uint8Array;
|
|
90
89
|
/**
|
|
91
90
|
* Multiply
|
|
92
91
|
* @param a {bigint[]} Polygon
|
|
93
92
|
* @param b {bigint[]} Polygon
|
|
94
93
|
* @returns {bigint[]} Multiplied polygons
|
|
95
94
|
*/
|
|
96
|
-
|
|
95
|
+
protected multiply(a: bigint[], b: bigint[]): bigint[];
|
|
97
96
|
/**
|
|
98
|
-
*
|
|
97
|
+
* Inverse NTT
|
|
99
98
|
* @param poly {bigint[]} Polygon
|
|
100
|
-
* @returns {Uint8Array} Polygon buffer
|
|
101
99
|
* @private
|
|
102
100
|
*/
|
|
103
|
-
|
|
101
|
+
protected invNTT(poly: bigint[]): bigint[];
|
|
104
102
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @param
|
|
107
|
-
* @returns {bigint[]} Polygon
|
|
103
|
+
* NTT Operation
|
|
104
|
+
* @param poly {bigint[]} Polygon
|
|
108
105
|
* @private
|
|
109
106
|
*/
|
|
110
|
-
|
|
107
|
+
protected ntt(poly: bigint[]): bigint[];
|
|
111
108
|
/**
|
|
112
|
-
*
|
|
113
|
-
* @param poly {bigint[]} Polygon
|
|
114
|
-
* @returns {Uint8Array} rounded buffer
|
|
109
|
+
* Error polygon
|
|
115
110
|
* @private
|
|
116
111
|
*/
|
|
117
|
-
|
|
112
|
+
protected errorPoly(): bigint[];
|
|
118
113
|
/**
|
|
119
|
-
*
|
|
120
|
-
* @
|
|
121
|
-
* @param exp {bigint} exponential
|
|
122
|
-
* @param mod {bigint} module
|
|
123
|
-
* @returns {bigint} Result of modular exponentiation
|
|
114
|
+
* Uniform polygon
|
|
115
|
+
* @returns {bigint[]}
|
|
124
116
|
* @private
|
|
125
117
|
*/
|
|
126
|
-
|
|
118
|
+
protected uniformPoly(): bigint[];
|
|
127
119
|
/**
|
|
128
|
-
*
|
|
129
|
-
* @
|
|
130
|
-
* @param m {bigint}
|
|
131
|
-
* @returns {bigint} Inversion result
|
|
120
|
+
* Get small polygon
|
|
121
|
+
* @returns {bigint[]} Small polygon
|
|
132
122
|
* @private
|
|
133
123
|
*/
|
|
134
|
-
|
|
124
|
+
protected smallPoly(): bigint[];
|
|
135
125
|
/**
|
|
136
126
|
* Hash shared secret
|
|
137
|
-
* @param ss {Uint8Array} Shared
|
|
138
|
-
* @param publicKey {Uint8Array} Public
|
|
139
|
-
* @param ciphertext {Uint8Array} Cipher text
|
|
140
|
-
* @returns {Uint8Array}
|
|
141
|
-
* @
|
|
127
|
+
* @param ss {Uint8Array} Shared Secret
|
|
128
|
+
* @param publicKey {Uint8Array} Public Key
|
|
129
|
+
* @param ciphertext {Uint8Array} Cipher text
|
|
130
|
+
* @returns {Uint8Array} Hash buffer
|
|
131
|
+
* @protected
|
|
142
132
|
*/
|
|
143
|
-
|
|
133
|
+
protected hashSharedSecretSync(ss: Uint8Array, publicKey: Uint8Array, ciphertext: Uint8Array): Uint8Array;
|
|
144
134
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QuarkDash Ring-LWE Implementation
|
|
3
|
+
*
|
|
4
|
+
* @git https://github.com/devsdaddy/quarkdash
|
|
5
|
+
* @version 1.1.0
|
|
6
|
+
* @author Elijah Rastorguev
|
|
7
|
+
* @build 1003
|
|
8
|
+
* @website https://dev.to/devsdaddy
|
|
9
|
+
* @updated 13.04.2026
|
|
10
|
+
*/
|
|
11
|
+
import { IKeyExchange } from "../core/types";
|
|
12
|
+
import { BaseRingLWE } from "./baselwe";
|
|
13
|
+
/**
|
|
14
|
+
* Ring-LWE based key exchange implementation
|
|
15
|
+
*/
|
|
16
|
+
export declare class QuarkDashRLWE extends BaseRingLWE implements IKeyExchange {
|
|
17
|
+
protected readonly N = 256;
|
|
18
|
+
protected readonly Q = 7681n;
|
|
19
|
+
protected readonly ROOT = 7n;
|
|
20
|
+
protected readonly INV_N: bigint;
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QuarkDash Radical Ring-LWE Implementation
|
|
3
|
+
*
|
|
4
|
+
* @git https://github.com/devsdaddy/quarkdash
|
|
5
|
+
* @version 1.1.0
|
|
6
|
+
* @author Elijah Rastorguev
|
|
7
|
+
* @build 1002
|
|
8
|
+
* @website https://dev.to/devsdaddy
|
|
9
|
+
* @updated 13.04.2026
|
|
10
|
+
*/
|
|
11
|
+
import { IKeyExchange } from "../core/types";
|
|
12
|
+
import { BaseRingLWE } from "./baselwe";
|
|
13
|
+
/**
|
|
14
|
+
* QuarkDash Radical Ring-LWE Implementation
|
|
15
|
+
*/
|
|
16
|
+
export declare class QuarkDashRRLWE extends BaseRingLWE implements IKeyExchange {
|
|
17
|
+
protected readonly N = 256;
|
|
18
|
+
protected readonly Q = 12289n;
|
|
19
|
+
protected readonly ROOT = 7n;
|
|
20
|
+
protected readonly INV_N: bigint;
|
|
21
|
+
/**
|
|
22
|
+
* Override small polynome for Radical Ring-lWE
|
|
23
|
+
* @returns {bigint[]} Small polynome
|
|
24
|
+
* @protected
|
|
25
|
+
*/
|
|
26
|
+
protected smallPoly(): bigint[];
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quarkdash",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "QuarkDash - pure typescript hybrid cryptographic protocol that provides post-quantum security, high performance, and attack resistance.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"quark",
|
|
@@ -39,26 +39,34 @@
|
|
|
39
39
|
"scripts": {
|
|
40
40
|
"update-docs": "ts-node docutil.ts",
|
|
41
41
|
"clean": "rm -rf dist",
|
|
42
|
-
"build": "npm run clean && npm run update-docs && npm run build:esm && npm run build:cjs && npm run build:types",
|
|
42
|
+
"build": "npm run clean && npm run update-docs && npm run build:esm && npm run build:cjs && npm run build:types && npm run copy_wasm",
|
|
43
43
|
"build:esm": "tsc -p tsconfig.json",
|
|
44
44
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
45
45
|
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly --declaration --outDir dist/types",
|
|
46
|
+
"copy_wasm": "cp -r \"wasm/shake.wasm\" \"dist/\"",
|
|
46
47
|
"test": "jest --coverage",
|
|
47
48
|
"test:watch": "jest --watch",
|
|
48
49
|
"bench": "ts-node --compiler-options '{\"module\":\"CommonJS\"}' benchmarks/bench.ts",
|
|
49
50
|
"prepublishOnly": "npm run build && npm test"
|
|
50
51
|
},
|
|
52
|
+
"files": [
|
|
53
|
+
"wasm", "dist"
|
|
54
|
+
],
|
|
51
55
|
"devDependencies": {
|
|
52
56
|
"@types/jest": "^29.5.0",
|
|
53
57
|
"@types/node": "^20.0.0",
|
|
54
|
-
"
|
|
58
|
+
"copyfiles": "^2.4.1",
|
|
55
59
|
"jest": "^29.5.0",
|
|
56
60
|
"ts-jest": "^29.1.0",
|
|
61
|
+
"ts-morph": "^27.0.2",
|
|
57
62
|
"ts-node": "^10.9.0",
|
|
58
63
|
"typescript": "^5.0.0",
|
|
59
64
|
"ws": "^8.14.0"
|
|
60
65
|
},
|
|
61
|
-
"dependencies": {
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"fs": "^0.0.1-security",
|
|
68
|
+
"path": "^0.12.7"
|
|
69
|
+
},
|
|
62
70
|
"engines": {
|
|
63
71
|
"node": ">=16.0.0"
|
|
64
72
|
}
|
package/wasm/shake.wasm
ADDED
|
Binary file
|