quarkdash 1.0.7 → 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.
Files changed (113) hide show
  1. package/README.md +4 -2
  2. package/dist/cjs/cipher/chacha.js +154 -0
  3. package/dist/cjs/cipher/chacha.js.map +1 -0
  4. package/dist/cjs/cipher/cipher.js +34 -0
  5. package/dist/cjs/cipher/cipher.js.map +1 -0
  6. package/dist/cjs/cipher/gimli.js +143 -0
  7. package/dist/cjs/cipher/gimli.js.map +1 -0
  8. package/dist/cjs/core/kdf.js.map +1 -0
  9. package/dist/cjs/{mac.js → core/mac.js} +37 -1
  10. package/dist/cjs/core/mac.js.map +1 -0
  11. package/dist/cjs/{types.js.map → core/types.js.map} +1 -1
  12. package/dist/cjs/{utils.js → core/utils.js} +25 -8
  13. package/dist/cjs/core/utils.js.map +1 -0
  14. package/dist/cjs/core/wasm_loader.js +100 -0
  15. package/dist/cjs/core/wasm_loader.js.map +1 -0
  16. package/dist/cjs/crypto.js +30 -13
  17. package/dist/cjs/crypto.js.map +1 -1
  18. package/dist/cjs/{sha.js → hash/sha.js} +3 -2
  19. package/dist/cjs/hash/sha.js.map +1 -0
  20. package/dist/cjs/hash/shake.js +318 -0
  21. package/dist/cjs/hash/shake.js.map +1 -0
  22. package/dist/cjs/index.js +16 -11
  23. package/dist/cjs/index.js.map +1 -1
  24. package/dist/cjs/{ringlwe.js → session/baselwe.js} +246 -203
  25. package/dist/cjs/session/baselwe.js.map +1 -0
  26. package/dist/cjs/session/ringlwe.js +19 -0
  27. package/dist/cjs/session/ringlwe.js.map +1 -0
  28. package/dist/cjs/session/rringlwe.js +42 -0
  29. package/dist/cjs/session/rringlwe.js.map +1 -0
  30. package/dist/esm/cipher/chacha.js +150 -0
  31. package/dist/esm/cipher/chacha.js.map +1 -0
  32. package/dist/esm/cipher/cipher.js +30 -0
  33. package/dist/esm/cipher/cipher.js.map +1 -0
  34. package/dist/esm/cipher/gimli.js +139 -0
  35. package/dist/esm/cipher/gimli.js.map +1 -0
  36. package/dist/esm/core/kdf.js.map +1 -0
  37. package/dist/esm/core/mac.js +87 -0
  38. package/dist/esm/core/mac.js.map +1 -0
  39. package/dist/esm/{types.js.map → core/types.js.map} +1 -1
  40. package/dist/esm/{utils.js → core/utils.js} +24 -4
  41. package/dist/esm/core/utils.js.map +1 -0
  42. package/dist/esm/core/wasm_loader.js +64 -0
  43. package/dist/esm/core/wasm_loader.js.map +1 -0
  44. package/dist/esm/crypto.js +30 -13
  45. package/dist/esm/crypto.js.map +1 -1
  46. package/dist/esm/{sha.js → hash/sha.js} +3 -2
  47. package/dist/esm/hash/sha.js.map +1 -0
  48. package/dist/esm/hash/shake.js +311 -0
  49. package/dist/esm/hash/shake.js.map +1 -0
  50. package/dist/esm/index.js +16 -11
  51. package/dist/esm/index.js.map +1 -1
  52. package/dist/esm/{ringlwe.js → session/baselwe.js} +244 -201
  53. package/dist/esm/session/baselwe.js.map +1 -0
  54. package/dist/esm/session/ringlwe.js +15 -0
  55. package/dist/esm/session/ringlwe.js.map +1 -0
  56. package/dist/esm/session/rringlwe.js +38 -0
  57. package/dist/esm/session/rringlwe.js.map +1 -0
  58. package/dist/shake.wasm +0 -0
  59. package/dist/types/cipher/chacha.d.ts +67 -0
  60. package/dist/types/cipher/cipher.d.ts +31 -0
  61. package/dist/types/cipher/gimli.d.ts +64 -0
  62. package/dist/types/{kdf.d.ts → core/kdf.d.ts} +3 -2
  63. package/dist/types/{mac.d.ts → core/mac.d.ts} +21 -2
  64. package/dist/types/{types.d.ts → core/types.d.ts} +5 -2
  65. package/dist/types/{utils.d.ts → core/utils.d.ts} +13 -0
  66. package/dist/types/core/wasm_loader.d.ts +5 -0
  67. package/dist/types/crypto.d.ts +8 -4
  68. package/dist/types/{sha.d.ts → hash/sha.d.ts} +3 -2
  69. package/dist/types/hash/shake.d.ts +85 -0
  70. package/dist/types/index.d.ts +15 -10
  71. package/dist/types/{ringlwe.d.ts → session/baselwe.d.ts} +87 -91
  72. package/dist/types/session/ringlwe.d.ts +21 -0
  73. package/dist/types/session/rringlwe.d.ts +27 -0
  74. package/package.json +13 -3
  75. package/wasm/shake.wasm +0 -0
  76. package/dist/cjs/cipher.js +0 -265
  77. package/dist/cjs/cipher.js.map +0 -1
  78. package/dist/cjs/kdf.js.map +0 -1
  79. package/dist/cjs/mac.js.map +0 -1
  80. package/dist/cjs/ringlwe.js.map +0 -1
  81. package/dist/cjs/sha.js.map +0 -1
  82. package/dist/cjs/shake.js +0 -159
  83. package/dist/cjs/shake.js.map +0 -1
  84. package/dist/cjs/utils.js.map +0 -1
  85. package/dist/esm/cipher.js +0 -259
  86. package/dist/esm/cipher.js.map +0 -1
  87. package/dist/esm/kdf.js.map +0 -1
  88. package/dist/esm/mac.js +0 -51
  89. package/dist/esm/mac.js.map +0 -1
  90. package/dist/esm/ringlwe.js.map +0 -1
  91. package/dist/esm/sha.js.map +0 -1
  92. package/dist/esm/shake.js +0 -155
  93. package/dist/esm/shake.js.map +0 -1
  94. package/dist/esm/utils.js.map +0 -1
  95. package/dist/types/cipher.d.ts +0 -153
  96. package/dist/types/shake.d.ts +0 -53
  97. package/img/cover.png +0 -0
  98. package/src/cipher.ts +0 -260
  99. package/src/crypto.ts +0 -306
  100. package/src/index.ts +0 -27
  101. package/src/kdf.ts +0 -64
  102. package/src/mac.ts +0 -65
  103. package/src/ringlwe.ts +0 -289
  104. package/src/sha.ts +0 -265
  105. package/src/shake.ts +0 -163
  106. package/src/types.ts +0 -75
  107. package/src/utils.ts +0 -290
  108. package/tsconfig.cjs.json +0 -7
  109. package/tsconfig.json +0 -18
  110. /package/dist/cjs/{kdf.js → core/kdf.js} +0 -0
  111. /package/dist/cjs/{types.js → core/types.js} +0 -0
  112. /package/dist/esm/{kdf.js → core/kdf.js} +0 -0
  113. /package/dist/esm/{types.js → core/types.js} +0 -0
