@bcts/components 1.0.0-beta.0 → 1.0.0-beta.1

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/dist/index.cjs CHANGED
@@ -21,7 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  enumerable: true
22
22
  }) : target, mod));
23
23
  //#endregion
24
- const require_digest = require("./digest-DL5sTq8T.cjs");
25
24
  let _bcts_dcbor = require("@bcts/dcbor");
26
25
  let _bcts_tags = require("@bcts/tags");
27
26
  let pako = require("pako");
@@ -40,6 +39,503 @@ let _scure_base = require("@scure/base");
40
39
  let _noble_hashes_hmac_js = require("@noble/hashes/hmac.js");
41
40
  let _noble_post_quantum_ml_kem_js = require("@noble/post-quantum/ml-kem.js");
42
41
  let _bcts_sskr = require("@bcts/sskr");
42
+ //#region src/error.ts
43
+ /**
44
+ * Copyright © 2023-2026 Blockchain Commons, LLC
45
+ * Copyright © 2025-2026 Parity Technologies
46
+ *
47
+ *
48
+ * Error types for cryptographic and component operations
49
+ *
50
+ * Ported from bc-components-rust/src/error.rs
51
+ *
52
+ * This module provides a unified error handling system that matches the Rust
53
+ * implementation's error variants with full structural parity:
54
+ *
55
+ * - InvalidSize: Invalid data size for the specified type
56
+ * - InvalidData: Invalid data format or content
57
+ * - DataTooShort: Data too short for the expected type
58
+ * - Crypto: Cryptographic operation failed
59
+ * - Cbor: CBOR encoding or decoding error
60
+ * - Sskr: SSKR error
61
+ * - Ssh: SSH key operation failed
62
+ * - Uri: URI parsing failed
63
+ * - Compression: Data compression/decompression failed
64
+ * - PostQuantum: Post-quantum cryptography library error
65
+ * - LevelMismatch: Signature level mismatch
66
+ * - SshAgent: SSH agent operation failed
67
+ * - Hex: Hex decoding error
68
+ * - Utf8: UTF-8 conversion error
69
+ * - Env: Environment variable error
70
+ * - SshAgentClient: SSH agent client error
71
+ * - General: General error with custom message
72
+ */
73
+ /**
74
+ * Error kind enum matching Rust's Error variants.
75
+ *
76
+ * This enum allows programmatic checking of error types, matching the
77
+ * Rust enum variants exactly.
78
+ */
79
+ let ErrorKind = /* @__PURE__ */ function(ErrorKind) {
80
+ /** Invalid data size for the specified type */
81
+ ErrorKind["InvalidSize"] = "InvalidSize";
82
+ /** Invalid data format or content */
83
+ ErrorKind["InvalidData"] = "InvalidData";
84
+ /** Data too short for the expected type */
85
+ ErrorKind["DataTooShort"] = "DataTooShort";
86
+ /** Cryptographic operation failed */
87
+ ErrorKind["Crypto"] = "Crypto";
88
+ /** CBOR encoding or decoding error */
89
+ ErrorKind["Cbor"] = "Cbor";
90
+ /** SSKR error */
91
+ ErrorKind["Sskr"] = "Sskr";
92
+ /** SSH key operation failed */
93
+ ErrorKind["Ssh"] = "Ssh";
94
+ /** URI parsing failed */
95
+ ErrorKind["Uri"] = "Uri";
96
+ /** Data compression/decompression failed */
97
+ ErrorKind["Compression"] = "Compression";
98
+ /** Post-quantum cryptography library error */
99
+ ErrorKind["PostQuantum"] = "PostQuantum";
100
+ /** Signature level mismatch */
101
+ ErrorKind["LevelMismatch"] = "LevelMismatch";
102
+ /** SSH agent operation failed */
103
+ ErrorKind["SshAgent"] = "SshAgent";
104
+ /** Hex decoding error */
105
+ ErrorKind["Hex"] = "Hex";
106
+ /** UTF-8 conversion error */
107
+ ErrorKind["Utf8"] = "Utf8";
108
+ /** Environment variable error */
109
+ ErrorKind["Env"] = "Env";
110
+ /** SSH agent client error */
111
+ ErrorKind["SshAgentClient"] = "SshAgentClient";
112
+ /** General error with custom message */
113
+ ErrorKind["General"] = "General";
114
+ return ErrorKind;
115
+ }({});
116
+ /**
117
+ * Error type for cryptographic and component operations.
118
+ *
119
+ * This class provides full structural parity with the Rust Error enum,
120
+ * including:
121
+ * - An `errorKind` property for programmatic error type checking
122
+ * - Structured `errorData` for accessing error-specific fields
123
+ * - Factory methods matching Rust's impl block
124
+ */
125
+ var CryptoError = class CryptoError extends Error {
126
+ /** The error kind for programmatic type checking */
127
+ errorKind;
128
+ /** Structured error data matching Rust's error variants */
129
+ errorData;
130
+ constructor(message, errorData) {
131
+ super(message);
132
+ this.name = "CryptoError";
133
+ this.errorKind = errorData.kind;
134
+ this.errorData = errorData;
135
+ const ErrorWithStackTrace = Error;
136
+ if (typeof ErrorWithStackTrace.captureStackTrace === "function") ErrorWithStackTrace.captureStackTrace(this, CryptoError);
137
+ }
138
+ /**
139
+ * Create an invalid size error.
140
+ *
141
+ * Rust equivalent: `Error::InvalidSize { data_type, expected, actual }`
142
+ *
143
+ * @param expected - The expected size
144
+ * @param actual - The actual size received
145
+ */
146
+ static invalidSize(expected, actual) {
147
+ return CryptoError.invalidSizeForType("data", expected, actual);
148
+ }
149
+ /**
150
+ * Create an invalid size error with a data type name.
151
+ *
152
+ * Rust equivalent: `Error::invalid_size(data_type, expected, actual)`
153
+ *
154
+ * @param dataType - The name of the data type
155
+ * @param expected - The expected size
156
+ * @param actual - The actual size received
157
+ */
158
+ static invalidSizeForType(dataType, expected, actual) {
159
+ return new CryptoError(`invalid ${dataType} size: expected ${expected}, got ${actual}`, {
160
+ kind: "InvalidSize",
161
+ dataType,
162
+ expected,
163
+ actual
164
+ });
165
+ }
166
+ /**
167
+ * Create an invalid data error.
168
+ *
169
+ * @param message - Description of what's invalid
170
+ */
171
+ static invalidData(message) {
172
+ return CryptoError.invalidDataForType("data", message);
173
+ }
174
+ /**
175
+ * Create an invalid data error with a data type name.
176
+ *
177
+ * Rust equivalent: `Error::invalid_data(data_type, reason)`
178
+ *
179
+ * @param dataType - The name of the data type
180
+ * @param reason - The reason the data is invalid
181
+ */
182
+ static invalidDataForType(dataType, reason) {
183
+ return new CryptoError(`invalid ${dataType}: ${reason}`, {
184
+ kind: "InvalidData",
185
+ dataType,
186
+ reason
187
+ });
188
+ }
189
+ /**
190
+ * Create a data too short error.
191
+ *
192
+ * Rust equivalent: `Error::data_too_short(data_type, minimum, actual)`
193
+ *
194
+ * @param dataType - The name of the data type
195
+ * @param minimum - The minimum required size
196
+ * @param actual - The actual size received
197
+ */
198
+ static dataTooShort(dataType, minimum, actual) {
199
+ return new CryptoError(`data too short: ${dataType} expected at least ${minimum}, got ${actual}`, {
200
+ kind: "DataTooShort",
201
+ dataType,
202
+ minimum,
203
+ actual
204
+ });
205
+ }
206
+ /**
207
+ * Create an invalid format error.
208
+ *
209
+ * @param message - Description of the format error
210
+ */
211
+ static invalidFormat(message) {
212
+ return CryptoError.invalidDataForType("format", message);
213
+ }
214
+ /**
215
+ * Create an invalid input error.
216
+ *
217
+ * @param message - Description of the invalid input
218
+ */
219
+ static invalidInput(message) {
220
+ return CryptoError.invalidDataForType("input", message);
221
+ }
222
+ /**
223
+ * Create a cryptographic operation failed error.
224
+ *
225
+ * Rust equivalent: `Error::crypto(msg)`
226
+ *
227
+ * @param message - Description of the failure
228
+ */
229
+ static cryptoOperation(message) {
230
+ return CryptoError.crypto(message);
231
+ }
232
+ /**
233
+ * Create a crypto error.
234
+ *
235
+ * Rust equivalent: `Error::Crypto(msg)`
236
+ *
237
+ * @param message - Description of the failure
238
+ */
239
+ static crypto(message) {
240
+ return new CryptoError(`cryptographic operation failed: ${message}`, {
241
+ kind: "Crypto",
242
+ message
243
+ });
244
+ }
245
+ /**
246
+ * Create a post-quantum cryptography error.
247
+ *
248
+ * Rust equivalent: `Error::post_quantum(msg)`
249
+ *
250
+ * @param message - Description of the failure
251
+ */
252
+ static postQuantum(message) {
253
+ return new CryptoError(`post-quantum cryptography error: ${message}`, {
254
+ kind: "PostQuantum",
255
+ message
256
+ });
257
+ }
258
+ /**
259
+ * Create a signature level mismatch error.
260
+ *
261
+ * Rust equivalent: `Error::LevelMismatch`
262
+ */
263
+ static levelMismatch() {
264
+ return new CryptoError("signature level does not match key level", { kind: "LevelMismatch" });
265
+ }
266
+ /**
267
+ * Create a CBOR error.
268
+ *
269
+ * Rust equivalent: `Error::Cbor(err)`
270
+ *
271
+ * @param message - Description of the CBOR error
272
+ */
273
+ static cbor(message) {
274
+ return new CryptoError(`CBOR error: ${message}`, {
275
+ kind: "Cbor",
276
+ message
277
+ });
278
+ }
279
+ /**
280
+ * Create a hex decoding error.
281
+ *
282
+ * Rust equivalent: `Error::Hex(err)`
283
+ *
284
+ * @param message - Description of the hex error
285
+ */
286
+ static hex(message) {
287
+ return new CryptoError(`hex decoding error: ${message}`, {
288
+ kind: "Hex",
289
+ message
290
+ });
291
+ }
292
+ /**
293
+ * Create a UTF-8 conversion error.
294
+ *
295
+ * Rust equivalent: `Error::Utf8(err)`
296
+ *
297
+ * @param message - Description of the UTF-8 error
298
+ */
299
+ static utf8(message) {
300
+ return new CryptoError(`UTF-8 conversion error: ${message}`, {
301
+ kind: "Utf8",
302
+ message
303
+ });
304
+ }
305
+ /**
306
+ * Create a compression error.
307
+ *
308
+ * Rust equivalent: `Error::compression(msg)`
309
+ *
310
+ * @param message - Description of the compression error
311
+ */
312
+ static compression(message) {
313
+ return new CryptoError(`compression error: ${message}`, {
314
+ kind: "Compression",
315
+ message
316
+ });
317
+ }
318
+ /**
319
+ * Create a URI parsing error.
320
+ *
321
+ * Rust equivalent: `Error::Uri(err)`
322
+ *
323
+ * @param message - Description of the URI error
324
+ */
325
+ static uri(message) {
326
+ return new CryptoError(`invalid URI: ${message}`, {
327
+ kind: "Uri",
328
+ message
329
+ });
330
+ }
331
+ /**
332
+ * Create an SSKR error.
333
+ *
334
+ * Rust equivalent: `Error::Sskr(err)`
335
+ *
336
+ * @param message - Description of the SSKR error
337
+ */
338
+ static sskr(message) {
339
+ return new CryptoError(`SSKR error: ${message}`, {
340
+ kind: "Sskr",
341
+ message
342
+ });
343
+ }
344
+ /**
345
+ * Create an SSH operation error.
346
+ *
347
+ * Rust equivalent: `Error::ssh(msg)`
348
+ *
349
+ * @param message - Description of the SSH error
350
+ */
351
+ static ssh(message) {
352
+ return new CryptoError(`SSH operation failed: ${message}`, {
353
+ kind: "Ssh",
354
+ message
355
+ });
356
+ }
357
+ /**
358
+ * Create an SSH agent error.
359
+ *
360
+ * Rust equivalent: `Error::ssh_agent(msg)`
361
+ *
362
+ * @param message - Description of the SSH agent error
363
+ */
364
+ static sshAgent(message) {
365
+ return new CryptoError(`SSH agent error: ${message}`, {
366
+ kind: "SshAgent",
367
+ message
368
+ });
369
+ }
370
+ /**
371
+ * Create an SSH agent client error.
372
+ *
373
+ * Rust equivalent: `Error::ssh_agent_client(msg)`
374
+ *
375
+ * @param message - Description of the SSH agent client error
376
+ */
377
+ static sshAgentClient(message) {
378
+ return new CryptoError(`SSH agent client error: ${message}`, {
379
+ kind: "SshAgentClient",
380
+ message
381
+ });
382
+ }
383
+ /**
384
+ * Create an environment variable error.
385
+ *
386
+ * Rust equivalent: `Error::Env(err)`
387
+ *
388
+ * @param message - Description of the environment error
389
+ */
390
+ static env(message) {
391
+ return new CryptoError(`environment variable error: ${message}`, {
392
+ kind: "Env",
393
+ message
394
+ });
395
+ }
396
+ /**
397
+ * Create a general error with a custom message.
398
+ *
399
+ * Rust equivalent: `Error::general(msg)` / `Error::General(msg)`
400
+ *
401
+ * @param message - The error message
402
+ */
403
+ static general(message) {
404
+ return new CryptoError(message, {
405
+ kind: "General",
406
+ message
407
+ });
408
+ }
409
+ /**
410
+ * Check if this error is of a specific kind.
411
+ *
412
+ * @param kind - The error kind to check
413
+ */
414
+ isKind(kind) {
415
+ return this.errorKind === kind;
416
+ }
417
+ /**
418
+ * Check if this is an InvalidSize error.
419
+ */
420
+ isInvalidSize() {
421
+ return this.errorKind === "InvalidSize";
422
+ }
423
+ /**
424
+ * Check if this is an InvalidData error.
425
+ */
426
+ isInvalidData() {
427
+ return this.errorKind === "InvalidData";
428
+ }
429
+ /**
430
+ * Check if this is a DataTooShort error.
431
+ */
432
+ isDataTooShort() {
433
+ return this.errorKind === "DataTooShort";
434
+ }
435
+ /**
436
+ * Check if this is a Crypto error.
437
+ */
438
+ isCrypto() {
439
+ return this.errorKind === "Crypto";
440
+ }
441
+ /**
442
+ * Check if this is a Cbor error.
443
+ */
444
+ isCbor() {
445
+ return this.errorKind === "Cbor";
446
+ }
447
+ /**
448
+ * Check if this is an Sskr error.
449
+ */
450
+ isSskr() {
451
+ return this.errorKind === "Sskr";
452
+ }
453
+ /**
454
+ * Check if this is an Ssh error.
455
+ */
456
+ isSsh() {
457
+ return this.errorKind === "Ssh";
458
+ }
459
+ /**
460
+ * Check if this is a Uri error.
461
+ */
462
+ isUri() {
463
+ return this.errorKind === "Uri";
464
+ }
465
+ /**
466
+ * Check if this is a Compression error.
467
+ */
468
+ isCompression() {
469
+ return this.errorKind === "Compression";
470
+ }
471
+ /**
472
+ * Check if this is a PostQuantum error.
473
+ */
474
+ isPostQuantum() {
475
+ return this.errorKind === "PostQuantum";
476
+ }
477
+ /**
478
+ * Check if this is a LevelMismatch error.
479
+ */
480
+ isLevelMismatch() {
481
+ return this.errorKind === "LevelMismatch";
482
+ }
483
+ /**
484
+ * Check if this is an SshAgent error.
485
+ */
486
+ isSshAgent() {
487
+ return this.errorKind === "SshAgent";
488
+ }
489
+ /**
490
+ * Check if this is a Hex error.
491
+ */
492
+ isHex() {
493
+ return this.errorKind === "Hex";
494
+ }
495
+ /**
496
+ * Check if this is a Utf8 error.
497
+ */
498
+ isUtf8() {
499
+ return this.errorKind === "Utf8";
500
+ }
501
+ /**
502
+ * Check if this is an Env error.
503
+ */
504
+ isEnv() {
505
+ return this.errorKind === "Env";
506
+ }
507
+ /**
508
+ * Check if this is an SshAgentClient error.
509
+ */
510
+ isSshAgentClient() {
511
+ return this.errorKind === "SshAgentClient";
512
+ }
513
+ /**
514
+ * Check if this is a General error.
515
+ */
516
+ isGeneral() {
517
+ return this.errorKind === "General";
518
+ }
519
+ };
520
+ /**
521
+ * Type guard to check if a result is an Error.
522
+ */
523
+ function isError(result) {
524
+ return result instanceof Error;
525
+ }
526
+ /**
527
+ * Type guard to check if a result is a CryptoError.
528
+ */
529
+ function isCryptoError(result) {
530
+ return result instanceof CryptoError;
531
+ }
532
+ /**
533
+ * Type guard to check if an error is a CryptoError of a specific kind.
534
+ */
535
+ function isCryptoErrorKind(result, kind) {
536
+ return isCryptoError(result) && result.errorKind === kind;
537
+ }
538
+ //#endregion
43
539
  //#region src/private-key-data-provider.ts
