@lib-q/prf 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.
@@ -0,0 +1,1636 @@
1
+ /* @ts-self-types="./lib_q_prf.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
+ * Secure WASM AEAD Context
284
+ *
285
+ * This context provides secure AEAD operations with:
286
+ * - Consistent error handling using Result<T, JsValue>
287
+ * - Security validation for all inputs
288
+ * - Protection against timing attacks
289
+ * - Memory safety with automatic cleanup
290
+ */
291
+ export class SecureWasmAeadContext {
292
+ __destroy_into_raw() {
293
+ const ptr = this.__wbg_ptr;
294
+ this.__wbg_ptr = 0;
295
+ SecureWasmAeadContextFinalization.unregister(this);
296
+ return ptr;
297
+ }
298
+ free() {
299
+ const ptr = this.__destroy_into_raw();
300
+ wasm.__wbg_securewasmaeadcontext_free(ptr, 0);
301
+ }
302
+ /**
303
+ * Decrypt data (Layer A `Result` ABI only; see [`crate::AeadDecryptSemantic`] for Layer B).
304
+ * @param {string} algorithm
305
+ * @param {Uint8Array} key
306
+ * @param {Uint8Array} nonce
307
+ * @param {Uint8Array} ciphertext
308
+ * @param {Uint8Array | null} [associated_data]
309
+ * @returns {any}
310
+ */
311
+ decrypt(algorithm, key, nonce, ciphertext, associated_data) {
312
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
313
+ const len0 = WASM_VECTOR_LEN;
314
+ const ret = wasm.securewasmaeadcontext_decrypt(this.__wbg_ptr, ptr0, len0, key, nonce, ciphertext, isLikeNone(associated_data) ? 0 : addToExternrefTable0(associated_data));
315
+ if (ret[2]) {
316
+ throw takeFromExternrefTable0(ret[1]);
317
+ }
318
+ return takeFromExternrefTable0(ret[0]);
319
+ }
320
+ /**
321
+ * Encrypt data
322
+ * @param {string} algorithm
323
+ * @param {Uint8Array} key
324
+ * @param {Uint8Array} nonce
325
+ * @param {Uint8Array} plaintext
326
+ * @param {Uint8Array | null} [associated_data]
327
+ * @returns {any}
328
+ */
329
+ encrypt(algorithm, key, nonce, plaintext, associated_data) {
330
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
331
+ const len0 = WASM_VECTOR_LEN;
332
+ const ret = wasm.securewasmaeadcontext_encrypt(this.__wbg_ptr, ptr0, len0, key, nonce, plaintext, isLikeNone(associated_data) ? 0 : addToExternrefTable0(associated_data));
333
+ if (ret[2]) {
334
+ throw takeFromExternrefTable0(ret[1]);
335
+ }
336
+ return takeFromExternrefTable0(ret[0]);
337
+ }
338
+ /**
339
+ * Get supported algorithms
340
+ * @returns {any}
341
+ */
342
+ get_supported_algorithms() {
343
+ const ret = wasm.securewasmaeadcontext_get_supported_algorithms(this.__wbg_ptr);
344
+ if (ret[2]) {
345
+ throw takeFromExternrefTable0(ret[1]);
346
+ }
347
+ return takeFromExternrefTable0(ret[0]);
348
+ }
349
+ /**
350
+ * Create a new secure WASM AEAD context
351
+ */
352
+ constructor() {
353
+ const ret = wasm.securewasmaeadcontext_new();
354
+ if (ret[2]) {
355
+ throw takeFromExternrefTable0(ret[1]);
356
+ }
357
+ this.__wbg_ptr = ret[0];
358
+ SecureWasmAeadContextFinalization.register(this, this.__wbg_ptr, this);
359
+ return this;
360
+ }
361
+ }
362
+ if (Symbol.dispose) SecureWasmAeadContext.prototype[Symbol.dispose] = SecureWasmAeadContext.prototype.free;
363
+
364
+ /**
365
+ * Secure WASM Hash Context
366
+ *
367
+ * This context provides secure hash 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 SecureWasmHashContext {
374
+ __destroy_into_raw() {
375
+ const ptr = this.__wbg_ptr;
376
+ this.__wbg_ptr = 0;
377
+ SecureWasmHashContextFinalization.unregister(this);
378
+ return ptr;
379
+ }
380
+ free() {
381
+ const ptr = this.__destroy_into_raw();
382
+ wasm.__wbg_securewasmhashcontext_free(ptr, 0);
383
+ }
384
+ /**
385
+ * Get supported algorithms
386
+ * @returns {any}
387
+ */
388
+ get_supported_algorithms() {
389
+ const ret = wasm.securewasmhashcontext_get_supported_algorithms(this.__wbg_ptr);
390
+ if (ret[2]) {
391
+ throw takeFromExternrefTable0(ret[1]);
392
+ }
393
+ return takeFromExternrefTable0(ret[0]);
394
+ }
395
+ /**
396
+ * Hash data
397
+ * @param {string} algorithm
398
+ * @param {Uint8Array} data
399
+ * @returns {any}
400
+ */
401
+ hash(algorithm, data) {
402
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
403
+ const len0 = WASM_VECTOR_LEN;
404
+ const ret = wasm.securewasmhashcontext_hash(this.__wbg_ptr, ptr0, len0, data);
405
+ if (ret[2]) {
406
+ throw takeFromExternrefTable0(ret[1]);
407
+ }
408
+ return takeFromExternrefTable0(ret[0]);
409
+ }
410
+ /**
411
+ * Create a new secure WASM hash context
412
+ */
413
+ constructor() {
414
+ const ret = wasm.securewasmhashcontext_new();
415
+ if (ret[2]) {
416
+ throw takeFromExternrefTable0(ret[1]);
417
+ }
418
+ this.__wbg_ptr = ret[0];
419
+ SecureWasmHashContextFinalization.register(this, this.__wbg_ptr, this);
420
+ return this;
421
+ }
422
+ }
423
+ if (Symbol.dispose) SecureWasmHashContext.prototype[Symbol.dispose] = SecureWasmHashContext.prototype.free;
424
+
425
+ /**
426
+ * Secure WASM KEM Context
427
+ *
428
+ * This context provides secure KEM operations with:
429
+ * - Consistent error handling using Result<T, JsValue>
430
+ * - Security validation for all inputs
431
+ * - Protection against timing attacks
432
+ * - Memory safety with automatic cleanup
433
+ */
434
+ export class SecureWasmKemContext {
435
+ __destroy_into_raw() {
436
+ const ptr = this.__wbg_ptr;
437
+ this.__wbg_ptr = 0;
438
+ SecureWasmKemContextFinalization.unregister(this);
439
+ return ptr;
440
+ }
441
+ free() {
442
+ const ptr = this.__destroy_into_raw();
443
+ wasm.__wbg_securewasmkemcontext_free(ptr, 0);
444
+ }
445
+ /**
446
+ * Decapsulate a shared secret
447
+ * @param {string} algorithm
448
+ * @param {Uint8Array} private_key
449
+ * @param {Uint8Array} ciphertext
450
+ * @returns {any}
451
+ */
452
+ decapsulate(algorithm, private_key, ciphertext) {
453
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
454
+ const len0 = WASM_VECTOR_LEN;
455
+ const ret = wasm.securewasmkemcontext_decapsulate(this.__wbg_ptr, ptr0, len0, private_key, ciphertext);
456
+ if (ret[2]) {
457
+ throw takeFromExternrefTable0(ret[1]);
458
+ }
459
+ return takeFromExternrefTable0(ret[0]);
460
+ }
461
+ /**
462
+ * Encapsulate a shared secret
463
+ * @param {string} algorithm
464
+ * @param {Uint8Array} public_key
465
+ * @param {Uint8Array | null} [randomness]
466
+ * @returns {any}
467
+ */
468
+ encapsulate(algorithm, public_key, randomness) {
469
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
470
+ const len0 = WASM_VECTOR_LEN;
471
+ const ret = wasm.securewasmkemcontext_encapsulate(this.__wbg_ptr, ptr0, len0, public_key, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
472
+ if (ret[2]) {
473
+ throw takeFromExternrefTable0(ret[1]);
474
+ }
475
+ return takeFromExternrefTable0(ret[0]);
476
+ }
477
+ /**
478
+ * Generate a KEM keypair
479
+ * @param {string} algorithm
480
+ * @param {Uint8Array | null} [randomness]
481
+ * @returns {any}
482
+ */
483
+ generate_keypair(algorithm, randomness) {
484
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
485
+ const len0 = WASM_VECTOR_LEN;
486
+ const ret = wasm.securewasmkemcontext_generate_keypair(this.__wbg_ptr, ptr0, len0, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
487
+ if (ret[2]) {
488
+ throw takeFromExternrefTable0(ret[1]);
489
+ }
490
+ return takeFromExternrefTable0(ret[0]);
491
+ }
492
+ /**
493
+ * Get supported algorithms
494
+ * @returns {any}
495
+ */
496
+ get_supported_algorithms() {
497
+ const ret = wasm.securewasmkemcontext_get_supported_algorithms(this.__wbg_ptr);
498
+ if (ret[2]) {
499
+ throw takeFromExternrefTable0(ret[1]);
500
+ }
501
+ return takeFromExternrefTable0(ret[0]);
502
+ }
503
+ /**
504
+ * Create a new secure WASM KEM context
505
+ */
506
+ constructor() {
507
+ const ret = wasm.securewasmkemcontext_new();
508
+ if (ret[2]) {
509
+ throw takeFromExternrefTable0(ret[1]);
510
+ }
511
+ this.__wbg_ptr = ret[0];
512
+ SecureWasmKemContextFinalization.register(this, this.__wbg_ptr, this);
513
+ return this;
514
+ }
515
+ }
516
+ if (Symbol.dispose) SecureWasmKemContext.prototype[Symbol.dispose] = SecureWasmKemContext.prototype.free;
517
+
518
+ /**
519
+ * Secure WASM Signature Context
520
+ *
521
+ * This context provides secure signature operations with:
522
+ * - Consistent error handling using Result<T, JsValue>
523
+ * - Security validation for all inputs
524
+ * - Protection against timing attacks
525
+ * - Memory safety with automatic cleanup
526
+ */
527
+ export class SecureWasmSignatureContext {
528
+ __destroy_into_raw() {
529
+ const ptr = this.__wbg_ptr;
530
+ this.__wbg_ptr = 0;
531
+ SecureWasmSignatureContextFinalization.unregister(this);
532
+ return ptr;
533
+ }
534
+ free() {
535
+ const ptr = this.__destroy_into_raw();
536
+ wasm.__wbg_securewasmsignaturecontext_free(ptr, 0);
537
+ }
538
+ /**
539
+ * Generate a signature keypair
540
+ * @param {string} algorithm
541
+ * @param {Uint8Array | null} [randomness]
542
+ * @returns {any}
543
+ */
544
+ generate_keypair(algorithm, randomness) {
545
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
546
+ const len0 = WASM_VECTOR_LEN;
547
+ const ret = wasm.securewasmsignaturecontext_generate_keypair(this.__wbg_ptr, ptr0, len0, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
548
+ if (ret[2]) {
549
+ throw takeFromExternrefTable0(ret[1]);
550
+ }
551
+ return takeFromExternrefTable0(ret[0]);
552
+ }
553
+ /**
554
+ * Get supported algorithms
555
+ * @returns {any}
556
+ */
557
+ get_supported_algorithms() {
558
+ const ret = wasm.securewasmsignaturecontext_get_supported_algorithms(this.__wbg_ptr);
559
+ if (ret[2]) {
560
+ throw takeFromExternrefTable0(ret[1]);
561
+ }
562
+ return takeFromExternrefTable0(ret[0]);
563
+ }
564
+ /**
565
+ * Create a new secure WASM signature context
566
+ */
567
+ constructor() {
568
+ const ret = wasm.securewasmsignaturecontext_new();
569
+ if (ret[2]) {
570
+ throw takeFromExternrefTable0(ret[1]);
571
+ }
572
+ this.__wbg_ptr = ret[0];
573
+ SecureWasmSignatureContextFinalization.register(this, this.__wbg_ptr, this);
574
+ return this;
575
+ }
576
+ /**
577
+ * Sign a message
578
+ * @param {string} algorithm
579
+ * @param {Uint8Array} private_key
580
+ * @param {Uint8Array} message
581
+ * @param {Uint8Array | null} [randomness]
582
+ * @returns {any}
583
+ */
584
+ sign(algorithm, private_key, message, randomness) {
585
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
586
+ const len0 = WASM_VECTOR_LEN;
587
+ const ret = wasm.securewasmsignaturecontext_sign(this.__wbg_ptr, ptr0, len0, private_key, message, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
588
+ if (ret[2]) {
589
+ throw takeFromExternrefTable0(ret[1]);
590
+ }
591
+ return takeFromExternrefTable0(ret[0]);
592
+ }
593
+ /**
594
+ * Verify a signature
595
+ * @param {string} algorithm
596
+ * @param {Uint8Array} public_key
597
+ * @param {Uint8Array} message
598
+ * @param {Uint8Array} signature
599
+ * @returns {any}
600
+ */
601
+ verify(algorithm, public_key, message, signature) {
602
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
603
+ const len0 = WASM_VECTOR_LEN;
604
+ const ret = wasm.securewasmsignaturecontext_verify(this.__wbg_ptr, ptr0, len0, public_key, message, signature);
605
+ if (ret[2]) {
606
+ throw takeFromExternrefTable0(ret[1]);
607
+ }
608
+ return takeFromExternrefTable0(ret[0]);
609
+ }
610
+ }
611
+ if (Symbol.dispose) SecureWasmSignatureContext.prototype[Symbol.dispose] = SecureWasmSignatureContext.prototype.free;
612
+
613
+ /**
614
+ * Security levels for cryptographic algorithms
615
+ * @enum {1 | 3 | 4 | 5}
616
+ */
617
+ export const SecurityLevel = Object.freeze({
618
+ Level1: 1, "1": "Level1",
619
+ Level3: 3, "3": "Level3",
620
+ Level4: 4, "4": "Level4",
621
+ Level5: 5, "5": "Level5",
622
+ });
623
+
624
+ /**
625
+ * Signature keypair with automatic memory zeroization
626
+ */
627
+ export class SigKeypair {
628
+ __destroy_into_raw() {
629
+ const ptr = this.__wbg_ptr;
630
+ this.__wbg_ptr = 0;
631
+ SigKeypairFinalization.unregister(this);
632
+ return ptr;
633
+ }
634
+ free() {
635
+ const ptr = this.__destroy_into_raw();
636
+ wasm.__wbg_sigkeypair_free(ptr, 0);
637
+ }
638
+ }
639
+ if (Symbol.dispose) SigKeypair.prototype[Symbol.dispose] = SigKeypair.prototype.free;
640
+
641
+ /**
642
+ * Signature public key
643
+ */
644
+ export class SigPublicKey {
645
+ __destroy_into_raw() {
646
+ const ptr = this.__wbg_ptr;
647
+ this.__wbg_ptr = 0;
648
+ SigPublicKeyFinalization.unregister(this);
649
+ return ptr;
650
+ }
651
+ free() {
652
+ const ptr = this.__destroy_into_raw();
653
+ wasm.__wbg_sigpublickey_free(ptr, 0);
654
+ }
655
+ }
656
+ if (Symbol.dispose) SigPublicKey.prototype[Symbol.dispose] = SigPublicKey.prototype.free;
657
+
658
+ /**
659
+ * Signature secret key with automatic memory zeroization
660
+ */
661
+ export class SigSecretKey {
662
+ __destroy_into_raw() {
663
+ const ptr = this.__wbg_ptr;
664
+ this.__wbg_ptr = 0;
665
+ SigSecretKeyFinalization.unregister(this);
666
+ return ptr;
667
+ }
668
+ free() {
669
+ const ptr = this.__destroy_into_raw();
670
+ wasm.__wbg_sigsecretkey_free(ptr, 0);
671
+ }
672
+ }
673
+ if (Symbol.dispose) SigSecretKey.prototype[Symbol.dispose] = SigSecretKey.prototype.free;
674
+
675
+ /**
676
+ * WASM-compatible AEAD context wrapper
677
+ *
678
+ * This wrapper provides JavaScript-compatible bindings for AEAD operations:
679
+ * - Integrates with the new modular architecture
680
+ * - Includes security validation
681
+ * - Provides consistent error handling
682
+ * - Supports all AEAD algorithms
683
+ */
684
+ export class WasmAeadContext {
685
+ __destroy_into_raw() {
686
+ const ptr = this.__wbg_ptr;
687
+ this.__wbg_ptr = 0;
688
+ WasmAeadContextFinalization.unregister(this);
689
+ return ptr;
690
+ }
691
+ free() {
692
+ const ptr = this.__destroy_into_raw();
693
+ wasm.__wbg_wasmaeadcontext_free(ptr, 0);
694
+ }
695
+ }
696
+ if (Symbol.dispose) WasmAeadContext.prototype[Symbol.dispose] = WasmAeadContext.prototype.free;
697
+
698
+ /**
699
+ * WASM-compatible CryptoProvider wrapper
700
+ *
701
+ * This wrapper provides JavaScript-compatible bindings for the crypto provider:
702
+ * - Integrates with the new modular architecture
703
+ * - Provides consistent error handling
704
+ * - Supports all cryptographic operations
705
+ */
706
+ export class WasmCryptoProvider {
707
+ __destroy_into_raw() {
708
+ const ptr = this.__wbg_ptr;
709
+ this.__wbg_ptr = 0;
710
+ WasmCryptoProviderFinalization.unregister(this);
711
+ return ptr;
712
+ }
713
+ free() {
714
+ const ptr = this.__destroy_into_raw();
715
+ wasm.__wbg_wasmcryptoprovider_free(ptr, 0);
716
+ }
717
+ }
718
+ if (Symbol.dispose) WasmCryptoProvider.prototype[Symbol.dispose] = WasmCryptoProvider.prototype.free;
719
+
720
+ /**
721
+ * WASM-compatible Hash context wrapper
722
+ *
723
+ * This wrapper provides JavaScript-compatible bindings for hash operations:
724
+ * - Integrates with the new modular architecture
725
+ * - Includes security validation
726
+ * - Provides consistent error handling
727
+ * - Supports all hash algorithms
728
+ */
729
+ export class WasmHashContext {
730
+ __destroy_into_raw() {
731
+ const ptr = this.__wbg_ptr;
732
+ this.__wbg_ptr = 0;
733
+ WasmHashContextFinalization.unregister(this);
734
+ return ptr;
735
+ }
736
+ free() {
737
+ const ptr = this.__destroy_into_raw();
738
+ wasm.__wbg_wasmhashcontext_free(ptr, 0);
739
+ }
740
+ }
741
+ if (Symbol.dispose) WasmHashContext.prototype[Symbol.dispose] = WasmHashContext.prototype.free;
742
+
743
+ /**
744
+ * WASM-compatible KEM context wrapper
745
+ *
746
+ * This wrapper provides JavaScript-compatible bindings for KEM operations:
747
+ * - Integrates with the new modular architecture
748
+ * - Includes security validation
749
+ * - Provides consistent error handling
750
+ * - Supports all KEM algorithms
751
+ */
752
+ export class WasmKemContext {
753
+ __destroy_into_raw() {
754
+ const ptr = this.__wbg_ptr;
755
+ this.__wbg_ptr = 0;
756
+ WasmKemContextFinalization.unregister(this);
757
+ return ptr;
758
+ }
759
+ free() {
760
+ const ptr = this.__destroy_into_raw();
761
+ wasm.__wbg_wasmkemcontext_free(ptr, 0);
762
+ }
763
+ }
764
+ if (Symbol.dispose) WasmKemContext.prototype[Symbol.dispose] = WasmKemContext.prototype.free;
765
+
766
+ /**
767
+ * Generic WASM key pair implementation
768
+ */
769
+ export class WasmKeyPairImpl {
770
+ __destroy_into_raw() {
771
+ const ptr = this.__wbg_ptr;
772
+ this.__wbg_ptr = 0;
773
+ WasmKeyPairImplFinalization.unregister(this);
774
+ return ptr;
775
+ }
776
+ free() {
777
+ const ptr = this.__destroy_into_raw();
778
+ wasm.__wbg_wasmkeypairimpl_free(ptr, 0);
779
+ }
780
+ /**
781
+ * @param {Uint8Array} public_key
782
+ * @param {Uint8Array} secret_key
783
+ */
784
+ constructor(public_key, secret_key) {
785
+ const ret = wasm.wasmkeypairimpl_new(public_key, secret_key);
786
+ this.__wbg_ptr = ret;
787
+ WasmKeyPairImplFinalization.register(this, this.__wbg_ptr, this);
788
+ return this;
789
+ }
790
+ /**
791
+ * @returns {Uint8Array}
792
+ */
793
+ get public_key() {
794
+ const ret = wasm.wasmkeypairimpl_public_key(this.__wbg_ptr);
795
+ return ret;
796
+ }
797
+ /**
798
+ * @returns {Uint8Array}
799
+ */
800
+ get secret_key() {
801
+ const ret = wasm.wasmkeypairimpl_secret_key(this.__wbg_ptr);
802
+ return ret;
803
+ }
804
+ }
805
+ if (Symbol.dispose) WasmKeyPairImpl.prototype[Symbol.dispose] = WasmKeyPairImpl.prototype.free;
806
+
807
+ /**
808
+ * WASM-compatible provider factory
809
+ *
810
+ * This factory provides JavaScript-compatible bindings for creating providers:
811
+ * - Integrates with the new modular architecture
812
+ * - Provides consistent error handling
813
+ * - Supports all provider creation operations
814
+ */
815
+ export class WasmProviderFactory {
816
+ __destroy_into_raw() {
817
+ const ptr = this.__wbg_ptr;
818
+ this.__wbg_ptr = 0;
819
+ WasmProviderFactoryFinalization.unregister(this);
820
+ return ptr;
821
+ }
822
+ free() {
823
+ const ptr = this.__destroy_into_raw();
824
+ wasm.__wbg_wasmproviderfactory_free(ptr, 0);
825
+ }
826
+ /**
827
+ * Create a new provider manager
828
+ * @returns {WasmProviderManager}
829
+ */
830
+ static create_provider_manager() {
831
+ const ret = wasm.wasmproviderfactory_create_provider_manager();
832
+ return WasmProviderManager.__wrap(ret);
833
+ }
834
+ /**
835
+ * Create a provider manager with specific configuration
836
+ * @param {string} config
837
+ * @returns {WasmProviderManager}
838
+ */
839
+ static create_provider_manager_with_config(config) {
840
+ const ptr0 = passStringToWasm0(config, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
841
+ const len0 = WASM_VECTOR_LEN;
842
+ const ret = wasm.wasmproviderfactory_create_provider_manager_with_config(ptr0, len0);
843
+ if (ret[2]) {
844
+ throw takeFromExternrefTable0(ret[1]);
845
+ }
846
+ return WasmProviderManager.__wrap(ret[0]);
847
+ }
848
+ /**
849
+ * Get available provider types
850
+ * @returns {string}
851
+ */
852
+ static get_available_providers() {
853
+ let deferred1_0;
854
+ let deferred1_1;
855
+ try {
856
+ const ret = wasm.wasmproviderfactory_get_available_providers();
857
+ deferred1_0 = ret[0];
858
+ deferred1_1 = ret[1];
859
+ return getStringFromWasm0(ret[0], ret[1]);
860
+ } finally {
861
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
862
+ }
863
+ }
864
+ /**
865
+ * Validate provider configuration
866
+ * @param {string} config
867
+ * @returns {boolean}
868
+ */
869
+ static validate_provider_config(config) {
870
+ const ptr0 = passStringToWasm0(config, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
871
+ const len0 = WASM_VECTOR_LEN;
872
+ const ret = wasm.wasmproviderfactory_validate_provider_config(ptr0, len0);
873
+ if (ret[2]) {
874
+ throw takeFromExternrefTable0(ret[1]);
875
+ }
876
+ return ret[0] !== 0;
877
+ }
878
+ }
879
+ if (Symbol.dispose) WasmProviderFactory.prototype[Symbol.dispose] = WasmProviderFactory.prototype.free;
880
+
881
+ /**
882
+ * WASM-compatible provider manager
883
+ *
884
+ * This manager provides JavaScript-compatible bindings for provider operations:
885
+ * - Integrates with the new modular architecture
886
+ * - Includes security validation
887
+ * - Provides consistent error handling
888
+ * - Supports all provider operations
889
+ */
890
+ export class WasmProviderManager {
891
+ static __wrap(ptr) {
892
+ const obj = Object.create(WasmProviderManager.prototype);
893
+ obj.__wbg_ptr = ptr;
894
+ WasmProviderManagerFinalization.register(obj, obj.__wbg_ptr, obj);
895
+ return obj;
896
+ }
897
+ __destroy_into_raw() {
898
+ const ptr = this.__wbg_ptr;
899
+ this.__wbg_ptr = 0;
900
+ WasmProviderManagerFinalization.unregister(this);
901
+ return ptr;
902
+ }
903
+ free() {
904
+ const ptr = this.__destroy_into_raw();
905
+ wasm.__wbg_wasmprovidermanager_free(ptr, 0);
906
+ }
907
+ }
908
+ if (Symbol.dispose) WasmProviderManager.prototype[Symbol.dispose] = WasmProviderManager.prototype.free;
909
+
910
+ /**
911
+ * WASM-compatible Signature context wrapper
912
+ *
913
+ * This wrapper provides JavaScript-compatible bindings for signature operations:
914
+ * - Integrates with the new modular architecture
915
+ * - Includes security validation
916
+ * - Provides consistent error handling
917
+ * - Supports all signature algorithms
918
+ */
919
+ export class WasmSignatureContext {
920
+ __destroy_into_raw() {
921
+ const ptr = this.__wbg_ptr;
922
+ this.__wbg_ptr = 0;
923
+ WasmSignatureContextFinalization.unregister(this);
924
+ return ptr;
925
+ }
926
+ free() {
927
+ const ptr = this.__destroy_into_raw();
928
+ wasm.__wbg_wasmsignaturecontext_free(ptr, 0);
929
+ }
930
+ /**
931
+ * Generate a keypair for the specified algorithm
932
+ * @param {string} algorithm
933
+ * @param {Uint8Array | null} [randomness]
934
+ * @returns {any}
935
+ */
936
+ generate_keypair(algorithm, randomness) {
937
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
938
+ const len0 = WASM_VECTOR_LEN;
939
+ const ret = wasm.wasmsignaturecontext_generate_keypair(this.__wbg_ptr, ptr0, len0, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
940
+ if (ret[2]) {
941
+ throw takeFromExternrefTable0(ret[1]);
942
+ }
943
+ return takeFromExternrefTable0(ret[0]);
944
+ }
945
+ /**
946
+ * Check if an algorithm is supported
947
+ * @param {string} algorithm
948
+ * @returns {boolean}
949
+ */
950
+ is_algorithm_supported(algorithm) {
951
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
952
+ const len0 = WASM_VECTOR_LEN;
953
+ const ret = wasm.wasmsignaturecontext_is_algorithm_supported(this.__wbg_ptr, ptr0, len0);
954
+ return ret !== 0;
955
+ }
956
+ /**
957
+ * Get the security level of the context
958
+ * @returns {number}
959
+ */
960
+ security_level() {
961
+ const ret = wasm.wasmsignaturecontext_security_level(this.__wbg_ptr);
962
+ return ret >>> 0;
963
+ }
964
+ /**
965
+ * Sign a message using the given secret key
966
+ * @param {string} algorithm
967
+ * @param {Uint8Array} secret_key_data
968
+ * @param {Uint8Array} message
969
+ * @param {Uint8Array | null} [randomness]
970
+ * @returns {Uint8Array}
971
+ */
972
+ sign(algorithm, secret_key_data, message, randomness) {
973
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
974
+ const len0 = WASM_VECTOR_LEN;
975
+ const ret = wasm.wasmsignaturecontext_sign(this.__wbg_ptr, ptr0, len0, secret_key_data, message, isLikeNone(randomness) ? 0 : addToExternrefTable0(randomness));
976
+ if (ret[3]) {
977
+ throw takeFromExternrefTable0(ret[2]);
978
+ }
979
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
980
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
981
+ return v2;
982
+ }
983
+ /**
984
+ * Get supported algorithms
985
+ * @returns {string}
986
+ */
987
+ supported_algorithms() {
988
+ let deferred1_0;
989
+ let deferred1_1;
990
+ try {
991
+ const ret = wasm.wasmsignaturecontext_supported_algorithms(this.__wbg_ptr);
992
+ deferred1_0 = ret[0];
993
+ deferred1_1 = ret[1];
994
+ return getStringFromWasm0(ret[0], ret[1]);
995
+ } finally {
996
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
997
+ }
998
+ }
999
+ /**
1000
+ * Verify a signature using the given public key
1001
+ * @param {string} algorithm
1002
+ * @param {Uint8Array} public_key_data
1003
+ * @param {Uint8Array} message
1004
+ * @param {Uint8Array} signature
1005
+ * @returns {boolean}
1006
+ */
1007
+ verify(algorithm, public_key_data, message, signature) {
1008
+ const ptr0 = passStringToWasm0(algorithm, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1009
+ const len0 = WASM_VECTOR_LEN;
1010
+ const ret = wasm.wasmsignaturecontext_verify(this.__wbg_ptr, ptr0, len0, public_key_data, message, signature);
1011
+ if (ret[2]) {
1012
+ throw takeFromExternrefTable0(ret[1]);
1013
+ }
1014
+ return ret[0] !== 0;
1015
+ }
1016
+ }
1017
+ if (Symbol.dispose) WasmSignatureContext.prototype[Symbol.dispose] = WasmSignatureContext.prototype.free;
1018
+
1019
+ /**
1020
+ * Convert bytes to hexadecimal string
1021
+ *
1022
+ * This function provides secure hex encoding for WASM:
1023
+ * - Uses constant-time operations where possible
1024
+ * - Handles large data efficiently
1025
+ * - Returns JavaScript string
1026
+ * @param {Uint8Array} data
1027
+ * @returns {string}
1028
+ */
1029
+ export function bytes_to_hex(data) {
1030
+ let deferred1_0;
1031
+ let deferred1_1;
1032
+ try {
1033
+ const ret = wasm.bytes_to_hex(data);
1034
+ deferred1_0 = ret[0];
1035
+ deferred1_1 = ret[1];
1036
+ return getStringFromWasm0(ret[0], ret[1]);
1037
+ } finally {
1038
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1039
+ }
1040
+ }
1041
+
1042
+ /**
1043
+ * Get library information for WASM
1044
+ *
1045
+ * This function provides library metadata for JavaScript consumption
1046
+ * @returns {string}
1047
+ */
1048
+ export function get_library_info() {
1049
+ let deferred1_0;
1050
+ let deferred1_1;
1051
+ try {
1052
+ const ret = wasm.get_library_info();
1053
+ deferred1_0 = ret[0];
1054
+ deferred1_1 = ret[1];
1055
+ return getStringFromWasm0(ret[0], ret[1]);
1056
+ } finally {
1057
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1058
+ }
1059
+ }
1060
+
1061
+ /**
1062
+ * Get supported algorithms by category
1063
+ *
1064
+ * This function provides algorithm information for JavaScript
1065
+ * @returns {string}
1066
+ */
1067
+ export function get_supported_algorithms() {
1068
+ let deferred1_0;
1069
+ let deferred1_1;
1070
+ try {
1071
+ const ret = wasm.get_supported_algorithms();
1072
+ deferred1_0 = ret[0];
1073
+ deferred1_1 = ret[1];
1074
+ return getStringFromWasm0(ret[0], ret[1]);
1075
+ } finally {
1076
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1077
+ }
1078
+ }
1079
+
1080
+ /**
1081
+ * Gold PRF on the 256-bit pilot parameters; inputs are **big-endian** 32-byte field elements.
1082
+ * Returns hex-encoded 32-byte little-endian output residue.
1083
+ * @param {string} key_be_hex
1084
+ * @param {string} x_be_hex
1085
+ * @returns {any}
1086
+ */
1087
+ export function goldPrfU256BeHex(key_be_hex, x_be_hex) {
1088
+ const ptr0 = passStringToWasm0(key_be_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1089
+ const len0 = WASM_VECTOR_LEN;
1090
+ const ptr1 = passStringToWasm0(x_be_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1091
+ const len1 = WASM_VECTOR_LEN;
1092
+ const ret = wasm.goldPrfU256BeHex(ptr0, len0, ptr1, len1);
1093
+ if (ret[2]) {
1094
+ throw takeFromExternrefTable0(ret[1]);
1095
+ }
1096
+ return takeFromExternrefTable0(ret[0]);
1097
+ }
1098
+
1099
+ /**
1100
+ * Convert hexadecimal string to bytes
1101
+ *
1102
+ * This function provides secure hex decoding for WASM:
1103
+ * - Validates hex string format
1104
+ * - Handles errors gracefully
1105
+ * - Returns Uint8Array
1106
+ * @param {string} hex
1107
+ * @returns {Uint8Array}
1108
+ */
1109
+ export function hex_to_bytes(hex) {
1110
+ const ptr0 = passStringToWasm0(hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1111
+ const len0 = WASM_VECTOR_LEN;
1112
+ const ret = wasm.hex_to_bytes(ptr0, len0);
1113
+ if (ret[2]) {
1114
+ throw takeFromExternrefTable0(ret[1]);
1115
+ }
1116
+ return takeFromExternrefTable0(ret[0]);
1117
+ }
1118
+
1119
+ /**
1120
+ * Check if a feature is available
1121
+ *
1122
+ * This function allows JavaScript to check feature availability
1123
+ * @param {string} feature
1124
+ * @returns {boolean}
1125
+ */
1126
+ export function is_feature_available(feature) {
1127
+ const ptr0 = passStringToWasm0(feature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1128
+ const len0 = WASM_VECTOR_LEN;
1129
+ const ret = wasm.is_feature_available(ptr0, len0);
1130
+ return ret !== 0;
1131
+ }
1132
+
1133
+ /**
1134
+ * Legendre PRF on the 256-bit pilot modulus; `key` and `x` are **big-endian** 32-byte field elements (64 hex chars each).
1135
+ * @param {string} key_be_hex
1136
+ * @param {string} x_be_hex
1137
+ * @returns {number}
1138
+ */
1139
+ export function legendrePrfU256BeHex(key_be_hex, x_be_hex) {
1140
+ const ptr0 = passStringToWasm0(key_be_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1141
+ const len0 = WASM_VECTOR_LEN;
1142
+ const ptr1 = passStringToWasm0(x_be_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1143
+ const len1 = WASM_VECTOR_LEN;
1144
+ const ret = wasm.legendrePrfU256BeHex(ptr0, len0, ptr1, len1);
1145
+ if (ret[2]) {
1146
+ throw takeFromExternrefTable0(ret[1]);
1147
+ }
1148
+ return ret[0];
1149
+ }
1150
+
1151
+ /**
1152
+ * Generate cryptographically secure random bytes for WASM
1153
+ *
1154
+ * This function provides secure random generation in WASM environments:
1155
+ * - Uses the browser's crypto.getRandomValues() API
1156
+ * - Validates input size to prevent DoS attacks
1157
+ * - Returns Uint8Array for direct JavaScript consumption
1158
+ * @param {number} length
1159
+ * @returns {Uint8Array}
1160
+ */
1161
+ export function random_bytes(length) {
1162
+ const ret = wasm.random_bytes(length);
1163
+ if (ret[2]) {
1164
+ throw takeFromExternrefTable0(ret[1]);
1165
+ }
1166
+ return takeFromExternrefTable0(ret[0]);
1167
+ }
1168
+
1169
+ /**
1170
+ * Validate input data for WASM operations
1171
+ *
1172
+ * This function provides comprehensive input validation:
1173
+ * - Checks for null/undefined values
1174
+ * - Validates data size limits
1175
+ * - Ensures data is not empty when required
1176
+ * @param {Uint8Array} data
1177
+ * @param {number | null} [min_size]
1178
+ * @param {number | null} [max_size]
1179
+ * @returns {boolean}
1180
+ */
1181
+ export function validate_input(data, min_size, max_size) {
1182
+ 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);
1183
+ if (ret[2]) {
1184
+ throw takeFromExternrefTable0(ret[1]);
1185
+ }
1186
+ return ret[0] !== 0;
1187
+ }
1188
+ function __wbg_get_imports() {
1189
+ const import0 = {
1190
+ __proto__: null,
1191
+ __wbg_Error_bce6d499ff0a4aff: function(arg0, arg1) {
1192
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1193
+ return ret;
1194
+ },
1195
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
1196
+ const ret = String(arg1);
1197
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1198
+ const len1 = WASM_VECTOR_LEN;
1199
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1200
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1201
+ },
1202
+ __wbg___wbindgen_debug_string_edece8177ad01481: function(arg0, arg1) {
1203
+ const ret = debugString(arg1);
1204
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1205
+ const len1 = WASM_VECTOR_LEN;
1206
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1207
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1208
+ },
1209
+ __wbg___wbindgen_is_string_dde0fd9020db4434: function(arg0) {
1210
+ const ret = typeof(arg0) === 'string';
1211
+ return ret;
1212
+ },
1213
+ __wbg___wbindgen_throw_9c31b086c2b26051: function(arg0, arg1) {
1214
+ throw new Error(getStringFromWasm0(arg0, arg1));
1215
+ },
1216
+ __wbg_getRandomValues_76dfc69825c9c552: function() { return handleError(function (arg0, arg1) {
1217
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
1218
+ }, arguments); },
1219
+ __wbg_get_index_c051becca25aa6d8: function(arg0, arg1) {
1220
+ const ret = arg0[arg1 >>> 0];
1221
+ return ret;
1222
+ },
1223
+ __wbg_length_56fcd3e2b7e0299d: function(arg0) {
1224
+ const ret = arg0.length;
1225
+ return ret;
1226
+ },
1227
+ __wbg_new_02d162bc6cf02f60: function() {
1228
+ const ret = new Object();
1229
+ return ret;
1230
+ },
1231
+ __wbg_new_070df68d66325372: function() {
1232
+ const ret = new Map();
1233
+ return ret;
1234
+ },
1235
+ __wbg_new_310879b66b6e95e1: function() {
1236
+ const ret = new Array();
1237
+ return ret;
1238
+ },
1239
+ __wbg_new_with_length_99887c91eae4abab: function(arg0) {
1240
+ const ret = new Uint8Array(arg0 >>> 0);
1241
+ return ret;
1242
+ },
1243
+ __wbg_prototypesetcall_5f9bdc8d75e07276: function(arg0, arg1, arg2) {
1244
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1245
+ },
1246
+ __wbg_set_24d0fa9e104112f9: function(arg0, arg1, arg2) {
1247
+ arg0.set(getArrayU8FromWasm0(arg1, arg2));
1248
+ },
1249
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
1250
+ arg0[arg1] = arg2;
1251
+ },
1252
+ __wbg_set_78ea6a19f4818587: function(arg0, arg1, arg2) {
1253
+ arg0[arg1 >>> 0] = arg2;
1254
+ },
1255
+ __wbg_set_facb7a5914e0fa39: function(arg0, arg1, arg2) {
1256
+ const ret = arg0.set(arg1, arg2);
1257
+ return ret;
1258
+ },
1259
+ __wbg_set_index_6216eb6926d2fbc6: function(arg0, arg1, arg2) {
1260
+ arg0[arg1 >>> 0] = arg2;
1261
+ },
1262
+ __wbindgen_cast_0000000000000001: function(arg0) {
1263
+ // Cast intrinsic for `F64 -> Externref`.
1264
+ const ret = arg0;
1265
+ return ret;
1266
+ },
1267
+ __wbindgen_cast_0000000000000002: function(arg0) {
1268
+ // Cast intrinsic for `I64 -> Externref`.
1269
+ const ret = arg0;
1270
+ return ret;
1271
+ },
1272
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1273
+ // Cast intrinsic for `Ref(String) -> Externref`.
1274
+ const ret = getStringFromWasm0(arg0, arg1);
1275
+ return ret;
1276
+ },
1277
+ __wbindgen_cast_0000000000000004: function(arg0) {
1278
+ // Cast intrinsic for `U64 -> Externref`.
1279
+ const ret = BigInt.asUintN(64, arg0);
1280
+ return ret;
1281
+ },
1282
+ __wbindgen_init_externref_table: function() {
1283
+ const table = wasm.__wbindgen_externrefs;
1284
+ const offset = table.grow(4);
1285
+ table.set(0, undefined);
1286
+ table.set(offset + 0, undefined);
1287
+ table.set(offset + 1, null);
1288
+ table.set(offset + 2, true);
1289
+ table.set(offset + 3, false);
1290
+ },
1291
+ };
1292
+ return {
1293
+ __proto__: null,
1294
+ "./lib_q_prf_bg.js": import0,
1295
+ };
1296
+ }
1297
+
1298
+ const HashResultWasmFinalization = (typeof FinalizationRegistry === 'undefined')
1299
+ ? { register: () => {}, unregister: () => {} }
1300
+ : new FinalizationRegistry(ptr => wasm.__wbg_hashresultwasm_free(ptr, 1));
1301
+ const KemKeypairFinalization = (typeof FinalizationRegistry === 'undefined')
1302
+ ? { register: () => {}, unregister: () => {} }
1303
+ : new FinalizationRegistry(ptr => wasm.__wbg_kemkeypair_free(ptr, 1));
1304
+ const KemPublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1305
+ ? { register: () => {}, unregister: () => {} }
1306
+ : new FinalizationRegistry(ptr => wasm.__wbg_kempublickey_free(ptr, 1));
1307
+ const KemSecretKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1308
+ ? { register: () => {}, unregister: () => {} }
1309
+ : new FinalizationRegistry(ptr => wasm.__wbg_kemsecretkey_free(ptr, 1));
1310
+ const SecureWasmAeadContextFinalization = (typeof FinalizationRegistry === 'undefined')
1311
+ ? { register: () => {}, unregister: () => {} }
1312
+ : new FinalizationRegistry(ptr => wasm.__wbg_securewasmaeadcontext_free(ptr, 1));
1313
+ const SecureWasmHashContextFinalization = (typeof FinalizationRegistry === 'undefined')
1314
+ ? { register: () => {}, unregister: () => {} }
1315
+ : new FinalizationRegistry(ptr => wasm.__wbg_securewasmhashcontext_free(ptr, 1));
1316
+ const SecureWasmKemContextFinalization = (typeof FinalizationRegistry === 'undefined')
1317
+ ? { register: () => {}, unregister: () => {} }
1318
+ : new FinalizationRegistry(ptr => wasm.__wbg_securewasmkemcontext_free(ptr, 1));
1319
+ const SecureWasmSignatureContextFinalization = (typeof FinalizationRegistry === 'undefined')
1320
+ ? { register: () => {}, unregister: () => {} }
1321
+ : new FinalizationRegistry(ptr => wasm.__wbg_securewasmsignaturecontext_free(ptr, 1));
1322
+ const SigKeypairFinalization = (typeof FinalizationRegistry === 'undefined')
1323
+ ? { register: () => {}, unregister: () => {} }
1324
+ : new FinalizationRegistry(ptr => wasm.__wbg_sigkeypair_free(ptr, 1));
1325
+ const SigPublicKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1326
+ ? { register: () => {}, unregister: () => {} }
1327
+ : new FinalizationRegistry(ptr => wasm.__wbg_sigpublickey_free(ptr, 1));
1328
+ const SigSecretKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1329
+ ? { register: () => {}, unregister: () => {} }
1330
+ : new FinalizationRegistry(ptr => wasm.__wbg_sigsecretkey_free(ptr, 1));
1331
+ const WasmAeadContextFinalization = (typeof FinalizationRegistry === 'undefined')
1332
+ ? { register: () => {}, unregister: () => {} }
1333
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmaeadcontext_free(ptr, 1));
1334
+ const WasmCryptoProviderFinalization = (typeof FinalizationRegistry === 'undefined')
1335
+ ? { register: () => {}, unregister: () => {} }
1336
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmcryptoprovider_free(ptr, 1));
1337
+ const WasmHashContextFinalization = (typeof FinalizationRegistry === 'undefined')
1338
+ ? { register: () => {}, unregister: () => {} }
1339
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmhashcontext_free(ptr, 1));
1340
+ const WasmKemContextFinalization = (typeof FinalizationRegistry === 'undefined')
1341
+ ? { register: () => {}, unregister: () => {} }
1342
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmkemcontext_free(ptr, 1));
1343
+ const WasmKeyPairImplFinalization = (typeof FinalizationRegistry === 'undefined')
1344
+ ? { register: () => {}, unregister: () => {} }
1345
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmkeypairimpl_free(ptr, 1));
1346
+ const WasmProviderFactoryFinalization = (typeof FinalizationRegistry === 'undefined')
1347
+ ? { register: () => {}, unregister: () => {} }
1348
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmproviderfactory_free(ptr, 1));
1349
+ const WasmProviderManagerFinalization = (typeof FinalizationRegistry === 'undefined')
1350
+ ? { register: () => {}, unregister: () => {} }
1351
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmprovidermanager_free(ptr, 1));
1352
+ const WasmSignatureContextFinalization = (typeof FinalizationRegistry === 'undefined')
1353
+ ? { register: () => {}, unregister: () => {} }
1354
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmsignaturecontext_free(ptr, 1));
1355
+
1356
+ function addToExternrefTable0(obj) {
1357
+ const idx = wasm.__externref_table_alloc();
1358
+ wasm.__wbindgen_externrefs.set(idx, obj);
1359
+ return idx;
1360
+ }
1361
+
1362
+ function debugString(val) {
1363
+ // primitive types
1364
+ const type = typeof val;
1365
+ if (type == 'number' || type == 'boolean' || val == null) {
1366
+ return `${val}`;
1367
+ }
1368
+ if (type == 'string') {
1369
+ return `"${val}"`;
1370
+ }
1371
+ if (type == 'symbol') {
1372
+ const description = val.description;
1373
+ if (description == null) {
1374
+ return 'Symbol';
1375
+ } else {
1376
+ return `Symbol(${description})`;
1377
+ }
1378
+ }
1379
+ if (type == 'function') {
1380
+ const name = val.name;
1381
+ if (typeof name == 'string' && name.length > 0) {
1382
+ return `Function(${name})`;
1383
+ } else {
1384
+ return 'Function';
1385
+ }
1386
+ }
1387
+ // objects
1388
+ if (Array.isArray(val)) {
1389
+ const length = val.length;
1390
+ let debug = '[';
1391
+ if (length > 0) {
1392
+ debug += debugString(val[0]);
1393
+ }
1394
+ for(let i = 1; i < length; i++) {
1395
+ debug += ', ' + debugString(val[i]);
1396
+ }
1397
+ debug += ']';
1398
+ return debug;
1399
+ }
1400
+ // Test for built-in
1401
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1402
+ let className;
1403
+ if (builtInMatches && builtInMatches.length > 1) {
1404
+ className = builtInMatches[1];
1405
+ } else {
1406
+ // Failed to match the standard '[object ClassName]'
1407
+ return toString.call(val);
1408
+ }
1409
+ if (className == 'Object') {
1410
+ // we're a user defined class or Object
1411
+ // JSON.stringify avoids problems with cycles, and is generally much
1412
+ // easier than looping through ownProperties of `val`.
1413
+ try {
1414
+ return 'Object(' + JSON.stringify(val) + ')';
1415
+ } catch (_) {
1416
+ return 'Object';
1417
+ }
1418
+ }
1419
+ // errors
1420
+ if (val instanceof Error) {
1421
+ return `${val.name}: ${val.message}\n${val.stack}`;
1422
+ }
1423
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1424
+ return className;
1425
+ }
1426
+
1427
+ function getArrayU8FromWasm0(ptr, len) {
1428
+ ptr = ptr >>> 0;
1429
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1430
+ }
1431
+
1432
+ let cachedDataViewMemory0 = null;
1433
+ function getDataViewMemory0() {
1434
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1435
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1436
+ }
1437
+ return cachedDataViewMemory0;
1438
+ }
1439
+
1440
+ function getStringFromWasm0(ptr, len) {
1441
+ return decodeText(ptr >>> 0, len);
1442
+ }
1443
+
1444
+ let cachedUint8ArrayMemory0 = null;
1445
+ function getUint8ArrayMemory0() {
1446
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1447
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1448
+ }
1449
+ return cachedUint8ArrayMemory0;
1450
+ }
1451
+
1452
+ function handleError(f, args) {
1453
+ try {
1454
+ return f.apply(this, args);
1455
+ } catch (e) {
1456
+ const idx = addToExternrefTable0(e);
1457
+ wasm.__wbindgen_exn_store(idx);
1458
+ }
1459
+ }
1460
+
1461
+ function isLikeNone(x) {
1462
+ return x === undefined || x === null;
1463
+ }
1464
+
1465
+ function passArray8ToWasm0(arg, malloc) {
1466
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1467
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1468
+ WASM_VECTOR_LEN = arg.length;
1469
+ return ptr;
1470
+ }
1471
+
1472
+ function passStringToWasm0(arg, malloc, realloc) {
1473
+ if (realloc === undefined) {
1474
+ const buf = cachedTextEncoder.encode(arg);
1475
+ const ptr = malloc(buf.length, 1) >>> 0;
1476
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1477
+ WASM_VECTOR_LEN = buf.length;
1478
+ return ptr;
1479
+ }
1480
+
1481
+ let len = arg.length;
1482
+ let ptr = malloc(len, 1) >>> 0;
1483
+
1484
+ const mem = getUint8ArrayMemory0();
1485
+
1486
+ let offset = 0;
1487
+
1488
+ for (; offset < len; offset++) {
1489
+ const code = arg.charCodeAt(offset);
1490
+ if (code > 0x7F) break;
1491
+ mem[ptr + offset] = code;
1492
+ }
1493
+ if (offset !== len) {
1494
+ if (offset !== 0) {
1495
+ arg = arg.slice(offset);
1496
+ }
1497
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1498
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1499
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1500
+
1501
+ offset += ret.written;
1502
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1503
+ }
1504
+
1505
+ WASM_VECTOR_LEN = offset;
1506
+ return ptr;
1507
+ }
1508
+
1509
+ function takeFromExternrefTable0(idx) {
1510
+ const value = wasm.__wbindgen_externrefs.get(idx);
1511
+ wasm.__externref_table_dealloc(idx);
1512
+ return value;
1513
+ }
1514
+
1515
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1516
+ cachedTextDecoder.decode();
1517
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1518
+ let numBytesDecoded = 0;
1519
+ function decodeText(ptr, len) {
1520
+ numBytesDecoded += len;
1521
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1522
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1523
+ cachedTextDecoder.decode();
1524
+ numBytesDecoded = len;
1525
+ }
1526
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1527
+ }
1528
+
1529
+ const cachedTextEncoder = new TextEncoder();
1530
+
1531
+ if (!('encodeInto' in cachedTextEncoder)) {
1532
+ cachedTextEncoder.encodeInto = function (arg, view) {
1533
+ const buf = cachedTextEncoder.encode(arg);
1534
+ view.set(buf);
1535
+ return {
1536
+ read: arg.length,
1537
+ written: buf.length
1538
+ };
1539
+ };
1540
+ }
1541
+
1542
+ let WASM_VECTOR_LEN = 0;
1543
+
1544
+ let wasmModule, wasmInstance, wasm;
1545
+ function __wbg_finalize_init(instance, module) {
1546
+ wasmInstance = instance;
1547
+ wasm = instance.exports;
1548
+ wasmModule = module;
1549
+ cachedDataViewMemory0 = null;
1550
+ cachedUint8ArrayMemory0 = null;
1551
+ wasm.__wbindgen_start();
1552
+ return wasm;
1553
+ }
1554
+
1555
+ async function __wbg_load(module, imports) {
1556
+ if (typeof Response === 'function' && module instanceof Response) {
1557
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1558
+ try {
1559
+ return await WebAssembly.instantiateStreaming(module, imports);
1560
+ } catch (e) {
1561
+ const validResponse = module.ok && expectedResponseType(module.type);
1562
+
1563
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1564
+ 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);
1565
+
1566
+ } else { throw e; }
1567
+ }
1568
+ }
1569
+
1570
+ const bytes = await module.arrayBuffer();
1571
+ return await WebAssembly.instantiate(bytes, imports);
1572
+ } else {
1573
+ const instance = await WebAssembly.instantiate(module, imports);
1574
+
1575
+ if (instance instanceof WebAssembly.Instance) {
1576
+ return { instance, module };
1577
+ } else {
1578
+ return instance;
1579
+ }
1580
+ }
1581
+
1582
+ function expectedResponseType(type) {
1583
+ switch (type) {
1584
+ case 'basic': case 'cors': case 'default': return true;
1585
+ }
1586
+ return false;
1587
+ }
1588
+ }
1589
+
1590
+ function initSync(module) {
1591
+ if (wasm !== undefined) return wasm;
1592
+
1593
+
1594
+ if (module !== undefined) {
1595
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1596
+ ({module} = module)
1597
+ } else {
1598
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1599
+ }
1600
+ }
1601
+
1602
+ const imports = __wbg_get_imports();
1603
+ if (!(module instanceof WebAssembly.Module)) {
1604
+ module = new WebAssembly.Module(module);
1605
+ }
1606
+ const instance = new WebAssembly.Instance(module, imports);
1607
+ return __wbg_finalize_init(instance, module);
1608
+ }
1609
+
1610
+ async function __wbg_init(module_or_path) {
1611
+ if (wasm !== undefined) return wasm;
1612
+
1613
+
1614
+ if (module_or_path !== undefined) {
1615
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1616
+ ({module_or_path} = module_or_path)
1617
+ } else {
1618
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1619
+ }
1620
+ }
1621
+
1622
+ if (module_or_path === undefined) {
1623
+ module_or_path = new URL('lib_q_prf_bg.wasm', import.meta.url);
1624
+ }
1625
+ const imports = __wbg_get_imports();
1626
+
1627
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1628
+ module_or_path = fetch(module_or_path);
1629
+ }
1630
+
1631
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1632
+
1633
+ return __wbg_finalize_init(instance, module);
1634
+ }
1635
+
1636
+ export { initSync, __wbg_init as default };