@lib-q/core 0.0.1 → 0.0.2

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