44
540
  /**
45
541
  * Type guard to check if an object implements PrivateKeyDataProvider
@@ -62,6 +558,129 @@ function isDecrypter(obj) {
62
558
  return typeof obj === "object" && obj !== null && "encapsulationPrivateKey" in obj && typeof obj.encapsulationPrivateKey === "function" && "decapsulateSharedSecret" in obj && typeof obj.decapsulateSharedSecret === "function";
63
559
  }
64
560
  //#endregion
561
+ //#region src/utils.ts
562
+ /**
563
+ * Copyright © 2023-2026 Blockchain Commons, LLC
564
+ * Copyright © 2025-2026 Parity Technologies
565
+ *
566
+ *
567
+ * Utility functions for byte array conversions and comparisons.
568
+ *
569
+ * These functions provide cross-platform support for common byte manipulation
570
+ * operations needed in cryptographic and encoding contexts.
571
+ *
572
+ * @packageDocumentation
573
+ */
574
+ /**
575
+ * Convert a Uint8Array to a lowercase hexadecimal string.
576
+ *
577
+ * @param data - The byte array to convert
578
+ * @returns A lowercase hex string representation (2 characters per byte)
579
+ *
580
+ * @example
581
+ * ```typescript
582
+ * const bytes = new Uint8Array([0xde, 0xad, 0xbe, 0xef]);
583
+ * bytesToHex(bytes); // "deadbeef"
584
+ * ```
585
+ */
586
+ function bytesToHex(data) {
587
+ return Array.from(data).map((b) => b.toString(16).padStart(2, "0")).join("");
588
+ }
589
+ /**
590
+ * Convert a hexadecimal string to a Uint8Array.
591
+ *
592
+ * @param hex - A hex string (must have even length, case-insensitive)
593
+ * @returns The decoded byte array
594
+ * @throws {Error} If the hex string has odd length or contains invalid characters
595
+ *
596
+ * @example
597
+ * ```typescript
598
+ * hexToBytes("deadbeef"); // Uint8Array([0xde, 0xad, 0xbe, 0xef])
599
+ * hexToBytes("DEADBEEF"); // Uint8Array([0xde, 0xad, 0xbe, 0xef])
600
+ * hexToBytes("xyz"); // throws Error: Invalid hex string
601
+ * ```
602
+ */
603
+ function hexToBytes(hex) {
604
+ if (hex.length % 2 !== 0) throw new Error(`Hex string must have even length, got ${hex.length}`);
605
+ if (!/^[0-9A-Fa-f]*$/.test(hex)) throw new Error("Invalid hex string: contains non-hexadecimal characters");
606
+ const data = new Uint8Array(hex.length / 2);
607
+ for (let i = 0; i < hex.length; i += 2) data[i / 2] = parseInt(hex.substring(i, i + 2), 16);
608
+ return data;
609
+ }
610
+ /**
611
+ * Convert a Uint8Array to a base64-encoded string.
612
+ *
613
+ * This function works in both browser and Node.js environments.
614
+ * Uses btoa which is available in browsers and Node.js 16+.
615
+ *
616
+ * @param data - The byte array to encode
617
+ * @returns A base64-encoded string
618
+ *
619
+ * @example
620
+ * ```typescript
621
+ * const bytes = new Uint8Array([72, 101, 108, 108, 111]); // "Hello"
622
+ * toBase64(bytes); // "SGVsbG8="
623
+ * ```
624
+ */
625
+ function toBase64(data) {
626
+ let binary = "";
627
+ for (const byte of data) binary += String.fromCharCode(byte);
628
+ return btoa(binary);
629
+ }
630
+ /**
631
+ * Convert a base64-encoded string to a Uint8Array.
632
+ *
633
+ * This function works in both browser and Node.js environments.
634
+ * Uses atob which is available in browsers and Node.js 16+.
635
+ *
636
+ * @param base64 - A base64-encoded string
637
+ * @returns The decoded byte array
638
+ *
639
+ * @example
640
+ * ```typescript
641
+ * fromBase64("SGVsbG8="); // Uint8Array([72, 101, 108, 108, 111])
642
+ * ```
643
+ */
644
+ function fromBase64(base64) {
645
+ const binary = atob(base64);
646
+ const bytes = new Uint8Array(binary.length);
647
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
648
+ return bytes;
649
+ }
650
+ /**
651
+ * Compare two Uint8Arrays for equality using constant-time comparison.
652
+ *
653
+ * This function is designed to be resistant to timing attacks by always
654
+ * comparing all bytes regardless of where a difference is found. The
655
+ * comparison time depends only on the length of the arrays, not on where
656
+ * they differ.
657
+ *
658
+ * **Security Note**: If the arrays have different lengths, this function
659
+ * returns `false` immediately, which does leak length information. For
660
+ * cryptographic uses where length should also be secret, ensure both
661
+ * arrays are the same length before comparison.
662
+ *
663
+ * @param a - First byte array
664
+ * @param b - Second byte array
665
+ * @returns `true` if both arrays have the same length and identical contents
666
+ *
667
+ * @example
668
+ * ```typescript
669
+ * const key1 = new Uint8Array([1, 2, 3, 4]);
670
+ * const key2 = new Uint8Array([1, 2, 3, 4]);
671
+ * const key3 = new Uint8Array([1, 2, 3, 5]);
672
+ *
673
+ * bytesEqual(key1, key2); // true
674
+ * bytesEqual(key1, key3); // false
675
+ * ```
676
+ */
677
+ function bytesEqual(a, b) {
678
+ if (a.length !== b.length) return false;
679
+ let result = 0;
680
+ for (let i = 0; i < a.length; i++) result |= a[i] ^ b[i];
681
+ return result === 0;
682
+ }
683
+ //#endregion
65
684
  //#region src/json.ts
66
685
  /**
67
686
  * Copyright © 2023-2026 Blockchain Commons, LLC
@@ -126,7 +745,7 @@ var JSON = class JSON {
126
745
  * Create a new JSON instance from a hexadecimal string.
127
746
  */
128
747
  static fromHex(hex) {
129
- return new JSON(require_digest.hexToBytes(hex));
748
+ return new JSON(hexToBytes(hex));
130
749
  }
131
750
  /**
132
751
  * Return the length of the JSON data in bytes.
@@ -158,7 +777,7 @@ var JSON = class JSON {
158
777
  * Return the data as a hexadecimal string.
159
778
  */
160
779
  hex() {
161
- return require_digest.bytesToHex(this._data);
780
+ return bytesToHex(this._data);
162
781
  }
163
782
  /**
164
783
  * Return a copy of the underlying data.
@@ -241,6 +860,309 @@ var JSON = class JSON {
241
860
  }
242
861
  };
243
862
  //#endregion
863
+ //#region src/digest.ts
864
+ /**
865
+ * Copyright © 2023-2026 Blockchain Commons, LLC
866
+ * Copyright © 2025-2026 Parity Technologies
867
+ *
868
+ *
869
+ * SHA-256 cryptographic digest (32 bytes)
870
+ *
871
+ * Ported from bc-components-rust/src/digest.rs
872
+ *
873
+ * A `Digest` represents the cryptographic hash of some data. In this
874
+ * implementation, SHA-256 is used, which produces a 32-byte hash value.
875
+ * Digests are used throughout the crate for data verification and as unique
876
+ * identifiers derived from data.
877
+ *
878
+ * # CBOR Serialization
879
+ *
880
+ * `Digest` implements the CBOR tagged encoding interfaces, which means it can be
881
+ * serialized to and deserialized from CBOR with a specific tag (TAG_DIGEST = 40001).
882
+ *
883
+ * # UR Serialization
884
+ *
885
+ * When serialized as a Uniform Resource (UR), a `Digest` is represented as a
886
+ * binary blob with the type "digest".
887
+ *
888
+ * @example
889
+ * ```typescript
890
+ * import { Digest } from '@bcts/components';
891
+ *
892
+ * // Create a digest from a string
893
+ * const data = new TextEncoder().encode("hello world");
894
+ * const digest = Digest.fromImage(data);
895
+ *
896
+ * // Validate that the digest matches the original data
897
+ * console.log(digest.validate(data)); // true
898
+ *
899
+ * // Create a digest from a hex string
900
+ * const hexString = "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9";
901
+ * const digest2 = Digest.fromHex(hexString);
902
+ *
903
+ * // Retrieve the digest as hex
904
+ * console.log(digest2.hex()); // b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
905
+ * ```
906
+ */
907
+ var Digest = class Digest {
908
+ static DIGEST_SIZE = _bcts_crypto.SHA256_SIZE;
909
+ _data;
910
+ constructor(data) {
911
+ if (data.length !== Digest.DIGEST_SIZE) throw CryptoError.invalidSize(Digest.DIGEST_SIZE, data.length);
912
+ this._data = new Uint8Array(data);
913
+ }
914
+ /**
915
+ * Get the digest data.
916
+ */
917
+ data() {
918
+ return this._data;
919
+ }
920
+ /**
921
+ * Create a Digest from a 32-byte array.
922
+ */
923
+ static fromData(data) {
924
+ return new Digest(new Uint8Array(data));
925
+ }
926
+ /**
927
+ * Create a Digest from data, validating the length.
928
+ * Alias for fromData for compatibility with Rust API.
929
+ */
930
+ static fromDataRef(data) {
931
+ return Digest.fromData(data);
932
+ }
933
+ /**
934
+ * Create a Digest from hex string.
935
+ *
936
+ * @throws Error if the hex string is not exactly 64 characters.
937
+ */
938
+ static fromHex(hex) {
939
+ return new Digest(hexToBytes(hex));
940
+ }
941
+ /**
942
+ * Compute SHA-256 digest of data (called "image" in Rust).
943
+ *
944
+ * @param image - The data to hash
945
+ */
946
+ static fromImage(image) {
947
+ const hashData = (0, _bcts_crypto.sha256)(image);
948
+ return new Digest(new Uint8Array(hashData));
949
+ }
950
+ /**
951
+ * Compute SHA-256 digest from multiple data parts.
952
+ *
953
+ * The parts are concatenated and then hashed.
954
+ *
955
+ * @param imageParts - Array of byte arrays to concatenate and hash
956
+ */
957
+ static fromImageParts(imageParts) {
958
+ const totalLength = imageParts.reduce((sum, part) => sum + part.length, 0);
959
+ const buf = new Uint8Array(totalLength);
960
+ let offset = 0;
961
+ for (const part of imageParts) {
962
+ buf.set(part, offset);
963
+ offset += part.length;
964
+ }
965
+ return Digest.fromImage(buf);
966
+ }
967
+ /**
968
+ * Compute SHA-256 digest from an array of Digests.
969
+ *
970
+ * The digest bytes are concatenated and then hashed.
971
+ *
972
+ * @param digests - Array of Digests to combine
973
+ */
974
+ static fromDigests(digests) {
975
+ const buf = new Uint8Array(digests.length * Digest.DIGEST_SIZE);
976
+ let offset = 0;
977
+ for (const digest of digests) {
978
+ buf.set(digest._data, offset);
979
+ offset += Digest.DIGEST_SIZE;
980
+ }
981
+ return Digest.fromImage(buf);
982
+ }
983
+ /**
984
+ * Compute SHA-256 digest of data (legacy alias for fromImage).
985
+ * @deprecated Use fromImage instead
986
+ */
987
+ static hash(data) {
988
+ return Digest.fromImage(data);
989
+ }
990
+ /**
991
+ * Get the raw digest bytes as a copy.
992
+ */
993
+ toData() {
994
+ return new Uint8Array(this._data);
995
+ }
996
+ /**
997
+ * Get a reference to the raw digest bytes.
998
+ */
999
+ asBytes() {
1000
+ return this._data;
1001
+ }
1002
+ /**
1003
+ * Get hex string representation.
1004
+ */
1005
+ hex() {
1006
+ return bytesToHex(this._data);
1007
+ }
1008
+ /**
1009
+ * Get hex string representation (alias for hex()).
1010
+ */
1011
+ toHex() {
1012
+ return this.hex();
1013
+ }
1014
+ /**
1015
+ * Get base64 representation.
1016
+ */
1017
+ toBase64() {
1018
+ return toBase64(this._data);
1019
+ }
1020
+ /**
1021
+ * Get the first four bytes of the digest as a hexadecimal string.
1022
+ * Useful for short descriptions.
1023
+ */
1024
+ shortDescription() {
1025
+ return bytesToHex(this._data.slice(0, 4));
1026
+ }
1027
+ /**
1028
+ * Validate the digest against the given image.
1029
+ *
1030
+ * The image is hashed with SHA-256 and compared to this digest.
1031
+ * @returns `true` if the digest matches the image.
1032
+ */
1033
+ validate(image) {
1034
+ return this.equals(Digest.fromImage(image));
1035
+ }
1036
+ /**
1037
+ * Compare with another Digest.
1038
+ */
1039
+ equals(other) {
1040
+ if (this._data.length !== other._data.length) return false;
1041
+ for (let i = 0; i < this._data.length; i++) if (this._data[i] !== other._data[i]) return false;
1042
+ return true;
1043
+ }
1044
+ /**
1045
+ * Compare digests lexicographically.
1046
+ */
1047
+ compare(other) {
1048
+ for (let i = 0; i < this._data.length; i++) {
1049
+ const a = this._data[i];
1050
+ const b = other._data[i];
1051
+ if (a < b) return -1;
1052
+ if (a > b) return 1;
1053
+ }
1054
+ return 0;
1055
+ }
1056
+ /**
1057
+ * Get string representation.
1058
+ */
1059
+ toString() {
1060
+ return `Digest(${this.hex()})`;
1061
+ }
1062
+ /**
1063
+ * A Digest is its own digest provider - returns itself.
1064
+ */
1065
+ digest() {
1066
+ return this;
1067
+ }
1068
+ /**
1069
+ * Returns the CBOR tags associated with Digest.
1070
+ */
1071
+ cborTags() {
1072
+ return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.DIGEST.value]);
1073
+ }
1074
+ /**
1075
+ * Returns the untagged CBOR encoding (as a byte string).
1076
+ */
1077
+ untaggedCbor() {
1078
+ return (0, _bcts_dcbor.toByteString)(this._data);
1079
+ }
1080
+ /**
1081
+ * Returns the tagged CBOR encoding.
1082
+ */
1083
+ taggedCbor() {
1084
+ return (0, _bcts_dcbor.createTaggedCbor)(this);
1085
+ }
1086
+ /**
1087
+ * Returns the tagged value in CBOR binary representation.
1088
+ */
1089
+ taggedCborData() {
1090
+ return this.taggedCbor().toData();
1091
+ }
1092
+ /**
1093
+ * Creates a Digest by decoding it from untagged CBOR.
1094
+ */
1095
+ fromUntaggedCbor(cbor) {
1096
+ const data = (0, _bcts_dcbor.expectBytes)(cbor);
1097
+ return Digest.fromData(data);
1098
+ }
1099
+ /**
1100
+ * Creates a Digest by decoding it from tagged CBOR.
1101
+ */
1102
+ fromTaggedCbor(cbor) {
1103
+ (0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
1104
+ const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
1105
+ return this.fromUntaggedCbor(content);
1106
+ }
1107
+ /**
1108
+ * Static method to decode from tagged CBOR.
1109
+ */
1110
+ static fromTaggedCbor(cbor) {
1111
+ return new Digest(new Uint8Array(Digest.DIGEST_SIZE)).fromTaggedCbor(cbor);
1112
+ }
1113
+ /**
1114
+ * Static method to decode from tagged CBOR binary data.
1115
+ */
1116
+ static fromTaggedCborData(data) {
1117
+ const cbor = (0, _bcts_dcbor.decodeCbor)(data);
1118
+ return Digest.fromTaggedCbor(cbor);
1119
+ }
1120
+ /**
1121
+ * Static method to decode from untagged CBOR binary data.
1122
+ */
1123
+ static fromUntaggedCborData(data) {
1124
+ const bytes = (0, _bcts_dcbor.expectBytes)((0, _bcts_dcbor.decodeCbor)(data));
1125
+ return Digest.fromData(bytes);
1126
+ }
1127
+ /**
1128
+ * Returns the UR representation of the Digest.
1129
+ * Note: URs use untagged CBOR since the type is conveyed by the UR type itself.
1130
+ */
1131
+ ur() {
1132
+ return _bcts_uniform_resources.UR.new("digest", this.untaggedCbor());
1133
+ }
1134
+ /**
1135
+ * Returns the UR string representation.
1136
+ */
1137
+ urString() {
1138
+ return this.ur().string();
1139
+ }
1140
+ /**
1141
+ * Creates a Digest from a UR.
1142
+ */
1143
+ static fromUR(ur) {
1144
+ ur.checkType("digest");
1145
+ return new Digest(new Uint8Array(Digest.DIGEST_SIZE)).fromUntaggedCbor(ur.cbor());
1146
+ }
1147
+ /**
1148
+ * Creates a Digest from a UR string.
1149
+ */
1150
+ static fromURString(urString) {
1151
+ const ur = _bcts_uniform_resources.UR.fromURString(urString);
1152
+ return Digest.fromUR(ur);
1153
+ }
1154
+ /**
1155
+ * Validate the given data against the digest, if any.
1156
+ *
1157
+ * Returns `true` if the digest is `undefined` or if the digest matches the
1158
+ * image's digest. Returns `false` if the digest does not match.
1159
+ */
1160
+ static validateOpt(image, digest) {
1161
+ if (digest === void 0) return true;
1162
+ return digest.validate(image);
1163
+ }
1164
+ };
1165
+ //#endregion
244
1166
  //#region src/compressed.ts
