@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.d.ts ADDED
@@ -0,0 +1,958 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Algorithm identifiers for cryptographic operations
6
+ */
7
+ export enum Algorithm {
8
+ MlKem512 = 0,
9
+ MlKem768 = 1,
10
+ MlKem1024 = 2,
11
+ CbKem348864 = 3,
12
+ CbKem460896 = 4,
13
+ CbKem6688128 = 5,
14
+ CbKem6960119 = 6,
15
+ CbKem8192128 = 7,
16
+ Hqc128 = 8,
17
+ Hqc192 = 9,
18
+ Hqc256 = 10,
19
+ MlDsa44 = 11,
20
+ MlDsa65 = 12,
21
+ MlDsa87 = 13,
22
+ FnDsa = 14,
23
+ FnDsa512 = 15,
24
+ FnDsa1024 = 16,
25
+ SlhDsaSha256128fRobust = 17,
26
+ SlhDsaSha256192fRobust = 18,
27
+ SlhDsaSha256256fRobust = 19,
28
+ SlhDsaShake256128fRobust = 20,
29
+ SlhDsaShake256192fRobust = 21,
30
+ SlhDsaShake256256fRobust = 22,
31
+ Shake128 = 23,
32
+ Shake256 = 24,
33
+ CShake128 = 25,
34
+ CShake256 = 26,
35
+ Sha3_224 = 27,
36
+ Sha3_256 = 28,
37
+ Sha3_384 = 29,
38
+ Sha3_512 = 30,
39
+ Keccak224 = 31,
40
+ Keccak256 = 32,
41
+ Keccak384 = 33,
42
+ Keccak512 = 34,
43
+ Kt128 = 35,
44
+ Kt256 = 36,
45
+ TurboShake128 = 37,
46
+ TurboShake256 = 38,
47
+ Kmac128 = 39,
48
+ Kmac256 = 40,
49
+ TupleHash128 = 41,
50
+ TupleHash256 = 42,
51
+ ParallelHash128 = 43,
52
+ ParallelHash256 = 44,
53
+ Sha224 = 45,
54
+ Sha256 = 46,
55
+ Sha384 = 47,
56
+ Sha512 = 48,
57
+ Sha512_224 = 49,
58
+ Sha512_256 = 50,
59
+ Saturnin = 51,
60
+ Shake256Aead = 52,
61
+ DuplexSpongeAead = 53,
62
+ TweakAead = 54,
63
+ RomulusN = 55,
64
+ RomulusM = 56,
65
+ /**
66
+ * Privacy-protocol identifiers (not standalone KEM/sig/hash providers).
67
+ */
68
+ LatticeRingSignature = 57,
69
+ LatticeBlindIssuance = 58,
70
+ LatticeAnonymousToken = 59,
71
+ LatticeNullifierRegistry = 60,
72
+ /**
73
+ * Witness-derived nullifier mode (SHAKE256 over opening witness wire; see `lib-q-lattice-zkp`).
74
+ */
75
+ LatticeWitnessNullifier = 61,
76
+ /**
77
+ * DualRing-LB (CCS 2021 Alg. 3 aggregated verify on Ajtai openings, `lib-q-ring-sig`).
78
+ */
79
+ LatticeDualRingLb = 62,
80
+ /**
81
+ * ML-KEM-768 layered encapsulation with Saturnin AEAD per hop (mix-layer transport).
82
+ */
83
+ MixOnionRouting = 63,
84
+ /**
85
+ * SHAKE256 session token and stateless retry-cookie derivation for resumption handshakes.
86
+ */
87
+ SessionResumptionBinding = 64,
88
+ }
89
+
90
+ /**
91
+ * Algorithm categories
92
+ */
93
+ export enum AlgorithmCategory {
94
+ Kem = 0,
95
+ Signature = 1,
96
+ Hash = 2,
97
+ Aead = 3,
98
+ /**
99
+ * Anonymous credentials, mix-layer transport helpers, and related ZKP-adjacent protocols.
100
+ */
101
+ PrivacyProtocol = 4,
102
+ }
103
+
104
+ /**
105
+ * WASM-compatible hash result
106
+ */
107
+ export class HashResultWasm {
108
+ free(): void;
109
+ [Symbol.dispose](): void;
110
+ constructor(hash: Uint8Array, algorithm: string);
111
+ readonly algorithm: string;
112
+ readonly hash: Uint8Array;
113
+ }
114
+
115
+ /**
116
+ * KEM keypair with automatic memory zeroization
117
+ */
118
+ export class KemKeypair {
119
+ free(): void;
120
+ [Symbol.dispose](): void;
121
+ /**
122
+ * Create a new KEM keypair from bytes for WASM
123
+ */
124
+ constructor(public_key: Uint8Array, secret_key: Uint8Array);
125
+ /**
126
+ * Get the public key as bytes for WASM
127
+ */
128
+ public_key_bytes(): Uint8Array;
129
+ /**
130
+ * Copy the secret key into a new `Uint8Array` for WASM (avoids returning an owned non-zeroizing `Vec<u8>`).
131
+ */
132
+ secret_key_bytes(): Uint8Array;
133
+ }
134
+
135
+ /**
136
+ * KEM public key
137
+ */
138
+ export class KemPublicKey {
139
+ free(): void;
140
+ [Symbol.dispose](): void;
141
+ /**
142
+ * Get the key data as bytes for WASM
143
+ */
144
+ bytes(): Uint8Array;
145
+ /**
146
+ * Create a new KEM public key from bytes for WASM
147
+ */
148
+ constructor(data: Uint8Array);
149
+ }
150
+
151
+ /**
152
+ * KEM secret key with automatic memory zeroization
153
+ */
154
+ export class KemSecretKey {
155
+ free(): void;
156
+ [Symbol.dispose](): void;
157
+ /**
158
+ * Copy the key material into a new `Uint8Array` for WASM (avoids returning an owned non-zeroizing `Vec<u8>`).
159
+ */
160
+ bytes(): Uint8Array;
161
+ /**
162
+ * Create a new KEM secret key from bytes for WASM
163
+ */
164
+ constructor(data: Uint8Array);
165
+ }
166
+
167
+ /**
168
+ * CRYSTALS-ML-DSA signature implementation
169
+ *
170
+ * This implementation provides both high-level (std) and low-level (no_std) APIs
171
+ * following the lib-q architecture pattern for maximum flexibility.
172
+ */
173
+ export class MlDsa {
174
+ private constructor();
175
+ free(): void;
176
+ [Symbol.dispose](): void;
177
+ /**
178
+ * Generate a keypair for WASM (JavaScript) environment
179
+ *
180
+ * # Arguments
181
+ * * `randomness` - Optional randomness as Uint8Array
182
+ *
183
+ * # Returns
184
+ * * `Result<WasmMlDsaKeyPair, JsValue>` - The keypair or error
185
+ */
186
+ generate_keypair_wasm(randomness?: Uint8Array | null): WasmMlDsaKeyPair;
187
+ /**
188
+ * Sign a message in WASM (JavaScript) environment
189
+ *
190
+ * # Arguments
191
+ * * `secret_key` - The secret key as Uint8Array
192
+ * * `message` - The message to sign as Uint8Array
193
+ * * `randomness` - Optional randomness as Uint8Array
194
+ *
195
+ * # Returns
196
+ * * `Result<Uint8Array, JsValue>` - The signature or error
197
+ */
198
+ sign_wasm(secret_key: Uint8Array, message: Uint8Array, randomness?: Uint8Array | null): Uint8Array;
199
+ /**
200
+ * Verify a signature in WASM (JavaScript) environment
201
+ *
202
+ * # Arguments
203
+ * * `public_key` - The public key as Uint8Array
204
+ * * `message` - The message as Uint8Array
205
+ * * `signature` - The signature to verify as Uint8Array
206
+ *
207
+ * # Returns
208
+ * * `Result<bool, JsValue>` - Verification result or error
209
+ */
210
+ verify_wasm(public_key: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
211
+ }
212
+
213
+ /**
214
+ * Secure WASM AEAD Context
215
+ *
216
+ * This context provides secure AEAD operations with:
217
+ * - Consistent error handling using Result<T, JsValue>
218
+ * - Security validation for all inputs
219
+ * - Protection against timing attacks
220
+ * - Memory safety with automatic cleanup
221
+ */
222
+ export class SecureWasmAeadContext {
223
+ free(): void;
224
+ [Symbol.dispose](): void;
225
+ /**
226
+ * Decrypt data (Layer A `Result` ABI only; see [`crate::AeadDecryptSemantic`] for Layer B).
227
+ */
228
+ decrypt(algorithm: string, key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, associated_data?: Uint8Array | null): any;
229
+ /**
230
+ * Encrypt data
231
+ */
232
+ encrypt(algorithm: string, key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, associated_data?: Uint8Array | null): any;
233
+ /**
234
+ * Get supported algorithms
235
+ */
236
+ get_supported_algorithms(): any;
237
+ /**
238
+ * Create a new secure WASM AEAD context
239
+ */
240
+ constructor();
241
+ }
242
+
243
+ /**
244
+ * Secure WASM Hash Context
245
+ *
246
+ * This context provides secure hash operations with:
247
+ * - Consistent error handling using Result<T, JsValue>
248
+ * - Security validation for all inputs
249
+ * - Protection against timing attacks
250
+ * - Memory safety with automatic cleanup
251
+ */
252
+ export class SecureWasmHashContext {
253
+ free(): void;
254
+ [Symbol.dispose](): void;
255
+ /**
256
+ * Get supported algorithms
257
+ */
258
+ get_supported_algorithms(): any;
259
+ /**
260
+ * Hash data
261
+ */
262
+ hash(algorithm: string, data: Uint8Array): any;
263
+ /**
264
+ * Create a new secure WASM hash context
265
+ */
266
+ constructor();
267
+ }
268
+
269
+ /**
270
+ * Secure WASM KEM Context
271
+ *
272
+ * This context provides secure KEM operations with:
273
+ * - Consistent error handling using Result<T, JsValue>
274
+ * - Security validation for all inputs
275
+ * - Protection against timing attacks
276
+ * - Memory safety with automatic cleanup
277
+ */
278
+ export class SecureWasmKemContext {
279
+ free(): void;
280
+ [Symbol.dispose](): void;
281
+ /**
282
+ * Decapsulate a shared secret
283
+ */
284
+ decapsulate(algorithm: string, private_key: Uint8Array, ciphertext: Uint8Array): any;
285
+ /**
286
+ * Encapsulate a shared secret
287
+ */
288
+ encapsulate(algorithm: string, public_key: Uint8Array, randomness?: Uint8Array | null): any;
289
+ /**
290
+ * Generate a KEM keypair
291
+ */
292
+ generate_keypair(algorithm: string, randomness?: Uint8Array | null): any;
293
+ /**
294
+ * Get supported algorithms
295
+ */
296
+ get_supported_algorithms(): any;
297
+ /**
298
+ * Create a new secure WASM KEM context
299
+ */
300
+ constructor();
301
+ }
302
+
303
+ /**
304
+ * Secure WASM Signature Context
305
+ *
306
+ * This context provides secure signature operations with:
307
+ * - Consistent error handling using Result<T, JsValue>
308
+ * - Security validation for all inputs
309
+ * - Protection against timing attacks
310
+ * - Memory safety with automatic cleanup
311
+ */
312
+ export class SecureWasmSignatureContext {
313
+ free(): void;
314
+ [Symbol.dispose](): void;
315
+ /**
316
+ * Generate a signature keypair
317
+ */
318
+ generate_keypair(algorithm: string, randomness?: Uint8Array | null): any;
319
+ /**
320
+ * Get supported algorithms
321
+ */
322
+ get_supported_algorithms(): any;
323
+ /**
324
+ * Create a new secure WASM signature context
325
+ */
326
+ constructor();
327
+ /**
328
+ * Sign a message
329
+ */
330
+ sign(algorithm: string, private_key: Uint8Array, message: Uint8Array, randomness?: Uint8Array | null): any;
331
+ /**
332
+ * Verify a signature
333
+ */
334
+ verify(algorithm: string, public_key: Uint8Array, message: Uint8Array, signature: Uint8Array): any;
335
+ }
336
+
337
+ /**
338
+ * Security levels for cryptographic algorithms
339
+ */
340
+ export enum SecurityLevel {
341
+ Level1 = 1,
342
+ Level3 = 3,
343
+ Level4 = 4,
344
+ Level5 = 5,
345
+ }
346
+
347
+ /**
348
+ * Signature keypair with automatic memory zeroization
349
+ */
350
+ export class SigKeypair {
351
+ private constructor();
352
+ free(): void;
353
+ [Symbol.dispose](): void;
354
+ }
355
+
356
+ /**
357
+ * Signature public key
358
+ */
359
+ export class SigPublicKey {
360
+ private constructor();
361
+ free(): void;
362
+ [Symbol.dispose](): void;
363
+ }
364
+
365
+ /**
366
+ * Signature secret key with automatic memory zeroization
367
+ */
368
+ export class SigSecretKey {
369
+ private constructor();
370
+ free(): void;
371
+ [Symbol.dispose](): void;
372
+ }
373
+
374
+ /**
375
+ * SLH-DSA signature implementation wrapper
376
+ *
377
+ * This struct provides the lib-Q Signature trait implementation for SLH-DSA,
378
+ * routing operations to the appropriate parameter set based on the algorithm.
379
+ */
380
+ export class SlhDsa {
381
+ private constructor();
382
+ free(): void;
383
+ [Symbol.dispose](): void;
384
+ /**
385
+ * Generate a keypair for WASM (JavaScript) environment
386
+ *
387
+ * # Arguments
388
+ * * `algorithm` - The algorithm name as a string
389
+ * * `randomness` - Optional randomness as Uint8Array
390
+ *
391
+ * # Returns
392
+ * * `Result<WasmSlhDsaKeyPair, JsValue>` - The keypair or error
393
+ */
394
+ generate_keypair_wasm(algorithm: string, randomness?: Uint8Array | null): WasmSlhDsaKeyPair;
395
+ /**
396
+ * Sign a message in WASM (JavaScript) environment
397
+ *
398
+ * # Arguments
399
+ * * `algorithm` - The algorithm name as a string
400
+ * * `secret_key` - The secret key as Uint8Array
401
+ * * `message` - The message to sign as Uint8Array
402
+ * * `randomness` - Optional randomness as Uint8Array
403
+ *
404
+ * # Returns
405
+ * * `Result<Uint8Array, JsValue>` - The signature or error
406
+ */
407
+ sign_wasm(algorithm: string, secret_key: Uint8Array, message: Uint8Array, randomness?: Uint8Array | null): Uint8Array;
408
+ /**
409
+ * Verify a signature in WASM (JavaScript) environment
410
+ *
411
+ * # Arguments
412
+ * * `algorithm` - The algorithm name as a string
413
+ * * `public_key` - The public key as Uint8Array
414
+ * * `message` - The message as Uint8Array
415
+ * * `signature` - The signature to verify as Uint8Array
416
+ *
417
+ * # Returns
418
+ * * `Result<bool, JsValue>` - Verification result or error
419
+ */
420
+ verify_wasm(algorithm: string, public_key: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
421
+ }
422
+
423
+ /**
424
+ * WASM-compatible AEAD context wrapper
425
+ *
426
+ * This wrapper provides JavaScript-compatible bindings for AEAD operations:
427
+ * - Integrates with the new modular architecture
428
+ * - Includes security validation
429
+ * - Provides consistent error handling
430
+ * - Supports all AEAD algorithms
431
+ */
432
+ export class WasmAeadContext {
433
+ private constructor();
434
+ free(): void;
435
+ [Symbol.dispose](): void;
436
+ }
437
+
438
+ /**
439
+ * WASM-compatible CryptoProvider wrapper
440
+ *
441
+ * This wrapper provides JavaScript-compatible bindings for the crypto provider:
442
+ * - Integrates with the new modular architecture
443
+ * - Provides consistent error handling
444
+ * - Supports all cryptographic operations
445
+ */
446
+ export class WasmCryptoProvider {
447
+ private constructor();
448
+ free(): void;
449
+ [Symbol.dispose](): void;
450
+ }
451
+
452
+ /**
453
+ * WASM-compatible Hash context wrapper
454
+ *
455
+ * This wrapper provides JavaScript-compatible bindings for hash operations:
456
+ * - Integrates with the new modular architecture
457
+ * - Includes security validation
458
+ * - Provides consistent error handling
459
+ * - Supports all hash algorithms
460
+ */
461
+ export class WasmHashContext {
462
+ private constructor();
463
+ free(): void;
464
+ [Symbol.dispose](): void;
465
+ }
466
+
467
+ /**
468
+ * WASM-compatible KEM context wrapper
469
+ *
470
+ * This wrapper provides JavaScript-compatible bindings for KEM operations:
471
+ * - Integrates with the new modular architecture
472
+ * - Includes security validation
473
+ * - Provides consistent error handling
474
+ * - Supports all KEM algorithms
475
+ */
476
+ export class WasmKemContext {
477
+ private constructor();
478
+ free(): void;
479
+ [Symbol.dispose](): void;
480
+ }
481
+
482
+ /**
483
+ * Generic WASM key pair implementation
484
+ */
485
+ export class WasmKeyPairImpl {
486
+ free(): void;
487
+ [Symbol.dispose](): void;
488
+ constructor(public_key: Uint8Array, secret_key: Uint8Array);
489
+ readonly public_key: Uint8Array;
490
+ readonly secret_key: Uint8Array;
491
+ }
492
+
493
+ /**
494
+ * WASM-compatible ML-DSA key pair
495
+ */
496
+ export class WasmMlDsaKeyPair {
497
+ free(): void;
498
+ [Symbol.dispose](): void;
499
+ constructor(public_key: Uint8Array, secret_key: Uint8Array);
500
+ readonly public_key: Uint8Array;
501
+ readonly secret_key: Uint8Array;
502
+ }
503
+
504
+ /**
505
+ * WASM-compatible provider factory
506
+ *
507
+ * This factory provides JavaScript-compatible bindings for creating providers:
508
+ * - Integrates with the new modular architecture
509
+ * - Provides consistent error handling
510
+ * - Supports all provider creation operations
511
+ */
512
+ export class WasmProviderFactory {
513
+ private constructor();
514
+ free(): void;
515
+ [Symbol.dispose](): void;
516
+ /**
517
+ * Create a new provider manager
518
+ */
519
+ static create_provider_manager(): WasmProviderManager;
520
+ /**
521
+ * Create a provider manager with specific configuration
522
+ */
523
+ static create_provider_manager_with_config(config: string): WasmProviderManager;
524
+ /**
525
+ * Get available provider types
526
+ */
527
+ static get_available_providers(): string;
528
+ /**
529
+ * Validate provider configuration
530
+ */
531
+ static validate_provider_config(config: string): boolean;
532
+ }
533
+
534
+ /**
535
+ * WASM-compatible provider manager
536
+ *
537
+ * This manager provides JavaScript-compatible bindings for provider operations:
538
+ * - Integrates with the new modular architecture
539
+ * - Includes security validation
540
+ * - Provides consistent error handling
541
+ * - Supports all provider operations
542
+ */
543
+ export class WasmProviderManager {
544
+ private constructor();
545
+ free(): void;
546
+ [Symbol.dispose](): void;
547
+ }
548
+
549
+ /**
550
+ * WASM-compatible Signature context wrapper
551
+ *
552
+ * This wrapper provides JavaScript-compatible bindings for signature operations:
553
+ * - Integrates with the new modular architecture
554
+ * - Includes security validation
555
+ * - Provides consistent error handling
556
+ * - Supports all signature algorithms
557
+ */
558
+ export class WasmSignatureContext {
559
+ private constructor();
560
+ free(): void;
561
+ [Symbol.dispose](): void;
562
+ /**
563
+ * Generate a keypair for the specified algorithm
564
+ */
565
+ generate_keypair(algorithm: string, randomness?: Uint8Array | null): any;
566
+ /**
567
+ * Check if an algorithm is supported
568
+ */
569
+ is_algorithm_supported(algorithm: string): boolean;
570
+ /**
571
+ * Get the security level of the context
572
+ */
573
+ security_level(): number;
574
+ /**
575
+ * Sign a message using the given secret key
576
+ */
577
+ sign(algorithm: string, secret_key_data: Uint8Array, message: Uint8Array, randomness?: Uint8Array | null): Uint8Array;
578
+ /**
579
+ * Get supported algorithms
580
+ */
581
+ supported_algorithms(): string;
582
+ /**
583
+ * Verify a signature using the given public key
584
+ */
585
+ verify(algorithm: string, public_key_data: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
586
+ }
587
+
588
+ /**
589
+ * WASM-compatible SLH-DSA key pair
590
+ */
591
+ export class WasmSlhDsaKeyPair {
592
+ free(): void;
593
+ [Symbol.dispose](): void;
594
+ constructor(public_key: Uint8Array, secret_key: Uint8Array);
595
+ readonly public_key: Uint8Array;
596
+ readonly secret_key: Uint8Array;
597
+ }
598
+
599
+ /**
600
+ * Array of AEAD algorithm names available in this build (native JS array of strings).
601
+ */
602
+ export function aead_available_algorithms(): any;
603
+
604
+ /**
605
+ * AEAD decrypt (same `algorithm` names as [`aead_encrypt`]).
606
+ */
607
+ export function aead_decrypt(algorithm: string, key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, associated_data: Uint8Array): Uint8Array;
608
+
609
+ /**
610
+ * AEAD encrypt: `algorithm` is `Saturnin`, `DuplexSpongeAead`, or `RomulusN`.
611
+ */
612
+ export function aead_encrypt(algorithm: string, key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, associated_data: Uint8Array): Uint8Array;
613
+
614
+ /**
615
+ * Convert bytes to hexadecimal string
616
+ *
617
+ * This function provides secure hex encoding for WASM:
618
+ * - Uses constant-time operations where possible
619
+ * - Handles large data efficiently
620
+ * - Returns JavaScript string
621
+ */
622
+ export function bytes_to_hex(data: Uint8Array): string;
623
+
624
+ /**
625
+ * Convert bytes to hexadecimal string
626
+ */
627
+ export function bytes_to_hex_wasm(data: Uint8Array): string;
628
+
629
+ /**
630
+ * Decapsulate shared secret from ciphertext (hex) with secret key (hex); returns `{ sharedSecretHex }`.
631
+ */
632
+ export function cbKemDecapsulate(secret_key_hex: string, ciphertext_hex: string): any;
633
+
634
+ /**
635
+ * Raw shared secret bytes (decapsulate).
636
+ */
637
+ export function cbKemDecapsulateBytes(secret_key_hex: string, ciphertext_hex: string): Uint8Array;
638
+
639
+ /**
640
+ * Encapsulate to a peer's public key (hex).
641
+ */
642
+ export function cbKemEncapsulate(public_key_hex: string): any;
643
+
644
+ /**
645
+ * Generate a CB-KEM keypair for the variant compiled into this build.
646
+ */
647
+ export function cbKemKeygen(): any;
648
+
649
+ /**
650
+ * Create an AEAD context for WASM backed by `lib-q-aead` (same wiring as `libq::aead::context`).
651
+ */
652
+ export function create_aead_context(): WasmAeadContext;
653
+
654
+ /**
655
+ * Create a new Hash context for WASM backed by `lib-q-hash` (same wiring as
656
+ * [`crate::create_hash_context`]).
657
+ */
658
+ export function create_hash_context(): WasmHashContext;
659
+
660
+ /**
661
+ * Create a new KEM context for WASM
662
+ */
663
+ export function create_kem_context(): WasmKemContext;
664
+
665
+ /**
666
+ * Create a new provider manager for WASM
667
+ */
668
+ export function create_provider_manager(): WasmProviderManager;
669
+
670
+ /**
671
+ * Create a new Signature context for WASM backed by `lib-q-sig` (same wiring as native
672
+ * `SignatureContext` with [`LibQSignatureProvider`](lib_q_sig::LibQSignatureProvider)).
673
+ */
674
+ export function create_signature_context(): WasmSignatureContext;
675
+
676
+ /**
677
+ * Generate secure random bytes for WASM
678
+ */
679
+ export function generate_random_bytes(length: number): Uint8Array;
680
+
681
+ /**
682
+ * Get library information for WASM
683
+ *
684
+ * This function provides library metadata for JavaScript consumption
685
+ */
686
+ export function get_library_info(): string;
687
+
688
+ /**
689
+ * Get library information for WASM
690
+ */
691
+ export function get_library_info_wasm(): string;
692
+
693
+ /**
694
+ * Get performance benchmarks
695
+ */
696
+ export function get_performance_benchmarks_wasm(): string;
697
+
698
+ /**
699
+ * Get security recommendations
700
+ */
701
+ export function get_security_recommendations_wasm(): string;
702
+
703
+ /**
704
+ * Get supported algorithms by category
705
+ *
706
+ * This function provides algorithm information for JavaScript
707
+ */
708
+ export function get_supported_algorithms(): string;
709
+
710
+ /**
711
+ * Get supported algorithms by category
712
+ */
713
+ export function get_supported_algorithms_wasm(): any;
714
+
715
+ /**
716
+ * Get the library version
717
+ */
718
+ export function get_version(): string;
719
+
720
+ /**
721
+ * Convert hexadecimal string to bytes
722
+ *
723
+ * This function provides secure hex decoding for WASM:
724
+ * - Validates hex string format
725
+ * - Handles errors gracefully
726
+ * - Returns Uint8Array
727
+ */
728
+ export function hex_to_bytes(hex: string): Uint8Array;
729
+
730
+ /**
731
+ * Convert hexadecimal string to bytes
732
+ */
733
+ export function hex_to_bytes_wasm(hex: string): Uint8Array;
734
+
735
+ /**
736
+ * Object `{ "sharedSecretHex": "..." }` with hex-encoded shared secret bytes.
737
+ */
738
+ export function hqc_decapsulate(secret_key_hex: string, ciphertext_hex: string, param: string): any;
739
+
740
+ /**
741
+ * Object `{"ciphertext":"hex","sharedSecret":"hex"}`.
742
+ */
743
+ export function hqc_encapsulate(public_key_hex: string, param: string): any;
744
+
745
+ /**
746
+ * Object `{"publicKey":"hex","secretKey":"hex"}`.
747
+ */
748
+ export function hqc_keygen(param: string): any;
749
+
750
+ /**
751
+ * Initialize the library for WASM usage
752
+ */
753
+ export function init_wasm(): void;
754
+
755
+ /**
756
+ * Check if an algorithm is supported
757
+ */
758
+ export function is_algorithm_supported_wasm(algorithm: string): boolean;
759
+
760
+ /**
761
+ * Check if a feature is available
762
+ *
763
+ * This function allows JavaScript to check feature availability
764
+ */
765
+ export function is_feature_available(feature: string): boolean;
766
+
767
+ /**
768
+ * Generate cryptographically secure random bytes for WASM
769
+ *
770
+ * This function provides secure random generation in WASM environments:
771
+ * - Uses the browser's crypto.getRandomValues() API
772
+ * - Validates input size to prevent DoS attacks
773
+ * - Returns Uint8Array for direct JavaScript consumption
774
+ */
775
+ export function random_bytes(length: number): Uint8Array;
776
+
777
+ /**
778
+ * Fill `len` bytes from [`new_secure_rng`] (`WebAssembly` uses `getrandom` `wasm_js` backend).
779
+ */
780
+ export function secureRandomBytes(len: number): Uint8Array;
781
+
782
+ /**
783
+ * Validate input data for WASM operations
784
+ *
785
+ * This function provides comprehensive input validation:
786
+ * - Checks for null/undefined values
787
+ * - Validates data size limits
788
+ * - Ensures data is not empty when required
789
+ */
790
+ export function validate_input(data: Uint8Array, min_size?: number | null, max_size?: number | null): boolean;
791
+
792
+ /**
793
+ * Prove knowledge of a secret preimage (Poseidon-128 commitment) as a [`ZkpProof`] object.
794
+ */
795
+ export function zkpProvePreimageJson(secret: Uint8Array): any;
796
+
797
+ /**
798
+ * NIST cSHAKE256 preimage proof as a [`ZkpProof`] object.
799
+ */
800
+ export function zkpProvePreimageNistJson(secret: Uint8Array): any;
801
+
802
+ /**
803
+ * Verify a proof object from [`zkp_prove_preimage_json`]; `expected_hash_hex` is 32-byte hash.
804
+ */
805
+ export function zkpVerifyPreimageJson(proof: any, expected_hash_hex: string): boolean;
806
+
807
+ /**
808
+ * Verify NIST preimage proof object; `expected_hash_hex` is the 32-byte cSHAKE256 output.
809
+ */
810
+ export function zkpVerifyPreimageNistJson(proof: any, expected_hash_hex: string): boolean;
811
+
812
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
813
+
814
+ export interface InitOutput {
815
+ readonly memory: WebAssembly.Memory;
816
+ readonly bytes_to_hex_wasm: (a: any) => [number, number];
817
+ readonly create_aead_context: () => number;
818
+ readonly create_hash_context: () => number;
819
+ readonly create_kem_context: () => number;
820
+ readonly create_provider_manager: () => number;
821
+ readonly create_signature_context: () => number;
822
+ readonly generate_random_bytes: (a: number) => [number, number, number];
823
+ readonly get_library_info_wasm: () => [number, number];
824
+ readonly get_performance_benchmarks_wasm: () => [number, number];
825
+ readonly get_security_recommendations_wasm: () => [number, number];
826
+ readonly get_supported_algorithms_wasm: () => any;
827
+ readonly get_version: () => [number, number];
828
+ readonly hex_to_bytes_wasm: (a: number, b: number) => [number, number, number];
829
+ readonly init_wasm: () => [number, number];
830
+ readonly is_algorithm_supported_wasm: (a: number, b: number) => number;
831
+ readonly aead_available_algorithms: () => [number, number, number];
832
+ readonly aead_decrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number, number];
833
+ readonly aead_encrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number, number];
834
+ readonly zkpProvePreimageJson: (a: number, b: number) => [number, number, number];
835
+ readonly zkpProvePreimageNistJson: (a: number, b: number) => [number, number, number];
836
+ readonly zkpVerifyPreimageJson: (a: any, b: number, c: number) => [number, number, number];
837
+ readonly zkpVerifyPreimageNistJson: (a: any, b: number, c: number) => [number, number, number];
838
+ readonly __wbg_slhdsa_free: (a: number, b: number) => void;
839
+ readonly __wbg_wasmslhdsakeypair_free: (a: number, b: number) => void;
840
+ readonly slhdsa_generate_keypair_wasm: (a: number, b: number, c: number, d: number) => [number, number, number];
841
+ readonly slhdsa_sign_wasm: (a: number, b: number, c: number, d: any, e: any, f: number) => [number, number, number];
842
+ readonly slhdsa_verify_wasm: (a: number, b: number, c: number, d: any, e: any, f: any) => [number, number, number];
843
+ readonly wasmslhdsakeypair_public_key: (a: number) => any;
844
+ readonly wasmslhdsakeypair_secret_key: (a: number) => any;
845
+ readonly wasmslhdsakeypair_new: (a: any, b: any) => number;
846
+ readonly __wbg_mldsa_free: (a: number, b: number) => void;
847
+ readonly __wbg_wasmmldsakeypair_free: (a: number, b: number) => void;
848
+ readonly mldsa_generate_keypair_wasm: (a: number, b: number) => [number, number, number];
849
+ readonly mldsa_sign_wasm: (a: number, b: any, c: any, d: number) => [number, number, number];
850
+ readonly mldsa_verify_wasm: (a: number, b: any, c: any, d: any) => [number, number, number];
851
+ readonly wasmmldsakeypair_public_key: (a: number) => any;
852
+ readonly wasmmldsakeypair_secret_key: (a: number) => any;
853
+ readonly wasmmldsakeypair_new: (a: any, b: any) => number;
854
+ readonly hqc_decapsulate: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
855
+ readonly hqc_encapsulate: (a: number, b: number, c: number, d: number) => [number, number, number];
856
+ readonly hqc_keygen: (a: number, b: number) => [number, number, number];
857
+ readonly cbKemDecapsulate: (a: number, b: number, c: number, d: number) => [number, number, number];
858
+ readonly cbKemDecapsulateBytes: (a: number, b: number, c: number, d: number) => [number, number, number];
859
+ readonly cbKemEncapsulate: (a: number, b: number) => [number, number, number];
860
+ readonly cbKemKeygen: () => [number, number, number];
861
+ readonly secureRandomBytes: (a: number) => [number, number, number];
862
+ readonly __wbg_wasmaeadcontext_free: (a: number, b: number) => void;
863
+ readonly __wbg_wasmcryptoprovider_free: (a: number, b: number) => void;
864
+ readonly __wbg_wasmhashcontext_free: (a: number, b: number) => void;
865
+ readonly __wbg_wasmkemcontext_free: (a: number, b: number) => void;
866
+ readonly __wbg_wasmsignaturecontext_free: (a: number, b: number) => void;
867
+ readonly wasmsignaturecontext_generate_keypair: (a: number, b: number, c: number, d: number) => [number, number, number];
868
+ readonly wasmsignaturecontext_is_algorithm_supported: (a: number, b: number, c: number) => number;
869
+ readonly wasmsignaturecontext_security_level: (a: number) => number;
870
+ readonly wasmsignaturecontext_sign: (a: number, b: number, c: number, d: any, e: any, f: number) => [number, number, number, number];
871
+ readonly wasmsignaturecontext_supported_algorithms: (a: number) => [number, number];
872
+ readonly wasmsignaturecontext_verify: (a: number, b: number, c: number, d: any, e: any, f: any) => [number, number, number];
873
+ readonly __wbg_wasmproviderfactory_free: (a: number, b: number) => void;
874
+ readonly __wbg_wasmprovidermanager_free: (a: number, b: number) => void;
875
+ readonly wasmproviderfactory_create_provider_manager: () => number;
876
+ readonly wasmproviderfactory_create_provider_manager_with_config: (a: number, b: number) => [number, number, number];
877
+ readonly wasmproviderfactory_get_available_providers: () => [number, number];
878
+ readonly wasmproviderfactory_validate_provider_config: (a: number, b: number) => [number, number, number];
879
+ readonly __wbg_securewasmaeadcontext_free: (a: number, b: number) => void;
880
+ readonly __wbg_securewasmhashcontext_free: (a: number, b: number) => void;
881
+ readonly __wbg_securewasmkemcontext_free: (a: number, b: number) => void;
882
+ readonly __wbg_securewasmsignaturecontext_free: (a: number, b: number) => void;
883
+ readonly securewasmaeadcontext_decrypt: (a: number, b: number, c: number, d: any, e: any, f: any, g: number) => [number, number, number];
884
+ readonly securewasmaeadcontext_encrypt: (a: number, b: number, c: number, d: any, e: any, f: any, g: number) => [number, number, number];
885
+ readonly securewasmaeadcontext_get_supported_algorithms: (a: number) => [number, number, number];
886
+ readonly securewasmaeadcontext_new: () => [number, number, number];
887
+ readonly securewasmhashcontext_get_supported_algorithms: (a: number) => [number, number, number];
888
+ readonly securewasmhashcontext_hash: (a: number, b: number, c: number, d: any) => [number, number, number];
889
+ readonly securewasmkemcontext_decapsulate: (a: number, b: number, c: number, d: any, e: any) => [number, number, number];
890
+ readonly securewasmkemcontext_encapsulate: (a: number, b: number, c: number, d: any, e: number) => [number, number, number];
891
+ readonly securewasmkemcontext_generate_keypair: (a: number, b: number, c: number, d: number) => [number, number, number];
892
+ readonly securewasmkemcontext_get_supported_algorithms: (a: number) => [number, number, number];
893
+ readonly securewasmsignaturecontext_generate_keypair: (a: number, b: number, c: number, d: number) => [number, number, number];
894
+ readonly securewasmsignaturecontext_get_supported_algorithms: (a: number) => [number, number, number];
895
+ readonly securewasmsignaturecontext_sign: (a: number, b: number, c: number, d: any, e: any, f: number) => [number, number, number];
896
+ readonly securewasmsignaturecontext_verify: (a: number, b: number, c: number, d: any, e: any, f: any) => [number, number, number];
897
+ readonly securewasmhashcontext_new: () => [number, number, number];
898
+ readonly securewasmkemcontext_new: () => [number, number, number];
899
+ readonly securewasmsignaturecontext_new: () => [number, number, number];
900
+ readonly __wbg_hashresultwasm_free: (a: number, b: number) => void;
901
+ readonly __wbg_wasmkeypairimpl_free: (a: number, b: number) => void;
902
+ readonly bytes_to_hex: (a: any) => [number, number];
903
+ readonly get_library_info: () => [number, number];
904
+ readonly get_supported_algorithms: () => [number, number];
905
+ readonly hashresultwasm_algorithm: (a: number) => [number, number];
906
+ readonly hashresultwasm_hash: (a: number) => any;
907
+ readonly hashresultwasm_new: (a: any, b: number, c: number) => number;
908
+ readonly hex_to_bytes: (a: number, b: number) => [number, number, number];
909
+ readonly is_feature_available: (a: number, b: number) => number;
910
+ readonly random_bytes: (a: number) => [number, number, number];
911
+ readonly validate_input: (a: any, b: number, c: number) => [number, number, number];
912
+ readonly wasmkeypairimpl_public_key: (a: number) => any;
913
+ readonly wasmkeypairimpl_secret_key: (a: number) => any;
914
+ readonly wasmkeypairimpl_new: (a: any, b: any) => number;
915
+ readonly __wbg_kemkeypair_free: (a: number, b: number) => void;
916
+ readonly __wbg_kempublickey_free: (a: number, b: number) => void;
917
+ readonly __wbg_kemsecretkey_free: (a: number, b: number) => void;
918
+ readonly __wbg_sigkeypair_free: (a: number, b: number) => void;
919
+ readonly __wbg_sigpublickey_free: (a: number, b: number) => void;
920
+ readonly __wbg_sigsecretkey_free: (a: number, b: number) => void;
921
+ readonly kemkeypair_new_wasm: (a: number, b: number, c: number, d: number) => number;
922
+ readonly kemkeypair_public_key_bytes: (a: number) => [number, number];
923
+ readonly kemkeypair_secret_key_bytes: (a: number) => any;
924
+ readonly kempublickey_bytes: (a: number) => [number, number];
925
+ readonly kempublickey_new_from_bytes: (a: number, b: number) => number;
926
+ readonly kemsecretkey_bytes: (a: number) => any;
927
+ readonly kemsecretkey_new_from_bytes: (a: number, b: number) => number;
928
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
929
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
930
+ readonly __wbindgen_exn_store: (a: number) => void;
931
+ readonly __externref_table_alloc: () => number;
932
+ readonly __wbindgen_externrefs: WebAssembly.Table;
933
+ readonly __externref_table_dealloc: (a: number) => void;
934
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
935
+ readonly __wbindgen_start: () => void;
936
+ }
937
+
938
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
939
+
940
+ /**
941
+ * Instantiates the given `module`, which can either be bytes or
942
+ * a precompiled `WebAssembly.Module`.
943
+ *
944
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
945
+ *
946
+ * @returns {InitOutput}
947
+ */
948
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
949
+
950
+ /**
951
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
952
+ * for everything else, calls `WebAssembly.instantiate` directly.
953
+ *
954
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
955
+ *
956
+ * @returns {Promise<InitOutput>}
957
+ */
958
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;