@@ -0,0 +1,67 @@
1
+ import { ICipher } from "../core/types";
2
+ /**
3
+ * ChaCha20 Based Cipher Implementation
4
+ */
5
+ export declare class QuarkDashChaCha 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 ChaCha20 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 ChaCha20
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 ChaCha20
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 ChaCha20
33
+ * @param data {Uint8Array} Raw data buffer
34
+ * @returns {Uint8Array} Result buffer
35
+ */
36
+ encryptSync(data: Uint8Array): Uint8Array;
37
+ /**
38
+ * Decrypt data sync using ChaCha20
39
+ * @param data {Uint8Array} Encrypted raw data buffer
40
+ * @returns {Uint8Array} Result buffer
41
+ */
42
+ decryptSync(data: Uint8Array): Uint8Array;
43
+ /**
44
+ * Process ChaCha20 Cipher
45
+ * @param data {Uint8Array} Data for processing
46
+ * @returns {Uint8Array} Processing result
47
+ * @private
48
+ */
49
+ private process;
50
+ /**
51
+ * Quarter Round
52
+ * @param s {Uint8Array} Buffer
53
+ * @param a {number}
54
+ * @param b {number}
55
+ * @param c {number}
56
+ * @param d {number}
57
+ * @private
58
+ */
59
+ private quarterRound;
60
+ /**
61
+ * Generate Keystream Batch
62
+ * @param startCounter {number} Start counter
63
+ * @param count {number} Count
64
+ * @private
65
+ */
66
+ private generateKeystreamBatch;
67
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * QuarkDash Ciphers 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 { ICipher } from "../core/types";
12
+ /**
13
+ * Cipher Type
14
+ */
15
+ export declare enum CipherType {
16
+ ChaCha20 = 0,
17
+ Gimli = 1
18
+ }
19
+ /**
20
+ * Cipher Factory
21
+ */
22
+ export declare class CipherFactory {
23
+ /**
24
+ * Create Cipher
25
+ * @param algorithm {CipherType} Current cipher type
26
+ * @param key {Uint8Array} Key buffer
27
+ * @param nonce {Uint8Array} Nonce buffer
28
+ * @returns {ICipher} Cipher class instance
29
+ */
30
+ static create(algorithm: CipherType, key: Uint8Array, nonce: Uint8Array): ICipher;
31
+ }
@@ -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.0.0
5
+ * @version 1.1.0
6
6
  * @author Elijah Rastorguev
