@kynesyslabs/demosdk 2.1.14 → 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.
- package/build/abstraction/Identities.js.map +1 -1
- package/build/encryption/PQC/enigma.d.ts +83 -0
- package/build/encryption/PQC/enigma.js +243 -0
- package/build/encryption/PQC/enigma.js.map +1 -0
- package/build/encryption/PQC/falconts/falcon.d.ts +130 -0
- package/build/encryption/PQC/falconts/falcon.js +228 -0
- package/build/encryption/PQC/falconts/falcon.js.map +1 -0
- package/build/encryption/PQC/falconts/index.d.ts +4 -0
- package/build/encryption/PQC/falconts/index.js +19 -0
- package/build/encryption/PQC/falconts/index.js.map +1 -0
- package/build/encryption/PQC/falconts/mnemonic.d.ts +27 -0
- package/build/encryption/PQC/falconts/mnemonic.js +109 -0
- package/build/encryption/PQC/falconts/mnemonic.js.map +1 -0
- package/build/encryption/PQC/falconts/wordlist.d.ts +5 -0
- package/build/encryption/PQC/falconts/wordlist.js +216 -0
- package/build/encryption/PQC/falconts/wordlist.js.map +1 -0
- package/build/encryption/PQC/utils.d.ts +8 -0
- package/build/encryption/PQC/utils.js +16 -0
- package/build/encryption/PQC/utils.js.map +1 -0
- package/build/encryption/index.d.ts +2 -1
- package/build/encryption/index.js +4 -2
- package/build/encryption/index.js.map +1 -1
- package/build/encryption/unifiedCrypto.d.ts +125 -0
- package/build/encryption/unifiedCrypto.js +408 -0
- package/build/encryption/unifiedCrypto.js.map +1 -0
- package/build/instant_messaging/index.d.ts +300 -0
- package/build/instant_messaging/index.js +630 -0
- package/build/instant_messaging/index.js.map +1 -0
- package/build/multichain/core/btc.d.ts +4 -2
- package/build/multichain/core/btc.js +27 -4
- package/build/multichain/core/btc.js.map +1 -1
- package/build/utils/uint8Serialize.d.ts +2 -0
- package/build/utils/uint8Serialize.js +22 -0
- package/build/utils/uint8Serialize.js.map +1 -0
- package/build/websdk/utils/sha256.js +5 -1
- package/build/websdk/utils/sha256.js.map +1 -1
- package/package.json +9 -2
- package/build/encryption/PQC/index.d.ts +0 -136
- package/build/encryption/PQC/index.js +0 -405
- package/build/encryption/PQC/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Identities.js","sourceRoot":"","sources":["../../../src/abstraction/Identities.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,8EAA8E;;;;;AAE9E,4DAAwD;
|
|
1
|
+
{"version":3,"file":"Identities.js","sourceRoot":"","sources":["../../../src/abstraction/Identities.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,8EAA8E;;;;;AAE9E,4DAAwD;AAWxD,4DAA8B;AAC9B,qCAA4C;AAI5C,MAAqB,UAAU;IAA/B;QACI,YAAO,GAAG;YACN,IAAI,EAAE;gBACF,MAAM,EAAE;oBACJ,yBAAyB;oBACzB,mCAAmC;oBACnC,oCAAoC;iBACvC;gBACD,OAAO,EAAE,CAAC,eAAe,EAAE,qBAAqB,CAAC;aACpD;SACJ,CAAA;IA+PL,CAAC;IA7PG;;;;;OAKG;IACH,KAAK,CAAC,sBAAsB,CAAC,OAAiB;QAC1C,MAAM,OAAO,GAAG,MAAM,CAAA;QACtB,MAAM,SAAS,GAAG,2BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;QAChE,MAAM,OAAO,GAAG;YACZ,OAAO;YACP,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;YACpC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;SAC/C,CAAA;QAED,MAAM,QAAQ,GAAG,2BAAY,CAAC,MAAM,CAChC,OAAO,EACP,oBAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAC/C,oBAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CA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CAAC,eAAe,CAAC,KAAY,EAAE,OAAgB;QAChD,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACtE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,iBAAiB,CAAC,KAAY,EAAE,OAAgB;QAClD,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAA;IACxE,CAAC;CACJ;AAzQD,6BAyQC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export declare class Enigma {
|
|
2
|
+
ml_dsa_signing_keypair: {
|
|
3
|
+
publicKey: Uint8Array;
|
|
4
|
+
privateKey: Uint8Array;
|
|
5
|
+
};
|
|
6
|
+
falcon_signing_keypair: {
|
|
7
|
+
genKey: Uint8Array;
|
|
8
|
+
publicKey: Uint8Array;
|
|
9
|
+
privateKey: Uint8Array;
|
|
10
|
+
};
|
|
11
|
+
ml_kem_encryption_keypair: {
|
|
12
|
+
publicKey: Uint8Array;
|
|
13
|
+
privateKey: Uint8Array;
|
|
14
|
+
};
|
|
15
|
+
ml_kem_aes_parameters: string;
|
|
16
|
+
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Hashes data using SHA-3-256
|
|
19
|
+
* @param data The data to hash
|
|
20
|
+
* @returns The hash of the data
|
|
21
|
+
*/
|
|
22
|
+
static hash(data: string, algorithm?: string): Promise<Uint8Array>;
|
|
23
|
+
/**
|
|
24
|
+
* Verifies a signature using ml-dsa
|
|
25
|
+
* @param signature The signature to verify
|
|
26
|
+
* @param message The message to verify the signature against
|
|
27
|
+
* @param publicKey The public key to verify the signature against
|
|
28
|
+
* @returns True if the signature is valid, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
static verify_ml_dsa(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Verifies a signature using falcon
|
|
33
|
+
* @param signature The signature to verify
|
|
34
|
+
* @param message The message to verify the signature against
|
|
35
|
+
* @param publicKey The public key to verify the signature against
|
|
36
|
+
* @returns True if the signature is valid, false otherwise
|
|
37
|
+
*/
|
|
38
|
+
static verify_falcon(signature: Uint8Array, message: string, publicKey: Uint8Array): Promise<boolean>;
|
|
39
|
+
/** Sign data using ml_dsa
|
|
40
|
+
* @param message The message to sign
|
|
41
|
+
* @returns The signature of the message
|
|
42
|
+
*/
|
|
43
|
+
sign_ml_dsa(message: Uint8Array): Promise<Uint8Array>;
|
|
44
|
+
/** Sign data using falcon
|
|
45
|
+
* @param message The message to sign
|
|
46
|
+
* @returns The signature of the message
|
|
47
|
+
*/
|
|
48
|
+
sign_falcon(message: string): Promise<Uint8Array>;
|
|
49
|
+
encapsulate_ml_kem(peerPublicKey: Uint8Array): Promise<{
|
|
50
|
+
cipherText: Uint8Array;
|
|
51
|
+
sharedSecret: Uint8Array;
|
|
52
|
+
}>;
|
|
53
|
+
decapsulate_ml_kem(cipherText: Uint8Array): Promise<Uint8Array>;
|
|
54
|
+
/** Encrypt data using ml_kem + aes
|
|
55
|
+
* @param message The message to encrypt
|
|
56
|
+
* @returns The encrypted message
|
|
57
|
+
*/
|
|
58
|
+
encrypt_ml_kem_aes(message: Uint8Array, peerPublicKey: Uint8Array): Promise<{
|
|
59
|
+
cipherText: Uint8Array;
|
|
60
|
+
encryptedMessage: Uint8Array;
|
|
61
|
+
}>;
|
|
62
|
+
/** Decrypt data using ml_kem + aes
|
|
63
|
+
* @param encryptedMessage The encrypted message to decrypt
|
|
64
|
+
* @param cipherText The cipher text containing the encapsulated shared secret
|
|
65
|
+
* @returns The decrypted message
|
|
66
|
+
*/
|
|
67
|
+
decrypt_ml_kem_aes(encryptedMessage: Uint8Array, cipherText: Uint8Array): Promise<Uint8Array>;
|
|
68
|
+
/**
|
|
69
|
+
* Generates a ml_dsa signing keypair given a seed or creating one
|
|
70
|
+
* @param seed (optional) the seed used to generate the keypair
|
|
71
|
+
*/
|
|
72
|
+
generate_ml_dsa_signing_keypair(seed?: Uint8Array): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Generates a falcon signing keypair given a seed or creating one
|
|
75
|
+
* @param seed (optional) the seed used to generate the keypair
|
|
76
|
+
*/
|
|
77
|
+
generate_falcon_signing_keypair(seed?: Uint8Array): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Generates a ml_kem encryption keypair given a seed or creating one
|
|
80
|
+
* @param seed (optional) the seed used to generate the keypair
|
|
81
|
+
*/
|
|
82
|
+
generate_ml_kem_encryption_keypair(seed?: Uint8Array): Promise<void>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
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
|
+
exports.Enigma = void 0;
|
|
37
|
+
/* INFO Enigma - An experimental wrapper for Post Quantum Cryptography in Typescript designed with ease of use in mind
|
|
38
|
+
Currently suggested and tested schemas for each algorithm are:
|
|
39
|
+
- Signing: ml-dsa or falcon
|
|
40
|
+
- Encryption: NTRU
|
|
41
|
+
- Hashing: SHA-3
|
|
42
|
+
|
|
43
|
+
While implemented, the following algorithms are not included in the pqc test suite:
|
|
44
|
+
- Key Encapsulation: McEliece
|
|
45
|
+
|
|
46
|
+
While implemented, the following algorithms are not fully tested:
|
|
47
|
+
- ChaCha20-Poly1305
|
|
48
|
+
To properly test the encryption and decryption of data, please see the pqc test suite.
|
|
49
|
+
*/
|
|
50
|
+
const ml_kem_1 = require("@noble/post-quantum/ml-kem");
|
|
51
|
+
const ml_dsa_1 = require("@noble/post-quantum/ml-dsa");
|
|
52
|
+
const sha3_1 = require("@noble/hashes/sha3");
|
|
53
|
+
const crypto = __importStar(require("crypto"));
|
|
54
|
+
const falconts_1 = require("./falconts");
|
|
55
|
+
const crypto_1 = require("crypto");
|
|
56
|
+
class Enigma {
|
|
57
|
+
constructor() {
|
|
58
|
+
// ml-dsa signing keypair
|
|
59
|
+
this.ml_dsa_signing_keypair = null;
|
|
60
|
+
// falcon signing keypair
|
|
61
|
+
this.falcon_signing_keypair = null;
|
|
62
|
+
// ml-kem encryption keypair
|
|
63
|
+
this.ml_kem_encryption_keypair = null;
|
|
64
|
+
// ml-kem-aes parameters
|
|
65
|
+
this.ml_kem_aes_parameters = null;
|
|
66
|
+
}
|
|
67
|
+
// Static methods
|
|
68
|
+
/**
|
|
69
|
+
* Hashes data using SHA-3-256
|
|
70
|
+
* @param data The data to hash
|
|
71
|
+
* @returns The hash of the data
|
|
72
|
+
*/
|
|
73
|
+
static async hash(data, algorithm = "sha3-256") {
|
|
74
|
+
// NOTE: algorithm is not used yet, but will be used in the future
|
|
75
|
+
return sha3_1.sha3_256.create().update(data).digest();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Verifies a signature using ml-dsa
|
|
79
|
+
* @param signature The signature to verify
|
|
80
|
+
* @param message The message to verify the signature against
|
|
81
|
+
* @param publicKey The public key to verify the signature against
|
|
82
|
+
* @returns True if the signature is valid, false otherwise
|
|
83
|
+
*/
|
|
84
|
+
static async verify_ml_dsa(signature, message, publicKey) {
|
|
85
|
+
return ml_dsa_1.ml_dsa65.verify(publicKey, message, signature);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Verifies a signature using falcon
|
|
89
|
+
* @param signature The signature to verify
|
|
90
|
+
* @param message The message to verify the signature against
|
|
91
|
+
* @param publicKey The public key to verify the signature against
|
|
92
|
+
* @returns True if the signature is valid, false otherwise
|
|
93
|
+
*/
|
|
94
|
+
static async verify_falcon(signature, message, publicKey) {
|
|
95
|
+
const falcon = new falconts_1.Falcon(); // Initialize falcon kernel
|
|
96
|
+
await falcon.init();
|
|
97
|
+
return falcon.verify(message, signature, publicKey);
|
|
98
|
+
}
|
|
99
|
+
// Dynamic methods
|
|
100
|
+
/** Sign data using ml_dsa
|
|
101
|
+
* @param message The message to sign
|
|
102
|
+
* @returns The signature of the message
|
|
103
|
+
*/
|
|
104
|
+
async sign_ml_dsa(message) {
|
|
105
|
+
if (!this.ml_dsa_signing_keypair.privateKey) {
|
|
106
|
+
throw new Error("ml_dsa_signing_keypair.privateKey is not set");
|
|
107
|
+
}
|
|
108
|
+
return ml_dsa_1.ml_dsa65.sign(this.ml_dsa_signing_keypair.privateKey, message);
|
|
109
|
+
}
|
|
110
|
+
/** Sign data using falcon
|
|
111
|
+
* @param message The message to sign
|
|
112
|
+
* @returns The signature of the message
|
|
113
|
+
*/
|
|
114
|
+
async sign_falcon(message) {
|
|
115
|
+
if (!this.falcon_signing_keypair.privateKey) {
|
|
116
|
+
throw new Error("falcon_signing_keypair.privateKey is not set");
|
|
117
|
+
}
|
|
118
|
+
const falcon = new falconts_1.Falcon();
|
|
119
|
+
await falcon.init();
|
|
120
|
+
await falcon.setKeypair({
|
|
121
|
+
genkeySeed: this.falcon_signing_keypair.genKey,
|
|
122
|
+
sk: this.falcon_signing_keypair.privateKey,
|
|
123
|
+
pk: this.falcon_signing_keypair.publicKey,
|
|
124
|
+
});
|
|
125
|
+
return falcon.sign(message);
|
|
126
|
+
}
|
|
127
|
+
async encapsulate_ml_kem(peerPublicKey) {
|
|
128
|
+
if (!this.ml_kem_encryption_keypair.privateKey) {
|
|
129
|
+
throw new Error("ml_kem_encryption_keypair.privateKey is not set");
|
|
130
|
+
}
|
|
131
|
+
return ml_kem_1.ml_kem768.encapsulate(peerPublicKey);
|
|
132
|
+
}
|
|
133
|
+
async decapsulate_ml_kem(cipherText) {
|
|
134
|
+
if (!this.ml_kem_encryption_keypair.privateKey) {
|
|
135
|
+
throw new Error("ml_kem_encryption_keypair.privateKey is not set");
|
|
136
|
+
}
|
|
137
|
+
return ml_kem_1.ml_kem768.decapsulate(cipherText, this.ml_kem_encryption_keypair.privateKey);
|
|
138
|
+
}
|
|
139
|
+
/** Encrypt data using ml_kem + aes
|
|
140
|
+
* @param message The message to encrypt
|
|
141
|
+
* @returns The encrypted message
|
|
142
|
+
*/
|
|
143
|
+
async encrypt_ml_kem_aes(message, peerPublicKey) {
|
|
144
|
+
if (!this.ml_kem_encryption_keypair.privateKey) {
|
|
145
|
+
throw new Error("ml_kem_encryption_keypair.privateKey is not set");
|
|
146
|
+
}
|
|
147
|
+
// Generate shared secret and encapsulate it in a cipher text using ml_kem and the peer's public key
|
|
148
|
+
const encapsulatedSecret = ml_kem_1.ml_kem768.encapsulate(peerPublicKey);
|
|
149
|
+
// Encrypt the message using AES-256-GCM with the shared secret
|
|
150
|
+
const iv = crypto.randomBytes(12); // 96-bit IV for GCM mode
|
|
151
|
+
const cipher = crypto.createCipheriv("aes-256-gcm", encapsulatedSecret.sharedSecret, iv);
|
|
152
|
+
// Encrypt the message
|
|
153
|
+
const encryptedMessage = Buffer.concat([
|
|
154
|
+
cipher.update(message),
|
|
155
|
+
cipher.final(),
|
|
156
|
+
]);
|
|
157
|
+
// Get the authentication tag
|
|
158
|
+
const authTag = cipher.getAuthTag();
|
|
159
|
+
// Combine IV, encrypted message, and auth tag for transmission
|
|
160
|
+
const combinedEncryptedData = Buffer.concat([
|
|
161
|
+
iv,
|
|
162
|
+
encryptedMessage,
|
|
163
|
+
authTag,
|
|
164
|
+
]);
|
|
165
|
+
return {
|
|
166
|
+
cipherText: encapsulatedSecret.cipherText,
|
|
167
|
+
encryptedMessage: combinedEncryptedData,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/** Decrypt data using ml_kem + aes
|
|
171
|
+
* @param encryptedMessage The encrypted message to decrypt
|
|
172
|
+
* @param cipherText The cipher text containing the encapsulated shared secret
|
|
173
|
+
* @returns The decrypted message
|
|
174
|
+
*/
|
|
175
|
+
async decrypt_ml_kem_aes(encryptedMessage, cipherText) {
|
|
176
|
+
if (!this.ml_kem_encryption_keypair.privateKey) {
|
|
177
|
+
throw new Error("ml_kem_encryption_keypair.privateKey is not set");
|
|
178
|
+
}
|
|
179
|
+
// Get the shared secret from the cipher text
|
|
180
|
+
const sharedSecret = ml_kem_1.ml_kem768.decapsulate(cipherText, this.ml_kem_encryption_keypair.privateKey);
|
|
181
|
+
// Decrypt the message using AES-256-GCM with the shared secret
|
|
182
|
+
const iv = encryptedMessage.slice(0, 12);
|
|
183
|
+
const message = encryptedMessage.slice(12, -16);
|
|
184
|
+
const authTag = encryptedMessage.slice(-16);
|
|
185
|
+
// Decrypt the message
|
|
186
|
+
const decipher = crypto.createDecipheriv("aes-256-gcm", sharedSecret, iv);
|
|
187
|
+
decipher.setAuthTag(authTag);
|
|
188
|
+
const decryptedMessage = Buffer.concat([
|
|
189
|
+
decipher.update(message),
|
|
190
|
+
decipher.final(),
|
|
191
|
+
]);
|
|
192
|
+
return decryptedMessage;
|
|
193
|
+
}
|
|
194
|
+
// Keypair generation methods
|
|
195
|
+
/**
|
|
196
|
+
* Generates a ml_dsa signing keypair given a seed or creating one
|
|
197
|
+
* @param seed (optional) the seed used to generate the keypair
|
|
198
|
+
*/
|
|
199
|
+
async generate_ml_dsa_signing_keypair(seed = null) {
|
|
200
|
+
if (!seed) {
|
|
201
|
+
seed = (0, crypto_1.randomBytes)(32);
|
|
202
|
+
}
|
|
203
|
+
const keypair = ml_dsa_1.ml_dsa65.keygen(seed);
|
|
204
|
+
this.ml_dsa_signing_keypair = {
|
|
205
|
+
publicKey: keypair.publicKey,
|
|
206
|
+
privateKey: keypair.secretKey,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Generates a falcon signing keypair given a seed or creating one
|
|
211
|
+
* @param seed (optional) the seed used to generate the keypair
|
|
212
|
+
*/
|
|
213
|
+
async generate_falcon_signing_keypair(seed = null) {
|
|
214
|
+
if (!seed) {
|
|
215
|
+
seed = (0, crypto_1.randomBytes)(48);
|
|
216
|
+
}
|
|
217
|
+
const falcon = new falconts_1.Falcon();
|
|
218
|
+
await falcon.init();
|
|
219
|
+
await falcon.genkey(seed);
|
|
220
|
+
const falconKeyPair = await falcon.getKeypair();
|
|
221
|
+
this.falcon_signing_keypair = {
|
|
222
|
+
genKey: falconKeyPair.genkeySeed,
|
|
223
|
+
publicKey: falconKeyPair.pk,
|
|
224
|
+
privateKey: falconKeyPair.sk,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Generates a ml_kem encryption keypair given a seed or creating one
|
|
229
|
+
* @param seed (optional) the seed used to generate the keypair
|
|
230
|
+
*/
|
|
231
|
+
async generate_ml_kem_encryption_keypair(seed = null) {
|
|
232
|
+
if (!seed) {
|
|
233
|
+
seed = (0, crypto_1.randomBytes)(64);
|
|
234
|
+
}
|
|
235
|
+
let keys = ml_kem_1.ml_kem768.keygen(seed);
|
|
236
|
+
this.ml_kem_encryption_keypair = {
|
|
237
|
+
privateKey: keys.secretKey,
|
|
238
|
+
publicKey: keys.publicKey,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
exports.Enigma = Enigma;
|
|
243
|
+
//# sourceMappingURL=enigma.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enigma.js","sourceRoot":"","sources":["../../../../src/encryption/PQC/enigma.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;EAYE;AACF,uDAAsD;AACtD,uDAAqD;AACrD,6CAA6C;AAC7C,+CAAgC;AAChC,yCAAmC;AACnC,mCAAoC;AAEpC,MAAa,MAAM;IAwBf;QAtBA,yBAAyB;QACzB,2BAAsB,GAGlB,IAAI,CAAA;QAER,yBAAyB;QACzB,2BAAsB,GAIlB,IAAI,CAAA;QAER,4BAA4B;QAC5B,8BAAyB,GAGrB,IAAI,CAAA;QAER,wBAAwB;QACxB,0BAAqB,GAAW,IAAI,CAAA;IAErB,CAAC;IAEhB,iBAAiB;IAEjB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,YAAoB,UAAU;QAC1D,kEAAkE;QAClE,OAAO,eAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAA;IAClD,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,aAAa,CACtB,SAAqB,EACrB,OAAmB,EACnB,SAAqB;QAErB,OAAO,iBAAQ,C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|
|
3
|
+
publicKeyCreate: (privateKey: Uint8Array) => Uint8Array;
|
|
4
|
+
sign: (message: string, privateKey: Uint8Array, salt?: Uint8Array) => Uint8Array;
|
|
5
|
+
verify: (signature: Uint8Array, message: string, publicKey: Uint8Array) => boolean;
|
|
6
|
+
algid: string;
|
|
7
|
+
genkeySeedByte: number;
|
|
8
|
+
skByte: number;
|
|
9
|
+
pkByte: number;
|
|
10
|
+
signByte: number;
|
|
11
|
+
signSaltByte: number;
|
|
12
|
+
signNonceByte: number;
|
|
13
|
+
}
|
|
14
|
+
export interface FalconKeypair {
|
|
15
|
+
genkeySeed: Uint8Array;
|
|
16
|
+
sk: Uint8Array;
|
|
17
|
+
pk: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
export default class Falcon {
|
|
20
|
+
private kernel;
|
|
21
|
+
private keypair;
|
|
22
|
+
private algid;
|
|
23
|
+
constructor(algid?: string);
|
|
24
|
+
init(): Promise<void>;
|
|
25
|
+
genkey(seed?: Uint8Array): Promise<void>;
|
|
26
|
+
sign(message: string, salt?: Uint8Array): Promise<Uint8Array>;
|
|
27
|
+
verify(message: string, signature: Uint8Array, publicKey: Uint8Array): Promise<boolean>;
|
|
28
|
+
publicKeyCreate(privateKey: Uint8Array): Promise<Uint8Array>;
|
|
29
|
+
setKeypair(keypair: FalconKeypair): Promise<void>;
|
|
30
|
+
getPublicKey(): Promise<Uint8Array>;
|
|
31
|
+
getPrivateKey(): Promise<Uint8Array>;
|
|
32
|
+
getAlgid(): Promise<string>;
|
|
33
|
+
getKeypair(): Promise<FalconKeypair>;
|
|
34
|
+
getKernel(): Promise<FalconKernel>;
|
|
35
|
+
/**
|
|
36
|
+
* Convert a Uint8Array to a hex string
|
|
37
|
+
* @param array The Uint8Array to convert
|
|
38
|
+
* @returns A hex string representation of the Uint8Array
|
|
39
|
+
*/
|
|
40
|
+
static uint8ArrayToHex(array: Uint8Array): string;
|
|
41
|
+
/**
|
|
42
|
+
* Convert a hex string to a Uint8Array
|
|
43
|
+
* @param hex The hex string to convert
|
|
44
|
+
* @returns A Uint8Array representation of the hex string
|
|
45
|
+
*/
|
|
46
|
+
static hexToUint8Array(hex: string): Uint8Array;
|
|
47
|
+
/**
|
|
48
|
+
* Get the public key as a hex string
|
|
49
|
+
* @returns A hex string representation of the public key
|
|
50
|
+
*/
|
|
51
|
+
getPublicKeyHex(): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the private key as a hex string
|
|
54
|
+
* @returns A hex string representation of the private key
|
|
55
|
+
*/
|
|
56
|
+
getPrivateKeyHex(): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Sign a message and return the signature as a hex string
|
|
59
|
+
* @param message The message to sign
|
|
60
|
+
* @returns A hex string representation of the signature
|
|
61
|
+
*/
|
|
62
|
+
signHex(message: string): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Verify a signature provided as a hex string
|
|
65
|
+
* @param message The message that was signed
|
|
66
|
+
* @param signatureHex The signature as a hex string
|
|
67
|
+
* @returns True if the signature is valid, false otherwise
|
|
68
|
+
*/
|
|
69
|
+
verifyHex(message: string, signatureHex: string, publicKeyHex: string): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* Create a public key from a private key provided as a hex string
|
|
72
|
+
* @param privateKeyHex The private key as a hex string
|
|
73
|
+
* @returns A hex string representation of the public key
|
|
74
|
+
*/
|
|
75
|
+
publicKeyCreateHex(privateKeyHex: string): Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Set a private key from a hex string
|
|
78
|
+
* @param privateKeyHex The private key as a hex string
|
|
79
|
+
* @returns The public key as a hex string
|
|
80
|
+
*/
|
|
81
|
+
setPrivateKeyHex(privateKeyHex: string): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Convert a Uint8Array to a base64 string
|
|
84
|
+
* @param array The Uint8Array to convert
|
|
85
|
+
* @returns A base64 string representation of the Uint8Array
|
|
86
|
+
*/
|
|
87
|
+
static uint8ArrayToBase64(array: Uint8Array): string;
|
|
88
|
+
/**
|
|
89
|
+
* Convert a base64 string to a Uint8Array
|
|
90
|
+
* @param base64 The base64 string to convert
|
|
91
|
+
* @returns A Uint8Array representation of the base64 string
|
|
92
|
+
*/
|
|
93
|
+
static base64ToUint8Array(base64: string): Uint8Array;
|
|
94
|
+
/**
|
|
95
|
+
* Get the public key as a base64 string
|
|
96
|
+
* @returns A base64 string representation of the public key
|
|
97
|
+
*/
|
|
98
|
+
getPublicKeyBase64(): Promise<string>;
|
|
99
|
+
/**
|
|
100
|
+
* Get the private key as a base64 string
|
|
101
|
+
* @returns A base64 string representation of the private key
|
|
102
|
+
*/
|
|
103
|
+
getPrivateKeyBase64(): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Sign a message and return the signature as a base64 string
|
|
106
|
+
* @param message The message to sign
|
|
107
|
+
* @returns A base64 string representation of the signature
|
|
108
|
+
*/
|
|
109
|
+
signBase64(message: string): Promise<string>;
|
|
110
|
+
/**
|
|
111
|
+
* Verify a signature provided as a base64 string
|
|
112
|
+
* @param message The message that was signed
|
|
113
|
+
* @param signatureBase64 The signature as a base64 string
|
|
114
|
+
* @returns True if the signature is valid, false otherwise
|
|
115
|
+
*/
|
|
116
|
+
verifyBase64(message: string, signatureBase64: string, publicKeyBase64: string): Promise<boolean>;
|
|
117
|
+
/**
|
|
118
|
+
* Create a public key from a private key provided as a base64 string
|
|
119
|
+
* @param privateKeyBase64 The private key as a base64 string
|
|
120
|
+
* @returns A base64 string representation of the public key
|
|
121
|
+
*/
|
|
122
|
+
publicKeyCreateBase64(privateKeyBase64: string): Promise<string>;
|
|
123
|
+
/**
|
|
124
|
+
* Set a private key from a base64 string
|
|
125
|
+
* @param privateKeyBase64 The private key as a base64 string
|
|
126
|
+
* @returns The public key as a base64 string
|
|
127
|
+
*/
|
|
128
|
+
setPrivateKeyBase64(privateKeyBase64: string): Promise<string>;
|
|
129
|
+
}
|
|
130
|
+
export {};
|