@bcts/components 1.0.0-alpha.21 → 1.0.0-alpha.23
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/{digest-DFW8lGqJ.mjs → digest-B1bpgcdz.mjs} +78 -68
- package/dist/digest-B1bpgcdz.mjs.map +1 -0
- package/dist/{digest-DWA5qjpo.cjs → digest-DL5sTq8T.cjs} +111 -114
- package/dist/{digest-DWA5qjpo.cjs.map → digest-DL5sTq8T.cjs.map} +1 -1
- package/dist/digest-DRakTOWS.cjs +2 -0
- package/dist/index.cjs +547 -648
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -14
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -14
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +947 -1038
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +513 -610
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/digest-BJkzk4LG.mjs +0 -3
- package/dist/digest-BzlBpAL2.cjs +0 -3
- package/dist/digest-DFW8lGqJ.mjs.map +0 -1
package/dist/index.iife.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_crypto, _bcts_uniform_resources, _bcts_rand, _scure_sr25519, _noble_hashes_blake2_js, _noble_post_quantum_ml_dsa_js, _noble_post_quantum_ml_kem_js, _bcts_sskr) {
|
|
2
|
-
|
|
3
|
-
//#region
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -8,30 +8,22 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
10
|
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
11
|
-
var __exportAll = (all,
|
|
11
|
+
var __exportAll = (all, no_symbols) => {
|
|
12
12
|
let target = {};
|
|
13
|
-
for (var name in all) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
if (symbols) {
|
|
20
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
21
|
-
}
|
|
13
|
+
for (var name in all) __defProp(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
22
18
|
return target;
|
|
23
19
|
};
|
|
24
20
|
var __copyProps = (to, from, except, desc) => {
|
|
25
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
+
key = keys[i];
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
24
|
+
get: ((k) => from[k]).bind(null, key),
|
|
25
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
26
|
+
});
|
|
35
27
|
}
|
|
36
28
|
return to;
|
|
37
29
|
};
|
|
@@ -39,12 +31,10 @@ var bctsComponents = (function(exports, _bcts_dcbor, _bcts_tags, pako, _bcts_cry
|
|
|
39
31
|
value: mod,
|
|
40
32
|
enumerable: true
|
|
41
33
|
}) : target, mod));
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
//#region src/error.ts
|
|
47
|
-
/**
|
|
34
|
+
//#endregion
|
|
35
|
+
_scure_sr25519 = __toESM(_scure_sr25519, 1);
|
|
36
|
+
//#region src/error.ts
|
|
37
|
+
/**
|
|
48
38
|
* Type guard to check if a result is an Error.
|
|
49
39
|
*/
|
|
50
40
|
function isError(result) {
|
|
@@ -64,42 +54,42 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
64
54
|
}
|
|
65
55
|
var ErrorKind, CryptoError;
|
|
66
56
|
var init_error = __esmMin((() => {
|
|
67
|
-
ErrorKind = /* @__PURE__ */ function(ErrorKind
|
|
57
|
+
ErrorKind = /* @__PURE__ */ function(ErrorKind) {
|
|
68
58
|
/** Invalid data size for the specified type */
|
|
69
|
-
ErrorKind
|
|
59
|
+
ErrorKind["InvalidSize"] = "InvalidSize";
|
|
70
60
|
/** Invalid data format or content */
|
|
71
|
-
ErrorKind
|
|
61
|
+
ErrorKind["InvalidData"] = "InvalidData";
|
|
72
62
|
/** Data too short for the expected type */
|
|
73
|
-
ErrorKind
|
|
63
|
+
ErrorKind["DataTooShort"] = "DataTooShort";
|
|
74
64
|
/** Cryptographic operation failed */
|
|
75
|
-
ErrorKind
|
|
65
|
+
ErrorKind["Crypto"] = "Crypto";
|
|
76
66
|
/** CBOR encoding or decoding error */
|
|
77
|
-
ErrorKind
|
|
67
|
+
ErrorKind["Cbor"] = "Cbor";
|
|
78
68
|
/** SSKR error */
|
|
79
|
-
ErrorKind
|
|
69
|
+
ErrorKind["Sskr"] = "Sskr";
|
|
80
70
|
/** SSH key operation failed */
|
|
81
|
-
ErrorKind
|
|
71
|
+
ErrorKind["Ssh"] = "Ssh";
|
|
82
72
|
/** URI parsing failed */
|
|
83
|
-
ErrorKind
|
|
73
|
+
ErrorKind["Uri"] = "Uri";
|
|
84
74
|
/** Data compression/decompression failed */
|
|
85
|
-
ErrorKind
|
|
75
|
+
ErrorKind["Compression"] = "Compression";
|
|
86
76
|
/** Post-quantum cryptography library error */
|
|
87
|
-
ErrorKind
|
|
77
|
+
ErrorKind["PostQuantum"] = "PostQuantum";
|
|
88
78
|
/** Signature level mismatch */
|
|
89
|
-
ErrorKind
|
|
79
|
+
ErrorKind["LevelMismatch"] = "LevelMismatch";
|
|
90
80
|
/** SSH agent operation failed */
|
|
91
|
-
ErrorKind
|
|
81
|
+
ErrorKind["SshAgent"] = "SshAgent";
|
|
92
82
|
/** Hex decoding error */
|
|
93
|
-
ErrorKind
|
|
83
|
+
ErrorKind["Hex"] = "Hex";
|
|
94
84
|
/** UTF-8 conversion error */
|
|
95
|
-
ErrorKind
|
|
85
|
+
ErrorKind["Utf8"] = "Utf8";
|
|
96
86
|
/** Environment variable error */
|
|
97
|
-
ErrorKind
|
|
87
|
+
ErrorKind["Env"] = "Env";
|
|
98
88
|
/** SSH agent client error */
|
|
99
|
-
ErrorKind
|
|
89
|
+
ErrorKind["SshAgentClient"] = "SshAgentClient";
|
|
100
90
|
/** General error with custom message */
|
|
101
|
-
ErrorKind
|
|
102
|
-
return ErrorKind
|
|
91
|
+
ErrorKind["General"] = "General";
|
|
92
|
+
return ErrorKind;
|
|
103
93
|
}({});
|
|
104
94
|
CryptoError = class CryptoError extends Error {
|
|
105
95
|
/** The error kind for programmatic type checking */
|
|
@@ -136,7 +126,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
136
126
|
*/
|
|
137
127
|
static invalidSizeForType(dataType, expected, actual) {
|
|
138
128
|
return new CryptoError(`invalid ${dataType} size: expected ${expected}, got ${actual}`, {
|
|
139
|
-
kind:
|
|
129
|
+
kind: "InvalidSize",
|
|
140
130
|
dataType,
|
|
141
131
|
expected,
|
|
142
132
|
actual
|
|
@@ -160,7 +150,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
160
150
|
*/
|
|
161
151
|
static invalidDataForType(dataType, reason) {
|
|
162
152
|
return new CryptoError(`invalid ${dataType}: ${reason}`, {
|
|
163
|
-
kind:
|
|
153
|
+
kind: "InvalidData",
|
|
164
154
|
dataType,
|
|
165
155
|
reason
|
|
166
156
|
});
|
|
@@ -176,7 +166,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
176
166
|
*/
|
|
177
167
|
static dataTooShort(dataType, minimum, actual) {
|
|
178
168
|
return new CryptoError(`data too short: ${dataType} expected at least ${minimum}, got ${actual}`, {
|
|
179
|
-
kind:
|
|
169
|
+
kind: "DataTooShort",
|
|
180
170
|
dataType,
|
|
181
171
|
minimum,
|
|
182
172
|
actual
|
|
@@ -217,7 +207,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
217
207
|
*/
|
|
218
208
|
static crypto(message) {
|
|
219
209
|
return new CryptoError(`cryptographic operation failed: ${message}`, {
|
|
220
|
-
kind:
|
|
210
|
+
kind: "Crypto",
|
|
221
211
|
message
|
|
222
212
|
});
|
|
223
213
|
}
|
|
@@ -230,7 +220,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
230
220
|
*/
|
|
231
221
|
static postQuantum(message) {
|
|
232
222
|
return new CryptoError(`post-quantum cryptography error: ${message}`, {
|
|
233
|
-
kind:
|
|
223
|
+
kind: "PostQuantum",
|
|
234
224
|
message
|
|
235
225
|
});
|
|
236
226
|
}
|
|
@@ -240,7 +230,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
240
230
|
* Rust equivalent: `Error::LevelMismatch`
|
|
241
231
|
*/
|
|
242
232
|
static levelMismatch() {
|
|
243
|
-
return new CryptoError("signature level does not match key level", { kind:
|
|
233
|
+
return new CryptoError("signature level does not match key level", { kind: "LevelMismatch" });
|
|
244
234
|
}
|
|
245
235
|
/**
|
|
246
236
|
* Create a CBOR error.
|
|
@@ -251,7 +241,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
251
241
|
*/
|
|
252
242
|
static cbor(message) {
|
|
253
243
|
return new CryptoError(`CBOR error: ${message}`, {
|
|
254
|
-
kind:
|
|
244
|
+
kind: "Cbor",
|
|
255
245
|
message
|
|
256
246
|
});
|
|
257
247
|
}
|
|
@@ -264,7 +254,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
264
254
|
*/
|
|
265
255
|
static hex(message) {
|
|
266
256
|
return new CryptoError(`hex decoding error: ${message}`, {
|
|
267
|
-
kind:
|
|
257
|
+
kind: "Hex",
|
|
268
258
|
message
|
|
269
259
|
});
|
|
270
260
|
}
|
|
@@ -277,7 +267,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
277
267
|
*/
|
|
278
268
|
static utf8(message) {
|
|
279
269
|
return new CryptoError(`UTF-8 conversion error: ${message}`, {
|
|
280
|
-
kind:
|
|
270
|
+
kind: "Utf8",
|
|
281
271
|
message
|
|
282
272
|
});
|
|
283
273
|
}
|
|
@@ -290,7 +280,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
290
280
|
*/
|
|
291
281
|
static compression(message) {
|
|
292
282
|
return new CryptoError(`compression error: ${message}`, {
|
|
293
|
-
kind:
|
|
283
|
+
kind: "Compression",
|
|
294
284
|
message
|
|
295
285
|
});
|
|
296
286
|
}
|
|
@@ -303,7 +293,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
303
293
|
*/
|
|
304
294
|
static uri(message) {
|
|
305
295
|
return new CryptoError(`invalid URI: ${message}`, {
|
|
306
|
-
kind:
|
|
296
|
+
kind: "Uri",
|
|
307
297
|
message
|
|
308
298
|
});
|
|
309
299
|
}
|
|
@@ -316,7 +306,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
316
306
|
*/
|
|
317
307
|
static sskr(message) {
|
|
318
308
|
return new CryptoError(`SSKR error: ${message}`, {
|
|
319
|
-
kind:
|
|
309
|
+
kind: "Sskr",
|
|
320
310
|
message
|
|
321
311
|
});
|
|
322
312
|
}
|
|
@@ -329,7 +319,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
329
319
|
*/
|
|
330
320
|
static ssh(message) {
|
|
331
321
|
return new CryptoError(`SSH operation failed: ${message}`, {
|
|
332
|
-
kind:
|
|
322
|
+
kind: "Ssh",
|
|
333
323
|
message
|
|
334
324
|
});
|
|
335
325
|
}
|
|
@@ -342,7 +332,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
342
332
|
*/
|
|
343
333
|
static sshAgent(message) {
|
|
344
334
|
return new CryptoError(`SSH agent error: ${message}`, {
|
|
345
|
-
kind:
|
|
335
|
+
kind: "SshAgent",
|
|
346
336
|
message
|
|
347
337
|
});
|
|
348
338
|
}
|
|
@@ -355,7 +345,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
355
345
|
*/
|
|
356
346
|
static sshAgentClient(message) {
|
|
357
347
|
return new CryptoError(`SSH agent client error: ${message}`, {
|
|
358
|
-
kind:
|
|
348
|
+
kind: "SshAgentClient",
|
|
359
349
|
message
|
|
360
350
|
});
|
|
361
351
|
}
|
|
@@ -368,7 +358,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
368
358
|
*/
|
|
369
359
|
static env(message) {
|
|
370
360
|
return new CryptoError(`environment variable error: ${message}`, {
|
|
371
|
-
kind:
|
|
361
|
+
kind: "Env",
|
|
372
362
|
message
|
|
373
363
|
});
|
|
374
364
|
}
|
|
@@ -381,7 +371,7 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
381
371
|
*/
|
|
382
372
|
static general(message) {
|
|
383
373
|
return new CryptoError(message, {
|
|
384
|
-
kind:
|
|
374
|
+
kind: "General",
|
|
385
375
|
message
|
|
386
376
|
});
|
|
387
377
|
}
|
|
@@ -397,120 +387,118 @@ _scure_sr25519 = __toESM(_scure_sr25519);
|
|
|
397
387
|
* Check if this is an InvalidSize error.
|
|
398
388
|
*/
|
|
399
389
|
isInvalidSize() {
|
|
400
|
-
return this.errorKind ===
|
|
390
|
+
return this.errorKind === "InvalidSize";
|
|
401
391
|
}
|
|
402
392
|
/**
|
|
403
393
|
* Check if this is an InvalidData error.
|
|
404
394
|
*/
|
|
405
395
|
isInvalidData() {
|
|
406
|
-
return this.errorKind ===
|
|
396
|
+
return this.errorKind === "InvalidData";
|
|
407
397
|
}
|
|
408
398
|
/**
|
|
409
399
|
* Check if this is a DataTooShort error.
|
|
410
400
|
*/
|
|
411
401
|
isDataTooShort() {
|
|
412
|
-
return this.errorKind ===
|
|
402
|
+
return this.errorKind === "DataTooShort";
|
|
413
403
|
}
|
|
414
404
|
/**
|
|
415
405
|
* Check if this is a Crypto error.
|
|
416
406
|
*/
|
|
417
407
|
isCrypto() {
|
|
418
|
-
return this.errorKind ===
|
|
408
|
+
return this.errorKind === "Crypto";
|
|
419
409
|
}
|
|
420
410
|
/**
|
|
421
411
|
* Check if this is a Cbor error.
|
|
422
412
|
*/
|
|
423
413
|
isCbor() {
|
|
424
|
-
return this.errorKind ===
|
|
414
|
+
return this.errorKind === "Cbor";
|
|
425
415
|
}
|
|
426
416
|
/**
|
|
427
417
|
* Check if this is an Sskr error.
|
|
428
418
|
*/
|
|
429
419
|
isSskr() {
|
|
430
|
-
return this.errorKind ===
|
|
420
|
+
return this.errorKind === "Sskr";
|
|
431
421
|
}
|
|
432
422
|
/**
|
|
433
423
|
* Check if this is an Ssh error.
|
|
434
424
|
*/
|
|
435
425
|
isSsh() {
|
|
436
|
-
return this.errorKind ===
|
|
426
|
+
return this.errorKind === "Ssh";
|
|
437
427
|
}
|
|
438
428
|
/**
|
|
439
429
|
* Check if this is a Uri error.
|
|
440
430
|
*/
|
|
441
431
|
isUri() {
|
|
442
|
-
return this.errorKind ===
|
|
432
|
+
return this.errorKind === "Uri";
|
|
443
433
|
}
|
|
444
434
|
/**
|
|
445
435
|
* Check if this is a Compression error.
|
|
446
436
|
*/
|
|
447
437
|
isCompression() {
|
|
448
|
-
return this.errorKind ===
|
|
438
|
+
return this.errorKind === "Compression";
|
|
449
439
|
}
|
|
450
440
|
/**
|
|
451
441
|
* Check if this is a PostQuantum error.
|
|
452
442
|
*/
|
|
453
443
|
isPostQuantum() {
|
|
454
|
-
return this.errorKind ===
|
|
444
|
+
return this.errorKind === "PostQuantum";
|
|
455
445
|
}
|
|
456
446
|
/**
|
|
457
447
|
* Check if this is a LevelMismatch error.
|
|
458
448
|
*/
|
|
459
449
|
isLevelMismatch() {
|
|
460
|
-
return this.errorKind ===
|
|
450
|
+
return this.errorKind === "LevelMismatch";
|
|
461
451
|
}
|
|
462
452
|
/**
|
|
463
453
|
* Check if this is an SshAgent error.
|
|
464
454
|
*/
|
|
465
455
|
isSshAgent() {
|
|
466
|
-
return this.errorKind ===
|
|
456
|
+
return this.errorKind === "SshAgent";
|
|
467
457
|
}
|
|
468
458
|
/**
|
|
469
459
|
* Check if this is a Hex error.
|
|
470
460
|
*/
|
|
471
461
|
isHex() {
|
|
472
|
-
return this.errorKind ===
|
|
462
|
+
return this.errorKind === "Hex";
|
|
473
463
|
}
|
|
474
464
|
/**
|
|
475
465
|
* Check if this is a Utf8 error.
|
|
476
466
|
*/
|
|
477
467
|
isUtf8() {
|
|
478
|
-
return this.errorKind ===
|
|
468
|
+
return this.errorKind === "Utf8";
|
|
479
469
|
}
|
|
480
470
|
/**
|
|
481
471
|
* Check if this is an Env error.
|
|
482
472
|
*/
|
|
483
473
|
isEnv() {
|
|
484
|
-
return this.errorKind ===
|
|
474
|
+
return this.errorKind === "Env";
|
|
485
475
|
}
|
|
486
476
|
/**
|
|
487
477
|
* Check if this is an SshAgentClient error.
|
|
488
478
|
*/
|
|
489
479
|
isSshAgentClient() {
|
|
490
|
-
return this.errorKind ===
|
|
480
|
+
return this.errorKind === "SshAgentClient";
|
|
491
481
|
}
|
|
492
482
|
/**
|
|
493
483
|
* Check if this is a General error.
|
|
494
484
|
*/
|
|
495
485
|
isGeneral() {
|
|
496
|
-
return this.errorKind ===
|
|
486
|
+
return this.errorKind === "General";
|
|
497
487
|
}
|
|
498
488
|
};
|
|
499
489
|
}));
|
|
500
|
-
|
|
501
|
-
//#
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
/**
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/private-key-data-provider.ts
|
|
492
|
+
init_error();
|
|
493
|
+
/**
|
|
505
494
|
* Type guard to check if an object implements PrivateKeyDataProvider
|
|
506
495
|
*/
|
|
507
496
|
function isPrivateKeyDataProvider(obj) {
|
|
508
497
|
return typeof obj === "object" && obj !== null && "privateKeyData" in obj && typeof obj.privateKeyData === "function";
|
|
509
498
|
}
|
|
510
|
-
|
|
511
|
-
//#
|
|
512
|
-
|
|
513
|
-
/**
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/encrypter.ts
|
|
501
|
+
/**
|
|
514
502
|
* Type guard to check if an object implements the Encrypter interface.
|
|
515
503
|
*/
|
|
516
504
|
function isEncrypter(obj) {
|
|
@@ -522,10 +510,9 @@ init_error();
|
|
|
522
510
|
function isDecrypter(obj) {
|
|
523
511
|
return typeof obj === "object" && obj !== null && "encapsulationPrivateKey" in obj && typeof obj.encapsulationPrivateKey === "function" && "decapsulateSharedSecret" in obj && typeof obj.decapsulateSharedSecret === "function";
|
|
524
512
|
}
|
|
525
|
-
|
|
526
|
-
//#
|
|
527
|
-
|
|
528
|
-
/**
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region src/utils.ts
|
|
515
|
+
/**
|
|
529
516
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
530
517
|
* Copyright © 2025-2026 Parity Technologies
|
|
531
518
|
*
|
|
@@ -647,10 +634,9 @@ init_error();
|
|
|
647
634
|
return result === 0;
|
|
648
635
|
}
|
|
649
636
|
var init_utils = __esmMin((() => {}));
|
|
650
|
-
|
|
651
|
-
//#
|
|
652
|
-
|
|
653
|
-
/**
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region src/json.ts
|
|
639
|
+
/**
|
|
654
640
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
655
641
|
* Copyright © 2025-2026 Parity Technologies
|
|
656
642
|
*
|
|
@@ -828,10 +814,9 @@ init_error();
|
|
|
828
814
|
return JSON.fromString("").fromUntaggedCbor(cborValue);
|
|
829
815
|
}
|
|
830
816
|
};
|
|
831
|
-
|
|
832
|
-
//#
|
|
833
|
-
|
|
834
|
-
/**
|
|
817
|
+
//#endregion
|
|
818
|
+
//#region src/digest.ts
|
|
819
|
+
/**
|
|
835
820
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
836
821
|
* Copyright © 2025-2026 Parity Technologies
|
|
837
822
|
*
|
|
@@ -1066,30 +1051,30 @@ init_error();
|
|
|
1066
1051
|
/**
|
|
1067
1052
|
* Creates a Digest by decoding it from untagged CBOR.
|
|
1068
1053
|
*/
|
|
1069
|
-
fromUntaggedCbor(cbor
|
|
1070
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
1054
|
+
fromUntaggedCbor(cbor) {
|
|
1055
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
1071
1056
|
return Digest.fromData(data);
|
|
1072
1057
|
}
|
|
1073
1058
|
/**
|
|
1074
1059
|
* Creates a Digest by decoding it from tagged CBOR.
|
|
1075
1060
|
*/
|
|
1076
|
-
fromTaggedCbor(cbor
|
|
1077
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
1078
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
1061
|
+
fromTaggedCbor(cbor) {
|
|
1062
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
1063
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
1079
1064
|
return this.fromUntaggedCbor(content);
|
|
1080
1065
|
}
|
|
1081
1066
|
/**
|
|
1082
1067
|
* Static method to decode from tagged CBOR.
|
|
1083
1068
|
*/
|
|
1084
|
-
static fromTaggedCbor(cbor
|
|
1085
|
-
return new Digest(new Uint8Array(Digest.DIGEST_SIZE)).fromTaggedCbor(cbor
|
|
1069
|
+
static fromTaggedCbor(cbor) {
|
|
1070
|
+
return new Digest(new Uint8Array(Digest.DIGEST_SIZE)).fromTaggedCbor(cbor);
|
|
1086
1071
|
}
|
|
1087
1072
|
/**
|
|
1088
1073
|
* Static method to decode from tagged CBOR binary data.
|
|
1089
1074
|
*/
|
|
1090
1075
|
static fromTaggedCborData(data) {
|
|
1091
|
-
const cbor
|
|
1092
|
-
return Digest.fromTaggedCbor(cbor
|
|
1076
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
1077
|
+
return Digest.fromTaggedCbor(cbor);
|
|
1093
1078
|
}
|
|
1094
1079
|
/**
|
|
1095
1080
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -1137,10 +1122,9 @@ init_error();
|
|
|
1137
1122
|
}
|
|
1138
1123
|
};
|
|
1139
1124
|
}));
|
|
1140
|
-
|
|
1141
|
-
//#
|
|
1142
|
-
|
|
1143
|
-
/**
|
|
1125
|
+
//#endregion
|
|
1126
|
+
//#region src/compressed.ts
|
|
1127
|
+
/**
|
|
1144
1128
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
1145
1129
|
* Copyright © 2025-2026 Parity Technologies
|
|
1146
1130
|
*
|
|
@@ -1427,10 +1411,9 @@ init_error();
|
|
|
1427
1411
|
return Compressed.fromDecompressedData(new Uint8Array(0)).fromUntaggedCbor(cborValue);
|
|
1428
1412
|
}
|
|
1429
1413
|
};
|
|
1430
|
-
|
|
1431
|
-
//#
|
|
1432
|
-
|
|
1433
|
-
/**
|
|
1414
|
+
//#endregion
|
|
1415
|
+
//#region src/hkdf-rng.ts
|
|
1416
|
+
/**
|
|
1434
1417
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
1435
1418
|
* Copyright © 2025-2026 Parity Technologies
|
|
1436
1419
|
*
|
|
@@ -1640,10 +1623,9 @@ init_error();
|
|
|
1640
1623
|
return this._pageIndex;
|
|
1641
1624
|
}
|
|
1642
1625
|
};
|
|
1643
|
-
|
|
1644
|
-
//#
|
|
1645
|
-
|
|
1646
|
-
/**
|
|
1626
|
+
//#endregion
|
|
1627
|
+
//#region src/digest-provider.ts
|
|
1628
|
+
/**
|
|
1647
1629
|
* Helper function to get a digest from a byte array.
|
|
1648
1630
|
* This provides DigestProvider-like functionality for raw bytes.
|
|
1649
1631
|
*
|
|
@@ -1651,13 +1633,12 @@ init_error();
|
|
|
1651
1633
|
* @returns A Promise resolving to a Digest of the data
|
|
1652
1634
|
*/
|
|
1653
1635
|
async function digestFromBytes(data) {
|
|
1654
|
-
const { Digest
|
|
1655
|
-
return Digest
|
|
1636
|
+
const { Digest } = await Promise.resolve().then(() => (init_digest(), digest_exports));
|
|
1637
|
+
return Digest.fromImage(data);
|
|
1656
1638
|
}
|
|
1657
|
-
|
|
1658
|
-
//#
|
|
1659
|
-
|
|
1660
|
-
/**
|
|
1639
|
+
//#endregion
|
|
1640
|
+
//#region src/nonce.ts
|
|
1641
|
+
/**
|
|
1661
1642
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
1662
1643
|
* Copyright © 2025-2026 Parity Technologies
|
|
1663
1644
|
*
|
|
@@ -1839,30 +1820,30 @@ init_error();
|
|
|
1839
1820
|
/**
|
|
1840
1821
|
* Creates a Nonce by decoding it from untagged CBOR.
|
|
1841
1822
|
*/
|
|
1842
|
-
fromUntaggedCbor(cbor
|
|
1843
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
1823
|
+
fromUntaggedCbor(cbor) {
|
|
1824
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
1844
1825
|
return Nonce.fromDataRef(data);
|
|
1845
1826
|
}
|
|
1846
1827
|
/**
|
|
1847
1828
|
* Creates a Nonce by decoding it from tagged CBOR.
|
|
1848
1829
|
*/
|
|
1849
|
-
fromTaggedCbor(cbor
|
|
1850
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
1851
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
1830
|
+
fromTaggedCbor(cbor) {
|
|
1831
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
1832
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
1852
1833
|
return this.fromUntaggedCbor(content);
|
|
1853
1834
|
}
|
|
1854
1835
|
/**
|
|
1855
1836
|
* Static method to decode from tagged CBOR.
|
|
1856
1837
|
*/
|
|
1857
|
-
static fromTaggedCbor(cbor
|
|
1858
|
-
return new Nonce(new Uint8Array(Nonce.NONCE_SIZE)).fromTaggedCbor(cbor
|
|
1838
|
+
static fromTaggedCbor(cbor) {
|
|
1839
|
+
return new Nonce(new Uint8Array(Nonce.NONCE_SIZE)).fromTaggedCbor(cbor);
|
|
1859
1840
|
}
|
|
1860
1841
|
/**
|
|
1861
1842
|
* Static method to decode from tagged CBOR binary data.
|
|
1862
1843
|
*/
|
|
1863
1844
|
static fromTaggedCborData(data) {
|
|
1864
|
-
const cbor
|
|
1865
|
-
return Nonce.fromTaggedCbor(cbor
|
|
1845
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
1846
|
+
return Nonce.fromTaggedCbor(cbor);
|
|
1866
1847
|
}
|
|
1867
1848
|
/**
|
|
1868
1849
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -1899,10 +1880,9 @@ init_error();
|
|
|
1899
1880
|
return Nonce.fromUR(ur);
|
|
1900
1881
|
}
|
|
1901
1882
|
};
|
|
1902
|
-
|
|
1903
|
-
//#
|
|
1904
|
-
|
|
1905
|
-
/**
|
|
1883
|
+
//#endregion
|
|
1884
|
+
//#region src/salt.ts
|
|
1885
|
+
/**
|
|
1906
1886
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
1907
1887
|
* Copyright © 2025-2026 Parity Technologies
|
|
1908
1888
|
*
|
|
@@ -2149,30 +2129,30 @@ init_error();
|
|
|
2149
2129
|
/**
|
|
2150
2130
|
* Creates a Salt by decoding it from untagged CBOR.
|
|
2151
2131
|
*/
|
|
2152
|
-
fromUntaggedCbor(cbor
|
|
2153
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
2132
|
+
fromUntaggedCbor(cbor) {
|
|
2133
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
2154
2134
|
return Salt.fromData(data);
|
|
2155
2135
|
}
|
|
2156
2136
|
/**
|
|
2157
2137
|
* Creates a Salt by decoding it from tagged CBOR.
|
|
2158
2138
|
*/
|
|
2159
|
-
fromTaggedCbor(cbor
|
|
2160
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
2161
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
2139
|
+
fromTaggedCbor(cbor) {
|
|
2140
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
2141
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
2162
2142
|
return this.fromUntaggedCbor(content);
|
|
2163
2143
|
}
|
|
2164
2144
|
/**
|
|
2165
2145
|
* Static method to decode from tagged CBOR.
|
|
2166
2146
|
*/
|
|
2167
|
-
static fromTaggedCbor(cbor
|
|
2168
|
-
return new Salt(new Uint8Array(0)).fromTaggedCbor(cbor
|
|
2147
|
+
static fromTaggedCbor(cbor) {
|
|
2148
|
+
return new Salt(new Uint8Array(0)).fromTaggedCbor(cbor);
|
|
2169
2149
|
}
|
|
2170
2150
|
/**
|
|
2171
2151
|
* Static method to decode from tagged CBOR binary data.
|
|
2172
2152
|
*/
|
|
2173
2153
|
static fromTaggedCborData(data) {
|
|
2174
|
-
const cbor
|
|
2175
|
-
return Salt.fromTaggedCbor(cbor
|
|
2154
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
2155
|
+
return Salt.fromTaggedCbor(cbor);
|
|
2176
2156
|
}
|
|
2177
2157
|
/**
|
|
2178
2158
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -2209,10 +2189,9 @@ init_error();
|
|
|
2209
2189
|
return Salt.fromUR(ur);
|
|
2210
2190
|
}
|
|
2211
2191
|
};
|
|
2212
|
-
|
|
2213
|
-
//#
|
|
2214
|
-
|
|
2215
|
-
/**
|
|
2192
|
+
//#endregion
|
|
2193
|
+
//#region src/seed.ts
|
|
2194
|
+
/**
|
|
2216
2195
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
2217
2196
|
* Copyright © 2025-2026 Parity Technologies
|
|
2218
2197
|
*
|
|
@@ -2560,9 +2539,9 @@ init_error();
|
|
|
2560
2539
|
/**
|
|
2561
2540
|
* Creates a Seed by decoding it from tagged CBOR.
|
|
2562
2541
|
*/
|
|
2563
|
-
fromTaggedCbor(cbor
|
|
2564
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
2565
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
2542
|
+
fromTaggedCbor(cbor) {
|
|
2543
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
2544
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
2566
2545
|
return this.fromUntaggedCbor(content);
|
|
2567
2546
|
}
|
|
2568
2547
|
/**
|
|
@@ -2613,9 +2592,8 @@ init_error();
|
|
|
2613
2592
|
return Seed.fromUR(ur);
|
|
2614
2593
|
}
|
|
2615
2594
|
};
|
|
2616
|
-
|
|
2617
|
-
//#
|
|
2618
|
-
//#region src/reference.ts
|
|
2595
|
+
//#endregion
|
|
2596
|
+
//#region src/reference.ts
|
|
2619
2597
|
init_digest();
|
|
2620
2598
|
init_error();
|
|
2621
2599
|
/**
|
|
@@ -2758,10 +2736,9 @@ init_error();
|
|
|
2758
2736
|
return `Reference(${this.shortReference("hex")})`;
|
|
2759
2737
|
}
|
|
2760
2738
|
};
|
|
2761
|
-
|
|
2762
|
-
//#
|
|
2763
|
-
|
|
2764
|
-
/**
|
|
2739
|
+
//#endregion
|
|
2740
|
+
//#region src/id/arid.ts
|
|
2741
|
+
/**
|
|
2765
2742
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
2766
2743
|
* Copyright © 2025-2026 Parity Technologies
|
|
2767
2744
|
*
|
|
@@ -2956,30 +2933,30 @@ init_error();
|
|
|
2956
2933
|
/**
|
|
2957
2934
|
* Creates an ARID by decoding it from untagged CBOR.
|
|
2958
2935
|
*/
|
|
2959
|
-
fromUntaggedCbor(cbor
|
|
2960
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
2936
|
+
fromUntaggedCbor(cbor) {
|
|
2937
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
2961
2938
|
return ARID.fromDataRef(data);
|
|
2962
2939
|
}
|
|
2963
2940
|
/**
|
|
2964
2941
|
* Creates an ARID by decoding it from tagged CBOR.
|
|
2965
2942
|
*/
|
|
2966
|
-
fromTaggedCbor(cbor
|
|
2967
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
2968
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
2943
|
+
fromTaggedCbor(cbor) {
|
|
2944
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
2945
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
2969
2946
|
return this.fromUntaggedCbor(content);
|
|
2970
2947
|
}
|
|
2971
2948
|
/**
|
|
2972
2949
|
* Static method to decode from tagged CBOR.
|
|
2973
2950
|
*/
|
|
2974
|
-
static fromTaggedCbor(cbor
|
|
2975
|
-
return new ARID(new Uint8Array(ARID.ARID_SIZE)).fromTaggedCbor(cbor
|
|
2951
|
+
static fromTaggedCbor(cbor) {
|
|
2952
|
+
return new ARID(new Uint8Array(ARID.ARID_SIZE)).fromTaggedCbor(cbor);
|
|
2976
2953
|
}
|
|
2977
2954
|
/**
|
|
2978
2955
|
* Static method to decode from tagged CBOR binary data.
|
|
2979
2956
|
*/
|
|
2980
2957
|
static fromTaggedCborData(data) {
|
|
2981
|
-
const cbor
|
|
2982
|
-
return ARID.fromTaggedCbor(cbor
|
|
2958
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
2959
|
+
return ARID.fromTaggedCbor(cbor);
|
|
2983
2960
|
}
|
|
2984
2961
|
/**
|
|
2985
2962
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -3022,10 +2999,9 @@ init_error();
|
|
|
3022
2999
|
return ARID.fromURString(urString);
|
|
3023
3000
|
}
|
|
3024
3001
|
};
|
|
3025
|
-
|
|
3026
|
-
//#
|
|
3027
|
-
|
|
3028
|
-
/**
|
|
3002
|
+
//#endregion
|
|
3003
|
+
//#region src/id/uuid.ts
|
|
3004
|
+
/**
|
|
3029
3005
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
3030
3006
|
* Copyright © 2025-2026 Parity Technologies
|
|
3031
3007
|
*
|
|
@@ -3199,30 +3175,30 @@ init_error();
|
|
|
3199
3175
|
/**
|
|
3200
3176
|
* Creates a UUID by decoding it from untagged CBOR.
|
|
3201
3177
|
*/
|
|
3202
|
-
fromUntaggedCbor(cbor
|
|
3203
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
3178
|
+
fromUntaggedCbor(cbor) {
|
|
3179
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
3204
3180
|
return UUID.fromDataRef(data);
|
|
3205
3181
|
}
|
|
3206
3182
|
/**
|
|
3207
3183
|
* Creates a UUID by decoding it from tagged CBOR.
|
|
3208
3184
|
*/
|
|
3209
|
-
fromTaggedCbor(cbor
|
|
3210
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
3211
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
3185
|
+
fromTaggedCbor(cbor) {
|
|
3186
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
3187
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
3212
3188
|
return this.fromUntaggedCbor(content);
|
|
3213
3189
|
}
|
|
3214
3190
|
/**
|
|
3215
3191
|
* Static method to decode from tagged CBOR.
|
|
3216
3192
|
*/
|
|
3217
|
-
static fromTaggedCbor(cbor
|
|
3218
|
-
return new UUID(new Uint8Array(UUID_SIZE)).fromTaggedCbor(cbor
|
|
3193
|
+
static fromTaggedCbor(cbor) {
|
|
3194
|
+
return new UUID(new Uint8Array(UUID_SIZE)).fromTaggedCbor(cbor);
|
|
3219
3195
|
}
|
|
3220
3196
|
/**
|
|
3221
3197
|
* Static method to decode from tagged CBOR binary data.
|
|
3222
3198
|
*/
|
|
3223
3199
|
static fromTaggedCborData(data) {
|
|
3224
|
-
const cbor
|
|
3225
|
-
return UUID.fromTaggedCbor(cbor
|
|
3200
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
3201
|
+
return UUID.fromTaggedCbor(cbor);
|
|
3226
3202
|
}
|
|
3227
3203
|
/**
|
|
3228
3204
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -3259,10 +3235,9 @@ init_error();
|
|
|
3259
3235
|
return UUID.fromUR(ur);
|
|
3260
3236
|
}
|
|
3261
3237
|
};
|
|
3262
|
-
|
|
3263
|
-
//#
|
|
3264
|
-
|
|
3265
|
-
/**
|
|
3238
|
+
//#endregion
|
|
3239
|
+
//#region src/id/xid.ts
|
|
3240
|
+
/**
|
|
3266
3241
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
3267
3242
|
* Copyright © 2025-2026 Parity Technologies
|
|
3268
3243
|
*
|
|
@@ -3479,30 +3454,30 @@ init_error();
|
|
|
3479
3454
|
/**
|
|
3480
3455
|
* Creates a XID by decoding it from untagged CBOR.
|
|
3481
3456
|
*/
|
|
3482
|
-
fromUntaggedCbor(cbor
|
|
3483
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
3457
|
+
fromUntaggedCbor(cbor) {
|
|
3458
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
3484
3459
|
return XID.fromDataRef(data);
|
|
3485
3460
|
}
|
|
3486
3461
|
/**
|
|
3487
3462
|
* Creates a XID by decoding it from tagged CBOR.
|
|
3488
3463
|
*/
|
|
3489
|
-
fromTaggedCbor(cbor
|
|
3490
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
3491
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
3464
|
+
fromTaggedCbor(cbor) {
|
|
3465
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
3466
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
3492
3467
|
return this.fromUntaggedCbor(content);
|
|
3493
3468
|
}
|
|
3494
3469
|
/**
|
|
3495
3470
|
* Static method to decode from tagged CBOR.
|
|
3496
3471
|
*/
|
|
3497
|
-
static fromTaggedCbor(cbor
|
|
3498
|
-
return new XID(new Uint8Array(XID_SIZE)).fromTaggedCbor(cbor
|
|
3472
|
+
static fromTaggedCbor(cbor) {
|
|
3473
|
+
return new XID(new Uint8Array(XID_SIZE)).fromTaggedCbor(cbor);
|
|
3499
3474
|
}
|
|
3500
3475
|
/**
|
|
3501
3476
|
* Static method to decode from tagged CBOR binary data.
|
|
3502
3477
|
*/
|
|
3503
3478
|
static fromTaggedCborData(data) {
|
|
3504
|
-
const cbor
|
|
3505
|
-
return XID.fromTaggedCbor(cbor
|
|
3479
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
3480
|
+
return XID.fromTaggedCbor(cbor);
|
|
3506
3481
|
}
|
|
3507
3482
|
/**
|
|
3508
3483
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -3539,10 +3514,9 @@ init_error();
|
|
|
3539
3514
|
return XID.fromUR(ur);
|
|
3540
3515
|
}
|
|
3541
3516
|
};
|
|
3542
|
-
|
|
3543
|
-
//#
|
|
3544
|
-
|
|
3545
|
-
/**
|
|
3517
|
+
//#endregion
|
|
3518
|
+
//#region src/id/uri.ts
|
|
3519
|
+
/**
|
|
3546
3520
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
3547
3521
|
* Copyright © 2025-2026 Parity Technologies
|
|
3548
3522
|
*
|
|
@@ -3762,10 +3736,9 @@ init_error();
|
|
|
3762
3736
|
return URI.fromUR(ur);
|
|
3763
3737
|
}
|
|
3764
3738
|
};
|
|
3765
|
-
|
|
3766
|
-
//#
|
|
3767
|
-
|
|
3768
|
-
/**
|
|
3739
|
+
//#endregion
|
|
3740
|
+
//#region src/x25519/x25519-public-key.ts
|
|
3741
|
+
/**
|
|
3769
3742
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
3770
3743
|
* Copyright © 2025-2026 Parity Technologies
|
|
3771
3744
|
*
|
|
@@ -3898,37 +3871,37 @@ init_error();
|
|
|
3898
3871
|
/**
|
|
3899
3872
|
* Creates an X25519PublicKey by decoding it from untagged CBOR.
|
|
3900
3873
|
*/
|
|
3901
|
-
fromUntaggedCbor(cbor
|
|
3902
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
3874
|
+
fromUntaggedCbor(cbor) {
|
|
3875
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
3903
3876
|
return X25519PublicKey.fromDataRef(data);
|
|
3904
3877
|
}
|
|
3905
3878
|
/**
|
|
3906
3879
|
* Creates an X25519PublicKey by decoding it from tagged CBOR.
|
|
3907
3880
|
*/
|
|
3908
|
-
fromTaggedCbor(cbor
|
|
3909
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
3910
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
3881
|
+
fromTaggedCbor(cbor) {
|
|
3882
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
3883
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
3911
3884
|
return this.fromUntaggedCbor(content);
|
|
3912
3885
|
}
|
|
3913
3886
|
/**
|
|
3914
3887
|
* Static method to decode from tagged CBOR.
|
|
3915
3888
|
*/
|
|
3916
|
-
static fromTaggedCbor(cbor
|
|
3917
|
-
return new X25519PublicKey(new Uint8Array(_bcts_crypto.X25519_PUBLIC_KEY_SIZE)).fromTaggedCbor(cbor
|
|
3889
|
+
static fromTaggedCbor(cbor) {
|
|
3890
|
+
return new X25519PublicKey(new Uint8Array(_bcts_crypto.X25519_PUBLIC_KEY_SIZE)).fromTaggedCbor(cbor);
|
|
3918
3891
|
}
|
|
3919
3892
|
/**
|
|
3920
3893
|
* Static method to decode from tagged CBOR binary data.
|
|
3921
3894
|
*/
|
|
3922
3895
|
static fromTaggedCborData(data) {
|
|
3923
|
-
const cbor
|
|
3924
|
-
return X25519PublicKey.fromTaggedCbor(cbor
|
|
3896
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
3897
|
+
return X25519PublicKey.fromTaggedCbor(cbor);
|
|
3925
3898
|
}
|
|
3926
3899
|
/**
|
|
3927
3900
|
* Static method to decode from untagged CBOR binary data.
|
|
3928
3901
|
*/
|
|
3929
3902
|
static fromUntaggedCborData(data) {
|
|
3930
|
-
const cbor
|
|
3931
|
-
return new X25519PublicKey(new Uint8Array(_bcts_crypto.X25519_PUBLIC_KEY_SIZE)).fromUntaggedCbor(cbor
|
|
3903
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
3904
|
+
return new X25519PublicKey(new Uint8Array(_bcts_crypto.X25519_PUBLIC_KEY_SIZE)).fromUntaggedCbor(cbor);
|
|
3932
3905
|
}
|
|
3933
3906
|
/**
|
|
3934
3907
|
* Returns the UR representation of the X25519PublicKey.
|
|
@@ -3962,10 +3935,9 @@ init_error();
|
|
|
3962
3935
|
return X25519PublicKey.fromUR(ur);
|
|
3963
3936
|
}
|
|
3964
3937
|
};
|
|
3965
|
-
|
|
3966
|
-
//#
|
|
3967
|
-
|
|
3968
|
-
/**
|
|
3938
|
+
//#endregion
|
|
3939
|
+
//#region src/symmetric/authentication-tag.ts
|
|
3940
|
+
/**
|
|
3969
3941
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
3970
3942
|
* Copyright © 2025-2026 Parity Technologies
|
|
3971
3943
|
*
|
|
@@ -4081,22 +4053,21 @@ init_error();
|
|
|
4081
4053
|
/**
|
|
4082
4054
|
* Creates an AuthenticationTag from CBOR.
|
|
4083
4055
|
*/
|
|
4084
|
-
static fromCbor(cbor
|
|
4085
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
4056
|
+
static fromCbor(cbor) {
|
|
4057
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
4086
4058
|
return AuthenticationTag.fromDataRef(data);
|
|
4087
4059
|
}
|
|
4088
4060
|
/**
|
|
4089
4061
|
* Creates an AuthenticationTag from CBOR binary data.
|
|
4090
4062
|
*/
|
|
4091
4063
|
static fromCborData(data) {
|
|
4092
|
-
const cbor
|
|
4093
|
-
return AuthenticationTag.fromCbor(cbor
|
|
4064
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
4065
|
+
return AuthenticationTag.fromCbor(cbor);
|
|
4094
4066
|
}
|
|
4095
4067
|
};
|
|
4096
|
-
|
|
4097
|
-
//#
|
|
4098
|
-
|
|
4099
|
-
/**
|
|
4068
|
+
//#endregion
|
|
4069
|
+
//#region src/symmetric/encrypted-message.ts
|
|
4070
|
+
/**
|
|
4100
4071
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
4101
4072
|
* Copyright © 2025-2026 Parity Technologies
|
|
4102
4073
|
*
|
|
@@ -4335,10 +4306,9 @@ init_error();
|
|
|
4335
4306
|
return EncryptedMessage.fromUR(ur);
|
|
4336
4307
|
}
|
|
4337
4308
|
};
|
|
4338
|
-
|
|
4339
|
-
//#
|
|
4340
|
-
|
|
4341
|
-
/**
|
|
4309
|
+
//#endregion
|
|
4310
|
+
//#region src/symmetric/symmetric-key.ts
|
|
4311
|
+
/**
|
|
4342
4312
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
4343
4313
|
* Copyright © 2025-2026 Parity Technologies
|
|
4344
4314
|
*
|
|
@@ -4509,30 +4479,30 @@ init_error();
|
|
|
4509
4479
|
/**
|
|
4510
4480
|
* Creates a SymmetricKey by decoding it from untagged CBOR.
|
|
4511
4481
|
*/
|
|
4512
|
-
fromUntaggedCbor(cbor
|
|
4513
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
4482
|
+
fromUntaggedCbor(cbor) {
|
|
4483
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
4514
4484
|
return SymmetricKey.fromDataRef(data);
|
|
4515
4485
|
}
|
|
4516
4486
|
/**
|
|
4517
4487
|
* Creates a SymmetricKey by decoding it from tagged CBOR.
|
|
4518
4488
|
*/
|
|
4519
|
-
fromTaggedCbor(cbor
|
|
4520
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
4521
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
4489
|
+
fromTaggedCbor(cbor) {
|
|
4490
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
4491
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
4522
4492
|
return this.fromUntaggedCbor(content);
|
|
4523
4493
|
}
|
|
4524
4494
|
/**
|
|
4525
4495
|
* Static method to decode from tagged CBOR.
|
|
4526
4496
|
*/
|
|
4527
|
-
static fromTaggedCbor(cbor
|
|
4528
|
-
return new SymmetricKey(new Uint8Array(SYMMETRIC_KEY_SIZE)).fromTaggedCbor(cbor
|
|
4497
|
+
static fromTaggedCbor(cbor) {
|
|
4498
|
+
return new SymmetricKey(new Uint8Array(SYMMETRIC_KEY_SIZE)).fromTaggedCbor(cbor);
|
|
4529
4499
|
}
|
|
4530
4500
|
/**
|
|
4531
4501
|
* Static method to decode from tagged CBOR binary data.
|
|
4532
4502
|
*/
|
|
4533
4503
|
static fromTaggedCborData(data) {
|
|
4534
|
-
const cbor
|
|
4535
|
-
return SymmetricKey.fromTaggedCbor(cbor
|
|
4504
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
4505
|
+
return SymmetricKey.fromTaggedCbor(cbor);
|
|
4536
4506
|
}
|
|
4537
4507
|
/**
|
|
4538
4508
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -4578,10 +4548,9 @@ init_error();
|
|
|
4578
4548
|
return SymmetricKey.fromURString(urString);
|
|
4579
4549
|
}
|
|
4580
4550
|
};
|
|
4581
|
-
|
|
4582
|
-
//#
|
|
4583
|
-
|
|
4584
|
-
/**
|
|
4551
|
+
//#endregion
|
|
4552
|
+
//#region src/x25519/x25519-private-key.ts
|
|
4553
|
+
/**
|
|
4585
4554
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
4586
4555
|
* Copyright © 2025-2026 Parity Technologies
|
|
4587
4556
|
*
|
|
@@ -4792,37 +4761,37 @@ init_error();
|
|
|
4792
4761
|
/**
|
|
4793
4762
|
* Creates an X25519PrivateKey by decoding it from untagged CBOR.
|
|
4794
4763
|
*/
|
|
4795
|
-
fromUntaggedCbor(cbor
|
|
4796
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
4764
|
+
fromUntaggedCbor(cbor) {
|
|
4765
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
4797
4766
|
return X25519PrivateKey.fromDataRef(data);
|
|
4798
4767
|
}
|
|
4799
4768
|
/**
|
|
4800
4769
|
* Creates an X25519PrivateKey by decoding it from tagged CBOR.
|
|
4801
4770
|
*/
|
|
4802
|
-
fromTaggedCbor(cbor
|
|
4803
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
4804
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
4771
|
+
fromTaggedCbor(cbor) {
|
|
4772
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
4773
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
4805
4774
|
return this.fromUntaggedCbor(content);
|
|
4806
4775
|
}
|
|
4807
4776
|
/**
|
|
4808
4777
|
* Static method to decode from tagged CBOR.
|
|
4809
4778
|
*/
|
|
4810
|
-
static fromTaggedCbor(cbor
|
|
4811
|
-
return new X25519PrivateKey(new Uint8Array(_bcts_crypto.X25519_PRIVATE_KEY_SIZE)).fromTaggedCbor(cbor
|
|
4779
|
+
static fromTaggedCbor(cbor) {
|
|
4780
|
+
return new X25519PrivateKey(new Uint8Array(_bcts_crypto.X25519_PRIVATE_KEY_SIZE)).fromTaggedCbor(cbor);
|
|
4812
4781
|
}
|
|
4813
4782
|
/**
|
|
4814
4783
|
* Static method to decode from tagged CBOR binary data.
|
|
4815
4784
|
*/
|
|
4816
4785
|
static fromTaggedCborData(data) {
|
|
4817
|
-
const cbor
|
|
4818
|
-
return X25519PrivateKey.fromTaggedCbor(cbor
|
|
4786
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
4787
|
+
return X25519PrivateKey.fromTaggedCbor(cbor);
|
|
4819
4788
|
}
|
|
4820
4789
|
/**
|
|
4821
4790
|
* Static method to decode from untagged CBOR binary data.
|
|
4822
4791
|
*/
|
|
4823
4792
|
static fromUntaggedCborData(data) {
|
|
4824
|
-
const cbor
|
|
4825
|
-
return new X25519PrivateKey(new Uint8Array(_bcts_crypto.X25519_PRIVATE_KEY_SIZE)).fromUntaggedCbor(cbor
|
|
4793
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
4794
|
+
return new X25519PrivateKey(new Uint8Array(_bcts_crypto.X25519_PRIVATE_KEY_SIZE)).fromUntaggedCbor(cbor);
|
|
4826
4795
|
}
|
|
4827
4796
|
/**
|
|
4828
4797
|
* Returns the UR representation of the X25519PrivateKey.
|
|
@@ -4856,10 +4825,9 @@ init_error();
|
|
|
4856
4825
|
return X25519PrivateKey.fromUR(ur);
|
|
4857
4826
|
}
|
|
4858
4827
|
};
|
|
4859
|
-
|
|
4860
|
-
//#
|
|
4861
|
-
|
|
4862
|
-
/**
|
|
4828
|
+
//#endregion
|
|
4829
|
+
//#region src/ed25519/ed25519-public-key.ts
|
|
4830
|
+
/**
|
|
4863
4831
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
4864
4832
|
* Copyright © 2025-2026 Parity Technologies
|
|
4865
4833
|
*
|
|
@@ -4931,10 +4899,9 @@ init_error();
|
|
|
4931
4899
|
return `Ed25519PublicKey(${this.toHex().substring(0, 16)}...)`;
|
|
4932
4900
|
}
|
|
4933
4901
|
};
|
|
4934
|
-
|
|
4935
|
-
//#
|
|
4936
|
-
|
|
4937
|
-
/**
|
|
4902
|
+
//#endregion
|
|
4903
|
+
//#region src/ed25519/ed25519-private-key.ts
|
|
4904
|
+
/**
|
|
4938
4905
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
4939
4906
|
* Copyright © 2025-2026 Parity Technologies
|
|
4940
4907
|
*
|
|
@@ -5029,10 +4996,9 @@ init_error();
|
|
|
5029
4996
|
return `Ed25519PrivateKey(${this.toHex().substring(0, 16)}...)`;
|
|
5030
4997
|
}
|
|
5031
4998
|
};
|
|
5032
|
-
|
|
5033
|
-
//#
|
|
5034
|
-
|
|
5035
|
-
/**
|
|
4999
|
+
//#endregion
|
|
5000
|
+
//#region src/sr25519/sr25519-public-key.ts
|
|
5001
|
+
/**
|
|
5036
5002
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5037
5003
|
* Copyright © 2025-2026 Parity Technologies
|
|
5038
5004
|
*
|
|
@@ -5055,7 +5021,7 @@ init_error();
|
|
|
5055
5021
|
var Sr25519PublicKey = class Sr25519PublicKey {
|
|
5056
5022
|
_data;
|
|
5057
5023
|
constructor(data) {
|
|
5058
|
-
if (data.length !==
|
|
5024
|
+
if (data.length !== 32) throw new Error(`Sr25519PublicKey must be 32 bytes, got ${data.length}`);
|
|
5059
5025
|
this._data = new Uint8Array(data);
|
|
5060
5026
|
}
|
|
5061
5027
|
/**
|
|
@@ -5135,10 +5101,9 @@ init_error();
|
|
|
5135
5101
|
return `Sr25519PublicKey(${bytesToHex(this._data).substring(0, 16)}...)`;
|
|
5136
5102
|
}
|
|
5137
5103
|
};
|
|
5138
|
-
|
|
5139
|
-
//#
|
|
5140
|
-
|
|
5141
|
-
/**
|
|
5104
|
+
//#endregion
|
|
5105
|
+
//#region src/sr25519/sr25519-private-key.ts
|
|
5106
|
+
/**
|
|
5142
5107
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5143
5108
|
* Copyright © 2025-2026 Parity Technologies
|
|
5144
5109
|
*
|
|
@@ -5175,7 +5140,7 @@ init_error();
|
|
|
5175
5140
|
_seed;
|
|
5176
5141
|
_cachedPublicKey;
|
|
5177
5142
|
constructor(seed) {
|
|
5178
|
-
if (seed.length !==
|
|
5143
|
+
if (seed.length !== 32) throw new Error(`Sr25519PrivateKey seed must be 32 bytes, got ${seed.length}`);
|
|
5179
5144
|
this._seed = new Uint8Array(seed);
|
|
5180
5145
|
}
|
|
5181
5146
|
/**
|
|
@@ -5189,7 +5154,7 @@ init_error();
|
|
|
5189
5154
|
* Create a new random Sr25519 private key using the provided RNG.
|
|
5190
5155
|
*/
|
|
5191
5156
|
static randomUsing(rng) {
|
|
5192
|
-
return new Sr25519PrivateKey(rng.randomData(
|
|
5157
|
+
return new Sr25519PrivateKey(rng.randomData(32));
|
|
5193
5158
|
}
|
|
5194
5159
|
/**
|
|
5195
5160
|
* Create an Sr25519 private key from a 32-byte seed.
|
|
@@ -5220,7 +5185,7 @@ init_error();
|
|
|
5220
5185
|
* @returns A new Sr25519 private key
|
|
5221
5186
|
*/
|
|
5222
5187
|
static deriveFromKeyMaterial(keyMaterial) {
|
|
5223
|
-
return new Sr25519PrivateKey((0, _noble_hashes_blake2_js.blake2b)(keyMaterial, { dkLen:
|
|
5188
|
+
return new Sr25519PrivateKey((0, _noble_hashes_blake2_js.blake2b)(keyMaterial, { dkLen: 32 }));
|
|
5224
5189
|
}
|
|
5225
5190
|
/**
|
|
5226
5191
|
* Generate a keypair and return both private and public keys.
|
|
@@ -5309,10 +5274,9 @@ init_error();
|
|
|
5309
5274
|
return `Sr25519PrivateKey(${bytesToHex(this._seed).substring(0, 8)}...)`;
|
|
5310
5275
|
}
|
|
5311
5276
|
};
|
|
5312
|
-
|
|
5313
|
-
//#
|
|
5314
|
-
|
|
5315
|
-
/**
|
|
5277
|
+
//#endregion
|
|
5278
|
+
//#region src/ec-key/ec-key-base.ts
|
|
5279
|
+
/**
|
|
5316
5280
|
* Type guard to check if an object implements ECKeyBase.
|
|
5317
5281
|
*/
|
|
5318
5282
|
function isECKeyBase(obj) {
|
|
@@ -5334,10 +5298,9 @@ init_error();
|
|
|
5334
5298
|
if (!isECKey(obj)) return false;
|
|
5335
5299
|
return typeof obj.uncompressedPublicKey === "function";
|
|
5336
5300
|
}
|
|
5337
|
-
|
|
5338
|
-
//#
|
|
5339
|
-
|
|
5340
|
-
/**
|
|
5301
|
+
//#endregion
|
|
5302
|
+
//#region src/ec-key/ec-uncompressed-public-key.ts
|
|
5303
|
+
/**
|
|
5341
5304
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5342
5305
|
* Copyright © 2025-2026 Parity Technologies
|
|
5343
5306
|
*
|
|
@@ -5550,10 +5513,9 @@ init_error();
|
|
|
5550
5513
|
return ECUncompressedPublicKey.fromUR(ur);
|
|
5551
5514
|
}
|
|
5552
5515
|
};
|
|
5553
|
-
|
|
5554
|
-
//#
|
|
5555
|
-
|
|
5556
|
-
/**
|
|
5516
|
+
//#endregion
|
|
5517
|
+
//#region src/ec-key/ec-public-key.ts
|
|
5518
|
+
/**
|
|
5557
5519
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5558
5520
|
* Copyright © 2025-2026 Parity Technologies
|
|
5559
5521
|
*
|
|
@@ -5792,10 +5754,9 @@ init_error();
|
|
|
5792
5754
|
return ECPublicKey.fromUR(ur);
|
|
5793
5755
|
}
|
|
5794
5756
|
};
|
|
5795
|
-
|
|
5796
|
-
//#
|
|
5797
|
-
|
|
5798
|
-
/**
|
|
5757
|
+
//#endregion
|
|
5758
|
+
//#region src/ec-key/schnorr-public-key.ts
|
|
5759
|
+
/**
|
|
5799
5760
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5800
5761
|
* Copyright © 2025-2026 Parity Technologies
|
|
5801
5762
|
*
|
|
@@ -5917,10 +5878,9 @@ init_error();
|
|
|
5917
5878
|
return `SchnorrPublicKey(${this.toHex().substring(0, 16)}...)`;
|
|
5918
5879
|
}
|
|
5919
5880
|
};
|
|
5920
|
-
|
|
5921
|
-
//#
|
|
5922
|
-
|
|
5923
|
-
/**
|
|
5881
|
+
//#endregion
|
|
5882
|
+
//#region src/ec-key/ec-private-key.ts
|
|
5883
|
+
/**
|
|
5924
5884
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
5925
5885
|
* Copyright © 2025-2026 Parity Technologies
|
|
5926
5886
|
*
|
|
@@ -6234,10 +6194,9 @@ init_error();
|
|
|
6234
6194
|
return ECPrivateKey.fromUR(ur);
|
|
6235
6195
|
}
|
|
6236
6196
|
};
|
|
6237
|
-
|
|
6238
|
-
//#
|
|
6239
|
-
|
|
6240
|
-
/**
|
|
6197
|
+
//#endregion
|
|
6198
|
+
//#region src/mldsa/mldsa-level.ts
|
|
6199
|
+
/**
|
|
6241
6200
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
6242
6201
|
* Copyright © 2025-2026 Parity Technologies
|
|
6243
6202
|
*
|
|
@@ -6262,30 +6221,30 @@ init_error();
|
|
|
6262
6221
|
* - 3: NIST Level 3 (MLDSA65)
|
|
6263
6222
|
* - 5: NIST Level 5 (MLDSA87)
|
|
6264
6223
|
*/
|
|
6265
|
-
let MLDSALevel = /* @__PURE__ */ function(MLDSALevel
|
|
6224
|
+
let MLDSALevel = /* @__PURE__ */ function(MLDSALevel) {
|
|
6266
6225
|
/** NIST Level 2 - AES-128 equivalent security */
|
|
6267
|
-
MLDSALevel
|
|
6226
|
+
MLDSALevel[MLDSALevel["MLDSA44"] = 2] = "MLDSA44";
|
|
6268
6227
|
/** NIST Level 3 - AES-192 equivalent security */
|
|
6269
|
-
MLDSALevel
|
|
6228
|
+
MLDSALevel[MLDSALevel["MLDSA65"] = 3] = "MLDSA65";
|
|
6270
6229
|
/** NIST Level 5 - AES-256 equivalent security */
|
|
6271
|
-
MLDSALevel
|
|
6272
|
-
return MLDSALevel
|
|
6230
|
+
MLDSALevel[MLDSALevel["MLDSA87"] = 5] = "MLDSA87";
|
|
6231
|
+
return MLDSALevel;
|
|
6273
6232
|
}({});
|
|
6274
6233
|
/**
|
|
6275
6234
|
* Key sizes for each ML-DSA security level.
|
|
6276
6235
|
*/
|
|
6277
6236
|
const MLDSA_KEY_SIZES = {
|
|
6278
|
-
[
|
|
6237
|
+
[2]: {
|
|
6279
6238
|
privateKey: 2560,
|
|
6280
6239
|
publicKey: 1312,
|
|
6281
6240
|
signature: 2420
|
|
6282
6241
|
},
|
|
6283
|
-
[
|
|
6242
|
+
[3]: {
|
|
6284
6243
|
privateKey: 4032,
|
|
6285
6244
|
publicKey: 1952,
|
|
6286
6245
|
signature: 3309
|
|
6287
6246
|
},
|
|
6288
|
-
[
|
|
6247
|
+
[5]: {
|
|
6289
6248
|
privateKey: 4896,
|
|
6290
6249
|
publicKey: 2592,
|
|
6291
6250
|
signature: 4627
|
|
@@ -6314,9 +6273,9 @@ init_error();
|
|
|
6314
6273
|
*/
|
|
6315
6274
|
function mldsaLevelToString(level) {
|
|
6316
6275
|
switch (level) {
|
|
6317
|
-
case
|
|
6318
|
-
case
|
|
6319
|
-
case
|
|
6276
|
+
case 2: return "MLDSA44";
|
|
6277
|
+
case 3: return "MLDSA65";
|
|
6278
|
+
case 5: return "MLDSA87";
|
|
6320
6279
|
}
|
|
6321
6280
|
}
|
|
6322
6281
|
/**
|
|
@@ -6324,9 +6283,9 @@ init_error();
|
|
|
6324
6283
|
*/
|
|
6325
6284
|
function mldsaLevelFromValue(value) {
|
|
6326
6285
|
switch (value) {
|
|
6327
|
-
case 2: return
|
|
6328
|
-
case 3: return
|
|
6329
|
-
case 5: return
|
|
6286
|
+
case 2: return 2;
|
|
6287
|
+
case 3: return 3;
|
|
6288
|
+
case 5: return 5;
|
|
6330
6289
|
default: throw new Error(`Invalid MLDSA level value: ${value}`);
|
|
6331
6290
|
}
|
|
6332
6291
|
}
|
|
@@ -6349,21 +6308,21 @@ init_error();
|
|
|
6349
6308
|
function mldsaGenerateKeypairUsing(level, rng) {
|
|
6350
6309
|
const seed = rng.randomData(32);
|
|
6351
6310
|
switch (level) {
|
|
6352
|
-
case
|
|
6311
|
+
case 2: {
|
|
6353
6312
|
const keypair = _noble_post_quantum_ml_dsa_js.ml_dsa44.keygen(seed);
|
|
6354
6313
|
return {
|
|
6355
6314
|
publicKey: keypair.publicKey,
|
|
6356
6315
|
secretKey: keypair.secretKey
|
|
6357
6316
|
};
|
|
6358
6317
|
}
|
|
6359
|
-
case
|
|
6318
|
+
case 3: {
|
|
6360
6319
|
const keypair = _noble_post_quantum_ml_dsa_js.ml_dsa65.keygen(seed);
|
|
6361
6320
|
return {
|
|
6362
6321
|
publicKey: keypair.publicKey,
|
|
6363
6322
|
secretKey: keypair.secretKey
|
|
6364
6323
|
};
|
|
6365
6324
|
}
|
|
6366
|
-
case
|
|
6325
|
+
case 5: {
|
|
6367
6326
|
const keypair = _noble_post_quantum_ml_dsa_js.ml_dsa87.keygen(seed);
|
|
6368
6327
|
return {
|
|
6369
6328
|
publicKey: keypair.publicKey,
|
|
@@ -6382,9 +6341,9 @@ init_error();
|
|
|
6382
6341
|
*/
|
|
6383
6342
|
function mldsaSign(level, secretKey, message) {
|
|
6384
6343
|
switch (level) {
|
|
6385
|
-
case
|
|
6386
|
-
case
|
|
6387
|
-
case
|
|
6344
|
+
case 2: return _noble_post_quantum_ml_dsa_js.ml_dsa44.sign(message, secretKey);
|
|
6345
|
+
case 3: return _noble_post_quantum_ml_dsa_js.ml_dsa65.sign(message, secretKey);
|
|
6346
|
+
case 5: return _noble_post_quantum_ml_dsa_js.ml_dsa87.sign(message, secretKey);
|
|
6388
6347
|
}
|
|
6389
6348
|
}
|
|
6390
6349
|
/**
|
|
@@ -6399,18 +6358,17 @@ init_error();
|
|
|
6399
6358
|
function mldsaVerify(level, publicKey, message, signature) {
|
|
6400
6359
|
try {
|
|
6401
6360
|
switch (level) {
|
|
6402
|
-
case
|
|
6403
|
-
case
|
|
6404
|
-
case
|
|
6361
|
+
case 2: return _noble_post_quantum_ml_dsa_js.ml_dsa44.verify(signature, message, publicKey);
|
|
6362
|
+
case 3: return _noble_post_quantum_ml_dsa_js.ml_dsa65.verify(signature, message, publicKey);
|
|
6363
|
+
case 5: return _noble_post_quantum_ml_dsa_js.ml_dsa87.verify(signature, message, publicKey);
|
|
6405
6364
|
}
|
|
6406
6365
|
} catch {
|
|
6407
6366
|
return false;
|
|
6408
6367
|
}
|
|
6409
6368
|
}
|
|
6410
|
-
|
|
6411
|
-
//#
|
|
6412
|
-
|
|
6413
|
-
/**
|
|
6369
|
+
//#endregion
|
|
6370
|
+
//#region src/mldsa/mldsa-public-key.ts
|
|
6371
|
+
/**
|
|
6414
6372
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
6415
6373
|
* Copyright © 2025-2026 Parity Technologies
|
|
6416
6374
|
*
|
|
@@ -6554,8 +6512,7 @@ init_error();
|
|
|
6554
6512
|
* Static method to decode from tagged CBOR.
|
|
6555
6513
|
*/
|
|
6556
6514
|
static fromTaggedCbor(cborValue) {
|
|
6557
|
-
|
|
6558
|
-
return new MLDSAPublicKey(MLDSALevel.MLDSA44, dummyData).fromTaggedCbor(cborValue);
|
|
6515
|
+
return new MLDSAPublicKey(2, new Uint8Array(mldsaPublicKeySize(2))).fromTaggedCbor(cborValue);
|
|
6559
6516
|
}
|
|
6560
6517
|
/**
|
|
6561
6518
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -6569,8 +6526,7 @@ init_error();
|
|
|
6569
6526
|
*/
|
|
6570
6527
|
static fromUntaggedCborData(data) {
|
|
6571
6528
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
6572
|
-
|
|
6573
|
-
return new MLDSAPublicKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(cborValue);
|
|
6529
|
+
return new MLDSAPublicKey(2, new Uint8Array(mldsaPublicKeySize(2))).fromUntaggedCbor(cborValue);
|
|
6574
6530
|
}
|
|
6575
6531
|
/**
|
|
6576
6532
|
* Returns the UR representation.
|
|
@@ -6591,8 +6547,7 @@ init_error();
|
|
|
6591
6547
|
*/
|
|
6592
6548
|
static fromUR(ur) {
|
|
6593
6549
|
if (ur.urTypeStr() !== _bcts_tags.MLDSA_PUBLIC_KEY.name) throw new Error(`Expected UR type ${_bcts_tags.MLDSA_PUBLIC_KEY.name}, got ${ur.urTypeStr()}`);
|
|
6594
|
-
|
|
6595
|
-
return new MLDSAPublicKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(ur.cbor());
|
|
6550
|
+
return new MLDSAPublicKey(2, new Uint8Array(mldsaPublicKeySize(2))).fromUntaggedCbor(ur.cbor());
|
|
6596
6551
|
}
|
|
6597
6552
|
/**
|
|
6598
6553
|
* Creates an MLDSAPublicKey from a UR string.
|
|
@@ -6602,10 +6557,9 @@ init_error();
|
|
|
6602
6557
|
return MLDSAPublicKey.fromUR(ur);
|
|
6603
6558
|
}
|
|
6604
6559
|
};
|
|
6605
|
-
|
|
6606
|
-
//#
|
|
6607
|
-
|
|
6608
|
-
/**
|
|
6560
|
+
//#endregion
|
|
6561
|
+
//#region src/mldsa/mldsa-signature.ts
|
|
6562
|
+
/**
|
|
6609
6563
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
6610
6564
|
* Copyright © 2025-2026 Parity Technologies
|
|
6611
6565
|
*
|
|
@@ -6738,8 +6692,7 @@ init_error();
|
|
|
6738
6692
|
* Static method to decode from tagged CBOR.
|
|
6739
6693
|
*/
|
|
6740
6694
|
static fromTaggedCbor(cborValue) {
|
|
6741
|
-
|
|
6742
|
-
return new MLDSASignature(MLDSALevel.MLDSA44, dummyData).fromTaggedCbor(cborValue);
|
|
6695
|
+
return new MLDSASignature(2, new Uint8Array(mldsaSignatureSize(2))).fromTaggedCbor(cborValue);
|
|
6743
6696
|
}
|
|
6744
6697
|
/**
|
|
6745
6698
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -6753,8 +6706,7 @@ init_error();
|
|
|
6753
6706
|
*/
|
|
6754
6707
|
static fromUntaggedCborData(data) {
|
|
6755
6708
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
6756
|
-
|
|
6757
|
-
return new MLDSASignature(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(cborValue);
|
|
6709
|
+
return new MLDSASignature(2, new Uint8Array(mldsaSignatureSize(2))).fromUntaggedCbor(cborValue);
|
|
6758
6710
|
}
|
|
6759
6711
|
/**
|
|
6760
6712
|
* Returns the UR representation.
|
|
@@ -6775,8 +6727,7 @@ init_error();
|
|
|
6775
6727
|
*/
|
|
6776
6728
|
static fromUR(ur) {
|
|
6777
6729
|
if (ur.urTypeStr() !== _bcts_tags.MLDSA_SIGNATURE.name) throw new Error(`Expected UR type ${_bcts_tags.MLDSA_SIGNATURE.name}, got ${ur.urTypeStr()}`);
|
|
6778
|
-
|
|
6779
|
-
return new MLDSASignature(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(ur.cbor());
|
|
6730
|
+
return new MLDSASignature(2, new Uint8Array(mldsaSignatureSize(2))).fromUntaggedCbor(ur.cbor());
|
|
6780
6731
|
}
|
|
6781
6732
|
/**
|
|
6782
6733
|
* Creates an MLDSASignature from a UR string.
|
|
@@ -6786,10 +6737,9 @@ init_error();
|
|
|
6786
6737
|
return MLDSASignature.fromUR(ur);
|
|
6787
6738
|
}
|
|
6788
6739
|
};
|
|
6789
|
-
|
|
6790
|
-
//#
|
|
6791
|
-
|
|
6792
|
-
/**
|
|
6740
|
+
//#endregion
|
|
6741
|
+
//#region src/mldsa/mldsa-private-key.ts
|
|
6742
|
+
/**
|
|
6793
6743
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
6794
6744
|
* Copyright © 2025-2026 Parity Technologies
|
|
6795
6745
|
*
|
|
@@ -6830,7 +6780,7 @@ init_error();
|
|
|
6830
6780
|
*
|
|
6831
6781
|
* @param level - The ML-DSA security level (default: MLDSA65)
|
|
6832
6782
|
*/
|
|
6833
|
-
static new(level =
|
|
6783
|
+
static new(level = 3) {
|
|
6834
6784
|
const rng = new _bcts_rand.SecureRandomNumberGenerator();
|
|
6835
6785
|
return MLDSAPrivateKey.newUsing(level, rng);
|
|
6836
6786
|
}
|
|
@@ -6858,7 +6808,7 @@ init_error();
|
|
|
6858
6808
|
* @param level - The ML-DSA security level (default: MLDSA65)
|
|
6859
6809
|
* @returns Tuple of [privateKey, publicKey]
|
|
6860
6810
|
*/
|
|
6861
|
-
static keypair(level =
|
|
6811
|
+
static keypair(level = 3) {
|
|
6862
6812
|
const rng = new _bcts_rand.SecureRandomNumberGenerator();
|
|
6863
6813
|
return MLDSAPrivateKey.keypairUsing(level, rng);
|
|
6864
6814
|
}
|
|
@@ -6981,8 +6931,7 @@ init_error();
|
|
|
6981
6931
|
* Static method to decode from tagged CBOR.
|
|
6982
6932
|
*/
|
|
6983
6933
|
static fromTaggedCbor(cborValue) {
|
|
6984
|
-
|
|
6985
|
-
return new MLDSAPrivateKey(MLDSALevel.MLDSA44, dummyData).fromTaggedCbor(cborValue);
|
|
6934
|
+
return new MLDSAPrivateKey(2, new Uint8Array(mldsaPrivateKeySize(2))).fromTaggedCbor(cborValue);
|
|
6986
6935
|
}
|
|
6987
6936
|
/**
|
|
6988
6937
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -6996,8 +6945,7 @@ init_error();
|
|
|
6996
6945
|
*/
|
|
6997
6946
|
static fromUntaggedCborData(data) {
|
|
6998
6947
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
6999
|
-
|
|
7000
|
-
return new MLDSAPrivateKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(cborValue);
|
|
6948
|
+
return new MLDSAPrivateKey(2, new Uint8Array(mldsaPrivateKeySize(2))).fromUntaggedCbor(cborValue);
|
|
7001
6949
|
}
|
|
7002
6950
|
/**
|
|
7003
6951
|
* Returns the UR representation.
|
|
@@ -7018,8 +6966,7 @@ init_error();
|
|
|
7018
6966
|
*/
|
|
7019
6967
|
static fromUR(ur) {
|
|
7020
6968
|
if (ur.urTypeStr() !== _bcts_tags.MLDSA_PRIVATE_KEY.name) throw new Error(`Expected UR type ${_bcts_tags.MLDSA_PRIVATE_KEY.name}, got ${ur.urTypeStr()}`);
|
|
7021
|
-
|
|
7022
|
-
return new MLDSAPrivateKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(ur.cbor());
|
|
6969
|
+
return new MLDSAPrivateKey(2, new Uint8Array(mldsaPrivateKeySize(2))).fromUntaggedCbor(ur.cbor());
|
|
7023
6970
|
}
|
|
7024
6971
|
/**
|
|
7025
6972
|
* Creates an MLDSAPrivateKey from a UR string.
|
|
@@ -7029,10 +6976,9 @@ init_error();
|
|
|
7029
6976
|
return MLDSAPrivateKey.fromUR(ur);
|
|
7030
6977
|
}
|
|
7031
6978
|
};
|
|
7032
|
-
|
|
7033
|
-
//#
|
|
7034
|
-
|
|
7035
|
-
/**
|
|
6979
|
+
//#endregion
|
|
6980
|
+
//#region src/signing/signature.ts
|
|
6981
|
+
/**
|
|
7036
6982
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
7037
6983
|
* Copyright © 2025-2026 Parity Technologies
|
|
7038
6984
|
*
|
|
@@ -7083,7 +7029,7 @@ init_error();
|
|
|
7083
7029
|
*/
|
|
7084
7030
|
static schnorrFromData(data) {
|
|
7085
7031
|
if (data.length !== _bcts_crypto.SCHNORR_SIGNATURE_SIZE) throw CryptoError.invalidSize(_bcts_crypto.SCHNORR_SIGNATURE_SIZE, data.length);
|
|
7086
|
-
return new Signature(
|
|
7032
|
+
return new Signature("Schnorr", data);
|
|
7087
7033
|
}
|
|
7088
7034
|
/**
|
|
7089
7035
|
* Creates a Schnorr signature from a hex string.
|
|
@@ -7102,7 +7048,7 @@ init_error();
|
|
|
7102
7048
|
*/
|
|
7103
7049
|
static ecdsaFromData(data) {
|
|
7104
7050
|
if (data.length !== _bcts_crypto.ECDSA_SIGNATURE_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ECDSA_SIGNATURE_SIZE, data.length);
|
|
7105
|
-
return new Signature(
|
|
7051
|
+
return new Signature("Ecdsa", data);
|
|
7106
7052
|
}
|
|
7107
7053
|
/**
|
|
7108
7054
|
* Creates an ECDSA signature from a hex string.
|
|
@@ -7121,7 +7067,7 @@ init_error();
|
|
|
7121
7067
|
*/
|
|
7122
7068
|
static ed25519FromData(data) {
|
|
7123
7069
|
if (data.length !== _bcts_crypto.ED25519_SIGNATURE_SIZE) throw CryptoError.invalidSize(_bcts_crypto.ED25519_SIGNATURE_SIZE, data.length);
|
|
7124
|
-
return new Signature(
|
|
7070
|
+
return new Signature("Ed25519", data);
|
|
7125
7071
|
}
|
|
7126
7072
|
/**
|
|
7127
7073
|
* Creates an Ed25519 signature from a hex string.
|
|
@@ -7139,8 +7085,8 @@ init_error();
|
|
|
7139
7085
|
* @returns A new Sr25519 signature
|
|
7140
7086
|
*/
|
|
7141
7087
|
static sr25519FromData(data) {
|
|
7142
|
-
if (data.length !==
|
|
7143
|
-
return new Signature(
|
|
7088
|
+
if (data.length !== 64) throw CryptoError.invalidSize(64, data.length);
|
|
7089
|
+
return new Signature("Sr25519", data);
|
|
7144
7090
|
}
|
|
7145
7091
|
/**
|
|
7146
7092
|
* Creates an Sr25519 signature from a hex string.
|
|
@@ -7160,14 +7106,14 @@ init_error();
|
|
|
7160
7106
|
static mldsaFromSignature(sig) {
|
|
7161
7107
|
let scheme;
|
|
7162
7108
|
switch (sig.level()) {
|
|
7163
|
-
case
|
|
7164
|
-
scheme =
|
|
7109
|
+
case 2:
|
|
7110
|
+
scheme = "MLDSA44";
|
|
7165
7111
|
break;
|
|
7166
|
-
case
|
|
7167
|
-
scheme =
|
|
7112
|
+
case 3:
|
|
7113
|
+
scheme = "MLDSA65";
|
|
7168
7114
|
break;
|
|
7169
|
-
case
|
|
7170
|
-
scheme =
|
|
7115
|
+
case 5:
|
|
7116
|
+
scheme = "MLDSA87";
|
|
7171
7117
|
break;
|
|
7172
7118
|
default: throw new Error(`Unknown MLDSA level: ${sig.level()}`);
|
|
7173
7119
|
}
|
|
@@ -7185,17 +7131,17 @@ init_error();
|
|
|
7185
7131
|
*/
|
|
7186
7132
|
signatureType() {
|
|
7187
7133
|
switch (this._type) {
|
|
7188
|
-
case
|
|
7189
|
-
case
|
|
7190
|
-
case
|
|
7191
|
-
case
|
|
7192
|
-
case
|
|
7193
|
-
case
|
|
7194
|
-
case
|
|
7195
|
-
case
|
|
7196
|
-
case
|
|
7197
|
-
case
|
|
7198
|
-
case
|
|
7134
|
+
case "Ed25519": return "Ed25519";
|
|
7135
|
+
case "Schnorr": return "Schnorr";
|
|
7136
|
+
case "Ecdsa": return "Ecdsa";
|
|
7137
|
+
case "Sr25519": return "Sr25519";
|
|
7138
|
+
case "MLDSA44": return "MLDSA-44";
|
|
7139
|
+
case "MLDSA65": return "MLDSA-65";
|
|
7140
|
+
case "MLDSA87": return "MLDSA-87";
|
|
7141
|
+
case "SshEd25519": return "SshEd25519";
|
|
7142
|
+
case "SshDsa": return "SshDsa";
|
|
7143
|
+
case "SshEcdsaP256": return "SshEcdsaP256";
|
|
7144
|
+
case "SshEcdsaP384": return "SshEcdsaP384";
|
|
7199
7145
|
default: return this._type;
|
|
7200
7146
|
}
|
|
7201
7147
|
}
|
|
@@ -7211,14 +7157,14 @@ init_error();
|
|
|
7211
7157
|
* @returns The 64-byte signature data if this is a Schnorr signature, null otherwise
|
|
7212
7158
|
*/
|
|
7213
7159
|
toSchnorr() {
|
|
7214
|
-
if (this._type ===
|
|
7160
|
+
if (this._type === "Schnorr") return this._data;
|
|
7215
7161
|
return null;
|
|
7216
7162
|
}
|
|
7217
7163
|
/**
|
|
7218
7164
|
* Checks if this is a Schnorr signature.
|
|
7219
7165
|
*/
|
|
7220
7166
|
isSchnorr() {
|
|
7221
|
-
return this._type ===
|
|
7167
|
+
return this._type === "Schnorr";
|
|
7222
7168
|
}
|
|
7223
7169
|
/**
|
|
7224
7170
|
* Returns the ECDSA signature data if this is an ECDSA signature.
|
|
@@ -7226,14 +7172,14 @@ init_error();
|
|
|
7226
7172
|
* @returns The 64-byte signature data if this is an ECDSA signature, null otherwise
|
|
7227
7173
|
*/
|
|
7228
7174
|
toEcdsa() {
|
|
7229
|
-
if (this._type ===
|
|
7175
|
+
if (this._type === "Ecdsa") return this._data;
|
|
7230
7176
|
return null;
|
|
7231
7177
|
}
|
|
7232
7178
|
/**
|
|
7233
7179
|
* Checks if this is an ECDSA signature.
|
|
7234
7180
|
*/
|
|
7235
7181
|
isEcdsa() {
|
|
7236
|
-
return this._type ===
|
|
7182
|
+
return this._type === "Ecdsa";
|
|
7237
7183
|
}
|
|
7238
7184
|
/**
|
|
7239
7185
|
* Returns the Ed25519 signature data if this is an Ed25519 signature.
|
|
@@ -7241,14 +7187,14 @@ init_error();
|
|
|
7241
7187
|
* @returns The 64-byte signature data if this is an Ed25519 signature, null otherwise
|
|
7242
7188
|
*/
|
|
7243
7189
|
toEd25519() {
|
|
7244
|
-
if (this._type ===
|
|
7190
|
+
if (this._type === "Ed25519") return this._data;
|
|
7245
7191
|
return null;
|
|
7246
7192
|
}
|
|
7247
7193
|
/**
|
|
7248
7194
|
* Checks if this is an Ed25519 signature.
|
|
7249
7195
|
*/
|
|
7250
7196
|
isEd25519() {
|
|
7251
|
-
return this._type ===
|
|
7197
|
+
return this._type === "Ed25519";
|
|
7252
7198
|
}
|
|
7253
7199
|
/**
|
|
7254
7200
|
* Returns the Sr25519 signature data if this is an Sr25519 signature.
|
|
@@ -7256,14 +7202,14 @@ init_error();
|
|
|
7256
7202
|
* @returns The 64-byte signature data if this is an Sr25519 signature, null otherwise
|
|
7257
7203
|
*/
|
|
7258
7204
|
toSr25519() {
|
|
7259
|
-
if (this._type ===
|
|
7205
|
+
if (this._type === "Sr25519") return this._data;
|
|
7260
7206
|
return null;
|
|
7261
7207
|
}
|
|
7262
7208
|
/**
|
|
7263
7209
|
* Checks if this is an Sr25519 signature.
|
|
7264
7210
|
*/
|
|
7265
7211
|
isSr25519() {
|
|
7266
|
-
return this._type ===
|
|
7212
|
+
return this._type === "Sr25519";
|
|
7267
7213
|
}
|
|
7268
7214
|
/**
|
|
7269
7215
|
* Returns the MLDSASignature if this is an MLDSA signature.
|
|
@@ -7318,19 +7264,19 @@ init_error();
|
|
|
7318
7264
|
*/
|
|
7319
7265
|
untaggedCbor() {
|
|
7320
7266
|
switch (this._type) {
|
|
7321
|
-
case
|
|
7322
|
-
case
|
|
7323
|
-
case
|
|
7324
|
-
case
|
|
7325
|
-
case
|
|
7326
|
-
case
|
|
7327
|
-
case
|
|
7267
|
+
case "Schnorr": return (0, _bcts_dcbor.toByteString)(this._data);
|
|
7268
|
+
case "Ecdsa": return (0, _bcts_dcbor.cbor)([1, (0, _bcts_dcbor.toByteString)(this._data)]);
|
|
7269
|
+
case "Ed25519": return (0, _bcts_dcbor.cbor)([2, (0, _bcts_dcbor.toByteString)(this._data)]);
|
|
7270
|
+
case "Sr25519": return (0, _bcts_dcbor.cbor)([3, (0, _bcts_dcbor.toByteString)(this._data)]);
|
|
7271
|
+
case "MLDSA44":
|
|
7272
|
+
case "MLDSA65":
|
|
7273
|
+
case "MLDSA87":
|
|
7328
7274
|
if (this._mldsaSignature === void 0) throw new Error("MLDSA signature is missing");
|
|
7329
7275
|
return this._mldsaSignature.taggedCbor();
|
|
7330
|
-
case
|
|
7331
|
-
case
|
|
7332
|
-
case
|
|
7333
|
-
case
|
|
7276
|
+
case "SshEd25519":
|
|
7277
|
+
case "SshDsa":
|
|
7278
|
+
case "SshEcdsaP256":
|
|
7279
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported for CBOR encoding`);
|
|
7334
7280
|
}
|
|
7335
7281
|
}
|
|
7336
7282
|
/**
|
|
@@ -7391,7 +7337,7 @@ init_error();
|
|
|
7391
7337
|
* Static method to decode from tagged CBOR.
|
|
7392
7338
|
*/
|
|
7393
7339
|
static fromTaggedCbor(cborValue) {
|
|
7394
|
-
return new Signature(
|
|
7340
|
+
return new Signature("Ed25519", new Uint8Array(_bcts_crypto.ED25519_SIGNATURE_SIZE)).fromTaggedCbor(cborValue);
|
|
7395
7341
|
}
|
|
7396
7342
|
/**
|
|
7397
7343
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -7405,7 +7351,7 @@ init_error();
|
|
|
7405
7351
|
*/
|
|
7406
7352
|
static fromUntaggedCborData(data) {
|
|
7407
7353
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
7408
|
-
return new Signature(
|
|
7354
|
+
return new Signature("Ed25519", new Uint8Array(_bcts_crypto.ED25519_SIGNATURE_SIZE)).fromUntaggedCbor(cborValue);
|
|
7409
7355
|
}
|
|
7410
7356
|
/**
|
|
7411
7357
|
* Get the UR type for signatures.
|
|
@@ -7444,10 +7390,9 @@ init_error();
|
|
|
7444
7390
|
return Signature.fromURString(urString);
|
|
7445
7391
|
}
|
|
7446
7392
|
};
|
|
7447
|
-
|
|
7448
|
-
//#
|
|
7449
|
-
|
|
7450
|
-
/**
|
|
7393
|
+
//#endregion
|
|
7394
|
+
//#region src/signing/signing-public-key.ts
|
|
7395
|
+
/**
|
|
7451
7396
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
7452
7397
|
* Copyright © 2025-2026 Parity Technologies
|
|
7453
7398
|
*
|
|
@@ -7504,7 +7449,7 @@ init_error();
|
|
|
7504
7449
|
* @returns A new signing public key containing the Schnorr key
|
|
7505
7450
|
*/
|
|
7506
7451
|
static fromSchnorr(key) {
|
|
7507
|
-
return new SigningPublicKey(
|
|
7452
|
+
return new SigningPublicKey("Schnorr", key, void 0, void 0, void 0, void 0);
|
|
7508
7453
|
}
|
|
7509
7454
|
/**
|
|
7510
7455
|
* Creates a new signing public key from an ECDSA (compressed) public key.
|
|
@@ -7513,7 +7458,7 @@ init_error();
|
|
|
7513
7458
|
* @returns A new signing public key containing the ECDSA key
|
|
7514
7459
|
*/
|
|
7515
7460
|
static fromEcdsa(key) {
|
|
7516
|
-
return new SigningPublicKey(
|
|
7461
|
+
return new SigningPublicKey("Ecdsa", void 0, key, void 0, void 0, void 0);
|
|
7517
7462
|
}
|
|
7518
7463
|
/**
|
|
7519
7464
|
* Creates a new signing public key from an Ed25519 public key.
|
|
@@ -7522,7 +7467,7 @@ init_error();
|
|
|
7522
7467
|
* @returns A new signing public key containing the Ed25519 key
|
|
7523
7468
|
*/
|
|
7524
7469
|
static fromEd25519(key) {
|
|
7525
|
-
return new SigningPublicKey(
|
|
7470
|
+
return new SigningPublicKey("Ed25519", void 0, void 0, key, void 0, void 0);
|
|
7526
7471
|
}
|
|
7527
7472
|
/**
|
|
7528
7473
|
* Creates a new signing public key from an Sr25519 public key.
|
|
@@ -7531,7 +7476,7 @@ init_error();
|
|
|
7531
7476
|
* @returns A new signing public key containing the Sr25519 key
|
|
7532
7477
|
*/
|
|
7533
7478
|
static fromSr25519(key) {
|
|
7534
|
-
return new SigningPublicKey(
|
|
7479
|
+
return new SigningPublicKey("Sr25519", void 0, void 0, void 0, key, void 0);
|
|
7535
7480
|
}
|
|
7536
7481
|
/**
|
|
7537
7482
|
* Creates a new signing public key from an MLDSAPublicKey.
|
|
@@ -7542,14 +7487,14 @@ init_error();
|
|
|
7542
7487
|
static fromMldsa(key) {
|
|
7543
7488
|
let scheme;
|
|
7544
7489
|
switch (key.level()) {
|
|
7545
|
-
case
|
|
7546
|
-
scheme =
|
|
7490
|
+
case 2:
|
|
7491
|
+
scheme = "MLDSA44";
|
|
7547
7492
|
break;
|
|
7548
|
-
case
|
|
7549
|
-
scheme =
|
|
7493
|
+
case 3:
|
|
7494
|
+
scheme = "MLDSA65";
|
|
7550
7495
|
break;
|
|
7551
|
-
case
|
|
7552
|
-
scheme =
|
|
7496
|
+
case 5:
|
|
7497
|
+
scheme = "MLDSA87";
|
|
7553
7498
|
break;
|
|
7554
7499
|
default: throw new Error(`Unknown MLDSA level: ${key.level()}`);
|
|
7555
7500
|
}
|
|
@@ -7567,17 +7512,17 @@ init_error();
|
|
|
7567
7512
|
*/
|
|
7568
7513
|
keyType() {
|
|
7569
7514
|
switch (this._type) {
|
|
7570
|
-
case
|
|
7571
|
-
case
|
|
7572
|
-
case
|
|
7573
|
-
case
|
|
7574
|
-
case
|
|
7575
|
-
case
|
|
7576
|
-
case
|
|
7577
|
-
case
|
|
7578
|
-
case
|
|
7579
|
-
case
|
|
7580
|
-
case
|
|
7515
|
+
case "Ed25519": return "Ed25519";
|
|
7516
|
+
case "Schnorr": return "Schnorr";
|
|
7517
|
+
case "Ecdsa": return "ECDSA";
|
|
7518
|
+
case "Sr25519": return "Sr25519";
|
|
7519
|
+
case "MLDSA44": return "MLDSA-44";
|
|
7520
|
+
case "MLDSA65": return "MLDSA-65";
|
|
7521
|
+
case "MLDSA87": return "MLDSA-87";
|
|
7522
|
+
case "SshEd25519": return "SSH-Ed25519";
|
|
7523
|
+
case "SshDsa": return "SSH-DSA";
|
|
7524
|
+
case "SshEcdsaP256": return "SSH-ECDSA-P256";
|
|
7525
|
+
case "SshEcdsaP384": return "SSH-ECDSA-P384";
|
|
7581
7526
|
default: return this._type;
|
|
7582
7527
|
}
|
|
7583
7528
|
}
|
|
@@ -7587,7 +7532,7 @@ init_error();
|
|
|
7587
7532
|
* @returns The SchnorrPublicKey if this is a Schnorr key, null otherwise
|
|
7588
7533
|
*/
|
|
7589
7534
|
toSchnorr() {
|
|
7590
|
-
if (this._type ===
|
|
7535
|
+
if (this._type === "Schnorr" && this._schnorrKey !== void 0) return this._schnorrKey;
|
|
7591
7536
|
return null;
|
|
7592
7537
|
}
|
|
7593
7538
|
/**
|
|
@@ -7596,7 +7541,7 @@ init_error();
|
|
|
7596
7541
|
* @returns The ECPublicKey if this is an ECDSA key, null otherwise
|
|
7597
7542
|
*/
|
|
7598
7543
|
toEcdsa() {
|
|
7599
|
-
if (this._type ===
|
|
7544
|
+
if (this._type === "Ecdsa" && this._ecdsaKey !== void 0) return this._ecdsaKey;
|
|
7600
7545
|
return null;
|
|
7601
7546
|
}
|
|
7602
7547
|
/**
|
|
@@ -7605,7 +7550,7 @@ init_error();
|
|
|
7605
7550
|
* @returns The Ed25519 public key if this is an Ed25519 key, null otherwise
|
|
7606
7551
|
*/
|
|
7607
7552
|
toEd25519() {
|
|
7608
|
-
if (this._type ===
|
|
7553
|
+
if (this._type === "Ed25519" && this._ed25519Key !== void 0) return this._ed25519Key;
|
|
7609
7554
|
return null;
|
|
7610
7555
|
}
|
|
7611
7556
|
/**
|
|
@@ -7614,32 +7559,32 @@ init_error();
|
|
|
7614
7559
|
* @returns The Sr25519 public key if this is an Sr25519 key, null otherwise
|
|
7615
7560
|
*/
|
|
7616
7561
|
toSr25519() {
|
|
7617
|
-
if (this._type ===
|
|
7562
|
+
if (this._type === "Sr25519" && this._sr25519Key !== void 0) return this._sr25519Key;
|
|
7618
7563
|
return null;
|
|
7619
7564
|
}
|
|
7620
7565
|
/**
|
|
7621
7566
|
* Checks if this is a Schnorr signing key.
|
|
7622
7567
|
*/
|
|
7623
7568
|
isSchnorr() {
|
|
7624
|
-
return this._type ===
|
|
7569
|
+
return this._type === "Schnorr";
|
|
7625
7570
|
}
|
|
7626
7571
|
/**
|
|
7627
7572
|
* Checks if this is an ECDSA signing key.
|
|
7628
7573
|
*/
|
|
7629
7574
|
isEcdsa() {
|
|
7630
|
-
return this._type ===
|
|
7575
|
+
return this._type === "Ecdsa";
|
|
7631
7576
|
}
|
|
7632
7577
|
/**
|
|
7633
7578
|
* Checks if this is an Ed25519 signing key.
|
|
7634
7579
|
*/
|
|
7635
7580
|
isEd25519() {
|
|
7636
|
-
return this._type ===
|
|
7581
|
+
return this._type === "Ed25519";
|
|
7637
7582
|
}
|
|
7638
7583
|
/**
|
|
7639
7584
|
* Checks if this is an Sr25519 signing key.
|
|
7640
7585
|
*/
|
|
7641
7586
|
isSr25519() {
|
|
7642
|
-
return this._type ===
|
|
7587
|
+
return this._type === "Sr25519";
|
|
7643
7588
|
}
|
|
7644
7589
|
/**
|
|
7645
7590
|
* Returns the underlying MLDSA public key if this is an MLDSA key.
|
|
@@ -7662,27 +7607,27 @@ init_error();
|
|
|
7662
7607
|
equals(other) {
|
|
7663
7608
|
if (this._type !== other._type) return false;
|
|
7664
7609
|
switch (this._type) {
|
|
7665
|
-
case
|
|
7610
|
+
case "Schnorr":
|
|
7666
7611
|
if (this._schnorrKey === void 0 || other._schnorrKey === void 0) return false;
|
|
7667
7612
|
return this._schnorrKey.equals(other._schnorrKey);
|
|
7668
|
-
case
|
|
7613
|
+
case "Ecdsa":
|
|
7669
7614
|
if (this._ecdsaKey === void 0 || other._ecdsaKey === void 0) return false;
|
|
7670
7615
|
return this._ecdsaKey.equals(other._ecdsaKey);
|
|
7671
|
-
case
|
|
7616
|
+
case "Ed25519":
|
|
7672
7617
|
if (this._ed25519Key === void 0 || other._ed25519Key === void 0) return false;
|
|
7673
7618
|
return this._ed25519Key.equals(other._ed25519Key);
|
|
7674
|
-
case
|
|
7619
|
+
case "Sr25519":
|
|
7675
7620
|
if (this._sr25519Key === void 0 || other._sr25519Key === void 0) return false;
|
|
7676
7621
|
return this._sr25519Key.equals(other._sr25519Key);
|
|
7677
|
-
case
|
|
7678
|
-
case
|
|
7679
|
-
case
|
|
7622
|
+
case "MLDSA44":
|
|
7623
|
+
case "MLDSA65":
|
|
7624
|
+
case "MLDSA87":
|
|
7680
7625
|
if (this._mldsaKey === void 0 || other._mldsaKey === void 0) return false;
|
|
7681
7626
|
return this._mldsaKey.equals(other._mldsaKey);
|
|
7682
|
-
case
|
|
7683
|
-
case
|
|
7684
|
-
case
|
|
7685
|
-
case
|
|
7627
|
+
case "SshEd25519":
|
|
7628
|
+
case "SshDsa":
|
|
7629
|
+
case "SshEcdsaP256":
|
|
7630
|
+
case "SshEcdsaP384": return false;
|
|
7686
7631
|
}
|
|
7687
7632
|
}
|
|
7688
7633
|
/**
|
|
@@ -7690,17 +7635,17 @@ init_error();
|
|
|
7690
7635
|
*/
|
|
7691
7636
|
toString() {
|
|
7692
7637
|
switch (this._type) {
|
|
7693
|
-
case
|
|
7694
|
-
case
|
|
7695
|
-
case
|
|
7696
|
-
case
|
|
7697
|
-
case
|
|
7698
|
-
case
|
|
7699
|
-
case
|
|
7700
|
-
case
|
|
7701
|
-
case
|
|
7702
|
-
case
|
|
7703
|
-
case
|
|
7638
|
+
case "Schnorr": return `SigningPublicKey(${this._type}, ${this._schnorrKey?.toHex().substring(0, 16)}...)`;
|
|
7639
|
+
case "Ecdsa": return `SigningPublicKey(${this._type}, ${this._ecdsaKey?.toHex().substring(0, 16)}...)`;
|
|
7640
|
+
case "Ed25519": return `SigningPublicKey(${this._type}, ${this._ed25519Key?.toHex().substring(0, 16)}...)`;
|
|
7641
|
+
case "Sr25519": return `SigningPublicKey(${this._type}, ${this._sr25519Key?.toHex().substring(0, 16)}...)`;
|
|
7642
|
+
case "MLDSA44":
|
|
7643
|
+
case "MLDSA65":
|
|
7644
|
+
case "MLDSA87": return `SigningPublicKey(${this._type}, ${this._mldsaKey?.toString().substring(0, 30)}...)`;
|
|
7645
|
+
case "SshEd25519":
|
|
7646
|
+
case "SshDsa":
|
|
7647
|
+
case "SshEcdsaP256":
|
|
7648
|
+
case "SshEcdsaP384": return `SigningPublicKey(${this._type}, SSH scheme not supported)`;
|
|
7704
7649
|
}
|
|
7705
7650
|
}
|
|
7706
7651
|
/**
|
|
@@ -7723,7 +7668,7 @@ init_error();
|
|
|
7723
7668
|
verify(signature, message) {
|
|
7724
7669
|
if (signature.scheme() !== this._type) return false;
|
|
7725
7670
|
switch (this._type) {
|
|
7726
|
-
case
|
|
7671
|
+
case "Schnorr": {
|
|
7727
7672
|
if (this._schnorrKey === void 0) return false;
|
|
7728
7673
|
const sigData = signature.toSchnorr();
|
|
7729
7674
|
if (sigData === null) return false;
|
|
@@ -7733,7 +7678,7 @@ init_error();
|
|
|
7733
7678
|
return false;
|
|
7734
7679
|
}
|
|
7735
7680
|
}
|
|
7736
|
-
case
|
|
7681
|
+
case "Ecdsa": {
|
|
7737
7682
|
if (this._ecdsaKey === void 0) return false;
|
|
7738
7683
|
const sigData = signature.toEcdsa();
|
|
7739
7684
|
if (sigData === null) return false;
|
|
@@ -7743,7 +7688,7 @@ init_error();
|
|
|
7743
7688
|
return false;
|
|
7744
7689
|
}
|
|
7745
7690
|
}
|
|
7746
|
-
case
|
|
7691
|
+
case "Ed25519": {
|
|
7747
7692
|
if (this._ed25519Key === void 0) return false;
|
|
7748
7693
|
const sigData = signature.toEd25519();
|
|
7749
7694
|
if (sigData === null) return false;
|
|
@@ -7753,7 +7698,7 @@ init_error();
|
|
|
7753
7698
|
return false;
|
|
7754
7699
|
}
|
|
7755
7700
|
}
|
|
7756
|
-
case
|
|
7701
|
+
case "Sr25519": {
|
|
7757
7702
|
if (this._sr25519Key === void 0) return false;
|
|
7758
7703
|
const sigData = signature.toSr25519();
|
|
7759
7704
|
if (sigData === null) return false;
|
|
@@ -7763,9 +7708,9 @@ init_error();
|
|
|
7763
7708
|
return false;
|
|
7764
7709
|
}
|
|
7765
7710
|
}
|
|
7766
|
-
case
|
|
7767
|
-
case
|
|
7768
|
-
case
|
|
7711
|
+
case "MLDSA44":
|
|
7712
|
+
case "MLDSA65":
|
|
7713
|
+
case "MLDSA87": {
|
|
7769
7714
|
if (this._mldsaKey === void 0) return false;
|
|
7770
7715
|
const mldsaSig = signature.toMldsa();
|
|
7771
7716
|
if (mldsaSig === null) return false;
|
|
@@ -7775,10 +7720,10 @@ init_error();
|
|
|
7775
7720
|
return false;
|
|
7776
7721
|
}
|
|
7777
7722
|
}
|
|
7778
|
-
case
|
|
7779
|
-
case
|
|
7780
|
-
case
|
|
7781
|
-
case
|
|
7723
|
+
case "SshEd25519":
|
|
7724
|
+
case "SshDsa":
|
|
7725
|
+
case "SshEcdsaP256":
|
|
7726
|
+
case "SshEcdsaP384": return false;
|
|
7782
7727
|
}
|
|
7783
7728
|
}
|
|
7784
7729
|
/**
|
|
@@ -7798,27 +7743,27 @@ init_error();
|
|
|
7798
7743
|
*/
|
|
7799
7744
|
untaggedCbor() {
|
|
7800
7745
|
switch (this._type) {
|
|
7801
|
-
case
|
|
7746
|
+
case "Schnorr":
|
|
7802
7747
|
if (this._schnorrKey === void 0) throw new Error("Schnorr public key is missing");
|
|
7803
7748
|
return (0, _bcts_dcbor.toByteString)(this._schnorrKey.toData());
|
|
7804
|
-
case
|
|
7749
|
+
case "Ecdsa":
|
|
7805
7750
|
if (this._ecdsaKey === void 0) throw new Error("ECDSA public key is missing");
|
|
7806
7751
|
return (0, _bcts_dcbor.cbor)([1, (0, _bcts_dcbor.toByteString)(this._ecdsaKey.toData())]);
|
|
7807
|
-
case
|
|
7752
|
+
case "Ed25519":
|
|
7808
7753
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 public key is missing");
|
|
7809
7754
|
return (0, _bcts_dcbor.cbor)([2, (0, _bcts_dcbor.toByteString)(this._ed25519Key.toData())]);
|
|
7810
|
-
case
|
|
7755
|
+
case "Sr25519":
|
|
7811
7756
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 public key is missing");
|
|
7812
7757
|
return (0, _bcts_dcbor.cbor)([3, (0, _bcts_dcbor.toByteString)(this._sr25519Key.toData())]);
|
|
7813
|
-
case
|
|
7814
|
-
case
|
|
7815
|
-
case
|
|
7758
|
+
case "MLDSA44":
|
|
7759
|
+
case "MLDSA65":
|
|
7760
|
+
case "MLDSA87":
|
|
7816
7761
|
if (this._mldsaKey === void 0) throw new Error("MLDSA public key is missing");
|
|
7817
7762
|
return this._mldsaKey.taggedCbor();
|
|
7818
|
-
case
|
|
7819
|
-
case
|
|
7820
|
-
case
|
|
7821
|
-
case
|
|
7763
|
+
case "SshEd25519":
|
|
7764
|
+
case "SshDsa":
|
|
7765
|
+
case "SshEcdsaP256":
|
|
7766
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported for CBOR encoding`);
|
|
7822
7767
|
}
|
|
7823
7768
|
}
|
|
7824
7769
|
/**
|
|
@@ -7879,7 +7824,7 @@ init_error();
|
|
|
7879
7824
|
* Static method to decode from tagged CBOR.
|
|
7880
7825
|
*/
|
|
7881
7826
|
static fromTaggedCbor(cborValue) {
|
|
7882
|
-
return new SigningPublicKey(
|
|
7827
|
+
return new SigningPublicKey("Ed25519", void 0, void 0, Ed25519PublicKey.from(new Uint8Array(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE))).fromTaggedCbor(cborValue);
|
|
7883
7828
|
}
|
|
7884
7829
|
/**
|
|
7885
7830
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -7893,7 +7838,7 @@ init_error();
|
|
|
7893
7838
|
*/
|
|
7894
7839
|
static fromUntaggedCborData(data) {
|
|
7895
7840
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
7896
|
-
return new SigningPublicKey(
|
|
7841
|
+
return new SigningPublicKey("Ed25519", void 0, void 0, Ed25519PublicKey.from(new Uint8Array(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE))).fromUntaggedCbor(cborValue);
|
|
7897
7842
|
}
|
|
7898
7843
|
/**
|
|
7899
7844
|
* Get the UR type for signing public keys.
|
|
@@ -7936,7 +7881,7 @@ init_error();
|
|
|
7936
7881
|
* Currently only supports Ed25519 keys.
|
|
7937
7882
|
*/
|
|
7938
7883
|
toSsh(comment) {
|
|
7939
|
-
if (this._type !==
|
|
7884
|
+
if (this._type !== "Ed25519") throw new Error(`SSH export only supports Ed25519 keys, got ${this._type}`);
|
|
7940
7885
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 key not initialized");
|
|
7941
7886
|
const algorithm = "ssh-ed25519";
|
|
7942
7887
|
const algorithmBytes = new TextEncoder().encode(algorithm);
|
|
@@ -7972,10 +7917,9 @@ init_error();
|
|
|
7972
7917
|
return comment !== void 0 && comment !== "" ? `${result} ${comment}` : result;
|
|
7973
7918
|
}
|
|
7974
7919
|
};
|
|
7975
|
-
|
|
7976
|
-
//#
|
|
7977
|
-
|
|
7978
|
-
/**
|
|
7920
|
+
//#endregion
|
|
7921
|
+
//#region src/signing/signing-private-key.ts
|
|
7922
|
+
/**
|
|
7979
7923
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
7980
7924
|
* Copyright © 2025-2026 Parity Technologies
|
|
7981
7925
|
*
|
|
@@ -8030,7 +7974,7 @@ init_error();
|
|
|
8030
7974
|
* @returns A new Schnorr signing private key
|
|
8031
7975
|
*/
|
|
8032
7976
|
static newSchnorr(key) {
|
|
8033
|
-
return new SigningPrivateKey(
|
|
7977
|
+
return new SigningPrivateKey("Schnorr", key, void 0, void 0, void 0);
|
|
8034
7978
|
}
|
|
8035
7979
|
/**
|
|
8036
7980
|
* Creates a new ECDSA signing private key from an ECPrivateKey.
|
|
@@ -8039,7 +7983,7 @@ init_error();
|
|
|
8039
7983
|
* @returns A new ECDSA signing private key
|
|
8040
7984
|
*/
|
|
8041
7985
|
static newEcdsa(key) {
|
|
8042
|
-
return new SigningPrivateKey(
|
|
7986
|
+
return new SigningPrivateKey("Ecdsa", key, void 0, void 0, void 0);
|
|
8043
7987
|
}
|
|
8044
7988
|
/**
|
|
8045
7989
|
* Creates a new Ed25519 signing private key from an Ed25519PrivateKey.
|
|
@@ -8048,7 +7992,7 @@ init_error();
|
|
|
8048
7992
|
* @returns A new Ed25519 signing private key
|
|
8049
7993
|
*/
|
|
8050
7994
|
static newEd25519(key) {
|
|
8051
|
-
return new SigningPrivateKey(
|
|
7995
|
+
return new SigningPrivateKey("Ed25519", void 0, key, void 0, void 0);
|
|
8052
7996
|
}
|
|
8053
7997
|
/**
|
|
8054
7998
|
* Creates a new SR25519 signing private key from an Sr25519PrivateKey.
|
|
@@ -8057,7 +8001,7 @@ init_error();
|
|
|
8057
8001
|
* @returns A new SR25519 signing private key
|
|
8058
8002
|
*/
|
|
8059
8003
|
static newSr25519(key) {
|
|
8060
|
-
return new SigningPrivateKey(
|
|
8004
|
+
return new SigningPrivateKey("Sr25519", void 0, void 0, key, void 0);
|
|
8061
8005
|
}
|
|
8062
8006
|
/**
|
|
8063
8007
|
* Creates a new MLDSA signing private key from an MLDSAPrivateKey.
|
|
@@ -8068,14 +8012,14 @@ init_error();
|
|
|
8068
8012
|
static newMldsa(key) {
|
|
8069
8013
|
let scheme;
|
|
8070
8014
|
switch (key.level()) {
|
|
8071
|
-
case
|
|
8072
|
-
scheme =
|
|
8015
|
+
case 2:
|
|
8016
|
+
scheme = "MLDSA44";
|
|
8073
8017
|
break;
|
|
8074
|
-
case
|
|
8075
|
-
scheme =
|
|
8018
|
+
case 3:
|
|
8019
|
+
scheme = "MLDSA65";
|
|
8076
8020
|
break;
|
|
8077
|
-
case
|
|
8078
|
-
scheme =
|
|
8021
|
+
case 5:
|
|
8022
|
+
scheme = "MLDSA87";
|
|
8079
8023
|
break;
|
|
8080
8024
|
default: throw new Error(`Unknown MLDSA level: ${key.level()}`);
|
|
8081
8025
|
}
|
|
@@ -8125,17 +8069,17 @@ init_error();
|
|
|
8125
8069
|
*/
|
|
8126
8070
|
keyType() {
|
|
8127
8071
|
switch (this._type) {
|
|
8128
|
-
case
|
|
8129
|
-
case
|
|
8130
|
-
case
|
|
8131
|
-
case
|
|
8132
|
-
case
|
|
8133
|
-
case
|
|
8134
|
-
case
|
|
8135
|
-
case
|
|
8136
|
-
case
|
|
8137
|
-
case
|
|
8138
|
-
case
|
|
8072
|
+
case "Ed25519": return "Ed25519";
|
|
8073
|
+
case "Schnorr": return "Schnorr";
|
|
8074
|
+
case "Ecdsa": return "ECDSA";
|
|
8075
|
+
case "Sr25519": return "Sr25519";
|
|
8076
|
+
case "MLDSA44": return "MLDSA-44";
|
|
8077
|
+
case "MLDSA65": return "MLDSA-65";
|
|
8078
|
+
case "MLDSA87": return "MLDSA-87";
|
|
8079
|
+
case "SshEd25519": return "SSH-Ed25519";
|
|
8080
|
+
case "SshDsa": return "SSH-DSA";
|
|
8081
|
+
case "SshEcdsaP256": return "SSH-ECDSA-P256";
|
|
8082
|
+
case "SshEcdsaP384": return "SSH-ECDSA-P384";
|
|
8139
8083
|
default: return this._type;
|
|
8140
8084
|
}
|
|
8141
8085
|
}
|
|
@@ -8145,7 +8089,7 @@ init_error();
|
|
|
8145
8089
|
* @returns The EC private key if this is a Schnorr or ECDSA key, null otherwise
|
|
8146
8090
|
*/
|
|
8147
8091
|
toEc() {
|
|
8148
|
-
if ((this._type ===
|
|
8092
|
+
if ((this._type === "Schnorr" || this._type === "Ecdsa") && this._ecKey !== void 0) return this._ecKey;
|
|
8149
8093
|
return null;
|
|
8150
8094
|
}
|
|
8151
8095
|
/**
|
|
@@ -8154,7 +8098,7 @@ init_error();
|
|
|
8154
8098
|
* @returns The EC private key if this is a Schnorr key, null otherwise
|
|
8155
8099
|
*/
|
|
8156
8100
|
toSchnorr() {
|
|
8157
|
-
if (this._type ===
|
|
8101
|
+
if (this._type === "Schnorr" && this._ecKey !== void 0) return this._ecKey;
|
|
8158
8102
|
return null;
|
|
8159
8103
|
}
|
|
8160
8104
|
/**
|
|
@@ -8163,7 +8107,7 @@ init_error();
|
|
|
8163
8107
|
* @returns The EC private key if this is an ECDSA key, null otherwise
|
|
8164
8108
|
*/
|
|
8165
8109
|
toEcdsa() {
|
|
8166
|
-
if (this._type ===
|
|
8110
|
+
if (this._type === "Ecdsa" && this._ecKey !== void 0) return this._ecKey;
|
|
8167
8111
|
return null;
|
|
8168
8112
|
}
|
|
8169
8113
|
/**
|
|
@@ -8172,7 +8116,7 @@ init_error();
|
|
|
8172
8116
|
* @returns The Ed25519 private key if this is an Ed25519 key, null otherwise
|
|
8173
8117
|
*/
|
|
8174
8118
|
toEd25519() {
|
|
8175
|
-
if (this._type ===
|
|
8119
|
+
if (this._type === "Ed25519" && this._ed25519Key !== void 0) return this._ed25519Key;
|
|
8176
8120
|
return null;
|
|
8177
8121
|
}
|
|
8178
8122
|
/**
|
|
@@ -8181,7 +8125,7 @@ init_error();
|
|
|
8181
8125
|
* @returns The Sr25519 private key if this is an Sr25519 key, null otherwise
|
|
8182
8126
|
*/
|
|
8183
8127
|
toSr25519() {
|
|
8184
|
-
if (this._type ===
|
|
8128
|
+
if (this._type === "Sr25519" && this._sr25519Key !== void 0) return this._sr25519Key;
|
|
8185
8129
|
return null;
|
|
8186
8130
|
}
|
|
8187
8131
|
/**
|
|
@@ -8197,25 +8141,25 @@ init_error();
|
|
|
8197
8141
|
* Checks if this is a Schnorr signing key.
|
|
8198
8142
|
*/
|
|
8199
8143
|
isSchnorr() {
|
|
8200
|
-
return this._type ===
|
|
8144
|
+
return this._type === "Schnorr";
|
|
8201
8145
|
}
|
|
8202
8146
|
/**
|
|
8203
8147
|
* Checks if this is an ECDSA signing key.
|
|
8204
8148
|
*/
|
|
8205
8149
|
isEcdsa() {
|
|
8206
|
-
return this._type ===
|
|
8150
|
+
return this._type === "Ecdsa";
|
|
8207
8151
|
}
|
|
8208
8152
|
/**
|
|
8209
8153
|
* Checks if this is an Ed25519 signing key.
|
|
8210
8154
|
*/
|
|
8211
8155
|
isEd25519() {
|
|
8212
|
-
return this._type ===
|
|
8156
|
+
return this._type === "Ed25519";
|
|
8213
8157
|
}
|
|
8214
8158
|
/**
|
|
8215
8159
|
* Checks if this is an Sr25519 signing key.
|
|
8216
8160
|
*/
|
|
8217
8161
|
isSr25519() {
|
|
8218
|
-
return this._type ===
|
|
8162
|
+
return this._type === "Sr25519";
|
|
8219
8163
|
}
|
|
8220
8164
|
/**
|
|
8221
8165
|
* Checks if this is an MLDSA signing key.
|
|
@@ -8230,27 +8174,27 @@ init_error();
|
|
|
8230
8174
|
*/
|
|
8231
8175
|
publicKey() {
|
|
8232
8176
|
switch (this._type) {
|
|
8233
|
-
case
|
|
8177
|
+
case "Schnorr":
|
|
8234
8178
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
8235
8179
|
return SigningPublicKey.fromSchnorr(this._ecKey.schnorrPublicKey());
|
|
8236
|
-
case
|
|
8180
|
+
case "Ecdsa":
|
|
8237
8181
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
8238
8182
|
return SigningPublicKey.fromEcdsa(this._ecKey.publicKey());
|
|
8239
|
-
case
|
|
8183
|
+
case "Ed25519":
|
|
8240
8184
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 private key is missing");
|
|
8241
8185
|
return SigningPublicKey.fromEd25519(this._ed25519Key.publicKey());
|
|
8242
|
-
case
|
|
8186
|
+
case "Sr25519":
|
|
8243
8187
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 private key is missing");
|
|
8244
8188
|
return SigningPublicKey.fromSr25519(this._sr25519Key.publicKey());
|
|
8245
|
-
case
|
|
8246
|
-
case
|
|
8247
|
-
case
|
|
8189
|
+
case "MLDSA44":
|
|
8190
|
+
case "MLDSA65":
|
|
8191
|
+
case "MLDSA87":
|
|
8248
8192
|
if (this._mldsaKey === void 0) throw new Error("MLDSA private key is missing");
|
|
8249
8193
|
return SigningPublicKey.fromMldsa(this._mldsaKey.publicKey());
|
|
8250
|
-
case
|
|
8251
|
-
case
|
|
8252
|
-
case
|
|
8253
|
-
case
|
|
8194
|
+
case "SshEd25519":
|
|
8195
|
+
case "SshDsa":
|
|
8196
|
+
case "SshEcdsaP256":
|
|
8197
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported`);
|
|
8254
8198
|
}
|
|
8255
8199
|
}
|
|
8256
8200
|
/**
|
|
@@ -8259,25 +8203,25 @@ init_error();
|
|
|
8259
8203
|
equals(other) {
|
|
8260
8204
|
if (this._type !== other._type) return false;
|
|
8261
8205
|
switch (this._type) {
|
|
8262
|
-
case
|
|
8263
|
-
case
|
|
8206
|
+
case "Schnorr":
|
|
8207
|
+
case "Ecdsa":
|
|
8264
8208
|
if (this._ecKey === void 0 || other._ecKey === void 0) return false;
|
|
8265
8209
|
return this._ecKey.equals(other._ecKey);
|
|
8266
|
-
case
|
|
8210
|
+
case "Ed25519":
|
|
8267
8211
|
if (this._ed25519Key === void 0 || other._ed25519Key === void 0) return false;
|
|
8268
8212
|
return this._ed25519Key.equals(other._ed25519Key);
|
|
8269
|
-
case
|
|
8213
|
+
case "Sr25519":
|
|
8270
8214
|
if (this._sr25519Key === void 0 || other._sr25519Key === void 0) return false;
|
|
8271
8215
|
return this._sr25519Key.equals(other._sr25519Key);
|
|
8272
|
-
case
|
|
8273
|
-
case
|
|
8274
|
-
case
|
|
8216
|
+
case "MLDSA44":
|
|
8217
|
+
case "MLDSA65":
|
|
8218
|
+
case "MLDSA87":
|
|
8275
8219
|
if (this._mldsaKey === void 0 || other._mldsaKey === void 0) return false;
|
|
8276
8220
|
return this._mldsaKey.equals(other._mldsaKey);
|
|
8277
|
-
case
|
|
8278
|
-
case
|
|
8279
|
-
case
|
|
8280
|
-
case
|
|
8221
|
+
case "SshEd25519":
|
|
8222
|
+
case "SshDsa":
|
|
8223
|
+
case "SshEcdsaP256":
|
|
8224
|
+
case "SshEcdsaP384": return false;
|
|
8281
8225
|
}
|
|
8282
8226
|
}
|
|
8283
8227
|
/**
|
|
@@ -8310,41 +8254,41 @@ init_error();
|
|
|
8310
8254
|
*/
|
|
8311
8255
|
signWithOptions(message, options) {
|
|
8312
8256
|
switch (this._type) {
|
|
8313
|
-
case
|
|
8257
|
+
case "Schnorr": {
|
|
8314
8258
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
8315
8259
|
if (options?.type === "Schnorr") {
|
|
8316
|
-
const sigData
|
|
8317
|
-
return Signature.schnorrFromData(sigData
|
|
8260
|
+
const sigData = this._ecKey.schnorrSignUsing(message, options.rng);
|
|
8261
|
+
return Signature.schnorrFromData(sigData);
|
|
8318
8262
|
}
|
|
8319
8263
|
const sigData = this._ecKey.schnorrSign(message);
|
|
8320
8264
|
return Signature.schnorrFromData(sigData);
|
|
8321
8265
|
}
|
|
8322
|
-
case
|
|
8266
|
+
case "Ecdsa": {
|
|
8323
8267
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
8324
8268
|
const sigData = this._ecKey.ecdsaSign(message);
|
|
8325
8269
|
return Signature.ecdsaFromData(sigData);
|
|
8326
8270
|
}
|
|
8327
|
-
case
|
|
8271
|
+
case "Ed25519": {
|
|
8328
8272
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 private key is missing");
|
|
8329
8273
|
const sigData = this._ed25519Key.sign(message);
|
|
8330
8274
|
return Signature.ed25519FromData(sigData);
|
|
8331
8275
|
}
|
|
8332
|
-
case
|
|
8276
|
+
case "Sr25519": {
|
|
8333
8277
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 private key is missing");
|
|
8334
8278
|
const sigData = this._sr25519Key.sign(message);
|
|
8335
8279
|
return Signature.sr25519FromData(sigData);
|
|
8336
8280
|
}
|
|
8337
|
-
case
|
|
8338
|
-
case
|
|
8339
|
-
case
|
|
8281
|
+
case "MLDSA44":
|
|
8282
|
+
case "MLDSA65":
|
|
8283
|
+
case "MLDSA87": {
|
|
8340
8284
|
if (this._mldsaKey === void 0) throw new Error("MLDSA private key is missing");
|
|
8341
8285
|
const mldsaSig = this._mldsaKey.sign(message);
|
|
8342
8286
|
return Signature.mldsaFromSignature(mldsaSig);
|
|
8343
8287
|
}
|
|
8344
|
-
case
|
|
8345
|
-
case
|
|
8346
|
-
case
|
|
8347
|
-
case
|
|
8288
|
+
case "SshEd25519":
|
|
8289
|
+
case "SshDsa":
|
|
8290
|
+
case "SshEcdsaP256":
|
|
8291
|
+
case "SshEcdsaP384":
|
|
8348
8292
|
if (options?.type === "Ssh") throw new Error(`SSH signature scheme ${this._type} is not yet implemented. Namespace: ${options.namespace}, hashAlg: ${options.hashAlg}`);
|
|
8349
8293
|
throw new Error(`SSH signature scheme ${this._type} requires SigningOptions.Ssh`);
|
|
8350
8294
|
}
|
|
@@ -8464,27 +8408,27 @@ init_error();
|
|
|
8464
8408
|
*/
|
|
8465
8409
|
untaggedCbor() {
|
|
8466
8410
|
switch (this._type) {
|
|
8467
|
-
case
|
|
8411
|
+
case "Schnorr":
|
|
8468
8412
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
8469
8413
|
return (0, _bcts_dcbor.toByteString)(this._ecKey.toData());
|
|
8470
|
-
case
|
|
8414
|
+
case "Ecdsa":
|
|
8471
8415
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
8472
8416
|
return (0, _bcts_dcbor.cbor)([1, (0, _bcts_dcbor.toByteString)(this._ecKey.toData())]);
|
|
8473
|
-
case
|
|
8417
|
+
case "Ed25519":
|
|
8474
8418
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 private key is missing");
|
|
8475
8419
|
return (0, _bcts_dcbor.cbor)([2, (0, _bcts_dcbor.toByteString)(this._ed25519Key.toData())]);
|
|
8476
|
-
case
|
|
8420
|
+
case "Sr25519":
|
|
8477
8421
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 private key is missing");
|
|
8478
8422
|
return (0, _bcts_dcbor.cbor)([3, (0, _bcts_dcbor.toByteString)(this._sr25519Key.toData())]);
|
|
8479
|
-
case
|
|
8480
|
-
case
|
|
8481
|
-
case
|
|
8423
|
+
case "MLDSA44":
|
|
8424
|
+
case "MLDSA65":
|
|
8425
|
+
case "MLDSA87":
|
|
8482
8426
|
if (this._mldsaKey === void 0) throw new Error("MLDSA private key is missing");
|
|
8483
8427
|
return this._mldsaKey.taggedCbor();
|
|
8484
|
-
case
|
|
8485
|
-
case
|
|
8486
|
-
case
|
|
8487
|
-
case
|
|
8428
|
+
case "SshEd25519":
|
|
8429
|
+
case "SshDsa":
|
|
8430
|
+
case "SshEcdsaP256":
|
|
8431
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported for CBOR encoding`);
|
|
8488
8432
|
}
|
|
8489
8433
|
}
|
|
8490
8434
|
/**
|
|
@@ -8546,7 +8490,7 @@ init_error();
|
|
|
8546
8490
|
* Static method to decode from tagged CBOR.
|
|
8547
8491
|
*/
|
|
8548
8492
|
static fromTaggedCbor(cborValue) {
|
|
8549
|
-
return new SigningPrivateKey(
|
|
8493
|
+
return new SigningPrivateKey("Ed25519", void 0, Ed25519PrivateKey.from(new Uint8Array(_bcts_crypto.ED25519_PRIVATE_KEY_SIZE))).fromTaggedCbor(cborValue);
|
|
8550
8494
|
}
|
|
8551
8495
|
/**
|
|
8552
8496
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -8560,7 +8504,7 @@ init_error();
|
|
|
8560
8504
|
*/
|
|
8561
8505
|
static fromUntaggedCborData(data) {
|
|
8562
8506
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
8563
|
-
return new SigningPrivateKey(
|
|
8507
|
+
return new SigningPrivateKey("Ed25519", void 0, Ed25519PrivateKey.from(new Uint8Array(_bcts_crypto.ED25519_PRIVATE_KEY_SIZE))).fromUntaggedCbor(cborValue);
|
|
8564
8508
|
}
|
|
8565
8509
|
/**
|
|
8566
8510
|
* Get the UR type for signing private keys.
|
|
@@ -8603,7 +8547,7 @@ init_error();
|
|
|
8603
8547
|
* Currently only supports Ed25519 keys.
|
|
8604
8548
|
*/
|
|
8605
8549
|
toSsh(comment) {
|
|
8606
|
-
if (this._type !==
|
|
8550
|
+
if (this._type !== "Ed25519") throw new Error(`SSH export only supports Ed25519 keys, got ${this._type}`);
|
|
8607
8551
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 key not initialized");
|
|
8608
8552
|
const publicKey = this._ed25519Key.publicKey();
|
|
8609
8553
|
const privateKeyBytes = this._ed25519Key.toData();
|
|
@@ -8624,9 +8568,8 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8624
8568
|
-----END OPENSSH PRIVATE KEY-----`;
|
|
8625
8569
|
}
|
|
8626
8570
|
};
|
|
8627
|
-
|
|
8628
|
-
//#
|
|
8629
|
-
//#region src/signing/signature-scheme.ts
|
|
8571
|
+
//#endregion
|
|
8572
|
+
//#region src/signing/signature-scheme.ts
|
|
8630
8573
|
init_error();
|
|
8631
8574
|
/**
|
|
8632
8575
|
* Supported digital signature schemes.
|
|
@@ -8644,65 +8587,65 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8644
8587
|
* - SshEcdsaP256: ECDSA P-256 via SSH agent
|
|
8645
8588
|
* - SshEcdsaP384: ECDSA P-384 via SSH agent
|
|
8646
8589
|
*/
|
|
8647
|
-
let SignatureScheme = /* @__PURE__ */ function(SignatureScheme
|
|
8590
|
+
let SignatureScheme = /* @__PURE__ */ function(SignatureScheme) {
|
|
8648
8591
|
/**
|
|
8649
8592
|
* BIP-340 Schnorr signature scheme (secp256k1)
|
|
8650
8593
|
* Default scheme (matching Rust bc-components default when secp256k1 is enabled)
|
|
8651
8594
|
*/
|
|
8652
|
-
SignatureScheme
|
|
8595
|
+
SignatureScheme["Schnorr"] = "Schnorr";
|
|
8653
8596
|
/**
|
|
8654
8597
|
* ECDSA signature scheme (secp256k1)
|
|
8655
8598
|
*/
|
|
8656
|
-
SignatureScheme
|
|
8599
|
+
SignatureScheme["Ecdsa"] = "Ecdsa";
|
|
8657
8600
|
/**
|
|
8658
8601
|
* Ed25519 signature scheme (RFC 8032)
|
|
8659
8602
|
*/
|
|
8660
|
-
SignatureScheme
|
|
8603
|
+
SignatureScheme["Ed25519"] = "Ed25519";
|
|
8661
8604
|
/**
|
|
8662
8605
|
* SR25519 signature scheme (Schnorr over Ristretto25519)
|
|
8663
8606
|
* Used by Polkadot/Substrate
|
|
8664
8607
|
*/
|
|
8665
|
-
SignatureScheme
|
|
8608
|
+
SignatureScheme["Sr25519"] = "Sr25519";
|
|
8666
8609
|
/**
|
|
8667
8610
|
* ML-DSA44 post-quantum signature scheme (NIST level 2)
|
|
8668
8611
|
*/
|
|
8669
|
-
SignatureScheme
|
|
8612
|
+
SignatureScheme["MLDSA44"] = "MLDSA44";
|
|
8670
8613
|
/**
|
|
8671
8614
|
* ML-DSA65 post-quantum signature scheme (NIST level 3)
|
|
8672
8615
|
*/
|
|
8673
|
-
SignatureScheme
|
|
8616
|
+
SignatureScheme["MLDSA65"] = "MLDSA65";
|
|
8674
8617
|
/**
|
|
8675
8618
|
* ML-DSA87 post-quantum signature scheme (NIST level 5)
|
|
8676
8619
|
*/
|
|
8677
|
-
SignatureScheme
|
|
8620
|
+
SignatureScheme["MLDSA87"] = "MLDSA87";
|
|
8678
8621
|
/**
|
|
8679
8622
|
* Ed25519 signature via SSH agent.
|
|
8680
8623
|
* Requires SSH agent daemon support.
|
|
8681
8624
|
*/
|
|
8682
|
-
SignatureScheme
|
|
8625
|
+
SignatureScheme["SshEd25519"] = "SshEd25519";
|
|
8683
8626
|
/**
|
|
8684
8627
|
* DSA signature via SSH agent.
|
|
8685
8628
|
* Requires SSH agent daemon support.
|
|
8686
8629
|
*/
|
|
8687
|
-
SignatureScheme
|
|
8630
|
+
SignatureScheme["SshDsa"] = "SshDsa";
|
|
8688
8631
|
/**
|
|
8689
8632
|
* ECDSA P-256 signature via SSH agent.
|
|
8690
8633
|
* Requires SSH agent daemon support.
|
|
8691
8634
|
*/
|
|
8692
|
-
SignatureScheme
|
|
8635
|
+
SignatureScheme["SshEcdsaP256"] = "SshEcdsaP256";
|
|
8693
8636
|
/**
|
|
8694
8637
|
* ECDSA P-384 signature via SSH agent.
|
|
8695
8638
|
* Requires SSH agent daemon support.
|
|
8696
8639
|
*/
|
|
8697
|
-
SignatureScheme
|
|
8698
|
-
return SignatureScheme
|
|
8640
|
+
SignatureScheme["SshEcdsaP384"] = "SshEcdsaP384";
|
|
8641
|
+
return SignatureScheme;
|
|
8699
8642
|
}({});
|
|
8700
8643
|
/**
|
|
8701
8644
|
* Get the default signature scheme.
|
|
8702
8645
|
* Defaults to Schnorr (matching Rust bc-components default when secp256k1 is enabled).
|
|
8703
8646
|
*/
|
|
8704
8647
|
function defaultSignatureScheme() {
|
|
8705
|
-
return
|
|
8648
|
+
return "Schnorr";
|
|
8706
8649
|
}
|
|
8707
8650
|
/**
|
|
8708
8651
|
* Check if a signature scheme requires SSH agent support.
|
|
@@ -8711,7 +8654,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8711
8654
|
* @returns true if the scheme requires SSH agent
|
|
8712
8655
|
*/
|
|
8713
8656
|
function isSshScheme(scheme) {
|
|
8714
|
-
return scheme ===
|
|
8657
|
+
return scheme === "SshEd25519" || scheme === "SshDsa" || scheme === "SshEcdsaP256" || scheme === "SshEcdsaP384";
|
|
8715
8658
|
}
|
|
8716
8659
|
/**
|
|
8717
8660
|
* Check if a signature scheme is a post-quantum ML-DSA scheme.
|
|
@@ -8720,7 +8663,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8720
8663
|
* @returns true if the scheme is an ML-DSA scheme
|
|
8721
8664
|
*/
|
|
8722
8665
|
function isMldsaScheme(scheme) {
|
|
8723
|
-
return scheme ===
|
|
8666
|
+
return scheme === "MLDSA44" || scheme === "MLDSA65" || scheme === "MLDSA87";
|
|
8724
8667
|
}
|
|
8725
8668
|
/**
|
|
8726
8669
|
* Creates a new key pair for the signature scheme.
|
|
@@ -8731,45 +8674,45 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8731
8674
|
*/
|
|
8732
8675
|
function createKeypair(scheme) {
|
|
8733
8676
|
switch (scheme) {
|
|
8734
|
-
case
|
|
8677
|
+
case "Schnorr": {
|
|
8735
8678
|
const ecKey = ECPrivateKey.random();
|
|
8736
8679
|
const privateKey = SigningPrivateKey.newSchnorr(ecKey);
|
|
8737
8680
|
return [privateKey, privateKey.publicKey()];
|
|
8738
8681
|
}
|
|
8739
|
-
case
|
|
8682
|
+
case "Ecdsa": {
|
|
8740
8683
|
const ecKey = ECPrivateKey.random();
|
|
8741
8684
|
const privateKey = SigningPrivateKey.newEcdsa(ecKey);
|
|
8742
8685
|
return [privateKey, privateKey.publicKey()];
|
|
8743
8686
|
}
|
|
8744
|
-
case
|
|
8687
|
+
case "Ed25519": {
|
|
8745
8688
|
const ed25519Key = Ed25519PrivateKey.random();
|
|
8746
8689
|
const privateKey = SigningPrivateKey.newEd25519(ed25519Key);
|
|
8747
8690
|
return [privateKey, privateKey.publicKey()];
|
|
8748
8691
|
}
|
|
8749
|
-
case
|
|
8692
|
+
case "Sr25519": {
|
|
8750
8693
|
const sr25519Key = Sr25519PrivateKey.random();
|
|
8751
8694
|
const privateKey = SigningPrivateKey.newSr25519(sr25519Key);
|
|
8752
8695
|
return [privateKey, privateKey.publicKey()];
|
|
8753
8696
|
}
|
|
8754
|
-
case
|
|
8755
|
-
const mldsaKey = MLDSAPrivateKey.new(
|
|
8697
|
+
case "MLDSA44": {
|
|
8698
|
+
const mldsaKey = MLDSAPrivateKey.new(2);
|
|
8756
8699
|
const privateKey = SigningPrivateKey.newMldsa(mldsaKey);
|
|
8757
8700
|
return [privateKey, privateKey.publicKey()];
|
|
8758
8701
|
}
|
|
8759
|
-
case
|
|
8760
|
-
const mldsaKey = MLDSAPrivateKey.new(
|
|
8702
|
+
case "MLDSA65": {
|
|
8703
|
+
const mldsaKey = MLDSAPrivateKey.new(3);
|
|
8761
8704
|
const privateKey = SigningPrivateKey.newMldsa(mldsaKey);
|
|
8762
8705
|
return [privateKey, privateKey.publicKey()];
|
|
8763
8706
|
}
|
|
8764
|
-
case
|
|
8765
|
-
const mldsaKey = MLDSAPrivateKey.new(
|
|
8707
|
+
case "MLDSA87": {
|
|
8708
|
+
const mldsaKey = MLDSAPrivateKey.new(5);
|
|
8766
8709
|
const privateKey = SigningPrivateKey.newMldsa(mldsaKey);
|
|
8767
8710
|
return [privateKey, privateKey.publicKey()];
|
|
8768
8711
|
}
|
|
8769
|
-
case
|
|
8770
|
-
case
|
|
8771
|
-
case
|
|
8772
|
-
case
|
|
8712
|
+
case "SshEd25519":
|
|
8713
|
+
case "SshDsa":
|
|
8714
|
+
case "SshEcdsaP256":
|
|
8715
|
+
case "SshEcdsaP384": throw CryptoError.sshAgent(`SSH signature scheme ${scheme} requires SSH agent support which is not yet implemented. Use Ed25519, Sr25519, Schnorr, ECDSA, or MLDSA variants instead.`);
|
|
8773
8716
|
}
|
|
8774
8717
|
}
|
|
8775
8718
|
/**
|
|
@@ -8782,39 +8725,38 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8782
8725
|
*/
|
|
8783
8726
|
function createKeypairUsing(scheme, rng) {
|
|
8784
8727
|
switch (scheme) {
|
|
8785
|
-
case
|
|
8728
|
+
case "Schnorr": {
|
|
8786
8729
|
const ecKey = ECPrivateKey.newUsing(rng);
|
|
8787
8730
|
const privateKey = SigningPrivateKey.newSchnorr(ecKey);
|
|
8788
8731
|
return [privateKey, privateKey.publicKey()];
|
|
8789
8732
|
}
|
|
8790
|
-
case
|
|
8733
|
+
case "Ecdsa": {
|
|
8791
8734
|
const ecKey = ECPrivateKey.newUsing(rng);
|
|
8792
8735
|
const privateKey = SigningPrivateKey.newEcdsa(ecKey);
|
|
8793
8736
|
return [privateKey, privateKey.publicKey()];
|
|
8794
8737
|
}
|
|
8795
|
-
case
|
|
8738
|
+
case "Ed25519": {
|
|
8796
8739
|
const ed25519Key = Ed25519PrivateKey.randomUsing(rng);
|
|
8797
8740
|
const privateKey = SigningPrivateKey.newEd25519(ed25519Key);
|
|
8798
8741
|
return [privateKey, privateKey.publicKey()];
|
|
8799
8742
|
}
|
|
8800
|
-
case
|
|
8743
|
+
case "Sr25519": {
|
|
8801
8744
|
const sr25519Key = Sr25519PrivateKey.randomUsing(rng);
|
|
8802
8745
|
const privateKey = SigningPrivateKey.newSr25519(sr25519Key);
|
|
8803
8746
|
return [privateKey, privateKey.publicKey()];
|
|
8804
8747
|
}
|
|
8805
|
-
case
|
|
8806
|
-
case
|
|
8807
|
-
case
|
|
8808
|
-
case
|
|
8809
|
-
case
|
|
8810
|
-
case
|
|
8811
|
-
case
|
|
8748
|
+
case "MLDSA44":
|
|
8749
|
+
case "MLDSA65":
|
|
8750
|
+
case "MLDSA87": throw CryptoError.general(`Deterministic keypair generation not supported for ${scheme}. Use createKeypair() instead.`);
|
|
8751
|
+
case "SshEd25519":
|
|
8752
|
+
case "SshDsa":
|
|
8753
|
+
case "SshEcdsaP256":
|
|
8754
|
+
case "SshEcdsaP384": throw CryptoError.sshAgent(`SSH signature scheme ${scheme} requires SSH agent support which is not yet implemented. Use Ed25519, Sr25519, Schnorr, ECDSA, or MLDSA variants instead.`);
|
|
8812
8755
|
}
|
|
8813
8756
|
}
|
|
8814
|
-
|
|
8815
|
-
//#
|
|
8816
|
-
|
|
8817
|
-
/**
|
|
8757
|
+
//#endregion
|
|
8758
|
+
//#region src/mlkem/mlkem-level.ts
|
|
8759
|
+
/**
|
|
8818
8760
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
8819
8761
|
* Copyright © 2025-2026 Parity Technologies
|
|
8820
8762
|
*
|
|
@@ -8839,32 +8781,32 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8839
8781
|
* - 768: ML-KEM-768 (NIST Level 3)
|
|
8840
8782
|
* - 1024: ML-KEM-1024 (NIST Level 5)
|
|
8841
8783
|
*/
|
|
8842
|
-
let MLKEMLevel = /* @__PURE__ */ function(MLKEMLevel
|
|
8784
|
+
let MLKEMLevel = /* @__PURE__ */ function(MLKEMLevel) {
|
|
8843
8785
|
/** NIST Level 1 - AES-128 equivalent security */
|
|
8844
|
-
MLKEMLevel
|
|
8786
|
+
MLKEMLevel[MLKEMLevel["MLKEM512"] = 512] = "MLKEM512";
|
|
8845
8787
|
/** NIST Level 3 - AES-192 equivalent security */
|
|
8846
|
-
MLKEMLevel
|
|
8788
|
+
MLKEMLevel[MLKEMLevel["MLKEM768"] = 768] = "MLKEM768";
|
|
8847
8789
|
/** NIST Level 5 - AES-256 equivalent security */
|
|
8848
|
-
MLKEMLevel
|
|
8849
|
-
return MLKEMLevel
|
|
8790
|
+
MLKEMLevel[MLKEMLevel["MLKEM1024"] = 1024] = "MLKEM1024";
|
|
8791
|
+
return MLKEMLevel;
|
|
8850
8792
|
}({});
|
|
8851
8793
|
/**
|
|
8852
8794
|
* Key sizes for each ML-KEM security level.
|
|
8853
8795
|
*/
|
|
8854
8796
|
const MLKEM_KEY_SIZES = {
|
|
8855
|
-
[
|
|
8797
|
+
[512]: {
|
|
8856
8798
|
privateKey: 1632,
|
|
8857
8799
|
publicKey: 800,
|
|
8858
8800
|
ciphertext: 768,
|
|
8859
8801
|
sharedSecret: 32
|
|
8860
8802
|
},
|
|
8861
|
-
[
|
|
8803
|
+
[768]: {
|
|
8862
8804
|
privateKey: 2400,
|
|
8863
8805
|
publicKey: 1184,
|
|
8864
8806
|
ciphertext: 1088,
|
|
8865
8807
|
sharedSecret: 32
|
|
8866
8808
|
},
|
|
8867
|
-
[
|
|
8809
|
+
[1024]: {
|
|
8868
8810
|
privateKey: 3168,
|
|
8869
8811
|
publicKey: 1568,
|
|
8870
8812
|
ciphertext: 1568,
|
|
@@ -8901,9 +8843,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8901
8843
|
*/
|
|
8902
8844
|
function mlkemLevelToString(level) {
|
|
8903
8845
|
switch (level) {
|
|
8904
|
-
case
|
|
8905
|
-
case
|
|
8906
|
-
case
|
|
8846
|
+
case 512: return "MLKEM512";
|
|
8847
|
+
case 768: return "MLKEM768";
|
|
8848
|
+
case 1024: return "MLKEM1024";
|
|
8907
8849
|
}
|
|
8908
8850
|
}
|
|
8909
8851
|
/**
|
|
@@ -8911,9 +8853,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8911
8853
|
*/
|
|
8912
8854
|
function mlkemLevelFromValue(value) {
|
|
8913
8855
|
switch (value) {
|
|
8914
|
-
case 512: return
|
|
8915
|
-
case 768: return
|
|
8916
|
-
case 1024: return
|
|
8856
|
+
case 512: return 512;
|
|
8857
|
+
case 768: return 768;
|
|
8858
|
+
case 1024: return 1024;
|
|
8917
8859
|
default: throw new Error(`Invalid MLKEM level value: ${value}`);
|
|
8918
8860
|
}
|
|
8919
8861
|
}
|
|
@@ -8936,21 +8878,21 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8936
8878
|
function mlkemGenerateKeypairUsing(level, rng) {
|
|
8937
8879
|
const seed = rng.randomData(64);
|
|
8938
8880
|
switch (level) {
|
|
8939
|
-
case
|
|
8881
|
+
case 512: {
|
|
8940
8882
|
const keypair = _noble_post_quantum_ml_kem_js.ml_kem512.keygen(seed);
|
|
8941
8883
|
return {
|
|
8942
8884
|
publicKey: keypair.publicKey,
|
|
8943
8885
|
secretKey: keypair.secretKey
|
|
8944
8886
|
};
|
|
8945
8887
|
}
|
|
8946
|
-
case
|
|
8888
|
+
case 768: {
|
|
8947
8889
|
const keypair = _noble_post_quantum_ml_kem_js.ml_kem768.keygen(seed);
|
|
8948
8890
|
return {
|
|
8949
8891
|
publicKey: keypair.publicKey,
|
|
8950
8892
|
secretKey: keypair.secretKey
|
|
8951
8893
|
};
|
|
8952
8894
|
}
|
|
8953
|
-
case
|
|
8895
|
+
case 1024: {
|
|
8954
8896
|
const keypair = _noble_post_quantum_ml_kem_js.ml_kem1024.keygen(seed);
|
|
8955
8897
|
return {
|
|
8956
8898
|
publicKey: keypair.publicKey,
|
|
@@ -8968,21 +8910,21 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
8968
8910
|
*/
|
|
8969
8911
|
function mlkemEncapsulate(level, publicKey) {
|
|
8970
8912
|
switch (level) {
|
|
8971
|
-
case
|
|
8913
|
+
case 512: {
|
|
8972
8914
|
const result = _noble_post_quantum_ml_kem_js.ml_kem512.encapsulate(publicKey);
|
|
8973
8915
|
return {
|
|
8974
8916
|
sharedSecret: result.sharedSecret,
|
|
8975
8917
|
ciphertext: result.cipherText
|
|
8976
8918
|
};
|
|
8977
8919
|
}
|
|
8978
|
-
case
|
|
8920
|
+
case 768: {
|
|
8979
8921
|
const result = _noble_post_quantum_ml_kem_js.ml_kem768.encapsulate(publicKey);
|
|
8980
8922
|
return {
|
|
8981
8923
|
sharedSecret: result.sharedSecret,
|
|
8982
8924
|
ciphertext: result.cipherText
|
|
8983
8925
|
};
|
|
8984
8926
|
}
|
|
8985
|
-
case
|
|
8927
|
+
case 1024: {
|
|
8986
8928
|
const result = _noble_post_quantum_ml_kem_js.ml_kem1024.encapsulate(publicKey);
|
|
8987
8929
|
return {
|
|
8988
8930
|
sharedSecret: result.sharedSecret,
|
|
@@ -9001,9 +8943,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9001
8943
|
*/
|
|
9002
8944
|
function mlkemDecapsulate(level, secretKey, ciphertext) {
|
|
9003
8945
|
switch (level) {
|
|
9004
|
-
case
|
|
9005
|
-
case
|
|
9006
|
-
case
|
|
8946
|
+
case 512: return _noble_post_quantum_ml_kem_js.ml_kem512.decapsulate(ciphertext, secretKey);
|
|
8947
|
+
case 768: return _noble_post_quantum_ml_kem_js.ml_kem768.decapsulate(ciphertext, secretKey);
|
|
8948
|
+
case 1024: return _noble_post_quantum_ml_kem_js.ml_kem1024.decapsulate(ciphertext, secretKey);
|
|
9007
8949
|
}
|
|
9008
8950
|
}
|
|
9009
8951
|
/**
|
|
@@ -9012,9 +8954,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9012
8954
|
* where dk_pke is the private portion before the public key.
|
|
9013
8955
|
*/
|
|
9014
8956
|
const MLKEM_DK_PKE_SIZES = {
|
|
9015
|
-
[
|
|
9016
|
-
[
|
|
9017
|
-
[
|
|
8957
|
+
[512]: 768,
|
|
8958
|
+
[768]: 1152,
|
|
8959
|
+
[1024]: 1536
|
|
9018
8960
|
};
|
|
9019
8961
|
/**
|
|
9020
8962
|
* Extract the public key from a secret key.
|
|
@@ -9032,10 +8974,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9032
8974
|
const offset = dkPkeSize;
|
|
9033
8975
|
return secretKey.slice(offset, offset + publicKeySize);
|
|
9034
8976
|
}
|
|
9035
|
-
|
|
9036
|
-
//#
|
|
9037
|
-
|
|
9038
|
-
/**
|
|
8977
|
+
//#endregion
|
|
8978
|
+
//#region src/mlkem/mlkem-ciphertext.ts
|
|
8979
|
+
/**
|
|
9039
8980
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
9040
8981
|
* Copyright © 2025-2026 Parity Technologies
|
|
9041
8982
|
*
|
|
@@ -9168,8 +9109,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9168
9109
|
* Static method to decode from tagged CBOR.
|
|
9169
9110
|
*/
|
|
9170
9111
|
static fromTaggedCbor(cborValue) {
|
|
9171
|
-
|
|
9172
|
-
return new MLKEMCiphertext(MLKEMLevel.MLKEM512, dummyData).fromTaggedCbor(cborValue);
|
|
9112
|
+
return new MLKEMCiphertext(512, new Uint8Array(mlkemCiphertextSize(512))).fromTaggedCbor(cborValue);
|
|
9173
9113
|
}
|
|
9174
9114
|
/**
|
|
9175
9115
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -9183,8 +9123,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9183
9123
|
*/
|
|
9184
9124
|
static fromUntaggedCborData(data) {
|
|
9185
9125
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
9186
|
-
|
|
9187
|
-
return new MLKEMCiphertext(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(cborValue);
|
|
9126
|
+
return new MLKEMCiphertext(512, new Uint8Array(mlkemCiphertextSize(512))).fromUntaggedCbor(cborValue);
|
|
9188
9127
|
}
|
|
9189
9128
|
/**
|
|
9190
9129
|
* Returns the UR representation.
|
|
@@ -9205,8 +9144,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9205
9144
|
*/
|
|
9206
9145
|
static fromUR(ur) {
|
|
9207
9146
|
if (ur.urTypeStr() !== _bcts_tags.MLKEM_CIPHERTEXT.name) throw new Error(`Expected UR type ${_bcts_tags.MLKEM_CIPHERTEXT.name}, got ${ur.urTypeStr()}`);
|
|
9208
|
-
|
|
9209
|
-
return new MLKEMCiphertext(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(ur.cbor());
|
|
9147
|
+
return new MLKEMCiphertext(512, new Uint8Array(mlkemCiphertextSize(512))).fromUntaggedCbor(ur.cbor());
|
|
9210
9148
|
}
|
|
9211
9149
|
/**
|
|
9212
9150
|
* Creates an MLKEMCiphertext from a UR string.
|
|
@@ -9216,10 +9154,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9216
9154
|
return MLKEMCiphertext.fromUR(ur);
|
|
9217
9155
|
}
|
|
9218
9156
|
};
|
|
9219
|
-
|
|
9220
|
-
//#
|
|
9221
|
-
|
|
9222
|
-
/**
|
|
9157
|
+
//#endregion
|
|
9158
|
+
//#region src/encapsulation/encapsulation-ciphertext.ts
|
|
9159
|
+
/**
|
|
9223
9160
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
9224
9161
|
* Copyright © 2025-2026 Parity Technologies
|
|
9225
9162
|
*
|
|
@@ -9243,16 +9180,16 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9243
9180
|
*/
|
|
9244
9181
|
function mlkemLevelToScheme$2(level) {
|
|
9245
9182
|
switch (level) {
|
|
9246
|
-
case
|
|
9247
|
-
case
|
|
9248
|
-
case
|
|
9183
|
+
case 512: return "mlkem512";
|
|
9184
|
+
case 768: return "mlkem768";
|
|
9185
|
+
case 1024: return "mlkem1024";
|
|
9249
9186
|
}
|
|
9250
9187
|
}
|
|
9251
9188
|
/**
|
|
9252
9189
|
* Check if a scheme is an MLKEM scheme
|
|
9253
9190
|
*/
|
|
9254
9191
|
function isMlkemScheme$2(scheme) {
|
|
9255
|
-
return scheme ===
|
|
9192
|
+
return scheme === "mlkem512" || scheme === "mlkem768" || scheme === "mlkem1024";
|
|
9256
9193
|
}
|
|
9257
9194
|
/**
|
|
9258
9195
|
* Represents the ciphertext from a key encapsulation operation.
|
|
@@ -9273,7 +9210,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9273
9210
|
* Create an EncapsulationCiphertext from an X25519PublicKey.
|
|
9274
9211
|
*/
|
|
9275
9212
|
static fromX25519PublicKey(publicKey) {
|
|
9276
|
-
return new EncapsulationCiphertext(
|
|
9213
|
+
return new EncapsulationCiphertext("x25519", publicKey, void 0);
|
|
9277
9214
|
}
|
|
9278
9215
|
/**
|
|
9279
9216
|
* Create an EncapsulationCiphertext from raw X25519 data.
|
|
@@ -9305,7 +9242,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9305
9242
|
* Returns true if this is an X25519 ciphertext.
|
|
9306
9243
|
*/
|
|
9307
9244
|
isX25519() {
|
|
9308
|
-
return this._scheme ===
|
|
9245
|
+
return this._scheme === "x25519";
|
|
9309
9246
|
}
|
|
9310
9247
|
/**
|
|
9311
9248
|
* Returns true if this is an MLKEM ciphertext.
|
|
@@ -9345,7 +9282,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9345
9282
|
* Returns the raw ciphertext data.
|
|
9346
9283
|
*/
|
|
9347
9284
|
data() {
|
|
9348
|
-
if (this._scheme ===
|
|
9285
|
+
if (this._scheme === "x25519") {
|
|
9349
9286
|
const pk = this._x25519PublicKey;
|
|
9350
9287
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
9351
9288
|
return pk.data();
|
|
@@ -9361,7 +9298,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9361
9298
|
*/
|
|
9362
9299
|
equals(other) {
|
|
9363
9300
|
if (this._scheme !== other._scheme) return false;
|
|
9364
|
-
if (this._scheme ===
|
|
9301
|
+
if (this._scheme === "x25519") {
|
|
9365
9302
|
const thisPk = this._x25519PublicKey;
|
|
9366
9303
|
const otherPk = other._x25519PublicKey;
|
|
9367
9304
|
if (thisPk === void 0 || otherPk === void 0) return false;
|
|
@@ -9378,7 +9315,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9378
9315
|
* Get string representation.
|
|
9379
9316
|
*/
|
|
9380
9317
|
toString() {
|
|
9381
|
-
if (this._scheme ===
|
|
9318
|
+
if (this._scheme === "x25519") return `EncapsulationCiphertext(X25519, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
9382
9319
|
else if (isMlkemScheme$2(this._scheme)) return `EncapsulationCiphertext(${String(this._scheme)}, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
9383
9320
|
return `EncapsulationCiphertext(${String(this._scheme)})`;
|
|
9384
9321
|
}
|
|
@@ -9386,7 +9323,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9386
9323
|
* Returns the CBOR tags associated with this ciphertext.
|
|
9387
9324
|
*/
|
|
9388
9325
|
cborTags() {
|
|
9389
|
-
if (this._scheme ===
|
|
9326
|
+
if (this._scheme === "x25519") return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.X25519_PUBLIC_KEY.value]);
|
|
9390
9327
|
else if (isMlkemScheme$2(this._scheme)) return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.MLKEM_CIPHERTEXT.value]);
|
|
9391
9328
|
throw new Error(`Unsupported scheme: ${String(this._scheme)}`);
|
|
9392
9329
|
}
|
|
@@ -9394,7 +9331,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9394
9331
|
* Returns the untagged CBOR encoding.
|
|
9395
9332
|
*/
|
|
9396
9333
|
untaggedCbor() {
|
|
9397
|
-
if (this._scheme ===
|
|
9334
|
+
if (this._scheme === "x25519") {
|
|
9398
9335
|
const pk = this._x25519PublicKey;
|
|
9399
9336
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
9400
9337
|
return (0, _bcts_dcbor.toByteString)(pk.data());
|
|
@@ -9463,10 +9400,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9463
9400
|
return EncapsulationCiphertext.fromX25519PublicKey(X25519PublicKey.fromData(new Uint8Array(32))).fromUntaggedCbor(cborValue);
|
|
9464
9401
|
}
|
|
9465
9402
|
};
|
|
9466
|
-
|
|
9467
|
-
//#
|
|
9468
|
-
|
|
9469
|
-
/**
|
|
9403
|
+
//#endregion
|
|
9404
|
+
//#region src/mlkem/mlkem-public-key.ts
|
|
9405
|
+
/**
|
|
9470
9406
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
9471
9407
|
* Copyright © 2025-2026 Parity Technologies
|
|
9472
9408
|
*
|
|
@@ -9615,8 +9551,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9615
9551
|
* Static method to decode from tagged CBOR.
|
|
9616
9552
|
*/
|
|
9617
9553
|
static fromTaggedCbor(cborValue) {
|
|
9618
|
-
|
|
9619
|
-
return new MLKEMPublicKey(MLKEMLevel.MLKEM512, dummyData).fromTaggedCbor(cborValue);
|
|
9554
|
+
return new MLKEMPublicKey(512, new Uint8Array(mlkemPublicKeySize(512))).fromTaggedCbor(cborValue);
|
|
9620
9555
|
}
|
|
9621
9556
|
/**
|
|
9622
9557
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -9630,8 +9565,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9630
9565
|
*/
|
|
9631
9566
|
static fromUntaggedCborData(data) {
|
|
9632
9567
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
9633
|
-
|
|
9634
|
-
return new MLKEMPublicKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(cborValue);
|
|
9568
|
+
return new MLKEMPublicKey(512, new Uint8Array(mlkemPublicKeySize(512))).fromUntaggedCbor(cborValue);
|
|
9635
9569
|
}
|
|
9636
9570
|
/**
|
|
9637
9571
|
* Returns the UR representation.
|
|
@@ -9652,8 +9586,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9652
9586
|
*/
|
|
9653
9587
|
static fromUR(ur) {
|
|
9654
9588
|
if (ur.urTypeStr() !== _bcts_tags.MLKEM_PUBLIC_KEY.name) throw new Error(`Expected UR type ${_bcts_tags.MLKEM_PUBLIC_KEY.name}, got ${ur.urTypeStr()}`);
|
|
9655
|
-
|
|
9656
|
-
return new MLKEMPublicKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(ur.cbor());
|
|
9589
|
+
return new MLKEMPublicKey(512, new Uint8Array(mlkemPublicKeySize(512))).fromUntaggedCbor(ur.cbor());
|
|
9657
9590
|
}
|
|
9658
9591
|
/**
|
|
9659
9592
|
* Creates an MLKEMPublicKey from a UR string.
|
|
@@ -9663,10 +9596,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9663
9596
|
return MLKEMPublicKey.fromUR(ur);
|
|
9664
9597
|
}
|
|
9665
9598
|
};
|
|
9666
|
-
|
|
9667
|
-
//#
|
|
9668
|
-
|
|
9669
|
-
/**
|
|
9599
|
+
//#endregion
|
|
9600
|
+
//#region src/encapsulation/encapsulation-public-key.ts
|
|
9601
|
+
/**
|
|
9670
9602
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
9671
9603
|
* Copyright © 2025-2026 Parity Technologies
|
|
9672
9604
|
*
|
|
@@ -9699,16 +9631,16 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9699
9631
|
*/
|
|
9700
9632
|
function mlkemLevelToScheme$1(level) {
|
|
9701
9633
|
switch (level) {
|
|
9702
|
-
case
|
|
9703
|
-
case
|
|
9704
|
-
case
|
|
9634
|
+
case 512: return "mlkem512";
|
|
9635
|
+
case 768: return "mlkem768";
|
|
9636
|
+
case 1024: return "mlkem1024";
|
|
9705
9637
|
}
|
|
9706
9638
|
}
|
|
9707
9639
|
/**
|
|
9708
9640
|
* Check if a scheme is an MLKEM scheme
|
|
9709
9641
|
*/
|
|
9710
9642
|
function isMlkemScheme$1(scheme) {
|
|
9711
|
-
return scheme ===
|
|
9643
|
+
return scheme === "mlkem512" || scheme === "mlkem768" || scheme === "mlkem1024";
|
|
9712
9644
|
}
|
|
9713
9645
|
/**
|
|
9714
9646
|
* Represents a public key for key encapsulation.
|
|
@@ -9728,7 +9660,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9728
9660
|
* Create an EncapsulationPublicKey from an X25519PublicKey.
|
|
9729
9661
|
*/
|
|
9730
9662
|
static fromX25519PublicKey(publicKey) {
|
|
9731
|
-
return new EncapsulationPublicKey(
|
|
9663
|
+
return new EncapsulationPublicKey("x25519", publicKey, void 0);
|
|
9732
9664
|
}
|
|
9733
9665
|
/**
|
|
9734
9666
|
* Create an EncapsulationPublicKey from raw X25519 public key bytes.
|
|
@@ -9760,7 +9692,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9760
9692
|
* Returns true if this is an X25519 public key.
|
|
9761
9693
|
*/
|
|
9762
9694
|
isX25519() {
|
|
9763
|
-
return this._scheme ===
|
|
9695
|
+
return this._scheme === "x25519";
|
|
9764
9696
|
}
|
|
9765
9697
|
/**
|
|
9766
9698
|
* Returns true if this is an MLKEM public key.
|
|
@@ -9800,7 +9732,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9800
9732
|
* Returns the raw public key data.
|
|
9801
9733
|
*/
|
|
9802
9734
|
data() {
|
|
9803
|
-
if (this._scheme ===
|
|
9735
|
+
if (this._scheme === "x25519") {
|
|
9804
9736
|
const pk = this._x25519PublicKey;
|
|
9805
9737
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
9806
9738
|
return pk.data();
|
|
@@ -9831,7 +9763,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9831
9763
|
* @returns A tuple of [sharedSecret, ciphertext]
|
|
9832
9764
|
*/
|
|
9833
9765
|
encapsulateNewSharedSecret() {
|
|
9834
|
-
if (this._scheme ===
|
|
9766
|
+
if (this._scheme === "x25519") {
|
|
9835
9767
|
const pk = this._x25519PublicKey;
|
|
9836
9768
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
9837
9769
|
const [ephemeralPrivate, ephemeralPublic] = X25519PrivateKey.keypair();
|
|
@@ -9849,7 +9781,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9849
9781
|
*/
|
|
9850
9782
|
equals(other) {
|
|
9851
9783
|
if (this._scheme !== other._scheme) return false;
|
|
9852
|
-
if (this._scheme ===
|
|
9784
|
+
if (this._scheme === "x25519") {
|
|
9853
9785
|
const thisPk = this._x25519PublicKey;
|
|
9854
9786
|
const otherPk = other._x25519PublicKey;
|
|
9855
9787
|
if (thisPk === void 0 || otherPk === void 0) return false;
|
|
@@ -9866,7 +9798,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9866
9798
|
* Get string representation.
|
|
9867
9799
|
*/
|
|
9868
9800
|
toString() {
|
|
9869
|
-
if (this._scheme ===
|
|
9801
|
+
if (this._scheme === "x25519") return `EncapsulationPublicKey(X25519, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
9870
9802
|
else if (isMlkemScheme$1(this._scheme)) return `EncapsulationPublicKey(${String(this._scheme)}, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
9871
9803
|
return `EncapsulationPublicKey(${String(this._scheme)})`;
|
|
9872
9804
|
}
|
|
@@ -9884,7 +9816,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9884
9816
|
* Returns the CBOR tags associated with this public key.
|
|
9885
9817
|
*/
|
|
9886
9818
|
cborTags() {
|
|
9887
|
-
if (this._scheme ===
|
|
9819
|
+
if (this._scheme === "x25519") return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.X25519_PUBLIC_KEY.value]);
|
|
9888
9820
|
else if (isMlkemScheme$1(this._scheme)) return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.MLKEM_PUBLIC_KEY.value]);
|
|
9889
9821
|
throw new Error(`Unsupported scheme: ${String(this._scheme)}`);
|
|
9890
9822
|
}
|
|
@@ -9892,7 +9824,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9892
9824
|
* Returns the untagged CBOR encoding.
|
|
9893
9825
|
*/
|
|
9894
9826
|
untaggedCbor() {
|
|
9895
|
-
if (this._scheme ===
|
|
9827
|
+
if (this._scheme === "x25519") {
|
|
9896
9828
|
const pk = this._x25519PublicKey;
|
|
9897
9829
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
9898
9830
|
return (0, _bcts_dcbor.toByteString)(pk.data());
|
|
@@ -9964,7 +9896,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
9964
9896
|
* Returns the UR representation.
|
|
9965
9897
|
*/
|
|
9966
9898
|
ur() {
|
|
9967
|
-
if (this._scheme ===
|
|
9899
|
+
if (this._scheme === "x25519") {
|
|
9968
9900
|
const name = _bcts_tags.X25519_PUBLIC_KEY.name;
|
|
9969
9901
|
if (name === void 0) throw new Error("TAG_X25519_PUBLIC_KEY.name is undefined");
|
|
9970
9902
|
return _bcts_uniform_resources.UR.new(name, this.untaggedCbor());
|
|
@@ -10000,10 +9932,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10000
9932
|
return EncapsulationPublicKey.fromUR(ur);
|
|
10001
9933
|
}
|
|
10002
9934
|
};
|
|
10003
|
-
|
|
10004
|
-
//#
|
|
10005
|
-
|
|
10006
|
-
/**
|
|
9935
|
+
//#endregion
|
|
9936
|
+
//#region src/mlkem/mlkem-private-key.ts
|
|
9937
|
+
/**
|
|
10007
9938
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
10008
9939
|
* Copyright © 2025-2026 Parity Technologies
|
|
10009
9940
|
*
|
|
@@ -10044,7 +9975,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10044
9975
|
*
|
|
10045
9976
|
* @param level - The ML-KEM security level (default: MLKEM768)
|
|
10046
9977
|
*/
|
|
10047
|
-
static new(level =
|
|
9978
|
+
static new(level = 768) {
|
|
10048
9979
|
const rng = new _bcts_rand.SecureRandomNumberGenerator();
|
|
10049
9980
|
return MLKEMPrivateKey.newUsing(level, rng);
|
|
10050
9981
|
}
|
|
@@ -10072,7 +10003,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10072
10003
|
* @param level - The ML-KEM security level (default: MLKEM768)
|
|
10073
10004
|
* @returns Tuple of [privateKey, publicKey]
|
|
10074
10005
|
*/
|
|
10075
|
-
static keypair(level =
|
|
10006
|
+
static keypair(level = 768) {
|
|
10076
10007
|
const rng = new _bcts_rand.SecureRandomNumberGenerator();
|
|
10077
10008
|
return MLKEMPrivateKey.keypairUsing(level, rng);
|
|
10078
10009
|
}
|
|
@@ -10198,8 +10129,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10198
10129
|
* Static method to decode from tagged CBOR.
|
|
10199
10130
|
*/
|
|
10200
10131
|
static fromTaggedCbor(cborValue) {
|
|
10201
|
-
|
|
10202
|
-
return new MLKEMPrivateKey(MLKEMLevel.MLKEM512, dummyData).fromTaggedCbor(cborValue);
|
|
10132
|
+
return new MLKEMPrivateKey(512, new Uint8Array(mlkemPrivateKeySize(512))).fromTaggedCbor(cborValue);
|
|
10203
10133
|
}
|
|
10204
10134
|
/**
|
|
10205
10135
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -10213,8 +10143,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10213
10143
|
*/
|
|
10214
10144
|
static fromUntaggedCborData(data) {
|
|
10215
10145
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
10216
|
-
|
|
10217
|
-
return new MLKEMPrivateKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(cborValue);
|
|
10146
|
+
return new MLKEMPrivateKey(512, new Uint8Array(mlkemPrivateKeySize(512))).fromUntaggedCbor(cborValue);
|
|
10218
10147
|
}
|
|
10219
10148
|
/**
|
|
10220
10149
|
* Returns the UR representation.
|
|
@@ -10235,8 +10164,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10235
10164
|
*/
|
|
10236
10165
|
static fromUR(ur) {
|
|
10237
10166
|
if (ur.urTypeStr() !== _bcts_tags.MLKEM_PRIVATE_KEY.name) throw new Error(`Expected UR type ${_bcts_tags.MLKEM_PRIVATE_KEY.name}, got ${ur.urTypeStr()}`);
|
|
10238
|
-
|
|
10239
|
-
return new MLKEMPrivateKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(ur.cbor());
|
|
10167
|
+
return new MLKEMPrivateKey(512, new Uint8Array(mlkemPrivateKeySize(512))).fromUntaggedCbor(ur.cbor());
|
|
10240
10168
|
}
|
|
10241
10169
|
/**
|
|
10242
10170
|
* Creates an MLKEMPrivateKey from a UR string.
|
|
@@ -10246,10 +10174,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10246
10174
|
return MLKEMPrivateKey.fromUR(ur);
|
|
10247
10175
|
}
|
|
10248
10176
|
};
|
|
10249
|
-
|
|
10250
|
-
//#
|
|
10251
|
-
|
|
10252
|
-
/**
|
|
10177
|
+
//#endregion
|
|
10178
|
+
//#region src/encapsulation/encapsulation-private-key.ts
|
|
10179
|
+
/**
|
|
10253
10180
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
10254
10181
|
* Copyright © 2025-2026 Parity Technologies
|
|
10255
10182
|
*
|
|
@@ -10281,16 +10208,16 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10281
10208
|
*/
|
|
10282
10209
|
function mlkemLevelToScheme(level) {
|
|
10283
10210
|
switch (level) {
|
|
10284
|
-
case
|
|
10285
|
-
case
|
|
10286
|
-
case
|
|
10211
|
+
case 512: return "mlkem512";
|
|
10212
|
+
case 768: return "mlkem768";
|
|
10213
|
+
case 1024: return "mlkem1024";
|
|
10287
10214
|
}
|
|
10288
10215
|
}
|
|
10289
10216
|
/**
|
|
10290
10217
|
* Check if a scheme is an MLKEM scheme
|
|
10291
10218
|
*/
|
|
10292
10219
|
function isMlkemScheme(scheme) {
|
|
10293
|
-
return scheme ===
|
|
10220
|
+
return scheme === "mlkem512" || scheme === "mlkem768" || scheme === "mlkem1024";
|
|
10294
10221
|
}
|
|
10295
10222
|
/**
|
|
10296
10223
|
* Represents a private key for key encapsulation.
|
|
@@ -10310,7 +10237,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10310
10237
|
* Create an EncapsulationPrivateKey from an X25519PrivateKey.
|
|
10311
10238
|
*/
|
|
10312
10239
|
static fromX25519PrivateKey(privateKey) {
|
|
10313
|
-
return new EncapsulationPrivateKey(
|
|
10240
|
+
return new EncapsulationPrivateKey("x25519", privateKey, void 0);
|
|
10314
10241
|
}
|
|
10315
10242
|
/**
|
|
10316
10243
|
* Create an EncapsulationPrivateKey from raw X25519 private key bytes.
|
|
@@ -10355,7 +10282,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10355
10282
|
/**
|
|
10356
10283
|
* Generate a new MLKEM encapsulation private key.
|
|
10357
10284
|
*/
|
|
10358
|
-
static newMlkem(level =
|
|
10285
|
+
static newMlkem(level = 768) {
|
|
10359
10286
|
const mlkemPrivate = MLKEMPrivateKey.new(level);
|
|
10360
10287
|
return EncapsulationPrivateKey.fromMlkem(mlkemPrivate);
|
|
10361
10288
|
}
|
|
@@ -10383,7 +10310,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10383
10310
|
/**
|
|
10384
10311
|
* Generate a new MLKEM keypair.
|
|
10385
10312
|
*/
|
|
10386
|
-
static mlkemKeypair(level =
|
|
10313
|
+
static mlkemKeypair(level = 768) {
|
|
10387
10314
|
const [mlkemPrivate, mlkemPublic] = MLKEMPrivateKey.keypair(level);
|
|
10388
10315
|
return [EncapsulationPrivateKey.fromMlkem(mlkemPrivate), EncapsulationPublicKey.fromMlkem(mlkemPublic)];
|
|
10389
10316
|
}
|
|
@@ -10404,7 +10331,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10404
10331
|
* Returns true if this is an X25519 private key.
|
|
10405
10332
|
*/
|
|
10406
10333
|
isX25519() {
|
|
10407
|
-
return this._scheme ===
|
|
10334
|
+
return this._scheme === "x25519";
|
|
10408
10335
|
}
|
|
10409
10336
|
/**
|
|
10410
10337
|
* Returns true if this is an MLKEM private key.
|
|
@@ -10444,7 +10371,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10444
10371
|
* Returns the raw private key data.
|
|
10445
10372
|
*/
|
|
10446
10373
|
data() {
|
|
10447
|
-
if (this._scheme ===
|
|
10374
|
+
if (this._scheme === "x25519") {
|
|
10448
10375
|
const pk = this._x25519PrivateKey;
|
|
10449
10376
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
10450
10377
|
return pk.data();
|
|
@@ -10459,7 +10386,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10459
10386
|
* Get the public key corresponding to this private key.
|
|
10460
10387
|
*/
|
|
10461
10388
|
publicKey() {
|
|
10462
|
-
if (this._scheme ===
|
|
10389
|
+
if (this._scheme === "x25519") {
|
|
10463
10390
|
const pk = this._x25519PrivateKey;
|
|
10464
10391
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
10465
10392
|
const x25519Public = pk.publicKey();
|
|
@@ -10481,7 +10408,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10481
10408
|
*/
|
|
10482
10409
|
decapsulateSharedSecret(ciphertext) {
|
|
10483
10410
|
if (ciphertext.encapsulationScheme() !== this._scheme) throw CryptoError.invalidData(`Scheme mismatch: expected ${String(this._scheme)}, got ${String(ciphertext.encapsulationScheme())}`);
|
|
10484
|
-
if (this._scheme ===
|
|
10411
|
+
if (this._scheme === "x25519") {
|
|
10485
10412
|
const pk = this._x25519PrivateKey;
|
|
10486
10413
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
10487
10414
|
const ephemeralPublic = ciphertext.x25519PublicKey();
|
|
@@ -10499,7 +10426,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10499
10426
|
*/
|
|
10500
10427
|
equals(other) {
|
|
10501
10428
|
if (this._scheme !== other._scheme) return false;
|
|
10502
|
-
if (this._scheme ===
|
|
10429
|
+
if (this._scheme === "x25519") {
|
|
10503
10430
|
const thisPk = this._x25519PrivateKey;
|
|
10504
10431
|
const otherPk = other._x25519PrivateKey;
|
|
10505
10432
|
if (thisPk === void 0 || otherPk === void 0) return false;
|
|
@@ -10516,7 +10443,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10516
10443
|
* Get string representation.
|
|
10517
10444
|
*/
|
|
10518
10445
|
toString() {
|
|
10519
|
-
if (this._scheme ===
|
|
10446
|
+
if (this._scheme === "x25519") return `EncapsulationPrivateKey(X25519, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
10520
10447
|
else if (isMlkemScheme(this._scheme)) return `EncapsulationPrivateKey(${String(this._scheme)}, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
10521
10448
|
return `EncapsulationPrivateKey(${String(this._scheme)})`;
|
|
10522
10449
|
}
|
|
@@ -10534,7 +10461,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10534
10461
|
* Returns the CBOR tags associated with this private key.
|
|
10535
10462
|
*/
|
|
10536
10463
|
cborTags() {
|
|
10537
|
-
if (this._scheme ===
|
|
10464
|
+
if (this._scheme === "x25519") return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.X25519_PRIVATE_KEY.value]);
|
|
10538
10465
|
else if (isMlkemScheme(this._scheme)) return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.MLKEM_PRIVATE_KEY.value]);
|
|
10539
10466
|
throw new Error(`Unsupported scheme: ${String(this._scheme)}`);
|
|
10540
10467
|
}
|
|
@@ -10542,7 +10469,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10542
10469
|
* Returns the untagged CBOR encoding.
|
|
10543
10470
|
*/
|
|
10544
10471
|
untaggedCbor() {
|
|
10545
|
-
if (this._scheme ===
|
|
10472
|
+
if (this._scheme === "x25519") {
|
|
10546
10473
|
const pk = this._x25519PrivateKey;
|
|
10547
10474
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
10548
10475
|
return (0, _bcts_dcbor.toByteString)(pk.data());
|
|
@@ -10614,7 +10541,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10614
10541
|
* Returns the UR representation.
|
|
10615
10542
|
*/
|
|
10616
10543
|
ur() {
|
|
10617
|
-
if (this._scheme ===
|
|
10544
|
+
if (this._scheme === "x25519") {
|
|
10618
10545
|
const name = _bcts_tags.X25519_PRIVATE_KEY.name;
|
|
10619
10546
|
if (name === void 0) throw new Error("TAG_X25519_PRIVATE_KEY.name is undefined");
|
|
10620
10547
|
return _bcts_uniform_resources.UR.new(name, this.untaggedCbor());
|
|
@@ -10650,37 +10577,36 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10650
10577
|
return EncapsulationPrivateKey.fromUR(ur);
|
|
10651
10578
|
}
|
|
10652
10579
|
};
|
|
10653
|
-
|
|
10654
|
-
//#
|
|
10655
|
-
|
|
10656
|
-
/**
|
|
10580
|
+
//#endregion
|
|
10581
|
+
//#region src/encapsulation/encapsulation-scheme.ts
|
|
10582
|
+
/**
|
|
10657
10583
|
* Available key encapsulation schemes.
|
|
10658
10584
|
*/
|
|
10659
|
-
let EncapsulationScheme = /* @__PURE__ */ function(EncapsulationScheme
|
|
10585
|
+
let EncapsulationScheme = /* @__PURE__ */ function(EncapsulationScheme) {
|
|
10660
10586
|
/**
|
|
10661
10587
|
* X25519 Diffie-Hellman key exchange (default).
|
|
10662
10588
|
* Based on Curve25519 as defined in RFC 7748.
|
|
10663
10589
|
*/
|
|
10664
|
-
EncapsulationScheme
|
|
10590
|
+
EncapsulationScheme["X25519"] = "x25519";
|
|
10665
10591
|
/**
|
|
10666
10592
|
* ML-KEM-512 post-quantum key encapsulation (NIST security level 1).
|
|
10667
10593
|
*/
|
|
10668
|
-
EncapsulationScheme
|
|
10594
|
+
EncapsulationScheme["MLKEM512"] = "mlkem512";
|
|
10669
10595
|
/**
|
|
10670
10596
|
* ML-KEM-768 post-quantum key encapsulation (NIST security level 3).
|
|
10671
10597
|
*/
|
|
10672
|
-
EncapsulationScheme
|
|
10598
|
+
EncapsulationScheme["MLKEM768"] = "mlkem768";
|
|
10673
10599
|
/**
|
|
10674
10600
|
* ML-KEM-1024 post-quantum key encapsulation (NIST security level 5).
|
|
10675
10601
|
*/
|
|
10676
|
-
EncapsulationScheme
|
|
10677
|
-
return EncapsulationScheme
|
|
10602
|
+
EncapsulationScheme["MLKEM1024"] = "mlkem1024";
|
|
10603
|
+
return EncapsulationScheme;
|
|
10678
10604
|
}({});
|
|
10679
10605
|
/**
|
|
10680
10606
|
* Returns the default encapsulation scheme (X25519).
|
|
10681
10607
|
*/
|
|
10682
10608
|
function defaultEncapsulationScheme() {
|
|
10683
|
-
return
|
|
10609
|
+
return "x25519";
|
|
10684
10610
|
}
|
|
10685
10611
|
/**
|
|
10686
10612
|
* Generate a new keypair for the given encapsulation scheme.
|
|
@@ -10688,12 +10614,12 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10688
10614
|
* @param scheme - The encapsulation scheme to use (defaults to X25519)
|
|
10689
10615
|
* @returns A tuple of [privateKey, publicKey]
|
|
10690
10616
|
*/
|
|
10691
|
-
function createEncapsulationKeypair(scheme =
|
|
10617
|
+
function createEncapsulationKeypair(scheme = "x25519") {
|
|
10692
10618
|
switch (scheme) {
|
|
10693
|
-
case
|
|
10694
|
-
case
|
|
10695
|
-
case
|
|
10696
|
-
case
|
|
10619
|
+
case "x25519": return EncapsulationPrivateKey.keypair();
|
|
10620
|
+
case "mlkem512": return EncapsulationPrivateKey.mlkemKeypair(512);
|
|
10621
|
+
case "mlkem768": return EncapsulationPrivateKey.mlkemKeypair(768);
|
|
10622
|
+
case "mlkem1024": return EncapsulationPrivateKey.mlkemKeypair(1024);
|
|
10697
10623
|
}
|
|
10698
10624
|
}
|
|
10699
10625
|
/**
|
|
@@ -10707,18 +10633,17 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10707
10633
|
* @returns A tuple of [privateKey, publicKey]
|
|
10708
10634
|
* @throws Error if the scheme doesn't support deterministic generation
|
|
10709
10635
|
*/
|
|
10710
|
-
function createEncapsulationKeypairUsing(rng, scheme =
|
|
10636
|
+
function createEncapsulationKeypairUsing(rng, scheme = "x25519") {
|
|
10711
10637
|
switch (scheme) {
|
|
10712
|
-
case
|
|
10713
|
-
case
|
|
10714
|
-
case
|
|
10715
|
-
case
|
|
10638
|
+
case "x25519": return EncapsulationPrivateKey.keypairUsing(rng);
|
|
10639
|
+
case "mlkem512":
|
|
10640
|
+
case "mlkem768":
|
|
10641
|
+
case "mlkem1024": throw new Error("Deterministic keypair generation not supported for this encapsulation scheme");
|
|
10716
10642
|
}
|
|
10717
10643
|
}
|
|
10718
|
-
|
|
10719
|
-
//#
|
|
10720
|
-
|
|
10721
|
-
/**
|
|
10644
|
+
//#endregion
|
|
10645
|
+
//#region src/encapsulation/sealed-message.ts
|
|
10646
|
+
/**
|
|
10722
10647
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
10723
10648
|
* Copyright © 2025-2026 Parity Technologies
|
|
10724
10649
|
*
|
|
@@ -10947,10 +10872,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10947
10872
|
return SealedMessage.fromUR(ur);
|
|
10948
10873
|
}
|
|
10949
10874
|
};
|
|
10950
|
-
|
|
10951
|
-
//#
|
|
10952
|
-
|
|
10953
|
-
/**
|
|
10875
|
+
//#endregion
|
|
10876
|
+
//#region src/encrypted-key/hash-type.ts
|
|
10877
|
+
/**
|
|
10954
10878
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
10955
10879
|
* Copyright © 2025-2026 Parity Technologies
|
|
10956
10880
|
*
|
|
@@ -10971,20 +10895,20 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
10971
10895
|
/**
|
|
10972
10896
|
* Enum representing supported hash types for key derivation.
|
|
10973
10897
|
*/
|
|
10974
|
-
let HashType = /* @__PURE__ */ function(HashType
|
|
10898
|
+
let HashType = /* @__PURE__ */ function(HashType) {
|
|
10975
10899
|
/** SHA-256 hash algorithm */
|
|
10976
|
-
HashType
|
|
10900
|
+
HashType[HashType["SHA256"] = 0] = "SHA256";
|
|
10977
10901
|
/** SHA-512 hash algorithm */
|
|
10978
|
-
HashType
|
|
10979
|
-
return HashType
|
|
10902
|
+
HashType[HashType["SHA512"] = 1] = "SHA512";
|
|
10903
|
+
return HashType;
|
|
10980
10904
|
}({});
|
|
10981
10905
|
/**
|
|
10982
10906
|
* Convert HashType to its string representation.
|
|
10983
10907
|
*/
|
|
10984
10908
|
function hashTypeToString(hashType) {
|
|
10985
10909
|
switch (hashType) {
|
|
10986
|
-
case
|
|
10987
|
-
case
|
|
10910
|
+
case 0: return "SHA256";
|
|
10911
|
+
case 1: return "SHA512";
|
|
10988
10912
|
default: throw new Error(`Unknown HashType: ${String(hashType)}`);
|
|
10989
10913
|
}
|
|
10990
10914
|
}
|
|
@@ -11000,15 +10924,14 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11000
10924
|
function hashTypeFromCbor(cborValue) {
|
|
11001
10925
|
const value = (0, _bcts_dcbor.expectNumber)(cborValue);
|
|
11002
10926
|
switch (value) {
|
|
11003
|
-
case 0: return
|
|
11004
|
-
case 1: return
|
|
10927
|
+
case 0: return 0;
|
|
10928
|
+
case 1: return 1;
|
|
11005
10929
|
default: throw new Error(`Invalid HashType: ${value}`);
|
|
11006
10930
|
}
|
|
11007
10931
|
}
|
|
11008
|
-
|
|
11009
|
-
//#
|
|
11010
|
-
|
|
11011
|
-
/**
|
|
10932
|
+
//#endregion
|
|
10933
|
+
//#region src/encrypted-key/key-derivation-method.ts
|
|
10934
|
+
/**
|
|
11012
10935
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
11013
10936
|
* Copyright © 2025-2026 Parity Technologies
|
|
11014
10937
|
*
|
|
@@ -11032,24 +10955,24 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11032
10955
|
/**
|
|
11033
10956
|
* Enum representing supported key derivation methods.
|
|
11034
10957
|
*/
|
|
11035
|
-
let KeyDerivationMethod = /* @__PURE__ */ function(KeyDerivationMethod
|
|
10958
|
+
let KeyDerivationMethod = /* @__PURE__ */ function(KeyDerivationMethod) {
|
|
11036
10959
|
/** HKDF (HMAC-based Key Derivation Function) - RFC 5869 */
|
|
11037
|
-
KeyDerivationMethod
|
|
10960
|
+
KeyDerivationMethod[KeyDerivationMethod["HKDF"] = 0] = "HKDF";
|
|
11038
10961
|
/** PBKDF2 (Password-Based Key Derivation Function 2) - RFC 8018 */
|
|
11039
|
-
KeyDerivationMethod
|
|
10962
|
+
KeyDerivationMethod[KeyDerivationMethod["PBKDF2"] = 1] = "PBKDF2";
|
|
11040
10963
|
/** Scrypt - RFC 7914 */
|
|
11041
|
-
KeyDerivationMethod
|
|
10964
|
+
KeyDerivationMethod[KeyDerivationMethod["Scrypt"] = 2] = "Scrypt";
|
|
11042
10965
|
/** Argon2id - RFC 9106 (default, most secure for passwords) */
|
|
11043
|
-
KeyDerivationMethod
|
|
10966
|
+
KeyDerivationMethod[KeyDerivationMethod["Argon2id"] = 3] = "Argon2id";
|
|
11044
10967
|
/** SSH Agent - Uses SSH agent for key derivation */
|
|
11045
|
-
KeyDerivationMethod
|
|
11046
|
-
return KeyDerivationMethod
|
|
10968
|
+
KeyDerivationMethod[KeyDerivationMethod["SSHAgent"] = 4] = "SSHAgent";
|
|
10969
|
+
return KeyDerivationMethod;
|
|
11047
10970
|
}({});
|
|
11048
10971
|
/**
|
|
11049
10972
|
* Returns the default key derivation method (Argon2id).
|
|
11050
10973
|
*/
|
|
11051
10974
|
function defaultKeyDerivationMethod() {
|
|
11052
|
-
return
|
|
10975
|
+
return 3;
|
|
11053
10976
|
}
|
|
11054
10977
|
/**
|
|
11055
10978
|
* Returns the zero-based index of the key derivation method.
|
|
@@ -11062,11 +10985,11 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11062
10985
|
*/
|
|
11063
10986
|
function keyDerivationMethodFromIndex(index) {
|
|
11064
10987
|
switch (index) {
|
|
11065
|
-
case 0: return
|
|
11066
|
-
case 1: return
|
|
11067
|
-
case 2: return
|
|
11068
|
-
case 3: return
|
|
11069
|
-
case 4: return
|
|
10988
|
+
case 0: return 0;
|
|
10989
|
+
case 1: return 1;
|
|
10990
|
+
case 2: return 2;
|
|
10991
|
+
case 3: return 3;
|
|
10992
|
+
case 4: return 4;
|
|
11070
10993
|
default: return;
|
|
11071
10994
|
}
|
|
11072
10995
|
}
|
|
@@ -11075,11 +10998,11 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11075
10998
|
*/
|
|
11076
10999
|
function keyDerivationMethodToString(method) {
|
|
11077
11000
|
switch (method) {
|
|
11078
|
-
case
|
|
11079
|
-
case
|
|
11080
|
-
case
|
|
11081
|
-
case
|
|
11082
|
-
case
|
|
11001
|
+
case 0: return "HKDF";
|
|
11002
|
+
case 1: return "PBKDF2";
|
|
11003
|
+
case 2: return "Scrypt";
|
|
11004
|
+
case 3: return "Argon2id";
|
|
11005
|
+
case 4: return "SSHAgent";
|
|
11083
11006
|
default: throw new Error(`Unknown KeyDerivationMethod: ${String(method)}`);
|
|
11084
11007
|
}
|
|
11085
11008
|
}
|
|
@@ -11092,10 +11015,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11092
11015
|
if (method === void 0) throw new Error(`Invalid KeyDerivationMethod index: ${value}`);
|
|
11093
11016
|
return method;
|
|
11094
11017
|
}
|
|
11095
|
-
|
|
11096
|
-
//#
|
|
11097
|
-
|
|
11098
|
-
/**
|
|
11018
|
+
//#endregion
|
|
11019
|
+
//#region src/encrypted-key/hkdf-params.ts
|
|
11020
|
+
/**
|
|
11099
11021
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
11100
11022
|
* Copyright © 2025-2026 Parity Technologies
|
|
11101
11023
|
*
|
|
@@ -11122,7 +11044,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11122
11044
|
* but NOT for password-based key derivation.
|
|
11123
11045
|
*/
|
|
11124
11046
|
var HKDFParams = class HKDFParams {
|
|
11125
|
-
static INDEX =
|
|
11047
|
+
static INDEX = 0;
|
|
11126
11048
|
_salt;
|
|
11127
11049
|
_hashType;
|
|
11128
11050
|
constructor(salt, hashType) {
|
|
@@ -11134,7 +11056,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11134
11056
|
* Uses a random 16-byte salt and SHA-256.
|
|
11135
11057
|
*/
|
|
11136
11058
|
static new() {
|
|
11137
|
-
return HKDFParams.newOpt(Salt.newWithLen(
|
|
11059
|
+
return HKDFParams.newOpt(Salt.newWithLen(16), 0);
|
|
11138
11060
|
}
|
|
11139
11061
|
/**
|
|
11140
11062
|
* Create HKDF parameters with custom settings.
|
|
@@ -11173,8 +11095,8 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11173
11095
|
}
|
|
11174
11096
|
_deriveKey(secret) {
|
|
11175
11097
|
switch (this._hashType) {
|
|
11176
|
-
case
|
|
11177
|
-
case
|
|
11098
|
+
case 0: return (0, _bcts_crypto.hkdfHmacSha256)(secret, this._salt.asBytes(), 32);
|
|
11099
|
+
case 1: return (0, _bcts_crypto.hkdfHmacSha512)(secret, this._salt.asBytes(), 32);
|
|
11178
11100
|
default: throw new Error(`Unknown hash type: ${String(this._hashType)}`);
|
|
11179
11101
|
}
|
|
11180
11102
|
}
|
|
@@ -11219,10 +11141,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11219
11141
|
return new HKDFParams(Salt.fromData(saltData), hashTypeFromCbor(array[2]));
|
|
11220
11142
|
}
|
|
11221
11143
|
};
|
|
11222
|
-
|
|
11223
|
-
//#
|
|
11224
|
-
|
|
11225
|
-
/**
|
|
11144
|
+
//#endregion
|
|
11145
|
+
//#region src/encrypted-key/pbkdf2-params.ts
|
|
11146
|
+
/**
|
|
11226
11147
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
11227
11148
|
* Copyright © 2025-2026 Parity Technologies
|
|
11228
11149
|
*
|
|
@@ -11245,7 +11166,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11245
11166
|
* PBKDF2 parameters for password-based key derivation.
|
|
11246
11167
|
*/
|
|
11247
11168
|
var PBKDF2Params = class PBKDF2Params {
|
|
11248
|
-
static INDEX =
|
|
11169
|
+
static INDEX = 1;
|
|
11249
11170
|
_salt;
|
|
11250
11171
|
_iterations;
|
|
11251
11172
|
_hashType;
|
|
@@ -11259,7 +11180,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11259
11180
|
* Uses a random 16-byte salt, 100,000 iterations, and SHA-256.
|
|
11260
11181
|
*/
|
|
11261
11182
|
static new() {
|
|
11262
|
-
return PBKDF2Params.newOpt(Salt.newWithLen(
|
|
11183
|
+
return PBKDF2Params.newOpt(Salt.newWithLen(16), DEFAULT_PBKDF2_ITERATIONS, 0);
|
|
11263
11184
|
}
|
|
11264
11185
|
/**
|
|
11265
11186
|
* Create PBKDF2 parameters with custom settings.
|
|
@@ -11302,8 +11223,8 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11302
11223
|
}
|
|
11303
11224
|
_deriveKey(secret) {
|
|
11304
11225
|
switch (this._hashType) {
|
|
11305
|
-
case
|
|
11306
|
-
case
|
|
11226
|
+
case 0: return (0, _bcts_crypto.pbkdf2HmacSha256)(secret, this._salt.asBytes(), this._iterations, 32);
|
|
11227
|
+
case 1: return (0, _bcts_crypto.pbkdf2HmacSha512)(secret, this._salt.asBytes(), this._iterations, 32);
|
|
11307
11228
|
default: throw new Error(`Unknown hash type: ${String(this._hashType)}`);
|
|
11308
11229
|
}
|
|
11309
11230
|
}
|
|
@@ -11349,10 +11270,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11349
11270
|
return new PBKDF2Params(Salt.fromData(saltData), Number((0, _bcts_dcbor.expectNumber)(array[2])), hashTypeFromCbor(array[3]));
|
|
11350
11271
|
}
|
|
11351
11272
|
};
|
|
11352
|
-
|
|
11353
|
-
//#
|
|
11354
|
-
|
|
11355
|
-
/**
|
|
11273
|
+
//#endregion
|
|
11274
|
+
//#region src/encrypted-key/scrypt-params.ts
|
|
11275
|
+
/**
|
|
11356
11276
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
11357
11277
|
* Copyright © 2025-2026 Parity Technologies
|
|
11358
11278
|
*
|
|
@@ -11385,7 +11305,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11385
11305
|
* - p: Parallelization parameter
|
|
11386
11306
|
*/
|
|
11387
11307
|
var ScryptParams = class ScryptParams {
|
|
11388
|
-
static INDEX =
|
|
11308
|
+
static INDEX = 2;
|
|
11389
11309
|
_salt;
|
|
11390
11310
|
_logN;
|
|
11391
11311
|
_r;
|
|
@@ -11401,7 +11321,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11401
11321
|
* Uses a random 16-byte salt, log_n=15, r=8, p=1.
|
|
11402
11322
|
*/
|
|
11403
11323
|
static new() {
|
|
11404
|
-
return ScryptParams.newOpt(Salt.newWithLen(
|
|
11324
|
+
return ScryptParams.newOpt(Salt.newWithLen(16), 15, 8, 1);
|
|
11405
11325
|
}
|
|
11406
11326
|
/**
|
|
11407
11327
|
* Create Scrypt parameters with custom settings.
|
|
@@ -11492,10 +11412,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11492
11412
|
return new ScryptParams(Salt.fromData(saltData), Number((0, _bcts_dcbor.expectNumber)(array[2])), Number((0, _bcts_dcbor.expectNumber)(array[3])), Number((0, _bcts_dcbor.expectNumber)(array[4])));
|
|
11493
11413
|
}
|
|
11494
11414
|
};
|
|
11495
|
-
|
|
11496
|
-
//#
|
|
11497
|
-
|
|
11498
|
-
/**
|
|
11415
|
+
//#endregion
|
|
11416
|
+
//#region src/encrypted-key/argon2id-params.ts
|
|
11417
|
+
/**
|
|
11499
11418
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
11500
11419
|
* Copyright © 2025-2026 Parity Technologies
|
|
11501
11420
|
*
|
|
@@ -11525,7 +11444,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11525
11444
|
* attacks.
|
|
11526
11445
|
*/
|
|
11527
11446
|
var Argon2idParams = class Argon2idParams {
|
|
11528
|
-
static INDEX =
|
|
11447
|
+
static INDEX = 3;
|
|
11529
11448
|
_salt;
|
|
11530
11449
|
constructor(salt) {
|
|
11531
11450
|
this._salt = salt;
|
|
@@ -11535,7 +11454,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11535
11454
|
* Uses a random 16-byte salt.
|
|
11536
11455
|
*/
|
|
11537
11456
|
static new() {
|
|
11538
|
-
return Argon2idParams.newOpt(Salt.newWithLen(
|
|
11457
|
+
return Argon2idParams.newOpt(Salt.newWithLen(16));
|
|
11539
11458
|
}
|
|
11540
11459
|
/**
|
|
11541
11460
|
* Create Argon2id parameters with a custom salt.
|
|
@@ -11608,10 +11527,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11608
11527
|
return new Argon2idParams(Salt.fromData(saltData));
|
|
11609
11528
|
}
|
|
11610
11529
|
};
|
|
11611
|
-
|
|
11612
|
-
//#
|
|
11613
|
-
|
|
11614
|
-
/**
|
|
11530
|
+
//#endregion
|
|
11531
|
+
//#region src/encrypted-key/ssh-agent-params.ts
|
|
11532
|
+
/**
|
|
11615
11533
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
11616
11534
|
* Copyright © 2025-2026 Parity Technologies
|
|
11617
11535
|
*
|
|
@@ -11629,8 +11547,6 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11629
11547
|
* Ported from bc-components-rust/src/encrypted_key/ssh_agent_params.rs
|
|
11630
11548
|
*/
|
|
11631
11549
|
init_error();
|
|
11632
|
-
/** Default salt length for SSH agent key derivation */
|
|
11633
|
-
const SALT_LEN$1 = 16;
|
|
11634
11550
|
/**
|
|
11635
11551
|
* SSH Agent parameters for key derivation.
|
|
11636
11552
|
*
|
|
@@ -11643,7 +11559,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11643
11559
|
* methods will throw an error if SSH agent support is not available.
|
|
11644
11560
|
*/
|
|
11645
11561
|
var SSHAgentParams = class SSHAgentParams {
|
|
11646
|
-
static INDEX =
|
|
11562
|
+
static INDEX = 4;
|
|
11647
11563
|
_salt;
|
|
11648
11564
|
_id;
|
|
11649
11565
|
constructor(salt, id) {
|
|
@@ -11656,7 +11572,7 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11656
11572
|
* @param id - The SSH key identity (usually the key comment or public key fingerprint)
|
|
11657
11573
|
*/
|
|
11658
11574
|
static new(id) {
|
|
11659
|
-
return SSHAgentParams.newOpt(Salt.newWithLen(
|
|
11575
|
+
return SSHAgentParams.newOpt(Salt.newWithLen(16), id);
|
|
11660
11576
|
}
|
|
11661
11577
|
/**
|
|
11662
11578
|
* Create SSH agent parameters with custom salt and key ID.
|
|
@@ -11744,10 +11660,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11744
11660
|
return new SSHAgentParams(Salt.fromData(saltData), (0, _bcts_dcbor.expectText)(array[2]));
|
|
11745
11661
|
}
|
|
11746
11662
|
};
|
|
11747
|
-
|
|
11748
|
-
//#
|
|
11749
|
-
|
|
11750
|
-
/**
|
|
11663
|
+
//#endregion
|
|
11664
|
+
//#region src/encrypted-key/key-derivation-params.ts
|
|
11665
|
+
/**
|
|
11751
11666
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
11752
11667
|
* Copyright © 2025-2026 Parity Technologies
|
|
11753
11668
|
*
|
|
@@ -11822,11 +11737,11 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11822
11737
|
*/
|
|
11823
11738
|
function keyDerivationParamsMethod(kdp) {
|
|
11824
11739
|
switch (kdp.type) {
|
|
11825
|
-
case "hkdf": return
|
|
11826
|
-
case "pbkdf2": return
|
|
11827
|
-
case "scrypt": return
|
|
11828
|
-
case "argon2id": return
|
|
11829
|
-
case "sshagent": return
|
|
11740
|
+
case "hkdf": return 0;
|
|
11741
|
+
case "pbkdf2": return 1;
|
|
11742
|
+
case "scrypt": return 2;
|
|
11743
|
+
case "argon2id": return 3;
|
|
11744
|
+
case "sshagent": return 4;
|
|
11830
11745
|
}
|
|
11831
11746
|
}
|
|
11832
11747
|
/**
|
|
@@ -11899,32 +11814,31 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11899
11814
|
const method = keyDerivationMethodFromIndex(Number(index));
|
|
11900
11815
|
if (method === void 0) throw new Error(`Invalid KeyDerivationMethod index: ${index}`);
|
|
11901
11816
|
switch (method) {
|
|
11902
|
-
case
|
|
11817
|
+
case 0: return {
|
|
11903
11818
|
type: "hkdf",
|
|
11904
11819
|
params: HKDFParams.fromCbor(cborValue)
|
|
11905
11820
|
};
|
|
11906
|
-
case
|
|
11821
|
+
case 1: return {
|
|
11907
11822
|
type: "pbkdf2",
|
|
11908
11823
|
params: PBKDF2Params.fromCbor(cborValue)
|
|
11909
11824
|
};
|
|
11910
|
-
case
|
|
11825
|
+
case 2: return {
|
|
11911
11826
|
type: "scrypt",
|
|
11912
11827
|
params: ScryptParams.fromCbor(cborValue)
|
|
11913
11828
|
};
|
|
11914
|
-
case
|
|
11829
|
+
case 3: return {
|
|
11915
11830
|
type: "argon2id",
|
|
11916
11831
|
params: Argon2idParams.fromCbor(cborValue)
|
|
11917
11832
|
};
|
|
11918
|
-
case
|
|
11833
|
+
case 4: return {
|
|
11919
11834
|
type: "sshagent",
|
|
11920
11835
|
params: SSHAgentParams.fromCbor(cborValue)
|
|
11921
11836
|
};
|
|
11922
11837
|
}
|
|
11923
11838
|
}
|
|
11924
|
-
|
|
11925
|
-
//#
|
|
11926
|
-
|
|
11927
|
-
/**
|
|
11839
|
+
//#endregion
|
|
11840
|
+
//#region src/encrypted-key/encrypted-key.ts
|
|
11841
|
+
/**
|
|
11928
11842
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
11929
11843
|
* Copyright © 2025-2026 Parity Technologies
|
|
11930
11844
|
*
|
|
@@ -11986,19 +11900,19 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
11986
11900
|
static lock(method, secret, contentKey) {
|
|
11987
11901
|
let params;
|
|
11988
11902
|
switch (method) {
|
|
11989
|
-
case
|
|
11903
|
+
case 0:
|
|
11990
11904
|
params = hkdfParams();
|
|
11991
11905
|
break;
|
|
11992
|
-
case
|
|
11906
|
+
case 1:
|
|
11993
11907
|
params = pbkdf2Params();
|
|
11994
11908
|
break;
|
|
11995
|
-
case
|
|
11909
|
+
case 2:
|
|
11996
11910
|
params = scryptParams();
|
|
11997
11911
|
break;
|
|
11998
|
-
case
|
|
11912
|
+
case 3:
|
|
11999
11913
|
params = argon2idParams();
|
|
12000
11914
|
break;
|
|
12001
|
-
case
|
|
11915
|
+
case 4: throw new Error("SSH Agent key derivation cannot be used with lock() - use lockOpt() with sshAgentParams() instead");
|
|
12002
11916
|
}
|
|
12003
11917
|
return EncryptedKey.lockOpt(params, secret, contentKey);
|
|
12004
11918
|
}
|
|
@@ -12160,10 +12074,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
12160
12074
|
return EncryptedKey.fromUR(ur);
|
|
12161
12075
|
}
|
|
12162
12076
|
};
|
|
12163
|
-
|
|
12164
|
-
//#
|
|
12165
|
-
|
|
12166
|
-
/**
|
|
12077
|
+
//#endregion
|
|
12078
|
+
//#region src/public-keys.ts
|
|
12079
|
+
/**
|
|
12167
12080
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
12168
12081
|
* Copyright © 2025-2026 Parity Technologies
|
|
12169
12082
|
*
|
|
@@ -12390,10 +12303,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
12390
12303
|
return PublicKeys.fromUR(ur);
|
|
12391
12304
|
}
|
|
12392
12305
|
};
|
|
12393
|
-
|
|
12394
|
-
//#
|
|
12395
|
-
|
|
12396
|
-
/**
|
|
12306
|
+
//#endregion
|
|
12307
|
+
//#region src/private-keys.ts
|
|
12308
|
+
/**
|
|
12397
12309
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
12398
12310
|
* Copyright © 2025-2026 Parity Technologies
|
|
12399
12311
|
*
|
|
@@ -12607,10 +12519,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
12607
12519
|
return PrivateKeys.fromUR(ur);
|
|
12608
12520
|
}
|
|
12609
12521
|
};
|
|
12610
|
-
|
|
12611
|
-
//#
|
|
12612
|
-
|
|
12613
|
-
/**
|
|
12522
|
+
//#endregion
|
|
12523
|
+
//#region src/private-key-base.ts
|
|
12524
|
+
/**
|
|
12614
12525
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
12615
12526
|
* Copyright © 2025-2026 Parity Technologies
|
|
12616
12527
|
*
|
|
@@ -12882,10 +12793,9 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
12882
12793
|
return PrivateKeyBase.fromUR(ur);
|
|
12883
12794
|
}
|
|
12884
12795
|
};
|
|
12885
|
-
|
|
12886
|
-
//#
|
|
12887
|
-
|
|
12888
|
-
/**
|
|
12796
|
+
//#endregion
|
|
12797
|
+
//#region src/sskr.ts
|
|
12798
|
+
/**
|
|
12889
12799
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
12890
12800
|
* Copyright © 2025-2026 Parity Technologies
|
|
12891
12801
|
*
|
|
@@ -13160,186 +13070,185 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
13160
13070
|
function sskrCombineShares(shares) {
|
|
13161
13071
|
return (0, _bcts_sskr.sskrCombine)(shares.map((share) => share.data()));
|
|
13162
13072
|
}
|
|
13163
|
-
|
|
13164
|
-
//#
|
|
13165
|
-
//#region src/index.ts
|
|
13073
|
+
//#endregion
|
|
13074
|
+
//#region src/index.ts
|
|
13166
13075
|
init_error();
|
|
13167
13076
|
init_utils();
|
|
13168
13077
|
init_digest();
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
exports.
|
|
13172
|
-
exports.
|
|
13173
|
-
exports
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
exports.
|
|
13181
|
-
exports.
|
|
13182
|
-
exports.
|
|
13183
|
-
exports.
|
|
13184
|
-
exports.
|
|
13185
|
-
exports.
|
|
13186
|
-
exports.
|
|
13187
|
-
exports.
|
|
13188
|
-
exports.
|
|
13189
|
-
exports
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
exports.
|
|
13203
|
-
exports.
|
|
13204
|
-
exports.
|
|
13205
|
-
exports.
|
|
13206
|
-
exports.
|
|
13207
|
-
exports.
|
|
13208
|
-
exports.
|
|
13209
|
-
exports.
|
|
13210
|
-
exports.
|
|
13211
|
-
exports.
|
|
13212
|
-
exports.
|
|
13213
|
-
exports.
|
|
13214
|
-
exports
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
exports
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
|
|
13225
|
-
|
|
13226
|
-
|
|
13227
|
-
|
|
13228
|
-
exports.
|
|
13229
|
-
exports.
|
|
13230
|
-
exports.
|
|
13231
|
-
exports.
|
|
13232
|
-
exports.
|
|
13233
|
-
exports.
|
|
13234
|
-
exports.
|
|
13235
|
-
exports.
|
|
13236
|
-
exports.
|
|
13237
|
-
exports.
|
|
13238
|
-
exports.
|
|
13239
|
-
exports.
|
|
13240
|
-
exports.
|
|
13241
|
-
exports.
|
|
13242
|
-
exports.
|
|
13243
|
-
exports.
|
|
13244
|
-
exports.
|
|
13245
|
-
exports.
|
|
13246
|
-
exports.
|
|
13247
|
-
exports.
|
|
13248
|
-
exports.
|
|
13249
|
-
exports.
|
|
13250
|
-
exports.
|
|
13251
|
-
exports.
|
|
13252
|
-
exports.
|
|
13253
|
-
exports.
|
|
13254
|
-
exports.
|
|
13255
|
-
exports.
|
|
13256
|
-
exports.
|
|
13257
|
-
exports.
|
|
13258
|
-
exports.
|
|
13259
|
-
exports.
|
|
13260
|
-
exports.
|
|
13261
|
-
exports.
|
|
13262
|
-
exports.
|
|
13263
|
-
exports.
|
|
13264
|
-
exports.
|
|
13265
|
-
exports.
|
|
13266
|
-
exports.
|
|
13267
|
-
exports.
|
|
13268
|
-
exports.
|
|
13269
|
-
exports.
|
|
13270
|
-
exports.
|
|
13271
|
-
exports.
|
|
13272
|
-
exports.
|
|
13273
|
-
exports.
|
|
13274
|
-
exports.
|
|
13275
|
-
exports.
|
|
13276
|
-
exports.
|
|
13277
|
-
exports.
|
|
13278
|
-
exports.
|
|
13279
|
-
exports.
|
|
13280
|
-
exports.
|
|
13281
|
-
exports.
|
|
13282
|
-
exports.
|
|
13283
|
-
exports.
|
|
13284
|
-
exports.
|
|
13285
|
-
exports.
|
|
13286
|
-
exports.
|
|
13287
|
-
exports.
|
|
13288
|
-
exports.
|
|
13289
|
-
exports.
|
|
13290
|
-
exports.
|
|
13291
|
-
exports.
|
|
13292
|
-
exports.
|
|
13293
|
-
exports.
|
|
13294
|
-
exports.
|
|
13295
|
-
exports.
|
|
13296
|
-
exports.
|
|
13297
|
-
exports.
|
|
13298
|
-
exports.
|
|
13299
|
-
exports.
|
|
13300
|
-
exports.
|
|
13301
|
-
exports.
|
|
13302
|
-
exports.
|
|
13303
|
-
exports.
|
|
13304
|
-
exports.
|
|
13305
|
-
exports.
|
|
13306
|
-
exports.
|
|
13307
|
-
exports.
|
|
13308
|
-
exports.
|
|
13309
|
-
exports.
|
|
13310
|
-
exports.
|
|
13311
|
-
exports.
|
|
13312
|
-
exports.
|
|
13313
|
-
exports.
|
|
13314
|
-
exports.
|
|
13315
|
-
exports.
|
|
13316
|
-
exports.
|
|
13317
|
-
exports.
|
|
13318
|
-
exports.
|
|
13319
|
-
exports.
|
|
13320
|
-
exports.
|
|
13321
|
-
exports.
|
|
13322
|
-
exports.
|
|
13323
|
-
exports.
|
|
13324
|
-
exports.
|
|
13325
|
-
exports.
|
|
13326
|
-
exports.
|
|
13327
|
-
exports.
|
|
13328
|
-
exports.
|
|
13329
|
-
exports.
|
|
13330
|
-
exports.
|
|
13331
|
-
exports.
|
|
13332
|
-
exports.
|
|
13333
|
-
exports.
|
|
13334
|
-
exports.
|
|
13335
|
-
exports.
|
|
13336
|
-
exports.
|
|
13337
|
-
exports.
|
|
13338
|
-
exports.
|
|
13339
|
-
exports.
|
|
13340
|
-
exports.
|
|
13341
|
-
exports.
|
|
13342
|
-
exports
|
|
13343
|
-
return exports;
|
|
13078
|
+
//#endregion
|
|
13079
|
+
exports.ARID = ARID;
|
|
13080
|
+
exports.Argon2idParams = Argon2idParams;
|
|
13081
|
+
exports.AuthenticationTag = AuthenticationTag;
|
|
13082
|
+
Object.defineProperty(exports, "COMPRESSED", {
|
|
13083
|
+
enumerable: true,
|
|
13084
|
+
get: function() {
|
|
13085
|
+
return _bcts_tags.COMPRESSED;
|
|
13086
|
+
}
|
|
13087
|
+
});
|
|
13088
|
+
exports.Compressed = Compressed;
|
|
13089
|
+
exports.CryptoError = CryptoError;
|
|
13090
|
+
exports.DEFAULT_PBKDF2_ITERATIONS = DEFAULT_PBKDF2_ITERATIONS;
|
|
13091
|
+
exports.DEFAULT_SCRYPT_LOG_N = DEFAULT_SCRYPT_LOG_N;
|
|
13092
|
+
exports.DEFAULT_SCRYPT_P = DEFAULT_SCRYPT_P;
|
|
13093
|
+
exports.DEFAULT_SCRYPT_R = DEFAULT_SCRYPT_R;
|
|
13094
|
+
exports.Digest = Digest;
|
|
13095
|
+
exports.ECPrivateKey = ECPrivateKey;
|
|
13096
|
+
exports.ECPublicKey = ECPublicKey;
|
|
13097
|
+
exports.ECUncompressedPublicKey = ECUncompressedPublicKey;
|
|
13098
|
+
Object.defineProperty(exports, "ENCRYPTED", {
|
|
13099
|
+
enumerable: true,
|
|
13100
|
+
get: function() {
|
|
13101
|
+
return _bcts_tags.ENCRYPTED;
|
|
13102
|
+
}
|
|
13103
|
+
});
|
|
13104
|
+
Object.defineProperty(exports, "ENVELOPE", {
|
|
13105
|
+
enumerable: true,
|
|
13106
|
+
get: function() {
|
|
13107
|
+
return _bcts_tags.ENVELOPE;
|
|
13108
|
+
}
|
|
13109
|
+
});
|
|
13110
|
+
exports.Ed25519PrivateKey = Ed25519PrivateKey;
|
|
13111
|
+
exports.Ed25519PublicKey = Ed25519PublicKey;
|
|
13112
|
+
exports.EncapsulationCiphertext = EncapsulationCiphertext;
|
|
13113
|
+
exports.EncapsulationPrivateKey = EncapsulationPrivateKey;
|
|
13114
|
+
exports.EncapsulationPublicKey = EncapsulationPublicKey;
|
|
13115
|
+
exports.EncapsulationScheme = EncapsulationScheme;
|
|
13116
|
+
exports.EncryptedKey = EncryptedKey;
|
|
13117
|
+
exports.EncryptedMessage = EncryptedMessage;
|
|
13118
|
+
exports.ErrorKind = ErrorKind;
|
|
13119
|
+
exports.HKDFParams = HKDFParams;
|
|
13120
|
+
exports.HKDFRng = HKDFRng;
|
|
13121
|
+
exports.HashType = HashType;
|
|
13122
|
+
exports.JSON = JSON;
|
|
13123
|
+
Object.defineProperty(exports, "KNOWN_VALUE", {
|
|
13124
|
+
enumerable: true,
|
|
13125
|
+
get: function() {
|
|
13126
|
+
return _bcts_tags.KNOWN_VALUE;
|
|
13127
|
+
}
|
|
13128
|
+
});
|
|
13129
|
+
exports.KeyDerivationMethod = KeyDerivationMethod;
|
|
13130
|
+
Object.defineProperty(exports, "LEAF", {
|
|
13131
|
+
enumerable: true,
|
|
13132
|
+
get: function() {
|
|
13133
|
+
return _bcts_tags.LEAF;
|
|
13134
|
+
}
|
|
13135
|
+
});
|
|
13136
|
+
exports.MLDSALevel = MLDSALevel;
|
|
13137
|
+
exports.MLDSAPrivateKey = MLDSAPrivateKey;
|
|
13138
|
+
exports.MLDSAPublicKey = MLDSAPublicKey;
|
|
13139
|
+
exports.MLDSASignature = MLDSASignature;
|
|
13140
|
+
exports.MLDSA_KEY_SIZES = MLDSA_KEY_SIZES;
|
|
13141
|
+
exports.MLKEMCiphertext = MLKEMCiphertext;
|
|
13142
|
+
exports.MLKEMLevel = MLKEMLevel;
|
|
13143
|
+
exports.MLKEMPrivateKey = MLKEMPrivateKey;
|
|
13144
|
+
exports.MLKEMPublicKey = MLKEMPublicKey;
|
|
13145
|
+
exports.MLKEM_KEY_SIZES = MLKEM_KEY_SIZES;
|
|
13146
|
+
exports.Nonce = Nonce;
|
|
13147
|
+
exports.PBKDF2Params = PBKDF2Params;
|
|
13148
|
+
exports.PrivateKeyBase = PrivateKeyBase;
|
|
13149
|
+
exports.PrivateKeys = PrivateKeys;
|
|
13150
|
+
exports.PublicKeys = PublicKeys;
|
|
13151
|
+
exports.Reference = Reference;
|
|
13152
|
+
exports.SALT_LEN = SALT_LEN;
|
|
13153
|
+
exports.SR25519_DEFAULT_CONTEXT = SR25519_DEFAULT_CONTEXT;
|
|
13154
|
+
exports.SR25519_PRIVATE_KEY_SIZE = SR25519_PRIVATE_KEY_SIZE;
|
|
13155
|
+
exports.SR25519_PUBLIC_KEY_SIZE = SR25519_PUBLIC_KEY_SIZE;
|
|
13156
|
+
exports.SR25519_SIGNATURE_SIZE = SR25519_SIGNATURE_SIZE;
|
|
13157
|
+
exports.SSHAgentParams = SSHAgentParams;
|
|
13158
|
+
exports.SSKRGroupSpec = _bcts_sskr.GroupSpec;
|
|
13159
|
+
exports.SSKRSecret = _bcts_sskr.Secret;
|
|
13160
|
+
exports.SSKRShare = SSKRShare;
|
|
13161
|
+
exports.SSKRShareCbor = SSKRShareCbor;
|
|
13162
|
+
exports.SSKRSpec = _bcts_sskr.Spec;
|
|
13163
|
+
exports.Salt = Salt;
|
|
13164
|
+
exports.SchnorrPublicKey = SchnorrPublicKey;
|
|
13165
|
+
exports.ScryptParams = ScryptParams;
|
|
13166
|
+
exports.SealedMessage = SealedMessage;
|
|
13167
|
+
exports.Seed = Seed;
|
|
13168
|
+
exports.Signature = Signature;
|
|
13169
|
+
exports.SignatureScheme = SignatureScheme;
|
|
13170
|
+
exports.SigningPrivateKey = SigningPrivateKey;
|
|
13171
|
+
exports.SigningPublicKey = SigningPublicKey;
|
|
13172
|
+
exports.Sr25519PrivateKey = Sr25519PrivateKey;
|
|
13173
|
+
exports.Sr25519PublicKey = Sr25519PublicKey;
|
|
13174
|
+
exports.SymmetricKey = SymmetricKey;
|
|
13175
|
+
exports.URI = URI;
|
|
13176
|
+
exports.UUID = UUID;
|
|
13177
|
+
exports.X25519PrivateKey = X25519PrivateKey;
|
|
13178
|
+
exports.X25519PublicKey = X25519PublicKey;
|
|
13179
|
+
exports.XID = XID;
|
|
13180
|
+
exports.argon2idParams = argon2idParams;
|
|
13181
|
+
exports.bytesEqual = bytesEqual;
|
|
13182
|
+
exports.bytesToHex = bytesToHex;
|
|
13183
|
+
exports.createEncapsulationKeypair = createEncapsulationKeypair;
|
|
13184
|
+
exports.createEncapsulationKeypairUsing = createEncapsulationKeypairUsing;
|
|
13185
|
+
exports.createKeypair = createKeypair;
|
|
13186
|
+
exports.createKeypairUsing = createKeypairUsing;
|
|
13187
|
+
exports.defaultEncapsulationScheme = defaultEncapsulationScheme;
|
|
13188
|
+
exports.defaultKeyDerivationMethod = defaultKeyDerivationMethod;
|
|
13189
|
+
exports.defaultKeyDerivationParams = defaultKeyDerivationParams;
|
|
13190
|
+
exports.defaultSignatureScheme = defaultSignatureScheme;
|
|
13191
|
+
exports.digestFromBytes = digestFromBytes;
|
|
13192
|
+
exports.fromBase64 = fromBase64;
|
|
13193
|
+
exports.hashTypeFromCbor = hashTypeFromCbor;
|
|
13194
|
+
exports.hashTypeToCbor = hashTypeToCbor;
|
|
13195
|
+
exports.hashTypeToString = hashTypeToString;
|
|
13196
|
+
exports.hexToBytes = hexToBytes;
|
|
13197
|
+
exports.hkdfParams = hkdfParams;
|
|
13198
|
+
exports.isCryptoError = isCryptoError;
|
|
13199
|
+
exports.isCryptoErrorKind = isCryptoErrorKind;
|
|
13200
|
+
exports.isDecrypter = isDecrypter;
|
|
13201
|
+
exports.isECKey = isECKey;
|
|
13202
|
+
exports.isECKeyBase = isECKeyBase;
|
|
13203
|
+
exports.isECPublicKeyBase = isECPublicKeyBase;
|
|
13204
|
+
exports.isEncrypter = isEncrypter;
|
|
13205
|
+
exports.isError = isError;
|
|
13206
|
+
exports.isMldsaScheme = isMldsaScheme;
|
|
13207
|
+
exports.isPasswordBased = isPasswordBased;
|
|
13208
|
+
exports.isPrivateKeyDataProvider = isPrivateKeyDataProvider;
|
|
13209
|
+
exports.isReferenceProvider = isReferenceProvider;
|
|
13210
|
+
exports.isSshAgent = isSshAgent;
|
|
13211
|
+
exports.isSshScheme = isSshScheme;
|
|
13212
|
+
exports.keyDerivationMethodFromCbor = keyDerivationMethodFromCbor;
|
|
13213
|
+
exports.keyDerivationMethodFromIndex = keyDerivationMethodFromIndex;
|
|
13214
|
+
exports.keyDerivationMethodIndex = keyDerivationMethodIndex;
|
|
13215
|
+
exports.keyDerivationMethodToString = keyDerivationMethodToString;
|
|
13216
|
+
exports.keyDerivationParamsFromCbor = keyDerivationParamsFromCbor;
|
|
13217
|
+
exports.keyDerivationParamsMethod = keyDerivationParamsMethod;
|
|
13218
|
+
exports.keyDerivationParamsToCbor = keyDerivationParamsToCbor;
|
|
13219
|
+
exports.keyDerivationParamsToCborData = keyDerivationParamsToCborData;
|
|
13220
|
+
exports.keyDerivationParamsToString = keyDerivationParamsToString;
|
|
13221
|
+
exports.lockWithParams = lockWithParams;
|
|
13222
|
+
exports.mldsaGenerateKeypair = mldsaGenerateKeypair;
|
|
13223
|
+
exports.mldsaGenerateKeypairUsing = mldsaGenerateKeypairUsing;
|
|
13224
|
+
exports.mldsaLevelFromValue = mldsaLevelFromValue;
|
|
13225
|
+
exports.mldsaLevelToString = mldsaLevelToString;
|
|
13226
|
+
exports.mldsaPrivateKeySize = mldsaPrivateKeySize;
|
|
13227
|
+
exports.mldsaPublicKeySize = mldsaPublicKeySize;
|
|
13228
|
+
exports.mldsaSign = mldsaSign;
|
|
13229
|
+
exports.mldsaSignatureSize = mldsaSignatureSize;
|
|
13230
|
+
exports.mldsaVerify = mldsaVerify;
|
|
13231
|
+
exports.mlkemCiphertextSize = mlkemCiphertextSize;
|
|
13232
|
+
exports.mlkemDecapsulate = mlkemDecapsulate;
|
|
13233
|
+
exports.mlkemEncapsulate = mlkemEncapsulate;
|
|
13234
|
+
exports.mlkemGenerateKeypair = mlkemGenerateKeypair;
|
|
13235
|
+
exports.mlkemGenerateKeypairUsing = mlkemGenerateKeypairUsing;
|
|
13236
|
+
exports.mlkemLevelFromValue = mlkemLevelFromValue;
|
|
13237
|
+
exports.mlkemLevelToString = mlkemLevelToString;
|
|
13238
|
+
exports.mlkemPrivateKeySize = mlkemPrivateKeySize;
|
|
13239
|
+
exports.mlkemPublicKeySize = mlkemPublicKeySize;
|
|
13240
|
+
exports.mlkemSharedSecretSize = mlkemSharedSecretSize;
|
|
13241
|
+
exports.pbkdf2Params = pbkdf2Params;
|
|
13242
|
+
exports.scryptParams = scryptParams;
|
|
13243
|
+
exports.sshAgentParams = sshAgentParams;
|
|
13244
|
+
exports.sskrCombine = _bcts_sskr.sskrCombine;
|
|
13245
|
+
exports.sskrCombineShares = sskrCombineShares;
|
|
13246
|
+
exports.sskrGenerate = _bcts_sskr.sskrGenerate;
|
|
13247
|
+
exports.sskrGenerateShares = sskrGenerateShares;
|
|
13248
|
+
exports.sskrGenerateSharesUsing = sskrGenerateSharesUsing;
|
|
13249
|
+
exports.sskrGenerateUsing = _bcts_sskr.sskrGenerateUsing;
|
|
13250
|
+
exports.toBase64 = toBase64;
|
|
13251
|
+
return exports;
|
|
13344
13252
|
})({}, bctsDcbor, bctsTags, pako, bctsCrypto, bctsUniformResources, bctsRand, scureSr25519, nobleHashesBlake2, noblePostQuantumMldsa, noblePostQuantumMlkem, bctsSskr);
|
|
13253
|
+
|
|
13345
13254
|
//# sourceMappingURL=index.iife.js.map
|