7
- * @build 1000
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.0.0
5
+ * @version 1.1.0
6
6
  * @author Elijah Rastorguev
7
- * @build 1000
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.0.0
5
+ * @version 1.1.0
6
6
  * @author Elijah Rastorguev
7
- * @build 1000
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
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Load WASM Module
3
+ * @param wasmUrl
4
+ */
5
+ export declare function loadWasmModule(wasmUrl: string): Promise<WebAssembly.Module>;
@@ -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 1000
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.0.0
5
+ * @version 1.1.0
6
6
  * @author Elijah Rastorguev
7
- * @build 1000
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
+ }
@@ -2,17 +2,22 @@
2
2
  * QuarkDash Crypto Library
3
3
  *
4
4
  * @git https://github.com/devsdaddy/quarkdash
5
- * @version 1.0.0
5
+ * @version 1.1.0
6
6
  * @author Elijah Rastorguev
7
- * @build 1000
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 "./shake";
13
- export * from "./sha";
14
- export * from "./kdf";
15
- export * from "./mac";
16
- export * from "./cipher";
17
- export * from "./ringlwe";
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,90 +1,12 @@
1
+ import { ICryptoEncapsulated, ICryptoKeyPair } from "../core/types";
1
2
  /**
2
- * QuarkDash Ring-LWE Implementation
3
- *
4
- * @git https://github.com/devsdaddy/quarkdash
5
- * @version 1.0.0
6
- * @author Elijah Rastorguev
7
- * @build 1000
8
- * @website https://dev.to/devsdaddy
3
+ * Base Ring-LWE Function
9
4
  */