245
1167
  /**
246
1168
  * Copyright © 2023-2026 Blockchain Commons, LLC
@@ -299,7 +1221,7 @@ var Compressed = class Compressed {
299
1221
  /** Optional cryptographic digest of the content */
300
1222
  _digest;
301
1223
  constructor(checksum, decompressedSize, compressedData, digest) {
302
- if (compressedData.length > decompressedSize) throw require_digest.CryptoError.cryptoOperation("compressed data is larger than decompressed size");
1224
+ if (compressedData.length > decompressedSize) throw CryptoError.cryptoOperation("compressed data is larger than decompressed size");
303
1225
  this._checksum = checksum;
304
1226
  this._decompressedSize = decompressedSize;
305
1227
  this._compressedData = new Uint8Array(compressedData);
@@ -358,11 +1280,11 @@ var Compressed = class Compressed {
358
1280
  if (this._compressedData.length >= this._decompressedSize) return new Uint8Array(this._compressedData);
359
1281
  try {
360
1282
  const decompressedData = (0, pako.inflateRaw)(this._compressedData);
361
- if (_bcts_crypto.hash.crc32(decompressedData) !== this._checksum) throw require_digest.CryptoError.cryptoOperation("compressed data checksum mismatch");
1283
+ if (_bcts_crypto.hash.crc32(decompressedData) !== this._checksum) throw CryptoError.cryptoOperation("compressed data checksum mismatch");
362
1284
  return decompressedData;
363
1285
  } catch (e) {
364
- if (e instanceof require_digest.CryptoError) throw e;
365
- throw require_digest.CryptoError.cryptoOperation("corrupt compressed data");
1286
+ if (e instanceof CryptoError) throw e;
1287
+ throw CryptoError.cryptoOperation("corrupt compressed data");
366
1288
  }
367
1289
  }
368
1290
  /**
@@ -435,7 +1357,7 @@ var Compressed = class Compressed {
435
1357
  * Get string representation.
436
1358
  */
437
1359
  toString() {
438
- const checksumHex = require_digest.bytesToHex(new Uint8Array([
1360
+ const checksumHex = bytesToHex(new Uint8Array([
439
1361
  this._checksum >>> 24 & 255,
440
1362
  this._checksum >>> 16 & 255,
441
1363
  this._checksum >>> 8 & 255,
@@ -489,12 +1411,12 @@ var Compressed = class Compressed {
489
1411
  */
490
1412
  fromUntaggedCbor(cborValue) {
491
1413
  const elements = (0, _bcts_dcbor.expectArray)(cborValue);
492
- if (elements.length < 3 || elements.length > 4) throw require_digest.CryptoError.invalidData("invalid number of elements in compressed");
1414
+ if (elements.length < 3 || elements.length > 4) throw CryptoError.invalidData("invalid number of elements in compressed");
493
1415
  const checksum = (0, _bcts_dcbor.expectInteger)(elements[0]);
494
1416
  const decompressedSize = (0, _bcts_dcbor.expectInteger)(elements[1]);
495
1417
  const compressedData = (0, _bcts_dcbor.expectBytes)(elements[2]);
496
1418
  let digest;
497
- if (elements.length === 4) digest = require_digest.Digest.fromTaggedCbor(elements[3]);
1419
+ if (elements.length === 4) digest = Digest.fromTaggedCbor(elements[3]);
498
1420
  return Compressed.new(Number(checksum), Number(decompressedSize), compressedData, digest);
499
1421
  }
500
1422
  /**
@@ -741,15 +1663,48 @@ var HKDFRng = class HKDFRng {
741
1663
  //#endregion
742
1664
  //#region src/digest-provider.ts
743
1665
  /**
1666
+ * Copyright © 2023-2026 Blockchain Commons, LLC
1667
+ * Copyright © 2025-2026 Parity Technologies
1668
+ *
1669
+ *
1670
+ * DigestProvider interface for types that can provide a cryptographic digest.
1671
+ *
1672
+ * Ported from bc-components-rust/src/digest_provider.rs
1673
+ *
1674
+ * A type that can provide a single unique digest that characterizes its contents.
1675
+ * This trait is used to define a common interface for objects that can produce
1676
+ * a cryptographic digest (hash) of their content.
1677
+ *
1678
+ * @example
1679
+ * ```typescript
1680
+ * import { DigestProvider, Digest } from '@bcts/components';
1681
+ *
1682
+ * class Document implements DigestProvider {
1683
+ * private content: Uint8Array;
1684
+ * private cachedDigest?: Digest;
1685
+ *
1686
+ * constructor(content: Uint8Array) {
1687
+ * this.content = content;
1688
+ * }
1689
+ *
1690
+ * digest(): Digest {
1691
+ * if (!this.cachedDigest) {
1692
+ * this.cachedDigest = Digest.fromImage(this.content);
1693
+ * }
1694
+ * return this.cachedDigest;
1695
+ * }
1696
+ * }
1697
+ * ```
1698
+ */
1699
+ /**
744
1700
  * Helper function to get a digest from a byte array.
745
1701
  * This provides DigestProvider-like functionality for raw bytes.
746
1702
  *
747
1703
  * @param data - The byte array to hash
748
1704
  * @returns A Promise resolving to a Digest of the data
749
1705
  */
750
- async function digestFromBytes(data) {
751
- const { Digest } = await Promise.resolve().then(() => require("./digest-DRakTOWS.cjs"));
752
- return Digest.fromImage(data);
1706
+ function digestFromBytes(data) {
1707
+ return Promise.resolve(Digest.fromImage(data));
753
1708
  }
754
1709
  //#endregion
755
1710
  //#region src/nonce.ts
@@ -808,7 +1763,7 @@ var Nonce = class Nonce {
808
1763
  static NONCE_SIZE = _bcts_crypto.SYMMETRIC_NONCE_SIZE;
809
1764
  _data;
810
1765
  constructor(data) {
811
- if (data.length !== Nonce.NONCE_SIZE) throw require_digest.CryptoError.invalidSize(Nonce.NONCE_SIZE, data.length);
1766
+ if (data.length !== Nonce.NONCE_SIZE) throw CryptoError.invalidSize(Nonce.NONCE_SIZE, data.length);
812
1767
  this._data = new Uint8Array(data);
813
1768
  }
814
1769
  /**
@@ -833,7 +1788,7 @@ var Nonce = class Nonce {
833
1788
  * Restores a nonce from data (validates length).
834
1789
  */
835
1790
  static fromDataRef(data) {
836
- if (data.length !== Nonce.NONCE_SIZE) throw require_digest.CryptoError.invalidSize(Nonce.NONCE_SIZE, data.length);
1791
+ if (data.length !== Nonce.NONCE_SIZE) throw CryptoError.invalidSize(Nonce.NONCE_SIZE, data.length);
837
1792
  return Nonce.fromData(data);
838
1793
  }
839
1794
  /**
@@ -848,7 +1803,7 @@ var Nonce = class Nonce {
848
1803
  * @throws Error if the string is not exactly 24 hexadecimal digits.
849
1804
  */
850
1805
  static fromHex(hex) {
851
- return new Nonce(require_digest.hexToBytes(hex));
1806
+ return new Nonce(hexToBytes(hex));
852
1807
  }
853
1808
  /**
854
1809
  * Generate a random nonce using provided RNG.
@@ -878,7 +1833,7 @@ var Nonce = class Nonce {
878
1833
  * The data as a hexadecimal string.
879
1834
  */
880
1835
  hex() {
881
- return require_digest.bytesToHex(this._data);
1836
+ return bytesToHex(this._data);
882
1837
  }
883
1838
  /**
884
1839
  * Get hex string representation (alias for hex()).
@@ -890,7 +1845,7 @@ var Nonce = class Nonce {
890
1845
  * Get base64 representation.
891
1846
  */
892
1847
  toBase64() {
893
- return require_digest.toBase64(this._data);
1848
+ return toBase64(this._data);
894
1849
  }
895
1850
  /**
896
1851
  * Compare with another Nonce.
@@ -1075,7 +2030,7 @@ var Salt = class Salt {
1075
2030
  * Create a new salt from the given hexadecimal string.
1076
2031
  */
1077
2032
  static fromHex(hex) {
1078
- return Salt.fromData(require_digest.hexToBytes(hex));
2033
+ return Salt.fromData(hexToBytes(hex));
1079
2034
  }
1080
2035
  /**
1081
2036
  * Create a specific number of bytes of salt.
@@ -1092,7 +2047,7 @@ var Salt = class Salt {
1092
2047
  * @throws Error if the number of bytes is less than 8.
1093
2048
  */
1094
2049
  static newWithLenUsing(count, rng) {
1095
- if (count < MIN_SALT_SIZE) throw require_digest.CryptoError.dataTooShort("salt", MIN_SALT_SIZE, count);
2050
+ if (count < MIN_SALT_SIZE) throw CryptoError.dataTooShort("salt", MIN_SALT_SIZE, count);
1096
2051
  return new Salt(rng.randomData(count));
1097
2052
  }
1098
2053
  /**
@@ -1101,7 +2056,7 @@ var Salt = class Salt {
1101
2056
  * @throws Error if the minimum number of bytes is less than 8.
1102
2057
  */
1103
2058
  static newInRange(minSize, maxSize) {
1104
- if (minSize < MIN_SALT_SIZE) throw require_digest.CryptoError.dataTooShort("salt", MIN_SALT_SIZE, minSize);
2059
+ if (minSize < MIN_SALT_SIZE) throw CryptoError.dataTooShort("salt", MIN_SALT_SIZE, minSize);
1105
2060
  const rng = new _bcts_rand.SecureRandomNumberGenerator();
1106
2061
  return Salt.newInRangeUsing(minSize, maxSize, rng);
1107
2062
  }
@@ -1111,7 +2066,7 @@ var Salt = class Salt {
1111
2066
  * @throws Error if the minimum number of bytes is less than 8.
1112
2067
  */
1113
2068
  static newInRangeUsing(minSize, maxSize, rng) {
1114
- if (minSize < MIN_SALT_SIZE) throw require_digest.CryptoError.dataTooShort("salt", MIN_SALT_SIZE, minSize);
2069
+ if (minSize < MIN_SALT_SIZE) throw CryptoError.dataTooShort("salt", MIN_SALT_SIZE, minSize);
1115
2070
  const count = (0, _bcts_rand.rngNextInClosedRangeI32)(rng, minSize, maxSize);
1116
2071
  return Salt.newWithLenUsing(count, rng);
1117
2072
  }
@@ -1185,7 +2140,7 @@ var Salt = class Salt {
1185
2140
  * The data as a hexadecimal string.
1186
2141
  */
1187
2142
  hex() {
1188
- return require_digest.bytesToHex(this._data);
2143
+ return bytesToHex(this._data);
1189
2144
  }
1190
2145
  /**
1191
2146
  * Get hex string representation (alias for hex()).
@@ -1197,7 +2152,7 @@ var Salt = class Salt {
1197
2152
  * Get base64 representation.
1198
2153
  */
1199
2154
  toBase64() {
1200
- return require_digest.toBase64(this._data);
2155
+ return toBase64(this._data);
1201
2156
  }
1202
2157
  /**
1203
2158
  * Compare with another Salt.
@@ -1352,7 +2307,7 @@ var Seed = class Seed {
1352
2307
  _note;
1353
2308
  _creationDate;
1354
2309
  constructor(data, name, note, creationDate) {
1355
- if (data.length < Seed.MIN_SEED_LENGTH) throw require_digest.CryptoError.dataTooShort("seed", Seed.MIN_SEED_LENGTH, data.length);
2310
+ if (data.length < Seed.MIN_SEED_LENGTH) throw CryptoError.dataTooShort("seed", Seed.MIN_SEED_LENGTH, data.length);
1356
2311
  this._data = new Uint8Array(data);
1357
2312
  this._name = name ?? "";
1358
2313
  this._note = note ?? "";
@@ -1423,7 +2378,7 @@ var Seed = class Seed {
1423
2378
  * @param metadata - Optional metadata object
1424
2379
  */
1425
2380
  static fromHex(hex, metadata) {
1426
- return Seed.from(require_digest.hexToBytes(hex), metadata);
2381
+ return Seed.from(hexToBytes(hex), metadata);
1427
2382
  }
1428
2383
  /**
1429
2384
  * Generate a random seed with specified size (default 32 bytes).
@@ -1478,13 +2433,13 @@ var Seed = class Seed {
1478
2433
  * Get hex string representation.
1479
2434
  */
1480
2435
  toHex() {
1481
- return require_digest.bytesToHex(this._data);
2436
+ return bytesToHex(this._data);
1482
2437
  }
1483
2438
  /**
1484
2439
  * Get base64 representation.
1485
2440
  */
1486
2441
  toBase64() {
1487
- return require_digest.toBase64(this._data);
2442
+ return toBase64(this._data);
1488
2443
  }
1489
2444
  /**
1490
2445
  * Get seed size in bytes.
@@ -1637,7 +2592,7 @@ var Seed = class Seed {
1637
2592
  fromUntaggedCbor(cborValue) {
1638
2593
  const map = (0, _bcts_dcbor.expectMap)(cborValue);
1639
2594
  const data = map.extract(1);
1640
- if (data.length === 0) throw require_digest.CryptoError.invalidData("Seed data is empty");
2595
+ if (data.length === 0) throw CryptoError.invalidData("Seed data is empty");
1641
2596
  let creationDate;
1642
2597
  const dateValue = map.get(2);
1643
2598
  if (dateValue !== void 0) creationDate = _bcts_dcbor.CborDate.fromTaggedCbor((0, _bcts_dcbor.cbor)(dateValue)).datetime();
@@ -1745,7 +2700,7 @@ var Reference = class Reference {
1745
2700
  }
1746
2701
  /** Create a Reference from exactly 32 bytes. Mirrors Rust `Reference::from_data`. */
1747
2702
  static fromData(data) {
1748
- if (data.length !== Reference.REFERENCE_SIZE) throw require_digest.CryptoError.invalidSize(Reference.REFERENCE_SIZE, data.length);
2703
+ if (data.length !== Reference.REFERENCE_SIZE) throw CryptoError.invalidSize(Reference.REFERENCE_SIZE, data.length);
1749
2704
  return new Reference(new Uint8Array(data));
1750
2705
  }
1751
2706
  /** Alias of `fromData` for parity with Rust `from_data_ref`. */
@@ -1762,7 +2717,7 @@ var Reference = class Reference {
1762
2717
  }
1763
2718
  /** Create a Reference from a 64-character hex string. */
1764
2719
  static fromHex(hex) {
1765
- return Reference.fromData(require_digest.hexToBytes(hex));
2720
+ return Reference.fromData(hexToBytes(hex));
1766
2721
  }
1767
2722
  /**
1768
2723
  * Create a Reference whose bytes are the SHA-256 digest of the input.
@@ -1772,7 +2727,7 @@ var Reference = class Reference {
1772
2727
  * that should be wrapped without hashing (matches Rust `from_data`).
1773
2728
  */
1774
2729
  static hash(data) {
1775
- return Reference.fromDigest(require_digest.Digest.fromImage(data));
2730
+ return Reference.fromDigest(Digest.fromImage(data));
1776
2731
  }
1777
2732
  /** Returns the 32 reference bytes (copy). */
1778
2733
  data() {
@@ -1784,11 +2739,11 @@ var Reference = class Reference {
1784
2739
  }
1785
2740
  /** Returns a `Digest` constructed from these 32 bytes (no hashing). */
1786
2741
  getDigest() {
1787
- return require_digest.Digest.fromData(this._data);
2742
+ return Digest.fromData(this._data);
1788
2743
  }
1789
2744
  /** The full 64-character lowercase hex of the reference. */
1790
2745
  refHex() {
1791
- return require_digest.bytesToHex(this._data);
2746
+ return bytesToHex(this._data);
1792
2747
  }
1793
2748
  /** The first 4 bytes of the reference. */
1794
2749
  refDataShort() {
@@ -1796,7 +2751,7 @@ var Reference = class Reference {
1796
2751
  }
1797
2752
  /** The first 4 bytes of the reference, as 8 lowercase hex characters. */
1798
2753
  refHexShort() {
1799
- return require_digest.bytesToHex(this._data.slice(0, 4));
2754
+ return bytesToHex(this._data.slice(0, 4));
1800
2755
  }
1801
2756
  /**
1802
2757
  * The first 4 bytes as upper-case bytewords identifier.
@@ -1826,7 +2781,7 @@ var Reference = class Reference {
1826
2781
  }
1827
2782
  /** Returns the 32 raw bytes encoded as base64. */
1828
2783
  toBase64() {
1829
- return require_digest.toBase64(this._data);
2784
+ return toBase64(this._data);
1830
2785
  }
1831
2786
  /**
1832
2787
  * Returns a short representation of this reference in the requested format.
@@ -1841,7 +2796,7 @@ var Reference = class Reference {
1841
2796
  case "bytemojis": return (0, _bcts_uniform_resources.encodeBytemojisIdentifier)(this.refDataShort());
1842
2797
  default: {
1843
2798
  const _exhaustive = format;
1844
- throw require_digest.CryptoError.invalidFormat(`Unknown reference format: ${String(_exhaustive)}`);
2799
+ throw CryptoError.invalidFormat(`Unknown reference format: ${String(_exhaustive)}`);
1845
2800
  }
1846
2801
  }
1847
2802
  }
@@ -1856,7 +2811,7 @@ var Reference = class Reference {
1856
2811
  * `Digest::from_image(self.tagged_cbor().to_cbor_data())`.
1857
2812
  */
1858
2813
  digest() {
1859
- return require_digest.Digest.fromImage(this.taggedCborData());
2814
+ return Digest.fromImage(this.taggedCborData());
1860
2815
  }
1861
2816
  cborTags() {
1862
2817
  return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.REFERENCE.value]);
@@ -1970,7 +2925,7 @@ var ARID = class ARID {
1970
2925
  static ARID_SIZE = 32;
1971
2926
  _data;
1972
2927
  constructor(data) {
1973
- if (data.length !== ARID.ARID_SIZE) throw require_digest.CryptoError.invalidSize(ARID.ARID_SIZE, data.length);
2928
+ if (data.length !== ARID.ARID_SIZE) throw CryptoError.invalidSize(ARID.ARID_SIZE, data.length);
1974
2929
  this._data = new Uint8Array(data);
1975
2930
  }
1976
2931
  /**
@@ -1995,7 +2950,7 @@ var ARID = class ARID {
1995
2950
  * Create a new ARID from a reference to an array of bytes.
1996
2951
  */
1997
2952
  static fromDataRef(data) {
1998
- if (data.length !== ARID.ARID_SIZE) throw require_digest.CryptoError.invalidSize(ARID.ARID_SIZE, data.length);
2953
+ if (data.length !== ARID.ARID_SIZE) throw CryptoError.invalidSize(ARID.ARID_SIZE, data.length);
1999
2954
  return ARID.fromData(data);
2000
2955
  }
2001
2956
  /**
@@ -2010,7 +2965,7 @@ var ARID = class ARID {
2010
2965
  * @throws Error if the string is not exactly 64 hexadecimal digits.
2011
2966
  */
2012
2967
  static fromHex(hex) {
2013
- return new ARID(require_digest.hexToBytes(hex));
2968
+ return new ARID(hexToBytes(hex));
2014
2969
  }
2015
2970
  /**
2016
2971
  * Get the data of the ARID as an array of bytes.
@@ -2034,7 +2989,7 @@ var ARID = class ARID {
2034
2989
  * The data as a hexadecimal string.
2035
2990
  */
2036
2991
  hex() {
2037
- return require_digest.bytesToHex(this._data);
2992
+ return bytesToHex(this._data);
2038
2993
  }
2039
2994
  /**
2040
2995
  * Get hex string representation (alias for hex()).
@@ -2046,13 +3001,13 @@ var ARID = class ARID {
2046
3001
  * Get base64 representation.
2047
3002
  */
2048
3003
  toBase64() {
2049
- return require_digest.toBase64(this._data);
3004
+ return toBase64(this._data);
2050
3005
  }
2051
3006
  /**
2052
3007
  * The first four bytes of the ARID as a hexadecimal string.
2053
3008
  */
2054
3009
  shortDescription() {
2055
- return require_digest.bytesToHex(this._data.slice(0, 4));
3010
+ return bytesToHex(this._data.slice(0, 4));
2056
3011
  }
2057
3012
  /**
2058
3013
  * Compare with another ARID.
@@ -2212,7 +3167,7 @@ var UUID = class UUID {
2212
3167
  static UUID_SIZE = UUID_SIZE;
2213
3168
  _data;
2214
3169
  constructor(data) {
2215
- if (data.length !== UUID_SIZE) throw require_digest.CryptoError.invalidSize(UUID_SIZE, data.length);
3170
+ if (data.length !== UUID_SIZE) throw CryptoError.invalidSize(UUID_SIZE, data.length);
2216
3171
  this._data = new Uint8Array(data);
2217
3172
  }
2218
3173
  /**
@@ -2231,7 +3186,7 @@ var UUID = class UUID {
2231
3186
  * Restores a UUID from data (validates length).
2232
3187
  */
2233
3188
  static fromDataRef(data) {
2234
- if (data.length !== UUID_SIZE) throw require_digest.CryptoError.invalidSize(UUID_SIZE, data.length);
3189
+ if (data.length !== UUID_SIZE) throw CryptoError.invalidSize(UUID_SIZE, data.length);
2235
3190
  return UUID.fromData(data);
2236
3191
  }
2237
3192
  /**
@@ -2244,7 +3199,7 @@ var UUID = class UUID {
2244
3199
  * Create a UUID from hex string (32 hex chars)
2245
3200
  */
2246
3201
  static fromHex(hex) {
2247
- if (hex.length !== 32) throw require_digest.CryptoError.invalidFormat(`UUID hex must be 32 characters, got ${hex.length}`);
3202
+ if (hex.length !== 32) throw CryptoError.invalidFormat(`UUID hex must be 32 characters, got ${hex.length}`);
2248
3203
  const data = new Uint8Array(16);
2249
3204
  for (let i = 0; i < 16; i++) data[i] = parseInt(hex.substring(i * 2, i * 2 + 2), 16);
2250
3205
  return new UUID(data);
@@ -2254,7 +3209,7 @@ var UUID = class UUID {
2254
3209
  * Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2255
3210
  */
2256
3211
  static fromString(uuidString) {
2257
- if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(uuidString)) throw require_digest.CryptoError.invalidFormat(`Invalid UUID format: ${uuidString}`);
3212
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(uuidString)) throw CryptoError.invalidFormat(`Invalid UUID format: ${uuidString}`);
2258
3213
  const hex = uuidString.replace(/-/g, "");
2259
3214
  return UUID.fromHex(hex);
2260
3215
  }
@@ -2290,7 +3245,7 @@ var UUID = class UUID {
2290
3245
  * Get hex string representation (lowercase, matching Rust implementation).
2291
3246
  */
2292
3247
  hex() {
2293
- return require_digest.bytesToHex(this._data);
3248
+ return bytesToHex(this._data);
2294
3249
  }
2295
3250
  /**
2296
3251
  * Get hex string representation (alias for hex()).
@@ -2310,7 +3265,7 @@ var UUID = class UUID {
2310
3265
  * Get base64 representation.
2311
3266
  */
2312
3267
  toBase64() {
2313
- return require_digest.toBase64(this._data);
3268
+ return toBase64(this._data);
2314
3269
  }
2315
3270
  /**
2316
3271
  * Compare with another UUID.
@@ -2462,7 +3417,7 @@ var XID = class XID {
2462
3417
  static XID_SIZE = XID_SIZE;
2463
3418
  _data;
2464
3419
  constructor(data) {
2465
- if (data.length !== XID_SIZE) throw require_digest.CryptoError.invalidSize(XID_SIZE, data.length);
3420
+ if (data.length !== XID_SIZE) throw CryptoError.invalidSize(XID_SIZE, data.length);
2466
3421
  this._data = new Uint8Array(data);
2467
3422
  }
2468
3423
  /**
@@ -2477,7 +3432,7 @@ var XID = class XID {
2477
3432
  * Returns error if the data is not the correct length.
2478
3433
  */
2479
3434
  static fromDataRef(data) {
2480
- if (data.length !== XID_SIZE) throw require_digest.CryptoError.invalidSize(XID_SIZE, data.length);
3435
+ if (data.length !== XID_SIZE) throw CryptoError.invalidSize(XID_SIZE, data.length);
2481
3436
  return XID.fromData(data);
2482
3437
  }
2483
3438
  /**
@@ -2490,7 +3445,7 @@ var XID = class XID {
2490
3445
  * Create an XID from hex string (64 hex characters).
2491
3446
  */
2492
3447
  static fromHex(hex) {
2493
- if (hex.length !== 64) throw require_digest.CryptoError.invalidFormat(`XID hex must be 64 characters, got ${hex.length}`);
3448
+ if (hex.length !== 64) throw CryptoError.invalidFormat(`XID hex must be 64 characters, got ${hex.length}`);
2494
3449
  const data = new Uint8Array(32);
2495
3450
  for (let i = 0; i < 32; i++) data[i] = parseInt(hex.substring(i * 2, i * 2 + 2), 16);
2496
3451
  return new XID(data);
@@ -2516,7 +3471,7 @@ var XID = class XID {
2516
3471
  */
2517
3472
  static newFromSigningKey(signingPublicKey) {
2518
3473
  const keyCborData = signingPublicKey.taggedCborData();
2519
- const digest = require_digest.Digest.fromImage(keyCborData);
3474
+ const digest = Digest.fromImage(keyCborData);
2520
3475
  return XID.fromData(digest.toData());
2521
3476
  }
2522
3477
  /**
@@ -2555,7 +3510,7 @@ var XID = class XID {
2555
3510
  */
2556
3511
  validate(signingPublicKey) {
2557
3512
  const keyData = signingPublicKey.taggedCborData();
2558
- const digest = require_digest.Digest.fromImage(keyData);
3513
+ const digest = Digest.fromImage(keyData);
2559
3514
  return this.equals(XID.fromData(digest.toData()));
2560
3515
  }
2561
3516
  /**
@@ -2580,19 +3535,19 @@ var XID = class XID {
2580
3535
  * Get hex string representation (lowercase, matching Rust implementation).
2581
3536
  */
2582
3537
  toHex() {
2583
- return require_digest.bytesToHex(this._data);
3538
+ return bytesToHex(this._data);
2584
3539
  }
2585
3540
  /**
2586
3541
  * Get base64 representation.
2587
3542
  */
2588
3543
  toBase64() {
2589
- return require_digest.toBase64(this._data);
3544
+ return toBase64(this._data);
2590
3545
  }
2591
3546
  /**
2592
3547
  * Get short description (first 4 bytes) as hex.
2593
3548
  */
2594
3549
  shortDescription() {
2595
- return require_digest.bytesToHex(this._data.slice(0, 4));
3550
+ return bytesToHex(this._data.slice(0, 4));
2596
3551
  }
2597
3552
  /**
2598
3553
  * Get short reference (first 4 bytes) as hex (alias for shortDescription).
@@ -2782,7 +3737,7 @@ var URI = class URI {
2782
3737
  new URL(uri);
2783
3738
  return new URI(uri);
2784
3739
  } catch {
2785
- throw require_digest.CryptoError.invalidData("URI: invalid URI format");
3740
+ throw CryptoError.invalidData("URI: invalid URI format");
2786
3741
  }
2787
3742
  }
2788
3743
  /**
@@ -2866,7 +3821,7 @@ var URI = class URI {
2866
3821
  * Get base64 representation of the URI string.
2867
3822
  */
2868
3823
  toBase64() {
2869
- return require_digest.toBase64(new TextEncoder().encode(this._uri));
3824
+ return toBase64(new TextEncoder().encode(this._uri));
2870
3825
  }
2871
3826
  /**
2872
3827
  * Get the length of the URI string.
@@ -2974,7 +3929,7 @@ var URI = class URI {
2974
3929
  var Ed25519PublicKey = class Ed25519PublicKey {
2975
3930
  _data;
2976
3931
  constructor(data) {
2977
- if (data.length !== _bcts_crypto.ED25519_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE, data.length);
3932
+ if (data.length !== _bcts_crypto.ED25519_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE, data.length);
2978
3933
  this._data = new Uint8Array(data);
2979
3934
  }
2980
3935
  /**
@@ -2993,14 +3948,14 @@ var Ed25519PublicKey = class Ed25519PublicKey {
2993
3948
  * Mirror of Rust `Ed25519PublicKey::from_data_ref` — validates length.
2994
3949
  */
2995
3950
  static fromDataRef(data) {
2996
- if (data.length !== _bcts_crypto.ED25519_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE, data.length);
3951
+ if (data.length !== _bcts_crypto.ED25519_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE, data.length);
2997
3952
  return new Ed25519PublicKey(data);
2998
3953
  }
2999
3954
  /**
3000
3955
  * Create an Ed25519PublicKey from hex string.
3001
3956
  */
3002
3957
  static fromHex(hex) {
3003
- return new Ed25519PublicKey(require_digest.hexToBytes(hex));
3958
+ return new Ed25519PublicKey(hexToBytes(hex));
3004
3959
  }
3005
3960
  /** Returns the 32 raw public key bytes (copy). */
3006
3961
  data() {
@@ -3018,23 +3973,23 @@ var Ed25519PublicKey = class Ed25519PublicKey {
3018
3973
  * Get hex string representation
3019
3974
  */
3020
3975
  toHex() {
3021
- return require_digest.bytesToHex(this._data);
3976
+ return bytesToHex(this._data);
3022
3977
  }
3023
3978
  /**
3024
3979
  * Get base64 representation
3025
3980
  */
3026
3981
  toBase64() {
3027
- return require_digest.toBase64(this._data);
3982
+ return toBase64(this._data);
3028
3983
  }
3029
3984
  /**
3030
3985
  * Verify a signature using Ed25519
3031
3986
  */
3032
3987
  verify(message, signature) {
3033
3988
  try {
3034
- if (signature.length !== _bcts_crypto.ED25519_SIGNATURE_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ED25519_SIGNATURE_SIZE, signature.length);
3989
+ if (signature.length !== _bcts_crypto.ED25519_SIGNATURE_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ED25519_SIGNATURE_SIZE, signature.length);
3035
3990
  return (0, _bcts_crypto.ed25519Verify)(this._data, message, signature);
3036
3991
  } catch (e) {
3037
- throw require_digest.CryptoError.cryptoOperation(`Ed25519 verification failed: ${String(e)}`);
3992
+ throw CryptoError.cryptoOperation(`Ed25519 verification failed: ${String(e)}`);
3038
3993
  }
3039
3994
  }
3040
3995
  /**
@@ -3055,7 +4010,7 @@ var Ed25519PublicKey = class Ed25519PublicKey {
3055
4010
  * (not tagged CBOR) — same pattern as SchnorrPublicKey.
3056
4011
  */
3057
4012
  toString() {
3058
- return `Ed25519PublicKey(${require_digest.Digest.fromImage(this._data).shortDescription()})`;
4013
+ return `Ed25519PublicKey(${Digest.fromImage(this._data).shortDescription()})`;
3059
4014
  }
3060
4015
  };
3061
4016
  //#endregion
@@ -3072,7 +4027,7 @@ var Ed25519PrivateKey = class Ed25519PrivateKey {
3072
4027
  seed;
3073
4028
  _publicKey;
3074
4029
  constructor(seed) {
3075
- if (seed.length !== _bcts_crypto.ED25519_PRIVATE_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ED25519_PRIVATE_KEY_SIZE, seed.length);
4030
+ if (seed.length !== _bcts_crypto.ED25519_PRIVATE_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ED25519_PRIVATE_KEY_SIZE, seed.length);
3076
4031
  this.seed = new Uint8Array(seed);
3077
4032
  }
3078
4033
  /**
@@ -3085,7 +4040,7 @@ var Ed25519PrivateKey = class Ed25519PrivateKey {
3085
4040
  * Create an Ed25519PrivateKey from hex string (64 hex characters)
3086
4041
  */
3087
4042
  static fromHex(hex) {
3088
- return new Ed25519PrivateKey(require_digest.hexToBytes(hex));
4043
+ return new Ed25519PrivateKey(hexToBytes(hex));
3089
4044
  }
3090
4045
  /**
3091
4046
  * Generate a random Ed25519PrivateKey
@@ -3125,13 +4080,13 @@ var Ed25519PrivateKey = class Ed25519PrivateKey {
3125
4080
  * Get hex string representation of the seed
3126
4081
  */
3127
4082
  toHex() {
3128
- return require_digest.bytesToHex(this.seed);
4083
+ return bytesToHex(this.seed);
3129
4084
  }
3130
4085
  /**
3131
4086
  * Get base64 representation of the seed
3132
4087
  */
3133
4088
  toBase64() {
3134
- return require_digest.toBase64(this.seed);
4089
+ return toBase64(this.seed);
3135
4090
  }
3136
4091
  /**
3137
4092
  * Derive the corresponding public key
@@ -3151,7 +4106,7 @@ var Ed25519PrivateKey = class Ed25519PrivateKey {
3151
4106
  const signature = (0, _bcts_crypto.ed25519Sign)(this.seed, message);
3152
4107
  return new Uint8Array(signature);
3153
4108
  } catch (e) {
3154
- throw require_digest.CryptoError.cryptoOperation(`Ed25519 signing failed: ${String(e)}`);
4109
+ throw CryptoError.cryptoOperation(`Ed25519 signing failed: ${String(e)}`);
3155
4110
  }
3156
4111
  }
3157
4112
  /**
@@ -3227,7 +4182,7 @@ var Sr25519PublicKey = class Sr25519PublicKey {
3227
4182
  * Returns the hex representation of the key.
3228
4183
  */
3229
4184
  toHex() {
3230
- return require_digest.bytesToHex(this._data);
4185
+ return bytesToHex(this._data);
3231
4186
  }
3232
4187
  /**
3233
4188
  * Verify a signature using the default "substrate" context.
@@ -3254,7 +4209,7 @@ var Sr25519PublicKey = class Sr25519PublicKey {
3254
4209
  * @throws CryptoError if `context` is not the substrate default
3255
4210
  */
3256
4211
  verifyWithContext(signature, message, context) {
3257
- if (!require_digest.bytesEqual(context, SR25519_DEFAULT_CONTEXT)) throw require_digest.CryptoError.cryptoOperation("Sr25519: only the default substrate context is supported by the underlying library");
4212
+ if (!bytesEqual(context, SR25519_DEFAULT_CONTEXT)) throw CryptoError.cryptoOperation("Sr25519: only the default substrate context is supported by the underlying library");
3258
4213
  try {
3259
4214
  return _scure_sr25519.verify(message, signature, this._data);
3260
4215
  } catch {
@@ -3273,7 +4228,7 @@ var Sr25519PublicKey = class Sr25519PublicKey {
3273
4228
  * Get string representation.
3274
4229
  */
3275
4230
  toString() {
3276
- return `Sr25519PublicKey(${require_digest.bytesToHex(this._data).substring(0, 16)}...)`;
4231
+ return `Sr25519PublicKey(${bytesToHex(this._data).substring(0, 16)}...)`;
3277
4232
  }
3278
4233
  };
3279
4234
  //#endregion
@@ -3396,7 +4351,7 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
3396
4351
  * Returns the hex representation of the seed.
3397
4352
  */
3398
4353
  toHex() {
3399
- return require_digest.bytesToHex(this._seed);
4354
+ return bytesToHex(this._seed);
3400
4355
  }
3401
4356
  /**
3402
4357
  * Derives the corresponding public key.
@@ -3433,7 +4388,7 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
3433
4388
  * @throws CryptoError if `context` is not the substrate default
3434
4389
  */
3435
4390
  signWithContext(message, context) {
3436
- if (!require_digest.bytesEqual(context, SR25519_DEFAULT_CONTEXT)) throw require_digest.CryptoError.cryptoOperation("Sr25519: only the default substrate context is supported by the underlying library");
4391
+ if (!bytesEqual(context, SR25519_DEFAULT_CONTEXT)) throw CryptoError.cryptoOperation("Sr25519: only the default substrate context is supported by the underlying library");
3437
4392
  const secretKey = _scure_sr25519.secretFromSeed(this._seed);
3438
4393
  return _scure_sr25519.sign(secretKey, message);
3439
4394
  }
@@ -3449,7 +4404,7 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
3449
4404
  * Get string representation (truncated for security).
3450
4405
  */
3451
4406
  toString() {
3452
- return `Sr25519PrivateKey(${require_digest.bytesToHex(this._seed).substring(0, 8)}...)`;
4407
+ return `Sr25519PrivateKey(${bytesToHex(this._seed).substring(0, 8)}...)`;
3453
4408
  }
3454
4409
  };
3455
4410
  //#endregion
@@ -3485,7 +4440,7 @@ var ECUncompressedPublicKey = class ECUncompressedPublicKey {
3485
4440
  static KEY_SIZE = _bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE;
3486
4441
  _data;
3487
4442
  constructor(data) {
3488
- if (data.length !== _bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE, data.length);
4443
+ if (data.length !== _bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE, data.length);
3489
4444
  this._data = new Uint8Array(data);
3490
4445
  }
3491
4446
  /**
@@ -3499,7 +4454,7 @@ var ECUncompressedPublicKey = class ECUncompressedPublicKey {
3499
4454
  * Validates the length.
3500
4455
  */
3501
4456
  static fromDataRef(data) {
3502
- if (data.length !== _bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE, data.length);
4457
+ if (data.length !== _bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ECDSA_UNCOMPRESSED_PUBLIC_KEY_SIZE, data.length);
3503
4458
  return ECUncompressedPublicKey.fromData(data);
3504
4459
  }
3505
4460
  /**
@@ -3512,7 +4467,7 @@ var ECUncompressedPublicKey = class ECUncompressedPublicKey {
3512
4467
  * Restore an ECUncompressedPublicKey from a hex string.
3513
4468
  */
3514
4469
  static fromHex(hex) {
3515
- return ECUncompressedPublicKey.fromData(require_digest.hexToBytes(hex));
4470
+ return ECUncompressedPublicKey.fromData(hexToBytes(hex));
3516
4471
  }
3517
4472
  /**
3518
4473
  * Get a reference to the fixed-size array of bytes.
@@ -3530,7 +4485,7 @@ var ECUncompressedPublicKey = class ECUncompressedPublicKey {
3530
4485
  * Get hex string representation.
3531
4486
  */
3532
4487
  hex() {
3533
- return require_digest.bytesToHex(this._data);
4488
+ return bytesToHex(this._data);
3534
4489
  }
3535
4490
  /**
3536
4491
  * Get hex string representation (alias for hex()).
@@ -3542,7 +4497,7 @@ var ECUncompressedPublicKey = class ECUncompressedPublicKey {
3542
4497
  * Get base64 representation.
3543
4498
  */
3544
4499
  toBase64() {
3545
- return require_digest.toBase64(this._data);
4500
+ return toBase64(this._data);
3546
4501
  }
3547
4502
  /**
3548
4503
  * Convert to compressed public key format.
@@ -3700,7 +4655,7 @@ var ECPublicKey = class ECPublicKey {
3700
4655
  static KEY_SIZE = _bcts_crypto.ECDSA_PUBLIC_KEY_SIZE;
3701
4656
  _data;
3702
4657
  constructor(data) {
3703
- if (data.length !== _bcts_crypto.ECDSA_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ECDSA_PUBLIC_KEY_SIZE, data.length);
4658
+ if (data.length !== _bcts_crypto.ECDSA_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ECDSA_PUBLIC_KEY_SIZE, data.length);
3704
4659
  this._data = new Uint8Array(data);
3705
4660
  }
3706
4661
  /**
@@ -3714,7 +4669,7 @@ var ECPublicKey = class ECPublicKey {
3714
4669
  * Validates the length.
3715
4670
  */
3716
4671
  static fromDataRef(data) {
3717
- if (data.length !== _bcts_crypto.ECDSA_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ECDSA_PUBLIC_KEY_SIZE, data.length);
4672
+ if (data.length !== _bcts_crypto.ECDSA_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ECDSA_PUBLIC_KEY_SIZE, data.length);
3718
4673
  return ECPublicKey.fromData(data);
3719
4674
  }
3720
4675
  /**
@@ -3727,7 +4682,7 @@ var ECPublicKey = class ECPublicKey {
3727
4682
  * Restore an ECPublicKey from a hex string.
3728
4683
  */
3729
4684
  static fromHex(hex) {
3730
- return ECPublicKey.fromData(require_digest.hexToBytes(hex));
4685
+ return ECPublicKey.fromData(hexToBytes(hex));
3731
4686
  }
3732
4687
  /**
3733
4688
  * Get a reference to the fixed-size array of bytes.
@@ -3745,7 +4700,7 @@ var ECPublicKey = class ECPublicKey {
3745
4700
  * Get hex string representation.
3746
4701
  */
3747
4702
  hex() {
3748
- return require_digest.bytesToHex(this._data);
4703
+ return bytesToHex(this._data);
3749
4704
  }
3750
4705
  /**
3751
4706
  * Get hex string representation (alias for hex()).
@@ -3757,7 +4712,7 @@ var ECPublicKey = class ECPublicKey {
3757
4712
  * Get base64 representation.
3758
4713
  */
3759
4714
  toBase64() {
3760
- return require_digest.toBase64(this._data);
4715
+ return toBase64(this._data);
3761
4716
  }
3762
4717
  /**
3763
4718
  * Returns the compressed public key (self).
@@ -3938,7 +4893,7 @@ var SchnorrPublicKey = class SchnorrPublicKey {
3938
4893
  static KEY_SIZE = _bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE;
3939
4894
  _data;
3940
4895
  constructor(data) {
3941
- if (data.length !== _bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE, data.length);
4896
+ if (data.length !== _bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE, data.length);
3942
4897
  this._data = new Uint8Array(data);
3943
4898
  }
3944
4899
  /**
@@ -3952,7 +4907,7 @@ var SchnorrPublicKey = class SchnorrPublicKey {
3952
4907
  * Validates the length.
3953
4908
  */
3954
4909
  static fromDataRef(data) {
3955
- if (data.length !== _bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE, data.length);
4910
+ if (data.length !== _bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.SCHNORR_PUBLIC_KEY_SIZE, data.length);
3956
4911
  return SchnorrPublicKey.fromData(data);
3957
4912
  }
3958
4913
  /**
@@ -3965,7 +4920,7 @@ var SchnorrPublicKey = class SchnorrPublicKey {
3965
4920
  * Restore a SchnorrPublicKey from a hex string.
3966
4921
  */
3967
4922
  static fromHex(hex) {
3968
- return SchnorrPublicKey.fromData(require_digest.hexToBytes(hex));
4923
+ return SchnorrPublicKey.fromData(hexToBytes(hex));
3969
4924
  }
3970
4925
  /**
3971
4926
  * Get a reference to the fixed-size array of bytes.
@@ -3983,7 +4938,7 @@ var SchnorrPublicKey = class SchnorrPublicKey {
3983
4938
  * Get hex string representation.
3984
4939
  */
3985
4940
  hex() {
3986
- return require_digest.bytesToHex(this._data);
4941
+ return bytesToHex(this._data);
3987
4942
  }
3988
4943
  /**
3989
4944
  * Get hex string representation (alias for hex()).
@@ -3995,7 +4950,7 @@ var SchnorrPublicKey = class SchnorrPublicKey {
3995
4950
  * Get base64 representation.
3996
4951
  */
3997
4952
  toBase64() {
3998
- return require_digest.toBase64(this._data);
4953
+ return toBase64(this._data);
3999
4954
  }
4000
4955
  /**
4001
4956
  * Verify a Schnorr signature (BIP-340).
@@ -4030,7 +4985,7 @@ var SchnorrPublicKey = class SchnorrPublicKey {
4030
4985
  * reference's binary form (= SHA-256(data)[0..4]).
4031
4986
  */
4032
4987
  toString() {
4033
- return `SchnorrPublicKey(${require_digest.Digest.fromImage(this._data).shortDescription()})`;
4988
+ return `SchnorrPublicKey(${Digest.fromImage(this._data).shortDescription()})`;
4034
4989
  }
4035
4990
  };
4036
4991
  //#endregion
@@ -4070,7 +5025,7 @@ var ECPrivateKey = class ECPrivateKey {
4070
5025
  _publicKey;
4071
5026
  _schnorrPublicKey;
4072
5027
  constructor(data) {
4073
- if (data.length !== _bcts_crypto.ECDSA_PRIVATE_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ECDSA_PRIVATE_KEY_SIZE, data.length);
5028
+ if (data.length !== _bcts_crypto.ECDSA_PRIVATE_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ECDSA_PRIVATE_KEY_SIZE, data.length);
4074
5029
  this._data = new Uint8Array(data);
4075
5030
  }
4076
5031
  /**
@@ -4127,7 +5082,7 @@ var ECPrivateKey = class ECPrivateKey {
4127
5082
  * Validates the length.
4128
5083
  */
4129
5084
  static fromDataRef(data) {
4130
- if (data.length !== _bcts_crypto.ECDSA_PRIVATE_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ECDSA_PRIVATE_KEY_SIZE, data.length);
5085
+ if (data.length !== _bcts_crypto.ECDSA_PRIVATE_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ECDSA_PRIVATE_KEY_SIZE, data.length);
4131
5086
  return ECPrivateKey.fromData(data);
4132
5087
  }
4133
5088
  /**
@@ -4140,7 +5095,7 @@ var ECPrivateKey = class ECPrivateKey {
4140
5095
  * Restore an ECPrivateKey from a hex string.
4141
5096
  */
4142
5097
  static fromHex(hex) {
4143
- return ECPrivateKey.fromData(require_digest.hexToBytes(hex));
5098
+ return ECPrivateKey.fromData(hexToBytes(hex));
4144
5099
  }
4145
5100
  /**
4146
5101
  * Get a reference to the fixed-size array of bytes.
@@ -4158,7 +5113,7 @@ var ECPrivateKey = class ECPrivateKey {
4158
5113
  * Get hex string representation.
4159
5114
  */
4160
5115
  hex() {
4161
- return require_digest.bytesToHex(this._data);
5116
+ return bytesToHex(this._data);
4162
5117
  }
4163
5118
  /**
4164
5119
  * Get hex string representation (alias for hex()).
@@ -4170,7 +5125,7 @@ var ECPrivateKey = class ECPrivateKey {
4170
5125
  * Get base64 representation.
4171
5126
  */
4172
5127
  toBase64() {
4173
- return require_digest.toBase64(this._data);
5128
+ return toBase64(this._data);
4174
5129
  }
4175
5130
  /**
4176
5131
  * Get the ECPublicKey (compressed) corresponding to this ECPrivateKey.
@@ -4202,7 +5157,7 @@ var ECPrivateKey = class ECPrivateKey {
4202
5157
  try {
4203
5158
  return (0, _bcts_crypto.ecdsaSign)(this._data, message);
4204
5159
  } catch (e) {
4205
- throw require_digest.CryptoError.cryptoOperation(`ECDSA signing failed: ${String(e)}`);
5160
+ throw CryptoError.cryptoOperation(`ECDSA signing failed: ${String(e)}`);
4206
5161
  }
4207
5162
  }
4208
5163
  /**
@@ -4215,7 +5170,7 @@ var ECPrivateKey = class ECPrivateKey {
4215
5170
  try {
4216
5171
  return (0, _bcts_crypto.schnorrSign)(this._data, message);
4217
5172
  } catch (e) {
4218
- throw require_digest.CryptoError.cryptoOperation(`Schnorr signing failed: ${String(e)}`);
5173
+ throw CryptoError.cryptoOperation(`Schnorr signing failed: ${String(e)}`);
4219
5174
  }
4220
5175
  }
4221
5176
  /**
@@ -4229,7 +5184,7 @@ var ECPrivateKey = class ECPrivateKey {
4229
5184
  try {
4230
5185
  return (0, _bcts_crypto.schnorrSignUsing)(this._data, message, rng);
4231
5186
  } catch (e) {
4232
- throw require_digest.CryptoError.cryptoOperation(`Schnorr signing failed: ${String(e)}`);
5187
+ throw CryptoError.cryptoOperation(`Schnorr signing failed: ${String(e)}`);
4233
5188
  }
4234
5189
  }
4235
5190
  /**
@@ -4619,7 +5574,7 @@ var MLDSAPublicKey = class MLDSAPublicKey {
4619
5574
  * Get string representation.
4620
5575
  */
4621
5576
  toString() {
4622
- const hex = require_digest.bytesToHex(this._data);
5577
+ const hex = bytesToHex(this._data);
4623
5578
  return `MLDSAPublicKey(${mldsaLevelToString(this._level)}, ${hex.substring(0, 16)}...)`;
4624
5579
  }
4625
5580
  /**
@@ -4798,7 +5753,7 @@ var MLDSASignature = class MLDSASignature {
4798
5753
  * Get string representation.
4799
5754
  */
4800
5755
  toString() {
4801
- const hex = require_digest.bytesToHex(this._data);
5756
+ const hex = bytesToHex(this._data);
4802
5757
  return `MLDSASignature(${mldsaLevelToString(this._level)}, ${hex.substring(0, 16)}...)`;
4803
5758
  }
4804
5759
  /**
@@ -5036,7 +5991,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
5036
5991
  * Get string representation (truncated for security).
5037
5992
  */
5038
5993
  toString() {
5039
- const hex = require_digest.bytesToHex(this._data);
5994
+ const hex = bytesToHex(this._data);
5040
5995
  return `MLDSAPrivateKey(${mldsaLevelToString(this._level)}, ${hex.substring(0, 8)}...)`;
5041
5996
  }
5042
5997
  /**
@@ -5150,6 +6105,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
5150
6105
  */
5151
6106
  const MAX_UINT32 = 4294967295;
5152
6107
  var SshBufferReader = class {
6108
+ bytes;
5153
6109
  view;
5154
6110
  offset;
5155
6111
  constructor(bytes) {
@@ -6249,7 +7205,7 @@ var SSHPrivateKey = class SSHPrivateKey {
6249
7205
  if (pubBytes.length !== ED25519_PUBLIC_LEN) throw new Error(`SSHPrivateKey ed25519: public key length ${pubBytes.length} != ${ED25519_PUBLIC_LEN}`);
6250
7206
  if (publicKey.data.kind !== "ed25519" || !bytesEqual$1(pubBytes, publicKey.data.pubBytes)) throw new Error("SSHPrivateKey ed25519: outer/inner public-key mismatch");
6251
7207
  const combined = innerReader.readString();
6252
- if (combined.length !== ED25519_SEED_LEN + ED25519_PUBLIC_LEN) throw new Error(`SSHPrivateKey ed25519: combined seed||public length ${combined.length} != ${ED25519_SEED_LEN + ED25519_PUBLIC_LEN}`);
7208
+ if (combined.length !== 64) throw new Error(`SSHPrivateKey ed25519: combined seed||public length ${combined.length} != 64`);
6253
7209
  if (!bytesEqual$1(combined.subarray(ED25519_SEED_LEN), pubBytes)) throw new Error("SSHPrivateKey ed25519: combined-blob public tail does not match public field");
6254
7210
  data = {
6255
7211
  kind: "ed25519",
@@ -6340,7 +7296,7 @@ var SSHPrivateKey = class SSHPrivateKey {
6340
7296
  switch (this.data.kind) {
6341
7297
  case "ed25519": {
6342
7298
  w.writeString(this.data.pubBytes);
6343
- const combined = new Uint8Array(ED25519_SEED_LEN + ED25519_PUBLIC_LEN);
7299
+ const combined = new Uint8Array(64);
6344
7300
  combined.set(this.data.seed, 0);
6345
7301
  combined.set(this.data.pubBytes, ED25519_SEED_LEN);
6346
7302
  w.writeString(combined);
@@ -6453,7 +7409,7 @@ var X25519PublicKey = class X25519PublicKey {
6453
7409
  static KEY_SIZE = _bcts_crypto.X25519_PUBLIC_KEY_SIZE;
6454
7410
  _data;
6455
7411
  constructor(data) {
6456
- if (data.length !== _bcts_crypto.X25519_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.X25519_PUBLIC_KEY_SIZE, data.length);
7412
+ if (data.length !== _bcts_crypto.X25519_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.X25519_PUBLIC_KEY_SIZE, data.length);
6457
7413
  this._data = new Uint8Array(data);
6458
7414
  }
6459
7415
  /**
@@ -6467,7 +7423,7 @@ var X25519PublicKey = class X25519PublicKey {
6467
7423
  * Validates the length.
6468
7424
  */
6469
7425
  static fromDataRef(data) {
6470
- if (data.length !== _bcts_crypto.X25519_PUBLIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.X25519_PUBLIC_KEY_SIZE, data.length);
7426
+ if (data.length !== _bcts_crypto.X25519_PUBLIC_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.X25519_PUBLIC_KEY_SIZE, data.length);
6471
7427
  return X25519PublicKey.fromData(data);
6472
7428
  }
6473
7429
  /**
@@ -6480,7 +7436,7 @@ var X25519PublicKey = class X25519PublicKey {
6480
7436
  * Restore an X25519PublicKey from a hex string.
6481
7437
  */
6482
7438
  static fromHex(hex) {
6483
- return X25519PublicKey.fromData(require_digest.hexToBytes(hex));
7439
+ return X25519PublicKey.fromData(hexToBytes(hex));
6484
7440
  }
6485
7441
  /**
6486
7442
  * Get a reference to the fixed-size array of bytes.
@@ -6498,7 +7454,7 @@ var X25519PublicKey = class X25519PublicKey {
6498
7454
  * Get hex string representation.
6499
7455
  */
6500
7456
  hex() {
6501
- return require_digest.bytesToHex(this._data);
7457
+ return bytesToHex(this._data);
6502
7458
  }
6503
7459
  /**
6504
7460
  * Get hex string representation (alias for hex()).
@@ -6510,7 +7466,7 @@ var X25519PublicKey = class X25519PublicKey {
6510
7466
  * Get base64 representation.
6511
7467
  */
6512
7468
  toBase64() {
6513
- return require_digest.toBase64(this._data);
7469
+ return toBase64(this._data);
6514
7470
  }
6515
7471
  /**
6516
7472
  * Compare with another X25519PublicKey.
@@ -6529,7 +7485,7 @@ var X25519PublicKey = class X25519PublicKey {
6529
7485
  * computed from the **tagged-CBOR** form of the key.
6530
7486
  */
6531
7487
  toString() {
6532
- return `X25519PublicKey(${require_digest.Digest.fromImage(this.taggedCborData()).shortDescription()})`;
7488
+ return `X25519PublicKey(${Digest.fromImage(this.taggedCborData()).shortDescription()})`;
6533
7489
  }
6534
7490
  /**
6535
7491
  * Returns the CBOR tags associated with X25519PublicKey.
@@ -6650,7 +7606,7 @@ var AuthenticationTag = class AuthenticationTag {
6650
7606
  static AUTHENTICATION_TAG_SIZE = AUTHENTICATION_TAG_SIZE;
6651
7607
  _data;
6652
7608
  constructor(data) {
6653
- if (data.length !== AUTHENTICATION_TAG_SIZE) throw require_digest.CryptoError.invalidSize(AUTHENTICATION_TAG_SIZE, data.length);
7609
+ if (data.length !== AUTHENTICATION_TAG_SIZE) throw CryptoError.invalidSize(AUTHENTICATION_TAG_SIZE, data.length);
6654
7610
  this._data = new Uint8Array(data);
6655
7611
  }
6656
7612
  /**
@@ -6663,7 +7619,7 @@ var AuthenticationTag = class AuthenticationTag {
6663
7619
  * Restore an AuthenticationTag from a reference to an array of bytes.
6664
7620
  */
6665
7621
  static fromDataRef(data) {
6666
- if (data.length !== AUTHENTICATION_TAG_SIZE) throw require_digest.CryptoError.invalidSize(AUTHENTICATION_TAG_SIZE, data.length);
7622
+ if (data.length !== AUTHENTICATION_TAG_SIZE) throw CryptoError.invalidSize(AUTHENTICATION_TAG_SIZE, data.length);
6667
7623
  return AuthenticationTag.fromData(data);
6668
7624
  }
6669
7625
  /**
@@ -6676,7 +7632,7 @@ var AuthenticationTag = class AuthenticationTag {
6676
7632
  * Create an AuthenticationTag from hex string.
6677
7633
  */
6678
7634
  static fromHex(hex) {
6679
- return AuthenticationTag.fromData(require_digest.hexToBytes(hex));
7635
+ return AuthenticationTag.fromData(hexToBytes(hex));
6680
7636
  }
6681
7637
  /**
6682
7638
  * Get a reference to the fixed-size array of bytes.
@@ -6700,13 +7656,13 @@ var AuthenticationTag = class AuthenticationTag {
6700
7656
  * Get hex string representation.
6701
7657
  */
6702
7658
  toHex() {
6703
- return require_digest.bytesToHex(this._data);
7659
+ return bytesToHex(this._data);
6704
7660
  }
6705
7661
  /**
6706
7662
  * Get base64 representation.
6707
7663
  */
6708
7664
  toBase64() {
6709
- return require_digest.toBase64(this._data);
7665
+ return toBase64(this._data);
6710
7666
  }
6711
7667
  /**
6712
7668
  * Compare with another AuthenticationTag.
@@ -6861,7 +7817,7 @@ var EncryptedMessage = class EncryptedMessage {
6861
7817
  const aadCbor = this.aadCbor();
6862
7818
  if (aadCbor === null) return null;
6863
7819
  try {
6864
- return require_digest.Digest.fromTaggedCbor(aadCbor);
7820
+ return Digest.fromTaggedCbor(aadCbor);
6865
7821
  } catch {
6866
7822
  return null;
6867
7823
  }
@@ -6886,7 +7842,7 @@ var EncryptedMessage = class EncryptedMessage {
6886
7842
  * Get string representation.
6887
7843
  */
6888
7844
  toString() {
6889
- return `EncryptedMessage(ciphertext: ${require_digest.bytesToHex(this._ciphertext).substring(0, 16)}..., nonce: ${this._nonce.toHex()}, auth: ${this._auth.toHex()})`;
7845
+ return `EncryptedMessage(ciphertext: ${bytesToHex(this._ciphertext).substring(0, 16)}..., nonce: ${this._nonce.toHex()}, auth: ${this._auth.toHex()})`;
6890
7846
  }
6891
7847
  /**
6892
7848
  * Returns the CBOR tags associated with EncryptedMessage.
@@ -7020,7 +7976,7 @@ var SymmetricKey = class SymmetricKey {
7020
7976
  static SYMMETRIC_KEY_SIZE = SYMMETRIC_KEY_SIZE;
7021
7977
  _data;
7022
7978
  constructor(data) {
7023
- if (data.length !== SYMMETRIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(SYMMETRIC_KEY_SIZE, data.length);
7979
+ if (data.length !== SYMMETRIC_KEY_SIZE) throw CryptoError.invalidSize(SYMMETRIC_KEY_SIZE, data.length);
7024
7980
  this._data = new Uint8Array(data);
7025
7981
  }
7026
7982
  /**
@@ -7039,7 +7995,7 @@ var SymmetricKey = class SymmetricKey {
7039
7995
  * Create a new symmetric key from data (validates length).
7040
7996
  */
7041
7997
  static fromDataRef(data) {
7042
- if (data.length !== SYMMETRIC_KEY_SIZE) throw require_digest.CryptoError.invalidSize(SYMMETRIC_KEY_SIZE, data.length);
7998
+ if (data.length !== SYMMETRIC_KEY_SIZE) throw CryptoError.invalidSize(SYMMETRIC_KEY_SIZE, data.length);
7043
7999
  return SymmetricKey.fromData(data);
7044
8000
  }
7045
8001
  /**
@@ -7052,7 +8008,7 @@ var SymmetricKey = class SymmetricKey {
7052
8008
  * Create a SymmetricKey from hex string.
7053
8009
  */
7054
8010
  static fromHex(hex) {
7055
- return SymmetricKey.fromData(require_digest.hexToBytes(hex));
8011
+ return SymmetricKey.fromData(hexToBytes(hex));
7056
8012
  }
7057
8013
  /**
7058
8014
  * Generate a random symmetric key.
@@ -7089,7 +8045,7 @@ var SymmetricKey = class SymmetricKey {
7089
8045
  * Get hex string representation.
7090
8046
  */
7091
8047
  hex() {
7092
- return require_digest.bytesToHex(this._data);
8048
+ return bytesToHex(this._data);
7093
8049
  }
7094
8050
  /**
7095
8051
  * Get hex string representation (alias for hex()).
@@ -7101,7 +8057,7 @@ var SymmetricKey = class SymmetricKey {
7101
8057
  * Get base64 representation.
7102
8058
  */
7103
8059
  toBase64() {
7104
- return require_digest.toBase64(this._data);
8060
+ return toBase64(this._data);
7105
8061
  }
7106
8062
  /**
7107
8063
  * Compare with another SymmetricKey.
@@ -7266,7 +8222,7 @@ var X25519PrivateKey = class X25519PrivateKey {
7266
8222
  _data;
7267
8223
  _publicKey;
7268
8224
  constructor(data) {
7269
- if (data.length !== _bcts_crypto.X25519_PRIVATE_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.X25519_PRIVATE_KEY_SIZE, data.length);
8225
+ if (data.length !== _bcts_crypto.X25519_PRIVATE_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.X25519_PRIVATE_KEY_SIZE, data.length);
7270
8226
  this._data = new Uint8Array(data);
7271
8227
  }
7272
8228
  /**
@@ -7323,7 +8279,7 @@ var X25519PrivateKey = class X25519PrivateKey {
7323
8279
  * Validates the length.
7324
8280
  */
7325
8281
  static fromDataRef(data) {
7326
- if (data.length !== _bcts_crypto.X25519_PRIVATE_KEY_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.X25519_PRIVATE_KEY_SIZE, data.length);
8282
+ if (data.length !== _bcts_crypto.X25519_PRIVATE_KEY_SIZE) throw CryptoError.invalidSize(_bcts_crypto.X25519_PRIVATE_KEY_SIZE, data.length);
7327
8283
  return X25519PrivateKey.fromData(data);
7328
8284
  }
7329
8285
  /**
@@ -7336,7 +8292,7 @@ var X25519PrivateKey = class X25519PrivateKey {
7336
8292
  * Restore an X25519PrivateKey from a hex string.
7337
8293
  */
7338
8294
  static fromHex(hex) {
7339
- return X25519PrivateKey.fromData(require_digest.hexToBytes(hex));
8295
+ return X25519PrivateKey.fromData(hexToBytes(hex));
7340
8296
  }
7341
8297
  /**
7342
8298
  * Get a reference to the fixed-size array of bytes.
@@ -7354,7 +8310,7 @@ var X25519PrivateKey = class X25519PrivateKey {
7354
8310
  * Get hex string representation.
7355
8311
  */
7356
8312
  hex() {
7357
- return require_digest.bytesToHex(this._data);
8313
+ return bytesToHex(this._data);
7358
8314
  }
7359
8315
  /**
7360
8316
  * Get hex string representation (alias for hex()).
@@ -7366,7 +8322,7 @@ var X25519PrivateKey = class X25519PrivateKey {
7366
8322
  * Get base64 representation.
7367
8323
  */
7368
8324
  toBase64() {
7369
- return require_digest.toBase64(this._data);
8325
+ return toBase64(this._data);
7370
8326
  }
7371
8327
  /**
7372
8328
  * Get the X25519PublicKey corresponding to this X25519PrivateKey.
@@ -7399,7 +8355,7 @@ var X25519PrivateKey = class X25519PrivateKey {
7399
8355
  const shared = (0, _bcts_crypto.x25519SharedKey)(this._data, publicKey.data());
7400
8356
  return new Uint8Array(shared);
7401
8357
  } catch (e) {
7402
- throw require_digest.CryptoError.cryptoOperation(`ECDH key agreement failed: ${String(e)}`);
8358
+ throw CryptoError.cryptoOperation(`ECDH key agreement failed: ${String(e)}`);
7403
8359
  }
7404
8360
  }
7405
8361
  /**
@@ -7880,7 +8836,7 @@ var MLKEMCiphertext = class MLKEMCiphertext {
7880
8836
  * Get string representation.
7881
8837
  */
7882
8838
  toString() {
7883
- const hex = require_digest.bytesToHex(this._data);
8839
+ const hex = bytesToHex(this._data);
7884
8840
  return `MLKEMCiphertext(${mlkemLevelToString(this._level)}, ${hex.substring(0, 16)}...)`;
7885
8841
  }
7886
8842
  /**
@@ -8136,8 +9092,8 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
8136
9092
  * Get string representation.
8137
9093
  */
8138
9094
  toString() {
8139
- if (this._scheme === "x25519") return `EncapsulationCiphertext(X25519, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
8140
- else if (isMlkemScheme$2(this._scheme)) return `EncapsulationCiphertext(${String(this._scheme)}, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
9095
+ if (this._scheme === "x25519") return `EncapsulationCiphertext(X25519, ${bytesToHex(this.data()).substring(0, 16)}...)`;
9096
+ else if (isMlkemScheme$2(this._scheme)) return `EncapsulationCiphertext(${String(this._scheme)}, ${bytesToHex(this.data()).substring(0, 16)}...)`;
8141
9097
  return `EncapsulationCiphertext(${String(this._scheme)})`;
8142
9098
  }
8143
9099
  /**
@@ -8320,7 +9276,7 @@ var MLKEMPublicKey = class MLKEMPublicKey {
8320
9276
  * Get string representation.
8321
9277
  */
8322
9278
  toString() {
8323
- const hex = require_digest.bytesToHex(this._data);
9279
+ const hex = bytesToHex(this._data);
8324
9280
  return `MLKEMPublicKey(${mlkemLevelToString(this._level)}, ${hex.substring(0, 16)}...)`;
8325
9281
  }
8326
9282
  /**
@@ -8635,7 +9591,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
8635
9591
  * representation, providing a unique, content-addressable identifier.
8636
9592
  */
8637
9593
  reference() {
8638
- const digest = require_digest.Digest.fromImage(this.taggedCborData());
9594
+ const digest = Digest.fromImage(this.taggedCborData());
8639
9595
  return Reference.from(digest);
8640
9596
  }
8641
9597
  /**
@@ -8903,7 +9859,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
8903
9859
  * Get string representation (truncated for security).
8904
9860
  */
8905
9861
  toString() {
8906
- const hex = require_digest.bytesToHex(this._data);
9862
+ const hex = bytesToHex(this._data);
8907
9863
  return `MLKEMPrivateKey(${mlkemLevelToString(this._level)}, ${hex.substring(0, 8)}...)`;
8908
9864
  }
8909
9865
  /**
@@ -9229,7 +10185,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
9229
10185
  * @throws CryptoError if the scheme doesn't match
9230
10186
  */
9231
10187
  decapsulateSharedSecret(ciphertext) {
9232
- if (ciphertext.encapsulationScheme() !== this._scheme) throw require_digest.CryptoError.invalidData(`Scheme mismatch: expected ${String(this._scheme)}, got ${String(ciphertext.encapsulationScheme())}`);
10188
+ if (ciphertext.encapsulationScheme() !== this._scheme) throw CryptoError.invalidData(`Scheme mismatch: expected ${String(this._scheme)}, got ${String(ciphertext.encapsulationScheme())}`);
9233
10189
  if (this._scheme === "x25519") {
9234
10190
  const pk = this._x25519PrivateKey;
9235
10191
  if (pk === void 0) throw new Error("X25519 private key not set");
@@ -9265,8 +10221,8 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
9265
10221
  * Get string representation.
9266
10222
  */
9267
10223
  toString() {
9268
- if (this._scheme === "x25519") return `EncapsulationPrivateKey(X25519, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
9269
- else if (isMlkemScheme(this._scheme)) return `EncapsulationPrivateKey(${String(this._scheme)}, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
10224
+ if (this._scheme === "x25519") return `EncapsulationPrivateKey(X25519, ${bytesToHex(this.data()).substring(0, 16)}...)`;
10225
+ else if (isMlkemScheme(this._scheme)) return `EncapsulationPrivateKey(${String(this._scheme)}, ${bytesToHex(this.data()).substring(0, 16)}...)`;
9270
10226
  return `EncapsulationPrivateKey(${String(this._scheme)})`;
9271
10227
  }
9272
10228
  /**
@@ -9276,7 +10232,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
9276
10232
  * representation, providing a unique, content-addressable identifier.
9277
10233
  */
9278
10234
  reference() {
9279
- const digest = require_digest.Digest.fromImage(this.taggedCborData());
10235
+ const digest = Digest.fromImage(this.taggedCborData());
9280
10236
  return Reference.from(digest);
9281
10237
  }
9282
10238
  /**
@@ -9500,6 +10456,16 @@ var PrivateKeyBase = class PrivateKeyBase {
9500
10456
  return EncapsulationPrivateKey.fromX25519PrivateKey(this.x25519PrivateKey());
9501
10457
  }
9502
10458
  /**
10459
+ * Decapsulate a shared secret from a ciphertext.
10460
+ *
10461
+ * Implements the `Decrypter` interface so a `PrivateKeyBase` can be used
10462
+ * directly as a recipient key, mirroring Rust `impl Decrypter for
10463
+ * PrivateKeyBase`.
10464
+ */
10465
+ decapsulateSharedSecret(ciphertext) {
10466
+ return this.encapsulationPrivateKey().decapsulateSharedSecret(ciphertext);
10467
+ }
10468
+ /**
9503
10469
  * Derive a PrivateKeys container with Ed25519 signing and X25519 agreement keys.
9504
10470
  *
9505
10471
  * @returns PrivateKeys containing the derived signing and encapsulation keys
@@ -9661,7 +10627,7 @@ var PrivateKeyBase = class PrivateKeyBase {
9661
10627
  * Get string representation (truncated for security).
9662
10628
  */
9663
10629
  toString() {
9664
- return `PrivateKeyBase(${require_digest.bytesToHex(this._data).substring(0, 8)}...)`;
10630
+ return `PrivateKeyBase(${bytesToHex(this._data).substring(0, 8)}...)`;
9665
10631
  }
9666
10632
  /**
9667
10633
  * Returns the CBOR tags associated with PrivateKeyBase.
@@ -10003,7 +10969,7 @@ function createKeypairUsing(scheme, rng, comment = "") {
10003
10969
  }
10004
10970
  case "MLDSA44":
10005
10971
  case "MLDSA65":
10006
- case "MLDSA87": throw require_digest.CryptoError.general(`Deterministic keypair generation not supported for ${scheme}. Use createKeypair() instead.`);
10972
+ case "MLDSA87": throw CryptoError.general(`Deterministic keypair generation not supported for ${scheme}. Use createKeypair() instead.`);
10007
10973
  case "SshEd25519":
10008
10974
  case "SshDsa":
10009
10975
  case "SshEcdsaP256":
@@ -10065,7 +11031,7 @@ var Signature = class Signature {
10065
11031
  * @returns A new Schnorr signature
10066
11032
  */
10067
11033
  static schnorrFromData(data) {
10068
- if (data.length !== _bcts_crypto.SCHNORR_SIGNATURE_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.SCHNORR_SIGNATURE_SIZE, data.length);
11034
+ if (data.length !== _bcts_crypto.SCHNORR_SIGNATURE_SIZE) throw CryptoError.invalidSize(_bcts_crypto.SCHNORR_SIGNATURE_SIZE, data.length);
10069
11035
  return new Signature("Schnorr", data);
10070
11036
  }
10071
11037
  /**
@@ -10075,7 +11041,7 @@ var Signature = class Signature {
10075
11041
  * @returns A new Schnorr signature
10076
11042
  */
10077
11043
  static schnorrFromHex(hex) {
10078
- return Signature.schnorrFromData(require_digest.hexToBytes(hex));
11044
+ return Signature.schnorrFromData(hexToBytes(hex));
10079
11045
  }
10080
11046
  /**
10081
11047
  * Creates an ECDSA signature from a 64-byte array.
@@ -10084,7 +11050,7 @@ var Signature = class Signature {
10084
11050
  * @returns A new ECDSA signature
10085
11051
  */
10086
11052
  static ecdsaFromData(data) {
10087
- if (data.length !== _bcts_crypto.ECDSA_SIGNATURE_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ECDSA_SIGNATURE_SIZE, data.length);
11053
+ if (data.length !== _bcts_crypto.ECDSA_SIGNATURE_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ECDSA_SIGNATURE_SIZE, data.length);
10088
11054
  return new Signature("Ecdsa", data);
10089
11055
  }
10090
11056
  /**
@@ -10094,7 +11060,7 @@ var Signature = class Signature {
10094
11060
  * @returns A new ECDSA signature
10095
11061
  */
10096
11062
  static ecdsaFromHex(hex) {
10097
- return Signature.ecdsaFromData(require_digest.hexToBytes(hex));
11063
+ return Signature.ecdsaFromData(hexToBytes(hex));
10098
11064
  }
10099
11065
  /**
10100
11066
  * Creates an Ed25519 signature from a 64-byte array.
@@ -10103,7 +11069,7 @@ var Signature = class Signature {
10103
11069
  * @returns A new Ed25519 signature
10104
11070
  */
10105
11071
  static ed25519FromData(data) {
10106
- if (data.length !== _bcts_crypto.ED25519_SIGNATURE_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ED25519_SIGNATURE_SIZE, data.length);
11072
+ if (data.length !== _bcts_crypto.ED25519_SIGNATURE_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ED25519_SIGNATURE_SIZE, data.length);
10107
11073
  return new Signature("Ed25519", data);
10108
11074
  }
10109
11075
  /**
@@ -10113,7 +11079,7 @@ var Signature = class Signature {
10113
11079
  * @returns A new Ed25519 signature
10114
11080
  */
10115
11081
  static ed25519FromHex(hex) {
10116
- return Signature.ed25519FromData(require_digest.hexToBytes(hex));
11082
+ return Signature.ed25519FromData(hexToBytes(hex));
10117
11083
  }
10118
11084
  /**
10119
11085
  * Creates an Sr25519 signature from a 64-byte array.
@@ -10122,7 +11088,7 @@ var Signature = class Signature {
10122
11088
  * @returns A new Sr25519 signature
10123
11089
  */
10124
11090
  static sr25519FromData(data) {
10125
- if (data.length !== 64) throw require_digest.CryptoError.invalidSize(64, data.length);
11091
+ if (data.length !== 64) throw CryptoError.invalidSize(64, data.length);
10126
11092
  return new Signature("Sr25519", data);
10127
11093
  }
10128
11094
  /**
@@ -10132,7 +11098,7 @@ var Signature = class Signature {
10132
11098
  * @returns A new Sr25519 signature
10133
11099
  */
10134
11100
  static sr25519FromHex(hex) {
10135
- return Signature.sr25519FromData(require_digest.hexToBytes(hex));
11101
+ return Signature.sr25519FromData(hexToBytes(hex));
10136
11102
  }
10137
11103
  /**
10138
11104
  * Creates a Signature from an MLDSASignature.
@@ -10318,7 +11284,7 @@ var Signature = class Signature {
10318
11284
  * Get hex string representation of the signature data.
10319
11285
  */
10320
11286
  toHex() {
10321
- return require_digest.bytesToHex(this._data);
11287
+ return bytesToHex(this._data);
10322
11288
  }
10323
11289
  /**
10324
11290
  * Compare with another Signature.
@@ -10838,7 +11804,7 @@ var SigningPublicKey = class SigningPublicKey {
10838
11804
  * representation, providing a unique, content-addressable identifier.
10839
11805
  */
10840
11806
  reference() {
10841
- const digest = require_digest.Digest.fromImage(this.taggedCborData());
11807
+ const digest = Digest.fromImage(this.taggedCborData());
10842
11808
  return Reference.from(digest);
10843
11809
  }
10844
11810
  /**
@@ -11038,6 +12004,12 @@ var SigningPublicKey = class SigningPublicKey {
11038
12004
  */
11039
12005
  static fromUntaggedCborData(data) {
11040
12006
  const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
12007
+ return SigningPublicKey.fromUntaggedCbor(cborValue);
12008
+ }
12009
+ /**
12010
+ * Static method to decode from untagged CBOR.
12011
+ */
12012
+ static fromUntaggedCbor(cborValue) {
11041
12013
  return new SigningPublicKey("Ed25519", void 0, void 0, Ed25519PublicKey.from(new Uint8Array(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE))).fromUntaggedCbor(cborValue);
11042
12014
  }
11043
12015
  /**
@@ -11048,7 +12020,7 @@ var SigningPublicKey = class SigningPublicKey {
11048
12020
  * Returns the UR representation of the signing public key.
11049
12021
  */
11050
12022
  ur() {
11051
- return _bcts_uniform_resources.UR.new(SigningPublicKey.UR_TYPE, this.taggedCbor());
12023
+ return _bcts_uniform_resources.UR.new(SigningPublicKey.UR_TYPE, this.untaggedCbor());
11052
12024
  }
11053
12025
  /**
11054
12026
  * Returns the UR string representation of the signing public key.
@@ -11061,7 +12033,7 @@ var SigningPublicKey = class SigningPublicKey {
11061
12033
  */
11062
12034
  static fromUR(ur) {
11063
12035
  ur.checkType(SigningPublicKey.UR_TYPE);
11064
- return SigningPublicKey.fromTaggedCbor(ur.cbor());
12036
+ return SigningPublicKey.fromUntaggedCbor(ur.cbor());
11065
12037
  }
11066
12038
  /**
11067
12039
  * Creates a SigningPublicKey from a UR string.
@@ -11499,7 +12471,7 @@ var SigningPrivateKey = class SigningPrivateKey {
11499
12471
  * representation, providing a unique, content-addressable identifier.
11500
12472
  */
11501
12473
  reference() {
11502
- const digest = require_digest.Digest.fromImage(this.taggedCborData());
12474
+ const digest = Digest.fromImage(this.taggedCborData());
11503
12475
  return Reference.from(digest);
11504
12476
  }
11505
12477
  /**
@@ -11785,6 +12757,12 @@ var SigningPrivateKey = class SigningPrivateKey {
11785
12757
  */
11786
12758
  static fromUntaggedCborData(data) {
11787
12759
  const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
12760
+ return SigningPrivateKey.fromUntaggedCbor(cborValue);
12761
+ }
12762
+ /**
12763
+ * Static method to decode from untagged CBOR.
12764
+ */
12765
+ static fromUntaggedCbor(cborValue) {
11788
12766
  return new SigningPrivateKey("Ed25519", void 0, Ed25519PrivateKey.from(new Uint8Array(_bcts_crypto.ED25519_PRIVATE_KEY_SIZE))).fromUntaggedCbor(cborValue);
11789
12767
  }
11790
12768
  /**
@@ -11795,7 +12773,7 @@ var SigningPrivateKey = class SigningPrivateKey {
11795
12773
  * Returns the UR representation of the signing private key.
11796
12774
  */
11797
12775
  ur() {
11798
- return _bcts_uniform_resources.UR.new(SigningPrivateKey.UR_TYPE, this.taggedCbor());
12776
+ return _bcts_uniform_resources.UR.new(SigningPrivateKey.UR_TYPE, this.untaggedCbor());
11799
12777
  }
11800
12778
  /**
11801
12779
  * Returns the UR string representation of the signing private key.
@@ -11808,7 +12786,7 @@ var SigningPrivateKey = class SigningPrivateKey {
11808
12786
  */
11809
12787
  static fromUR(ur) {
11810
12788
  ur.checkType(SigningPrivateKey.UR_TYPE);
11811
- return SigningPrivateKey.fromTaggedCbor(ur.cbor());
12789
+ return SigningPrivateKey.fromUntaggedCbor(ur.cbor());
11812
12790
  }
11813
12791
  /**
11814
12792
  * Creates a SigningPrivateKey from a UR string.
@@ -11920,7 +12898,7 @@ var PublicKeys = class PublicKeys {
11920
12898
  * representation, providing a unique, content-addressable identifier.
11921
12899
  */
11922
12900
  reference() {
11923
- const digest = require_digest.Digest.fromImage(this.taggedCborData());
12901
+ const digest = Digest.fromImage(this.taggedCborData());
11924
12902
  return Reference.from(digest);
11925
12903
  }
11926
12904
  /**
@@ -12178,7 +13156,7 @@ var PrivateKeys = class PrivateKeys {
12178
13156
  * representation, providing a unique, content-addressable identifier.
12179
13157
  */
12180
13158
  reference() {
12181
- const digest = require_digest.Digest.fromImage(this.taggedCborData());
13159
+ const digest = Digest.fromImage(this.taggedCborData());
12182
13160
  return Reference.from(digest);
12183
13161
  }
12184
13162
  /**
@@ -12493,7 +13471,7 @@ var SealedMessage = class SealedMessage {
12493
13471
  * Get string representation.
12494
13472
  */
12495
13473
  toString() {
12496
- return `SealedMessage(${this._encapsulatedKey.encapsulationScheme()}, ciphertext: ${require_digest.bytesToHex(this._message.ciphertext()).substring(0, 16)}...)`;
13474
+ return `SealedMessage(${this._encapsulatedKey.encapsulationScheme()}, ciphertext: ${bytesToHex(this._message.ciphertext()).substring(0, 16)}...)`;
12497
13475
  }
12498
13476
  /**
12499
13477
  * Returns the CBOR tags associated with SealedMessage.
@@ -13305,7 +14283,7 @@ var SSHAgentParams = class SSHAgentParams {
13305
14283
  * @throws CryptoError - SSH agent support is not available
13306
14284
  */
13307
14285
  lock(_contentKey, _secret) {
13308
- throw require_digest.CryptoError.sshAgent("SSH agent key derivation is not yet implemented in this TypeScript port. Use HKDF, PBKDF2, Scrypt, or Argon2id instead.");
14286
+ throw CryptoError.sshAgent("SSH agent key derivation is not yet implemented in this TypeScript port. Use HKDF, PBKDF2, Scrypt, or Argon2id instead.");
13309
14287
  }
13310
14288
  /**
13311
14289
  * Derive a key using SSH agent and decrypt the content key.
@@ -13317,7 +14295,7 @@ var SSHAgentParams = class SSHAgentParams {
13317
14295
  * @throws CryptoError - SSH agent support is not available
13318
14296
  */
13319
14297
  unlock(_encryptedMessage, _secret) {
13320
- throw require_digest.CryptoError.sshAgent("SSH agent key derivation is not yet implemented in this TypeScript port. Use HKDF, PBKDF2, Scrypt, or Argon2id instead.");
14298
+ throw CryptoError.sshAgent("SSH agent key derivation is not yet implemented in this TypeScript port. Use HKDF, PBKDF2, Scrypt, or Argon2id instead.");
13321
14299
  }
13322
14300
  /**
13323
14301
  * Get string representation.
@@ -13657,7 +14635,7 @@ var EncryptedKey = class EncryptedKey {
13657
14635
  */
13658
14636
  unlock(secret) {
13659
14637
  const aad = this._encryptedMessage.aad();
13660
- if (aad.length === 0) throw require_digest.CryptoError.invalidData("Missing AAD in EncryptedKey");
14638
+ if (aad.length === 0) throw CryptoError.invalidData("Missing AAD in EncryptedKey");
13661
14639
  const params = keyDerivationParamsFromCbor((0, _bcts_dcbor.decodeCbor)(aad));
13662
14640
  switch (params.type) {
13663
14641
  case "hkdf": return params.params.unlock(this._encryptedMessage, secret);
@@ -13710,7 +14688,7 @@ var EncryptedKey = class EncryptedKey {
13710
14688
  fromUntaggedCbor(cborValue) {
13711
14689
  const encryptedMessage = EncryptedMessage.fromTaggedCbor(cborValue);
13712
14690
  const aad = encryptedMessage.aad();
13713
- if (aad.length === 0) throw require_digest.CryptoError.invalidData("Missing AAD in EncryptedKey");
14691
+ if (aad.length === 0) throw CryptoError.invalidData("Missing AAD in EncryptedKey");
13714
14692
  return new EncryptedKey(keyDerivationParamsFromCbor((0, _bcts_dcbor.decodeCbor)(aad)), encryptedMessage);
13715
14693
  }
13716
14694
  /**
@@ -13828,7 +14806,7 @@ var SSKRShareCbor = class SSKRShareCbor {
13828
14806
  * @param hex - The share as a hex string
13829
14807
  */
13830
14808
  static fromHex(hex) {
13831
- return new SSKRShareCbor(require_digest.hexToBytes(hex));
14809
+ return new SSKRShareCbor(hexToBytes(hex));
13832
14810
  }
13833
14811
  /**
13834
14812
  * Returns the raw share bytes.
@@ -13846,7 +14824,7 @@ var SSKRShareCbor = class SSKRShareCbor {
13846
14824
  * Returns the share as a hex string.
13847
14825
  */
13848
14826
  hex() {
13849
- return require_digest.bytesToHex(this._data);
14827
+ return bytesToHex(this._data);
13850
14828
  }
13851
14829
  /**
13852
14830
  * Returns the identifier (2 bytes) as a number.
@@ -13858,7 +14836,7 @@ var SSKRShareCbor = class SSKRShareCbor {
13858
14836
  * Returns the identifier as a hex string.
13859
14837
  */
13860
14838
  identifierHex() {
13861
- return require_digest.bytesToHex(this._data.subarray(0, 2));
14839
+ return bytesToHex(this._data.subarray(0, 2));
13862
14840
  }
13863
14841
  /**
13864
14842
  * Returns the group threshold (minimum number of groups needed).
@@ -13956,7 +14934,7 @@ var SSKRShareCbor = class SSKRShareCbor {
13956
14934
  * Static method to decode from tagged CBOR.
13957
14935
  */
13958
14936
  static fromTaggedCbor(cborValue) {
13959
- return new SSKRShareCbor(new Uint8Array(METADATA_SIZE_BYTES + 16)).fromTaggedCbor(cborValue);
14937
+ return new SSKRShareCbor(new Uint8Array(21)).fromTaggedCbor(cborValue);
13960
14938
  }
13961
14939
  /**
13962
14940
  * Static method to decode from tagged CBOR binary data.
@@ -13970,7 +14948,7 @@ var SSKRShareCbor = class SSKRShareCbor {
13970
14948
  */
13971
14949
  static fromUntaggedCborData(data) {
13972
14950
  const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
13973
- return new SSKRShareCbor(new Uint8Array(METADATA_SIZE_BYTES + 16)).fromUntaggedCbor(cborValue);
14951
+ return new SSKRShareCbor(new Uint8Array(21)).fromUntaggedCbor(cborValue);
13974
14952
  }
13975
14953
  };
13976
14954
  /**
@@ -14100,12 +15078,12 @@ Object.defineProperty(exports, "COMPRESSED", {
14100
15078
  }
14101
15079
  });
14102
15080
  exports.Compressed = Compressed;
14103
- exports.CryptoError = require_digest.CryptoError;
15081
+ exports.CryptoError = CryptoError;
14104
15082
  exports.DEFAULT_PBKDF2_ITERATIONS = DEFAULT_PBKDF2_ITERATIONS;
14105
15083
  exports.DEFAULT_SCRYPT_LOG_N = DEFAULT_SCRYPT_LOG_N;
14106
15084
  exports.DEFAULT_SCRYPT_P = DEFAULT_SCRYPT_P;
14107
15085
  exports.DEFAULT_SCRYPT_R = DEFAULT_SCRYPT_R;
14108
- exports.Digest = require_digest.Digest;
15086
+ exports.Digest = Digest;
14109
15087
  exports.ECPrivateKey = ECPrivateKey;
14110
15088
  exports.ECPublicKey = ECPublicKey;
14111
15089
  exports.ECUncompressedPublicKey = ECUncompressedPublicKey;
@@ -14129,7 +15107,7 @@ exports.EncapsulationPublicKey = EncapsulationPublicKey;
14129
15107
  exports.EncapsulationScheme = EncapsulationScheme;
14130
15108
  exports.EncryptedKey = EncryptedKey;
14131
15109
  exports.EncryptedMessage = EncryptedMessage;
14132
- exports.ErrorKind = require_digest.ErrorKind;
15110
+ exports.ErrorKind = ErrorKind;
14133
15111
  exports.HKDFParams = HKDFParams;
14134
15112
  exports.HKDFRng = HKDFRng;
14135
15113
  exports.HashType = HashType;
@@ -14199,10 +15177,9 @@ exports.X25519PrivateKey = X25519PrivateKey;
14199
15177
  exports.X25519PublicKey = X25519PublicKey;
14200
15178
  exports.XID = XID;
14201
15179
  exports.XID_PREFIX = XID_PREFIX;
14202
- exports.__toESM = __toESM;
14203
15180
  exports.argon2idParams = argon2idParams;
14204
- exports.bytesEqual = require_digest.bytesEqual;
14205
- exports.bytesToHex = require_digest.bytesToHex;
15181
+ exports.bytesEqual = bytesEqual;
15182
+ exports.bytesToHex = bytesToHex;
14206
15183
  exports.createEncapsulationKeypair = createEncapsulationKeypair;
14207
15184
  exports.createEncapsulationKeypairUsing = createEncapsulationKeypairUsing;
14208
15185
  exports.createKeypair = createKeypair;
@@ -14212,20 +15189,20 @@ exports.defaultKeyDerivationMethod = defaultKeyDerivationMethod;
14212
15189
  exports.defaultKeyDerivationParams = defaultKeyDerivationParams;
14213
15190
  exports.defaultSignatureScheme = defaultSignatureScheme;
14214
15191
  exports.digestFromBytes = digestFromBytes;
14215
- exports.fromBase64 = require_digest.fromBase64;
15192
+ exports.fromBase64 = fromBase64;
14216
15193
  exports.hashTypeFromCbor = hashTypeFromCbor;
14217
15194
  exports.hashTypeToCbor = hashTypeToCbor;
14218
15195
  exports.hashTypeToString = hashTypeToString;
14219
- exports.hexToBytes = require_digest.hexToBytes;
15196
+ exports.hexToBytes = hexToBytes;
14220
15197
  exports.hkdfParams = hkdfParams;
14221
- exports.isCryptoError = require_digest.isCryptoError;
14222
- exports.isCryptoErrorKind = require_digest.isCryptoErrorKind;
15198
+ exports.isCryptoError = isCryptoError;
15199
+ exports.isCryptoErrorKind = isCryptoErrorKind;
14223
15200
  exports.isDecrypter = isDecrypter;
14224
15201
  exports.isECKey = isECKey;
14225
15202
  exports.isECKeyBase = isECKeyBase;
14226
15203
  exports.isECPublicKeyBase = isECPublicKeyBase;
14227
15204
  exports.isEncrypter = isEncrypter;
14228
- exports.isError = require_digest.isError;
15205
+ exports.isError = isError;
14229
15206
  exports.isMldsaScheme = isMldsaScheme;
14230
15207
  exports.isPasswordBased = isPasswordBased;
14231
15208
  exports.isPrivateKeyDataProvider = isPrivateKeyDataProvider;
@@ -14277,6 +15254,6 @@ exports.sskrGenerate = _bcts_sskr.sskrGenerate;
14277
15254
  exports.sskrGenerateShares = sskrGenerateShares;
14278
15255
  exports.sskrGenerateSharesUsing = sskrGenerateSharesUsing;
14279
15256
  exports.sskrGenerateUsing = _bcts_sskr.sskrGenerateUsing;
14280
- exports.toBase64 = require_digest.toBase64;
15257
+ exports.toBase64 = toBase64;
14281
15258
 
14282
15259
  //# sourceMappingURL=index.cjs.map