@enclave-technologies/pqc-primitives 0.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/LICENSE +202 -0
- package/README.md +173 -0
- package/dist/bundler/constants.js +63 -0
- package/dist/bundler/enclave_pqc_primitives_wasm.d.ts +218 -0
- package/dist/bundler/enclave_pqc_primitives_wasm.js +9 -0
- package/dist/bundler/enclave_pqc_primitives_wasm_bg.js +838 -0
- package/dist/bundler/enclave_pqc_primitives_wasm_bg.wasm +0 -0
- package/dist/bundler/enclave_pqc_primitives_wasm_bg.wasm.d.ts +41 -0
- package/dist/bundler/index.d.ts +157 -0
- package/dist/bundler/index.js +80 -0
- package/dist/nodejs/constants.js +63 -0
- package/dist/nodejs/enclave_pqc_primitives_wasm.cjs +873 -0
- package/dist/nodejs/enclave_pqc_primitives_wasm.d.ts +218 -0
- package/dist/nodejs/enclave_pqc_primitives_wasm_bg.wasm +0 -0
- package/dist/nodejs/enclave_pqc_primitives_wasm_bg.wasm.d.ts +41 -0
- package/dist/nodejs/index.d.ts +157 -0
- package/dist/nodejs/index.js +54 -0
- package/dist/web/constants.js +63 -0
- package/dist/web/enclave_pqc_primitives_wasm.d.ts +284 -0
- package/dist/web/enclave_pqc_primitives_wasm.js +938 -0
- package/dist/web/enclave_pqc_primitives_wasm_bg.wasm +0 -0
- package/dist/web/enclave_pqc_primitives_wasm_bg.wasm.d.ts +41 -0
- package/dist/web/index.d.ts +157 -0
- package/dist/web/index.js +101 -0
- package/package.json +65 -0
|
@@ -0,0 +1,873 @@
|
|
|
1
|
+
/* @ts-self-types="./enclave_pqc_primitives_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Canonical suite identifier matching the Rust crate (Category 5 algorithms).
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
function ENCLAVE_PQ_SUITE_ID() {
|
|
8
|
+
let deferred1_0;
|
|
9
|
+
let deferred1_1;
|
|
10
|
+
try {
|
|
11
|
+
const ret = wasm.ENCLAVE_PQ_SUITE_ID();
|
|
12
|
+
deferred1_0 = ret[0];
|
|
13
|
+
deferred1_1 = ret[1];
|
|
14
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
15
|
+
} finally {
|
|
16
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ENCLAVE_PQ_SUITE_ID = ENCLAVE_PQ_SUITE_ID;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Domain-separation prefix for the Enclave labeled KDF.
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
function KDF_LABEL_PREFIX() {
|
|
26
|
+
let deferred1_0;
|
|
27
|
+
let deferred1_1;
|
|
28
|
+
try {
|
|
29
|
+
const ret = wasm.KDF_LABEL_PREFIX();
|
|
30
|
+
deferred1_0 = ret[0];
|
|
31
|
+
deferred1_1 = ret[1];
|
|
32
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
33
|
+
} finally {
|
|
34
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.KDF_LABEL_PREFIX = KDF_LABEL_PREFIX;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Algorithm identifier (`"Argon2id"`).
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
function PWHASH_ALGORITHM() {
|
|
44
|
+
let deferred1_0;
|
|
45
|
+
let deferred1_1;
|
|
46
|
+
try {
|
|
47
|
+
const ret = wasm.PWHASH_ALGORITHM();
|
|
48
|
+
deferred1_0 = ret[0];
|
|
49
|
+
deferred1_1 = ret[1];
|
|
50
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
51
|
+
} finally {
|
|
52
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.PWHASH_ALGORITHM = PWHASH_ALGORITHM;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Derived key length in bytes (matches AES-256-GCM key size).
|
|
59
|
+
* @returns {number}
|
|
60
|
+
*/
|
|
61
|
+
function PWHASH_OUTPUT_BYTES() {
|
|
62
|
+
const ret = wasm.PWHASH_OUTPUT_BYTES();
|
|
63
|
+
return ret >>> 0;
|
|
64
|
+
}
|
|
65
|
+
exports.PWHASH_OUTPUT_BYTES = PWHASH_OUTPUT_BYTES;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Salt length in bytes produced by [`generate_salt`].
|
|
69
|
+
* @returns {number}
|
|
70
|
+
*/
|
|
71
|
+
function PWHASH_SALT_BYTES() {
|
|
72
|
+
const ret = wasm.PWHASH_SALT_BYTES();
|
|
73
|
+
return ret >>> 0;
|
|
74
|
+
}
|
|
75
|
+
exports.PWHASH_SALT_BYTES = PWHASH_SALT_BYTES;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* OWASP baseline Argon2id params: `{ memoryCostKib, iterations, parallelism }`.
|
|
79
|
+
*
|
|
80
|
+
* Sourced from the OWASP Password Storage Cheat Sheet (19 MiB / t=2 / p=1).
|
|
81
|
+
* Slow and memory-hard by design — lowering these for login latency is a
|
|
82
|
+
* security tradeoff, not a free optimization.
|
|
83
|
+
* @returns {any}
|
|
84
|
+
*/
|
|
85
|
+
function RECOMMENDED_PARAMS() {
|
|
86
|
+
const ret = wasm.RECOMMENDED_PARAMS();
|
|
87
|
+
if (ret[2]) {
|
|
88
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
89
|
+
}
|
|
90
|
+
return takeFromExternrefTable0(ret[0]);
|
|
91
|
+
}
|
|
92
|
+
exports.RECOMMENDED_PARAMS = RECOMMENDED_PARAMS;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Decrypt AES-256-GCM ciphertext (including trailing tag).
|
|
96
|
+
*
|
|
97
|
+
* Throws on authentication failure (`AeadFailure: ...`).
|
|
98
|
+
* @param {Uint8Array} key
|
|
99
|
+
* @param {Uint8Array} nonce
|
|
100
|
+
* @param {Uint8Array} ciphertext
|
|
101
|
+
* @param {Uint8Array} aad
|
|
102
|
+
* @returns {Uint8Array}
|
|
103
|
+
*/
|
|
104
|
+
function aeadDecrypt(key, nonce, ciphertext, aad) {
|
|
105
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
106
|
+
const len0 = WASM_VECTOR_LEN;
|
|
107
|
+
const ptr1 = passArray8ToWasm0(nonce, wasm.__wbindgen_malloc);
|
|
108
|
+
const len1 = WASM_VECTOR_LEN;
|
|
109
|
+
const ptr2 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
110
|
+
const len2 = WASM_VECTOR_LEN;
|
|
111
|
+
const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
112
|
+
const len3 = WASM_VECTOR_LEN;
|
|
113
|
+
const ret = wasm.aeadDecrypt(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
114
|
+
if (ret[3]) {
|
|
115
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
116
|
+
}
|
|
117
|
+
var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
118
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
119
|
+
return v5;
|
|
120
|
+
}
|
|
121
|
+
exports.aeadDecrypt = aeadDecrypt;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Encrypt with AES-256-GCM under an explicit key and nonce.
|
|
125
|
+
*
|
|
126
|
+
* Returns `ciphertext || tag` (16-byte tag suffix). Callers must ensure
|
|
127
|
+
* `(key, nonce)` uniqueness.
|
|
128
|
+
* @param {Uint8Array} key
|
|
129
|
+
* @param {Uint8Array} nonce
|
|
130
|
+
* @param {Uint8Array} plaintext
|
|
131
|
+
* @param {Uint8Array} aad
|
|
132
|
+
* @returns {Uint8Array}
|
|
133
|
+
*/
|
|
134
|
+
function aeadEncrypt(key, nonce, plaintext, aad) {
|
|
135
|
+
const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
|
|
136
|
+
const len0 = WASM_VECTOR_LEN;
|
|
137
|
+
const ptr1 = passArray8ToWasm0(nonce, wasm.__wbindgen_malloc);
|
|
138
|
+
const len1 = WASM_VECTOR_LEN;
|
|
139
|
+
const ptr2 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
|
|
140
|
+
const len2 = WASM_VECTOR_LEN;
|
|
141
|
+
const ptr3 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc);
|
|
142
|
+
const len3 = WASM_VECTOR_LEN;
|
|
143
|
+
const ret = wasm.aeadEncrypt(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
144
|
+
if (ret[3]) {
|
|
145
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
146
|
+
}
|
|
147
|
+
var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
148
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
149
|
+
return v5;
|
|
150
|
+
}
|
|
151
|
+
exports.aeadEncrypt = aeadEncrypt;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Cryptographically random 16-byte salt for Argon2id.
|
|
155
|
+
* @returns {Uint8Array}
|
|
156
|
+
*/
|
|
157
|
+
function generateSalt() {
|
|
158
|
+
const ret = wasm.generateSalt();
|
|
159
|
+
if (ret[3]) {
|
|
160
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
161
|
+
}
|
|
162
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
163
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
164
|
+
return v1;
|
|
165
|
+
}
|
|
166
|
+
exports.generateSalt = generateSalt;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Return the [`CryptoUsageRecord`] from the last WASM primitive call.
|
|
170
|
+
*
|
|
171
|
+
* Shape: `{ algorithm, suiteId, operation, crateVersion }`.
|
|
172
|
+
* Returns `undefined` if no operation has run yet in this WASM instance.
|
|
173
|
+
*
|
|
174
|
+
* This is the CBOM attach point for product layers (Encrypt, etc.). This
|
|
175
|
+
* binding does not persist or transmit the record.
|
|
176
|
+
* @returns {any}
|
|
177
|
+
*/
|
|
178
|
+
function getLastUsageRecord() {
|
|
179
|
+
const ret = wasm.getLastUsageRecord();
|
|
180
|
+
if (ret[2]) {
|
|
181
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
182
|
+
}
|
|
183
|
+
return takeFromExternrefTable0(ret[0]);
|
|
184
|
+
}
|
|
185
|
+
exports.getLastUsageRecord = getLastUsageRecord;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* SHAKE256 over UTF-8 string bytes.
|
|
189
|
+
* @param {string} value
|
|
190
|
+
* @param {number} output_len
|
|
191
|
+
* @returns {Uint8Array}
|
|
192
|
+
*/
|
|
193
|
+
function hashUtf8(value, output_len) {
|
|
194
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
195
|
+
const len0 = WASM_VECTOR_LEN;
|
|
196
|
+
const ret = wasm.hashUtf8(ptr0, len0, output_len);
|
|
197
|
+
if (ret[3]) {
|
|
198
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
199
|
+
}
|
|
200
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
201
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
202
|
+
return v2;
|
|
203
|
+
}
|
|
204
|
+
exports.hashUtf8 = hashUtf8;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Decapsulate an ML-KEM-1024 ciphertext.
|
|
208
|
+
*
|
|
209
|
+
* `secret_key` may be a 64-byte seed or a 3168-byte expanded key.
|
|
210
|
+
* @param {Uint8Array} ciphertext
|
|
211
|
+
* @param {Uint8Array} secret_key
|
|
212
|
+
* @returns {Uint8Array}
|
|
213
|
+
*/
|
|
214
|
+
function kemDecapsulate(ciphertext, secret_key) {
|
|
215
|
+
const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
|
|
216
|
+
const len0 = WASM_VECTOR_LEN;
|
|
217
|
+
const ptr1 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
218
|
+
const len1 = WASM_VECTOR_LEN;
|
|
219
|
+
const ret = wasm.kemDecapsulate(ptr0, len0, ptr1, len1);
|
|
220
|
+
if (ret[3]) {
|
|
221
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
222
|
+
}
|
|
223
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
224
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
225
|
+
return v3;
|
|
226
|
+
}
|
|
227
|
+
exports.kemDecapsulate = kemDecapsulate;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Encapsulate a shared secret to an ML-KEM-1024 public key.
|
|
231
|
+
*
|
|
232
|
+
* Returns `{ ciphertext, sharedSecret }` (1568 / 32 bytes).
|
|
233
|
+
* @param {Uint8Array} public_key
|
|
234
|
+
* @returns {any}
|
|
235
|
+
*/
|
|
236
|
+
function kemEncapsulate(public_key) {
|
|
237
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
238
|
+
const len0 = WASM_VECTOR_LEN;
|
|
239
|
+
const ret = wasm.kemEncapsulate(ptr0, len0);
|
|
240
|
+
if (ret[2]) {
|
|
241
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
242
|
+
}
|
|
243
|
+
return takeFromExternrefTable0(ret[0]);
|
|
244
|
+
}
|
|
245
|
+
exports.kemEncapsulate = kemEncapsulate;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Deterministic encapsulation for known-answer / KAT compliance.
|
|
249
|
+
*
|
|
250
|
+
* # Hazmat
|
|
251
|
+
*
|
|
252
|
+
* **KATs only.** Production code must call [`kem_encapsulate`].
|
|
253
|
+
* @param {Uint8Array} public_key
|
|
254
|
+
* @param {Uint8Array} m
|
|
255
|
+
* @returns {any}
|
|
256
|
+
*/
|
|
257
|
+
function kemEncapsulateDeterministic(public_key, m) {
|
|
258
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
259
|
+
const len0 = WASM_VECTOR_LEN;
|
|
260
|
+
const ptr1 = passArray8ToWasm0(m, wasm.__wbindgen_malloc);
|
|
261
|
+
const len1 = WASM_VECTOR_LEN;
|
|
262
|
+
const ret = wasm.kemEncapsulateDeterministic(ptr0, len0, ptr1, len1);
|
|
263
|
+
if (ret[2]) {
|
|
264
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
265
|
+
}
|
|
266
|
+
return takeFromExternrefTable0(ret[0]);
|
|
267
|
+
}
|
|
268
|
+
exports.kemEncapsulateDeterministic = kemEncapsulateDeterministic;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Expand a 64-byte seed-form secret key to the FIPS expanded encoding
|
|
272
|
+
* ([`kem::SECRET_KEY_BYTES`] bytes).
|
|
273
|
+
* @param {Uint8Array} secret_key
|
|
274
|
+
* @returns {Uint8Array}
|
|
275
|
+
*/
|
|
276
|
+
function kemExpandedSecretKey(secret_key) {
|
|
277
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
278
|
+
const len0 = WASM_VECTOR_LEN;
|
|
279
|
+
const ret = wasm.kemExpandedSecretKey(ptr0, len0);
|
|
280
|
+
if (ret[3]) {
|
|
281
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
282
|
+
}
|
|
283
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
284
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
285
|
+
return v2;
|
|
286
|
+
}
|
|
287
|
+
exports.kemExpandedSecretKey = kemExpandedSecretKey;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Generate a fresh ML-KEM-1024 keypair (includes PCT).
|
|
291
|
+
*
|
|
292
|
+
* Returns `{ publicKey, secretKey }` where `secretKey` is the preferred
|
|
293
|
+
* seed form ([`kem::SECRET_KEY_SEED_BYTES`] = 64). Expanded size is
|
|
294
|
+
* [`kem::SECRET_KEY_BYTES`] = 3168 — use [`kem_expanded_secret_key`].
|
|
295
|
+
*
|
|
296
|
+
* Throws `PairwiseConsistencyFailureError` if the PCT fails.
|
|
297
|
+
* @returns {any}
|
|
298
|
+
*/
|
|
299
|
+
function kemGenerateKeypair() {
|
|
300
|
+
const ret = wasm.kemGenerateKeypair();
|
|
301
|
+
if (ret[2]) {
|
|
302
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
303
|
+
}
|
|
304
|
+
return takeFromExternrefTable0(ret[0]);
|
|
305
|
+
}
|
|
306
|
+
exports.kemGenerateKeypair = kemGenerateKeypair;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Derive an ML-KEM-1024 keypair from a 64-byte seed (`d || z`). Includes PCT.
|
|
310
|
+
* @param {Uint8Array} seed
|
|
311
|
+
* @returns {any}
|
|
312
|
+
*/
|
|
313
|
+
function kemKeypairFromSeed(seed) {
|
|
314
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
315
|
+
const len0 = WASM_VECTOR_LEN;
|
|
316
|
+
const ret = wasm.kemKeypairFromSeed(ptr0, len0);
|
|
317
|
+
if (ret[2]) {
|
|
318
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
319
|
+
}
|
|
320
|
+
return takeFromExternrefTable0(ret[0]);
|
|
321
|
+
}
|
|
322
|
+
exports.kemKeypairFromSeed = kemKeypairFromSeed;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Derive key material with `enclave-kdf-v1` labeled SHAKE256.
|
|
326
|
+
*
|
|
327
|
+
* Throws `InvalidParameter` on empty `label` or `length == 0`.
|
|
328
|
+
* @param {string} label
|
|
329
|
+
* @param {Uint8Array} ikm
|
|
330
|
+
* @param {number} length
|
|
331
|
+
* @returns {Uint8Array}
|
|
332
|
+
*/
|
|
333
|
+
function labeledKdf(label, ikm, length) {
|
|
334
|
+
const ptr0 = passStringToWasm0(label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
335
|
+
const len0 = WASM_VECTOR_LEN;
|
|
336
|
+
const ptr1 = passArray8ToWasm0(ikm, wasm.__wbindgen_malloc);
|
|
337
|
+
const len1 = WASM_VECTOR_LEN;
|
|
338
|
+
const ret = wasm.labeledKdf(ptr0, len0, ptr1, len1, length);
|
|
339
|
+
if (ret[3]) {
|
|
340
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
341
|
+
}
|
|
342
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
343
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
344
|
+
return v3;
|
|
345
|
+
}
|
|
346
|
+
exports.labeledKdf = labeledKdf;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* [`labeled_kdf`] with a 32-byte output.
|
|
350
|
+
* @param {string} label
|
|
351
|
+
* @param {Uint8Array} ikm
|
|
352
|
+
* @returns {Uint8Array}
|
|
353
|
+
*/
|
|
354
|
+
function labeledKdf32(label, ikm) {
|
|
355
|
+
const ptr0 = passStringToWasm0(label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
356
|
+
const len0 = WASM_VECTOR_LEN;
|
|
357
|
+
const ptr1 = passArray8ToWasm0(ikm, wasm.__wbindgen_malloc);
|
|
358
|
+
const len1 = WASM_VECTOR_LEN;
|
|
359
|
+
const ret = wasm.labeledKdf32(ptr0, len0, ptr1, len1);
|
|
360
|
+
if (ret[3]) {
|
|
361
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
362
|
+
}
|
|
363
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
364
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
365
|
+
return v3;
|
|
366
|
+
}
|
|
367
|
+
exports.labeledKdf32 = labeledKdf32;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Derive a 32-byte key from a password + salt with Argon2id.
|
|
371
|
+
*
|
|
372
|
+
* `params` must be `{ memoryCostKib, iterations, parallelism }` (see
|
|
373
|
+
* [`recommended_params`]). Throws on empty password / wrong salt length /
|
|
374
|
+
* invalid costs.
|
|
375
|
+
*
|
|
376
|
+
* This call is intentionally slow (~tens–hundreds of ms depending on host).
|
|
377
|
+
* That cost is the offline brute-force defense — do not lower params casually.
|
|
378
|
+
* @param {Uint8Array} password
|
|
379
|
+
* @param {Uint8Array} salt
|
|
380
|
+
* @param {any} params
|
|
381
|
+
* @returns {Uint8Array}
|
|
382
|
+
*/
|
|
383
|
+
function pwhashDeriveKey(password, salt, params) {
|
|
384
|
+
const ptr0 = passArray8ToWasm0(password, wasm.__wbindgen_malloc);
|
|
385
|
+
const len0 = WASM_VECTOR_LEN;
|
|
386
|
+
const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);
|
|
387
|
+
const len1 = WASM_VECTOR_LEN;
|
|
388
|
+
const ret = wasm.pwhashDeriveKey(ptr0, len0, ptr1, len1, params);
|
|
389
|
+
if (ret[3]) {
|
|
390
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
391
|
+
}
|
|
392
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
393
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
394
|
+
return v3;
|
|
395
|
+
}
|
|
396
|
+
exports.pwhashDeriveKey = pwhashDeriveKey;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Run known-answer CASTs for ML-KEM-1024, ML-DSA-87, and Argon2id.
|
|
400
|
+
*
|
|
401
|
+
* Throws `SelfTestFailureError` if any CAST fails. Pair-wise consistency is
|
|
402
|
+
* already enforced inside key generation — this is the power-on / module-entry
|
|
403
|
+
* known-answer path. The Argon2id CAST is slower (memory-hard by design).
|
|
404
|
+
*/
|
|
405
|
+
function runSelfTests() {
|
|
406
|
+
const ret = wasm.runSelfTests();
|
|
407
|
+
if (ret[1]) {
|
|
408
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
exports.runSelfTests = runSelfTests;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* One-shot SHAKE256 hash of `input` into `output_len` bytes.
|
|
415
|
+
* @param {Uint8Array} input
|
|
416
|
+
* @param {number} output_len
|
|
417
|
+
* @returns {Uint8Array}
|
|
418
|
+
*/
|
|
419
|
+
function shake256(input, output_len) {
|
|
420
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
421
|
+
const len0 = WASM_VECTOR_LEN;
|
|
422
|
+
const ret = wasm.shake256(ptr0, len0, output_len);
|
|
423
|
+
if (ret[3]) {
|
|
424
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
425
|
+
}
|
|
426
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
427
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
428
|
+
return v2;
|
|
429
|
+
}
|
|
430
|
+
exports.shake256 = shake256;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Expand a 32-byte seed-form secret key to the FIPS expanded encoding
|
|
434
|
+
* ([`sig::SECRET_KEY_BYTES`] bytes).
|
|
435
|
+
* @param {Uint8Array} secret_key
|
|
436
|
+
* @returns {Uint8Array}
|
|
437
|
+
*/
|
|
438
|
+
function sigExpandedSecretKey(secret_key) {
|
|
439
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
440
|
+
const len0 = WASM_VECTOR_LEN;
|
|
441
|
+
const ret = wasm.sigExpandedSecretKey(ptr0, len0);
|
|
442
|
+
if (ret[3]) {
|
|
443
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
444
|
+
}
|
|
445
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
446
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
447
|
+
return v2;
|
|
448
|
+
}
|
|
449
|
+
exports.sigExpandedSecretKey = sigExpandedSecretKey;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Generate a fresh ML-DSA-87 keypair (includes PCT).
|
|
453
|
+
*
|
|
454
|
+
* Returns `{ publicKey, secretKey }` where `secretKey` is the preferred
|
|
455
|
+
* seed form ([`sig::SECRET_KEY_SEED_BYTES`] = 32). Expanded size is
|
|
456
|
+
* [`sig::SECRET_KEY_BYTES`] = 4896.
|
|
457
|
+
*
|
|
458
|
+
* Throws `PairwiseConsistencyFailureError` if the PCT fails.
|
|
459
|
+
* @returns {any}
|
|
460
|
+
*/
|
|
461
|
+
function sigGenerateKeypair() {
|
|
462
|
+
const ret = wasm.sigGenerateKeypair();
|
|
463
|
+
if (ret[2]) {
|
|
464
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
465
|
+
}
|
|
466
|
+
return takeFromExternrefTable0(ret[0]);
|
|
467
|
+
}
|
|
468
|
+
exports.sigGenerateKeypair = sigGenerateKeypair;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Derive an ML-DSA-87 keypair from a 32-byte seed. Includes PCT.
|
|
472
|
+
* @param {Uint8Array} seed
|
|
473
|
+
* @returns {any}
|
|
474
|
+
*/
|
|
475
|
+
function sigKeypairFromSeed(seed) {
|
|
476
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
477
|
+
const len0 = WASM_VECTOR_LEN;
|
|
478
|
+
const ret = wasm.sigKeypairFromSeed(ptr0, len0);
|
|
479
|
+
if (ret[2]) {
|
|
480
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
481
|
+
}
|
|
482
|
+
return takeFromExternrefTable0(ret[0]);
|
|
483
|
+
}
|
|
484
|
+
exports.sigKeypairFromSeed = sigKeypairFromSeed;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Sign a message with empty context (deterministic ML-DSA-87).
|
|
488
|
+
*
|
|
489
|
+
* Empty `message` throws `InvalidLength` (matches Rust).
|
|
490
|
+
* @param {Uint8Array} secret_key
|
|
491
|
+
* @param {Uint8Array} message
|
|
492
|
+
* @returns {Uint8Array}
|
|
493
|
+
*/
|
|
494
|
+
function sigSign(secret_key, message) {
|
|
495
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
496
|
+
const len0 = WASM_VECTOR_LEN;
|
|
497
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
498
|
+
const len1 = WASM_VECTOR_LEN;
|
|
499
|
+
const ret = wasm.sigSign(ptr0, len0, ptr1, len1);
|
|
500
|
+
if (ret[3]) {
|
|
501
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
502
|
+
}
|
|
503
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
504
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
505
|
+
return v3;
|
|
506
|
+
}
|
|
507
|
+
exports.sigSign = sigSign;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Deterministic ML-DSA.Sign with an explicit context (`context.len() <= 255`).
|
|
511
|
+
*
|
|
512
|
+
* Empty `message` or `context.len() > 255` throws (matches Rust).
|
|
513
|
+
* @param {Uint8Array} secret_key
|
|
514
|
+
* @param {Uint8Array} message
|
|
515
|
+
* @param {Uint8Array} context
|
|
516
|
+
* @returns {Uint8Array}
|
|
517
|
+
*/
|
|
518
|
+
function sigSignWithContext(secret_key, message, context) {
|
|
519
|
+
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
520
|
+
const len0 = WASM_VECTOR_LEN;
|
|
521
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
522
|
+
const len1 = WASM_VECTOR_LEN;
|
|
523
|
+
const ptr2 = passArray8ToWasm0(context, wasm.__wbindgen_malloc);
|
|
524
|
+
const len2 = WASM_VECTOR_LEN;
|
|
525
|
+
const ret = wasm.sigSignWithContext(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
526
|
+
if (ret[3]) {
|
|
527
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
528
|
+
}
|
|
529
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
530
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
531
|
+
return v4;
|
|
532
|
+
}
|
|
533
|
+
exports.sigSignWithContext = sigSignWithContext;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Verify an ML-DSA-87 signature (empty context).
|
|
537
|
+
*
|
|
538
|
+
* Returns `false` on a cryptographically invalid signature. Throws only for
|
|
539
|
+
* malformed input lengths / encodings.
|
|
540
|
+
* @param {Uint8Array} public_key
|
|
541
|
+
* @param {Uint8Array} message
|
|
542
|
+
* @param {Uint8Array} signature
|
|
543
|
+
* @returns {boolean}
|
|
544
|
+
*/
|
|
545
|
+
function sigVerify(public_key, message, signature) {
|
|
546
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
547
|
+
const len0 = WASM_VECTOR_LEN;
|
|
548
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
549
|
+
const len1 = WASM_VECTOR_LEN;
|
|
550
|
+
const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
551
|
+
const len2 = WASM_VECTOR_LEN;
|
|
552
|
+
const ret = wasm.sigVerify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
553
|
+
if (ret[2]) {
|
|
554
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
555
|
+
}
|
|
556
|
+
return ret[0] !== 0;
|
|
557
|
+
}
|
|
558
|
+
exports.sigVerify = sigVerify;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Verify an ML-DSA-87 signature with an explicit context.
|
|
562
|
+
*
|
|
563
|
+
* Returns `false` on cryptographic failure; throws on malformed lengths.
|
|
564
|
+
* @param {Uint8Array} public_key
|
|
565
|
+
* @param {Uint8Array} message
|
|
566
|
+
* @param {Uint8Array} signature
|
|
567
|
+
* @param {Uint8Array} context
|
|
568
|
+
* @returns {boolean}
|
|
569
|
+
*/
|
|
570
|
+
function sigVerifyWithContext(public_key, message, signature, context) {
|
|
571
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
572
|
+
const len0 = WASM_VECTOR_LEN;
|
|
573
|
+
const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
574
|
+
const len1 = WASM_VECTOR_LEN;
|
|
575
|
+
const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
576
|
+
const len2 = WASM_VECTOR_LEN;
|
|
577
|
+
const ptr3 = passArray8ToWasm0(context, wasm.__wbindgen_malloc);
|
|
578
|
+
const len3 = WASM_VECTOR_LEN;
|
|
579
|
+
const ret = wasm.sigVerifyWithContext(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
580
|
+
if (ret[2]) {
|
|
581
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
582
|
+
}
|
|
583
|
+
return ret[0] !== 0;
|
|
584
|
+
}
|
|
585
|
+
exports.sigVerifyWithContext = sigVerifyWithContext;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Overwrite a JS `Uint8Array` in place with zeros.
|
|
589
|
+
*
|
|
590
|
+
* # Security note
|
|
591
|
+
*
|
|
592
|
+
* Rust-side secret keys are zeroized on `Drop`, but that guarantee **does not**
|
|
593
|
+
* cross the WASM boundary. Once secret material lives in a JS `Uint8Array`, the
|
|
594
|
+
* JS garbage collector will not zero it. Call this when you are finished with
|
|
595
|
+
* long-lived secret buffers.
|
|
596
|
+
* @param {Uint8Array} buf
|
|
597
|
+
*/
|
|
598
|
+
function zeroize(buf) {
|
|
599
|
+
wasm.zeroize(buf);
|
|
600
|
+
}
|
|
601
|
+
exports.zeroize = zeroize;
|
|
602
|
+
function __wbg_get_imports() {
|
|
603
|
+
const import0 = {
|
|
604
|
+
__proto__: null,
|
|
605
|
+
__wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
|
|
606
|
+
const ret = typeof(arg0) === 'function';
|
|
607
|
+
return ret;
|
|
608
|
+
},
|
|
609
|
+
__wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
|
|
610
|
+
const val = arg0;
|
|
611
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
612
|
+
return ret;
|
|
613
|
+
},
|
|
614
|
+
__wbg___wbindgen_is_string_ea5e6cc2e4141dfe: function(arg0) {
|
|
615
|
+
const ret = typeof(arg0) === 'string';
|
|
616
|
+
return ret;
|
|
617
|
+
},
|
|
618
|
+
__wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
|
|
619
|
+
const ret = arg0 === undefined;
|
|
620
|
+
return ret;
|
|
621
|
+
},
|
|
622
|
+
__wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
|
|
623
|
+
const obj = arg1;
|
|
624
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
625
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
626
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
627
|
+
},
|
|
628
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
629
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
630
|
+
},
|
|
631
|
+
__wbg_call_a6e5c5dce5018821: function() { return handleError(function (arg0, arg1, arg2) {
|
|
632
|
+
const ret = arg0.call(arg1, arg2);
|
|
633
|
+
return ret;
|
|
634
|
+
}, arguments); },
|
|
635
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
636
|
+
const ret = arg0.crypto;
|
|
637
|
+
return ret;
|
|
638
|
+
},
|
|
639
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
640
|
+
arg0.getRandomValues(arg1);
|
|
641
|
+
}, arguments); },
|
|
642
|
+
__wbg_getRandomValues_cc7f052a444bb2ce: function() { return handleError(function (arg0, arg1) {
|
|
643
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
644
|
+
}, arguments); },
|
|
645
|
+
__wbg_get_78f252d074a84d0b: function() { return handleError(function (arg0, arg1) {
|
|
646
|
+
const ret = Reflect.get(arg0, arg1);
|
|
647
|
+
return ret;
|
|
648
|
+
}, arguments); },
|
|
649
|
+
__wbg_length_1f0964f4a5e2c6d8: function(arg0) {
|
|
650
|
+
const ret = arg0.length;
|
|
651
|
+
return ret;
|
|
652
|
+
},
|
|
653
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
654
|
+
const ret = arg0.msCrypto;
|
|
655
|
+
return ret;
|
|
656
|
+
},
|
|
657
|
+
__wbg_new_b667d279fd5aa943: function(arg0, arg1) {
|
|
658
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
659
|
+
return ret;
|
|
660
|
+
},
|
|
661
|
+
__wbg_new_da52cf8fe3429cb2: function() {
|
|
662
|
+
const ret = new Object();
|
|
663
|
+
return ret;
|
|
664
|
+
},
|
|
665
|
+
__wbg_new_from_slice_77cdfb7977362f3c: function(arg0, arg1) {
|
|
666
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
667
|
+
return ret;
|
|
668
|
+
},
|
|
669
|
+
__wbg_new_with_length_e6785c33c8e4cce8: function(arg0) {
|
|
670
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
671
|
+
return ret;
|
|
672
|
+
},
|
|
673
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
674
|
+
const ret = arg0.node;
|
|
675
|
+
return ret;
|
|
676
|
+
},
|
|
677
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
678
|
+
const ret = arg0.process;
|
|
679
|
+
return ret;
|
|
680
|
+
},
|
|
681
|
+
__wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
|
|
682
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
683
|
+
},
|
|
684
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
685
|
+
arg0.randomFillSync(arg1);
|
|
686
|
+
}, arguments); },
|
|
687
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
688
|
+
const ret = module.require;
|
|
689
|
+
return ret;
|
|
690
|
+
}, arguments); },
|
|
691
|
+
__wbg_set_8535240470bf2500: function() { return handleError(function (arg0, arg1, arg2) {
|
|
692
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
693
|
+
return ret;
|
|
694
|
+
}, arguments); },
|
|
695
|
+
__wbg_set_index_0a2d916cd3658df4: function(arg0, arg1, arg2) {
|
|
696
|
+
arg0[arg1 >>> 0] = arg2;
|
|
697
|
+
},
|
|
698
|
+
__wbg_static_accessor_GLOBAL_4ef717fb391d88b7: function() {
|
|
699
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
700
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
701
|
+
},
|
|
702
|
+
__wbg_static_accessor_GLOBAL_THIS_8d1badc68b5a74f4: function() {
|
|
703
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
704
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
705
|
+
},
|
|
706
|
+
__wbg_static_accessor_SELF_146583524fe1469b: function() {
|
|
707
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
708
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
709
|
+
},
|
|
710
|
+
__wbg_static_accessor_WINDOW_f2829a2234d7819e: function() {
|
|
711
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
712
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
713
|
+
},
|
|
714
|
+
__wbg_subarray_3ed232c8a6baee09: function(arg0, arg1, arg2) {
|
|
715
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
716
|
+
return ret;
|
|
717
|
+
},
|
|
718
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
719
|
+
const ret = arg0.versions;
|
|
720
|
+
return ret;
|
|
721
|
+
},
|
|
722
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
723
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
724
|
+
const ret = arg0;
|
|
725
|
+
return ret;
|
|
726
|
+
},
|
|
727
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
728
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
729
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
730
|
+
return ret;
|
|
731
|
+
},
|
|
732
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
733
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
734
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
735
|
+
return ret;
|
|
736
|
+
},
|
|
737
|
+
__wbindgen_init_externref_table: function() {
|
|
738
|
+
const table = wasm.__wbindgen_externrefs;
|
|
739
|
+
const offset = table.grow(4);
|
|
740
|
+
table.set(0, undefined);
|
|
741
|
+
table.set(offset + 0, undefined);
|
|
742
|
+
table.set(offset + 1, null);
|
|
743
|
+
table.set(offset + 2, true);
|
|
744
|
+
table.set(offset + 3, false);
|
|
745
|
+
},
|
|
746
|
+
};
|
|
747
|
+
return {
|
|
748
|
+
__proto__: null,
|
|
749
|
+
"./enclave_pqc_primitives_wasm_bg.js": import0,
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function addToExternrefTable0(obj) {
|
|
754
|
+
const idx = wasm.__externref_table_alloc();
|
|
755
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
756
|
+
return idx;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
760
|
+
ptr = ptr >>> 0;
|
|
761
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
let cachedDataViewMemory0 = null;
|
|
765
|
+
function getDataViewMemory0() {
|
|
766
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
767
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
768
|
+
}
|
|
769
|
+
return cachedDataViewMemory0;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
function getStringFromWasm0(ptr, len) {
|
|
773
|
+
return decodeText(ptr >>> 0, len);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
let cachedUint8ArrayMemory0 = null;
|
|
777
|
+
function getUint8ArrayMemory0() {
|
|
778
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
779
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
780
|
+
}
|
|
781
|
+
return cachedUint8ArrayMemory0;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function handleError(f, args) {
|
|
785
|
+
try {
|
|
786
|
+
return f.apply(this, args);
|
|
787
|
+
} catch (e) {
|
|
788
|
+
const idx = addToExternrefTable0(e);
|
|
789
|
+
wasm.__wbindgen_exn_store(idx);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function isLikeNone(x) {
|
|
794
|
+
return x === undefined || x === null;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
798
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
799
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
800
|
+
WASM_VECTOR_LEN = arg.length;
|
|
801
|
+
return ptr;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
805
|
+
if (realloc === undefined) {
|
|
806
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
807
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
808
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
809
|
+
WASM_VECTOR_LEN = buf.length;
|
|
810
|
+
return ptr;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
let len = arg.length;
|
|
814
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
815
|
+
|
|
816
|
+
const mem = getUint8ArrayMemory0();
|
|
817
|
+
|
|
818
|
+
let offset = 0;
|
|
819
|
+
|
|
820
|
+
for (; offset < len; offset++) {
|
|
821
|
+
const code = arg.charCodeAt(offset);
|
|
822
|
+
if (code > 0x7F) break;
|
|
823
|
+
mem[ptr + offset] = code;
|
|
824
|
+
}
|
|
825
|
+
if (offset !== len) {
|
|
826
|
+
if (offset !== 0) {
|
|
827
|
+
arg = arg.slice(offset);
|
|
828
|
+
}
|
|
829
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
830
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
831
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
832
|
+
|
|
833
|
+
offset += ret.written;
|
|
834
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
WASM_VECTOR_LEN = offset;
|
|
838
|
+
return ptr;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
function takeFromExternrefTable0(idx) {
|
|
842
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
843
|
+
wasm.__externref_table_dealloc(idx);
|
|
844
|
+
return value;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
848
|
+
cachedTextDecoder.decode();
|
|
849
|
+
function decodeText(ptr, len) {
|
|
850
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
const cachedTextEncoder = new TextEncoder();
|
|
854
|
+
|
|
855
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
856
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
857
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
858
|
+
view.set(buf);
|
|
859
|
+
return {
|
|
860
|
+
read: arg.length,
|
|
861
|
+
written: buf.length
|
|
862
|
+
};
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
let WASM_VECTOR_LEN = 0;
|
|
867
|
+
|
|
868
|
+
const wasmPath = `${__dirname}/enclave_pqc_primitives_wasm_bg.wasm`;
|
|
869
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
870
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
871
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
872
|
+
let wasm = wasmInstance.exports;
|
|
873
|
+
wasm.__wbindgen_start();
|