@lib-q/core 0.0.1 → 0.0.5

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/nodejs/libq.js ADDED
@@ -0,0 +1,2455 @@
1
+ /* @ts-self-types="./libq.d.ts" */
2
+
3
+ /**
4
+ * Algorithm identifiers for cryptographic operations
5
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64}
6
+ */
7
+ const Algorithm = Object.freeze({
8
+ MlKem512: 0, "0": "MlKem512",
9
+ MlKem768: 1, "1": "MlKem768",
10
+ MlKem1024: 2, "2": "MlKem1024",
11
+ CbKem348864: 3, "3": "CbKem348864",
12
+ CbKem460896: 4, "4": "CbKem460896",
13
+ CbKem6688128: 5, "5": "CbKem6688128",
14
+ CbKem6960119: 6, "6": "CbKem6960119",
15
+ CbKem8192128: 7, "7": "CbKem8192128",
16
+ Hqc128: 8, "8": "Hqc128",
17
+ Hqc192: 9, "9": "Hqc192",
18
+ Hqc256: 10, "10": "Hqc256",
19
+ MlDsa44: 11, "11": "MlDsa44",
20
+ MlDsa65: 12, "12": "MlDsa65",
21
+ MlDsa87: 13, "13": "MlDsa87",
22
+ FnDsa: 14, "14": "FnDsa",
23
+ FnDsa512: 15, "15": "FnDsa512",
24
+ FnDsa1024: 16, "16": "FnDsa1024",
25
+ SlhDsaSha256128fRobust: 17, "17": "SlhDsaSha256128fRobust",
26
+ SlhDsaSha256192fRobust: 18, "18": "SlhDsaSha256192fRobust",
27
+ SlhDsaSha256256fRobust: 19, "19": "SlhDsaSha256256fRobust",
28
+ SlhDsaShake256128fRobust: 20, "20": "SlhDsaShake256128fRobust",
29
+ SlhDsaShake256192fRobust: 21, "21": "SlhDsaShake256192fRobust",
30
+ SlhDsaShake256256fRobust: 22, "22": "SlhDsaShake256256fRobust",
31
+ Shake128: 23, "23": "Shake128",
32
+ Shake256: 24, "24": "Shake256",
33
+ CShake128: 25, "25": "CShake128",
34
+ CShake256: 26, "26": "CShake256",
35
+ Sha3_224: 27, "27": "Sha3_224",
36
+ Sha3_256: 28, "28": "Sha3_256",
37
+ Sha3_384: 29, "29": "Sha3_384",
38
+ Sha3_512: 30, "30": "Sha3_512",
39
+ Keccak224: 31, "31": "Keccak224",
40
+ Keccak256: 32, "32": "Keccak256",
41
+ Keccak384: 33, "33": "Keccak384",
42
+ Keccak512: 34, "34": "Keccak512",
43
+ Kt128: 35, "35": "Kt128",
44
+ Kt256: 36, "36": "Kt256",
45
+ TurboShake128: 37, "37": "TurboShake128",
46
+ TurboShake256: 38, "38": "TurboShake256",
47
+ Kmac128: 39, "39": "Kmac128",
48
+ Kmac256: 40, "40": "Kmac256",
49
+ TupleHash128: 41, "41": "TupleHash128",
50
+ TupleHash256: 42, "42": "TupleHash256",
51
+ ParallelHash128: 43, "43": "ParallelHash128",
52
+ ParallelHash256: 44, "44": "ParallelHash256",
53
+ Sha224: 45, "45": "Sha224",
54
+ Sha256: 46, "46": "Sha256",
55
+ Sha384: 47, "47": "Sha384",
56
+ Sha512: 48, "48": "Sha512",
57
+ Sha512_224: 49, "49": "Sha512_224",
58
+ Sha512_256: 50, "50": "Sha512_256",
59
+ Saturnin: 51, "51": "Saturnin",
60
+ Shake256Aead: 52, "52": "Shake256Aead",
61
+ DuplexSpongeAead: 53, "53": "DuplexSpongeAead",
62
+ TweakAead: 54, "54": "TweakAead",
63
+ RomulusN: 55, "55": "RomulusN",
64
+ RomulusM: 56, "56": "RomulusM",
65
+ /**
66
+ * Privacy-protocol identifiers (not standalone KEM/sig/hash providers).
67
+ */
68
+ LatticeRingSignature: 57, "57": "LatticeRingSignature",
69
+ LatticeBlindIssuance: 58, "58": "LatticeBlindIssuance",
70
+ LatticeAnonymousToken: 59, "59": "LatticeAnonymousToken",
71
+ LatticeNullifierRegistry: 60, "60": "LatticeNullifierRegistry",
72
+ /**
73
+ * Witness-derived nullifier mode (SHAKE256 over opening witness wire; see `lib-q-lattice-zkp`).
74
+ */
75
+ LatticeWitnessNullifier: 61, "61": "LatticeWitnessNullifier",
76
+ /**
77
+ * DualRing-LB (CCS 2021 Alg. 3 aggregated verify on Ajtai openings, `lib-q-ring-sig`).
78
+ */
79
+ LatticeDualRingLb: 62, "62": "LatticeDualRingLb",
80
+ /**
81
+ * ML-KEM-768 layered encapsulation with Saturnin AEAD per hop (mix-layer transport).
82
+ */
83
+ MixOnionRouting: 63, "63": "MixOnionRouting",
84
+ /**
85
+ * SHAKE256 session token and stateless retry-cookie derivation for resumption handshakes.
86
+ */
87
+ SessionResumptionBinding: 64, "64": "SessionResumptionBinding",
88
+ });
89
+ exports.Algorithm = Algorithm;
90
+
91
+ /**
92
+ * Algorithm categories
93
+ * @enum {0 | 1 | 2 | 3 | 4}
94
+ */
95
+ const AlgorithmCategory = Object.freeze({
96
+ Kem: 0, "0": "Kem",
97
+ Signature: 1, "1": "Signature",
98
+ Hash: 2, "2": "Hash",
99
+ Aead: 3, "3": "Aead",
100
+ /**
101
+ * Anonymous credentials, mix-layer transport helpers, and related ZKP-adjacent protocols.
102
+ */
103
+ PrivacyProtocol: 4, "4": "PrivacyProtocol",
104
+ });
105
+ exports.AlgorithmCategory = AlgorithmCategory;
106
+
107
+ /**
108
+ * WASM-compatible hash result
109
+ */
110
+ class HashResultWasm {
111
+ __destroy_into_raw() {
112
+ const ptr = this.__wbg_ptr;
113
+ this.__wbg_ptr = 0;
114
+ HashResultWasmFinalization.unregister(this);
115
+ return ptr;
116
+ }
117
+ free() {
118
+ const ptr = this.__destroy_into_raw();
119
+ wasm.__wbg_hashresultwasm_free(ptr, 0);
120
+ }
121
+ /**
122
+ * @returns {string}
123
+ */
124
+ get algorithm() {
125
+ let deferred1_0;
126
+ let deferred1_1;
127
+ try {
128
+ const ret = wasm.hashresultwasm_algorithm(this.__wbg_ptr);
129
+ deferred1_0 = ret[0];
130
+ deferred1_1 = ret[1];
131
+ return getStringFromWasm0(ret[0], ret[1]);
132
+ } finally {
133
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
134
+ }
135
+ }
136
+ /**
137
+ * @returns {Uint8Array}
138
+ */
139
+ get hash() {
140
+ const ret = wasm.hashresultwasm_hash(this.__wbg_ptr);
141
+ return ret;
142
+ }
143
+ /**
144
+ * @param {Uint8Array} hash
145
+ * @param {string} algorithm
146
+ */
147
+ constructor(hash, algorithm) {
148
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
149
+ const len0 = WASM_VECTOR_LEN;
150
+ const ret = wasm.hashresultwasm_new(hash, ptr0, len0);
151
+ this.__wbg_ptr = ret;
152
+ HashResultWasmFinalization.register(this, this.__wbg_ptr, this);
153
+ return this;
154
+ }
155
+ }
156
+ if (Symbol.dispose) HashResultWasm.prototype[Symbol.dispose] = HashResultWasm.prototype.free;
157
+ exports.HashResultWasm = HashResultWasm;
158
+
159
+ /**
160
+ * KEM keypair with automatic memory zeroization
161
+ */
162
+ class KemKeypair {
163
+ __destroy_into_raw() {
164
+ const ptr = this.__wbg_ptr;
165
+ this.__wbg_ptr = 0;
166
+ KemKeypairFinalization.unregister(this);
167
+ return ptr;
168
+ }
169
+ free() {
170
+ const ptr = this.__destroy_into_raw();
171
+ wasm.__wbg_kemkeypair_free(ptr, 0);
172
+ }
173
+ /**
174
+ * Create a new KEM keypair from bytes for WASM
175
+ * @param {Uint8Array} public_key
176
+ * @param {Uint8Array} secret_key
177
+ */
178
+ constructor(public_key, secret_key) {
179
+ const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
180
+ const len0 = WASM_VECTOR_LEN;
181
+ const ptr1 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
182
+ const len1 = WASM_VECTOR_LEN;
183
+ const ret = wasm.kemkeypair_new_wasm(ptr0, len0, ptr1, len1);
184
+ this.__wbg_ptr = ret;
185
+ KemKeypairFinalization.register(this, this.__wbg_ptr, this);
186
+ return this;
187
+ }
188
+ /**
189
+ * Get the public key as bytes for WASM
190
+ * @returns {Uint8Array}
191
+ */
192
+ public_key_bytes() {
193
+ const ret = wasm.kemkeypair_public_key_bytes(this.__wbg_ptr);
194
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
195
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
196
+ return v1;
197
+ }
198
+ /**
199
+ * Copy the secret key into a new `Uint8Array` for WASM (avoids returning an owned non-zeroizing `Vec<u8>`).
200
+ * @returns {Uint8Array}
201
+ */
202
+ secret_key_bytes() {
203
+ const ret = wasm.kemkeypair_secret_key_bytes(this.__wbg_ptr);
204
+ return ret;
205
+ }
206
+ }
207
+ if (Symbol.dispose) KemKeypair.prototype[Symbol.dispose] = KemKeypair.prototype.free;
208
+ exports.KemKeypair = KemKeypair;
209
+
210
+ /**
211
+ * KEM public key
212
+ */
213
+ class KemPublicKey {
214
+ __destroy_into_raw() {
215
+ const ptr = this.__wbg_ptr;
216
+ this.__wbg_ptr = 0;
217
+ KemPublicKeyFinalization.unregister(this);
218
+ return ptr;
219
+ }
220
+ free() {
221
+ const ptr = this.__destroy_into_raw();
222
+ wasm.__wbg_kempublickey_free(ptr, 0);
223
+ }
224
+ /**
225
+ * Get the key data as bytes for WASM
226
+ * @returns {Uint8Array}
227
+ */
228
+ bytes() {
229
+ const ret = wasm.kempublickey_bytes(this.__wbg_ptr);
230
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
231
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
232
+ return v1;
233
+ }
234
+ /**
235
+ * Create a new KEM public key from bytes for WASM
236
+ * @param {Uint8Array} data
237
+ */
238
+ constructor(data) {
239
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
240
+ const len0 = WASM_VECTOR_LEN;
241
+ const ret = wasm.kempublickey_new_from_bytes(ptr0, len0);
242
+ this.__wbg_ptr = ret;
243
+ KemPublicKeyFinalization.register(this, this.__wbg_ptr, this);
244
+ return this;
245
+ }
246
+ }
247
+ if (Symbol.dispose) KemPublicKey.prototype[Symbol.dispose] = KemPublicKey.prototype.free;
248
+ exports.KemPublicKey = KemPublicKey;
249
+
250
+ /**
251
+ * KEM secret key with automatic memory zeroization
252
+ */
253
+ class KemSecretKey {
254
+ __destroy_into_raw() {
255
+ const ptr = this.__wbg_ptr;
256
+ this.__wbg_ptr = 0;
257
+ KemSecretKeyFinalization.unregister(this);
258
+ return ptr;
259
+ }
260
+ free() {
261
+ const ptr = this.__destroy_into_raw();
262
+ wasm.__wbg_kemsecretkey_free(ptr, 0);
263
+ }
264
+ /**
265
+ * Copy the key material into a new `Uint8Array` for WASM (avoids returning an owned non-zeroizing `Vec<u8>`).
266
+ * @returns {Uint8Array}
267
+ */
268
+ bytes() {
269
+ const ret = wasm.kemsecretkey_bytes(this.__wbg_ptr);
270
+ return ret;
271
+ }
272
+ /**
273
+ * Create a new KEM secret key from bytes for WASM
274
+ * @param {Uint8Array} data
275
+ */
276
+ constructor(data) {
277
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
278
+ const len0 = WASM_VECTOR_LEN;
279
+ const ret = wasm.kemsecretkey_new_from_bytes(ptr0, len0);
280
+ this.__wbg_ptr = ret;
281
+ KemSecretKeyFinalization.register(this, this.__wbg_ptr, this);
282
+ return this;
283
+ }
284
+ }
285
+ if (Symbol.dispose) KemSecretKey.prototype[Symbol.dispose] = KemSecretKey.prototype.free;
286
+ exports.KemSecretKey = KemSecretKey;
287
+
288
+ /**
289
+ * CRYSTALS-ML-DSA signature implementation
290
+ *
291
+ * This implementation provides both high-level (std) and low-level (no_std) APIs
292
+ * following the lib-q architecture pattern for maximum flexibility.
293
+ */
294
+ class MlDsa {
295
+ __destroy_into_raw() {
296
+ const ptr = this.__wbg_ptr;
297
+ this.__wbg_ptr = 0;
298
+ MlDsaFinalization.unregister(this);
299
+ return ptr;
300
+ }
301
+ free() {
302
+ const ptr = this.__destroy_into_raw();
303
+ wasm.__wbg_mldsa_free(ptr, 0);
304
+ }
305
+ /**
306
+ * Generate a keypair for WASM (JavaScript) environment
307
+ *
308
+ * # Arguments
309
+ * * `randomness` - Optional randomness as Uint8Array
310
+ *
311
+ * # Returns
312
+ * * `Result<WasmMlDsaKeyPair, JsValue>` - The keypair or error
313
+ * @param {Uint8Array | null} [randomness]
314
+ * @returns {WasmMlDsaKeyPair}
315
+ */
316
+ generate_keypair_wasm(randomness) {
317
+ const ret = wasm.mldsa_generate_keypair_wasm(this.__wbg_ptr, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
318
+ if (ret[2]) {
319
+ throw takeFromExternrefTable0(ret[1]);
320
+ }
321
+ return WasmMlDsaKeyPair.__wrap(ret[0]);
322
+ }
323
+ /**
324
+ * Sign a message in WASM (JavaScript) environment
325
+ *
326
+ * # Arguments
327
+ * * `secret_key` - The secret key as Uint8Array
328
+ * * `message` - The message to sign as Uint8Array
329
+ * * `randomness` - Optional randomness as Uint8Array
330
+ *
331
+ * # Returns
332
+ * * `Result<Uint8Array, JsValue>` - The signature or error
333
+ * @param {Uint8Array} secret_key
334
+ * @param {Uint8Array} message
335
+ * @param {Uint8Array | null} [randomness]
336
+ * @returns {Uint8Array}
337
+ */
338
+ sign_wasm(secret_key, message, randomness) {
339
+ const ret = wasm.mldsa_sign_wasm(this.__wbg_ptr, secret_key, message, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
340
+ if (ret[2]) {
341
+ throw takeFromExternrefTable0(ret[1]);
342
+ }
343
+ return takeFromExternrefTable0(ret[0]);
344
+ }
345
+ /**
346
+ * Verify a signature in WASM (JavaScript) environment
347
+ *
348
+ * # Arguments
349
+ * * `public_key` - The public key as Uint8Array
350
+ * * `message` - The message as Uint8Array
351
+ * * `signature` - The signature to verify as Uint8Array
352
+ *
353
+ * # Returns
354
+ * * `Result<bool, JsValue>` - Verification result or error
355
+ * @param {Uint8Array} public_key
356
+ * @param {Uint8Array} message
357
+ * @param {Uint8Array} signature
358
+ * @returns {boolean}
359
+ */
360
+ verify_wasm(public_key, message, signature) {
361
+ const ret = wasm.mldsa_verify_wasm(this.__wbg_ptr, public_key, message, signature);
362
+ if (ret[2]) {
363
+ throw takeFromExternrefTable0(ret[1]);
364
+ }
365
+ return ret[0] !== 0;
366
+ }
367
+ }
368
+ if (Symbol.dispose) MlDsa.prototype[Symbol.dispose] = MlDsa.prototype.free;
369
+ exports.MlDsa = MlDsa;
370
+
371
+ /**
372
+ * Secure WASM AEAD Context
373
+ *
374
+ * This context provides secure AEAD operations with:
375
+ * - Consistent error handling using Result<T, JsValue>
376
+ * - Security validation for all inputs
377
+ * - Protection against timing attacks
378
+ * - Memory safety with automatic cleanup
379
+ */
380
+ class SecureWasmAeadContext {
381
+ __destroy_into_raw() {
382
+ const ptr = this.__wbg_ptr;
383
+ this.__wbg_ptr = 0;
384
+ SecureWasmAeadContextFinalization.unregister(this);
385
+ return ptr;
386
+ }
387
+ free() {
388
+ const ptr = this.__destroy_into_raw();
389
+ wasm.__wbg_securewasmaeadcontext_free(ptr, 0);
390
+ }
391
+ /**
392
+ * Decrypt data (Layer A `Result` ABI only; see [`crate::AeadDecryptSemantic`] for Layer B).
393
+ * @param {string} algorithm
394
+ * @param {Uint8Array} key
395
+ * @param {Uint8Array} nonce
396
+ * @param {Uint8Array} ciphertext
397
+ * @param {Uint8Array | null} [associated_data]
398
+ * @returns {any}
399
+ */
400
+ decrypt(algorithm, key, nonce, ciphertext, associated_data) {
401
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
402
+ const len0 = WASM_VECTOR_LEN;
403
+ const ret = wasm.securewasmaeadcontext_decrypt(this.__wbg_ptr, ptr0, len0, key, nonce, ciphertext, isLikeNone(associated_data) ? 0 : addToExternrefTable0(associated_data));
404
+ if (ret[2]) {
405
+ throw takeFromExternrefTable0(ret[1]);
406
+ }
407
+ return takeFromExternrefTable0(ret[0]);
408
+ }
409
+ /**
410
+ * Encrypt data
411
+ * @param {string} algorithm
412
+ * @param {Uint8Array} key
413
+ * @param {Uint8Array} nonce
414
+ * @param {Uint8Array} plaintext
415
+ * @param {Uint8Array | null} [associated_data]
416
+ * @returns {any}
417
+ */
418
+ encrypt(algorithm, key, nonce, plaintext, associated_data) {
419
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
420
+ const len0 = WASM_VECTOR_LEN;
421
+ const ret = wasm.securewasmaeadcontext_encrypt(this.__wbg_ptr, ptr0, len0, key, nonce, plaintext, isLikeNone(associated_data) ? 0 : addToExternrefTable0(associated_data));
422
+ if (ret[2]) {
423
+ throw takeFromExternrefTable0(ret[1]);
424
+ }
425
+ return takeFromExternrefTable0(ret[0]);
426
+ }
427
+ /**
428
+ * Get supported algorithms
429
+ * @returns {any}
430
+ */
431
+ get_supported_algorithms() {
432
+ const ret = wasm.securewasmaeadcontext_get_supported_algorithms(this.__wbg_ptr);
433
+ if (ret[2]) {
434
+ throw takeFromExternrefTable0(ret[1]);
435
+ }
436
+ return takeFromExternrefTable0(ret[0]);
437
+ }
438
+ /**
439
+ * Create a new secure WASM AEAD context
440
+ */
441
+ constructor() {
442
+ const ret = wasm.securewasmaeadcontext_new();
443
+ if (ret[2]) {
444
+ throw takeFromExternrefTable0(ret[1]);
445
+ }
446
+ this.__wbg_ptr = ret[0];
447
+ SecureWasmAeadContextFinalization.register(this, this.__wbg_ptr, this);
448
+ return this;
449
+ }
450
+ }
451
+ if (Symbol.dispose) SecureWasmAeadContext.prototype[Symbol.dispose] = SecureWasmAeadContext.prototype.free;
452
+ exports.SecureWasmAeadContext = SecureWasmAeadContext;
453
+
454
+ /**
455
+ * Secure WASM Hash Context
456
+ *
457
+ * This context provides secure hash operations with:
458
+ * - Consistent error handling using Result<T, JsValue>
459
+ * - Security validation for all inputs
460
+ * - Protection against timing attacks
461
+ * - Memory safety with automatic cleanup
462
+ */
463
+ class SecureWasmHashContext {
464
+ __destroy_into_raw() {
465
+ const ptr = this.__wbg_ptr;
466
+ this.__wbg_ptr = 0;
467
+ SecureWasmHashContextFinalization.unregister(this);
468
+ return ptr;
469
+ }
470
+ free() {
471
+ const ptr = this.__destroy_into_raw();
472
+ wasm.__wbg_securewasmhashcontext_free(ptr, 0);
473
+ }
474
+ /**
475
+ * Get supported algorithms
476
+ * @returns {any}
477
+ */
478
+ get_supported_algorithms() {
479
+ const ret = wasm.securewasmhashcontext_get_supported_algorithms(this.__wbg_ptr);
480
+ if (ret[2]) {
481
+ throw takeFromExternrefTable0(ret[1]);
482
+ }
483
+ return takeFromExternrefTable0(ret[0]);
484
+ }
485
+ /**
486
+ * Hash data
487
+ * @param {string} algorithm
488
+ * @param {Uint8Array} data
489
+ * @returns {any}
490
+ */
491
+ hash(algorithm, data) {
492
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
493
+ const len0 = WASM_VECTOR_LEN;
494
+ const ret = wasm.securewasmhashcontext_hash(this.__wbg_ptr, ptr0, len0, data);
495
+ if (ret[2]) {
496
+ throw takeFromExternrefTable0(ret[1]);
497
+ }
498
+ return takeFromExternrefTable0(ret[0]);
499
+ }
500
+ /**
501
+ * Create a new secure WASM hash context
502
+ */
503
+ constructor() {
504
+ const ret = wasm.securewasmhashcontext_new();
505
+ if (ret[2]) {
506
+ throw takeFromExternrefTable0(ret[1]);
507
+ }
508
+ this.__wbg_ptr = ret[0];
509
+ SecureWasmHashContextFinalization.register(this, this.__wbg_ptr, this);
510
+ return this;
511
+ }
512
+ }
513
+ if (Symbol.dispose) SecureWasmHashContext.prototype[Symbol.dispose] = SecureWasmHashContext.prototype.free;
514
+ exports.SecureWasmHashContext = SecureWasmHashContext;
515
+
516
+ /**
517
+ * Secure WASM KEM Context
518
+ *
519
+ * This context provides secure KEM operations with:
520
+ * - Consistent error handling using Result<T, JsValue>
521
+ * - Security validation for all inputs
522
+ * - Protection against timing attacks
523
+ * - Memory safety with automatic cleanup
524
+ */
525
+ class SecureWasmKemContext {
526
+ __destroy_into_raw() {
527
+ const ptr = this.__wbg_ptr;
528
+ this.__wbg_ptr = 0;
529
+ SecureWasmKemContextFinalization.unregister(this);
530
+ return ptr;
531
+ }
532
+ free() {
533
+ const ptr = this.__destroy_into_raw();
534
+ wasm.__wbg_securewasmkemcontext_free(ptr, 0);
535
+ }
536
+ /**
537
+ * Decapsulate a shared secret
538
+ * @param {string} algorithm
539
+ * @param {Uint8Array} private_key
540
+ * @param {Uint8Array} ciphertext
541
+ * @returns {any}
542
+ */
543
+ decapsulate(algorithm, private_key, ciphertext) {
544
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
545
+ const len0 = WASM_VECTOR_LEN;
546
+ const ret = wasm.securewasmkemcontext_decapsulate(this.__wbg_ptr, ptr0, len0, private_key, ciphertext);
547
+ if (ret[2]) {
548
+ throw takeFromExternrefTable0(ret[1]);
549
+ }
550
+ return takeFromExternrefTable0(ret[0]);
551
+ }
552
+ /**
553
+ * Encapsulate a shared secret
554
+ * @param {string} algorithm
555
+ * @param {Uint8Array} public_key
556
+ * @param {Uint8Array | null} [randomness]
557
+ * @returns {any}
558
+ */
559
+ encapsulate(algorithm, public_key, randomness) {
560
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
561
+ const len0 = WASM_VECTOR_LEN;
562
+ const ret = wasm.securewasmkemcontext_encapsulate(this.__wbg_ptr, ptr0, len0, public_key, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
563
+ if (ret[2]) {
564
+ throw takeFromExternrefTable0(ret[1]);
565
+ }
566
+ return takeFromExternrefTable0(ret[0]);
567
+ }
568
+ /**
569
+ * Generate a KEM keypair
570
+ * @param {string} algorithm
571
+ * @param {Uint8Array | null} [randomness]
572
+ * @returns {any}
573
+ */
574
+ generate_keypair(algorithm, randomness) {
575
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
576
+ const len0 = WASM_VECTOR_LEN;
577
+ const ret = wasm.securewasmkemcontext_generate_keypair(this.__wbg_ptr, ptr0, len0, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
578
+ if (ret[2]) {
579
+ throw takeFromExternrefTable0(ret[1]);
580
+ }
581
+ return takeFromExternrefTable0(ret[0]);
582
+ }
583
+ /**
584
+ * Get supported algorithms
585
+ * @returns {any}
586
+ */
587
+ get_supported_algorithms() {
588
+ const ret = wasm.securewasmkemcontext_get_supported_algorithms(this.__wbg_ptr);
589
+ if (ret[2]) {
590
+ throw takeFromExternrefTable0(ret[1]);
591
+ }
592
+ return takeFromExternrefTable0(ret[0]);
593
+ }
594
+ /**
595
+ * Create a new secure WASM KEM context
596
+ */
597
+ constructor() {
598
+ const ret = wasm.securewasmkemcontext_new();
599
+ if (ret[2]) {
600
+ throw takeFromExternrefTable0(ret[1]);
601
+ }
602
+ this.__wbg_ptr = ret[0];
603
+ SecureWasmKemContextFinalization.register(this, this.__wbg_ptr, this);
604
+ return this;
605
+ }
606
+ }
607
+ if (Symbol.dispose) SecureWasmKemContext.prototype[Symbol.dispose] = SecureWasmKemContext.prototype.free;
608
+ exports.SecureWasmKemContext = SecureWasmKemContext;
609
+
610
+ /**
611
+ * Secure WASM Signature Context
612
+ *
613
+ * This context provides secure signature operations with:
614
+ * - Consistent error handling using Result<T, JsValue>
615
+ * - Security validation for all inputs
616
+ * - Protection against timing attacks
617
+ * - Memory safety with automatic cleanup
618
+ */
619
+ class SecureWasmSignatureContext {
620
+ __destroy_into_raw() {
621
+ const ptr = this.__wbg_ptr;
622
+ this.__wbg_ptr = 0;
623
+ SecureWasmSignatureContextFinalization.unregister(this);
624
+ return ptr;
625
+ }
626
+ free() {
627
+ const ptr = this.__destroy_into_raw();
628
+ wasm.__wbg_securewasmsignaturecontext_free(ptr, 0);
629
+ }
630
+ /**
631
+ * Generate a signature keypair
632
+ * @param {string} algorithm
633
+ * @param {Uint8Array | null} [randomness]
634
+ * @returns {any}
635
+ */
636
+ generate_keypair(algorithm, randomness) {
637
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
638
+ const len0 = WASM_VECTOR_LEN;
639
+ const ret = wasm.securewasmsignaturecontext_generate_keypair(this.__wbg_ptr, ptr0, len0, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
640
+ if (ret[2]) {
641
+ throw takeFromExternrefTable0(ret[1]);
642
+ }
643
+ return takeFromExternrefTable0(ret[0]);
644
+ }
645
+ /**
646
+ * Get supported algorithms
647
+ * @returns {any}
648
+ */
649
+ get_supported_algorithms() {
650
+ const ret = wasm.securewasmsignaturecontext_get_supported_algorithms(this.__wbg_ptr);
651
+ if (ret[2]) {
652
+ throw takeFromExternrefTable0(ret[1]);
653
+ }
654
+ return takeFromExternrefTable0(ret[0]);
655
+ }
656
+ /**
657
+ * Create a new secure WASM signature context
658
+ */
659
+ constructor() {
660
+ const ret = wasm.securewasmsignaturecontext_new();
661
+ if (ret[2]) {
662
+ throw takeFromExternrefTable0(ret[1]);
663
+ }
664
+ this.__wbg_ptr = ret[0];
665
+ SecureWasmSignatureContextFinalization.register(this, this.__wbg_ptr, this);
666
+ return this;
667
+ }
668
+ /**
669
+ * Sign a message
670
+ * @param {string} algorithm
671
+ * @param {Uint8Array} private_key
672
+ * @param {Uint8Array} message
673
+ * @param {Uint8Array | null} [randomness]
674
+ * @returns {any}
675
+ */
676
+ sign(algorithm, private_key, message, randomness) {
677
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
678
+ const len0 = WASM_VECTOR_LEN;
679
+ const ret = wasm.securewasmsignaturecontext_sign(this.__wbg_ptr, ptr0, len0, private_key, message, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
680
+ if (ret[2]) {
681
+ throw takeFromExternrefTable0(ret[1]);
682
+ }
683
+ return takeFromExternrefTable0(ret[0]);
684
+ }
685
+ /**
686
+ * Verify a signature
687
+ * @param {string} algorithm
688
+ * @param {Uint8Array} public_key
689
+ * @param {Uint8Array} message
690
+ * @param {Uint8Array} signature
691
+ * @returns {any}
692
+ */
693
+ verify(algorithm, public_key, message, signature) {
694
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
695
+ const len0 = WASM_VECTOR_LEN;
696
+ const ret = wasm.securewasmsignaturecontext_verify(this.__wbg_ptr, ptr0, len0, public_key, message, signature);
697
+ if (ret[2]) {
698
+ throw takeFromExternrefTable0(ret[1]);
699
+ }
700
+ return takeFromExternrefTable0(ret[0]);
701
+ }
702
+ }
703
+ if (Symbol.dispose) SecureWasmSignatureContext.prototype[Symbol.dispose] = SecureWasmSignatureContext.prototype.free;
704
+ exports.SecureWasmSignatureContext = SecureWasmSignatureContext;
705
+
706
+ /**
707
+ * Security levels for cryptographic algorithms
708
+ * @enum {1 | 3 | 4 | 5}
709
+ */
710
+ const SecurityLevel = Object.freeze({
711
+ Level1: 1, "1": "Level1",
712
+ Level3: 3, "3": "Level3",
713
+ Level4: 4, "4": "Level4",
714
+ Level5: 5, "5": "Level5",
715
+ });
716
+ exports.SecurityLevel = SecurityLevel;
717
+
718
+ /**
719
+ * Signature keypair with automatic memory zeroization
720
+ */
721
+ class SigKeypair {
722
+ __destroy_into_raw() {
723
+ const ptr = this.__wbg_ptr;
724
+ this.__wbg_ptr = 0;
725
+ SigKeypairFinalization.unregister(this);
726
+ return ptr;
727
+ }
728
+ free() {
729
+ const ptr = this.__destroy_into_raw();
730
+ wasm.__wbg_sigkeypair_free(ptr, 0);
731
+ }
732
+ }
733
+ if (Symbol.dispose) SigKeypair.prototype[Symbol.dispose] = SigKeypair.prototype.free;
734
+ exports.SigKeypair = SigKeypair;
735
+
736
+ /**
737
+ * Signature public key
738
+ */
739
+ class SigPublicKey {
740
+ __destroy_into_raw() {
741
+ const ptr = this.__wbg_ptr;
742
+ this.__wbg_ptr = 0;
743
+ SigPublicKeyFinalization.unregister(this);
744
+ return ptr;
745
+ }
746
+ free() {
747
+ const ptr = this.__destroy_into_raw();
748
+ wasm.__wbg_sigpublickey_free(ptr, 0);
749
+ }
750
+ }
751
+ if (Symbol.dispose) SigPublicKey.prototype[Symbol.dispose] = SigPublicKey.prototype.free;
752
+ exports.SigPublicKey = SigPublicKey;
753
+
754
+ /**
755
+ * Signature secret key with automatic memory zeroization
756
+ */
757
+ class SigSecretKey {
758
+ __destroy_into_raw() {
759
+ const ptr = this.__wbg_ptr;
760
+ this.__wbg_ptr = 0;
761
+ SigSecretKeyFinalization.unregister(this);
762
+ return ptr;
763
+ }
764
+ free() {
765
+ const ptr = this.__destroy_into_raw();
766
+ wasm.__wbg_sigsecretkey_free(ptr, 0);
767
+ }
768
+ }
769
+ if (Symbol.dispose) SigSecretKey.prototype[Symbol.dispose] = SigSecretKey.prototype.free;
770
+ exports.SigSecretKey = SigSecretKey;
771
+
772
+ /**
773
+ * SLH-DSA signature implementation wrapper
774
+ *
775
+ * This struct provides the lib-Q Signature trait implementation for SLH-DSA,
776
+ * routing operations to the appropriate parameter set based on the algorithm.
777
+ */
778
+ class SlhDsa {
779
+ __destroy_into_raw() {
780
+ const ptr = this.__wbg_ptr;
781
+ this.__wbg_ptr = 0;
782
+ SlhDsaFinalization.unregister(this);
783
+ return ptr;
784
+ }
785
+ free() {
786
+ const ptr = this.__destroy_into_raw();
787
+ wasm.__wbg_slhdsa_free(ptr, 0);
788
+ }
789
+ /**
790
+ * Generate a keypair for WASM (JavaScript) environment
791
+ *
792
+ * # Arguments
793
+ * * `algorithm` - The algorithm name as a string
794
+ * * `randomness` - Optional randomness as Uint8Array
795
+ *
796
+ * # Returns
797
+ * * `Result<WasmSlhDsaKeyPair, JsValue>` - The keypair or error
798
+ * @param {string} algorithm
799
+ * @param {Uint8Array | null} [randomness]
800
+ * @returns {WasmSlhDsaKeyPair}
801
+ */
802
+ generate_keypair_wasm(algorithm, randomness) {
803
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
804
+ const len0 = WASM_VECTOR_LEN;
805
+ const ret = wasm.slhdsa_generate_keypair_wasm(this.__wbg_ptr, ptr0, len0, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
806
+ if (ret[2]) {
807
+ throw takeFromExternrefTable0(ret[1]);
808
+ }
809
+ return WasmSlhDsaKeyPair.__wrap(ret[0]);
810
+ }
811
+ /**
812
+ * Sign a message in WASM (JavaScript) environment
813
+ *
814
+ * # Arguments
815
+ * * `algorithm` - The algorithm name as a string
816
+ * * `secret_key` - The secret key as Uint8Array
817
+ * * `message` - The message to sign as Uint8Array
818
+ * * `randomness` - Optional randomness as Uint8Array
819
+ *
820
+ * # Returns
821
+ * * `Result<Uint8Array, JsValue>` - The signature or error
822
+ * @param {string} algorithm
823
+ * @param {Uint8Array} secret_key
824
+ * @param {Uint8Array} message
825
+ * @param {Uint8Array | null} [randomness]
826
+ * @returns {Uint8Array}
827
+ */
828
+ sign_wasm(algorithm, secret_key, message, randomness) {
829
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
830
+ const len0 = WASM_VECTOR_LEN;
831
+ const ret = wasm.slhdsa_sign_wasm(this.__wbg_ptr, ptr0, len0, secret_key, message, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
832
+ if (ret[2]) {
833
+ throw takeFromExternrefTable0(ret[1]);
834
+ }
835
+ return takeFromExternrefTable0(ret[0]);
836
+ }
837
+ /**
838
+ * Verify a signature in WASM (JavaScript) environment
839
+ *
840
+ * # Arguments
841
+ * * `algorithm` - The algorithm name as a string
842
+ * * `public_key` - The public key as Uint8Array
843
+ * * `message` - The message as Uint8Array
844
+ * * `signature` - The signature to verify as Uint8Array
845
+ *
846
+ * # Returns
847
+ * * `Result<bool, JsValue>` - Verification result or error
848
+ * @param {string} algorithm
849
+ * @param {Uint8Array} public_key
850
+ * @param {Uint8Array} message
851
+ * @param {Uint8Array} signature
852
+ * @returns {boolean}
853
+ */
854
+ verify_wasm(algorithm, public_key, message, signature) {
855
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
856
+ const len0 = WASM_VECTOR_LEN;
857
+ const ret = wasm.slhdsa_verify_wasm(this.__wbg_ptr, ptr0, len0, public_key, message, signature);
858
+ if (ret[2]) {
859
+ throw takeFromExternrefTable0(ret[1]);
860
+ }
861
+ return ret[0] !== 0;
862
+ }
863
+ }
864
+ if (Symbol.dispose) SlhDsa.prototype[Symbol.dispose] = SlhDsa.prototype.free;
865
+ exports.SlhDsa = SlhDsa;
866
+
867
+ /**
868
+ * WASM-compatible AEAD context wrapper
869
+ *
870
+ * This wrapper provides JavaScript-compatible bindings for AEAD operations:
871
+ * - Integrates with the new modular architecture
872
+ * - Includes security validation
873
+ * - Provides consistent error handling
874
+ * - Supports all AEAD algorithms
875
+ */
876
+ class WasmAeadContext {
877
+ static __wrap(ptr) {
878
+ const obj = Object.create(WasmAeadContext.prototype);
879
+ obj.__wbg_ptr = ptr;
880
+ WasmAeadContextFinalization.register(obj, obj.__wbg_ptr, obj);
881
+ return obj;
882
+ }
883
+ __destroy_into_raw() {
884
+ const ptr = this.__wbg_ptr;
885
+ this.__wbg_ptr = 0;
886
+ WasmAeadContextFinalization.unregister(this);
887
+ return ptr;
888
+ }
889
+ free() {
890
+ const ptr = this.__destroy_into_raw();
891
+ wasm.__wbg_wasmaeadcontext_free(ptr, 0);
892
+ }
893
+ }
894
+ if (Symbol.dispose) WasmAeadContext.prototype[Symbol.dispose] = WasmAeadContext.prototype.free;
895
+ exports.WasmAeadContext = WasmAeadContext;
896
+
897
+ /**
898
+ * WASM-compatible CryptoProvider wrapper
899
+ *
900
+ * This wrapper provides JavaScript-compatible bindings for the crypto provider:
901
+ * - Integrates with the new modular architecture
902
+ * - Provides consistent error handling
903
+ * - Supports all cryptographic operations
904
+ */
905
+ class WasmCryptoProvider {
906
+ __destroy_into_raw() {
907
+ const ptr = this.__wbg_ptr;
908
+ this.__wbg_ptr = 0;
909
+ WasmCryptoProviderFinalization.unregister(this);
910
+ return ptr;
911
+ }
912
+ free() {
913
+ const ptr = this.__destroy_into_raw();
914
+ wasm.__wbg_wasmcryptoprovider_free(ptr, 0);
915
+ }
916
+ }
917
+ if (Symbol.dispose) WasmCryptoProvider.prototype[Symbol.dispose] = WasmCryptoProvider.prototype.free;
918
+ exports.WasmCryptoProvider = WasmCryptoProvider;
919
+
920
+ /**
921
+ * WASM-compatible Hash context wrapper
922
+ *
923
+ * This wrapper provides JavaScript-compatible bindings for hash operations:
924
+ * - Integrates with the new modular architecture
925
+ * - Includes security validation
926
+ * - Provides consistent error handling
927
+ * - Supports all hash algorithms
928
+ */
929
+ class WasmHashContext {
930
+ static __wrap(ptr) {
931
+ const obj = Object.create(WasmHashContext.prototype);
932
+ obj.__wbg_ptr = ptr;
933
+ WasmHashContextFinalization.register(obj, obj.__wbg_ptr, obj);
934
+ return obj;
935
+ }
936
+ __destroy_into_raw() {
937
+ const ptr = this.__wbg_ptr;
938
+ this.__wbg_ptr = 0;
939
+ WasmHashContextFinalization.unregister(this);
940
+ return ptr;
941
+ }
942
+ free() {
943
+ const ptr = this.__destroy_into_raw();
944
+ wasm.__wbg_wasmhashcontext_free(ptr, 0);
945
+ }
946
+ }
947
+ if (Symbol.dispose) WasmHashContext.prototype[Symbol.dispose] = WasmHashContext.prototype.free;
948
+ exports.WasmHashContext = WasmHashContext;
949
+
950
+ /**
951
+ * WASM-compatible KEM context wrapper
952
+ *
953
+ * This wrapper provides JavaScript-compatible bindings for KEM operations:
954
+ * - Integrates with the new modular architecture
955
+ * - Includes security validation
956
+ * - Provides consistent error handling
957
+ * - Supports all KEM algorithms
958
+ */
959
+ class WasmKemContext {
960
+ static __wrap(ptr) {
961
+ const obj = Object.create(WasmKemContext.prototype);
962
+ obj.__wbg_ptr = ptr;
963
+ WasmKemContextFinalization.register(obj, obj.__wbg_ptr, obj);
964
+ return obj;
965
+ }
966
+ __destroy_into_raw() {
967
+ const ptr = this.__wbg_ptr;
968
+ this.__wbg_ptr = 0;
969
+ WasmKemContextFinalization.unregister(this);
970
+ return ptr;
971
+ }
972
+ free() {
973
+ const ptr = this.__destroy_into_raw();
974
+ wasm.__wbg_wasmkemcontext_free(ptr, 0);
975
+ }
976
+ }
977
+ if (Symbol.dispose) WasmKemContext.prototype[Symbol.dispose] = WasmKemContext.prototype.free;
978
+ exports.WasmKemContext = WasmKemContext;
979
+
980
+ /**
981
+ * Generic WASM key pair implementation
982
+ */
983
+ class WasmKeyPairImpl {
984
+ __destroy_into_raw() {
985
+ const ptr = this.__wbg_ptr;
986
+ this.__wbg_ptr = 0;
987
+ WasmKeyPairImplFinalization.unregister(this);
988
+ return ptr;
989
+ }
990
+ free() {
991
+ const ptr = this.__destroy_into_raw();
992
+ wasm.__wbg_wasmkeypairimpl_free(ptr, 0);
993
+ }
994
+ /**
995
+ * @param {Uint8Array} public_key
996
+ * @param {Uint8Array} secret_key
997
+ */
998
+ constructor(public_key, secret_key) {
999
+ const ret = wasm.wasmkeypairimpl_new(public_key, secret_key);
1000
+ this.__wbg_ptr = ret;
1001
+ WasmKeyPairImplFinalization.register(this, this.__wbg_ptr, this);
1002
+ return this;
1003
+ }
1004
+ /**
1005
+ * @returns {Uint8Array}
1006
+ */
1007
+ get public_key() {
1008
+ const ret = wasm.wasmkeypairimpl_public_key(this.__wbg_ptr);
1009
+ return ret;
1010
+ }
1011
+ /**
1012
+ * @returns {Uint8Array}
1013
+ */
1014
+ get secret_key() {
1015
+ const ret = wasm.wasmkeypairimpl_secret_key(this.__wbg_ptr);
1016
+ return ret;
1017
+ }
1018
+ }
1019
+ if (Symbol.dispose) WasmKeyPairImpl.prototype[Symbol.dispose] = WasmKeyPairImpl.prototype.free;
1020
+ exports.WasmKeyPairImpl = WasmKeyPairImpl;
1021
+
1022
+ /**
1023
+ * WASM-compatible ML-DSA key pair
1024
+ */
1025
+ class WasmMlDsaKeyPair {
1026
+ static __wrap(ptr) {
1027
+ const obj = Object.create(WasmMlDsaKeyPair.prototype);
1028
+ obj.__wbg_ptr = ptr;
1029
+ WasmMlDsaKeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
1030
+ return obj;
1031
+ }
1032
+ __destroy_into_raw() {
1033
+ const ptr = this.__wbg_ptr;
1034
+ this.__wbg_ptr = 0;
1035
+ WasmMlDsaKeyPairFinalization.unregister(this);
1036
+ return ptr;
1037
+ }
1038
+ free() {
1039
+ const ptr = this.__destroy_into_raw();
1040
+ wasm.__wbg_wasmmldsakeypair_free(ptr, 0);
1041
+ }
1042
+ /**
1043
+ * @param {Uint8Array} public_key
1044
+ * @param {Uint8Array} secret_key
1045
+ */
1046
+ constructor(public_key, secret_key) {
1047
+ const ret = wasm.wasmmldsakeypair_new(public_key, secret_key);
1048
+ this.__wbg_ptr = ret;
1049
+ WasmMlDsaKeyPairFinalization.register(this, this.__wbg_ptr, this);
1050
+ return this;
1051
+ }
1052
+ /**
1053
+ * @returns {Uint8Array}
1054
+ */
1055
+ get public_key() {
1056
+ const ret = wasm.wasmmldsakeypair_public_key(this.__wbg_ptr);
1057
+ return ret;
1058
+ }
1059
+ /**
1060
+ * @returns {Uint8Array}
1061
+ */
1062
+ get secret_key() {
1063
+ const ret = wasm.wasmmldsakeypair_secret_key(this.__wbg_ptr);
1064
+ return ret;
1065
+ }
1066
+ }
1067
+ if (Symbol.dispose) WasmMlDsaKeyPair.prototype[Symbol.dispose] = WasmMlDsaKeyPair.prototype.free;
1068
+ exports.WasmMlDsaKeyPair = WasmMlDsaKeyPair;
1069
+
1070
+ /**
1071
+ * WASM-compatible provider factory
1072
+ *
1073
+ * This factory provides JavaScript-compatible bindings for creating providers:
1074
+ * - Integrates with the new modular architecture
1075
+ * - Provides consistent error handling
1076
+ * - Supports all provider creation operations
1077
+ */
1078
+ class WasmProviderFactory {
1079
+ __destroy_into_raw() {
1080
+ const ptr = this.__wbg_ptr;
1081
+ this.__wbg_ptr = 0;
1082
+ WasmProviderFactoryFinalization.unregister(this);
1083
+ return ptr;
1084
+ }
1085
+ free() {
1086
+ const ptr = this.__destroy_into_raw();
1087
+ wasm.__wbg_wasmproviderfactory_free(ptr, 0);
1088
+ }
1089
+ /**
1090
+ * Create a new provider manager
1091
+ * @returns {WasmProviderManager}
1092
+ */
1093
+ static create_provider_manager() {
1094
+ const ret = wasm.wasmproviderfactory_create_provider_manager();
1095
+ return WasmProviderManager.__wrap(ret);
1096
+ }
1097
+ /**
1098
+ * Create a provider manager with specific configuration
1099
+ * @param {string} config
1100
+ * @returns {WasmProviderManager}
1101
+ */
1102
+ static create_provider_manager_with_config(config) {
1103
+ const ptr0 = passStringToWasm0(config, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1104
+ const len0 = WASM_VECTOR_LEN;
1105
+ const ret = wasm.wasmproviderfactory_create_provider_manager_with_config(ptr0, len0);
1106
+ if (ret[2]) {
1107
+ throw takeFromExternrefTable0(ret[1]);
1108
+ }
1109
+ return WasmProviderManager.__wrap(ret[0]);
1110
+ }
1111
+ /**
1112
+ * Get available provider types
1113
+ * @returns {string}
1114
+ */
1115
+ static get_available_providers() {
1116
+ let deferred1_0;
1117
+ let deferred1_1;
1118
+ try {
1119
+ const ret = wasm.wasmproviderfactory_get_available_providers();
1120
+ deferred1_0 = ret[0];
1121
+ deferred1_1 = ret[1];
1122
+ return getStringFromWasm0(ret[0], ret[1]);
1123
+ } finally {
1124
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1125
+ }
1126
+ }
1127
+ /**
1128
+ * Validate provider configuration
1129
+ * @param {string} config
1130
+ * @returns {boolean}
1131
+ */
1132
+ static validate_provider_config(config) {
1133
+ const ptr0 = passStringToWasm0(config, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1134
+ const len0 = WASM_VECTOR_LEN;
1135
+ const ret = wasm.wasmproviderfactory_validate_provider_config(ptr0, len0);
1136
+ if (ret[2]) {
1137
+ throw takeFromExternrefTable0(ret[1]);
1138
+ }
1139
+ return ret[0] !== 0;
1140
+ }
1141
+ }
1142
+ if (Symbol.dispose) WasmProviderFactory.prototype[Symbol.dispose] = WasmProviderFactory.prototype.free;
1143
+ exports.WasmProviderFactory = WasmProviderFactory;
1144
+
1145
+ /**
1146
+ * WASM-compatible provider manager
1147
+ *
1148
+ * This manager provides JavaScript-compatible bindings for provider operations:
1149
+ * - Integrates with the new modular architecture
1150
+ * - Includes security validation
1151
+ * - Provides consistent error handling
1152
+ * - Supports all provider operations
1153
+ */
1154
+ class WasmProviderManager {
1155
+ static __wrap(ptr) {
1156
+ const obj = Object.create(WasmProviderManager.prototype);
1157
+ obj.__wbg_ptr = ptr;
1158
+ WasmProviderManagerFinalization.register(obj, obj.__wbg_ptr, obj);
1159
+ return obj;
1160
+ }
1161
+ __destroy_into_raw() {
1162
+ const ptr = this.__wbg_ptr;
1163
+ this.__wbg_ptr = 0;
1164
+ WasmProviderManagerFinalization.unregister(this);
1165
+ return ptr;
1166
+ }
1167
+ free() {
1168
+ const ptr = this.__destroy_into_raw();
1169
+ wasm.__wbg_wasmprovidermanager_free(ptr, 0);
1170
+ }
1171
+ }
1172
+ if (Symbol.dispose) WasmProviderManager.prototype[Symbol.dispose] = WasmProviderManager.prototype.free;
1173
+ exports.WasmProviderManager = WasmProviderManager;
1174
+
1175
+ /**
1176
+ * WASM-compatible Signature context wrapper
1177
+ *
1178
+ * This wrapper provides JavaScript-compatible bindings for signature operations:
1179
+ * - Integrates with the new modular architecture
1180
+ * - Includes security validation
1181
+ * - Provides consistent error handling
1182
+ * - Supports all signature algorithms
1183
+ */
1184
+ class WasmSignatureContext {
1185
+ static __wrap(ptr) {
1186
+ const obj = Object.create(WasmSignatureContext.prototype);
1187
+ obj.__wbg_ptr = ptr;
1188
+ WasmSignatureContextFinalization.register(obj, obj.__wbg_ptr, obj);
1189
+ return obj;
1190
+ }
1191
+ __destroy_into_raw() {
1192
+ const ptr = this.__wbg_ptr;
1193
+ this.__wbg_ptr = 0;
1194
+ WasmSignatureContextFinalization.unregister(this);
1195
+ return ptr;
1196
+ }
1197
+ free() {
1198
+ const ptr = this.__destroy_into_raw();
1199
+ wasm.__wbg_wasmsignaturecontext_free(ptr, 0);
1200
+ }
1201
+ /**
1202
+ * Generate a keypair for the specified algorithm
1203
+ * @param {string} algorithm
1204
+ * @param {Uint8Array | null} [randomness]
1205
+ * @returns {any}
1206
+ */
1207
+ generate_keypair(algorithm, randomness) {
1208
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1209
+ const len0 = WASM_VECTOR_LEN;
1210
+ const ret = wasm.wasmsignaturecontext_generate_keypair(this.__wbg_ptr, ptr0, len0, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
1211
+ if (ret[2]) {
1212
+ throw takeFromExternrefTable0(ret[1]);
1213
+ }
1214
+ return takeFromExternrefTable0(ret[0]);
1215
+ }
1216
+ /**
1217
+ * Check if an algorithm is supported
1218
+ * @param {string} algorithm
1219
+ * @returns {boolean}
1220
+ */
1221
+ is_algorithm_supported(algorithm) {
1222
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1223
+ const len0 = WASM_VECTOR_LEN;
1224
+ const ret = wasm.wasmsignaturecontext_is_algorithm_supported(this.__wbg_ptr, ptr0, len0);
1225
+ return ret !== 0;
1226
+ }
1227
+ /**
1228
+ * Get the security level of the context
1229
+ * @returns {number}
1230
+ */
1231
+ security_level() {
1232
+ const ret = wasm.wasmsignaturecontext_security_level(this.__wbg_ptr);
1233
+ return ret >>> 0;
1234
+ }
1235
+ /**
1236
+ * Sign a message using the given secret key
1237
+ * @param {string} algorithm
1238
+ * @param {Uint8Array} secret_key_data
1239
+ * @param {Uint8Array} message
1240
+ * @param {Uint8Array | null} [randomness]
1241
+ * @returns {Uint8Array}
1242
+ */
1243
+ sign(algorithm, secret_key_data, message, randomness) {
1244
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1245
+ const len0 = WASM_VECTOR_LEN;
1246
+ const ret = wasm.wasmsignaturecontext_sign(this.__wbg_ptr, ptr0, len0, secret_key_data, message, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
1247
+ if (ret[3]) {
1248
+ throw takeFromExternrefTable0(ret[2]);
1249
+ }
1250
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1251
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1252
+ return v2;
1253
+ }
1254
+ /**
1255
+ * Get supported algorithms
1256
+ * @returns {string}
1257
+ */
1258
+ supported_algorithms() {
1259
+ let deferred1_0;
1260
+ let deferred1_1;
1261
+ try {
1262
+ const ret = wasm.wasmsignaturecontext_supported_algorithms(this.__wbg_ptr);
1263
+ deferred1_0 = ret[0];
1264
+ deferred1_1 = ret[1];
1265
+ return getStringFromWasm0(ret[0], ret[1]);
1266
+ } finally {
1267
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1268
+ }
1269
+ }
1270
+ /**
1271
+ * Verify a signature using the given public key
1272
+ * @param {string} algorithm
1273
+ * @param {Uint8Array} public_key_data
1274
+ * @param {Uint8Array} message
1275
+ * @param {Uint8Array} signature
1276
+ * @returns {boolean}
1277
+ */
1278
+ verify(algorithm, public_key_data, message, signature) {
1279
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1280
+ const len0 = WASM_VECTOR_LEN;
1281
+ const ret = wasm.wasmsignaturecontext_verify(this.__wbg_ptr, ptr0, len0, public_key_data, message, signature);
1282
+ if (ret[2]) {
1283
+ throw takeFromExternrefTable0(ret[1]);
1284
+ }
1285
+ return ret[0] !== 0;
1286
+ }
1287
+ }
1288
+ if (Symbol.dispose) WasmSignatureContext.prototype[Symbol.dispose] = WasmSignatureContext.prototype.free;
1289
+ exports.WasmSignatureContext = WasmSignatureContext;
1290
+
1291
+ /**
1292
+ * WASM-compatible SLH-DSA key pair
1293
+ */
1294
+ class WasmSlhDsaKeyPair {
1295
+ static __wrap(ptr) {
1296
+ const obj = Object.create(WasmSlhDsaKeyPair.prototype);
1297
+ obj.__wbg_ptr = ptr;
1298
+ WasmSlhDsaKeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
1299
+ return obj;
1300
+ }
1301
+ __destroy_into_raw() {
1302
+ const ptr = this.__wbg_ptr;
1303
+ this.__wbg_ptr = 0;
1304
+ WasmSlhDsaKeyPairFinalization.unregister(this);
1305
+ return ptr;
1306
+ }
1307
+ free() {
1308
+ const ptr = this.__destroy_into_raw();
1309
+ wasm.__wbg_wasmslhdsakeypair_free(ptr, 0);
1310
+ }
1311
+ /**
1312
+ * @param {Uint8Array} public_key
1313
+ * @param {Uint8Array} secret_key
1314
+ */
1315
+ constructor(public_key, secret_key) {
1316
+ const ret = wasm.wasmslhdsakeypair_new(public_key, secret_key);
1317
+ this.__wbg_ptr = ret;
1318
+ WasmSlhDsaKeyPairFinalization.register(this, this.__wbg_ptr, this);
1319
+ return this;
1320
+ }
1321
+ /**
1322
+ * @returns {Uint8Array}
1323
+ */
1324
+ get public_key() {
1325
+ const ret = wasm.wasmslhdsakeypair_public_key(this.__wbg_ptr);
1326
+ return ret;
1327
+ }
1328
+ /**
1329
+ * @returns {Uint8Array}
1330
+ */
1331
+ get secret_key() {
1332
+ const ret = wasm.wasmslhdsakeypair_secret_key(this.__wbg_ptr);
1333
+ return ret;
1334
+ }
1335
+ }
1336
+ if (Symbol.dispose) WasmSlhDsaKeyPair.prototype[Symbol.dispose] = WasmSlhDsaKeyPair.prototype.free;
1337
+ exports.WasmSlhDsaKeyPair = WasmSlhDsaKeyPair;
1338
+
1339
+ /**
1340
+ * Array of AEAD algorithm names available in this build (native JS array of strings).
1341
+ * @returns {any}
1342
+ */
1343
+ function aead_available_algorithms() {
1344
+ const ret = wasm.aead_available_algorithms();
1345
+ if (ret[2]) {
1346
+ throw takeFromExternrefTable0(ret[1]);
1347
+ }
1348
+ return takeFromExternrefTable0(ret[0]);
1349
+ }
1350
+ exports.aead_available_algorithms = aead_available_algorithms;
1351
+
1352
+ /**
1353
+ * AEAD decrypt (same `algorithm` names as [`aead_encrypt`]).
1354
+ * @param {string} algorithm
1355
+ * @param {Uint8Array} key
1356
+ * @param {Uint8Array} nonce
1357
+ * @param {Uint8Array} ciphertext
1358
+ * @param {Uint8Array} associated_data
1359
+ * @returns {Uint8Array}
1360
+ */
1361
+ function aead_decrypt(algorithm, key, nonce, ciphertext, associated_data) {
1362
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1363
+ const len0 = WASM_VECTOR_LEN;
1364
+ const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
1365
+ const len1 = WASM_VECTOR_LEN;
1366
+ const ptr2 = passArray8ToWasm0(nonce, wasm.__wbindgen_malloc);
1367
+ const len2 = WASM_VECTOR_LEN;
1368
+ const ptr3 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);
1369
+ const len3 = WASM_VECTOR_LEN;
1370
+ const ptr4 = passArray8ToWasm0(associated_data, wasm.__wbindgen_malloc);
1371
+ const len4 = WASM_VECTOR_LEN;
1372
+ const ret = wasm.aead_decrypt(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
1373
+ if (ret[3]) {
1374
+ throw takeFromExternrefTable0(ret[2]);
1375
+ }
1376
+ var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1377
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1378
+ return v6;
1379
+ }
1380
+ exports.aead_decrypt = aead_decrypt;
1381
+
1382
+ /**
1383
+ * AEAD encrypt: `algorithm` is `Saturnin`, `DuplexSpongeAead`, or `RomulusN`.
1384
+ * @param {string} algorithm
1385
+ * @param {Uint8Array} key
1386
+ * @param {Uint8Array} nonce
1387
+ * @param {Uint8Array} plaintext
1388
+ * @param {Uint8Array} associated_data
1389
+ * @returns {Uint8Array}
1390
+ */
1391
+ function aead_encrypt(algorithm, key, nonce, plaintext, associated_data) {
1392
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1393
+ const len0 = WASM_VECTOR_LEN;
1394
+ const ptr1 = passArray8ToWasm0(key, wasm.__wbindgen_malloc);
1395
+ const len1 = WASM_VECTOR_LEN;
1396
+ const ptr2 = passArray8ToWasm0(nonce, wasm.__wbindgen_malloc);
1397
+ const len2 = WASM_VECTOR_LEN;
1398
+ const ptr3 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc);
1399
+ const len3 = WASM_VECTOR_LEN;
1400
+ const ptr4 = passArray8ToWasm0(associated_data, wasm.__wbindgen_malloc);
1401
+ const len4 = WASM_VECTOR_LEN;
1402
+ const ret = wasm.aead_encrypt(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
1403
+ if (ret[3]) {
1404
+ throw takeFromExternrefTable0(ret[2]);
1405
+ }
1406
+ var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1407
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1408
+ return v6;
1409
+ }
1410
+ exports.aead_encrypt = aead_encrypt;
1411
+
1412
+ /**
1413
+ * Convert bytes to hexadecimal string
1414
+ *
1415
+ * This function provides secure hex encoding for WASM:
1416
+ * - Uses constant-time operations where possible
1417
+ * - Handles large data efficiently
1418
+ * - Returns JavaScript string
1419
+ * @param {Uint8Array} data
1420
+ * @returns {string}
1421
+ */
1422
+ function bytes_to_hex(data) {
1423
+ let deferred1_0;
1424
+ let deferred1_1;
1425
+ try {
1426
+ const ret = wasm.bytes_to_hex(data);
1427
+ deferred1_0 = ret[0];
1428
+ deferred1_1 = ret[1];
1429
+ return getStringFromWasm0(ret[0], ret[1]);
1430
+ } finally {
1431
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1432
+ }
1433
+ }
1434
+ exports.bytes_to_hex = bytes_to_hex;
1435
+
1436
+ /**
1437
+ * Convert bytes to hexadecimal string
1438
+ * @param {Uint8Array} data
1439
+ * @returns {string}
1440
+ */
1441
+ function bytes_to_hex_wasm(data) {
1442
+ let deferred1_0;
1443
+ let deferred1_1;
1444
+ try {
1445
+ const ret = wasm.bytes_to_hex_wasm(data);
1446
+ deferred1_0 = ret[0];
1447
+ deferred1_1 = ret[1];
1448
+ return getStringFromWasm0(ret[0], ret[1]);
1449
+ } finally {
1450
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1451
+ }
1452
+ }
1453
+ exports.bytes_to_hex_wasm = bytes_to_hex_wasm;
1454
+
1455
+ /**
1456
+ * Decapsulate shared secret from ciphertext (hex) with secret key (hex); returns `{ sharedSecretHex }`.
1457
+ * @param {string} secret_key_hex
1458
+ * @param {string} ciphertext_hex
1459
+ * @returns {any}
1460
+ */
1461
+ function cbKemDecapsulate(secret_key_hex, ciphertext_hex) {
1462
+ const ptr0 = passStringToWasm0(secret_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1463
+ const len0 = WASM_VECTOR_LEN;
1464
+ const ptr1 = passStringToWasm0(ciphertext_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1465
+ const len1 = WASM_VECTOR_LEN;
1466
+ const ret = wasm.cbKemDecapsulate(ptr0, len0, ptr1, len1);
1467
+ if (ret[2]) {
1468
+ throw takeFromExternrefTable0(ret[1]);
1469
+ }
1470
+ return takeFromExternrefTable0(ret[0]);
1471
+ }
1472
+ exports.cbKemDecapsulate = cbKemDecapsulate;
1473
+
1474
+ /**
1475
+ * Raw shared secret bytes (decapsulate).
1476
+ * @param {string} secret_key_hex
1477
+ * @param {string} ciphertext_hex
1478
+ * @returns {Uint8Array}
1479
+ */
1480
+ function cbKemDecapsulateBytes(secret_key_hex, ciphertext_hex) {
1481
+ const ptr0 = passStringToWasm0(secret_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1482
+ const len0 = WASM_VECTOR_LEN;
1483
+ const ptr1 = passStringToWasm0(ciphertext_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1484
+ const len1 = WASM_VECTOR_LEN;
1485
+ const ret = wasm.cbKemDecapsulateBytes(ptr0, len0, ptr1, len1);
1486
+ if (ret[2]) {
1487
+ throw takeFromExternrefTable0(ret[1]);
1488
+ }
1489
+ return takeFromExternrefTable0(ret[0]);
1490
+ }
1491
+ exports.cbKemDecapsulateBytes = cbKemDecapsulateBytes;
1492
+
1493
+ /**
1494
+ * Encapsulate to a peer's public key (hex).
1495
+ * @param {string} public_key_hex
1496
+ * @returns {any}
1497
+ */
1498
+ function cbKemEncapsulate(public_key_hex) {
1499
+ const ptr0 = passStringToWasm0(public_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1500
+ const len0 = WASM_VECTOR_LEN;
1501
+ const ret = wasm.cbKemEncapsulate(ptr0, len0);
1502
+ if (ret[2]) {
1503
+ throw takeFromExternrefTable0(ret[1]);
1504
+ }
1505
+ return takeFromExternrefTable0(ret[0]);
1506
+ }
1507
+ exports.cbKemEncapsulate = cbKemEncapsulate;
1508
+
1509
+ /**
1510
+ * Generate a CB-KEM keypair for the variant compiled into this build.
1511
+ * @returns {any}
1512
+ */
1513
+ function cbKemKeygen() {
1514
+ const ret = wasm.cbKemKeygen();
1515
+ if (ret[2]) {
1516
+ throw takeFromExternrefTable0(ret[1]);
1517
+ }
1518
+ return takeFromExternrefTable0(ret[0]);
1519
+ }
1520
+ exports.cbKemKeygen = cbKemKeygen;
1521
+
1522
+ /**
1523
+ * Create an AEAD context for WASM backed by `lib-q-aead` (same wiring as `libq::aead::context`).
1524
+ * @returns {WasmAeadContext}
1525
+ */
1526
+ function create_aead_context() {
1527
+ const ret = wasm.create_aead_context();
1528
+ return WasmAeadContext.__wrap(ret);
1529
+ }
1530
+ exports.create_aead_context = create_aead_context;
1531
+
1532
+ /**
1533
+ * Create a new Hash context for WASM backed by `lib-q-hash` (same wiring as
1534
+ * [`crate::create_hash_context`]).
1535
+ * @returns {WasmHashContext}
1536
+ */
1537
+ function create_hash_context() {
1538
+ const ret = wasm.create_hash_context();
1539
+ return WasmHashContext.__wrap(ret);
1540
+ }
1541
+ exports.create_hash_context = create_hash_context;
1542
+
1543
+ /**
1544
+ * Create a new KEM context for WASM
1545
+ * @returns {WasmKemContext}
1546
+ */
1547
+ function create_kem_context() {
1548
+ const ret = wasm.create_kem_context();
1549
+ return WasmKemContext.__wrap(ret);
1550
+ }
1551
+ exports.create_kem_context = create_kem_context;
1552
+
1553
+ /**
1554
+ * Create a new provider manager for WASM
1555
+ * @returns {WasmProviderManager}
1556
+ */
1557
+ function create_provider_manager() {
1558
+ const ret = wasm.create_provider_manager();
1559
+ return WasmProviderManager.__wrap(ret);
1560
+ }
1561
+ exports.create_provider_manager = create_provider_manager;
1562
+
1563
+ /**
1564
+ * Create a new Signature context for WASM backed by `lib-q-sig` (same wiring as native
1565
+ * `SignatureContext` with [`LibQSignatureProvider`](lib_q_sig::LibQSignatureProvider)).
1566
+ * @returns {WasmSignatureContext}
1567
+ */
1568
+ function create_signature_context() {
1569
+ const ret = wasm.create_signature_context();
1570
+ return WasmSignatureContext.__wrap(ret);
1571
+ }
1572
+ exports.create_signature_context = create_signature_context;
1573
+
1574
+ /**
1575
+ * Generate secure random bytes for WASM
1576
+ * @param {number} length
1577
+ * @returns {Uint8Array}
1578
+ */
1579
+ function generate_random_bytes(length) {
1580
+ const ret = wasm.generate_random_bytes(length);
1581
+ if (ret[2]) {
1582
+ throw takeFromExternrefTable0(ret[1]);
1583
+ }
1584
+ return takeFromExternrefTable0(ret[0]);
1585
+ }
1586
+ exports.generate_random_bytes = generate_random_bytes;
1587
+
1588
+ /**
1589
+ * Get library information for WASM
1590
+ *
1591
+ * This function provides library metadata for JavaScript consumption
1592
+ * @returns {string}
1593
+ */
1594
+ function get_library_info() {
1595
+ let deferred1_0;
1596
+ let deferred1_1;
1597
+ try {
1598
+ const ret = wasm.get_library_info();
1599
+ deferred1_0 = ret[0];
1600
+ deferred1_1 = ret[1];
1601
+ return getStringFromWasm0(ret[0], ret[1]);
1602
+ } finally {
1603
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1604
+ }
1605
+ }
1606
+ exports.get_library_info = get_library_info;
1607
+
1608
+ /**
1609
+ * Get library information for WASM
1610
+ * @returns {string}
1611
+ */
1612
+ function get_library_info_wasm() {
1613
+ let deferred1_0;
1614
+ let deferred1_1;
1615
+ try {
1616
+ const ret = wasm.get_library_info_wasm();
1617
+ deferred1_0 = ret[0];
1618
+ deferred1_1 = ret[1];
1619
+ return getStringFromWasm0(ret[0], ret[1]);
1620
+ } finally {
1621
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1622
+ }
1623
+ }
1624
+ exports.get_library_info_wasm = get_library_info_wasm;
1625
+
1626
+ /**
1627
+ * Get performance benchmarks
1628
+ * @returns {string}
1629
+ */
1630
+ function get_performance_benchmarks_wasm() {
1631
+ let deferred1_0;
1632
+ let deferred1_1;
1633
+ try {
1634
+ const ret = wasm.get_performance_benchmarks_wasm();
1635
+ deferred1_0 = ret[0];
1636
+ deferred1_1 = ret[1];
1637
+ return getStringFromWasm0(ret[0], ret[1]);
1638
+ } finally {
1639
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1640
+ }
1641
+ }
1642
+ exports.get_performance_benchmarks_wasm = get_performance_benchmarks_wasm;
1643
+
1644
+ /**
1645
+ * Get security recommendations
1646
+ * @returns {string}
1647
+ */
1648
+ function get_security_recommendations_wasm() {
1649
+ let deferred1_0;
1650
+ let deferred1_1;
1651
+ try {
1652
+ const ret = wasm.get_security_recommendations_wasm();
1653
+ deferred1_0 = ret[0];
1654
+ deferred1_1 = ret[1];
1655
+ return getStringFromWasm0(ret[0], ret[1]);
1656
+ } finally {
1657
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1658
+ }
1659
+ }
1660
+ exports.get_security_recommendations_wasm = get_security_recommendations_wasm;
1661
+
1662
+ /**
1663
+ * Get supported algorithms by category
1664
+ *
1665
+ * This function provides algorithm information for JavaScript
1666
+ * @returns {string}
1667
+ */
1668
+ function get_supported_algorithms() {
1669
+ let deferred1_0;
1670
+ let deferred1_1;
1671
+ try {
1672
+ const ret = wasm.get_supported_algorithms();
1673
+ deferred1_0 = ret[0];
1674
+ deferred1_1 = ret[1];
1675
+ return getStringFromWasm0(ret[0], ret[1]);
1676
+ } finally {
1677
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1678
+ }
1679
+ }
1680
+ exports.get_supported_algorithms = get_supported_algorithms;
1681
+
1682
+ /**
1683
+ * Get supported algorithms by category
1684
+ * @returns {any}
1685
+ */
1686
+ function get_supported_algorithms_wasm() {
1687
+ const ret = wasm.get_supported_algorithms_wasm();
1688
+ return ret;
1689
+ }
1690
+ exports.get_supported_algorithms_wasm = get_supported_algorithms_wasm;
1691
+
1692
+ /**
1693
+ * Get the library version
1694
+ * @returns {string}
1695
+ */
1696
+ function get_version() {
1697
+ let deferred1_0;
1698
+ let deferred1_1;
1699
+ try {
1700
+ const ret = wasm.get_version();
1701
+ deferred1_0 = ret[0];
1702
+ deferred1_1 = ret[1];
1703
+ return getStringFromWasm0(ret[0], ret[1]);
1704
+ } finally {
1705
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1706
+ }
1707
+ }
1708
+ exports.get_version = get_version;
1709
+
1710
+ /**
1711
+ * Convert hexadecimal string to bytes
1712
+ *
1713
+ * This function provides secure hex decoding for WASM:
1714
+ * - Validates hex string format
1715
+ * - Handles errors gracefully
1716
+ * - Returns Uint8Array
1717
+ * @param {string} hex
1718
+ * @returns {Uint8Array}
1719
+ */
1720
+ function hex_to_bytes(hex) {
1721
+ const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1722
+ const len0 = WASM_VECTOR_LEN;
1723
+ const ret = wasm.hex_to_bytes(ptr0, len0);
1724
+ if (ret[2]) {
1725
+ throw takeFromExternrefTable0(ret[1]);
1726
+ }
1727
+ return takeFromExternrefTable0(ret[0]);
1728
+ }
1729
+ exports.hex_to_bytes = hex_to_bytes;
1730
+
1731
+ /**
1732
+ * Convert hexadecimal string to bytes
1733
+ * @param {string} hex
1734
+ * @returns {Uint8Array}
1735
+ */
1736
+ function hex_to_bytes_wasm(hex) {
1737
+ const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1738
+ const len0 = WASM_VECTOR_LEN;
1739
+ const ret = wasm.hex_to_bytes_wasm(ptr0, len0);
1740
+ if (ret[2]) {
1741
+ throw takeFromExternrefTable0(ret[1]);
1742
+ }
1743
+ return takeFromExternrefTable0(ret[0]);
1744
+ }
1745
+ exports.hex_to_bytes_wasm = hex_to_bytes_wasm;
1746
+
1747
+ /**
1748
+ * Object `{ "sharedSecretHex": "..." }` with hex-encoded shared secret bytes.
1749
+ * @param {string} secret_key_hex
1750
+ * @param {string} ciphertext_hex
1751
+ * @param {string} param
1752
+ * @returns {any}
1753
+ */
1754
+ function hqc_decapsulate(secret_key_hex, ciphertext_hex, param) {
1755
+ const ptr0 = passStringToWasm0(secret_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1756
+ const len0 = WASM_VECTOR_LEN;
1757
+ const ptr1 = passStringToWasm0(ciphertext_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1758
+ const len1 = WASM_VECTOR_LEN;
1759
+ const ptr2 = passStringToWasm0(param, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1760
+ const len2 = WASM_VECTOR_LEN;
1761
+ const ret = wasm.hqc_decapsulate(ptr0, len0, ptr1, len1, ptr2, len2);
1762
+ if (ret[2]) {
1763
+ throw takeFromExternrefTable0(ret[1]);
1764
+ }
1765
+ return takeFromExternrefTable0(ret[0]);
1766
+ }
1767
+ exports.hqc_decapsulate = hqc_decapsulate;
1768
+
1769
+ /**
1770
+ * Object `{"ciphertext":"hex","sharedSecret":"hex"}`.
1771
+ * @param {string} public_key_hex
1772
+ * @param {string} param
1773
+ * @returns {any}
1774
+ */
1775
+ function hqc_encapsulate(public_key_hex, param) {
1776
+ const ptr0 = passStringToWasm0(public_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1777
+ const len0 = WASM_VECTOR_LEN;
1778
+ const ptr1 = passStringToWasm0(param, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1779
+ const len1 = WASM_VECTOR_LEN;
1780
+ const ret = wasm.hqc_encapsulate(ptr0, len0, ptr1, len1);
1781
+ if (ret[2]) {
1782
+ throw takeFromExternrefTable0(ret[1]);
1783
+ }
1784
+ return takeFromExternrefTable0(ret[0]);
1785
+ }
1786
+ exports.hqc_encapsulate = hqc_encapsulate;
1787
+
1788
+ /**
1789
+ * Object `{"publicKey":"hex","secretKey":"hex"}`.
1790
+ * @param {string} param
1791
+ * @returns {any}
1792
+ */
1793
+ function hqc_keygen(param) {
1794
+ const ptr0 = passStringToWasm0(param, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1795
+ const len0 = WASM_VECTOR_LEN;
1796
+ const ret = wasm.hqc_keygen(ptr0, len0);
1797
+ if (ret[2]) {
1798
+ throw takeFromExternrefTable0(ret[1]);
1799
+ }
1800
+ return takeFromExternrefTable0(ret[0]);
1801
+ }
1802
+ exports.hqc_keygen = hqc_keygen;
1803
+
1804
+ /**
1805
+ * Initialize the library for WASM usage
1806
+ */
1807
+ function init_wasm() {
1808
+ const ret = wasm.init_wasm();
1809
+ if (ret[1]) {
1810
+ throw takeFromExternrefTable0(ret[0]);
1811
+ }
1812
+ }
1813
+ exports.init_wasm = init_wasm;
1814
+
1815
+ /**
1816
+ * Check if an algorithm is supported
1817
+ * @param {string} algorithm
1818
+ * @returns {boolean}
1819
+ */
1820
+ function is_algorithm_supported_wasm(algorithm) {
1821
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1822
+ const len0 = WASM_VECTOR_LEN;
1823
+ const ret = wasm.is_algorithm_supported_wasm(ptr0, len0);
1824
+ return ret !== 0;
1825
+ }
1826
+ exports.is_algorithm_supported_wasm = is_algorithm_supported_wasm;
1827
+
1828
+ /**
1829
+ * Check if a feature is available
1830
+ *
1831
+ * This function allows JavaScript to check feature availability
1832
+ * @param {string} feature
1833
+ * @returns {boolean}
1834
+ */
1835
+ function is_feature_available(feature) {
1836
+ const ptr0 = passStringToWasm0(feature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1837
+ const len0 = WASM_VECTOR_LEN;
1838
+ const ret = wasm.is_feature_available(ptr0, len0);
1839
+ return ret !== 0;
1840
+ }
1841
+ exports.is_feature_available = is_feature_available;
1842
+
1843
+ /**
1844
+ * Generate cryptographically secure random bytes for WASM
1845
+ *
1846
+ * This function provides secure random generation in WASM environments:
1847
+ * - Uses the browser's crypto.getRandomValues() API
1848
+ * - Validates input size to prevent DoS attacks
1849
+ * - Returns Uint8Array for direct JavaScript consumption
1850
+ * @param {number} length
1851
+ * @returns {Uint8Array}
1852
+ */
1853
+ function random_bytes(length) {
1854
+ const ret = wasm.random_bytes(length);
1855
+ if (ret[2]) {
1856
+ throw takeFromExternrefTable0(ret[1]);
1857
+ }
1858
+ return takeFromExternrefTable0(ret[0]);
1859
+ }
1860
+ exports.random_bytes = random_bytes;
1861
+
1862
+ /**
1863
+ * Fill `len` bytes from [`new_secure_rng`] (`WebAssembly` uses `getrandom` `wasm_js` backend).
1864
+ * @param {number} len
1865
+ * @returns {Uint8Array}
1866
+ */
1867
+ function secureRandomBytes(len) {
1868
+ const ret = wasm.secureRandomBytes(len);
1869
+ if (ret[2]) {
1870
+ throw takeFromExternrefTable0(ret[1]);
1871
+ }
1872
+ return takeFromExternrefTable0(ret[0]);
1873
+ }
1874
+ exports.secureRandomBytes = secureRandomBytes;
1875
+
1876
+ /**
1877
+ * Validate input data for WASM operations
1878
+ *
1879
+ * This function provides comprehensive input validation:
1880
+ * - Checks for null/undefined values
1881
+ * - Validates data size limits
1882
+ * - Ensures data is not empty when required
1883
+ * @param {Uint8Array} data
1884
+ * @param {number | null} [min_size]
1885
+ * @param {number | null} [max_size]
1886
+ * @returns {boolean}
1887
+ */
1888
+ function validate_input(data, min_size, max_size) {
1889
+ const ret = wasm.validate_input(data, isLikeNone(min_size) ? Number.MAX_SAFE_INTEGER : (min_size) >>> 0, isLikeNone(max_size) ? Number.MAX_SAFE_INTEGER : (max_size) >>> 0);
1890
+ if (ret[2]) {
1891
+ throw takeFromExternrefTable0(ret[1]);
1892
+ }
1893
+ return ret[0] !== 0;
1894
+ }
1895
+ exports.validate_input = validate_input;
1896
+
1897
+ /**
1898
+ * Prove knowledge of a secret preimage (Poseidon-128 commitment) as a [`ZkpProof`] object.
1899
+ * @param {Uint8Array} secret
1900
+ * @returns {any}
1901
+ */
1902
+ function zkpProvePreimageJson(secret) {
1903
+ const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
1904
+ const len0 = WASM_VECTOR_LEN;
1905
+ const ret = wasm.zkpProvePreimageJson(ptr0, len0);
1906
+ if (ret[2]) {
1907
+ throw takeFromExternrefTable0(ret[1]);
1908
+ }
1909
+ return takeFromExternrefTable0(ret[0]);
1910
+ }
1911
+ exports.zkpProvePreimageJson = zkpProvePreimageJson;
1912
+
1913
+ /**
1914
+ * NIST cSHAKE256 preimage proof as a [`ZkpProof`] object.
1915
+ * @param {Uint8Array} secret
1916
+ * @returns {any}
1917
+ */
1918
+ function zkpProvePreimageNistJson(secret) {
1919
+ const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);
1920
+ const len0 = WASM_VECTOR_LEN;
1921
+ const ret = wasm.zkpProvePreimageNistJson(ptr0, len0);
1922
+ if (ret[2]) {
1923
+ throw takeFromExternrefTable0(ret[1]);
1924
+ }
1925
+ return takeFromExternrefTable0(ret[0]);
1926
+ }
1927
+ exports.zkpProvePreimageNistJson = zkpProvePreimageNistJson;
1928
+
1929
+ /**
1930
+ * Verify a proof object from [`zkp_prove_preimage_json`]; `expected_hash_hex` is 32-byte hash.
1931
+ * @param {any} proof
1932
+ * @param {string} expected_hash_hex
1933
+ * @returns {boolean}
1934
+ */
1935
+ function zkpVerifyPreimageJson(proof, expected_hash_hex) {
1936
+ const ptr0 = passStringToWasm0(expected_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1937
+ const len0 = WASM_VECTOR_LEN;
1938
+ const ret = wasm.zkpVerifyPreimageJson(proof, ptr0, len0);
1939
+ if (ret[2]) {
1940
+ throw takeFromExternrefTable0(ret[1]);
1941
+ }
1942
+ return ret[0] !== 0;
1943
+ }
1944
+ exports.zkpVerifyPreimageJson = zkpVerifyPreimageJson;
1945
+
1946
+ /**
1947
+ * Verify NIST preimage proof object; `expected_hash_hex` is the 32-byte cSHAKE256 output.
1948
+ * @param {any} proof
1949
+ * @param {string} expected_hash_hex
1950
+ * @returns {boolean}
1951
+ */
1952
+ function zkpVerifyPreimageNistJson(proof, expected_hash_hex) {
1953
+ const ptr0 = passStringToWasm0(expected_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1954
+ const len0 = WASM_VECTOR_LEN;
1955
+ const ret = wasm.zkpVerifyPreimageNistJson(proof, ptr0, len0);
1956
+ if (ret[2]) {
1957
+ throw takeFromExternrefTable0(ret[1]);
1958
+ }
1959
+ return ret[0] !== 0;
1960
+ }
1961
+ exports.zkpVerifyPreimageNistJson = zkpVerifyPreimageNistJson;
1962
+ function __wbg_get_imports() {
1963
+ const import0 = {
1964
+ __proto__: null,
1965
+ __wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
1966
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1967
+ return ret;
1968
+ },
1969
+ __wbg_Number_6b506e6536831eaa: function(arg0) {
1970
+ const ret = Number(arg0);
1971
+ return ret;
1972
+ },
1973
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
1974
+ const ret = String(arg1);
1975
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1976
+ const len1 = WASM_VECTOR_LEN;
1977
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1978
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1979
+ },
1980
+ __wbg___wbindgen_boolean_get_1a45e2c38d4d41b9: function(arg0) {
1981
+ const v = arg0;
1982
+ const ret = typeof(v) === 'boolean' ? v : undefined;
1983
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1984
+ },
1985
+ __wbg___wbindgen_debug_string_0accd80f45e5faa2: function(arg0, arg1) {
1986
+ const ret = debugString(arg1);
1987
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1988
+ const len1 = WASM_VECTOR_LEN;
1989
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1990
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1991
+ },
1992
+ __wbg___wbindgen_in_70a403a56e771704: function(arg0, arg1) {
1993
+ const ret = arg0 in arg1;
1994
+ return ret;
1995
+ },
1996
+ __wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
1997
+ const ret = typeof(arg0) === 'function';
1998
+ return ret;
1999
+ },
2000
+ __wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
2001
+ const val = arg0;
2002
+ const ret = typeof(val) === 'object' && val !== null;
2003
+ return ret;
2004
+ },
2005
+ __wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
2006
+ const ret = typeof(arg0) === 'string';
2007
+ return ret;
2008
+ },
2009
+ __wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
2010
+ const ret = arg0 === undefined;
2011
+ return ret;
2012
+ },
2013
+ __wbg___wbindgen_jsval_loose_eq_2c56564c75129511: function(arg0, arg1) {
2014
+ const ret = arg0 == arg1;
2015
+ return ret;
2016
+ },
2017
+ __wbg___wbindgen_number_get_9bb1761122181af2: function(arg0, arg1) {
2018
+ const obj = arg1;
2019
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2020
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2021
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2022
+ },
2023
+ __wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
2024
+ const obj = arg1;
2025
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2026
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2027
+ var len1 = WASM_VECTOR_LEN;
2028
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2029
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2030
+ },
2031
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
2032
+ throw new Error(getStringFromWasm0(arg0, arg1));
2033
+ },
2034
+ __wbg_call_8a89609d89f6608a: function() { return handleError(function (arg0, arg1) {
2035
+ const ret = arg0.call(arg1);
2036
+ return ret;
2037
+ }, arguments); },
2038
+ __wbg_done_60cf307fcc680536: function(arg0) {
2039
+ const ret = arg0.done;
2040
+ return ret;
2041
+ },
2042
+ __wbg_entries_04b37a02507f1713: function(arg0) {
2043
+ const ret = Object.entries(arg0);
2044
+ return ret;
2045
+ },
2046
+ __wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {
2047
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2048
+ }, arguments); },
2049
+ __wbg_get_1f8f054ddbaa7db2: function() { return handleError(function (arg0, arg1) {
2050
+ const ret = Reflect.get(arg0, arg1);
2051
+ return ret;
2052
+ }, arguments); },
2053
+ __wbg_get_2b48c7d0d006a781: function(arg0, arg1) {
2054
+ const ret = arg0[arg1 >>> 0];
2055
+ return ret;
2056
+ },
2057
+ __wbg_get_index_ab123d64c89e3156: function(arg0, arg1) {
2058
+ const ret = arg0[arg1 >>> 0];
2059
+ return ret;
2060
+ },
2061
+ __wbg_get_unchecked_33f6e5c9e2f2d6b2: function(arg0, arg1) {
2062
+ const ret = arg0[arg1 >>> 0];
2063
+ return ret;
2064
+ },
2065
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
2066
+ const ret = arg0[arg1];
2067
+ return ret;
2068
+ },
2069
+ __wbg_instanceof_ArrayBuffer_8f49811467741499: function(arg0) {
2070
+ let result;
2071
+ try {
2072
+ result = arg0 instanceof ArrayBuffer;
2073
+ } catch (_) {
2074
+ result = false;
2075
+ }
2076
+ const ret = result;
2077
+ return ret;
2078
+ },
2079
+ __wbg_instanceof_Uint8Array_86f30649f63ef9c2: function(arg0) {
2080
+ let result;
2081
+ try {
2082
+ result = arg0 instanceof Uint8Array;
2083
+ } catch (_) {
2084
+ result = false;
2085
+ }
2086
+ const ret = result;
2087
+ return ret;
2088
+ },
2089
+ __wbg_isArray_67c2c9c4313f4448: function(arg0) {
2090
+ const ret = Array.isArray(arg0);
2091
+ return ret;
2092
+ },
2093
+ __wbg_isSafeInteger_66acec27e09e99a7: function(arg0) {
2094
+ const ret = Number.isSafeInteger(arg0);
2095
+ return ret;
2096
+ },
2097
+ __wbg_iterator_8732428d309e270e: function() {
2098
+ const ret = Symbol.iterator;
2099
+ return ret;
2100
+ },
2101
+ __wbg_length_4a591ecaa01354d9: function(arg0) {
2102
+ const ret = arg0.length;
2103
+ return ret;
2104
+ },
2105
+ __wbg_length_66f1a4b2e9026940: function(arg0) {
2106
+ const ret = arg0.length;
2107
+ return ret;
2108
+ },
2109
+ __wbg_new_578aeef4b6b94378: function(arg0) {
2110
+ const ret = new Uint8Array(arg0);
2111
+ return ret;
2112
+ },
2113
+ __wbg_new_622fc80556be2e26: function() {
2114
+ const ret = new Map();
2115
+ return ret;
2116
+ },
2117
+ __wbg_new_ce1ab61c1c2b300d: function() {
2118
+ const ret = new Object();
2119
+ return ret;
2120
+ },
2121
+ __wbg_new_d90091b82fdf5b91: function() {
2122
+ const ret = new Array();
2123
+ return ret;
2124
+ },
2125
+ __wbg_new_from_slice_18fa1f71286d66b8: function(arg0, arg1) {
2126
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2127
+ return ret;
2128
+ },
2129
+ __wbg_new_with_length_36a4998e27b014c5: function(arg0) {
2130
+ const ret = new Uint8Array(arg0 >>> 0);
2131
+ return ret;
2132
+ },
2133
+ __wbg_next_9e03acdf51c4960d: function(arg0) {
2134
+ const ret = arg0.next;
2135
+ return ret;
2136
+ },
2137
+ __wbg_next_eb8ca7351fa27906: function() { return handleError(function (arg0) {
2138
+ const ret = arg0.next();
2139
+ return ret;
2140
+ }, arguments); },
2141
+ __wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
2142
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
2143
+ },
2144
+ __wbg_set_29c99a8aac1c01e5: function(arg0, arg1, arg2) {
2145
+ arg0.set(getArrayU8FromWasm0(arg1, arg2));
2146
+ },
2147
+ __wbg_set_52b1e1eb5bed906a: function(arg0, arg1, arg2) {
2148
+ const ret = arg0.set(arg1, arg2);
2149
+ return ret;
2150
+ },
2151
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
2152
+ arg0[arg1] = arg2;
2153
+ },
2154
+ __wbg_set_dca99999bba88a9a: function(arg0, arg1, arg2) {
2155
+ arg0[arg1 >>> 0] = arg2;
2156
+ },
2157
+ __wbg_set_index_73ced2e1b4a2a37e: function(arg0, arg1, arg2) {
2158
+ arg0[arg1 >>> 0] = arg2;
2159
+ },
2160
+ __wbg_value_f3625092ee4b37f4: function(arg0) {
2161
+ const ret = arg0.value;
2162
+ return ret;
2163
+ },
2164
+ __wbindgen_cast_0000000000000001: function(arg0) {
2165
+ // Cast intrinsic for `F64 -> Externref`.
2166
+ const ret = arg0;
2167
+ return ret;
2168
+ },
2169
+ __wbindgen_cast_0000000000000002: function(arg0) {
2170
+ // Cast intrinsic for `I64 -> Externref`.
2171
+ const ret = arg0;
2172
+ return ret;
2173
+ },
2174
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
2175
+ // Cast intrinsic for `Ref(String) -> Externref`.
2176
+ const ret = getStringFromWasm0(arg0, arg1);
2177
+ return ret;
2178
+ },
2179
+ __wbindgen_cast_0000000000000004: function(arg0) {
2180
+ // Cast intrinsic for `U64 -> Externref`.
2181
+ const ret = BigInt.asUintN(64, arg0);
2182
+ return ret;
2183
+ },
2184
+ __wbindgen_init_externref_table: function() {
2185
+ const table = wasm.__wbindgen_externrefs;
2186
+ const offset = table.grow(4);
2187
+ table.set(0, undefined);
2188
+ table.set(offset + 0, undefined);
2189
+ table.set(offset + 1, null);
2190
+ table.set(offset + 2, true);
2191
+ table.set(offset + 3, false);
2192
+ },
2193
+ };
2194
+ return {
2195
+ __proto__: null,
2196
+ "./libq_bg.js": import0,
2197
+ };
2198
+ }
2199
+
2200
+ const HashResultWasmFinalization = (typeof FinalizationRegistry === 'undefined')
2201
+ ? { register: () => {}, unregister: () => {} }
2202
+ : new FinalizationRegistry(ptr => wasm.__wbg_hashresultwasm_free(ptr, 1));
2203
+ const KemKeypairFinalization = (typeof FinalizationRegistry === 'undefined')
2204
+ ? { register: () => {}, unregister: () => {} }
2205
+ : new FinalizationRegistry(ptr => wasm.__wbg_kemkeypair_free(ptr, 1));
2206
+ const KemPublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
2207
+ ? { register: () => {}, unregister: () => {} }
2208
+ : new FinalizationRegistry(ptr => wasm.__wbg_kempublickey_free(ptr, 1));
2209
+ const KemSecretKeyFinalization = (typeof FinalizationRegistry === 'undefined')
2210
+ ? { register: () => {}, unregister: () => {} }
2211
+ : new FinalizationRegistry(ptr => wasm.__wbg_kemsecretkey_free(ptr, 1));
2212
+ const MlDsaFinalization = (typeof FinalizationRegistry === 'undefined')
2213
+ ? { register: () => {}, unregister: () => {} }
2214
+ : new FinalizationRegistry(ptr => wasm.__wbg_mldsa_free(ptr, 1));
2215
+ const SecureWasmAeadContextFinalization = (typeof FinalizationRegistry === 'undefined')
2216
+ ? { register: () => {}, unregister: () => {} }
2217
+ : new FinalizationRegistry(ptr => wasm.__wbg_securewasmaeadcontext_free(ptr, 1));
2218
+ const SecureWasmHashContextFinalization = (typeof FinalizationRegistry === 'undefined')
2219
+ ? { register: () => {}, unregister: () => {} }
2220
+ : new FinalizationRegistry(ptr => wasm.__wbg_securewasmhashcontext_free(ptr, 1));
2221
+ const SecureWasmKemContextFinalization = (typeof FinalizationRegistry === 'undefined')
2222
+ ? { register: () => {}, unregister: () => {} }
2223
+ : new FinalizationRegistry(ptr => wasm.__wbg_securewasmkemcontext_free(ptr, 1));
2224
+ const SecureWasmSignatureContextFinalization = (typeof FinalizationRegistry === 'undefined')
2225
+ ? { register: () => {}, unregister: () => {} }
2226
+ : new FinalizationRegistry(ptr => wasm.__wbg_securewasmsignaturecontext_free(ptr, 1));
2227
+ const SigKeypairFinalization = (typeof FinalizationRegistry === 'undefined')
2228
+ ? { register: () => {}, unregister: () => {} }
2229
+ : new FinalizationRegistry(ptr => wasm.__wbg_sigkeypair_free(ptr, 1));
2230
+ const SigPublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
2231
+ ? { register: () => {}, unregister: () => {} }
2232
+ : new FinalizationRegistry(ptr => wasm.__wbg_sigpublickey_free(ptr, 1));
2233
+ const SigSecretKeyFinalization = (typeof FinalizationRegistry === 'undefined')
2234
+ ? { register: () => {}, unregister: () => {} }
2235
+ : new FinalizationRegistry(ptr => wasm.__wbg_sigsecretkey_free(ptr, 1));
2236
+ const SlhDsaFinalization = (typeof FinalizationRegistry === 'undefined')
2237
+ ? { register: () => {}, unregister: () => {} }
2238
+ : new FinalizationRegistry(ptr => wasm.__wbg_slhdsa_free(ptr, 1));
2239
+ const WasmAeadContextFinalization = (typeof FinalizationRegistry === 'undefined')
2240
+ ? { register: () => {}, unregister: () => {} }
2241
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmaeadcontext_free(ptr, 1));
2242
+ const WasmCryptoProviderFinalization = (typeof FinalizationRegistry === 'undefined')
2243
+ ? { register: () => {}, unregister: () => {} }
2244
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmcryptoprovider_free(ptr, 1));
2245
+ const WasmHashContextFinalization = (typeof FinalizationRegistry === 'undefined')
2246
+ ? { register: () => {}, unregister: () => {} }
2247
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmhashcontext_free(ptr, 1));
2248
+ const WasmKemContextFinalization = (typeof FinalizationRegistry === 'undefined')
2249
+ ? { register: () => {}, unregister: () => {} }
2250
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmkemcontext_free(ptr, 1));
2251
+ const WasmKeyPairImplFinalization = (typeof FinalizationRegistry === 'undefined')
2252
+ ? { register: () => {}, unregister: () => {} }
2253
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmkeypairimpl_free(ptr, 1));
2254
+ const WasmMlDsaKeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
2255
+ ? { register: () => {}, unregister: () => {} }
2256
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmmldsakeypair_free(ptr, 1));
2257
+ const WasmProviderFactoryFinalization = (typeof FinalizationRegistry === 'undefined')
2258
+ ? { register: () => {}, unregister: () => {} }
2259
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmproviderfactory_free(ptr, 1));
2260
+ const WasmProviderManagerFinalization = (typeof FinalizationRegistry === 'undefined')
2261
+ ? { register: () => {}, unregister: () => {} }
2262
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmprovidermanager_free(ptr, 1));
2263
+ const WasmSignatureContextFinalization = (typeof FinalizationRegistry === 'undefined')
2264
+ ? { register: () => {}, unregister: () => {} }
2265
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmsignaturecontext_free(ptr, 1));
2266
+ const WasmSlhDsaKeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
2267
+ ? { register: () => {}, unregister: () => {} }
2268
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmslhdsakeypair_free(ptr, 1));
2269
+
2270
+ function addToExternrefTable0(obj) {
2271
+ const idx = wasm.__externref_table_alloc();
2272
+ wasm.__wbindgen_externrefs.set(idx, obj);
2273
+ return idx;
2274
+ }
2275
+
2276
+ function debugString(val) {
2277
+ // primitive types
2278
+ const type = typeof val;
2279
+ if (type == 'number' || type == 'boolean' || val == null) {
2280
+ return `${val}`;
2281
+ }
2282
+ if (type == 'string') {
2283
+ return `"${val}"`;
2284
+ }
2285
+ if (type == 'symbol') {
2286
+ const description = val.description;
2287
+ if (description == null) {
2288
+ return 'Symbol';
2289
+ } else {
2290
+ return `Symbol(${description})`;
2291
+ }
2292
+ }
2293
+ if (type == 'function') {
2294
+ const name = val.name;
2295
+ if (typeof name == 'string' && name.length > 0) {
2296
+ return `Function(${name})`;
2297
+ } else {
2298
+ return 'Function';
2299
+ }
2300
+ }
2301
+ // objects
2302
+ if (Array.isArray(val)) {
2303
+ const length = val.length;
2304
+ let debug = '[';
2305
+ if (length > 0) {
2306
+ debug += debugString(val[0]);
2307
+ }
2308
+ for(let i = 1; i < length; i++) {
2309
+ debug += ', ' + debugString(val[i]);
2310
+ }
2311
+ debug += ']';
2312
+ return debug;
2313
+ }
2314
+ // Test for built-in
2315
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2316
+ let className;
2317
+ if (builtInMatches && builtInMatches.length > 1) {
2318
+ className = builtInMatches[1];
2319
+ } else {
2320
+ // Failed to match the standard '[object ClassName]'
2321
+ return toString.call(val);
2322
+ }
2323
+ if (className == 'Object') {
2324
+ // we're a user defined class or Object
2325
+ // JSON.stringify avoids problems with cycles, and is generally much
2326
+ // easier than looping through ownProperties of `val`.
2327
+ try {
2328
+ return 'Object(' + JSON.stringify(val) + ')';
2329
+ } catch (_) {
2330
+ return 'Object';
2331
+ }
2332
+ }
2333
+ // errors
2334
+ if (val instanceof Error) {
2335
+ return `${val.name}: ${val.message}\n${val.stack}`;
2336
+ }
2337
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2338
+ return className;
2339
+ }
2340
+
2341
+ function getArrayU8FromWasm0(ptr, len) {
2342
+ ptr = ptr >>> 0;
2343
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2344
+ }
2345
+
2346
+ let cachedDataViewMemory0 = null;
2347
+ function getDataViewMemory0() {
2348
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2349
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2350
+ }
2351
+ return cachedDataViewMemory0;
2352
+ }
2353
+
2354
+ function getStringFromWasm0(ptr, len) {
2355
+ return decodeText(ptr >>> 0, len);
2356
+ }
2357
+
2358
+ let cachedUint8ArrayMemory0 = null;
2359
+ function getUint8ArrayMemory0() {
2360
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2361
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2362
+ }
2363
+ return cachedUint8ArrayMemory0;
2364
+ }
2365
+
2366
+ function handleError(f, args) {
2367
+ try {
2368
+ return f.apply(this, args);
2369
+ } catch (e) {
2370
+ const idx = addToExternrefTable0(e);
2371
+ wasm.__wbindgen_exn_store(idx);
2372
+ }
2373
+ }
2374
+
2375
+ function isLikeNone(x) {
2376
+ return x === undefined || x === null;
2377
+ }
2378
+
2379
+ function passArray8ToWasm0(arg, malloc) {
2380
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
2381
+ getUint8ArrayMemory0().set(arg, ptr / 1);
2382
+ WASM_VECTOR_LEN = arg.length;
2383
+ return ptr;
2384
+ }
2385
+
2386
+ function passStringToWasm0(arg, malloc, realloc) {
2387
+ if (realloc === undefined) {
2388
+ const buf = cachedTextEncoder.encode(arg);
2389
+ const ptr = malloc(buf.length, 1) >>> 0;
2390
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2391
+ WASM_VECTOR_LEN = buf.length;
2392
+ return ptr;
2393
+ }
2394
+
2395
+ let len = arg.length;
2396
+ let ptr = malloc(len, 1) >>> 0;
2397
+
2398
+ const mem = getUint8ArrayMemory0();
2399
+
2400
+ let offset = 0;
2401
+
2402
+ for (; offset < len; offset++) {
2403
+ const code = arg.charCodeAt(offset);
2404
+ if (code > 0x7F) break;
2405
+ mem[ptr + offset] = code;
2406
+ }
2407
+ if (offset !== len) {
2408
+ if (offset !== 0) {
2409
+ arg = arg.slice(offset);
2410
+ }
2411
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2412
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2413
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2414
+
2415
+ offset += ret.written;
2416
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2417
+ }
2418
+
2419
+ WASM_VECTOR_LEN = offset;
2420
+ return ptr;
2421
+ }
2422
+
2423
+ function takeFromExternrefTable0(idx) {
2424
+ const value = wasm.__wbindgen_externrefs.get(idx);
2425
+ wasm.__externref_table_dealloc(idx);
2426
+ return value;
2427
+ }
2428
+
2429
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2430
+ cachedTextDecoder.decode();
2431
+ function decodeText(ptr, len) {
2432
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2433
+ }
2434
+
2435
+ const cachedTextEncoder = new TextEncoder();
2436
+
2437
+ if (!('encodeInto' in cachedTextEncoder)) {
2438
+ cachedTextEncoder.encodeInto = function (arg, view) {
2439
+ const buf = cachedTextEncoder.encode(arg);
2440
+ view.set(buf);
2441
+ return {
2442
+ read: arg.length,
2443
+ written: buf.length
2444
+ };
2445
+ };
2446
+ }
2447
+
2448
+ let WASM_VECTOR_LEN = 0;
2449
+
2450
+ const wasmPath = `${__dirname}/libq_bg.wasm`;
2451
+ const wasmBytes = require('fs').readFileSync(wasmPath);
2452
+ const wasmModule = new WebAssembly.Module(wasmBytes);
2453
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
2454
+ let wasm = wasmInstance.exports;
2455
+ wasm.__wbindgen_start();