10
- import { ICryptoEncapsulated, ICryptoKeyPair, IKeyExchange } from "./types";
11
- /**
12
- * Ring-LWE based key exchange implementation
13
- */
14
- export declare class QuarkDashKeyExchange implements IKeyExchange {
15
- private static readonly N;
16
- private static readonly Q;
17
- private static readonly ROOT;
18
- private static readonly INV_N;
19
- /**
20
- * Get small polygon
21
- * @returns {bigint[]} Small polygon
22
- * @private
23
- */
24
- private static smallPoly;
25
- /**
26
- * Uniform polygon
27
- * @returns {bigint[]}
28
- * @private
29
- */
30
- private static uniformPoly;
31
- /**
32
- * NTT Operation
33
- * @param poly {bigint[]} Polygon
34
- * @private
35
- */
36
- private static ntt;
37
- /**
38
- * Inverse NTT
39
- * @param poly {bigint[]} Polygon
40
- * @private
41
- */
42
- private static invNTT;
43
- /**
44
- * Multiply
45
- * @param a {bigint[]} Polygon
46
- * @param b {bigint[]} Polygon
47
- * @returns {bigint[]} Multiplied polygons
48
- */
49
- static multiply(a: bigint[], b: bigint[]): bigint[];
50
- /**
51
- * Serialize polygon
52
- * @param poly {bigint[]} Polygon
53
- * @returns {Uint8Array} Polygon buffer
54
- * @private
55
- */
56
- private static serializePoly;
57
- /**
58
- * Deserialize Polygon
59
- * @param bytes {Uint8Array} Polygon buffer
60
- * @returns {bigint[]} Polygon
61
- * @private
62
- */
63
- private static deserializePoly;
64
- /**
65
- * Round to bits
66
- * @param poly {bigint[]} Polygon
67
- * @returns {Uint8Array} rounded buffer
68
- * @private
69
- */
70
- private static roundToBits;
71
- /**
72
- * Modular exponentiation
73
- * @param base {bigint} Base
74
- * @param exp {bigint} exponential
75
- * @param mod {bigint} module
76
- * @returns {bigint} Result of modular exponentiation
77
- * @private
78
- */
79
- private static powMod;
80
- /**
81
- * Modular inverse
82
- * @param a {bigint}
83
- * @param m {bigint}
84
- * @returns {bigint} Inversion result
85
- * @private
86
- */
87
- private static modInverse;
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;
88
10
  /**
89
11
  * Generate crypto key pair async
90
12
  * @returns {ICryptoKeyPair} Crypto key pair
@@ -127,12 +49,86 @@ export declare class QuarkDashKeyExchange implements IKeyExchange {
127
49
  */
128
50
  decapsulateSync(privateKey: Uint8Array, peerPublicKey: Uint8Array, ciphertext: Uint8Array): Uint8Array;
129
51
  /**
130
- * Hash shared secret
131
- * @param ss {Uint8Array} Shared secret buffer
132
- * @param publicKey {Uint8Array} Public key buffer
133
- * @param ciphertext {Uint8Array} Cipher text buffer
134
- * @returns {Uint8Array} Shared secret hash
52
+ * Modular inverse
53
+ * @param a {bigint}
54
+ * @param m {bigint}
55
+ * @returns {bigint} Inversion result
56
+ * @private
57
+ */
58
+ protected modInverse(a: bigint, m: bigint): bigint;
59
+ /**
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
65
+ * @private
66
+ */
67
+ protected powMod(base: bigint, exp: bigint, mod: bigint): bigint;
68
+ /**
69
+ * Round to bits
70
+ * @param poly {bigint[]} Polygon
71
+ * @returns {Uint8Array} rounded buffer
72
+ * @private
73
+ */
74
+ protected roundToBits(poly: bigint[]): Uint8Array;
75
+ /**
76
+ * Deserialize Polygon
77
+ * @param bytes {Uint8Array} Polygon buffer
78
+ * @returns {bigint[]} Polygon
79
+ * @private
80
+ */
81
+ protected deserializePoly(bytes: Uint8Array): bigint[];
82
+ /**
83
+ * Serialize polygon
84
+ * @param poly {bigint[]} Polygon
85
+ * @returns {Uint8Array} Polygon buffer
135
86
  * @private
136
87
  */
137
- private hashSharedSecret;
88
+ protected serializePoly(poly: bigint[]): Uint8Array;
89
+ /**
90
+ * Multiply
91
+ * @param a {bigint[]} Polygon
92
+ * @param b {bigint[]} Polygon
93
+ * @returns {bigint[]} Multiplied polygons
94
+ */
95
+ protected multiply(a: bigint[], b: bigint[]): bigint[];
96
+ /**
97
+ * Inverse NTT
98
+ * @param poly {bigint[]} Polygon
99
+ * @private
100
+ */
101
+ protected invNTT(poly: bigint[]): bigint[];
102
+ /**
103
+ * NTT Operation
104
+ * @param poly {bigint[]} Polygon
105
+ * @private
106
+ */
107
+ protected ntt(poly: bigint[]): bigint[];
108
+ /**
109
+ * Error polygon
110
+ * @private
111
+ */
112
+ protected errorPoly(): bigint[];
113
+ /**
114
+ * Uniform polygon
115
+ * @returns {bigint[]}
116
+ * @private
117
+ */
118
+ protected uniformPoly(): bigint[];
119
+ /**
120
+ * Get small polygon
121
+ * @returns {bigint[]} Small polygon
122
+ * @private
123
+ */
124
+ protected smallPoly(): bigint[];
125
+ /**
126
+ * Hash shared secret
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
132
+ */
133
+ protected hashSharedSecretSync(ss: Uint8Array, publicKey: Uint8Array, ciphertext: Uint8Array): Uint8Array;
138
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
+ }