@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.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -6,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
9
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
19
16
|
}
|
|
20
17
|
return to;
|
|
21
18
|
};
|
|
@@ -23,9 +20,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
20
|
value: mod,
|
|
24
21
|
enumerable: true
|
|
25
22
|
}) : target, mod));
|
|
26
|
-
|
|
27
23
|
//#endregion
|
|
28
|
-
const require_digest = require(
|
|
24
|
+
const require_digest = require("./digest-DL5sTq8T.cjs");
|
|
29
25
|
let _bcts_dcbor = require("@bcts/dcbor");
|
|
30
26
|
let _bcts_tags = require("@bcts/tags");
|
|
31
27
|
let pako = require("pako");
|
|
@@ -33,12 +29,11 @@ let _bcts_crypto = require("@bcts/crypto");
|
|
|
33
29
|
let _bcts_uniform_resources = require("@bcts/uniform-resources");
|
|
34
30
|
let _bcts_rand = require("@bcts/rand");
|
|
35
31
|
let _scure_sr25519 = require("@scure/sr25519");
|
|
36
|
-
_scure_sr25519 = __toESM(_scure_sr25519);
|
|
32
|
+
_scure_sr25519 = __toESM(_scure_sr25519, 1);
|
|
37
33
|
let _noble_hashes_blake2_js = require("@noble/hashes/blake2.js");
|
|
38
34
|
let _noble_post_quantum_ml_dsa_js = require("@noble/post-quantum/ml-dsa.js");
|
|
39
35
|
let _noble_post_quantum_ml_kem_js = require("@noble/post-quantum/ml-kem.js");
|
|
40
36
|
let _bcts_sskr = require("@bcts/sskr");
|
|
41
|
-
|
|
42
37
|
//#region src/private-key-data-provider.ts
|
|
43
38
|
/**
|
|
44
39
|
* Type guard to check if an object implements PrivateKeyDataProvider
|
|
@@ -46,7 +41,6 @@ let _bcts_sskr = require("@bcts/sskr");
|
|
|
46
41
|
function isPrivateKeyDataProvider(obj) {
|
|
47
42
|
return typeof obj === "object" && obj !== null && "privateKeyData" in obj && typeof obj.privateKeyData === "function";
|
|
48
43
|
}
|
|
49
|
-
|
|
50
44
|
//#endregion
|
|
51
45
|
//#region src/encrypter.ts
|
|
52
46
|
/**
|
|
@@ -61,7 +55,6 @@ function isEncrypter(obj) {
|
|
|
61
55
|
function isDecrypter(obj) {
|
|
62
56
|
return typeof obj === "object" && obj !== null && "encapsulationPrivateKey" in obj && typeof obj.encapsulationPrivateKey === "function" && "decapsulateSharedSecret" in obj && typeof obj.decapsulateSharedSecret === "function";
|
|
63
57
|
}
|
|
64
|
-
|
|
65
58
|
//#endregion
|
|
66
59
|
//#region src/json.ts
|
|
67
60
|
/**
|
|
@@ -241,7 +234,6 @@ var JSON = class JSON {
|
|
|
241
234
|
return JSON.fromString("").fromUntaggedCbor(cborValue);
|
|
242
235
|
}
|
|
243
236
|
};
|
|
244
|
-
|
|
245
237
|
//#endregion
|
|
246
238
|
//#region src/compressed.ts
|
|
247
239
|
/**
|
|
@@ -528,7 +520,6 @@ var Compressed = class Compressed {
|
|
|
528
520
|
return Compressed.fromDecompressedData(new Uint8Array(0)).fromUntaggedCbor(cborValue);
|
|
529
521
|
}
|
|
530
522
|
};
|
|
531
|
-
|
|
532
523
|
//#endregion
|
|
533
524
|
//#region src/hkdf-rng.ts
|
|
534
525
|
/**
|
|
@@ -741,7 +732,6 @@ var HKDFRng = class HKDFRng {
|
|
|
741
732
|
return this._pageIndex;
|
|
742
733
|
}
|
|
743
734
|
};
|
|
744
|
-
|
|
745
735
|
//#endregion
|
|
746
736
|
//#region src/digest-provider.ts
|
|
747
737
|
/**
|
|
@@ -752,10 +742,9 @@ var HKDFRng = class HKDFRng {
|
|
|
752
742
|
* @returns A Promise resolving to a Digest of the data
|
|
753
743
|
*/
|
|
754
744
|
async function digestFromBytes(data) {
|
|
755
|
-
const { Digest
|
|
756
|
-
return Digest
|
|
745
|
+
const { Digest } = await Promise.resolve().then(() => require("./digest-DRakTOWS.cjs"));
|
|
746
|
+
return Digest.fromImage(data);
|
|
757
747
|
}
|
|
758
|
-
|
|
759
748
|
//#endregion
|
|
760
749
|
//#region src/nonce.ts
|
|
761
750
|
/**
|
|
@@ -938,30 +927,30 @@ var Nonce = class Nonce {
|
|
|
938
927
|
/**
|
|
939
928
|
* Creates a Nonce by decoding it from untagged CBOR.
|
|
940
929
|
*/
|
|
941
|
-
fromUntaggedCbor(cbor
|
|
942
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
930
|
+
fromUntaggedCbor(cbor) {
|
|
931
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
943
932
|
return Nonce.fromDataRef(data);
|
|
944
933
|
}
|
|
945
934
|
/**
|
|
946
935
|
* Creates a Nonce by decoding it from tagged CBOR.
|
|
947
936
|
*/
|
|
948
|
-
fromTaggedCbor(cbor
|
|
949
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
950
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
937
|
+
fromTaggedCbor(cbor) {
|
|
938
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
939
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
951
940
|
return this.fromUntaggedCbor(content);
|
|
952
941
|
}
|
|
953
942
|
/**
|
|
954
943
|
* Static method to decode from tagged CBOR.
|
|
955
944
|
*/
|
|
956
|
-
static fromTaggedCbor(cbor
|
|
957
|
-
return new Nonce(new Uint8Array(Nonce.NONCE_SIZE)).fromTaggedCbor(cbor
|
|
945
|
+
static fromTaggedCbor(cbor) {
|
|
946
|
+
return new Nonce(new Uint8Array(Nonce.NONCE_SIZE)).fromTaggedCbor(cbor);
|
|
958
947
|
}
|
|
959
948
|
/**
|
|
960
949
|
* Static method to decode from tagged CBOR binary data.
|
|
961
950
|
*/
|
|
962
951
|
static fromTaggedCborData(data) {
|
|
963
|
-
const cbor
|
|
964
|
-
return Nonce.fromTaggedCbor(cbor
|
|
952
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
953
|
+
return Nonce.fromTaggedCbor(cbor);
|
|
965
954
|
}
|
|
966
955
|
/**
|
|
967
956
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -998,7 +987,6 @@ var Nonce = class Nonce {
|
|
|
998
987
|
return Nonce.fromUR(ur);
|
|
999
988
|
}
|
|
1000
989
|
};
|
|
1001
|
-
|
|
1002
990
|
//#endregion
|
|
1003
991
|
//#region src/salt.ts
|
|
1004
992
|
/**
|
|
@@ -1246,30 +1234,30 @@ var Salt = class Salt {
|
|
|
1246
1234
|
/**
|
|
1247
1235
|
* Creates a Salt by decoding it from untagged CBOR.
|
|
1248
1236
|
*/
|
|
1249
|
-
fromUntaggedCbor(cbor
|
|
1250
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
1237
|
+
fromUntaggedCbor(cbor) {
|
|
1238
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
1251
1239
|
return Salt.fromData(data);
|
|
1252
1240
|
}
|
|
1253
1241
|
/**
|
|
1254
1242
|
* Creates a Salt by decoding it from tagged CBOR.
|
|
1255
1243
|
*/
|
|
1256
|
-
fromTaggedCbor(cbor
|
|
1257
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
1258
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
1244
|
+
fromTaggedCbor(cbor) {
|
|
1245
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
1246
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
1259
1247
|
return this.fromUntaggedCbor(content);
|
|
1260
1248
|
}
|
|
1261
1249
|
/**
|
|
1262
1250
|
* Static method to decode from tagged CBOR.
|
|
1263
1251
|
*/
|
|
1264
|
-
static fromTaggedCbor(cbor
|
|
1265
|
-
return new Salt(new Uint8Array(0)).fromTaggedCbor(cbor
|
|
1252
|
+
static fromTaggedCbor(cbor) {
|
|
1253
|
+
return new Salt(new Uint8Array(0)).fromTaggedCbor(cbor);
|
|
1266
1254
|
}
|
|
1267
1255
|
/**
|
|
1268
1256
|
* Static method to decode from tagged CBOR binary data.
|
|
1269
1257
|
*/
|
|
1270
1258
|
static fromTaggedCborData(data) {
|
|
1271
|
-
const cbor
|
|
1272
|
-
return Salt.fromTaggedCbor(cbor
|
|
1259
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
1260
|
+
return Salt.fromTaggedCbor(cbor);
|
|
1273
1261
|
}
|
|
1274
1262
|
/**
|
|
1275
1263
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -1306,7 +1294,6 @@ var Salt = class Salt {
|
|
|
1306
1294
|
return Salt.fromUR(ur);
|
|
1307
1295
|
}
|
|
1308
1296
|
};
|
|
1309
|
-
|
|
1310
1297
|
//#endregion
|
|
1311
1298
|
//#region src/seed.ts
|
|
1312
1299
|
/**
|
|
@@ -1655,9 +1642,9 @@ var Seed = class Seed {
|
|
|
1655
1642
|
/**
|
|
1656
1643
|
* Creates a Seed by decoding it from tagged CBOR.
|
|
1657
1644
|
*/
|
|
1658
|
-
fromTaggedCbor(cbor
|
|
1659
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
1660
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
1645
|
+
fromTaggedCbor(cbor) {
|
|
1646
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
1647
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
1661
1648
|
return this.fromUntaggedCbor(content);
|
|
1662
1649
|
}
|
|
1663
1650
|
/**
|
|
@@ -1708,7 +1695,6 @@ var Seed = class Seed {
|
|
|
1708
1695
|
return Seed.fromUR(ur);
|
|
1709
1696
|
}
|
|
1710
1697
|
};
|
|
1711
|
-
|
|
1712
1698
|
//#endregion
|
|
1713
1699
|
//#region src/reference.ts
|
|
1714
1700
|
/**
|
|
@@ -1858,7 +1844,6 @@ var Reference = class Reference {
|
|
|
1858
1844
|
return `Reference(${this.shortReference("hex")})`;
|
|
1859
1845
|
}
|
|
1860
1846
|
};
|
|
1861
|
-
|
|
1862
1847
|
//#endregion
|
|
1863
1848
|
//#region src/id/arid.ts
|
|
1864
1849
|
/**
|
|
@@ -2054,30 +2039,30 @@ var ARID = class ARID {
|
|
|
2054
2039
|
/**
|
|
2055
2040
|
* Creates an ARID by decoding it from untagged CBOR.
|
|
2056
2041
|
*/
|
|
2057
|
-
fromUntaggedCbor(cbor
|
|
2058
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
2042
|
+
fromUntaggedCbor(cbor) {
|
|
2043
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
2059
2044
|
return ARID.fromDataRef(data);
|
|
2060
2045
|
}
|
|
2061
2046
|
/**
|
|
2062
2047
|
* Creates an ARID by decoding it from tagged CBOR.
|
|
2063
2048
|
*/
|
|
2064
|
-
fromTaggedCbor(cbor
|
|
2065
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
2066
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
2049
|
+
fromTaggedCbor(cbor) {
|
|
2050
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
2051
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
2067
2052
|
return this.fromUntaggedCbor(content);
|
|
2068
2053
|
}
|
|
2069
2054
|
/**
|
|
2070
2055
|
* Static method to decode from tagged CBOR.
|
|
2071
2056
|
*/
|
|
2072
|
-
static fromTaggedCbor(cbor
|
|
2073
|
-
return new ARID(new Uint8Array(ARID.ARID_SIZE)).fromTaggedCbor(cbor
|
|
2057
|
+
static fromTaggedCbor(cbor) {
|
|
2058
|
+
return new ARID(new Uint8Array(ARID.ARID_SIZE)).fromTaggedCbor(cbor);
|
|
2074
2059
|
}
|
|
2075
2060
|
/**
|
|
2076
2061
|
* Static method to decode from tagged CBOR binary data.
|
|
2077
2062
|
*/
|
|
2078
2063
|
static fromTaggedCborData(data) {
|
|
2079
|
-
const cbor
|
|
2080
|
-
return ARID.fromTaggedCbor(cbor
|
|
2064
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
2065
|
+
return ARID.fromTaggedCbor(cbor);
|
|
2081
2066
|
}
|
|
2082
2067
|
/**
|
|
2083
2068
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -2120,7 +2105,6 @@ var ARID = class ARID {
|
|
|
2120
2105
|
return ARID.fromURString(urString);
|
|
2121
2106
|
}
|
|
2122
2107
|
};
|
|
2123
|
-
|
|
2124
2108
|
//#endregion
|
|
2125
2109
|
//#region src/id/uuid.ts
|
|
2126
2110
|
/**
|
|
@@ -2295,30 +2279,30 @@ var UUID = class UUID {
|
|
|
2295
2279
|
/**
|
|
2296
2280
|
* Creates a UUID by decoding it from untagged CBOR.
|
|
2297
2281
|
*/
|
|
2298
|
-
fromUntaggedCbor(cbor
|
|
2299
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
2282
|
+
fromUntaggedCbor(cbor) {
|
|
2283
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
2300
2284
|
return UUID.fromDataRef(data);
|
|
2301
2285
|
}
|
|
2302
2286
|
/**
|
|
2303
2287
|
* Creates a UUID by decoding it from tagged CBOR.
|
|
2304
2288
|
*/
|
|
2305
|
-
fromTaggedCbor(cbor
|
|
2306
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
2307
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
2289
|
+
fromTaggedCbor(cbor) {
|
|
2290
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
2291
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
2308
2292
|
return this.fromUntaggedCbor(content);
|
|
2309
2293
|
}
|
|
2310
2294
|
/**
|
|
2311
2295
|
* Static method to decode from tagged CBOR.
|
|
2312
2296
|
*/
|
|
2313
|
-
static fromTaggedCbor(cbor
|
|
2314
|
-
return new UUID(new Uint8Array(UUID_SIZE)).fromTaggedCbor(cbor
|
|
2297
|
+
static fromTaggedCbor(cbor) {
|
|
2298
|
+
return new UUID(new Uint8Array(UUID_SIZE)).fromTaggedCbor(cbor);
|
|
2315
2299
|
}
|
|
2316
2300
|
/**
|
|
2317
2301
|
* Static method to decode from tagged CBOR binary data.
|
|
2318
2302
|
*/
|
|
2319
2303
|
static fromTaggedCborData(data) {
|
|
2320
|
-
const cbor
|
|
2321
|
-
return UUID.fromTaggedCbor(cbor
|
|
2304
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
2305
|
+
return UUID.fromTaggedCbor(cbor);
|
|
2322
2306
|
}
|
|
2323
2307
|
/**
|
|
2324
2308
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -2355,7 +2339,6 @@ var UUID = class UUID {
|
|
|
2355
2339
|
return UUID.fromUR(ur);
|
|
2356
2340
|
}
|
|
2357
2341
|
};
|
|
2358
|
-
|
|
2359
2342
|
//#endregion
|
|
2360
2343
|
//#region src/id/xid.ts
|
|
2361
2344
|
/**
|
|
@@ -2572,30 +2555,30 @@ var XID = class XID {
|
|
|
2572
2555
|
/**
|
|
2573
2556
|
* Creates a XID by decoding it from untagged CBOR.
|
|
2574
2557
|
*/
|
|
2575
|
-
fromUntaggedCbor(cbor
|
|
2576
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
2558
|
+
fromUntaggedCbor(cbor) {
|
|
2559
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
2577
2560
|
return XID.fromDataRef(data);
|
|
2578
2561
|
}
|
|
2579
2562
|
/**
|
|
2580
2563
|
* Creates a XID by decoding it from tagged CBOR.
|
|
2581
2564
|
*/
|
|
2582
|
-
fromTaggedCbor(cbor
|
|
2583
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
2584
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
2565
|
+
fromTaggedCbor(cbor) {
|
|
2566
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
2567
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
2585
2568
|
return this.fromUntaggedCbor(content);
|
|
2586
2569
|
}
|
|
2587
2570
|
/**
|
|
2588
2571
|
* Static method to decode from tagged CBOR.
|
|
2589
2572
|
*/
|
|
2590
|
-
static fromTaggedCbor(cbor
|
|
2591
|
-
return new XID(new Uint8Array(XID_SIZE)).fromTaggedCbor(cbor
|
|
2573
|
+
static fromTaggedCbor(cbor) {
|
|
2574
|
+
return new XID(new Uint8Array(XID_SIZE)).fromTaggedCbor(cbor);
|
|
2592
2575
|
}
|
|
2593
2576
|
/**
|
|
2594
2577
|
* Static method to decode from tagged CBOR binary data.
|
|
2595
2578
|
*/
|
|
2596
2579
|
static fromTaggedCborData(data) {
|
|
2597
|
-
const cbor
|
|
2598
|
-
return XID.fromTaggedCbor(cbor
|
|
2580
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
2581
|
+
return XID.fromTaggedCbor(cbor);
|
|
2599
2582
|
}
|
|
2600
2583
|
/**
|
|
2601
2584
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -2632,7 +2615,6 @@ var XID = class XID {
|
|
|
2632
2615
|
return XID.fromUR(ur);
|
|
2633
2616
|
}
|
|
2634
2617
|
};
|
|
2635
|
-
|
|
2636
2618
|
//#endregion
|
|
2637
2619
|
//#region src/id/uri.ts
|
|
2638
2620
|
/**
|
|
@@ -2853,7 +2835,6 @@ var URI = class URI {
|
|
|
2853
2835
|
return URI.fromUR(ur);
|
|
2854
2836
|
}
|
|
2855
2837
|
};
|
|
2856
|
-
|
|
2857
2838
|
//#endregion
|
|
2858
2839
|
//#region src/x25519/x25519-public-key.ts
|
|
2859
2840
|
/**
|
|
@@ -2987,37 +2968,37 @@ var X25519PublicKey = class X25519PublicKey {
|
|
|
2987
2968
|
/**
|
|
2988
2969
|
* Creates an X25519PublicKey by decoding it from untagged CBOR.
|
|
2989
2970
|
*/
|
|
2990
|
-
fromUntaggedCbor(cbor
|
|
2991
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
2971
|
+
fromUntaggedCbor(cbor) {
|
|
2972
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
2992
2973
|
return X25519PublicKey.fromDataRef(data);
|
|
2993
2974
|
}
|
|
2994
2975
|
/**
|
|
2995
2976
|
* Creates an X25519PublicKey by decoding it from tagged CBOR.
|
|
2996
2977
|
*/
|
|
2997
|
-
fromTaggedCbor(cbor
|
|
2998
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
2999
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
2978
|
+
fromTaggedCbor(cbor) {
|
|
2979
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
2980
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
3000
2981
|
return this.fromUntaggedCbor(content);
|
|
3001
2982
|
}
|
|
3002
2983
|
/**
|
|
3003
2984
|
* Static method to decode from tagged CBOR.
|
|
3004
2985
|
*/
|
|
3005
|
-
static fromTaggedCbor(cbor
|
|
3006
|
-
return new X25519PublicKey(new Uint8Array(_bcts_crypto.X25519_PUBLIC_KEY_SIZE)).fromTaggedCbor(cbor
|
|
2986
|
+
static fromTaggedCbor(cbor) {
|
|
2987
|
+
return new X25519PublicKey(new Uint8Array(_bcts_crypto.X25519_PUBLIC_KEY_SIZE)).fromTaggedCbor(cbor);
|
|
3007
2988
|
}
|
|
3008
2989
|
/**
|
|
3009
2990
|
* Static method to decode from tagged CBOR binary data.
|
|
3010
2991
|
*/
|
|
3011
2992
|
static fromTaggedCborData(data) {
|
|
3012
|
-
const cbor
|
|
3013
|
-
return X25519PublicKey.fromTaggedCbor(cbor
|
|
2993
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
2994
|
+
return X25519PublicKey.fromTaggedCbor(cbor);
|
|
3014
2995
|
}
|
|
3015
2996
|
/**
|
|
3016
2997
|
* Static method to decode from untagged CBOR binary data.
|
|
3017
2998
|
*/
|
|
3018
2999
|
static fromUntaggedCborData(data) {
|
|
3019
|
-
const cbor
|
|
3020
|
-
return new X25519PublicKey(new Uint8Array(_bcts_crypto.X25519_PUBLIC_KEY_SIZE)).fromUntaggedCbor(cbor
|
|
3000
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
3001
|
+
return new X25519PublicKey(new Uint8Array(_bcts_crypto.X25519_PUBLIC_KEY_SIZE)).fromUntaggedCbor(cbor);
|
|
3021
3002
|
}
|
|
3022
3003
|
/**
|
|
3023
3004
|
* Returns the UR representation of the X25519PublicKey.
|
|
@@ -3051,7 +3032,6 @@ var X25519PublicKey = class X25519PublicKey {
|
|
|
3051
3032
|
return X25519PublicKey.fromUR(ur);
|
|
3052
3033
|
}
|
|
3053
3034
|
};
|
|
3054
|
-
|
|
3055
3035
|
//#endregion
|
|
3056
3036
|
//#region src/symmetric/authentication-tag.ts
|
|
3057
3037
|
/**
|
|
@@ -3168,19 +3148,18 @@ var AuthenticationTag = class AuthenticationTag {
|
|
|
3168
3148
|
/**
|
|
3169
3149
|
* Creates an AuthenticationTag from CBOR.
|
|
3170
3150
|
*/
|
|
3171
|
-
static fromCbor(cbor
|
|
3172
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
3151
|
+
static fromCbor(cbor) {
|
|
3152
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
3173
3153
|
return AuthenticationTag.fromDataRef(data);
|
|
3174
3154
|
}
|
|
3175
3155
|
/**
|
|
3176
3156
|
* Creates an AuthenticationTag from CBOR binary data.
|
|
3177
3157
|
*/
|
|
3178
3158
|
static fromCborData(data) {
|
|
3179
|
-
const cbor
|
|
3180
|
-
return AuthenticationTag.fromCbor(cbor
|
|
3159
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
3160
|
+
return AuthenticationTag.fromCbor(cbor);
|
|
3181
3161
|
}
|
|
3182
3162
|
};
|
|
3183
|
-
|
|
3184
3163
|
//#endregion
|
|
3185
3164
|
//#region src/symmetric/encrypted-message.ts
|
|
3186
3165
|
/**
|
|
@@ -3420,7 +3399,6 @@ var EncryptedMessage = class EncryptedMessage {
|
|
|
3420
3399
|
return EncryptedMessage.fromUR(ur);
|
|
3421
3400
|
}
|
|
3422
3401
|
};
|
|
3423
|
-
|
|
3424
3402
|
//#endregion
|
|
3425
3403
|
//#region src/symmetric/symmetric-key.ts
|
|
3426
3404
|
/**
|
|
@@ -3592,30 +3570,30 @@ var SymmetricKey = class SymmetricKey {
|
|
|
3592
3570
|
/**
|
|
3593
3571
|
* Creates a SymmetricKey by decoding it from untagged CBOR.
|
|
3594
3572
|
*/
|
|
3595
|
-
fromUntaggedCbor(cbor
|
|
3596
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
3573
|
+
fromUntaggedCbor(cbor) {
|
|
3574
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
3597
3575
|
return SymmetricKey.fromDataRef(data);
|
|
3598
3576
|
}
|
|
3599
3577
|
/**
|
|
3600
3578
|
* Creates a SymmetricKey by decoding it from tagged CBOR.
|
|
3601
3579
|
*/
|
|
3602
|
-
fromTaggedCbor(cbor
|
|
3603
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
3604
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
3580
|
+
fromTaggedCbor(cbor) {
|
|
3581
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
3582
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
3605
3583
|
return this.fromUntaggedCbor(content);
|
|
3606
3584
|
}
|
|
3607
3585
|
/**
|
|
3608
3586
|
* Static method to decode from tagged CBOR.
|
|
3609
3587
|
*/
|
|
3610
|
-
static fromTaggedCbor(cbor
|
|
3611
|
-
return new SymmetricKey(new Uint8Array(SYMMETRIC_KEY_SIZE)).fromTaggedCbor(cbor
|
|
3588
|
+
static fromTaggedCbor(cbor) {
|
|
3589
|
+
return new SymmetricKey(new Uint8Array(SYMMETRIC_KEY_SIZE)).fromTaggedCbor(cbor);
|
|
3612
3590
|
}
|
|
3613
3591
|
/**
|
|
3614
3592
|
* Static method to decode from tagged CBOR binary data.
|
|
3615
3593
|
*/
|
|
3616
3594
|
static fromTaggedCborData(data) {
|
|
3617
|
-
const cbor
|
|
3618
|
-
return SymmetricKey.fromTaggedCbor(cbor
|
|
3595
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
3596
|
+
return SymmetricKey.fromTaggedCbor(cbor);
|
|
3619
3597
|
}
|
|
3620
3598
|
/**
|
|
3621
3599
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -3661,7 +3639,6 @@ var SymmetricKey = class SymmetricKey {
|
|
|
3661
3639
|
return SymmetricKey.fromURString(urString);
|
|
3662
3640
|
}
|
|
3663
3641
|
};
|
|
3664
|
-
|
|
3665
3642
|
//#endregion
|
|
3666
3643
|
//#region src/x25519/x25519-private-key.ts
|
|
3667
3644
|
/**
|
|
@@ -3873,37 +3850,37 @@ var X25519PrivateKey = class X25519PrivateKey {
|
|
|
3873
3850
|
/**
|
|
3874
3851
|
* Creates an X25519PrivateKey by decoding it from untagged CBOR.
|
|
3875
3852
|
*/
|
|
3876
|
-
fromUntaggedCbor(cbor
|
|
3877
|
-
const data = (0, _bcts_dcbor.expectBytes)(cbor
|
|
3853
|
+
fromUntaggedCbor(cbor) {
|
|
3854
|
+
const data = (0, _bcts_dcbor.expectBytes)(cbor);
|
|
3878
3855
|
return X25519PrivateKey.fromDataRef(data);
|
|
3879
3856
|
}
|
|
3880
3857
|
/**
|
|
3881
3858
|
* Creates an X25519PrivateKey by decoding it from tagged CBOR.
|
|
3882
3859
|
*/
|
|
3883
|
-
fromTaggedCbor(cbor
|
|
3884
|
-
(0, _bcts_dcbor.validateTag)(cbor
|
|
3885
|
-
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor
|
|
3860
|
+
fromTaggedCbor(cbor) {
|
|
3861
|
+
(0, _bcts_dcbor.validateTag)(cbor, this.cborTags());
|
|
3862
|
+
const content = (0, _bcts_dcbor.extractTaggedContent)(cbor);
|
|
3886
3863
|
return this.fromUntaggedCbor(content);
|
|
3887
3864
|
}
|
|
3888
3865
|
/**
|
|
3889
3866
|
* Static method to decode from tagged CBOR.
|
|
3890
3867
|
*/
|
|
3891
|
-
static fromTaggedCbor(cbor
|
|
3892
|
-
return new X25519PrivateKey(new Uint8Array(_bcts_crypto.X25519_PRIVATE_KEY_SIZE)).fromTaggedCbor(cbor
|
|
3868
|
+
static fromTaggedCbor(cbor) {
|
|
3869
|
+
return new X25519PrivateKey(new Uint8Array(_bcts_crypto.X25519_PRIVATE_KEY_SIZE)).fromTaggedCbor(cbor);
|
|
3893
3870
|
}
|
|
3894
3871
|
/**
|
|
3895
3872
|
* Static method to decode from tagged CBOR binary data.
|
|
3896
3873
|
*/
|
|
3897
3874
|
static fromTaggedCborData(data) {
|
|
3898
|
-
const cbor
|
|
3899
|
-
return X25519PrivateKey.fromTaggedCbor(cbor
|
|
3875
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
3876
|
+
return X25519PrivateKey.fromTaggedCbor(cbor);
|
|
3900
3877
|
}
|
|
3901
3878
|
/**
|
|
3902
3879
|
* Static method to decode from untagged CBOR binary data.
|
|
3903
3880
|
*/
|
|
3904
3881
|
static fromUntaggedCborData(data) {
|
|
3905
|
-
const cbor
|
|
3906
|
-
return new X25519PrivateKey(new Uint8Array(_bcts_crypto.X25519_PRIVATE_KEY_SIZE)).fromUntaggedCbor(cbor
|
|
3882
|
+
const cbor = (0, _bcts_dcbor.decodeCbor)(data);
|
|
3883
|
+
return new X25519PrivateKey(new Uint8Array(_bcts_crypto.X25519_PRIVATE_KEY_SIZE)).fromUntaggedCbor(cbor);
|
|
3907
3884
|
}
|
|
3908
3885
|
/**
|
|
3909
3886
|
* Returns the UR representation of the X25519PrivateKey.
|
|
@@ -3937,7 +3914,6 @@ var X25519PrivateKey = class X25519PrivateKey {
|
|
|
3937
3914
|
return X25519PrivateKey.fromUR(ur);
|
|
3938
3915
|
}
|
|
3939
3916
|
};
|
|
3940
|
-
|
|
3941
3917
|
//#endregion
|
|
3942
3918
|
//#region src/ed25519/ed25519-public-key.ts
|
|
3943
3919
|
/**
|
|
@@ -4010,7 +3986,6 @@ var Ed25519PublicKey = class Ed25519PublicKey {
|
|
|
4010
3986
|
return `Ed25519PublicKey(${this.toHex().substring(0, 16)}...)`;
|
|
4011
3987
|
}
|
|
4012
3988
|
};
|
|
4013
|
-
|
|
4014
3989
|
//#endregion
|
|
4015
3990
|
//#region src/ed25519/ed25519-private-key.ts
|
|
4016
3991
|
/**
|
|
@@ -4106,7 +4081,6 @@ var Ed25519PrivateKey = class Ed25519PrivateKey {
|
|
|
4106
4081
|
return `Ed25519PrivateKey(${this.toHex().substring(0, 16)}...)`;
|
|
4107
4082
|
}
|
|
4108
4083
|
};
|
|
4109
|
-
|
|
4110
4084
|
//#endregion
|
|
4111
4085
|
//#region src/sr25519/sr25519-public-key.ts
|
|
4112
4086
|
/**
|
|
@@ -4131,7 +4105,7 @@ var Ed25519PrivateKey = class Ed25519PrivateKey {
|
|
|
4131
4105
|
var Sr25519PublicKey = class Sr25519PublicKey {
|
|
4132
4106
|
_data;
|
|
4133
4107
|
constructor(data) {
|
|
4134
|
-
if (data.length !==
|
|
4108
|
+
if (data.length !== 32) throw new Error(`Sr25519PublicKey must be 32 bytes, got ${data.length}`);
|
|
4135
4109
|
this._data = new Uint8Array(data);
|
|
4136
4110
|
}
|
|
4137
4111
|
/**
|
|
@@ -4211,7 +4185,6 @@ var Sr25519PublicKey = class Sr25519PublicKey {
|
|
|
4211
4185
|
return `Sr25519PublicKey(${require_digest.bytesToHex(this._data).substring(0, 16)}...)`;
|
|
4212
4186
|
}
|
|
4213
4187
|
};
|
|
4214
|
-
|
|
4215
4188
|
//#endregion
|
|
4216
4189
|
//#region src/sr25519/sr25519-private-key.ts
|
|
4217
4190
|
/**
|
|
@@ -4250,7 +4223,7 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
|
|
|
4250
4223
|
_seed;
|
|
4251
4224
|
_cachedPublicKey;
|
|
4252
4225
|
constructor(seed) {
|
|
4253
|
-
if (seed.length !==
|
|
4226
|
+
if (seed.length !== 32) throw new Error(`Sr25519PrivateKey seed must be 32 bytes, got ${seed.length}`);
|
|
4254
4227
|
this._seed = new Uint8Array(seed);
|
|
4255
4228
|
}
|
|
4256
4229
|
/**
|
|
@@ -4264,7 +4237,7 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
|
|
|
4264
4237
|
* Create a new random Sr25519 private key using the provided RNG.
|
|
4265
4238
|
*/
|
|
4266
4239
|
static randomUsing(rng) {
|
|
4267
|
-
return new Sr25519PrivateKey(rng.randomData(
|
|
4240
|
+
return new Sr25519PrivateKey(rng.randomData(32));
|
|
4268
4241
|
}
|
|
4269
4242
|
/**
|
|
4270
4243
|
* Create an Sr25519 private key from a 32-byte seed.
|
|
@@ -4295,7 +4268,7 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
|
|
|
4295
4268
|
* @returns A new Sr25519 private key
|
|
4296
4269
|
*/
|
|
4297
4270
|
static deriveFromKeyMaterial(keyMaterial) {
|
|
4298
|
-
return new Sr25519PrivateKey((0, _noble_hashes_blake2_js.blake2b)(keyMaterial, { dkLen:
|
|
4271
|
+
return new Sr25519PrivateKey((0, _noble_hashes_blake2_js.blake2b)(keyMaterial, { dkLen: 32 }));
|
|
4299
4272
|
}
|
|
4300
4273
|
/**
|
|
4301
4274
|
* Generate a keypair and return both private and public keys.
|
|
@@ -4384,7 +4357,6 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
|
|
|
4384
4357
|
return `Sr25519PrivateKey(${require_digest.bytesToHex(this._seed).substring(0, 8)}...)`;
|
|
4385
4358
|
}
|
|
4386
4359
|
};
|
|
4387
|
-
|
|
4388
4360
|
//#endregion
|
|
4389
4361
|
//#region src/ec-key/ec-key-base.ts
|
|
4390
4362
|
/**
|
|
@@ -4409,7 +4381,6 @@ function isECPublicKeyBase(obj) {
|
|
|
4409
4381
|
if (!isECKey(obj)) return false;
|
|
4410
4382
|
return typeof obj.uncompressedPublicKey === "function";
|
|
4411
4383
|
}
|
|
4412
|
-
|
|
4413
4384
|
//#endregion
|
|
4414
4385
|
//#region src/ec-key/ec-uncompressed-public-key.ts
|
|
4415
4386
|
/**
|
|
@@ -4623,7 +4594,6 @@ var ECUncompressedPublicKey = class ECUncompressedPublicKey {
|
|
|
4623
4594
|
return ECUncompressedPublicKey.fromUR(ur);
|
|
4624
4595
|
}
|
|
4625
4596
|
};
|
|
4626
|
-
|
|
4627
4597
|
//#endregion
|
|
4628
4598
|
//#region src/ec-key/ec-public-key.ts
|
|
4629
4599
|
/**
|
|
@@ -4863,7 +4833,6 @@ var ECPublicKey = class ECPublicKey {
|
|
|
4863
4833
|
return ECPublicKey.fromUR(ur);
|
|
4864
4834
|
}
|
|
4865
4835
|
};
|
|
4866
|
-
|
|
4867
4836
|
//#endregion
|
|
4868
4837
|
//#region src/ec-key/schnorr-public-key.ts
|
|
4869
4838
|
/**
|
|
@@ -4986,7 +4955,6 @@ var SchnorrPublicKey = class SchnorrPublicKey {
|
|
|
4986
4955
|
return `SchnorrPublicKey(${this.toHex().substring(0, 16)}...)`;
|
|
4987
4956
|
}
|
|
4988
4957
|
};
|
|
4989
|
-
|
|
4990
4958
|
//#endregion
|
|
4991
4959
|
//#region src/ec-key/ec-private-key.ts
|
|
4992
4960
|
/**
|
|
@@ -5301,7 +5269,6 @@ var ECPrivateKey = class ECPrivateKey {
|
|
|
5301
5269
|
return ECPrivateKey.fromUR(ur);
|
|
5302
5270
|
}
|
|
5303
5271
|
};
|
|
5304
|
-
|
|
5305
5272
|
//#endregion
|
|
5306
5273
|
//#region src/mldsa/mldsa-level.ts
|
|
5307
5274
|
/**
|
|
@@ -5329,30 +5296,30 @@ var ECPrivateKey = class ECPrivateKey {
|
|
|
5329
5296
|
* - 3: NIST Level 3 (MLDSA65)
|
|
5330
5297
|
* - 5: NIST Level 5 (MLDSA87)
|
|
5331
5298
|
*/
|
|
5332
|
-
let MLDSALevel = /* @__PURE__ */ function(MLDSALevel
|
|
5299
|
+
let MLDSALevel = /* @__PURE__ */ function(MLDSALevel) {
|
|
5333
5300
|
/** NIST Level 2 - AES-128 equivalent security */
|
|
5334
|
-
MLDSALevel
|
|
5301
|
+
MLDSALevel[MLDSALevel["MLDSA44"] = 2] = "MLDSA44";
|
|
5335
5302
|
/** NIST Level 3 - AES-192 equivalent security */
|
|
5336
|
-
MLDSALevel
|
|
5303
|
+
MLDSALevel[MLDSALevel["MLDSA65"] = 3] = "MLDSA65";
|
|
5337
5304
|
/** NIST Level 5 - AES-256 equivalent security */
|
|
5338
|
-
MLDSALevel
|
|
5339
|
-
return MLDSALevel
|
|
5305
|
+
MLDSALevel[MLDSALevel["MLDSA87"] = 5] = "MLDSA87";
|
|
5306
|
+
return MLDSALevel;
|
|
5340
5307
|
}({});
|
|
5341
5308
|
/**
|
|
5342
5309
|
* Key sizes for each ML-DSA security level.
|
|
5343
5310
|
*/
|
|
5344
5311
|
const MLDSA_KEY_SIZES = {
|
|
5345
|
-
[
|
|
5312
|
+
[2]: {
|
|
5346
5313
|
privateKey: 2560,
|
|
5347
5314
|
publicKey: 1312,
|
|
5348
5315
|
signature: 2420
|
|
5349
5316
|
},
|
|
5350
|
-
[
|
|
5317
|
+
[3]: {
|
|
5351
5318
|
privateKey: 4032,
|
|
5352
5319
|
publicKey: 1952,
|
|
5353
5320
|
signature: 3309
|
|
5354
5321
|
},
|
|
5355
|
-
[
|
|
5322
|
+
[5]: {
|
|
5356
5323
|
privateKey: 4896,
|
|
5357
5324
|
publicKey: 2592,
|
|
5358
5325
|
signature: 4627
|
|
@@ -5381,9 +5348,9 @@ function mldsaSignatureSize(level) {
|
|
|
5381
5348
|
*/
|
|
5382
5349
|
function mldsaLevelToString(level) {
|
|
5383
5350
|
switch (level) {
|
|
5384
|
-
case
|
|
5385
|
-
case
|
|
5386
|
-
case
|
|
5351
|
+
case 2: return "MLDSA44";
|
|
5352
|
+
case 3: return "MLDSA65";
|
|
5353
|
+
case 5: return "MLDSA87";
|
|
5387
5354
|
}
|
|
5388
5355
|
}
|
|
5389
5356
|
/**
|
|
@@ -5391,9 +5358,9 @@ function mldsaLevelToString(level) {
|
|
|
5391
5358
|
*/
|
|
5392
5359
|
function mldsaLevelFromValue(value) {
|
|
5393
5360
|
switch (value) {
|
|
5394
|
-
case 2: return
|
|
5395
|
-
case 3: return
|
|
5396
|
-
case 5: return
|
|
5361
|
+
case 2: return 2;
|
|
5362
|
+
case 3: return 3;
|
|
5363
|
+
case 5: return 5;
|
|
5397
5364
|
default: throw new Error(`Invalid MLDSA level value: ${value}`);
|
|
5398
5365
|
}
|
|
5399
5366
|
}
|
|
@@ -5416,21 +5383,21 @@ function mldsaGenerateKeypair(level) {
|
|
|
5416
5383
|
function mldsaGenerateKeypairUsing(level, rng) {
|
|
5417
5384
|
const seed = rng.randomData(32);
|
|
5418
5385
|
switch (level) {
|
|
5419
|
-
case
|
|
5386
|
+
case 2: {
|
|
5420
5387
|
const keypair = _noble_post_quantum_ml_dsa_js.ml_dsa44.keygen(seed);
|
|
5421
5388
|
return {
|
|
5422
5389
|
publicKey: keypair.publicKey,
|
|
5423
5390
|
secretKey: keypair.secretKey
|
|
5424
5391
|
};
|
|
5425
5392
|
}
|
|
5426
|
-
case
|
|
5393
|
+
case 3: {
|
|
5427
5394
|
const keypair = _noble_post_quantum_ml_dsa_js.ml_dsa65.keygen(seed);
|
|
5428
5395
|
return {
|
|
5429
5396
|
publicKey: keypair.publicKey,
|
|
5430
5397
|
secretKey: keypair.secretKey
|
|
5431
5398
|
};
|
|
5432
5399
|
}
|
|
5433
|
-
case
|
|
5400
|
+
case 5: {
|
|
5434
5401
|
const keypair = _noble_post_quantum_ml_dsa_js.ml_dsa87.keygen(seed);
|
|
5435
5402
|
return {
|
|
5436
5403
|
publicKey: keypair.publicKey,
|
|
@@ -5449,9 +5416,9 @@ function mldsaGenerateKeypairUsing(level, rng) {
|
|
|
5449
5416
|
*/
|
|
5450
5417
|
function mldsaSign(level, secretKey, message) {
|
|
5451
5418
|
switch (level) {
|
|
5452
|
-
case
|
|
5453
|
-
case
|
|
5454
|
-
case
|
|
5419
|
+
case 2: return _noble_post_quantum_ml_dsa_js.ml_dsa44.sign(message, secretKey);
|
|
5420
|
+
case 3: return _noble_post_quantum_ml_dsa_js.ml_dsa65.sign(message, secretKey);
|
|
5421
|
+
case 5: return _noble_post_quantum_ml_dsa_js.ml_dsa87.sign(message, secretKey);
|
|
5455
5422
|
}
|
|
5456
5423
|
}
|
|
5457
5424
|
/**
|
|
@@ -5466,15 +5433,14 @@ function mldsaSign(level, secretKey, message) {
|
|
|
5466
5433
|
function mldsaVerify(level, publicKey, message, signature) {
|
|
5467
5434
|
try {
|
|
5468
5435
|
switch (level) {
|
|
5469
|
-
case
|
|
5470
|
-
case
|
|
5471
|
-
case
|
|
5436
|
+
case 2: return _noble_post_quantum_ml_dsa_js.ml_dsa44.verify(signature, message, publicKey);
|
|
5437
|
+
case 3: return _noble_post_quantum_ml_dsa_js.ml_dsa65.verify(signature, message, publicKey);
|
|
5438
|
+
case 5: return _noble_post_quantum_ml_dsa_js.ml_dsa87.verify(signature, message, publicKey);
|
|
5472
5439
|
}
|
|
5473
5440
|
} catch {
|
|
5474
5441
|
return false;
|
|
5475
5442
|
}
|
|
5476
5443
|
}
|
|
5477
|
-
|
|
5478
5444
|
//#endregion
|
|
5479
5445
|
//#region src/mldsa/mldsa-public-key.ts
|
|
5480
5446
|
/**
|
|
@@ -5620,8 +5586,7 @@ var MLDSAPublicKey = class MLDSAPublicKey {
|
|
|
5620
5586
|
* Static method to decode from tagged CBOR.
|
|
5621
5587
|
*/
|
|
5622
5588
|
static fromTaggedCbor(cborValue) {
|
|
5623
|
-
|
|
5624
|
-
return new MLDSAPublicKey(MLDSALevel.MLDSA44, dummyData).fromTaggedCbor(cborValue);
|
|
5589
|
+
return new MLDSAPublicKey(2, new Uint8Array(mldsaPublicKeySize(2))).fromTaggedCbor(cborValue);
|
|
5625
5590
|
}
|
|
5626
5591
|
/**
|
|
5627
5592
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -5635,8 +5600,7 @@ var MLDSAPublicKey = class MLDSAPublicKey {
|
|
|
5635
5600
|
*/
|
|
5636
5601
|
static fromUntaggedCborData(data) {
|
|
5637
5602
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
5638
|
-
|
|
5639
|
-
return new MLDSAPublicKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(cborValue);
|
|
5603
|
+
return new MLDSAPublicKey(2, new Uint8Array(mldsaPublicKeySize(2))).fromUntaggedCbor(cborValue);
|
|
5640
5604
|
}
|
|
5641
5605
|
/**
|
|
5642
5606
|
* Returns the UR representation.
|
|
@@ -5657,8 +5621,7 @@ var MLDSAPublicKey = class MLDSAPublicKey {
|
|
|
5657
5621
|
*/
|
|
5658
5622
|
static fromUR(ur) {
|
|
5659
5623
|
if (ur.urTypeStr() !== _bcts_tags.MLDSA_PUBLIC_KEY.name) throw new Error(`Expected UR type ${_bcts_tags.MLDSA_PUBLIC_KEY.name}, got ${ur.urTypeStr()}`);
|
|
5660
|
-
|
|
5661
|
-
return new MLDSAPublicKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(ur.cbor());
|
|
5624
|
+
return new MLDSAPublicKey(2, new Uint8Array(mldsaPublicKeySize(2))).fromUntaggedCbor(ur.cbor());
|
|
5662
5625
|
}
|
|
5663
5626
|
/**
|
|
5664
5627
|
* Creates an MLDSAPublicKey from a UR string.
|
|
@@ -5668,7 +5631,6 @@ var MLDSAPublicKey = class MLDSAPublicKey {
|
|
|
5668
5631
|
return MLDSAPublicKey.fromUR(ur);
|
|
5669
5632
|
}
|
|
5670
5633
|
};
|
|
5671
|
-
|
|
5672
5634
|
//#endregion
|
|
5673
5635
|
//#region src/mldsa/mldsa-signature.ts
|
|
5674
5636
|
/**
|
|
@@ -5803,8 +5765,7 @@ var MLDSASignature = class MLDSASignature {
|
|
|
5803
5765
|
* Static method to decode from tagged CBOR.
|
|
5804
5766
|
*/
|
|
5805
5767
|
static fromTaggedCbor(cborValue) {
|
|
5806
|
-
|
|
5807
|
-
return new MLDSASignature(MLDSALevel.MLDSA44, dummyData).fromTaggedCbor(cborValue);
|
|
5768
|
+
return new MLDSASignature(2, new Uint8Array(mldsaSignatureSize(2))).fromTaggedCbor(cborValue);
|
|
5808
5769
|
}
|
|
5809
5770
|
/**
|
|
5810
5771
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -5818,8 +5779,7 @@ var MLDSASignature = class MLDSASignature {
|
|
|
5818
5779
|
*/
|
|
5819
5780
|
static fromUntaggedCborData(data) {
|
|
5820
5781
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
5821
|
-
|
|
5822
|
-
return new MLDSASignature(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(cborValue);
|
|
5782
|
+
return new MLDSASignature(2, new Uint8Array(mldsaSignatureSize(2))).fromUntaggedCbor(cborValue);
|
|
5823
5783
|
}
|
|
5824
5784
|
/**
|
|
5825
5785
|
* Returns the UR representation.
|
|
@@ -5840,8 +5800,7 @@ var MLDSASignature = class MLDSASignature {
|
|
|
5840
5800
|
*/
|
|
5841
5801
|
static fromUR(ur) {
|
|
5842
5802
|
if (ur.urTypeStr() !== _bcts_tags.MLDSA_SIGNATURE.name) throw new Error(`Expected UR type ${_bcts_tags.MLDSA_SIGNATURE.name}, got ${ur.urTypeStr()}`);
|
|
5843
|
-
|
|
5844
|
-
return new MLDSASignature(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(ur.cbor());
|
|
5803
|
+
return new MLDSASignature(2, new Uint8Array(mldsaSignatureSize(2))).fromUntaggedCbor(ur.cbor());
|
|
5845
5804
|
}
|
|
5846
5805
|
/**
|
|
5847
5806
|
* Creates an MLDSASignature from a UR string.
|
|
@@ -5851,7 +5810,6 @@ var MLDSASignature = class MLDSASignature {
|
|
|
5851
5810
|
return MLDSASignature.fromUR(ur);
|
|
5852
5811
|
}
|
|
5853
5812
|
};
|
|
5854
|
-
|
|
5855
5813
|
//#endregion
|
|
5856
5814
|
//#region src/mldsa/mldsa-private-key.ts
|
|
5857
5815
|
/**
|
|
@@ -5894,7 +5852,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
5894
5852
|
*
|
|
5895
5853
|
* @param level - The ML-DSA security level (default: MLDSA65)
|
|
5896
5854
|
*/
|
|
5897
|
-
static new(level =
|
|
5855
|
+
static new(level = 3) {
|
|
5898
5856
|
const rng = new _bcts_rand.SecureRandomNumberGenerator();
|
|
5899
5857
|
return MLDSAPrivateKey.newUsing(level, rng);
|
|
5900
5858
|
}
|
|
@@ -5922,7 +5880,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
5922
5880
|
* @param level - The ML-DSA security level (default: MLDSA65)
|
|
5923
5881
|
* @returns Tuple of [privateKey, publicKey]
|
|
5924
5882
|
*/
|
|
5925
|
-
static keypair(level =
|
|
5883
|
+
static keypair(level = 3) {
|
|
5926
5884
|
const rng = new _bcts_rand.SecureRandomNumberGenerator();
|
|
5927
5885
|
return MLDSAPrivateKey.keypairUsing(level, rng);
|
|
5928
5886
|
}
|
|
@@ -6045,8 +6003,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
6045
6003
|
* Static method to decode from tagged CBOR.
|
|
6046
6004
|
*/
|
|
6047
6005
|
static fromTaggedCbor(cborValue) {
|
|
6048
|
-
|
|
6049
|
-
return new MLDSAPrivateKey(MLDSALevel.MLDSA44, dummyData).fromTaggedCbor(cborValue);
|
|
6006
|
+
return new MLDSAPrivateKey(2, new Uint8Array(mldsaPrivateKeySize(2))).fromTaggedCbor(cborValue);
|
|
6050
6007
|
}
|
|
6051
6008
|
/**
|
|
6052
6009
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -6060,8 +6017,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
6060
6017
|
*/
|
|
6061
6018
|
static fromUntaggedCborData(data) {
|
|
6062
6019
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
6063
|
-
|
|
6064
|
-
return new MLDSAPrivateKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(cborValue);
|
|
6020
|
+
return new MLDSAPrivateKey(2, new Uint8Array(mldsaPrivateKeySize(2))).fromUntaggedCbor(cborValue);
|
|
6065
6021
|
}
|
|
6066
6022
|
/**
|
|
6067
6023
|
* Returns the UR representation.
|
|
@@ -6082,8 +6038,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
6082
6038
|
*/
|
|
6083
6039
|
static fromUR(ur) {
|
|
6084
6040
|
if (ur.urTypeStr() !== _bcts_tags.MLDSA_PRIVATE_KEY.name) throw new Error(`Expected UR type ${_bcts_tags.MLDSA_PRIVATE_KEY.name}, got ${ur.urTypeStr()}`);
|
|
6085
|
-
|
|
6086
|
-
return new MLDSAPrivateKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(ur.cbor());
|
|
6041
|
+
return new MLDSAPrivateKey(2, new Uint8Array(mldsaPrivateKeySize(2))).fromUntaggedCbor(ur.cbor());
|
|
6087
6042
|
}
|
|
6088
6043
|
/**
|
|
6089
6044
|
* Creates an MLDSAPrivateKey from a UR string.
|
|
@@ -6093,7 +6048,6 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
6093
6048
|
return MLDSAPrivateKey.fromUR(ur);
|
|
6094
6049
|
}
|
|
6095
6050
|
};
|
|
6096
|
-
|
|
6097
6051
|
//#endregion
|
|
6098
6052
|
//#region src/signing/signature.ts
|
|
6099
6053
|
/**
|
|
@@ -6145,7 +6099,7 @@ var Signature = class Signature {
|
|
|
6145
6099
|
*/
|
|
6146
6100
|
static schnorrFromData(data) {
|
|
6147
6101
|
if (data.length !== _bcts_crypto.SCHNORR_SIGNATURE_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.SCHNORR_SIGNATURE_SIZE, data.length);
|
|
6148
|
-
return new Signature(
|
|
6102
|
+
return new Signature("Schnorr", data);
|
|
6149
6103
|
}
|
|
6150
6104
|
/**
|
|
6151
6105
|
* Creates a Schnorr signature from a hex string.
|
|
@@ -6164,7 +6118,7 @@ var Signature = class Signature {
|
|
|
6164
6118
|
*/
|
|
6165
6119
|
static ecdsaFromData(data) {
|
|
6166
6120
|
if (data.length !== _bcts_crypto.ECDSA_SIGNATURE_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ECDSA_SIGNATURE_SIZE, data.length);
|
|
6167
|
-
return new Signature(
|
|
6121
|
+
return new Signature("Ecdsa", data);
|
|
6168
6122
|
}
|
|
6169
6123
|
/**
|
|
6170
6124
|
* Creates an ECDSA signature from a hex string.
|
|
@@ -6183,7 +6137,7 @@ var Signature = class Signature {
|
|
|
6183
6137
|
*/
|
|
6184
6138
|
static ed25519FromData(data) {
|
|
6185
6139
|
if (data.length !== _bcts_crypto.ED25519_SIGNATURE_SIZE) throw require_digest.CryptoError.invalidSize(_bcts_crypto.ED25519_SIGNATURE_SIZE, data.length);
|
|
6186
|
-
return new Signature(
|
|
6140
|
+
return new Signature("Ed25519", data);
|
|
6187
6141
|
}
|
|
6188
6142
|
/**
|
|
6189
6143
|
* Creates an Ed25519 signature from a hex string.
|
|
@@ -6201,8 +6155,8 @@ var Signature = class Signature {
|
|
|
6201
6155
|
* @returns A new Sr25519 signature
|
|
6202
6156
|
*/
|
|
6203
6157
|
static sr25519FromData(data) {
|
|
6204
|
-
if (data.length !==
|
|
6205
|
-
return new Signature(
|
|
6158
|
+
if (data.length !== 64) throw require_digest.CryptoError.invalidSize(64, data.length);
|
|
6159
|
+
return new Signature("Sr25519", data);
|
|
6206
6160
|
}
|
|
6207
6161
|
/**
|
|
6208
6162
|
* Creates an Sr25519 signature from a hex string.
|
|
@@ -6222,14 +6176,14 @@ var Signature = class Signature {
|
|
|
6222
6176
|
static mldsaFromSignature(sig) {
|
|
6223
6177
|
let scheme;
|
|
6224
6178
|
switch (sig.level()) {
|
|
6225
|
-
case
|
|
6226
|
-
scheme =
|
|
6179
|
+
case 2:
|
|
6180
|
+
scheme = "MLDSA44";
|
|
6227
6181
|
break;
|
|
6228
|
-
case
|
|
6229
|
-
scheme =
|
|
6182
|
+
case 3:
|
|
6183
|
+
scheme = "MLDSA65";
|
|
6230
6184
|
break;
|
|
6231
|
-
case
|
|
6232
|
-
scheme =
|
|
6185
|
+
case 5:
|
|
6186
|
+
scheme = "MLDSA87";
|
|
6233
6187
|
break;
|
|
6234
6188
|
default: throw new Error(`Unknown MLDSA level: ${sig.level()}`);
|
|
6235
6189
|
}
|
|
@@ -6247,17 +6201,17 @@ var Signature = class Signature {
|
|
|
6247
6201
|
*/
|
|
6248
6202
|
signatureType() {
|
|
6249
6203
|
switch (this._type) {
|
|
6250
|
-
case
|
|
6251
|
-
case
|
|
6252
|
-
case
|
|
6253
|
-
case
|
|
6254
|
-
case
|
|
6255
|
-
case
|
|
6256
|
-
case
|
|
6257
|
-
case
|
|
6258
|
-
case
|
|
6259
|
-
case
|
|
6260
|
-
case
|
|
6204
|
+
case "Ed25519": return "Ed25519";
|
|
6205
|
+
case "Schnorr": return "Schnorr";
|
|
6206
|
+
case "Ecdsa": return "Ecdsa";
|
|
6207
|
+
case "Sr25519": return "Sr25519";
|
|
6208
|
+
case "MLDSA44": return "MLDSA-44";
|
|
6209
|
+
case "MLDSA65": return "MLDSA-65";
|
|
6210
|
+
case "MLDSA87": return "MLDSA-87";
|
|
6211
|
+
case "SshEd25519": return "SshEd25519";
|
|
6212
|
+
case "SshDsa": return "SshDsa";
|
|
6213
|
+
case "SshEcdsaP256": return "SshEcdsaP256";
|
|
6214
|
+
case "SshEcdsaP384": return "SshEcdsaP384";
|
|
6261
6215
|
default: return this._type;
|
|
6262
6216
|
}
|
|
6263
6217
|
}
|
|
@@ -6273,14 +6227,14 @@ var Signature = class Signature {
|
|
|
6273
6227
|
* @returns The 64-byte signature data if this is a Schnorr signature, null otherwise
|
|
6274
6228
|
*/
|
|
6275
6229
|
toSchnorr() {
|
|
6276
|
-
if (this._type ===
|
|
6230
|
+
if (this._type === "Schnorr") return this._data;
|
|
6277
6231
|
return null;
|
|
6278
6232
|
}
|
|
6279
6233
|
/**
|
|
6280
6234
|
* Checks if this is a Schnorr signature.
|
|
6281
6235
|
*/
|
|
6282
6236
|
isSchnorr() {
|
|
6283
|
-
return this._type ===
|
|
6237
|
+
return this._type === "Schnorr";
|
|
6284
6238
|
}
|
|
6285
6239
|
/**
|
|
6286
6240
|
* Returns the ECDSA signature data if this is an ECDSA signature.
|
|
@@ -6288,14 +6242,14 @@ var Signature = class Signature {
|
|
|
6288
6242
|
* @returns The 64-byte signature data if this is an ECDSA signature, null otherwise
|
|
6289
6243
|
*/
|
|
6290
6244
|
toEcdsa() {
|
|
6291
|
-
if (this._type ===
|
|
6245
|
+
if (this._type === "Ecdsa") return this._data;
|
|
6292
6246
|
return null;
|
|
6293
6247
|
}
|
|
6294
6248
|
/**
|
|
6295
6249
|
* Checks if this is an ECDSA signature.
|
|
6296
6250
|
*/
|
|
6297
6251
|
isEcdsa() {
|
|
6298
|
-
return this._type ===
|
|
6252
|
+
return this._type === "Ecdsa";
|
|
6299
6253
|
}
|
|
6300
6254
|
/**
|
|
6301
6255
|
* Returns the Ed25519 signature data if this is an Ed25519 signature.
|
|
@@ -6303,14 +6257,14 @@ var Signature = class Signature {
|
|
|
6303
6257
|
* @returns The 64-byte signature data if this is an Ed25519 signature, null otherwise
|
|
6304
6258
|
*/
|
|
6305
6259
|
toEd25519() {
|
|
6306
|
-
if (this._type ===
|
|
6260
|
+
if (this._type === "Ed25519") return this._data;
|
|
6307
6261
|
return null;
|
|
6308
6262
|
}
|
|
6309
6263
|
/**
|
|
6310
6264
|
* Checks if this is an Ed25519 signature.
|
|
6311
6265
|
*/
|
|
6312
6266
|
isEd25519() {
|
|
6313
|
-
return this._type ===
|
|
6267
|
+
return this._type === "Ed25519";
|
|
6314
6268
|
}
|
|
6315
6269
|
/**
|
|
6316
6270
|
* Returns the Sr25519 signature data if this is an Sr25519 signature.
|
|
@@ -6318,14 +6272,14 @@ var Signature = class Signature {
|
|
|
6318
6272
|
* @returns The 64-byte signature data if this is an Sr25519 signature, null otherwise
|
|
6319
6273
|
*/
|
|
6320
6274
|
toSr25519() {
|
|
6321
|
-
if (this._type ===
|
|
6275
|
+
if (this._type === "Sr25519") return this._data;
|
|
6322
6276
|
return null;
|
|
6323
6277
|
}
|
|
6324
6278
|
/**
|
|
6325
6279
|
* Checks if this is an Sr25519 signature.
|
|
6326
6280
|
*/
|
|
6327
6281
|
isSr25519() {
|
|
6328
|
-
return this._type ===
|
|
6282
|
+
return this._type === "Sr25519";
|
|
6329
6283
|
}
|
|
6330
6284
|
/**
|
|
6331
6285
|
* Returns the MLDSASignature if this is an MLDSA signature.
|
|
@@ -6380,19 +6334,19 @@ var Signature = class Signature {
|
|
|
6380
6334
|
*/
|
|
6381
6335
|
untaggedCbor() {
|
|
6382
6336
|
switch (this._type) {
|
|
6383
|
-
case
|
|
6384
|
-
case
|
|
6385
|
-
case
|
|
6386
|
-
case
|
|
6387
|
-
case
|
|
6388
|
-
case
|
|
6389
|
-
case
|
|
6337
|
+
case "Schnorr": return (0, _bcts_dcbor.toByteString)(this._data);
|
|
6338
|
+
case "Ecdsa": return (0, _bcts_dcbor.cbor)([1, (0, _bcts_dcbor.toByteString)(this._data)]);
|
|
6339
|
+
case "Ed25519": return (0, _bcts_dcbor.cbor)([2, (0, _bcts_dcbor.toByteString)(this._data)]);
|
|
6340
|
+
case "Sr25519": return (0, _bcts_dcbor.cbor)([3, (0, _bcts_dcbor.toByteString)(this._data)]);
|
|
6341
|
+
case "MLDSA44":
|
|
6342
|
+
case "MLDSA65":
|
|
6343
|
+
case "MLDSA87":
|
|
6390
6344
|
if (this._mldsaSignature === void 0) throw new Error("MLDSA signature is missing");
|
|
6391
6345
|
return this._mldsaSignature.taggedCbor();
|
|
6392
|
-
case
|
|
6393
|
-
case
|
|
6394
|
-
case
|
|
6395
|
-
case
|
|
6346
|
+
case "SshEd25519":
|
|
6347
|
+
case "SshDsa":
|
|
6348
|
+
case "SshEcdsaP256":
|
|
6349
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported for CBOR encoding`);
|
|
6396
6350
|
}
|
|
6397
6351
|
}
|
|
6398
6352
|
/**
|
|
@@ -6453,7 +6407,7 @@ var Signature = class Signature {
|
|
|
6453
6407
|
* Static method to decode from tagged CBOR.
|
|
6454
6408
|
*/
|
|
6455
6409
|
static fromTaggedCbor(cborValue) {
|
|
6456
|
-
return new Signature(
|
|
6410
|
+
return new Signature("Ed25519", new Uint8Array(_bcts_crypto.ED25519_SIGNATURE_SIZE)).fromTaggedCbor(cborValue);
|
|
6457
6411
|
}
|
|
6458
6412
|
/**
|
|
6459
6413
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -6467,7 +6421,7 @@ var Signature = class Signature {
|
|
|
6467
6421
|
*/
|
|
6468
6422
|
static fromUntaggedCborData(data) {
|
|
6469
6423
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
6470
|
-
return new Signature(
|
|
6424
|
+
return new Signature("Ed25519", new Uint8Array(_bcts_crypto.ED25519_SIGNATURE_SIZE)).fromUntaggedCbor(cborValue);
|
|
6471
6425
|
}
|
|
6472
6426
|
/**
|
|
6473
6427
|
* Get the UR type for signatures.
|
|
@@ -6506,7 +6460,6 @@ var Signature = class Signature {
|
|
|
6506
6460
|
return Signature.fromURString(urString);
|
|
6507
6461
|
}
|
|
6508
6462
|
};
|
|
6509
|
-
|
|
6510
6463
|
//#endregion
|
|
6511
6464
|
//#region src/signing/signing-public-key.ts
|
|
6512
6465
|
/**
|
|
@@ -6565,7 +6518,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6565
6518
|
* @returns A new signing public key containing the Schnorr key
|
|
6566
6519
|
*/
|
|
6567
6520
|
static fromSchnorr(key) {
|
|
6568
|
-
return new SigningPublicKey(
|
|
6521
|
+
return new SigningPublicKey("Schnorr", key, void 0, void 0, void 0, void 0);
|
|
6569
6522
|
}
|
|
6570
6523
|
/**
|
|
6571
6524
|
* Creates a new signing public key from an ECDSA (compressed) public key.
|
|
@@ -6574,7 +6527,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6574
6527
|
* @returns A new signing public key containing the ECDSA key
|
|
6575
6528
|
*/
|
|
6576
6529
|
static fromEcdsa(key) {
|
|
6577
|
-
return new SigningPublicKey(
|
|
6530
|
+
return new SigningPublicKey("Ecdsa", void 0, key, void 0, void 0, void 0);
|
|
6578
6531
|
}
|
|
6579
6532
|
/**
|
|
6580
6533
|
* Creates a new signing public key from an Ed25519 public key.
|
|
@@ -6583,7 +6536,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6583
6536
|
* @returns A new signing public key containing the Ed25519 key
|
|
6584
6537
|
*/
|
|
6585
6538
|
static fromEd25519(key) {
|
|
6586
|
-
return new SigningPublicKey(
|
|
6539
|
+
return new SigningPublicKey("Ed25519", void 0, void 0, key, void 0, void 0);
|
|
6587
6540
|
}
|
|
6588
6541
|
/**
|
|
6589
6542
|
* Creates a new signing public key from an Sr25519 public key.
|
|
@@ -6592,7 +6545,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6592
6545
|
* @returns A new signing public key containing the Sr25519 key
|
|
6593
6546
|
*/
|
|
6594
6547
|
static fromSr25519(key) {
|
|
6595
|
-
return new SigningPublicKey(
|
|
6548
|
+
return new SigningPublicKey("Sr25519", void 0, void 0, void 0, key, void 0);
|
|
6596
6549
|
}
|
|
6597
6550
|
/**
|
|
6598
6551
|
* Creates a new signing public key from an MLDSAPublicKey.
|
|
@@ -6603,14 +6556,14 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6603
6556
|
static fromMldsa(key) {
|
|
6604
6557
|
let scheme;
|
|
6605
6558
|
switch (key.level()) {
|
|
6606
|
-
case
|
|
6607
|
-
scheme =
|
|
6559
|
+
case 2:
|
|
6560
|
+
scheme = "MLDSA44";
|
|
6608
6561
|
break;
|
|
6609
|
-
case
|
|
6610
|
-
scheme =
|
|
6562
|
+
case 3:
|
|
6563
|
+
scheme = "MLDSA65";
|
|
6611
6564
|
break;
|
|
6612
|
-
case
|
|
6613
|
-
scheme =
|
|
6565
|
+
case 5:
|
|
6566
|
+
scheme = "MLDSA87";
|
|
6614
6567
|
break;
|
|
6615
6568
|
default: throw new Error(`Unknown MLDSA level: ${key.level()}`);
|
|
6616
6569
|
}
|
|
@@ -6628,17 +6581,17 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6628
6581
|
*/
|
|
6629
6582
|
keyType() {
|
|
6630
6583
|
switch (this._type) {
|
|
6631
|
-
case
|
|
6632
|
-
case
|
|
6633
|
-
case
|
|
6634
|
-
case
|
|
6635
|
-
case
|
|
6636
|
-
case
|
|
6637
|
-
case
|
|
6638
|
-
case
|
|
6639
|
-
case
|
|
6640
|
-
case
|
|
6641
|
-
case
|
|
6584
|
+
case "Ed25519": return "Ed25519";
|
|
6585
|
+
case "Schnorr": return "Schnorr";
|
|
6586
|
+
case "Ecdsa": return "ECDSA";
|
|
6587
|
+
case "Sr25519": return "Sr25519";
|
|
6588
|
+
case "MLDSA44": return "MLDSA-44";
|
|
6589
|
+
case "MLDSA65": return "MLDSA-65";
|
|
6590
|
+
case "MLDSA87": return "MLDSA-87";
|
|
6591
|
+
case "SshEd25519": return "SSH-Ed25519";
|
|
6592
|
+
case "SshDsa": return "SSH-DSA";
|
|
6593
|
+
case "SshEcdsaP256": return "SSH-ECDSA-P256";
|
|
6594
|
+
case "SshEcdsaP384": return "SSH-ECDSA-P384";
|
|
6642
6595
|
default: return this._type;
|
|
6643
6596
|
}
|
|
6644
6597
|
}
|
|
@@ -6648,7 +6601,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6648
6601
|
* @returns The SchnorrPublicKey if this is a Schnorr key, null otherwise
|
|
6649
6602
|
*/
|
|
6650
6603
|
toSchnorr() {
|
|
6651
|
-
if (this._type ===
|
|
6604
|
+
if (this._type === "Schnorr" && this._schnorrKey !== void 0) return this._schnorrKey;
|
|
6652
6605
|
return null;
|
|
6653
6606
|
}
|
|
6654
6607
|
/**
|
|
@@ -6657,7 +6610,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6657
6610
|
* @returns The ECPublicKey if this is an ECDSA key, null otherwise
|
|
6658
6611
|
*/
|
|
6659
6612
|
toEcdsa() {
|
|
6660
|
-
if (this._type ===
|
|
6613
|
+
if (this._type === "Ecdsa" && this._ecdsaKey !== void 0) return this._ecdsaKey;
|
|
6661
6614
|
return null;
|
|
6662
6615
|
}
|
|
6663
6616
|
/**
|
|
@@ -6666,7 +6619,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6666
6619
|
* @returns The Ed25519 public key if this is an Ed25519 key, null otherwise
|
|
6667
6620
|
*/
|
|
6668
6621
|
toEd25519() {
|
|
6669
|
-
if (this._type ===
|
|
6622
|
+
if (this._type === "Ed25519" && this._ed25519Key !== void 0) return this._ed25519Key;
|
|
6670
6623
|
return null;
|
|
6671
6624
|
}
|
|
6672
6625
|
/**
|
|
@@ -6675,32 +6628,32 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6675
6628
|
* @returns The Sr25519 public key if this is an Sr25519 key, null otherwise
|
|
6676
6629
|
*/
|
|
6677
6630
|
toSr25519() {
|
|
6678
|
-
if (this._type ===
|
|
6631
|
+
if (this._type === "Sr25519" && this._sr25519Key !== void 0) return this._sr25519Key;
|
|
6679
6632
|
return null;
|
|
6680
6633
|
}
|
|
6681
6634
|
/**
|
|
6682
6635
|
* Checks if this is a Schnorr signing key.
|
|
6683
6636
|
*/
|
|
6684
6637
|
isSchnorr() {
|
|
6685
|
-
return this._type ===
|
|
6638
|
+
return this._type === "Schnorr";
|
|
6686
6639
|
}
|
|
6687
6640
|
/**
|
|
6688
6641
|
* Checks if this is an ECDSA signing key.
|
|
6689
6642
|
*/
|
|
6690
6643
|
isEcdsa() {
|
|
6691
|
-
return this._type ===
|
|
6644
|
+
return this._type === "Ecdsa";
|
|
6692
6645
|
}
|
|
6693
6646
|
/**
|
|
6694
6647
|
* Checks if this is an Ed25519 signing key.
|
|
6695
6648
|
*/
|
|
6696
6649
|
isEd25519() {
|
|
6697
|
-
return this._type ===
|
|
6650
|
+
return this._type === "Ed25519";
|
|
6698
6651
|
}
|
|
6699
6652
|
/**
|
|
6700
6653
|
* Checks if this is an Sr25519 signing key.
|
|
6701
6654
|
*/
|
|
6702
6655
|
isSr25519() {
|
|
6703
|
-
return this._type ===
|
|
6656
|
+
return this._type === "Sr25519";
|
|
6704
6657
|
}
|
|
6705
6658
|
/**
|
|
6706
6659
|
* Returns the underlying MLDSA public key if this is an MLDSA key.
|
|
@@ -6723,27 +6676,27 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6723
6676
|
equals(other) {
|
|
6724
6677
|
if (this._type !== other._type) return false;
|
|
6725
6678
|
switch (this._type) {
|
|
6726
|
-
case
|
|
6679
|
+
case "Schnorr":
|
|
6727
6680
|
if (this._schnorrKey === void 0 || other._schnorrKey === void 0) return false;
|
|
6728
6681
|
return this._schnorrKey.equals(other._schnorrKey);
|
|
6729
|
-
case
|
|
6682
|
+
case "Ecdsa":
|
|
6730
6683
|
if (this._ecdsaKey === void 0 || other._ecdsaKey === void 0) return false;
|
|
6731
6684
|
return this._ecdsaKey.equals(other._ecdsaKey);
|
|
6732
|
-
case
|
|
6685
|
+
case "Ed25519":
|
|
6733
6686
|
if (this._ed25519Key === void 0 || other._ed25519Key === void 0) return false;
|
|
6734
6687
|
return this._ed25519Key.equals(other._ed25519Key);
|
|
6735
|
-
case
|
|
6688
|
+
case "Sr25519":
|
|
6736
6689
|
if (this._sr25519Key === void 0 || other._sr25519Key === void 0) return false;
|
|
6737
6690
|
return this._sr25519Key.equals(other._sr25519Key);
|
|
6738
|
-
case
|
|
6739
|
-
case
|
|
6740
|
-
case
|
|
6691
|
+
case "MLDSA44":
|
|
6692
|
+
case "MLDSA65":
|
|
6693
|
+
case "MLDSA87":
|
|
6741
6694
|
if (this._mldsaKey === void 0 || other._mldsaKey === void 0) return false;
|
|
6742
6695
|
return this._mldsaKey.equals(other._mldsaKey);
|
|
6743
|
-
case
|
|
6744
|
-
case
|
|
6745
|
-
case
|
|
6746
|
-
case
|
|
6696
|
+
case "SshEd25519":
|
|
6697
|
+
case "SshDsa":
|
|
6698
|
+
case "SshEcdsaP256":
|
|
6699
|
+
case "SshEcdsaP384": return false;
|
|
6747
6700
|
}
|
|
6748
6701
|
}
|
|
6749
6702
|
/**
|
|
@@ -6751,17 +6704,17 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6751
6704
|
*/
|
|
6752
6705
|
toString() {
|
|
6753
6706
|
switch (this._type) {
|
|
6754
|
-
case
|
|
6755
|
-
case
|
|
6756
|
-
case
|
|
6757
|
-
case
|
|
6758
|
-
case
|
|
6759
|
-
case
|
|
6760
|
-
case
|
|
6761
|
-
case
|
|
6762
|
-
case
|
|
6763
|
-
case
|
|
6764
|
-
case
|
|
6707
|
+
case "Schnorr": return `SigningPublicKey(${this._type}, ${this._schnorrKey?.toHex().substring(0, 16)}...)`;
|
|
6708
|
+
case "Ecdsa": return `SigningPublicKey(${this._type}, ${this._ecdsaKey?.toHex().substring(0, 16)}...)`;
|
|
6709
|
+
case "Ed25519": return `SigningPublicKey(${this._type}, ${this._ed25519Key?.toHex().substring(0, 16)}...)`;
|
|
6710
|
+
case "Sr25519": return `SigningPublicKey(${this._type}, ${this._sr25519Key?.toHex().substring(0, 16)}...)`;
|
|
6711
|
+
case "MLDSA44":
|
|
6712
|
+
case "MLDSA65":
|
|
6713
|
+
case "MLDSA87": return `SigningPublicKey(${this._type}, ${this._mldsaKey?.toString().substring(0, 30)}...)`;
|
|
6714
|
+
case "SshEd25519":
|
|
6715
|
+
case "SshDsa":
|
|
6716
|
+
case "SshEcdsaP256":
|
|
6717
|
+
case "SshEcdsaP384": return `SigningPublicKey(${this._type}, SSH scheme not supported)`;
|
|
6765
6718
|
}
|
|
6766
6719
|
}
|
|
6767
6720
|
/**
|
|
@@ -6784,7 +6737,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6784
6737
|
verify(signature, message) {
|
|
6785
6738
|
if (signature.scheme() !== this._type) return false;
|
|
6786
6739
|
switch (this._type) {
|
|
6787
|
-
case
|
|
6740
|
+
case "Schnorr": {
|
|
6788
6741
|
if (this._schnorrKey === void 0) return false;
|
|
6789
6742
|
const sigData = signature.toSchnorr();
|
|
6790
6743
|
if (sigData === null) return false;
|
|
@@ -6794,7 +6747,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6794
6747
|
return false;
|
|
6795
6748
|
}
|
|
6796
6749
|
}
|
|
6797
|
-
case
|
|
6750
|
+
case "Ecdsa": {
|
|
6798
6751
|
if (this._ecdsaKey === void 0) return false;
|
|
6799
6752
|
const sigData = signature.toEcdsa();
|
|
6800
6753
|
if (sigData === null) return false;
|
|
@@ -6804,7 +6757,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6804
6757
|
return false;
|
|
6805
6758
|
}
|
|
6806
6759
|
}
|
|
6807
|
-
case
|
|
6760
|
+
case "Ed25519": {
|
|
6808
6761
|
if (this._ed25519Key === void 0) return false;
|
|
6809
6762
|
const sigData = signature.toEd25519();
|
|
6810
6763
|
if (sigData === null) return false;
|
|
@@ -6814,7 +6767,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6814
6767
|
return false;
|
|
6815
6768
|
}
|
|
6816
6769
|
}
|
|
6817
|
-
case
|
|
6770
|
+
case "Sr25519": {
|
|
6818
6771
|
if (this._sr25519Key === void 0) return false;
|
|
6819
6772
|
const sigData = signature.toSr25519();
|
|
6820
6773
|
if (sigData === null) return false;
|
|
@@ -6824,9 +6777,9 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6824
6777
|
return false;
|
|
6825
6778
|
}
|
|
6826
6779
|
}
|
|
6827
|
-
case
|
|
6828
|
-
case
|
|
6829
|
-
case
|
|
6780
|
+
case "MLDSA44":
|
|
6781
|
+
case "MLDSA65":
|
|
6782
|
+
case "MLDSA87": {
|
|
6830
6783
|
if (this._mldsaKey === void 0) return false;
|
|
6831
6784
|
const mldsaSig = signature.toMldsa();
|
|
6832
6785
|
if (mldsaSig === null) return false;
|
|
@@ -6836,10 +6789,10 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6836
6789
|
return false;
|
|
6837
6790
|
}
|
|
6838
6791
|
}
|
|
6839
|
-
case
|
|
6840
|
-
case
|
|
6841
|
-
case
|
|
6842
|
-
case
|
|
6792
|
+
case "SshEd25519":
|
|
6793
|
+
case "SshDsa":
|
|
6794
|
+
case "SshEcdsaP256":
|
|
6795
|
+
case "SshEcdsaP384": return false;
|
|
6843
6796
|
}
|
|
6844
6797
|
}
|
|
6845
6798
|
/**
|
|
@@ -6859,27 +6812,27 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6859
6812
|
*/
|
|
6860
6813
|
untaggedCbor() {
|
|
6861
6814
|
switch (this._type) {
|
|
6862
|
-
case
|
|
6815
|
+
case "Schnorr":
|
|
6863
6816
|
if (this._schnorrKey === void 0) throw new Error("Schnorr public key is missing");
|
|
6864
6817
|
return (0, _bcts_dcbor.toByteString)(this._schnorrKey.toData());
|
|
6865
|
-
case
|
|
6818
|
+
case "Ecdsa":
|
|
6866
6819
|
if (this._ecdsaKey === void 0) throw new Error("ECDSA public key is missing");
|
|
6867
6820
|
return (0, _bcts_dcbor.cbor)([1, (0, _bcts_dcbor.toByteString)(this._ecdsaKey.toData())]);
|
|
6868
|
-
case
|
|
6821
|
+
case "Ed25519":
|
|
6869
6822
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 public key is missing");
|
|
6870
6823
|
return (0, _bcts_dcbor.cbor)([2, (0, _bcts_dcbor.toByteString)(this._ed25519Key.toData())]);
|
|
6871
|
-
case
|
|
6824
|
+
case "Sr25519":
|
|
6872
6825
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 public key is missing");
|
|
6873
6826
|
return (0, _bcts_dcbor.cbor)([3, (0, _bcts_dcbor.toByteString)(this._sr25519Key.toData())]);
|
|
6874
|
-
case
|
|
6875
|
-
case
|
|
6876
|
-
case
|
|
6827
|
+
case "MLDSA44":
|
|
6828
|
+
case "MLDSA65":
|
|
6829
|
+
case "MLDSA87":
|
|
6877
6830
|
if (this._mldsaKey === void 0) throw new Error("MLDSA public key is missing");
|
|
6878
6831
|
return this._mldsaKey.taggedCbor();
|
|
6879
|
-
case
|
|
6880
|
-
case
|
|
6881
|
-
case
|
|
6882
|
-
case
|
|
6832
|
+
case "SshEd25519":
|
|
6833
|
+
case "SshDsa":
|
|
6834
|
+
case "SshEcdsaP256":
|
|
6835
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported for CBOR encoding`);
|
|
6883
6836
|
}
|
|
6884
6837
|
}
|
|
6885
6838
|
/**
|
|
@@ -6940,7 +6893,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6940
6893
|
* Static method to decode from tagged CBOR.
|
|
6941
6894
|
*/
|
|
6942
6895
|
static fromTaggedCbor(cborValue) {
|
|
6943
|
-
return new SigningPublicKey(
|
|
6896
|
+
return new SigningPublicKey("Ed25519", void 0, void 0, Ed25519PublicKey.from(new Uint8Array(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE))).fromTaggedCbor(cborValue);
|
|
6944
6897
|
}
|
|
6945
6898
|
/**
|
|
6946
6899
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -6954,7 +6907,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6954
6907
|
*/
|
|
6955
6908
|
static fromUntaggedCborData(data) {
|
|
6956
6909
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
6957
|
-
return new SigningPublicKey(
|
|
6910
|
+
return new SigningPublicKey("Ed25519", void 0, void 0, Ed25519PublicKey.from(new Uint8Array(_bcts_crypto.ED25519_PUBLIC_KEY_SIZE))).fromUntaggedCbor(cborValue);
|
|
6958
6911
|
}
|
|
6959
6912
|
/**
|
|
6960
6913
|
* Get the UR type for signing public keys.
|
|
@@ -6997,7 +6950,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6997
6950
|
* Currently only supports Ed25519 keys.
|
|
6998
6951
|
*/
|
|
6999
6952
|
toSsh(comment) {
|
|
7000
|
-
if (this._type !==
|
|
6953
|
+
if (this._type !== "Ed25519") throw new Error(`SSH export only supports Ed25519 keys, got ${this._type}`);
|
|
7001
6954
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 key not initialized");
|
|
7002
6955
|
const algorithm = "ssh-ed25519";
|
|
7003
6956
|
const algorithmBytes = new TextEncoder().encode(algorithm);
|
|
@@ -7033,7 +6986,6 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
7033
6986
|
return comment !== void 0 && comment !== "" ? `${result} ${comment}` : result;
|
|
7034
6987
|
}
|
|
7035
6988
|
};
|
|
7036
|
-
|
|
7037
6989
|
//#endregion
|
|
7038
6990
|
//#region src/signing/signing-private-key.ts
|
|
7039
6991
|
/**
|
|
@@ -7090,7 +7042,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7090
7042
|
* @returns A new Schnorr signing private key
|
|
7091
7043
|
*/
|
|
7092
7044
|
static newSchnorr(key) {
|
|
7093
|
-
return new SigningPrivateKey(
|
|
7045
|
+
return new SigningPrivateKey("Schnorr", key, void 0, void 0, void 0);
|
|
7094
7046
|
}
|
|
7095
7047
|
/**
|
|
7096
7048
|
* Creates a new ECDSA signing private key from an ECPrivateKey.
|
|
@@ -7099,7 +7051,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7099
7051
|
* @returns A new ECDSA signing private key
|
|
7100
7052
|
*/
|
|
7101
7053
|
static newEcdsa(key) {
|
|
7102
|
-
return new SigningPrivateKey(
|
|
7054
|
+
return new SigningPrivateKey("Ecdsa", key, void 0, void 0, void 0);
|
|
7103
7055
|
}
|
|
7104
7056
|
/**
|
|
7105
7057
|
* Creates a new Ed25519 signing private key from an Ed25519PrivateKey.
|
|
@@ -7108,7 +7060,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7108
7060
|
* @returns A new Ed25519 signing private key
|
|
7109
7061
|
*/
|
|
7110
7062
|
static newEd25519(key) {
|
|
7111
|
-
return new SigningPrivateKey(
|
|
7063
|
+
return new SigningPrivateKey("Ed25519", void 0, key, void 0, void 0);
|
|
7112
7064
|
}
|
|
7113
7065
|
/**
|
|
7114
7066
|
* Creates a new SR25519 signing private key from an Sr25519PrivateKey.
|
|
@@ -7117,7 +7069,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7117
7069
|
* @returns A new SR25519 signing private key
|
|
7118
7070
|
*/
|
|
7119
7071
|
static newSr25519(key) {
|
|
7120
|
-
return new SigningPrivateKey(
|
|
7072
|
+
return new SigningPrivateKey("Sr25519", void 0, void 0, key, void 0);
|
|
7121
7073
|
}
|
|
7122
7074
|
/**
|
|
7123
7075
|
* Creates a new MLDSA signing private key from an MLDSAPrivateKey.
|
|
@@ -7128,14 +7080,14 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7128
7080
|
static newMldsa(key) {
|
|
7129
7081
|
let scheme;
|
|
7130
7082
|
switch (key.level()) {
|
|
7131
|
-
case
|
|
7132
|
-
scheme =
|
|
7083
|
+
case 2:
|
|
7084
|
+
scheme = "MLDSA44";
|
|
7133
7085
|
break;
|
|
7134
|
-
case
|
|
7135
|
-
scheme =
|
|
7086
|
+
case 3:
|
|
7087
|
+
scheme = "MLDSA65";
|
|
7136
7088
|
break;
|
|
7137
|
-
case
|
|
7138
|
-
scheme =
|
|
7089
|
+
case 5:
|
|
7090
|
+
scheme = "MLDSA87";
|
|
7139
7091
|
break;
|
|
7140
7092
|
default: throw new Error(`Unknown MLDSA level: ${key.level()}`);
|
|
7141
7093
|
}
|
|
@@ -7185,17 +7137,17 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7185
7137
|
*/
|
|
7186
7138
|
keyType() {
|
|
7187
7139
|
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
|
|
7140
|
+
case "Ed25519": return "Ed25519";
|
|
7141
|
+
case "Schnorr": return "Schnorr";
|
|
7142
|
+
case "Ecdsa": return "ECDSA";
|
|
7143
|
+
case "Sr25519": return "Sr25519";
|
|
7144
|
+
case "MLDSA44": return "MLDSA-44";
|
|
7145
|
+
case "MLDSA65": return "MLDSA-65";
|
|
7146
|
+
case "MLDSA87": return "MLDSA-87";
|
|
7147
|
+
case "SshEd25519": return "SSH-Ed25519";
|
|
7148
|
+
case "SshDsa": return "SSH-DSA";
|
|
7149
|
+
case "SshEcdsaP256": return "SSH-ECDSA-P256";
|
|
7150
|
+
case "SshEcdsaP384": return "SSH-ECDSA-P384";
|
|
7199
7151
|
default: return this._type;
|
|
7200
7152
|
}
|
|
7201
7153
|
}
|
|
@@ -7205,7 +7157,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7205
7157
|
* @returns The EC private key if this is a Schnorr or ECDSA key, null otherwise
|
|
7206
7158
|
*/
|
|
7207
7159
|
toEc() {
|
|
7208
|
-
if ((this._type ===
|
|
7160
|
+
if ((this._type === "Schnorr" || this._type === "Ecdsa") && this._ecKey !== void 0) return this._ecKey;
|
|
7209
7161
|
return null;
|
|
7210
7162
|
}
|
|
7211
7163
|
/**
|
|
@@ -7214,7 +7166,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7214
7166
|
* @returns The EC private key if this is a Schnorr key, null otherwise
|
|
7215
7167
|
*/
|
|
7216
7168
|
toSchnorr() {
|
|
7217
|
-
if (this._type ===
|
|
7169
|
+
if (this._type === "Schnorr" && this._ecKey !== void 0) return this._ecKey;
|
|
7218
7170
|
return null;
|
|
7219
7171
|
}
|
|
7220
7172
|
/**
|
|
@@ -7223,7 +7175,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7223
7175
|
* @returns The EC private key if this is an ECDSA key, null otherwise
|
|
7224
7176
|
*/
|
|
7225
7177
|
toEcdsa() {
|
|
7226
|
-
if (this._type ===
|
|
7178
|
+
if (this._type === "Ecdsa" && this._ecKey !== void 0) return this._ecKey;
|
|
7227
7179
|
return null;
|
|
7228
7180
|
}
|
|
7229
7181
|
/**
|
|
@@ -7232,7 +7184,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7232
7184
|
* @returns The Ed25519 private key if this is an Ed25519 key, null otherwise
|
|
7233
7185
|
*/
|
|
7234
7186
|
toEd25519() {
|
|
7235
|
-
if (this._type ===
|
|
7187
|
+
if (this._type === "Ed25519" && this._ed25519Key !== void 0) return this._ed25519Key;
|
|
7236
7188
|
return null;
|
|
7237
7189
|
}
|
|
7238
7190
|
/**
|
|
@@ -7241,7 +7193,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7241
7193
|
* @returns The Sr25519 private key if this is an Sr25519 key, null otherwise
|
|
7242
7194
|
*/
|
|
7243
7195
|
toSr25519() {
|
|
7244
|
-
if (this._type ===
|
|
7196
|
+
if (this._type === "Sr25519" && this._sr25519Key !== void 0) return this._sr25519Key;
|
|
7245
7197
|
return null;
|
|
7246
7198
|
}
|
|
7247
7199
|
/**
|
|
@@ -7257,25 +7209,25 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7257
7209
|
* Checks if this is a Schnorr signing key.
|
|
7258
7210
|
*/
|
|
7259
7211
|
isSchnorr() {
|
|
7260
|
-
return this._type ===
|
|
7212
|
+
return this._type === "Schnorr";
|
|
7261
7213
|
}
|
|
7262
7214
|
/**
|
|
7263
7215
|
* Checks if this is an ECDSA signing key.
|
|
7264
7216
|
*/
|
|
7265
7217
|
isEcdsa() {
|
|
7266
|
-
return this._type ===
|
|
7218
|
+
return this._type === "Ecdsa";
|
|
7267
7219
|
}
|
|
7268
7220
|
/**
|
|
7269
7221
|
* Checks if this is an Ed25519 signing key.
|
|
7270
7222
|
*/
|
|
7271
7223
|
isEd25519() {
|
|
7272
|
-
return this._type ===
|
|
7224
|
+
return this._type === "Ed25519";
|
|
7273
7225
|
}
|
|
7274
7226
|
/**
|
|
7275
7227
|
* Checks if this is an Sr25519 signing key.
|
|
7276
7228
|
*/
|
|
7277
7229
|
isSr25519() {
|
|
7278
|
-
return this._type ===
|
|
7230
|
+
return this._type === "Sr25519";
|
|
7279
7231
|
}
|
|
7280
7232
|
/**
|
|
7281
7233
|
* Checks if this is an MLDSA signing key.
|
|
@@ -7290,27 +7242,27 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7290
7242
|
*/
|
|
7291
7243
|
publicKey() {
|
|
7292
7244
|
switch (this._type) {
|
|
7293
|
-
case
|
|
7245
|
+
case "Schnorr":
|
|
7294
7246
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7295
7247
|
return SigningPublicKey.fromSchnorr(this._ecKey.schnorrPublicKey());
|
|
7296
|
-
case
|
|
7248
|
+
case "Ecdsa":
|
|
7297
7249
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7298
7250
|
return SigningPublicKey.fromEcdsa(this._ecKey.publicKey());
|
|
7299
|
-
case
|
|
7251
|
+
case "Ed25519":
|
|
7300
7252
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 private key is missing");
|
|
7301
7253
|
return SigningPublicKey.fromEd25519(this._ed25519Key.publicKey());
|
|
7302
|
-
case
|
|
7254
|
+
case "Sr25519":
|
|
7303
7255
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 private key is missing");
|
|
7304
7256
|
return SigningPublicKey.fromSr25519(this._sr25519Key.publicKey());
|
|
7305
|
-
case
|
|
7306
|
-
case
|
|
7307
|
-
case
|
|
7257
|
+
case "MLDSA44":
|
|
7258
|
+
case "MLDSA65":
|
|
7259
|
+
case "MLDSA87":
|
|
7308
7260
|
if (this._mldsaKey === void 0) throw new Error("MLDSA private key is missing");
|
|
7309
7261
|
return SigningPublicKey.fromMldsa(this._mldsaKey.publicKey());
|
|
7310
|
-
case
|
|
7311
|
-
case
|
|
7312
|
-
case
|
|
7313
|
-
case
|
|
7262
|
+
case "SshEd25519":
|
|
7263
|
+
case "SshDsa":
|
|
7264
|
+
case "SshEcdsaP256":
|
|
7265
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported`);
|
|
7314
7266
|
}
|
|
7315
7267
|
}
|
|
7316
7268
|
/**
|
|
@@ -7319,25 +7271,25 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7319
7271
|
equals(other) {
|
|
7320
7272
|
if (this._type !== other._type) return false;
|
|
7321
7273
|
switch (this._type) {
|
|
7322
|
-
case
|
|
7323
|
-
case
|
|
7274
|
+
case "Schnorr":
|
|
7275
|
+
case "Ecdsa":
|
|
7324
7276
|
if (this._ecKey === void 0 || other._ecKey === void 0) return false;
|
|
7325
7277
|
return this._ecKey.equals(other._ecKey);
|
|
7326
|
-
case
|
|
7278
|
+
case "Ed25519":
|
|
7327
7279
|
if (this._ed25519Key === void 0 || other._ed25519Key === void 0) return false;
|
|
7328
7280
|
return this._ed25519Key.equals(other._ed25519Key);
|
|
7329
|
-
case
|
|
7281
|
+
case "Sr25519":
|
|
7330
7282
|
if (this._sr25519Key === void 0 || other._sr25519Key === void 0) return false;
|
|
7331
7283
|
return this._sr25519Key.equals(other._sr25519Key);
|
|
7332
|
-
case
|
|
7333
|
-
case
|
|
7334
|
-
case
|
|
7284
|
+
case "MLDSA44":
|
|
7285
|
+
case "MLDSA65":
|
|
7286
|
+
case "MLDSA87":
|
|
7335
7287
|
if (this._mldsaKey === void 0 || other._mldsaKey === void 0) return false;
|
|
7336
7288
|
return this._mldsaKey.equals(other._mldsaKey);
|
|
7337
|
-
case
|
|
7338
|
-
case
|
|
7339
|
-
case
|
|
7340
|
-
case
|
|
7289
|
+
case "SshEd25519":
|
|
7290
|
+
case "SshDsa":
|
|
7291
|
+
case "SshEcdsaP256":
|
|
7292
|
+
case "SshEcdsaP384": return false;
|
|
7341
7293
|
}
|
|
7342
7294
|
}
|
|
7343
7295
|
/**
|
|
@@ -7370,41 +7322,41 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7370
7322
|
*/
|
|
7371
7323
|
signWithOptions(message, options) {
|
|
7372
7324
|
switch (this._type) {
|
|
7373
|
-
case
|
|
7325
|
+
case "Schnorr": {
|
|
7374
7326
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7375
7327
|
if (options?.type === "Schnorr") {
|
|
7376
|
-
const sigData
|
|
7377
|
-
return Signature.schnorrFromData(sigData
|
|
7328
|
+
const sigData = this._ecKey.schnorrSignUsing(message, options.rng);
|
|
7329
|
+
return Signature.schnorrFromData(sigData);
|
|
7378
7330
|
}
|
|
7379
7331
|
const sigData = this._ecKey.schnorrSign(message);
|
|
7380
7332
|
return Signature.schnorrFromData(sigData);
|
|
7381
7333
|
}
|
|
7382
|
-
case
|
|
7334
|
+
case "Ecdsa": {
|
|
7383
7335
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7384
7336
|
const sigData = this._ecKey.ecdsaSign(message);
|
|
7385
7337
|
return Signature.ecdsaFromData(sigData);
|
|
7386
7338
|
}
|
|
7387
|
-
case
|
|
7339
|
+
case "Ed25519": {
|
|
7388
7340
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 private key is missing");
|
|
7389
7341
|
const sigData = this._ed25519Key.sign(message);
|
|
7390
7342
|
return Signature.ed25519FromData(sigData);
|
|
7391
7343
|
}
|
|
7392
|
-
case
|
|
7344
|
+
case "Sr25519": {
|
|
7393
7345
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 private key is missing");
|
|
7394
7346
|
const sigData = this._sr25519Key.sign(message);
|
|
7395
7347
|
return Signature.sr25519FromData(sigData);
|
|
7396
7348
|
}
|
|
7397
|
-
case
|
|
7398
|
-
case
|
|
7399
|
-
case
|
|
7349
|
+
case "MLDSA44":
|
|
7350
|
+
case "MLDSA65":
|
|
7351
|
+
case "MLDSA87": {
|
|
7400
7352
|
if (this._mldsaKey === void 0) throw new Error("MLDSA private key is missing");
|
|
7401
7353
|
const mldsaSig = this._mldsaKey.sign(message);
|
|
7402
7354
|
return Signature.mldsaFromSignature(mldsaSig);
|
|
7403
7355
|
}
|
|
7404
|
-
case
|
|
7405
|
-
case
|
|
7406
|
-
case
|
|
7407
|
-
case
|
|
7356
|
+
case "SshEd25519":
|
|
7357
|
+
case "SshDsa":
|
|
7358
|
+
case "SshEcdsaP256":
|
|
7359
|
+
case "SshEcdsaP384":
|
|
7408
7360
|
if (options?.type === "Ssh") throw new Error(`SSH signature scheme ${this._type} is not yet implemented. Namespace: ${options.namespace}, hashAlg: ${options.hashAlg}`);
|
|
7409
7361
|
throw new Error(`SSH signature scheme ${this._type} requires SigningOptions.Ssh`);
|
|
7410
7362
|
}
|
|
@@ -7524,27 +7476,27 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7524
7476
|
*/
|
|
7525
7477
|
untaggedCbor() {
|
|
7526
7478
|
switch (this._type) {
|
|
7527
|
-
case
|
|
7479
|
+
case "Schnorr":
|
|
7528
7480
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7529
7481
|
return (0, _bcts_dcbor.toByteString)(this._ecKey.toData());
|
|
7530
|
-
case
|
|
7482
|
+
case "Ecdsa":
|
|
7531
7483
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7532
7484
|
return (0, _bcts_dcbor.cbor)([1, (0, _bcts_dcbor.toByteString)(this._ecKey.toData())]);
|
|
7533
|
-
case
|
|
7485
|
+
case "Ed25519":
|
|
7534
7486
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 private key is missing");
|
|
7535
7487
|
return (0, _bcts_dcbor.cbor)([2, (0, _bcts_dcbor.toByteString)(this._ed25519Key.toData())]);
|
|
7536
|
-
case
|
|
7488
|
+
case "Sr25519":
|
|
7537
7489
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 private key is missing");
|
|
7538
7490
|
return (0, _bcts_dcbor.cbor)([3, (0, _bcts_dcbor.toByteString)(this._sr25519Key.toData())]);
|
|
7539
|
-
case
|
|
7540
|
-
case
|
|
7541
|
-
case
|
|
7491
|
+
case "MLDSA44":
|
|
7492
|
+
case "MLDSA65":
|
|
7493
|
+
case "MLDSA87":
|
|
7542
7494
|
if (this._mldsaKey === void 0) throw new Error("MLDSA private key is missing");
|
|
7543
7495
|
return this._mldsaKey.taggedCbor();
|
|
7544
|
-
case
|
|
7545
|
-
case
|
|
7546
|
-
case
|
|
7547
|
-
case
|
|
7496
|
+
case "SshEd25519":
|
|
7497
|
+
case "SshDsa":
|
|
7498
|
+
case "SshEcdsaP256":
|
|
7499
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported for CBOR encoding`);
|
|
7548
7500
|
}
|
|
7549
7501
|
}
|
|
7550
7502
|
/**
|
|
@@ -7606,7 +7558,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7606
7558
|
* Static method to decode from tagged CBOR.
|
|
7607
7559
|
*/
|
|
7608
7560
|
static fromTaggedCbor(cborValue) {
|
|
7609
|
-
return new SigningPrivateKey(
|
|
7561
|
+
return new SigningPrivateKey("Ed25519", void 0, Ed25519PrivateKey.from(new Uint8Array(_bcts_crypto.ED25519_PRIVATE_KEY_SIZE))).fromTaggedCbor(cborValue);
|
|
7610
7562
|
}
|
|
7611
7563
|
/**
|
|
7612
7564
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -7620,7 +7572,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7620
7572
|
*/
|
|
7621
7573
|
static fromUntaggedCborData(data) {
|
|
7622
7574
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
7623
|
-
return new SigningPrivateKey(
|
|
7575
|
+
return new SigningPrivateKey("Ed25519", void 0, Ed25519PrivateKey.from(new Uint8Array(_bcts_crypto.ED25519_PRIVATE_KEY_SIZE))).fromUntaggedCbor(cborValue);
|
|
7624
7576
|
}
|
|
7625
7577
|
/**
|
|
7626
7578
|
* Get the UR type for signing private keys.
|
|
@@ -7663,7 +7615,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7663
7615
|
* Currently only supports Ed25519 keys.
|
|
7664
7616
|
*/
|
|
7665
7617
|
toSsh(comment) {
|
|
7666
|
-
if (this._type !==
|
|
7618
|
+
if (this._type !== "Ed25519") throw new Error(`SSH export only supports Ed25519 keys, got ${this._type}`);
|
|
7667
7619
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 key not initialized");
|
|
7668
7620
|
const publicKey = this._ed25519Key.publicKey();
|
|
7669
7621
|
const privateKeyBytes = this._ed25519Key.toData();
|
|
@@ -7684,7 +7636,6 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
7684
7636
|
-----END OPENSSH PRIVATE KEY-----`;
|
|
7685
7637
|
}
|
|
7686
7638
|
};
|
|
7687
|
-
|
|
7688
7639
|
//#endregion
|
|
7689
7640
|
//#region src/signing/signature-scheme.ts
|
|
7690
7641
|
/**
|
|
@@ -7703,65 +7654,65 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
7703
7654
|
* - SshEcdsaP256: ECDSA P-256 via SSH agent
|
|
7704
7655
|
* - SshEcdsaP384: ECDSA P-384 via SSH agent
|
|
7705
7656
|
*/
|
|
7706
|
-
let SignatureScheme = /* @__PURE__ */ function(SignatureScheme
|
|
7657
|
+
let SignatureScheme = /* @__PURE__ */ function(SignatureScheme) {
|
|
7707
7658
|
/**
|
|
7708
7659
|
* BIP-340 Schnorr signature scheme (secp256k1)
|
|
7709
7660
|
* Default scheme (matching Rust bc-components default when secp256k1 is enabled)
|
|
7710
7661
|
*/
|
|
7711
|
-
SignatureScheme
|
|
7662
|
+
SignatureScheme["Schnorr"] = "Schnorr";
|
|
7712
7663
|
/**
|
|
7713
7664
|
* ECDSA signature scheme (secp256k1)
|
|
7714
7665
|
*/
|
|
7715
|
-
SignatureScheme
|
|
7666
|
+
SignatureScheme["Ecdsa"] = "Ecdsa";
|
|
7716
7667
|
/**
|
|
7717
7668
|
* Ed25519 signature scheme (RFC 8032)
|
|
7718
7669
|
*/
|
|
7719
|
-
SignatureScheme
|
|
7670
|
+
SignatureScheme["Ed25519"] = "Ed25519";
|
|
7720
7671
|
/**
|
|
7721
7672
|
* SR25519 signature scheme (Schnorr over Ristretto25519)
|
|
7722
7673
|
* Used by Polkadot/Substrate
|
|
7723
7674
|
*/
|
|
7724
|
-
SignatureScheme
|
|
7675
|
+
SignatureScheme["Sr25519"] = "Sr25519";
|
|
7725
7676
|
/**
|
|
7726
7677
|
* ML-DSA44 post-quantum signature scheme (NIST level 2)
|
|
7727
7678
|
*/
|
|
7728
|
-
SignatureScheme
|
|
7679
|
+
SignatureScheme["MLDSA44"] = "MLDSA44";
|
|
7729
7680
|
/**
|
|
7730
7681
|
* ML-DSA65 post-quantum signature scheme (NIST level 3)
|
|
7731
7682
|
*/
|
|
7732
|
-
SignatureScheme
|
|
7683
|
+
SignatureScheme["MLDSA65"] = "MLDSA65";
|
|
7733
7684
|
/**
|
|
7734
7685
|
* ML-DSA87 post-quantum signature scheme (NIST level 5)
|
|
7735
7686
|
*/
|
|
7736
|
-
SignatureScheme
|
|
7687
|
+
SignatureScheme["MLDSA87"] = "MLDSA87";
|
|
7737
7688
|
/**
|
|
7738
7689
|
* Ed25519 signature via SSH agent.
|
|
7739
7690
|
* Requires SSH agent daemon support.
|
|
7740
7691
|
*/
|
|
7741
|
-
SignatureScheme
|
|
7692
|
+
SignatureScheme["SshEd25519"] = "SshEd25519";
|
|
7742
7693
|
/**
|
|
7743
7694
|
* DSA signature via SSH agent.
|
|
7744
7695
|
* Requires SSH agent daemon support.
|
|
7745
7696
|
*/
|
|
7746
|
-
SignatureScheme
|
|
7697
|
+
SignatureScheme["SshDsa"] = "SshDsa";
|
|
7747
7698
|
/**
|
|
7748
7699
|
* ECDSA P-256 signature via SSH agent.
|
|
7749
7700
|
* Requires SSH agent daemon support.
|
|
7750
7701
|
*/
|
|
7751
|
-
SignatureScheme
|
|
7702
|
+
SignatureScheme["SshEcdsaP256"] = "SshEcdsaP256";
|
|
7752
7703
|
/**
|
|
7753
7704
|
* ECDSA P-384 signature via SSH agent.
|
|
7754
7705
|
* Requires SSH agent daemon support.
|
|
7755
7706
|
*/
|
|
7756
|
-
SignatureScheme
|
|
7757
|
-
return SignatureScheme
|
|
7707
|
+
SignatureScheme["SshEcdsaP384"] = "SshEcdsaP384";
|
|
7708
|
+
return SignatureScheme;
|
|
7758
7709
|
}({});
|
|
7759
7710
|
/**
|
|
7760
7711
|
* Get the default signature scheme.
|
|
7761
7712
|
* Defaults to Schnorr (matching Rust bc-components default when secp256k1 is enabled).
|
|
7762
7713
|
*/
|
|
7763
7714
|
function defaultSignatureScheme() {
|
|
7764
|
-
return
|
|
7715
|
+
return "Schnorr";
|
|
7765
7716
|
}
|
|
7766
7717
|
/**
|
|
7767
7718
|
* Check if a signature scheme requires SSH agent support.
|
|
@@ -7770,7 +7721,7 @@ function defaultSignatureScheme() {
|
|
|
7770
7721
|
* @returns true if the scheme requires SSH agent
|
|
7771
7722
|
*/
|
|
7772
7723
|
function isSshScheme(scheme) {
|
|
7773
|
-
return scheme ===
|
|
7724
|
+
return scheme === "SshEd25519" || scheme === "SshDsa" || scheme === "SshEcdsaP256" || scheme === "SshEcdsaP384";
|
|
7774
7725
|
}
|
|
7775
7726
|
/**
|
|
7776
7727
|
* Check if a signature scheme is a post-quantum ML-DSA scheme.
|
|
@@ -7779,7 +7730,7 @@ function isSshScheme(scheme) {
|
|
|
7779
7730
|
* @returns true if the scheme is an ML-DSA scheme
|
|
7780
7731
|
*/
|
|
7781
7732
|
function isMldsaScheme(scheme) {
|
|
7782
|
-
return scheme ===
|
|
7733
|
+
return scheme === "MLDSA44" || scheme === "MLDSA65" || scheme === "MLDSA87";
|
|
7783
7734
|
}
|
|
7784
7735
|
/**
|
|
7785
7736
|
* Creates a new key pair for the signature scheme.
|
|
@@ -7790,45 +7741,45 @@ function isMldsaScheme(scheme) {
|
|
|
7790
7741
|
*/
|
|
7791
7742
|
function createKeypair(scheme) {
|
|
7792
7743
|
switch (scheme) {
|
|
7793
|
-
case
|
|
7744
|
+
case "Schnorr": {
|
|
7794
7745
|
const ecKey = ECPrivateKey.random();
|
|
7795
7746
|
const privateKey = SigningPrivateKey.newSchnorr(ecKey);
|
|
7796
7747
|
return [privateKey, privateKey.publicKey()];
|
|
7797
7748
|
}
|
|
7798
|
-
case
|
|
7749
|
+
case "Ecdsa": {
|
|
7799
7750
|
const ecKey = ECPrivateKey.random();
|
|
7800
7751
|
const privateKey = SigningPrivateKey.newEcdsa(ecKey);
|
|
7801
7752
|
return [privateKey, privateKey.publicKey()];
|
|
7802
7753
|
}
|
|
7803
|
-
case
|
|
7754
|
+
case "Ed25519": {
|
|
7804
7755
|
const ed25519Key = Ed25519PrivateKey.random();
|
|
7805
7756
|
const privateKey = SigningPrivateKey.newEd25519(ed25519Key);
|
|
7806
7757
|
return [privateKey, privateKey.publicKey()];
|
|
7807
7758
|
}
|
|
7808
|
-
case
|
|
7759
|
+
case "Sr25519": {
|
|
7809
7760
|
const sr25519Key = Sr25519PrivateKey.random();
|
|
7810
7761
|
const privateKey = SigningPrivateKey.newSr25519(sr25519Key);
|
|
7811
7762
|
return [privateKey, privateKey.publicKey()];
|
|
7812
7763
|
}
|
|
7813
|
-
case
|
|
7814
|
-
const mldsaKey = MLDSAPrivateKey.new(
|
|
7764
|
+
case "MLDSA44": {
|
|
7765
|
+
const mldsaKey = MLDSAPrivateKey.new(2);
|
|
7815
7766
|
const privateKey = SigningPrivateKey.newMldsa(mldsaKey);
|
|
7816
7767
|
return [privateKey, privateKey.publicKey()];
|
|
7817
7768
|
}
|
|
7818
|
-
case
|
|
7819
|
-
const mldsaKey = MLDSAPrivateKey.new(
|
|
7769
|
+
case "MLDSA65": {
|
|
7770
|
+
const mldsaKey = MLDSAPrivateKey.new(3);
|
|
7820
7771
|
const privateKey = SigningPrivateKey.newMldsa(mldsaKey);
|
|
7821
7772
|
return [privateKey, privateKey.publicKey()];
|
|
7822
7773
|
}
|
|
7823
|
-
case
|
|
7824
|
-
const mldsaKey = MLDSAPrivateKey.new(
|
|
7774
|
+
case "MLDSA87": {
|
|
7775
|
+
const mldsaKey = MLDSAPrivateKey.new(5);
|
|
7825
7776
|
const privateKey = SigningPrivateKey.newMldsa(mldsaKey);
|
|
7826
7777
|
return [privateKey, privateKey.publicKey()];
|
|
7827
7778
|
}
|
|
7828
|
-
case
|
|
7829
|
-
case
|
|
7830
|
-
case
|
|
7831
|
-
case
|
|
7779
|
+
case "SshEd25519":
|
|
7780
|
+
case "SshDsa":
|
|
7781
|
+
case "SshEcdsaP256":
|
|
7782
|
+
case "SshEcdsaP384": throw require_digest.CryptoError.sshAgent(`SSH signature scheme ${scheme} requires SSH agent support which is not yet implemented. Use Ed25519, Sr25519, Schnorr, ECDSA, or MLDSA variants instead.`);
|
|
7832
7783
|
}
|
|
7833
7784
|
}
|
|
7834
7785
|
/**
|
|
@@ -7841,36 +7792,35 @@ function createKeypair(scheme) {
|
|
|
7841
7792
|
*/
|
|
7842
7793
|
function createKeypairUsing(scheme, rng) {
|
|
7843
7794
|
switch (scheme) {
|
|
7844
|
-
case
|
|
7795
|
+
case "Schnorr": {
|
|
7845
7796
|
const ecKey = ECPrivateKey.newUsing(rng);
|
|
7846
7797
|
const privateKey = SigningPrivateKey.newSchnorr(ecKey);
|
|
7847
7798
|
return [privateKey, privateKey.publicKey()];
|
|
7848
7799
|
}
|
|
7849
|
-
case
|
|
7800
|
+
case "Ecdsa": {
|
|
7850
7801
|
const ecKey = ECPrivateKey.newUsing(rng);
|
|
7851
7802
|
const privateKey = SigningPrivateKey.newEcdsa(ecKey);
|
|
7852
7803
|
return [privateKey, privateKey.publicKey()];
|
|
7853
7804
|
}
|
|
7854
|
-
case
|
|
7805
|
+
case "Ed25519": {
|
|
7855
7806
|
const ed25519Key = Ed25519PrivateKey.randomUsing(rng);
|
|
7856
7807
|
const privateKey = SigningPrivateKey.newEd25519(ed25519Key);
|
|
7857
7808
|
return [privateKey, privateKey.publicKey()];
|
|
7858
7809
|
}
|
|
7859
|
-
case
|
|
7810
|
+
case "Sr25519": {
|
|
7860
7811
|
const sr25519Key = Sr25519PrivateKey.randomUsing(rng);
|
|
7861
7812
|
const privateKey = SigningPrivateKey.newSr25519(sr25519Key);
|
|
7862
7813
|
return [privateKey, privateKey.publicKey()];
|
|
7863
7814
|
}
|
|
7864
|
-
case
|
|
7865
|
-
case
|
|
7866
|
-
case
|
|
7867
|
-
case
|
|
7868
|
-
case
|
|
7869
|
-
case
|
|
7870
|
-
case
|
|
7815
|
+
case "MLDSA44":
|
|
7816
|
+
case "MLDSA65":
|
|
7817
|
+
case "MLDSA87": throw require_digest.CryptoError.general(`Deterministic keypair generation not supported for ${scheme}. Use createKeypair() instead.`);
|
|
7818
|
+
case "SshEd25519":
|
|
7819
|
+
case "SshDsa":
|
|
7820
|
+
case "SshEcdsaP256":
|
|
7821
|
+
case "SshEcdsaP384": throw require_digest.CryptoError.sshAgent(`SSH signature scheme ${scheme} requires SSH agent support which is not yet implemented. Use Ed25519, Sr25519, Schnorr, ECDSA, or MLDSA variants instead.`);
|
|
7871
7822
|
}
|
|
7872
7823
|
}
|
|
7873
|
-
|
|
7874
7824
|
//#endregion
|
|
7875
7825
|
//#region src/mlkem/mlkem-level.ts
|
|
7876
7826
|
/**
|
|
@@ -7898,32 +7848,32 @@ function createKeypairUsing(scheme, rng) {
|
|
|
7898
7848
|
* - 768: ML-KEM-768 (NIST Level 3)
|
|
7899
7849
|
* - 1024: ML-KEM-1024 (NIST Level 5)
|
|
7900
7850
|
*/
|
|
7901
|
-
let MLKEMLevel = /* @__PURE__ */ function(MLKEMLevel
|
|
7851
|
+
let MLKEMLevel = /* @__PURE__ */ function(MLKEMLevel) {
|
|
7902
7852
|
/** NIST Level 1 - AES-128 equivalent security */
|
|
7903
|
-
MLKEMLevel
|
|
7853
|
+
MLKEMLevel[MLKEMLevel["MLKEM512"] = 512] = "MLKEM512";
|
|
7904
7854
|
/** NIST Level 3 - AES-192 equivalent security */
|
|
7905
|
-
MLKEMLevel
|
|
7855
|
+
MLKEMLevel[MLKEMLevel["MLKEM768"] = 768] = "MLKEM768";
|
|
7906
7856
|
/** NIST Level 5 - AES-256 equivalent security */
|
|
7907
|
-
MLKEMLevel
|
|
7908
|
-
return MLKEMLevel
|
|
7857
|
+
MLKEMLevel[MLKEMLevel["MLKEM1024"] = 1024] = "MLKEM1024";
|
|
7858
|
+
return MLKEMLevel;
|
|
7909
7859
|
}({});
|
|
7910
7860
|
/**
|
|
7911
7861
|
* Key sizes for each ML-KEM security level.
|
|
7912
7862
|
*/
|
|
7913
7863
|
const MLKEM_KEY_SIZES = {
|
|
7914
|
-
[
|
|
7864
|
+
[512]: {
|
|
7915
7865
|
privateKey: 1632,
|
|
7916
7866
|
publicKey: 800,
|
|
7917
7867
|
ciphertext: 768,
|
|
7918
7868
|
sharedSecret: 32
|
|
7919
7869
|
},
|
|
7920
|
-
[
|
|
7870
|
+
[768]: {
|
|
7921
7871
|
privateKey: 2400,
|
|
7922
7872
|
publicKey: 1184,
|
|
7923
7873
|
ciphertext: 1088,
|
|
7924
7874
|
sharedSecret: 32
|
|
7925
7875
|
},
|
|
7926
|
-
[
|
|
7876
|
+
[1024]: {
|
|
7927
7877
|
privateKey: 3168,
|
|
7928
7878
|
publicKey: 1568,
|
|
7929
7879
|
ciphertext: 1568,
|
|
@@ -7960,9 +7910,9 @@ function mlkemSharedSecretSize(level) {
|
|
|
7960
7910
|
*/
|
|
7961
7911
|
function mlkemLevelToString(level) {
|
|
7962
7912
|
switch (level) {
|
|
7963
|
-
case
|
|
7964
|
-
case
|
|
7965
|
-
case
|
|
7913
|
+
case 512: return "MLKEM512";
|
|
7914
|
+
case 768: return "MLKEM768";
|
|
7915
|
+
case 1024: return "MLKEM1024";
|
|
7966
7916
|
}
|
|
7967
7917
|
}
|
|
7968
7918
|
/**
|
|
@@ -7970,9 +7920,9 @@ function mlkemLevelToString(level) {
|
|
|
7970
7920
|
*/
|
|
7971
7921
|
function mlkemLevelFromValue(value) {
|
|
7972
7922
|
switch (value) {
|
|
7973
|
-
case 512: return
|
|
7974
|
-
case 768: return
|
|
7975
|
-
case 1024: return
|
|
7923
|
+
case 512: return 512;
|
|
7924
|
+
case 768: return 768;
|
|
7925
|
+
case 1024: return 1024;
|
|
7976
7926
|
default: throw new Error(`Invalid MLKEM level value: ${value}`);
|
|
7977
7927
|
}
|
|
7978
7928
|
}
|
|
@@ -7995,21 +7945,21 @@ function mlkemGenerateKeypair(level) {
|
|
|
7995
7945
|
function mlkemGenerateKeypairUsing(level, rng) {
|
|
7996
7946
|
const seed = rng.randomData(64);
|
|
7997
7947
|
switch (level) {
|
|
7998
|
-
case
|
|
7948
|
+
case 512: {
|
|
7999
7949
|
const keypair = _noble_post_quantum_ml_kem_js.ml_kem512.keygen(seed);
|
|
8000
7950
|
return {
|
|
8001
7951
|
publicKey: keypair.publicKey,
|
|
8002
7952
|
secretKey: keypair.secretKey
|
|
8003
7953
|
};
|
|
8004
7954
|
}
|
|
8005
|
-
case
|
|
7955
|
+
case 768: {
|
|
8006
7956
|
const keypair = _noble_post_quantum_ml_kem_js.ml_kem768.keygen(seed);
|
|
8007
7957
|
return {
|
|
8008
7958
|
publicKey: keypair.publicKey,
|
|
8009
7959
|
secretKey: keypair.secretKey
|
|
8010
7960
|
};
|
|
8011
7961
|
}
|
|
8012
|
-
case
|
|
7962
|
+
case 1024: {
|
|
8013
7963
|
const keypair = _noble_post_quantum_ml_kem_js.ml_kem1024.keygen(seed);
|
|
8014
7964
|
return {
|
|
8015
7965
|
publicKey: keypair.publicKey,
|
|
@@ -8027,21 +7977,21 @@ function mlkemGenerateKeypairUsing(level, rng) {
|
|
|
8027
7977
|
*/
|
|
8028
7978
|
function mlkemEncapsulate(level, publicKey) {
|
|
8029
7979
|
switch (level) {
|
|
8030
|
-
case
|
|
7980
|
+
case 512: {
|
|
8031
7981
|
const result = _noble_post_quantum_ml_kem_js.ml_kem512.encapsulate(publicKey);
|
|
8032
7982
|
return {
|
|
8033
7983
|
sharedSecret: result.sharedSecret,
|
|
8034
7984
|
ciphertext: result.cipherText
|
|
8035
7985
|
};
|
|
8036
7986
|
}
|
|
8037
|
-
case
|
|
7987
|
+
case 768: {
|
|
8038
7988
|
const result = _noble_post_quantum_ml_kem_js.ml_kem768.encapsulate(publicKey);
|
|
8039
7989
|
return {
|
|
8040
7990
|
sharedSecret: result.sharedSecret,
|
|
8041
7991
|
ciphertext: result.cipherText
|
|
8042
7992
|
};
|
|
8043
7993
|
}
|
|
8044
|
-
case
|
|
7994
|
+
case 1024: {
|
|
8045
7995
|
const result = _noble_post_quantum_ml_kem_js.ml_kem1024.encapsulate(publicKey);
|
|
8046
7996
|
return {
|
|
8047
7997
|
sharedSecret: result.sharedSecret,
|
|
@@ -8060,9 +8010,9 @@ function mlkemEncapsulate(level, publicKey) {
|
|
|
8060
8010
|
*/
|
|
8061
8011
|
function mlkemDecapsulate(level, secretKey, ciphertext) {
|
|
8062
8012
|
switch (level) {
|
|
8063
|
-
case
|
|
8064
|
-
case
|
|
8065
|
-
case
|
|
8013
|
+
case 512: return _noble_post_quantum_ml_kem_js.ml_kem512.decapsulate(ciphertext, secretKey);
|
|
8014
|
+
case 768: return _noble_post_quantum_ml_kem_js.ml_kem768.decapsulate(ciphertext, secretKey);
|
|
8015
|
+
case 1024: return _noble_post_quantum_ml_kem_js.ml_kem1024.decapsulate(ciphertext, secretKey);
|
|
8066
8016
|
}
|
|
8067
8017
|
}
|
|
8068
8018
|
/**
|
|
@@ -8071,9 +8021,9 @@ function mlkemDecapsulate(level, secretKey, ciphertext) {
|
|
|
8071
8021
|
* where dk_pke is the private portion before the public key.
|
|
8072
8022
|
*/
|
|
8073
8023
|
const MLKEM_DK_PKE_SIZES = {
|
|
8074
|
-
[
|
|
8075
|
-
[
|
|
8076
|
-
[
|
|
8024
|
+
[512]: 768,
|
|
8025
|
+
[768]: 1152,
|
|
8026
|
+
[1024]: 1536
|
|
8077
8027
|
};
|
|
8078
8028
|
/**
|
|
8079
8029
|
* Extract the public key from a secret key.
|
|
@@ -8091,7 +8041,6 @@ function mlkemExtractPublicKey(level, secretKey) {
|
|
|
8091
8041
|
const offset = dkPkeSize;
|
|
8092
8042
|
return secretKey.slice(offset, offset + publicKeySize);
|
|
8093
8043
|
}
|
|
8094
|
-
|
|
8095
8044
|
//#endregion
|
|
8096
8045
|
//#region src/mlkem/mlkem-ciphertext.ts
|
|
8097
8046
|
/**
|
|
@@ -8226,8 +8175,7 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8226
8175
|
* Static method to decode from tagged CBOR.
|
|
8227
8176
|
*/
|
|
8228
8177
|
static fromTaggedCbor(cborValue) {
|
|
8229
|
-
|
|
8230
|
-
return new MLKEMCiphertext(MLKEMLevel.MLKEM512, dummyData).fromTaggedCbor(cborValue);
|
|
8178
|
+
return new MLKEMCiphertext(512, new Uint8Array(mlkemCiphertextSize(512))).fromTaggedCbor(cborValue);
|
|
8231
8179
|
}
|
|
8232
8180
|
/**
|
|
8233
8181
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -8241,8 +8189,7 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8241
8189
|
*/
|
|
8242
8190
|
static fromUntaggedCborData(data) {
|
|
8243
8191
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
8244
|
-
|
|
8245
|
-
return new MLKEMCiphertext(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(cborValue);
|
|
8192
|
+
return new MLKEMCiphertext(512, new Uint8Array(mlkemCiphertextSize(512))).fromUntaggedCbor(cborValue);
|
|
8246
8193
|
}
|
|
8247
8194
|
/**
|
|
8248
8195
|
* Returns the UR representation.
|
|
@@ -8263,8 +8210,7 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8263
8210
|
*/
|
|
8264
8211
|
static fromUR(ur) {
|
|
8265
8212
|
if (ur.urTypeStr() !== _bcts_tags.MLKEM_CIPHERTEXT.name) throw new Error(`Expected UR type ${_bcts_tags.MLKEM_CIPHERTEXT.name}, got ${ur.urTypeStr()}`);
|
|
8266
|
-
|
|
8267
|
-
return new MLKEMCiphertext(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(ur.cbor());
|
|
8213
|
+
return new MLKEMCiphertext(512, new Uint8Array(mlkemCiphertextSize(512))).fromUntaggedCbor(ur.cbor());
|
|
8268
8214
|
}
|
|
8269
8215
|
/**
|
|
8270
8216
|
* Creates an MLKEMCiphertext from a UR string.
|
|
@@ -8274,7 +8220,6 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8274
8220
|
return MLKEMCiphertext.fromUR(ur);
|
|
8275
8221
|
}
|
|
8276
8222
|
};
|
|
8277
|
-
|
|
8278
8223
|
//#endregion
|
|
8279
8224
|
//#region src/encapsulation/encapsulation-ciphertext.ts
|
|
8280
8225
|
/**
|
|
@@ -8300,16 +8245,16 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8300
8245
|
*/
|
|
8301
8246
|
function mlkemLevelToScheme$2(level) {
|
|
8302
8247
|
switch (level) {
|
|
8303
|
-
case
|
|
8304
|
-
case
|
|
8305
|
-
case
|
|
8248
|
+
case 512: return "mlkem512";
|
|
8249
|
+
case 768: return "mlkem768";
|
|
8250
|
+
case 1024: return "mlkem1024";
|
|
8306
8251
|
}
|
|
8307
8252
|
}
|
|
8308
8253
|
/**
|
|
8309
8254
|
* Check if a scheme is an MLKEM scheme
|
|
8310
8255
|
*/
|
|
8311
8256
|
function isMlkemScheme$2(scheme) {
|
|
8312
|
-
return scheme ===
|
|
8257
|
+
return scheme === "mlkem512" || scheme === "mlkem768" || scheme === "mlkem1024";
|
|
8313
8258
|
}
|
|
8314
8259
|
/**
|
|
8315
8260
|
* Represents the ciphertext from a key encapsulation operation.
|
|
@@ -8330,7 +8275,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8330
8275
|
* Create an EncapsulationCiphertext from an X25519PublicKey.
|
|
8331
8276
|
*/
|
|
8332
8277
|
static fromX25519PublicKey(publicKey) {
|
|
8333
|
-
return new EncapsulationCiphertext(
|
|
8278
|
+
return new EncapsulationCiphertext("x25519", publicKey, void 0);
|
|
8334
8279
|
}
|
|
8335
8280
|
/**
|
|
8336
8281
|
* Create an EncapsulationCiphertext from raw X25519 data.
|
|
@@ -8362,7 +8307,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8362
8307
|
* Returns true if this is an X25519 ciphertext.
|
|
8363
8308
|
*/
|
|
8364
8309
|
isX25519() {
|
|
8365
|
-
return this._scheme ===
|
|
8310
|
+
return this._scheme === "x25519";
|
|
8366
8311
|
}
|
|
8367
8312
|
/**
|
|
8368
8313
|
* Returns true if this is an MLKEM ciphertext.
|
|
@@ -8402,7 +8347,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8402
8347
|
* Returns the raw ciphertext data.
|
|
8403
8348
|
*/
|
|
8404
8349
|
data() {
|
|
8405
|
-
if (this._scheme ===
|
|
8350
|
+
if (this._scheme === "x25519") {
|
|
8406
8351
|
const pk = this._x25519PublicKey;
|
|
8407
8352
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8408
8353
|
return pk.data();
|
|
@@ -8418,7 +8363,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8418
8363
|
*/
|
|
8419
8364
|
equals(other) {
|
|
8420
8365
|
if (this._scheme !== other._scheme) return false;
|
|
8421
|
-
if (this._scheme ===
|
|
8366
|
+
if (this._scheme === "x25519") {
|
|
8422
8367
|
const thisPk = this._x25519PublicKey;
|
|
8423
8368
|
const otherPk = other._x25519PublicKey;
|
|
8424
8369
|
if (thisPk === void 0 || otherPk === void 0) return false;
|
|
@@ -8435,7 +8380,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8435
8380
|
* Get string representation.
|
|
8436
8381
|
*/
|
|
8437
8382
|
toString() {
|
|
8438
|
-
if (this._scheme ===
|
|
8383
|
+
if (this._scheme === "x25519") return `EncapsulationCiphertext(X25519, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
8439
8384
|
else if (isMlkemScheme$2(this._scheme)) return `EncapsulationCiphertext(${String(this._scheme)}, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
8440
8385
|
return `EncapsulationCiphertext(${String(this._scheme)})`;
|
|
8441
8386
|
}
|
|
@@ -8443,7 +8388,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8443
8388
|
* Returns the CBOR tags associated with this ciphertext.
|
|
8444
8389
|
*/
|
|
8445
8390
|
cborTags() {
|
|
8446
|
-
if (this._scheme ===
|
|
8391
|
+
if (this._scheme === "x25519") return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.X25519_PUBLIC_KEY.value]);
|
|
8447
8392
|
else if (isMlkemScheme$2(this._scheme)) return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.MLKEM_CIPHERTEXT.value]);
|
|
8448
8393
|
throw new Error(`Unsupported scheme: ${String(this._scheme)}`);
|
|
8449
8394
|
}
|
|
@@ -8451,7 +8396,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8451
8396
|
* Returns the untagged CBOR encoding.
|
|
8452
8397
|
*/
|
|
8453
8398
|
untaggedCbor() {
|
|
8454
|
-
if (this._scheme ===
|
|
8399
|
+
if (this._scheme === "x25519") {
|
|
8455
8400
|
const pk = this._x25519PublicKey;
|
|
8456
8401
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8457
8402
|
return (0, _bcts_dcbor.toByteString)(pk.data());
|
|
@@ -8520,7 +8465,6 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8520
8465
|
return EncapsulationCiphertext.fromX25519PublicKey(X25519PublicKey.fromData(new Uint8Array(32))).fromUntaggedCbor(cborValue);
|
|
8521
8466
|
}
|
|
8522
8467
|
};
|
|
8523
|
-
|
|
8524
8468
|
//#endregion
|
|
8525
8469
|
//#region src/mlkem/mlkem-public-key.ts
|
|
8526
8470
|
/**
|
|
@@ -8671,8 +8615,7 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8671
8615
|
* Static method to decode from tagged CBOR.
|
|
8672
8616
|
*/
|
|
8673
8617
|
static fromTaggedCbor(cborValue) {
|
|
8674
|
-
|
|
8675
|
-
return new MLKEMPublicKey(MLKEMLevel.MLKEM512, dummyData).fromTaggedCbor(cborValue);
|
|
8618
|
+
return new MLKEMPublicKey(512, new Uint8Array(mlkemPublicKeySize(512))).fromTaggedCbor(cborValue);
|
|
8676
8619
|
}
|
|
8677
8620
|
/**
|
|
8678
8621
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -8686,8 +8629,7 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8686
8629
|
*/
|
|
8687
8630
|
static fromUntaggedCborData(data) {
|
|
8688
8631
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
8689
|
-
|
|
8690
|
-
return new MLKEMPublicKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(cborValue);
|
|
8632
|
+
return new MLKEMPublicKey(512, new Uint8Array(mlkemPublicKeySize(512))).fromUntaggedCbor(cborValue);
|
|
8691
8633
|
}
|
|
8692
8634
|
/**
|
|
8693
8635
|
* Returns the UR representation.
|
|
@@ -8708,8 +8650,7 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8708
8650
|
*/
|
|
8709
8651
|
static fromUR(ur) {
|
|
8710
8652
|
if (ur.urTypeStr() !== _bcts_tags.MLKEM_PUBLIC_KEY.name) throw new Error(`Expected UR type ${_bcts_tags.MLKEM_PUBLIC_KEY.name}, got ${ur.urTypeStr()}`);
|
|
8711
|
-
|
|
8712
|
-
return new MLKEMPublicKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(ur.cbor());
|
|
8653
|
+
return new MLKEMPublicKey(512, new Uint8Array(mlkemPublicKeySize(512))).fromUntaggedCbor(ur.cbor());
|
|
8713
8654
|
}
|
|
8714
8655
|
/**
|
|
8715
8656
|
* Creates an MLKEMPublicKey from a UR string.
|
|
@@ -8719,7 +8660,6 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8719
8660
|
return MLKEMPublicKey.fromUR(ur);
|
|
8720
8661
|
}
|
|
8721
8662
|
};
|
|
8722
|
-
|
|
8723
8663
|
//#endregion
|
|
8724
8664
|
//#region src/encapsulation/encapsulation-public-key.ts
|
|
8725
8665
|
/**
|
|
@@ -8753,16 +8693,16 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8753
8693
|
*/
|
|
8754
8694
|
function mlkemLevelToScheme$1(level) {
|
|
8755
8695
|
switch (level) {
|
|
8756
|
-
case
|
|
8757
|
-
case
|
|
8758
|
-
case
|
|
8696
|
+
case 512: return "mlkem512";
|
|
8697
|
+
case 768: return "mlkem768";
|
|
8698
|
+
case 1024: return "mlkem1024";
|
|
8759
8699
|
}
|
|
8760
8700
|
}
|
|
8761
8701
|
/**
|
|
8762
8702
|
* Check if a scheme is an MLKEM scheme
|
|
8763
8703
|
*/
|
|
8764
8704
|
function isMlkemScheme$1(scheme) {
|
|
8765
|
-
return scheme ===
|
|
8705
|
+
return scheme === "mlkem512" || scheme === "mlkem768" || scheme === "mlkem1024";
|
|
8766
8706
|
}
|
|
8767
8707
|
/**
|
|
8768
8708
|
* Represents a public key for key encapsulation.
|
|
@@ -8782,7 +8722,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8782
8722
|
* Create an EncapsulationPublicKey from an X25519PublicKey.
|
|
8783
8723
|
*/
|
|
8784
8724
|
static fromX25519PublicKey(publicKey) {
|
|
8785
|
-
return new EncapsulationPublicKey(
|
|
8725
|
+
return new EncapsulationPublicKey("x25519", publicKey, void 0);
|
|
8786
8726
|
}
|
|
8787
8727
|
/**
|
|
8788
8728
|
* Create an EncapsulationPublicKey from raw X25519 public key bytes.
|
|
@@ -8814,7 +8754,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8814
8754
|
* Returns true if this is an X25519 public key.
|
|
8815
8755
|
*/
|
|
8816
8756
|
isX25519() {
|
|
8817
|
-
return this._scheme ===
|
|
8757
|
+
return this._scheme === "x25519";
|
|
8818
8758
|
}
|
|
8819
8759
|
/**
|
|
8820
8760
|
* Returns true if this is an MLKEM public key.
|
|
@@ -8854,7 +8794,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8854
8794
|
* Returns the raw public key data.
|
|
8855
8795
|
*/
|
|
8856
8796
|
data() {
|
|
8857
|
-
if (this._scheme ===
|
|
8797
|
+
if (this._scheme === "x25519") {
|
|
8858
8798
|
const pk = this._x25519PublicKey;
|
|
8859
8799
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8860
8800
|
return pk.data();
|
|
@@ -8885,7 +8825,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8885
8825
|
* @returns A tuple of [sharedSecret, ciphertext]
|
|
8886
8826
|
*/
|
|
8887
8827
|
encapsulateNewSharedSecret() {
|
|
8888
|
-
if (this._scheme ===
|
|
8828
|
+
if (this._scheme === "x25519") {
|
|
8889
8829
|
const pk = this._x25519PublicKey;
|
|
8890
8830
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8891
8831
|
const [ephemeralPrivate, ephemeralPublic] = X25519PrivateKey.keypair();
|
|
@@ -8903,7 +8843,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8903
8843
|
*/
|
|
8904
8844
|
equals(other) {
|
|
8905
8845
|
if (this._scheme !== other._scheme) return false;
|
|
8906
|
-
if (this._scheme ===
|
|
8846
|
+
if (this._scheme === "x25519") {
|
|
8907
8847
|
const thisPk = this._x25519PublicKey;
|
|
8908
8848
|
const otherPk = other._x25519PublicKey;
|
|
8909
8849
|
if (thisPk === void 0 || otherPk === void 0) return false;
|
|
@@ -8920,7 +8860,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8920
8860
|
* Get string representation.
|
|
8921
8861
|
*/
|
|
8922
8862
|
toString() {
|
|
8923
|
-
if (this._scheme ===
|
|
8863
|
+
if (this._scheme === "x25519") return `EncapsulationPublicKey(X25519, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
8924
8864
|
else if (isMlkemScheme$1(this._scheme)) return `EncapsulationPublicKey(${String(this._scheme)}, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
8925
8865
|
return `EncapsulationPublicKey(${String(this._scheme)})`;
|
|
8926
8866
|
}
|
|
@@ -8938,7 +8878,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8938
8878
|
* Returns the CBOR tags associated with this public key.
|
|
8939
8879
|
*/
|
|
8940
8880
|
cborTags() {
|
|
8941
|
-
if (this._scheme ===
|
|
8881
|
+
if (this._scheme === "x25519") return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.X25519_PUBLIC_KEY.value]);
|
|
8942
8882
|
else if (isMlkemScheme$1(this._scheme)) return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.MLKEM_PUBLIC_KEY.value]);
|
|
8943
8883
|
throw new Error(`Unsupported scheme: ${String(this._scheme)}`);
|
|
8944
8884
|
}
|
|
@@ -8946,7 +8886,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8946
8886
|
* Returns the untagged CBOR encoding.
|
|
8947
8887
|
*/
|
|
8948
8888
|
untaggedCbor() {
|
|
8949
|
-
if (this._scheme ===
|
|
8889
|
+
if (this._scheme === "x25519") {
|
|
8950
8890
|
const pk = this._x25519PublicKey;
|
|
8951
8891
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8952
8892
|
return (0, _bcts_dcbor.toByteString)(pk.data());
|
|
@@ -9018,7 +8958,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
9018
8958
|
* Returns the UR representation.
|
|
9019
8959
|
*/
|
|
9020
8960
|
ur() {
|
|
9021
|
-
if (this._scheme ===
|
|
8961
|
+
if (this._scheme === "x25519") {
|
|
9022
8962
|
const name = _bcts_tags.X25519_PUBLIC_KEY.name;
|
|
9023
8963
|
if (name === void 0) throw new Error("TAG_X25519_PUBLIC_KEY.name is undefined");
|
|
9024
8964
|
return _bcts_uniform_resources.UR.new(name, this.untaggedCbor());
|
|
@@ -9054,7 +8994,6 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
9054
8994
|
return EncapsulationPublicKey.fromUR(ur);
|
|
9055
8995
|
}
|
|
9056
8996
|
};
|
|
9057
|
-
|
|
9058
8997
|
//#endregion
|
|
9059
8998
|
//#region src/mlkem/mlkem-private-key.ts
|
|
9060
8999
|
/**
|
|
@@ -9097,7 +9036,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9097
9036
|
*
|
|
9098
9037
|
* @param level - The ML-KEM security level (default: MLKEM768)
|
|
9099
9038
|
*/
|
|
9100
|
-
static new(level =
|
|
9039
|
+
static new(level = 768) {
|
|
9101
9040
|
const rng = new _bcts_rand.SecureRandomNumberGenerator();
|
|
9102
9041
|
return MLKEMPrivateKey.newUsing(level, rng);
|
|
9103
9042
|
}
|
|
@@ -9125,7 +9064,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9125
9064
|
* @param level - The ML-KEM security level (default: MLKEM768)
|
|
9126
9065
|
* @returns Tuple of [privateKey, publicKey]
|
|
9127
9066
|
*/
|
|
9128
|
-
static keypair(level =
|
|
9067
|
+
static keypair(level = 768) {
|
|
9129
9068
|
const rng = new _bcts_rand.SecureRandomNumberGenerator();
|
|
9130
9069
|
return MLKEMPrivateKey.keypairUsing(level, rng);
|
|
9131
9070
|
}
|
|
@@ -9251,8 +9190,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9251
9190
|
* Static method to decode from tagged CBOR.
|
|
9252
9191
|
*/
|
|
9253
9192
|
static fromTaggedCbor(cborValue) {
|
|
9254
|
-
|
|
9255
|
-
return new MLKEMPrivateKey(MLKEMLevel.MLKEM512, dummyData).fromTaggedCbor(cborValue);
|
|
9193
|
+
return new MLKEMPrivateKey(512, new Uint8Array(mlkemPrivateKeySize(512))).fromTaggedCbor(cborValue);
|
|
9256
9194
|
}
|
|
9257
9195
|
/**
|
|
9258
9196
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -9266,8 +9204,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9266
9204
|
*/
|
|
9267
9205
|
static fromUntaggedCborData(data) {
|
|
9268
9206
|
const cborValue = (0, _bcts_dcbor.decodeCbor)(data);
|
|
9269
|
-
|
|
9270
|
-
return new MLKEMPrivateKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(cborValue);
|
|
9207
|
+
return new MLKEMPrivateKey(512, new Uint8Array(mlkemPrivateKeySize(512))).fromUntaggedCbor(cborValue);
|
|
9271
9208
|
}
|
|
9272
9209
|
/**
|
|
9273
9210
|
* Returns the UR representation.
|
|
@@ -9288,8 +9225,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9288
9225
|
*/
|
|
9289
9226
|
static fromUR(ur) {
|
|
9290
9227
|
if (ur.urTypeStr() !== _bcts_tags.MLKEM_PRIVATE_KEY.name) throw new Error(`Expected UR type ${_bcts_tags.MLKEM_PRIVATE_KEY.name}, got ${ur.urTypeStr()}`);
|
|
9291
|
-
|
|
9292
|
-
return new MLKEMPrivateKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(ur.cbor());
|
|
9228
|
+
return new MLKEMPrivateKey(512, new Uint8Array(mlkemPrivateKeySize(512))).fromUntaggedCbor(ur.cbor());
|
|
9293
9229
|
}
|
|
9294
9230
|
/**
|
|
9295
9231
|
* Creates an MLKEMPrivateKey from a UR string.
|
|
@@ -9299,7 +9235,6 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9299
9235
|
return MLKEMPrivateKey.fromUR(ur);
|
|
9300
9236
|
}
|
|
9301
9237
|
};
|
|
9302
|
-
|
|
9303
9238
|
//#endregion
|
|
9304
9239
|
//#region src/encapsulation/encapsulation-private-key.ts
|
|
9305
9240
|
/**
|
|
@@ -9331,16 +9266,16 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9331
9266
|
*/
|
|
9332
9267
|
function mlkemLevelToScheme(level) {
|
|
9333
9268
|
switch (level) {
|
|
9334
|
-
case
|
|
9335
|
-
case
|
|
9336
|
-
case
|
|
9269
|
+
case 512: return "mlkem512";
|
|
9270
|
+
case 768: return "mlkem768";
|
|
9271
|
+
case 1024: return "mlkem1024";
|
|
9337
9272
|
}
|
|
9338
9273
|
}
|
|
9339
9274
|
/**
|
|
9340
9275
|
* Check if a scheme is an MLKEM scheme
|
|
9341
9276
|
*/
|
|
9342
9277
|
function isMlkemScheme(scheme) {
|
|
9343
|
-
return scheme ===
|
|
9278
|
+
return scheme === "mlkem512" || scheme === "mlkem768" || scheme === "mlkem1024";
|
|
9344
9279
|
}
|
|
9345
9280
|
/**
|
|
9346
9281
|
* Represents a private key for key encapsulation.
|
|
@@ -9360,7 +9295,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9360
9295
|
* Create an EncapsulationPrivateKey from an X25519PrivateKey.
|
|
9361
9296
|
*/
|
|
9362
9297
|
static fromX25519PrivateKey(privateKey) {
|
|
9363
|
-
return new EncapsulationPrivateKey(
|
|
9298
|
+
return new EncapsulationPrivateKey("x25519", privateKey, void 0);
|
|
9364
9299
|
}
|
|
9365
9300
|
/**
|
|
9366
9301
|
* Create an EncapsulationPrivateKey from raw X25519 private key bytes.
|
|
@@ -9405,7 +9340,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9405
9340
|
/**
|
|
9406
9341
|
* Generate a new MLKEM encapsulation private key.
|
|
9407
9342
|
*/
|
|
9408
|
-
static newMlkem(level =
|
|
9343
|
+
static newMlkem(level = 768) {
|
|
9409
9344
|
const mlkemPrivate = MLKEMPrivateKey.new(level);
|
|
9410
9345
|
return EncapsulationPrivateKey.fromMlkem(mlkemPrivate);
|
|
9411
9346
|
}
|
|
@@ -9433,7 +9368,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9433
9368
|
/**
|
|
9434
9369
|
* Generate a new MLKEM keypair.
|
|
9435
9370
|
*/
|
|
9436
|
-
static mlkemKeypair(level =
|
|
9371
|
+
static mlkemKeypair(level = 768) {
|
|
9437
9372
|
const [mlkemPrivate, mlkemPublic] = MLKEMPrivateKey.keypair(level);
|
|
9438
9373
|
return [EncapsulationPrivateKey.fromMlkem(mlkemPrivate), EncapsulationPublicKey.fromMlkem(mlkemPublic)];
|
|
9439
9374
|
}
|
|
@@ -9454,7 +9389,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9454
9389
|
* Returns true if this is an X25519 private key.
|
|
9455
9390
|
*/
|
|
9456
9391
|
isX25519() {
|
|
9457
|
-
return this._scheme ===
|
|
9392
|
+
return this._scheme === "x25519";
|
|
9458
9393
|
}
|
|
9459
9394
|
/**
|
|
9460
9395
|
* Returns true if this is an MLKEM private key.
|
|
@@ -9494,7 +9429,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9494
9429
|
* Returns the raw private key data.
|
|
9495
9430
|
*/
|
|
9496
9431
|
data() {
|
|
9497
|
-
if (this._scheme ===
|
|
9432
|
+
if (this._scheme === "x25519") {
|
|
9498
9433
|
const pk = this._x25519PrivateKey;
|
|
9499
9434
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
9500
9435
|
return pk.data();
|
|
@@ -9509,7 +9444,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9509
9444
|
* Get the public key corresponding to this private key.
|
|
9510
9445
|
*/
|
|
9511
9446
|
publicKey() {
|
|
9512
|
-
if (this._scheme ===
|
|
9447
|
+
if (this._scheme === "x25519") {
|
|
9513
9448
|
const pk = this._x25519PrivateKey;
|
|
9514
9449
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
9515
9450
|
const x25519Public = pk.publicKey();
|
|
@@ -9531,7 +9466,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9531
9466
|
*/
|
|
9532
9467
|
decapsulateSharedSecret(ciphertext) {
|
|
9533
9468
|
if (ciphertext.encapsulationScheme() !== this._scheme) throw require_digest.CryptoError.invalidData(`Scheme mismatch: expected ${String(this._scheme)}, got ${String(ciphertext.encapsulationScheme())}`);
|
|
9534
|
-
if (this._scheme ===
|
|
9469
|
+
if (this._scheme === "x25519") {
|
|
9535
9470
|
const pk = this._x25519PrivateKey;
|
|
9536
9471
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
9537
9472
|
const ephemeralPublic = ciphertext.x25519PublicKey();
|
|
@@ -9549,7 +9484,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9549
9484
|
*/
|
|
9550
9485
|
equals(other) {
|
|
9551
9486
|
if (this._scheme !== other._scheme) return false;
|
|
9552
|
-
if (this._scheme ===
|
|
9487
|
+
if (this._scheme === "x25519") {
|
|
9553
9488
|
const thisPk = this._x25519PrivateKey;
|
|
9554
9489
|
const otherPk = other._x25519PrivateKey;
|
|
9555
9490
|
if (thisPk === void 0 || otherPk === void 0) return false;
|
|
@@ -9566,7 +9501,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9566
9501
|
* Get string representation.
|
|
9567
9502
|
*/
|
|
9568
9503
|
toString() {
|
|
9569
|
-
if (this._scheme ===
|
|
9504
|
+
if (this._scheme === "x25519") return `EncapsulationPrivateKey(X25519, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
9570
9505
|
else if (isMlkemScheme(this._scheme)) return `EncapsulationPrivateKey(${String(this._scheme)}, ${require_digest.bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
9571
9506
|
return `EncapsulationPrivateKey(${String(this._scheme)})`;
|
|
9572
9507
|
}
|
|
@@ -9584,7 +9519,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9584
9519
|
* Returns the CBOR tags associated with this private key.
|
|
9585
9520
|
*/
|
|
9586
9521
|
cborTags() {
|
|
9587
|
-
if (this._scheme ===
|
|
9522
|
+
if (this._scheme === "x25519") return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.X25519_PRIVATE_KEY.value]);
|
|
9588
9523
|
else if (isMlkemScheme(this._scheme)) return (0, _bcts_dcbor.tagsForValues)([_bcts_tags.MLKEM_PRIVATE_KEY.value]);
|
|
9589
9524
|
throw new Error(`Unsupported scheme: ${String(this._scheme)}`);
|
|
9590
9525
|
}
|
|
@@ -9592,7 +9527,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9592
9527
|
* Returns the untagged CBOR encoding.
|
|
9593
9528
|
*/
|
|
9594
9529
|
untaggedCbor() {
|
|
9595
|
-
if (this._scheme ===
|
|
9530
|
+
if (this._scheme === "x25519") {
|
|
9596
9531
|
const pk = this._x25519PrivateKey;
|
|
9597
9532
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
9598
9533
|
return (0, _bcts_dcbor.toByteString)(pk.data());
|
|
@@ -9664,7 +9599,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9664
9599
|
* Returns the UR representation.
|
|
9665
9600
|
*/
|
|
9666
9601
|
ur() {
|
|
9667
|
-
if (this._scheme ===
|
|
9602
|
+
if (this._scheme === "x25519") {
|
|
9668
9603
|
const name = _bcts_tags.X25519_PRIVATE_KEY.name;
|
|
9669
9604
|
if (name === void 0) throw new Error("TAG_X25519_PRIVATE_KEY.name is undefined");
|
|
9670
9605
|
return _bcts_uniform_resources.UR.new(name, this.untaggedCbor());
|
|
@@ -9700,37 +9635,36 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9700
9635
|
return EncapsulationPrivateKey.fromUR(ur);
|
|
9701
9636
|
}
|
|
9702
9637
|
};
|
|
9703
|
-
|
|
9704
9638
|
//#endregion
|
|
9705
9639
|
//#region src/encapsulation/encapsulation-scheme.ts
|
|
9706
9640
|
/**
|
|
9707
9641
|
* Available key encapsulation schemes.
|
|
9708
9642
|
*/
|
|
9709
|
-
let EncapsulationScheme = /* @__PURE__ */ function(EncapsulationScheme
|
|
9643
|
+
let EncapsulationScheme = /* @__PURE__ */ function(EncapsulationScheme) {
|
|
9710
9644
|
/**
|
|
9711
9645
|
* X25519 Diffie-Hellman key exchange (default).
|
|
9712
9646
|
* Based on Curve25519 as defined in RFC 7748.
|
|
9713
9647
|
*/
|
|
9714
|
-
EncapsulationScheme
|
|
9648
|
+
EncapsulationScheme["X25519"] = "x25519";
|
|
9715
9649
|
/**
|
|
9716
9650
|
* ML-KEM-512 post-quantum key encapsulation (NIST security level 1).
|
|
9717
9651
|
*/
|
|
9718
|
-
EncapsulationScheme
|
|
9652
|
+
EncapsulationScheme["MLKEM512"] = "mlkem512";
|
|
9719
9653
|
/**
|
|
9720
9654
|
* ML-KEM-768 post-quantum key encapsulation (NIST security level 3).
|
|
9721
9655
|
*/
|
|
9722
|
-
EncapsulationScheme
|
|
9656
|
+
EncapsulationScheme["MLKEM768"] = "mlkem768";
|
|
9723
9657
|
/**
|
|
9724
9658
|
* ML-KEM-1024 post-quantum key encapsulation (NIST security level 5).
|
|
9725
9659
|
*/
|
|
9726
|
-
EncapsulationScheme
|
|
9727
|
-
return EncapsulationScheme
|
|
9660
|
+
EncapsulationScheme["MLKEM1024"] = "mlkem1024";
|
|
9661
|
+
return EncapsulationScheme;
|
|
9728
9662
|
}({});
|
|
9729
9663
|
/**
|
|
9730
9664
|
* Returns the default encapsulation scheme (X25519).
|
|
9731
9665
|
*/
|
|
9732
9666
|
function defaultEncapsulationScheme() {
|
|
9733
|
-
return
|
|
9667
|
+
return "x25519";
|
|
9734
9668
|
}
|
|
9735
9669
|
/**
|
|
9736
9670
|
* Generate a new keypair for the given encapsulation scheme.
|
|
@@ -9738,12 +9672,12 @@ function defaultEncapsulationScheme() {
|
|
|
9738
9672
|
* @param scheme - The encapsulation scheme to use (defaults to X25519)
|
|
9739
9673
|
* @returns A tuple of [privateKey, publicKey]
|
|
9740
9674
|
*/
|
|
9741
|
-
function createEncapsulationKeypair(scheme =
|
|
9675
|
+
function createEncapsulationKeypair(scheme = "x25519") {
|
|
9742
9676
|
switch (scheme) {
|
|
9743
|
-
case
|
|
9744
|
-
case
|
|
9745
|
-
case
|
|
9746
|
-
case
|
|
9677
|
+
case "x25519": return EncapsulationPrivateKey.keypair();
|
|
9678
|
+
case "mlkem512": return EncapsulationPrivateKey.mlkemKeypair(512);
|
|
9679
|
+
case "mlkem768": return EncapsulationPrivateKey.mlkemKeypair(768);
|
|
9680
|
+
case "mlkem1024": return EncapsulationPrivateKey.mlkemKeypair(1024);
|
|
9747
9681
|
}
|
|
9748
9682
|
}
|
|
9749
9683
|
/**
|
|
@@ -9757,15 +9691,14 @@ function createEncapsulationKeypair(scheme = EncapsulationScheme.X25519) {
|
|
|
9757
9691
|
* @returns A tuple of [privateKey, publicKey]
|
|
9758
9692
|
* @throws Error if the scheme doesn't support deterministic generation
|
|
9759
9693
|
*/
|
|
9760
|
-
function createEncapsulationKeypairUsing(rng, scheme =
|
|
9694
|
+
function createEncapsulationKeypairUsing(rng, scheme = "x25519") {
|
|
9761
9695
|
switch (scheme) {
|
|
9762
|
-
case
|
|
9763
|
-
case
|
|
9764
|
-
case
|
|
9765
|
-
case
|
|
9696
|
+
case "x25519": return EncapsulationPrivateKey.keypairUsing(rng);
|
|
9697
|
+
case "mlkem512":
|
|
9698
|
+
case "mlkem768":
|
|
9699
|
+
case "mlkem1024": throw new Error("Deterministic keypair generation not supported for this encapsulation scheme");
|
|
9766
9700
|
}
|
|
9767
9701
|
}
|
|
9768
|
-
|
|
9769
9702
|
//#endregion
|
|
9770
9703
|
//#region src/encapsulation/sealed-message.ts
|
|
9771
9704
|
/**
|
|
@@ -9996,7 +9929,6 @@ var SealedMessage = class SealedMessage {
|
|
|
9996
9929
|
return SealedMessage.fromUR(ur);
|
|
9997
9930
|
}
|
|
9998
9931
|
};
|
|
9999
|
-
|
|
10000
9932
|
//#endregion
|
|
10001
9933
|
//#region src/encrypted-key/hash-type.ts
|
|
10002
9934
|
/**
|
|
@@ -10020,20 +9952,20 @@ var SealedMessage = class SealedMessage {
|
|
|
10020
9952
|
/**
|
|
10021
9953
|
* Enum representing supported hash types for key derivation.
|
|
10022
9954
|
*/
|
|
10023
|
-
let HashType = /* @__PURE__ */ function(HashType
|
|
9955
|
+
let HashType = /* @__PURE__ */ function(HashType) {
|
|
10024
9956
|
/** SHA-256 hash algorithm */
|
|
10025
|
-
HashType
|
|
9957
|
+
HashType[HashType["SHA256"] = 0] = "SHA256";
|
|
10026
9958
|
/** SHA-512 hash algorithm */
|
|
10027
|
-
HashType
|
|
10028
|
-
return HashType
|
|
9959
|
+
HashType[HashType["SHA512"] = 1] = "SHA512";
|
|
9960
|
+
return HashType;
|
|
10029
9961
|
}({});
|
|
10030
9962
|
/**
|
|
10031
9963
|
* Convert HashType to its string representation.
|
|
10032
9964
|
*/
|
|
10033
9965
|
function hashTypeToString(hashType) {
|
|
10034
9966
|
switch (hashType) {
|
|
10035
|
-
case
|
|
10036
|
-
case
|
|
9967
|
+
case 0: return "SHA256";
|
|
9968
|
+
case 1: return "SHA512";
|
|
10037
9969
|
default: throw new Error(`Unknown HashType: ${String(hashType)}`);
|
|
10038
9970
|
}
|
|
10039
9971
|
}
|
|
@@ -10049,12 +9981,11 @@ function hashTypeToCbor(hashType) {
|
|
|
10049
9981
|
function hashTypeFromCbor(cborValue) {
|
|
10050
9982
|
const value = (0, _bcts_dcbor.expectNumber)(cborValue);
|
|
10051
9983
|
switch (value) {
|
|
10052
|
-
case 0: return
|
|
10053
|
-
case 1: return
|
|
9984
|
+
case 0: return 0;
|
|
9985
|
+
case 1: return 1;
|
|
10054
9986
|
default: throw new Error(`Invalid HashType: ${value}`);
|
|
10055
9987
|
}
|
|
10056
9988
|
}
|
|
10057
|
-
|
|
10058
9989
|
//#endregion
|
|
10059
9990
|
//#region src/encrypted-key/key-derivation-method.ts
|
|
10060
9991
|
/**
|
|
@@ -10081,24 +10012,24 @@ function hashTypeFromCbor(cborValue) {
|
|
|
10081
10012
|
/**
|
|
10082
10013
|
* Enum representing supported key derivation methods.
|
|
10083
10014
|
*/
|
|
10084
|
-
let KeyDerivationMethod = /* @__PURE__ */ function(KeyDerivationMethod
|
|
10015
|
+
let KeyDerivationMethod = /* @__PURE__ */ function(KeyDerivationMethod) {
|
|
10085
10016
|
/** HKDF (HMAC-based Key Derivation Function) - RFC 5869 */
|
|
10086
|
-
KeyDerivationMethod
|
|
10017
|
+
KeyDerivationMethod[KeyDerivationMethod["HKDF"] = 0] = "HKDF";
|
|
10087
10018
|
/** PBKDF2 (Password-Based Key Derivation Function 2) - RFC 8018 */
|
|
10088
|
-
KeyDerivationMethod
|
|
10019
|
+
KeyDerivationMethod[KeyDerivationMethod["PBKDF2"] = 1] = "PBKDF2";
|
|
10089
10020
|
/** Scrypt - RFC 7914 */
|
|
10090
|
-
KeyDerivationMethod
|
|
10021
|
+
KeyDerivationMethod[KeyDerivationMethod["Scrypt"] = 2] = "Scrypt";
|
|
10091
10022
|
/** Argon2id - RFC 9106 (default, most secure for passwords) */
|
|
10092
|
-
KeyDerivationMethod
|
|
10023
|
+
KeyDerivationMethod[KeyDerivationMethod["Argon2id"] = 3] = "Argon2id";
|
|
10093
10024
|
/** SSH Agent - Uses SSH agent for key derivation */
|
|
10094
|
-
KeyDerivationMethod
|
|
10095
|
-
return KeyDerivationMethod
|
|
10025
|
+
KeyDerivationMethod[KeyDerivationMethod["SSHAgent"] = 4] = "SSHAgent";
|
|
10026
|
+
return KeyDerivationMethod;
|
|
10096
10027
|
}({});
|
|
10097
10028
|
/**
|
|
10098
10029
|
* Returns the default key derivation method (Argon2id).
|
|
10099
10030
|
*/
|
|
10100
10031
|
function defaultKeyDerivationMethod() {
|
|
10101
|
-
return
|
|
10032
|
+
return 3;
|
|
10102
10033
|
}
|
|
10103
10034
|
/**
|
|
10104
10035
|
* Returns the zero-based index of the key derivation method.
|
|
@@ -10111,11 +10042,11 @@ function keyDerivationMethodIndex(method) {
|
|
|
10111
10042
|
*/
|
|
10112
10043
|
function keyDerivationMethodFromIndex(index) {
|
|
10113
10044
|
switch (index) {
|
|
10114
|
-
case 0: return
|
|
10115
|
-
case 1: return
|
|
10116
|
-
case 2: return
|
|
10117
|
-
case 3: return
|
|
10118
|
-
case 4: return
|
|
10045
|
+
case 0: return 0;
|
|
10046
|
+
case 1: return 1;
|
|
10047
|
+
case 2: return 2;
|
|
10048
|
+
case 3: return 3;
|
|
10049
|
+
case 4: return 4;
|
|
10119
10050
|
default: return;
|
|
10120
10051
|
}
|
|
10121
10052
|
}
|
|
@@ -10124,11 +10055,11 @@ function keyDerivationMethodFromIndex(index) {
|
|
|
10124
10055
|
*/
|
|
10125
10056
|
function keyDerivationMethodToString(method) {
|
|
10126
10057
|
switch (method) {
|
|
10127
|
-
case
|
|
10128
|
-
case
|
|
10129
|
-
case
|
|
10130
|
-
case
|
|
10131
|
-
case
|
|
10058
|
+
case 0: return "HKDF";
|
|
10059
|
+
case 1: return "PBKDF2";
|
|
10060
|
+
case 2: return "Scrypt";
|
|
10061
|
+
case 3: return "Argon2id";
|
|
10062
|
+
case 4: return "SSHAgent";
|
|
10132
10063
|
default: throw new Error(`Unknown KeyDerivationMethod: ${String(method)}`);
|
|
10133
10064
|
}
|
|
10134
10065
|
}
|
|
@@ -10141,7 +10072,6 @@ function keyDerivationMethodFromCbor(cborValue) {
|
|
|
10141
10072
|
if (method === void 0) throw new Error(`Invalid KeyDerivationMethod index: ${value}`);
|
|
10142
10073
|
return method;
|
|
10143
10074
|
}
|
|
10144
|
-
|
|
10145
10075
|
//#endregion
|
|
10146
10076
|
//#region src/encrypted-key/hkdf-params.ts
|
|
10147
10077
|
/**
|
|
@@ -10171,7 +10101,7 @@ const SALT_LEN = 16;
|
|
|
10171
10101
|
* but NOT for password-based key derivation.
|
|
10172
10102
|
*/
|
|
10173
10103
|
var HKDFParams = class HKDFParams {
|
|
10174
|
-
static INDEX =
|
|
10104
|
+
static INDEX = 0;
|
|
10175
10105
|
_salt;
|
|
10176
10106
|
_hashType;
|
|
10177
10107
|
constructor(salt, hashType) {
|
|
@@ -10183,7 +10113,7 @@ var HKDFParams = class HKDFParams {
|
|
|
10183
10113
|
* Uses a random 16-byte salt and SHA-256.
|
|
10184
10114
|
*/
|
|
10185
10115
|
static new() {
|
|
10186
|
-
return HKDFParams.newOpt(Salt.newWithLen(
|
|
10116
|
+
return HKDFParams.newOpt(Salt.newWithLen(16), 0);
|
|
10187
10117
|
}
|
|
10188
10118
|
/**
|
|
10189
10119
|
* Create HKDF parameters with custom settings.
|
|
@@ -10222,8 +10152,8 @@ var HKDFParams = class HKDFParams {
|
|
|
10222
10152
|
}
|
|
10223
10153
|
_deriveKey(secret) {
|
|
10224
10154
|
switch (this._hashType) {
|
|
10225
|
-
case
|
|
10226
|
-
case
|
|
10155
|
+
case 0: return (0, _bcts_crypto.hkdfHmacSha256)(secret, this._salt.asBytes(), 32);
|
|
10156
|
+
case 1: return (0, _bcts_crypto.hkdfHmacSha512)(secret, this._salt.asBytes(), 32);
|
|
10227
10157
|
default: throw new Error(`Unknown hash type: ${String(this._hashType)}`);
|
|
10228
10158
|
}
|
|
10229
10159
|
}
|
|
@@ -10268,7 +10198,6 @@ var HKDFParams = class HKDFParams {
|
|
|
10268
10198
|
return new HKDFParams(Salt.fromData(saltData), hashTypeFromCbor(array[2]));
|
|
10269
10199
|
}
|
|
10270
10200
|
};
|
|
10271
|
-
|
|
10272
10201
|
//#endregion
|
|
10273
10202
|
//#region src/encrypted-key/pbkdf2-params.ts
|
|
10274
10203
|
/**
|
|
@@ -10294,7 +10223,7 @@ const DEFAULT_PBKDF2_ITERATIONS = 1e5;
|
|
|
10294
10223
|
* PBKDF2 parameters for password-based key derivation.
|
|
10295
10224
|
*/
|
|
10296
10225
|
var PBKDF2Params = class PBKDF2Params {
|
|
10297
|
-
static INDEX =
|
|
10226
|
+
static INDEX = 1;
|
|
10298
10227
|
_salt;
|
|
10299
10228
|
_iterations;
|
|
10300
10229
|
_hashType;
|
|
@@ -10308,7 +10237,7 @@ var PBKDF2Params = class PBKDF2Params {
|
|
|
10308
10237
|
* Uses a random 16-byte salt, 100,000 iterations, and SHA-256.
|
|
10309
10238
|
*/
|
|
10310
10239
|
static new() {
|
|
10311
|
-
return PBKDF2Params.newOpt(Salt.newWithLen(
|
|
10240
|
+
return PBKDF2Params.newOpt(Salt.newWithLen(16), DEFAULT_PBKDF2_ITERATIONS, 0);
|
|
10312
10241
|
}
|
|
10313
10242
|
/**
|
|
10314
10243
|
* Create PBKDF2 parameters with custom settings.
|
|
@@ -10351,8 +10280,8 @@ var PBKDF2Params = class PBKDF2Params {
|
|
|
10351
10280
|
}
|
|
10352
10281
|
_deriveKey(secret) {
|
|
10353
10282
|
switch (this._hashType) {
|
|
10354
|
-
case
|
|
10355
|
-
case
|
|
10283
|
+
case 0: return (0, _bcts_crypto.pbkdf2HmacSha256)(secret, this._salt.asBytes(), this._iterations, 32);
|
|
10284
|
+
case 1: return (0, _bcts_crypto.pbkdf2HmacSha512)(secret, this._salt.asBytes(), this._iterations, 32);
|
|
10356
10285
|
default: throw new Error(`Unknown hash type: ${String(this._hashType)}`);
|
|
10357
10286
|
}
|
|
10358
10287
|
}
|
|
@@ -10398,7 +10327,6 @@ var PBKDF2Params = class PBKDF2Params {
|
|
|
10398
10327
|
return new PBKDF2Params(Salt.fromData(saltData), Number((0, _bcts_dcbor.expectNumber)(array[2])), hashTypeFromCbor(array[3]));
|
|
10399
10328
|
}
|
|
10400
10329
|
};
|
|
10401
|
-
|
|
10402
10330
|
//#endregion
|
|
10403
10331
|
//#region src/encrypted-key/scrypt-params.ts
|
|
10404
10332
|
/**
|
|
@@ -10434,7 +10362,7 @@ const DEFAULT_SCRYPT_P = 1;
|
|
|
10434
10362
|
* - p: Parallelization parameter
|
|
10435
10363
|
*/
|
|
10436
10364
|
var ScryptParams = class ScryptParams {
|
|
10437
|
-
static INDEX =
|
|
10365
|
+
static INDEX = 2;
|
|
10438
10366
|
_salt;
|
|
10439
10367
|
_logN;
|
|
10440
10368
|
_r;
|
|
@@ -10450,7 +10378,7 @@ var ScryptParams = class ScryptParams {
|
|
|
10450
10378
|
* Uses a random 16-byte salt, log_n=15, r=8, p=1.
|
|
10451
10379
|
*/
|
|
10452
10380
|
static new() {
|
|
10453
|
-
return ScryptParams.newOpt(Salt.newWithLen(
|
|
10381
|
+
return ScryptParams.newOpt(Salt.newWithLen(16), 15, 8, 1);
|
|
10454
10382
|
}
|
|
10455
10383
|
/**
|
|
10456
10384
|
* Create Scrypt parameters with custom settings.
|
|
@@ -10541,7 +10469,6 @@ var ScryptParams = class ScryptParams {
|
|
|
10541
10469
|
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])));
|
|
10542
10470
|
}
|
|
10543
10471
|
};
|
|
10544
|
-
|
|
10545
10472
|
//#endregion
|
|
10546
10473
|
//#region src/encrypted-key/argon2id-params.ts
|
|
10547
10474
|
/**
|
|
@@ -10574,7 +10501,7 @@ var ScryptParams = class ScryptParams {
|
|
|
10574
10501
|
* attacks.
|
|
10575
10502
|
*/
|
|
10576
10503
|
var Argon2idParams = class Argon2idParams {
|
|
10577
|
-
static INDEX =
|
|
10504
|
+
static INDEX = 3;
|
|
10578
10505
|
_salt;
|
|
10579
10506
|
constructor(salt) {
|
|
10580
10507
|
this._salt = salt;
|
|
@@ -10584,7 +10511,7 @@ var Argon2idParams = class Argon2idParams {
|
|
|
10584
10511
|
* Uses a random 16-byte salt.
|
|
10585
10512
|
*/
|
|
10586
10513
|
static new() {
|
|
10587
|
-
return Argon2idParams.newOpt(Salt.newWithLen(
|
|
10514
|
+
return Argon2idParams.newOpt(Salt.newWithLen(16));
|
|
10588
10515
|
}
|
|
10589
10516
|
/**
|
|
10590
10517
|
* Create Argon2id parameters with a custom salt.
|
|
@@ -10657,28 +10584,6 @@ var Argon2idParams = class Argon2idParams {
|
|
|
10657
10584
|
return new Argon2idParams(Salt.fromData(saltData));
|
|
10658
10585
|
}
|
|
10659
10586
|
};
|
|
10660
|
-
|
|
10661
|
-
//#endregion
|
|
10662
|
-
//#region src/encrypted-key/ssh-agent-params.ts
|
|
10663
|
-
/**
|
|
10664
|
-
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
10665
|
-
* Copyright © 2025-2026 Parity Technologies
|
|
10666
|
-
*
|
|
10667
|
-
*
|
|
10668
|
-
* SSH Agent key derivation parameters
|
|
10669
|
-
*
|
|
10670
|
-
* SSH Agent uses an SSH agent daemon for key derivation. The agent signs
|
|
10671
|
-
* a challenge derived from the salt to produce the encryption key.
|
|
10672
|
-
*
|
|
10673
|
-
* CDDL:
|
|
10674
|
-
* ```cddl
|
|
10675
|
-
* SSHAgentParams = [4, Salt, id: tstr]
|
|
10676
|
-
* ```
|
|
10677
|
-
*
|
|
10678
|
-
* Ported from bc-components-rust/src/encrypted_key/ssh_agent_params.rs
|
|
10679
|
-
*/
|
|
10680
|
-
/** Default salt length for SSH agent key derivation */
|
|
10681
|
-
const SALT_LEN$1 = 16;
|
|
10682
10587
|
/**
|
|
10683
10588
|
* SSH Agent parameters for key derivation.
|
|
10684
10589
|
*
|
|
@@ -10691,7 +10596,7 @@ const SALT_LEN$1 = 16;
|
|
|
10691
10596
|
* methods will throw an error if SSH agent support is not available.
|
|
10692
10597
|
*/
|
|
10693
10598
|
var SSHAgentParams = class SSHAgentParams {
|
|
10694
|
-
static INDEX =
|
|
10599
|
+
static INDEX = 4;
|
|
10695
10600
|
_salt;
|
|
10696
10601
|
_id;
|
|
10697
10602
|
constructor(salt, id) {
|
|
@@ -10704,7 +10609,7 @@ var SSHAgentParams = class SSHAgentParams {
|
|
|
10704
10609
|
* @param id - The SSH key identity (usually the key comment or public key fingerprint)
|
|
10705
10610
|
*/
|
|
10706
10611
|
static new(id) {
|
|
10707
|
-
return SSHAgentParams.newOpt(Salt.newWithLen(
|
|
10612
|
+
return SSHAgentParams.newOpt(Salt.newWithLen(16), id);
|
|
10708
10613
|
}
|
|
10709
10614
|
/**
|
|
10710
10615
|
* Create SSH agent parameters with custom salt and key ID.
|
|
@@ -10792,7 +10697,6 @@ var SSHAgentParams = class SSHAgentParams {
|
|
|
10792
10697
|
return new SSHAgentParams(Salt.fromData(saltData), (0, _bcts_dcbor.expectText)(array[2]));
|
|
10793
10698
|
}
|
|
10794
10699
|
};
|
|
10795
|
-
|
|
10796
10700
|
//#endregion
|
|
10797
10701
|
//#region src/encrypted-key/key-derivation-params.ts
|
|
10798
10702
|
/**
|
|
@@ -10870,11 +10774,11 @@ function defaultKeyDerivationParams() {
|
|
|
10870
10774
|
*/
|
|
10871
10775
|
function keyDerivationParamsMethod(kdp) {
|
|
10872
10776
|
switch (kdp.type) {
|
|
10873
|
-
case "hkdf": return
|
|
10874
|
-
case "pbkdf2": return
|
|
10875
|
-
case "scrypt": return
|
|
10876
|
-
case "argon2id": return
|
|
10877
|
-
case "sshagent": return
|
|
10777
|
+
case "hkdf": return 0;
|
|
10778
|
+
case "pbkdf2": return 1;
|
|
10779
|
+
case "scrypt": return 2;
|
|
10780
|
+
case "argon2id": return 3;
|
|
10781
|
+
case "sshagent": return 4;
|
|
10878
10782
|
}
|
|
10879
10783
|
}
|
|
10880
10784
|
/**
|
|
@@ -10947,29 +10851,28 @@ function keyDerivationParamsFromCbor(cborValue) {
|
|
|
10947
10851
|
const method = keyDerivationMethodFromIndex(Number(index));
|
|
10948
10852
|
if (method === void 0) throw new Error(`Invalid KeyDerivationMethod index: ${index}`);
|
|
10949
10853
|
switch (method) {
|
|
10950
|
-
case
|
|
10854
|
+
case 0: return {
|
|
10951
10855
|
type: "hkdf",
|
|
10952
10856
|
params: HKDFParams.fromCbor(cborValue)
|
|
10953
10857
|
};
|
|
10954
|
-
case
|
|
10858
|
+
case 1: return {
|
|
10955
10859
|
type: "pbkdf2",
|
|
10956
10860
|
params: PBKDF2Params.fromCbor(cborValue)
|
|
10957
10861
|
};
|
|
10958
|
-
case
|
|
10862
|
+
case 2: return {
|
|
10959
10863
|
type: "scrypt",
|
|
10960
10864
|
params: ScryptParams.fromCbor(cborValue)
|
|
10961
10865
|
};
|
|
10962
|
-
case
|
|
10866
|
+
case 3: return {
|
|
10963
10867
|
type: "argon2id",
|
|
10964
10868
|
params: Argon2idParams.fromCbor(cborValue)
|
|
10965
10869
|
};
|
|
10966
|
-
case
|
|
10870
|
+
case 4: return {
|
|
10967
10871
|
type: "sshagent",
|
|
10968
10872
|
params: SSHAgentParams.fromCbor(cborValue)
|
|
10969
10873
|
};
|
|
10970
10874
|
}
|
|
10971
10875
|
}
|
|
10972
|
-
|
|
10973
10876
|
//#endregion
|
|
10974
10877
|
//#region src/encrypted-key/encrypted-key.ts
|
|
10975
10878
|
/**
|
|
@@ -11033,19 +10936,19 @@ var EncryptedKey = class EncryptedKey {
|
|
|
11033
10936
|
static lock(method, secret, contentKey) {
|
|
11034
10937
|
let params;
|
|
11035
10938
|
switch (method) {
|
|
11036
|
-
case
|
|
10939
|
+
case 0:
|
|
11037
10940
|
params = hkdfParams();
|
|
11038
10941
|
break;
|
|
11039
|
-
case
|
|
10942
|
+
case 1:
|
|
11040
10943
|
params = pbkdf2Params();
|
|
11041
10944
|
break;
|
|
11042
|
-
case
|
|
10945
|
+
case 2:
|
|
11043
10946
|
params = scryptParams();
|
|
11044
10947
|
break;
|
|
11045
|
-
case
|
|
10948
|
+
case 3:
|
|
11046
10949
|
params = argon2idParams();
|
|
11047
10950
|
break;
|
|
11048
|
-
case
|
|
10951
|
+
case 4: throw new Error("SSH Agent key derivation cannot be used with lock() - use lockOpt() with sshAgentParams() instead");
|
|
11049
10952
|
}
|
|
11050
10953
|
return EncryptedKey.lockOpt(params, secret, contentKey);
|
|
11051
10954
|
}
|
|
@@ -11207,7 +11110,6 @@ var EncryptedKey = class EncryptedKey {
|
|
|
11207
11110
|
return EncryptedKey.fromUR(ur);
|
|
11208
11111
|
}
|
|
11209
11112
|
};
|
|
11210
|
-
|
|
11211
11113
|
//#endregion
|
|
11212
11114
|
//#region src/public-keys.ts
|
|
11213
11115
|
/**
|
|
@@ -11436,7 +11338,6 @@ var PublicKeys = class PublicKeys {
|
|
|
11436
11338
|
return PublicKeys.fromUR(ur);
|
|
11437
11339
|
}
|
|
11438
11340
|
};
|
|
11439
|
-
|
|
11440
11341
|
//#endregion
|
|
11441
11342
|
//#region src/private-keys.ts
|
|
11442
11343
|
/**
|
|
@@ -11652,7 +11553,6 @@ var PrivateKeys = class PrivateKeys {
|
|
|
11652
11553
|
return PrivateKeys.fromUR(ur);
|
|
11653
11554
|
}
|
|
11654
11555
|
};
|
|
11655
|
-
|
|
11656
11556
|
//#endregion
|
|
11657
11557
|
//#region src/private-key-base.ts
|
|
11658
11558
|
/**
|
|
@@ -11926,7 +11826,6 @@ var PrivateKeyBase = class PrivateKeyBase {
|
|
|
11926
11826
|
return PrivateKeyBase.fromUR(ur);
|
|
11927
11827
|
}
|
|
11928
11828
|
};
|
|
11929
|
-
|
|
11930
11829
|
//#endregion
|
|
11931
11830
|
//#region src/sskr.ts
|
|
11932
11831
|
/**
|
|
@@ -12203,16 +12102,15 @@ function sskrGenerateSharesUsing(spec, masterSecret, rng) {
|
|
|
12203
12102
|
function sskrCombineShares(shares) {
|
|
12204
12103
|
return (0, _bcts_sskr.sskrCombine)(shares.map((share) => share.data()));
|
|
12205
12104
|
}
|
|
12206
|
-
|
|
12207
12105
|
//#endregion
|
|
12208
12106
|
exports.ARID = ARID;
|
|
12209
12107
|
exports.Argon2idParams = Argon2idParams;
|
|
12210
12108
|
exports.AuthenticationTag = AuthenticationTag;
|
|
12211
|
-
Object.defineProperty(exports,
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12109
|
+
Object.defineProperty(exports, "COMPRESSED", {
|
|
12110
|
+
enumerable: true,
|
|
12111
|
+
get: function() {
|
|
12112
|
+
return _bcts_tags.COMPRESSED;
|
|
12113
|
+
}
|
|
12216
12114
|
});
|
|
12217
12115
|
exports.Compressed = Compressed;
|
|
12218
12116
|
exports.CryptoError = require_digest.CryptoError;
|
|
@@ -12224,17 +12122,17 @@ exports.Digest = require_digest.Digest;
|
|
|
12224
12122
|
exports.ECPrivateKey = ECPrivateKey;
|
|
12225
12123
|
exports.ECPublicKey = ECPublicKey;
|
|
12226
12124
|
exports.ECUncompressedPublicKey = ECUncompressedPublicKey;
|
|
12227
|
-
Object.defineProperty(exports,
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
|
|
12125
|
+
Object.defineProperty(exports, "ENCRYPTED", {
|
|
12126
|
+
enumerable: true,
|
|
12127
|
+
get: function() {
|
|
12128
|
+
return _bcts_tags.ENCRYPTED;
|
|
12129
|
+
}
|
|
12232
12130
|
});
|
|
12233
|
-
Object.defineProperty(exports,
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12131
|
+
Object.defineProperty(exports, "ENVELOPE", {
|
|
12132
|
+
enumerable: true,
|
|
12133
|
+
get: function() {
|
|
12134
|
+
return _bcts_tags.ENVELOPE;
|
|
12135
|
+
}
|
|
12238
12136
|
});
|
|
12239
12137
|
exports.Ed25519PrivateKey = Ed25519PrivateKey;
|
|
12240
12138
|
exports.Ed25519PublicKey = Ed25519PublicKey;
|
|
@@ -12249,18 +12147,18 @@ exports.HKDFParams = HKDFParams;
|
|
|
12249
12147
|
exports.HKDFRng = HKDFRng;
|
|
12250
12148
|
exports.HashType = HashType;
|
|
12251
12149
|
exports.JSON = JSON;
|
|
12252
|
-
Object.defineProperty(exports,
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
|
|
12256
|
-
|
|
12150
|
+
Object.defineProperty(exports, "KNOWN_VALUE", {
|
|
12151
|
+
enumerable: true,
|
|
12152
|
+
get: function() {
|
|
12153
|
+
return _bcts_tags.KNOWN_VALUE;
|
|
12154
|
+
}
|
|
12257
12155
|
});
|
|
12258
12156
|
exports.KeyDerivationMethod = KeyDerivationMethod;
|
|
12259
|
-
Object.defineProperty(exports,
|
|
12260
|
-
|
|
12261
|
-
|
|
12262
|
-
|
|
12263
|
-
|
|
12157
|
+
Object.defineProperty(exports, "LEAF", {
|
|
12158
|
+
enumerable: true,
|
|
12159
|
+
get: function() {
|
|
12160
|
+
return _bcts_tags.LEAF;
|
|
12161
|
+
}
|
|
12264
12162
|
});
|
|
12265
12163
|
exports.MLDSALevel = MLDSALevel;
|
|
12266
12164
|
exports.MLDSAPrivateKey = MLDSAPrivateKey;
|
|
@@ -12378,4 +12276,5 @@ exports.sskrGenerateShares = sskrGenerateShares;
|
|
|
12378
12276
|
exports.sskrGenerateSharesUsing = sskrGenerateSharesUsing;
|
|
12379
12277
|
exports.sskrGenerateUsing = _bcts_sskr.sskrGenerateUsing;
|
|
12380
12278
|
exports.toBase64 = require_digest.toBase64;
|
|
12279
|
+
|
|
12381
12280
|
//# sourceMappingURL=index.cjs.map
|