@kynesyslabs/demosdk 2.1.15 → 2.2.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.
@@ -1,520 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- /* INFO Enigma - An experimental wrapper for Post Quantum Cryptography in Typescript designed with ease of use in mind
37
- Currently suggested and tested schemas for each algorithm are:
38
- - Signing: ml-dsa or falcon
39
- - Encryption: NTRU
40
- - Hashing: SHA-3
41
-
42
- While implemented, the following algorithms are not included in the pqc test suite:
43
- - Key Encapsulation: McEliece
44
-
45
- While implemented, the following algorithms are not fully tested:
46
- - ChaCha20-Poly1305
47
-
48
- To properly test the encryption and decryption of data, please see the pqc test suite.
49
- */
50
- const mceliece_nist_1 = require("mceliece-nist");
51
- const js_sha3_1 = require("js-sha3");
52
- const crypto = __importStar(require("crypto"));
53
- const ntru_1 = require("ntru");
54
- const falconts_1 = require("./falconts");
55
- const ml_dsa_1 = require("@noble/post-quantum/ml-dsa");
56
- const utils_1 = require("./ml-dsa/utils");
57
- const utils_2 = require("@noble/hashes/utils");
58
- // INFO Main class
59
- class Enigma {
60
- constructor() {
61
- this.signingKeyPair = null;
62
- this.signingSeed = null;
63
- this.falconKeyPair = null;
64
- this.chaCha20Keypair = null;
65
- this.mcelieceKeypair = null;
66
- this.ntruKeyPair = null;
67
- this.kem = new mceliece_nist_1.McEliece("mceliece8192128");
68
- // Nonce size for ChaCha20-Poly1305 (12 bytes = 96 bits)
69
- this.NONCE_SIZE = 12;
70
- }
71
- /**
72
- * Generates a cryptographically secure random value of specified length
73
- * @param length The length of the random value in bytes
74
- * @returns A Buffer containing random bytes
75
- */
76
- generateRandomBytes(length) {
77
- return crypto.randomBytes(length);
78
- }
79
- /**
80
- * Generates a key pair for encryption with NTRU
81
- * @returns A promise that resolves when the key pair is generated
82
- */
83
- async genNTRUKeyPair() {
84
- this.ntruKeyPair = await ntru_1.ntru.keyPair();
85
- }
86
- /**
87
- * Generates a key pair for mcEliece
88
- * @returns A promise that resolves when the key pair is generated
89
- */
90
- async genMcElieceKeyPair() {
91
- this.mcelieceKeypair = this.kem.keypair();
92
- }
93
- /**
94
- * Generates a Falcon key pair
95
- * @param seed The seed to use for key generation
96
- * @returns A promise that resolves when the key pair is generated
97
- */
98
- async genFalconKeyPair(seed = null) {
99
- if (!seed) {
100
- seed = (0, utils_2.randomBytes)(48);
101
- }
102
- const falcon = new falconts_1.Falcon();
103
- await falcon.init();
104
- await falcon.genkey(seed);
105
- this.falconKeyPair = await falcon.getKeypair();
106
- }
107
- /**
108
- * Generates a signing key pair
109
- * @param seed The seed to use for key generation
110
- * @returns A promise that resolves when the key pair is generated
111
- */
112
- async genSigningKeyPair(seed = null) {
113
- if (!seed) {
114
- seed = (0, utils_2.randomBytes)(32);
115
- }
116
- this.signingSeed = seed;
117
- const dlKeys = ml_dsa_1.ml_dsa65.keygen(seed);
118
- this.signingKeyPair = {
119
- privateKey: dlKeys.secretKey,
120
- publicKey: dlKeys.publicKey
121
- };
122
- }
123
- /* SECTION Signatures with ml-dsa */
124
- /**
125
- * Signs a message using ml-dsa
126
- * @param message The message to sign
127
- * @returns A promise that resolves to the signature
128
- */
129
- async sign(message) {
130
- if (typeof message === "string") {
131
- message = (0, utils_1.utf8ToBytes)(message);
132
- }
133
- const signature = ml_dsa_1.ml_dsa65.sign(this.signingKeyPair.privateKey, message);
134
- return signature;
135
- }
136
- /**
137
- * Verifies a signature using ml-dsa
138
- * @param message The message to verify
139
- * @param signature The signature to verify
140
- * @returns A promise that resolves to true if the signature is valid
141
- */
142
- async verify(publicKey, message, signature) {
143
- if (typeof publicKey === "string") {
144
- publicKey = (0, utils_1.utf8ToBytes)(publicKey);
145
- }
146
- if (typeof message === "string") {
147
- message = (0, utils_1.utf8ToBytes)(message);
148
- }
149
- if (typeof signature === "string") {
150
- signature = (0, utils_1.utf8ToBytes)(signature);
151
- }
152
- const isValid = ml_dsa_1.ml_dsa65.verify(publicKey, message, signature);
153
- return isValid;
154
- }
155
- // ml-dsa utils
156
- async getPublicKey(str = true) {
157
- if (str) {
158
- return (0, utils_1.bytesToUtf8)(this.signingKeyPair.publicKey);
159
- }
160
- return this.signingKeyPair.publicKey;
161
- }
162
- async getPrivateKey(str = true) {
163
- if (str) {
164
- return (0, utils_1.bytesToUtf8)(this.signingKeyPair.privateKey);
165
- }
166
- return this.signingKeyPair.privateKey;
167
- }
168
- async getSeed(str = false) {
169
- if (str) {
170
- return (0, utils_1.bytesToUtf8)(this.signingSeed);
171
- }
172
- return this.signingSeed;
173
- }
174
- async setSeed(seed) {
175
- if (typeof seed === "string") {
176
- seed = (0, utils_1.utf8ToBytes)(seed);
177
- }
178
- await this.genSigningKeyPair(seed);
179
- }
180
- /* SECTION Signatures with Falcon */
181
- /**
182
- * Signs a message using Falcon
183
- * @param message The message to sign
184
- * @param salt Optional salt for signing
185
- * @returns A promise that resolves to the signature
186
- */
187
- async signFalcon(message, salt = null) {
188
- const falcon = new falconts_1.Falcon();
189
- await falcon.init();
190
- await falcon.setKeypair(this.falconKeyPair);
191
- if (!(typeof message === "string")) {
192
- message = (0, utils_1.bytesToUtf8)(message);
193
- }
194
- if (salt) {
195
- if (typeof salt === "string") {
196
- salt = (0, utils_1.utf8ToBytes)(salt);
197
- }
198
- }
199
- const signature = await falcon.sign(message, salt);
200
- return signature;
201
- }
202
- /**
203
- * Signs a message using Falcon and returns the signature as a hex string
204
- * @param message The message to sign
205
- * @returns A promise that resolves to the signature as a hex string
206
- */
207
- async signFalconHex(message) {
208
- const signature = await this.signFalcon(message);
209
- return falconts_1.Falcon.uint8ArrayToHex(signature);
210
- }
211
- /**
212
- * Signs a message using Falcon and returns the signature as a base64 string
213
- * @param message The message to sign
214
- * @returns A promise that resolves to the signature as a base64 string
215
- */
216
- async signFalconBase64(message) {
217
- const signature = await this.signFalcon(message);
218
- return falconts_1.Falcon.uint8ArrayToBase64(signature);
219
- }
220
- /**
221
- * Verifies a signature using Falcon
222
- * @param message The message to verify
223
- * @param signature The signature to verify
224
- * @param publicKey The public key to use for verification
225
- * @returns A promise that resolves to true if the signature is valid
226
- */
227
- async verifyFalcon(message, signature, publicKey) {
228
- const falcon = new falconts_1.Falcon();
229
- await falcon.init();
230
- if (!(typeof message === "string")) {
231
- message = (0, utils_1.bytesToUtf8)(message);
232
- }
233
- if (typeof publicKey === "string") {
234
- publicKey = (0, utils_1.utf8ToBytes)(publicKey);
235
- }
236
- const isValid = await falcon.verify(message, signature, publicKey);
237
- return isValid;
238
- }
239
- /**
240
- * Verifies a signature using Falcon with hex format
241
- * @param message The message to verify
242
- * @param signatureHex The signature to verify as a hex string
243
- * @param publicKeyHex The public key to use for verification as a hex string
244
- * @returns A promise that resolves to true if the signature is valid
245
- */
246
- async verifyFalconHex(message, signatureHex, publicKeyHex) {
247
- const signature = falconts_1.Falcon.hexToUint8Array(signatureHex);
248
- const publicKey = falconts_1.Falcon.hexToUint8Array(publicKeyHex);
249
- return this.verifyFalcon(message, signature, publicKey);
250
- }
251
- /**
252
- * Verifies a signature using Falcon with base64 format
253
- * @param message The message to verify
254
- * @param signatureBase64 The signature to verify as a base64 string
255
- * @param publicKeyBase64 The public key to use for verification as a base64 string
256
- * @returns A promise that resolves to true if the signature is valid
257
- */
258
- async verifyFalconBase64(message, signatureBase64, publicKeyBase64) {
259
- const signature = falconts_1.Falcon.base64ToUint8Array(signatureBase64);
260
- const publicKey = falconts_1.Falcon.base64ToUint8Array(publicKeyBase64);
261
- return this.verifyFalcon(message, signature, publicKey);
262
- }
263
- // falcon utils
264
- async getPublicKeyFalcon(str = true) {
265
- if (str) {
266
- return (0, utils_1.bytesToUtf8)(this.falconKeyPair.pk);
267
- }
268
- return this.falconKeyPair.pk;
269
- }
270
- async getPrivateKeyFalcon(str = true) {
271
- if (str) {
272
- return (0, utils_1.bytesToUtf8)(this.falconKeyPair.sk);
273
- }
274
- return this.falconKeyPair.sk;
275
- }
276
- /**
277
- * Gets the Falcon public key as a hex string
278
- * @returns A promise that resolves to the public key as a hex string
279
- */
280
- async getPublicKeyFalconHex() {
281
- return falconts_1.Falcon.uint8ArrayToHex(this.falconKeyPair.pk);
282
- }
283
- /**
284
- * Gets the Falcon private key as a hex string
285
- * @returns A promise that resolves to the private key as a hex string
286
- */
287
- async getPrivateKeyFalconHex() {
288
- return falconts_1.Falcon.uint8ArrayToHex(this.falconKeyPair.sk);
289
- }
290
- /**
291
- * Gets the Falcon public key as a base64 string
292
- * @returns A promise that resolves to the public key as a base64 string
293
- */
294
- async getPublicKeyFalconBase64() {
295
- return falconts_1.Falcon.uint8ArrayToBase64(this.falconKeyPair.pk);
296
- }
297
- /**
298
- * Gets the Falcon private key as a base64 string
299
- * @returns A promise that resolves to the private key as a base64 string
300
- */
301
- async getPrivateKeyFalconBase64() {
302
- return falconts_1.Falcon.uint8ArrayToBase64(this.falconKeyPair.sk);
303
- }
304
- /**
305
- * Sets the Falcon private key from a hex string
306
- * @param privateKeyHex The private key as a hex string
307
- * @returns A promise that resolves to the public key as a hex string
308
- */
309
- async setPrivateKeyFalconHex(privateKeyHex) {
310
- const falcon = new falconts_1.Falcon();
311
- await falcon.init();
312
- const privateKey = falconts_1.Falcon.hexToUint8Array(privateKeyHex);
313
- const publicKey = await falcon.publicKeyCreate(privateKey);
314
- // Update the keypair
315
- this.falconKeyPair = {
316
- genkeySeed: new Uint8Array(0), // We don't have the seed
317
- sk: privateKey,
318
- pk: publicKey
319
- };
320
- return falconts_1.Falcon.uint8ArrayToHex(publicKey);
321
- }
322
- /**
323
- * Sets the Falcon private key from a base64 string
324
- * @param privateKeyBase64 The private key as a base64 string
325
- * @returns A promise that resolves to the public key as a base64 string
326
- */
327
- async setPrivateKeyFalconBase64(privateKeyBase64) {
328
- const falcon = new falconts_1.Falcon();
329
- await falcon.init();
330
- const privateKey = falconts_1.Falcon.base64ToUint8Array(privateKeyBase64);
331
- const publicKey = await falcon.publicKeyCreate(privateKey);
332
- // Update the keypair
333
- this.falconKeyPair = {
334
- genkeySeed: new Uint8Array(0), // We don't have the seed
335
- sk: privateKey,
336
- pk: publicKey
337
- };
338
- return falconts_1.Falcon.uint8ArrayToBase64(publicKey);
339
- }
340
- /* SECTION Keys generation and incapsulation with McEliece */
341
- /**
342
- * Generates a shared secret using the McEliece key encapsulation mechanism
343
- * @param peerPublicKey The public key of the peer
344
- * @returns A promise that resolves to an object containing the secret and encrypted key
345
- */
346
- async generateSecrets(peerPublicKey) {
347
- let { key, encryptedKey } = await this.kem.generateKey(peerPublicKey);
348
- let normalizedResult = {
349
- secret: key,
350
- shared: encryptedKey,
351
- };
352
- return normalizedResult;
353
- }
354
- /**
355
- * Derives a shared secret using the McEliece key encapsulation mechanism
356
- * @param shared The encrypted key
357
- * @returns A promise that resolves to the derived secret
358
- */
359
- async deriveSharedSecret(shared) {
360
- let secret = await this.kem.decryptKey(this.mcelieceKeypair.privateKey, shared);
361
- return secret;
362
- }
363
- /* SECTION Hashing with SHA-3 */
364
- /**
365
- * Hashes data using SHA-3 (Keccak-256)
366
- * @param input The data to hash
367
- * @returns A promise that resolves to the hash as a hex string
368
- */
369
- async hash(input) {
370
- if (typeof input === "string") {
371
- input = Buffer.from(input, "utf8");
372
- }
373
- // Use keccak_256 (SHA-3) for hashing
374
- // Convert Buffer to hex string for js-sha3
375
- const hash = (0, js_sha3_1.keccak_256)(input);
376
- return hash;
377
- }
378
- /**
379
- * Verifies if a hash matches the hash of the input data
380
- * @param input The data to hash
381
- * @param hash The hash to verify against
382
- * @returns A promise that resolves to true if the hash matches
383
- */
384
- async checkHash(input, hash) {
385
- if (typeof input === "string") {
386
- input = Buffer.from(input, "utf8");
387
- }
388
- // Calculate hash and compare
389
- const calculatedHash = (0, js_sha3_1.keccak_256)(input);
390
- return calculatedHash === hash;
391
- }
392
- /* SECTION Symmetric encryption and decryption with ChaCha20-Poly1305 */
393
- /**
394
- * Encrypts data using ChaCha20-Poly1305 with a secure random nonce
395
- * @param input The data to encrypt
396
- * @param key The encryption key (32 bytes for 256 bits)
397
- * @returns A Buffer containing the nonce prepended to the ciphertext
398
- */
399
- async encrypt(input, key) {
400
- // Convert key to Buffer if it's a string
401
- const keyBuffer = typeof key === 'string' ? Buffer.from(key, 'hex') : key;
402
- // Validate key length - ChaCha20-Poly1305 requires a 32-byte key
403
- if (keyBuffer.length !== 32) {
404
- throw new Error("Key must be 32 bytes long for ChaCha20-Poly1305");
405
- }
406
- // Generate a secure random nonce
407
- const nonce = this.generateRandomBytes(this.NONCE_SIZE);
408
- // Convert input to Buffer if it's a string
409
- const inputBuffer = typeof input === 'string' ? Buffer.from(input, 'utf8') : input;
410
- // Create cipher with the key and nonce
411
- const cipher = crypto.createCipheriv('chacha20-poly1305', keyBuffer, nonce, {
412
- authTagLength: 16 // 128-bit authentication tag
413
- });
414
- // Encrypt the data
415
- const encrypted = Buffer.concat([
416
- cipher.update(inputBuffer),
417
- cipher.final()
418
- ]);
419
- // Get the authentication tag
420
- const authTag = cipher.getAuthTag();
421
- // Prepend the nonce and append the auth tag to the ciphertext
422
- return Buffer.concat([nonce, encrypted, authTag]);
423
- }
424
- /**
425
- * Decrypts data using ChaCha20-Poly1305
426
- * @param input The encrypted data with nonce prepended and auth tag appended
427
- * @param key The decryption key (32 bytes for 256 bits)
428
- * @returns A Buffer containing the decrypted plaintext
429
- */
430
- async decrypt(input, key) {
431
- // Convert key to Buffer if it's a string
432
- const keyBuffer = typeof key === 'string' ? Buffer.from(key, 'hex') : key;
433
- // Validate key length - ChaCha20-Poly1305 requires a 32-byte key
434
- if (keyBuffer.length !== 32) {
435
- throw new Error("Key must be 32 bytes long for ChaCha20-Poly1305");
436
- }
437
- // Extract the nonce, ciphertext, and auth tag
438
- const nonce = input.subarray(0, this.NONCE_SIZE);
439
- const authTag = input.subarray(input.length - 16); // 16 bytes for auth tag
440
- const ciphertext = input.subarray(this.NONCE_SIZE, input.length - 16);
441
- // Create decipher with the key and nonce
442
- const decipher = crypto.createDecipheriv('chacha20-poly1305', keyBuffer, nonce, {
443
- authTagLength: 16 // 128-bit authentication tag
444
- });
445
- // Set the authentication tag
446
- decipher.setAuthTag(authTag);
447
- // Decrypt the data
448
- const decrypted = Buffer.concat([
449
- decipher.update(ciphertext),
450
- decipher.final()
451
- ]);
452
- return decrypted;
453
- }
454
- /* SECTION NTRU Encryption and Decryption */
455
- /**
456
- * Encrypts data using NTRU
457
- * @param input The data to encrypt
458
- * @param publicKey The public key to use for encryption
459
- * @returns A promise that resolves to an object containing the encrypted data and secret
460
- */
461
- async ntruEncrypt(input, publicKey) {
462
- // Convert input to Uint8Array if it's a string
463
- const inputData = typeof input === 'string' ? new TextEncoder().encode(input) : input;
464
- // Validate public key length
465
- const publicKeyBytes = await ntru_1.ntru.publicKeyBytes;
466
- if (publicKey.length !== publicKeyBytes) {
467
- throw new Error(`Public key must be ${publicKeyBytes} bytes long for NTRU`);
468
- }
469
- // Encrypt the data using NTRU
470
- const { cyphertext, secret } = await ntru_1.ntru.encrypt(publicKey);
471
- // Combine the encrypted data with the input
472
- const combined = new Uint8Array(cyphertext.length + inputData.length);
473
- combined.set(cyphertext, 0);
474
- combined.set(inputData, cyphertext.length);
475
- return {
476
- encrypted: combined,
477
- secret: secret
478
- };
479
- }
480
- /**
481
- * Decrypts data using NTRU
482
- * @param encrypted The encrypted data
483
- * @param privateKey The private key to use for decryption
484
- * @returns A promise that resolves to the decrypted data
485
- */
486
- async ntruDecrypt(encrypted, privateKey) {
487
- // Validate private key length
488
- const privateKeyBytes = await ntru_1.ntru.privateKeyBytes;
489
- if (privateKey.length !== privateKeyBytes) {
490
- throw new Error(`Private key must be ${privateKeyBytes} bytes long for NTRU`);
491
- }
492
- // Extract the cyphertext from the combined data
493
- const cyphertextBytes = await ntru_1.ntru.cyphertextBytes;
494
- const cyphertext = encrypted.subarray(0, cyphertextBytes);
495
- const data = encrypted.subarray(cyphertextBytes);
496
- // Decrypt the data using NTRU
497
- const secret = await ntru_1.ntru.decrypt(cyphertext, privateKey);
498
- // Return the decrypted data
499
- return data;
500
- }
501
- /**
502
- * Exports the NTRU key pair
503
- * @returns The NTRU key pair
504
- */
505
- exportNtruKeys() {
506
- if (!this.ntruKeyPair) {
507
- throw new Error("NTRU key pair not initialized. Call init() first.");
508
- }
509
- return this.ntruKeyPair;
510
- }
511
- /**
512
- * Imports an NTRU key pair
513
- * @param keyPair The key pair to import
514
- */
515
- importNtruKeys(keyPair) {
516
- this.ntruKeyPair = keyPair;
517
- }
518
- }
519
- exports.default = Enigma;
520
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/encryption/PQC/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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