@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.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as fromBase64, c as CryptoError, d as isCryptoErrorKind, f as isError, i as bytesToHex, l as ErrorKind, o as hexToBytes, r as bytesEqual, s as toBase64, t as Digest, u as isCryptoError } from "./digest-B1bpgcdz.mjs";
|
|
2
2
|
import { CborDate, CborMap, cbor, createTaggedCbor, decodeCbor, expectArray, expectBytes, expectInteger, expectMap, expectNumber, expectText, expectUnsigned, extractTaggedContent, isArray, isBytes, isTagged, tagValue, tagsForValues, toByteString, validateTag } from "@bcts/dcbor";
|
|
3
3
|
import { ARID as ARID$1, COMPRESSED, COMPRESSED as COMPRESSED$1, EC_KEY, EC_KEY_V1, ENCRYPTED, ENCRYPTED as ENCRYPTED$1, ENCRYPTED_KEY, ENVELOPE, JSON as JSON$1, KNOWN_VALUE, LEAF, MLDSA_PRIVATE_KEY, MLDSA_PUBLIC_KEY, MLDSA_SIGNATURE, MLKEM_CIPHERTEXT, MLKEM_PRIVATE_KEY, MLKEM_PUBLIC_KEY, NONCE, PRIVATE_KEYS, PRIVATE_KEY_BASE, PUBLIC_KEYS, SALT, SEALED_MESSAGE, SEED, SEED_V1, SIGNATURE, SIGNING_PRIVATE_KEY, SIGNING_PUBLIC_KEY, SSKR_SHARE, SSKR_SHARE_V1, SYMMETRIC_KEY, URI as URI$1, UUID as UUID$1, X25519_PRIVATE_KEY, X25519_PUBLIC_KEY, XID as XID$1 } from "@bcts/tags";
|
|
4
4
|
import { deflate, inflate } from "pako";
|
|
@@ -10,7 +10,6 @@ import { blake2b } from "@noble/hashes/blake2.js";
|
|
|
10
10
|
import { ml_dsa44, ml_dsa65, ml_dsa87 } from "@noble/post-quantum/ml-dsa.js";
|
|
11
11
|
import { ml_kem1024, ml_kem512, ml_kem768 } from "@noble/post-quantum/ml-kem.js";
|
|
12
12
|
import { GroupSpec as SSKRGroupSpec, Secret as SSKRSecret, Spec as SSKRSpec, sskrCombine, sskrGenerate, sskrGenerateUsing } from "@bcts/sskr";
|
|
13
|
-
|
|
14
13
|
//#region src/private-key-data-provider.ts
|
|
15
14
|
/**
|
|
16
15
|
* Type guard to check if an object implements PrivateKeyDataProvider
|
|
@@ -18,7 +17,6 @@ import { GroupSpec as SSKRGroupSpec, Secret as SSKRSecret, Spec as SSKRSpec, ssk
|
|
|
18
17
|
function isPrivateKeyDataProvider(obj) {
|
|
19
18
|
return typeof obj === "object" && obj !== null && "privateKeyData" in obj && typeof obj.privateKeyData === "function";
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
//#endregion
|
|
23
21
|
//#region src/encrypter.ts
|
|
24
22
|
/**
|
|
@@ -33,7 +31,6 @@ function isEncrypter(obj) {
|
|
|
33
31
|
function isDecrypter(obj) {
|
|
34
32
|
return typeof obj === "object" && obj !== null && "encapsulationPrivateKey" in obj && typeof obj.encapsulationPrivateKey === "function" && "decapsulateSharedSecret" in obj && typeof obj.decapsulateSharedSecret === "function";
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
//#endregion
|
|
38
35
|
//#region src/json.ts
|
|
39
36
|
/**
|
|
@@ -213,7 +210,6 @@ var JSON = class JSON {
|
|
|
213
210
|
return JSON.fromString("").fromUntaggedCbor(cborValue);
|
|
214
211
|
}
|
|
215
212
|
};
|
|
216
|
-
|
|
217
213
|
//#endregion
|
|
218
214
|
//#region src/compressed.ts
|
|
219
215
|
/**
|
|
@@ -500,7 +496,6 @@ var Compressed = class Compressed {
|
|
|
500
496
|
return Compressed.fromDecompressedData(new Uint8Array(0)).fromUntaggedCbor(cborValue);
|
|
501
497
|
}
|
|
502
498
|
};
|
|
503
|
-
|
|
504
499
|
//#endregion
|
|
505
500
|
//#region src/hkdf-rng.ts
|
|
506
501
|
/**
|
|
@@ -713,7 +708,6 @@ var HKDFRng = class HKDFRng {
|
|
|
713
708
|
return this._pageIndex;
|
|
714
709
|
}
|
|
715
710
|
};
|
|
716
|
-
|
|
717
711
|
//#endregion
|
|
718
712
|
//#region src/digest-provider.ts
|
|
719
713
|
/**
|
|
@@ -724,10 +718,9 @@ var HKDFRng = class HKDFRng {
|
|
|
724
718
|
* @returns A Promise resolving to a Digest of the data
|
|
725
719
|
*/
|
|
726
720
|
async function digestFromBytes(data) {
|
|
727
|
-
const { Digest
|
|
728
|
-
return Digest
|
|
721
|
+
const { Digest } = await import("./digest-B1bpgcdz.mjs").then((n) => n.n);
|
|
722
|
+
return Digest.fromImage(data);
|
|
729
723
|
}
|
|
730
|
-
|
|
731
724
|
//#endregion
|
|
732
725
|
//#region src/nonce.ts
|
|
733
726
|
/**
|
|
@@ -910,30 +903,30 @@ var Nonce = class Nonce {
|
|
|
910
903
|
/**
|
|
911
904
|
* Creates a Nonce by decoding it from untagged CBOR.
|
|
912
905
|
*/
|
|
913
|
-
fromUntaggedCbor(cbor
|
|
914
|
-
const data = expectBytes(cbor
|
|
906
|
+
fromUntaggedCbor(cbor) {
|
|
907
|
+
const data = expectBytes(cbor);
|
|
915
908
|
return Nonce.fromDataRef(data);
|
|
916
909
|
}
|
|
917
910
|
/**
|
|
918
911
|
* Creates a Nonce by decoding it from tagged CBOR.
|
|
919
912
|
*/
|
|
920
|
-
fromTaggedCbor(cbor
|
|
921
|
-
validateTag(cbor
|
|
922
|
-
const content = extractTaggedContent(cbor
|
|
913
|
+
fromTaggedCbor(cbor) {
|
|
914
|
+
validateTag(cbor, this.cborTags());
|
|
915
|
+
const content = extractTaggedContent(cbor);
|
|
923
916
|
return this.fromUntaggedCbor(content);
|
|
924
917
|
}
|
|
925
918
|
/**
|
|
926
919
|
* Static method to decode from tagged CBOR.
|
|
927
920
|
*/
|
|
928
|
-
static fromTaggedCbor(cbor
|
|
929
|
-
return new Nonce(new Uint8Array(Nonce.NONCE_SIZE)).fromTaggedCbor(cbor
|
|
921
|
+
static fromTaggedCbor(cbor) {
|
|
922
|
+
return new Nonce(new Uint8Array(Nonce.NONCE_SIZE)).fromTaggedCbor(cbor);
|
|
930
923
|
}
|
|
931
924
|
/**
|
|
932
925
|
* Static method to decode from tagged CBOR binary data.
|
|
933
926
|
*/
|
|
934
927
|
static fromTaggedCborData(data) {
|
|
935
|
-
const cbor
|
|
936
|
-
return Nonce.fromTaggedCbor(cbor
|
|
928
|
+
const cbor = decodeCbor(data);
|
|
929
|
+
return Nonce.fromTaggedCbor(cbor);
|
|
937
930
|
}
|
|
938
931
|
/**
|
|
939
932
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -970,7 +963,6 @@ var Nonce = class Nonce {
|
|
|
970
963
|
return Nonce.fromUR(ur);
|
|
971
964
|
}
|
|
972
965
|
};
|
|
973
|
-
|
|
974
966
|
//#endregion
|
|
975
967
|
//#region src/salt.ts
|
|
976
968
|
/**
|
|
@@ -1218,30 +1210,30 @@ var Salt = class Salt {
|
|
|
1218
1210
|
/**
|
|
1219
1211
|
* Creates a Salt by decoding it from untagged CBOR.
|
|
1220
1212
|
*/
|
|
1221
|
-
fromUntaggedCbor(cbor
|
|
1222
|
-
const data = expectBytes(cbor
|
|
1213
|
+
fromUntaggedCbor(cbor) {
|
|
1214
|
+
const data = expectBytes(cbor);
|
|
1223
1215
|
return Salt.fromData(data);
|
|
1224
1216
|
}
|
|
1225
1217
|
/**
|
|
1226
1218
|
* Creates a Salt by decoding it from tagged CBOR.
|
|
1227
1219
|
*/
|
|
1228
|
-
fromTaggedCbor(cbor
|
|
1229
|
-
validateTag(cbor
|
|
1230
|
-
const content = extractTaggedContent(cbor
|
|
1220
|
+
fromTaggedCbor(cbor) {
|
|
1221
|
+
validateTag(cbor, this.cborTags());
|
|
1222
|
+
const content = extractTaggedContent(cbor);
|
|
1231
1223
|
return this.fromUntaggedCbor(content);
|
|
1232
1224
|
}
|
|
1233
1225
|
/**
|
|
1234
1226
|
* Static method to decode from tagged CBOR.
|
|
1235
1227
|
*/
|
|
1236
|
-
static fromTaggedCbor(cbor
|
|
1237
|
-
return new Salt(new Uint8Array(0)).fromTaggedCbor(cbor
|
|
1228
|
+
static fromTaggedCbor(cbor) {
|
|
1229
|
+
return new Salt(new Uint8Array(0)).fromTaggedCbor(cbor);
|
|
1238
1230
|
}
|
|
1239
1231
|
/**
|
|
1240
1232
|
* Static method to decode from tagged CBOR binary data.
|
|
1241
1233
|
*/
|
|
1242
1234
|
static fromTaggedCborData(data) {
|
|
1243
|
-
const cbor
|
|
1244
|
-
return Salt.fromTaggedCbor(cbor
|
|
1235
|
+
const cbor = decodeCbor(data);
|
|
1236
|
+
return Salt.fromTaggedCbor(cbor);
|
|
1245
1237
|
}
|
|
1246
1238
|
/**
|
|
1247
1239
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -1278,7 +1270,6 @@ var Salt = class Salt {
|
|
|
1278
1270
|
return Salt.fromUR(ur);
|
|
1279
1271
|
}
|
|
1280
1272
|
};
|
|
1281
|
-
|
|
1282
1273
|
//#endregion
|
|
1283
1274
|
//#region src/seed.ts
|
|
1284
1275
|
/**
|
|
@@ -1627,9 +1618,9 @@ var Seed = class Seed {
|
|
|
1627
1618
|
/**
|
|
1628
1619
|
* Creates a Seed by decoding it from tagged CBOR.
|
|
1629
1620
|
*/
|
|
1630
|
-
fromTaggedCbor(cbor
|
|
1631
|
-
validateTag(cbor
|
|
1632
|
-
const content = extractTaggedContent(cbor
|
|
1621
|
+
fromTaggedCbor(cbor) {
|
|
1622
|
+
validateTag(cbor, this.cborTags());
|
|
1623
|
+
const content = extractTaggedContent(cbor);
|
|
1633
1624
|
return this.fromUntaggedCbor(content);
|
|
1634
1625
|
}
|
|
1635
1626
|
/**
|
|
@@ -1680,7 +1671,6 @@ var Seed = class Seed {
|
|
|
1680
1671
|
return Seed.fromUR(ur);
|
|
1681
1672
|
}
|
|
1682
1673
|
};
|
|
1683
|
-
|
|
1684
1674
|
//#endregion
|
|
1685
1675
|
//#region src/reference.ts
|
|
1686
1676
|
/**
|
|
@@ -1830,7 +1820,6 @@ var Reference = class Reference {
|
|
|
1830
1820
|
return `Reference(${this.shortReference("hex")})`;
|
|
1831
1821
|
}
|
|
1832
1822
|
};
|
|
1833
|
-
|
|
1834
1823
|
//#endregion
|
|
1835
1824
|
//#region src/id/arid.ts
|
|
1836
1825
|
/**
|
|
@@ -2026,30 +2015,30 @@ var ARID = class ARID {
|
|
|
2026
2015
|
/**
|
|
2027
2016
|
* Creates an ARID by decoding it from untagged CBOR.
|
|
2028
2017
|
*/
|
|
2029
|
-
fromUntaggedCbor(cbor
|
|
2030
|
-
const data = expectBytes(cbor
|
|
2018
|
+
fromUntaggedCbor(cbor) {
|
|
2019
|
+
const data = expectBytes(cbor);
|
|
2031
2020
|
return ARID.fromDataRef(data);
|
|
2032
2021
|
}
|
|
2033
2022
|
/**
|
|
2034
2023
|
* Creates an ARID by decoding it from tagged CBOR.
|
|
2035
2024
|
*/
|
|
2036
|
-
fromTaggedCbor(cbor
|
|
2037
|
-
validateTag(cbor
|
|
2038
|
-
const content = extractTaggedContent(cbor
|
|
2025
|
+
fromTaggedCbor(cbor) {
|
|
2026
|
+
validateTag(cbor, this.cborTags());
|
|
2027
|
+
const content = extractTaggedContent(cbor);
|
|
2039
2028
|
return this.fromUntaggedCbor(content);
|
|
2040
2029
|
}
|
|
2041
2030
|
/**
|
|
2042
2031
|
* Static method to decode from tagged CBOR.
|
|
2043
2032
|
*/
|
|
2044
|
-
static fromTaggedCbor(cbor
|
|
2045
|
-
return new ARID(new Uint8Array(ARID.ARID_SIZE)).fromTaggedCbor(cbor
|
|
2033
|
+
static fromTaggedCbor(cbor) {
|
|
2034
|
+
return new ARID(new Uint8Array(ARID.ARID_SIZE)).fromTaggedCbor(cbor);
|
|
2046
2035
|
}
|
|
2047
2036
|
/**
|
|
2048
2037
|
* Static method to decode from tagged CBOR binary data.
|
|
2049
2038
|
*/
|
|
2050
2039
|
static fromTaggedCborData(data) {
|
|
2051
|
-
const cbor
|
|
2052
|
-
return ARID.fromTaggedCbor(cbor
|
|
2040
|
+
const cbor = decodeCbor(data);
|
|
2041
|
+
return ARID.fromTaggedCbor(cbor);
|
|
2053
2042
|
}
|
|
2054
2043
|
/**
|
|
2055
2044
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -2092,7 +2081,6 @@ var ARID = class ARID {
|
|
|
2092
2081
|
return ARID.fromURString(urString);
|
|
2093
2082
|
}
|
|
2094
2083
|
};
|
|
2095
|
-
|
|
2096
2084
|
//#endregion
|
|
2097
2085
|
//#region src/id/uuid.ts
|
|
2098
2086
|
/**
|
|
@@ -2267,30 +2255,30 @@ var UUID = class UUID {
|
|
|
2267
2255
|
/**
|
|
2268
2256
|
* Creates a UUID by decoding it from untagged CBOR.
|
|
2269
2257
|
*/
|
|
2270
|
-
fromUntaggedCbor(cbor
|
|
2271
|
-
const data = expectBytes(cbor
|
|
2258
|
+
fromUntaggedCbor(cbor) {
|
|
2259
|
+
const data = expectBytes(cbor);
|
|
2272
2260
|
return UUID.fromDataRef(data);
|
|
2273
2261
|
}
|
|
2274
2262
|
/**
|
|
2275
2263
|
* Creates a UUID by decoding it from tagged CBOR.
|
|
2276
2264
|
*/
|
|
2277
|
-
fromTaggedCbor(cbor
|
|
2278
|
-
validateTag(cbor
|
|
2279
|
-
const content = extractTaggedContent(cbor
|
|
2265
|
+
fromTaggedCbor(cbor) {
|
|
2266
|
+
validateTag(cbor, this.cborTags());
|
|
2267
|
+
const content = extractTaggedContent(cbor);
|
|
2280
2268
|
return this.fromUntaggedCbor(content);
|
|
2281
2269
|
}
|
|
2282
2270
|
/**
|
|
2283
2271
|
* Static method to decode from tagged CBOR.
|
|
2284
2272
|
*/
|
|
2285
|
-
static fromTaggedCbor(cbor
|
|
2286
|
-
return new UUID(new Uint8Array(UUID_SIZE)).fromTaggedCbor(cbor
|
|
2273
|
+
static fromTaggedCbor(cbor) {
|
|
2274
|
+
return new UUID(new Uint8Array(UUID_SIZE)).fromTaggedCbor(cbor);
|
|
2287
2275
|
}
|
|
2288
2276
|
/**
|
|
2289
2277
|
* Static method to decode from tagged CBOR binary data.
|
|
2290
2278
|
*/
|
|
2291
2279
|
static fromTaggedCborData(data) {
|
|
2292
|
-
const cbor
|
|
2293
|
-
return UUID.fromTaggedCbor(cbor
|
|
2280
|
+
const cbor = decodeCbor(data);
|
|
2281
|
+
return UUID.fromTaggedCbor(cbor);
|
|
2294
2282
|
}
|
|
2295
2283
|
/**
|
|
2296
2284
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -2327,7 +2315,6 @@ var UUID = class UUID {
|
|
|
2327
2315
|
return UUID.fromUR(ur);
|
|
2328
2316
|
}
|
|
2329
2317
|
};
|
|
2330
|
-
|
|
2331
2318
|
//#endregion
|
|
2332
2319
|
//#region src/id/xid.ts
|
|
2333
2320
|
/**
|
|
@@ -2544,30 +2531,30 @@ var XID = class XID {
|
|
|
2544
2531
|
/**
|
|
2545
2532
|
* Creates a XID by decoding it from untagged CBOR.
|
|
2546
2533
|
*/
|
|
2547
|
-
fromUntaggedCbor(cbor
|
|
2548
|
-
const data = expectBytes(cbor
|
|
2534
|
+
fromUntaggedCbor(cbor) {
|
|
2535
|
+
const data = expectBytes(cbor);
|
|
2549
2536
|
return XID.fromDataRef(data);
|
|
2550
2537
|
}
|
|
2551
2538
|
/**
|
|
2552
2539
|
* Creates a XID by decoding it from tagged CBOR.
|
|
2553
2540
|
*/
|
|
2554
|
-
fromTaggedCbor(cbor
|
|
2555
|
-
validateTag(cbor
|
|
2556
|
-
const content = extractTaggedContent(cbor
|
|
2541
|
+
fromTaggedCbor(cbor) {
|
|
2542
|
+
validateTag(cbor, this.cborTags());
|
|
2543
|
+
const content = extractTaggedContent(cbor);
|
|
2557
2544
|
return this.fromUntaggedCbor(content);
|
|
2558
2545
|
}
|
|
2559
2546
|
/**
|
|
2560
2547
|
* Static method to decode from tagged CBOR.
|
|
2561
2548
|
*/
|
|
2562
|
-
static fromTaggedCbor(cbor
|
|
2563
|
-
return new XID(new Uint8Array(XID_SIZE)).fromTaggedCbor(cbor
|
|
2549
|
+
static fromTaggedCbor(cbor) {
|
|
2550
|
+
return new XID(new Uint8Array(XID_SIZE)).fromTaggedCbor(cbor);
|
|
2564
2551
|
}
|
|
2565
2552
|
/**
|
|
2566
2553
|
* Static method to decode from tagged CBOR binary data.
|
|
2567
2554
|
*/
|
|
2568
2555
|
static fromTaggedCborData(data) {
|
|
2569
|
-
const cbor
|
|
2570
|
-
return XID.fromTaggedCbor(cbor
|
|
2556
|
+
const cbor = decodeCbor(data);
|
|
2557
|
+
return XID.fromTaggedCbor(cbor);
|
|
2571
2558
|
}
|
|
2572
2559
|
/**
|
|
2573
2560
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -2604,7 +2591,6 @@ var XID = class XID {
|
|
|
2604
2591
|
return XID.fromUR(ur);
|
|
2605
2592
|
}
|
|
2606
2593
|
};
|
|
2607
|
-
|
|
2608
2594
|
//#endregion
|
|
2609
2595
|
//#region src/id/uri.ts
|
|
2610
2596
|
/**
|
|
@@ -2825,7 +2811,6 @@ var URI = class URI {
|
|
|
2825
2811
|
return URI.fromUR(ur);
|
|
2826
2812
|
}
|
|
2827
2813
|
};
|
|
2828
|
-
|
|
2829
2814
|
//#endregion
|
|
2830
2815
|
//#region src/x25519/x25519-public-key.ts
|
|
2831
2816
|
/**
|
|
@@ -2959,37 +2944,37 @@ var X25519PublicKey = class X25519PublicKey {
|
|
|
2959
2944
|
/**
|
|
2960
2945
|
* Creates an X25519PublicKey by decoding it from untagged CBOR.
|
|
2961
2946
|
*/
|
|
2962
|
-
fromUntaggedCbor(cbor
|
|
2963
|
-
const data = expectBytes(cbor
|
|
2947
|
+
fromUntaggedCbor(cbor) {
|
|
2948
|
+
const data = expectBytes(cbor);
|
|
2964
2949
|
return X25519PublicKey.fromDataRef(data);
|
|
2965
2950
|
}
|
|
2966
2951
|
/**
|
|
2967
2952
|
* Creates an X25519PublicKey by decoding it from tagged CBOR.
|
|
2968
2953
|
*/
|
|
2969
|
-
fromTaggedCbor(cbor
|
|
2970
|
-
validateTag(cbor
|
|
2971
|
-
const content = extractTaggedContent(cbor
|
|
2954
|
+
fromTaggedCbor(cbor) {
|
|
2955
|
+
validateTag(cbor, this.cborTags());
|
|
2956
|
+
const content = extractTaggedContent(cbor);
|
|
2972
2957
|
return this.fromUntaggedCbor(content);
|
|
2973
2958
|
}
|
|
2974
2959
|
/**
|
|
2975
2960
|
* Static method to decode from tagged CBOR.
|
|
2976
2961
|
*/
|
|
2977
|
-
static fromTaggedCbor(cbor
|
|
2978
|
-
return new X25519PublicKey(new Uint8Array(X25519_PUBLIC_KEY_SIZE)).fromTaggedCbor(cbor
|
|
2962
|
+
static fromTaggedCbor(cbor) {
|
|
2963
|
+
return new X25519PublicKey(new Uint8Array(X25519_PUBLIC_KEY_SIZE)).fromTaggedCbor(cbor);
|
|
2979
2964
|
}
|
|
2980
2965
|
/**
|
|
2981
2966
|
* Static method to decode from tagged CBOR binary data.
|
|
2982
2967
|
*/
|
|
2983
2968
|
static fromTaggedCborData(data) {
|
|
2984
|
-
const cbor
|
|
2985
|
-
return X25519PublicKey.fromTaggedCbor(cbor
|
|
2969
|
+
const cbor = decodeCbor(data);
|
|
2970
|
+
return X25519PublicKey.fromTaggedCbor(cbor);
|
|
2986
2971
|
}
|
|
2987
2972
|
/**
|
|
2988
2973
|
* Static method to decode from untagged CBOR binary data.
|
|
2989
2974
|
*/
|
|
2990
2975
|
static fromUntaggedCborData(data) {
|
|
2991
|
-
const cbor
|
|
2992
|
-
return new X25519PublicKey(new Uint8Array(X25519_PUBLIC_KEY_SIZE)).fromUntaggedCbor(cbor
|
|
2976
|
+
const cbor = decodeCbor(data);
|
|
2977
|
+
return new X25519PublicKey(new Uint8Array(X25519_PUBLIC_KEY_SIZE)).fromUntaggedCbor(cbor);
|
|
2993
2978
|
}
|
|
2994
2979
|
/**
|
|
2995
2980
|
* Returns the UR representation of the X25519PublicKey.
|
|
@@ -3023,7 +3008,6 @@ var X25519PublicKey = class X25519PublicKey {
|
|
|
3023
3008
|
return X25519PublicKey.fromUR(ur);
|
|
3024
3009
|
}
|
|
3025
3010
|
};
|
|
3026
|
-
|
|
3027
3011
|
//#endregion
|
|
3028
3012
|
//#region src/symmetric/authentication-tag.ts
|
|
3029
3013
|
/**
|
|
@@ -3140,19 +3124,18 @@ var AuthenticationTag = class AuthenticationTag {
|
|
|
3140
3124
|
/**
|
|
3141
3125
|
* Creates an AuthenticationTag from CBOR.
|
|
3142
3126
|
*/
|
|
3143
|
-
static fromCbor(cbor
|
|
3144
|
-
const data = expectBytes(cbor
|
|
3127
|
+
static fromCbor(cbor) {
|
|
3128
|
+
const data = expectBytes(cbor);
|
|
3145
3129
|
return AuthenticationTag.fromDataRef(data);
|
|
3146
3130
|
}
|
|
3147
3131
|
/**
|
|
3148
3132
|
* Creates an AuthenticationTag from CBOR binary data.
|
|
3149
3133
|
*/
|
|
3150
3134
|
static fromCborData(data) {
|
|
3151
|
-
const cbor
|
|
3152
|
-
return AuthenticationTag.fromCbor(cbor
|
|
3135
|
+
const cbor = decodeCbor(data);
|
|
3136
|
+
return AuthenticationTag.fromCbor(cbor);
|
|
3153
3137
|
}
|
|
3154
3138
|
};
|
|
3155
|
-
|
|
3156
3139
|
//#endregion
|
|
3157
3140
|
//#region src/symmetric/encrypted-message.ts
|
|
3158
3141
|
/**
|
|
@@ -3392,7 +3375,6 @@ var EncryptedMessage = class EncryptedMessage {
|
|
|
3392
3375
|
return EncryptedMessage.fromUR(ur);
|
|
3393
3376
|
}
|
|
3394
3377
|
};
|
|
3395
|
-
|
|
3396
3378
|
//#endregion
|
|
3397
3379
|
//#region src/symmetric/symmetric-key.ts
|
|
3398
3380
|
/**
|
|
@@ -3564,30 +3546,30 @@ var SymmetricKey = class SymmetricKey {
|
|
|
3564
3546
|
/**
|
|
3565
3547
|
* Creates a SymmetricKey by decoding it from untagged CBOR.
|
|
3566
3548
|
*/
|
|
3567
|
-
fromUntaggedCbor(cbor
|
|
3568
|
-
const data = expectBytes(cbor
|
|
3549
|
+
fromUntaggedCbor(cbor) {
|
|
3550
|
+
const data = expectBytes(cbor);
|
|
3569
3551
|
return SymmetricKey.fromDataRef(data);
|
|
3570
3552
|
}
|
|
3571
3553
|
/**
|
|
3572
3554
|
* Creates a SymmetricKey by decoding it from tagged CBOR.
|
|
3573
3555
|
*/
|
|
3574
|
-
fromTaggedCbor(cbor
|
|
3575
|
-
validateTag(cbor
|
|
3576
|
-
const content = extractTaggedContent(cbor
|
|
3556
|
+
fromTaggedCbor(cbor) {
|
|
3557
|
+
validateTag(cbor, this.cborTags());
|
|
3558
|
+
const content = extractTaggedContent(cbor);
|
|
3577
3559
|
return this.fromUntaggedCbor(content);
|
|
3578
3560
|
}
|
|
3579
3561
|
/**
|
|
3580
3562
|
* Static method to decode from tagged CBOR.
|
|
3581
3563
|
*/
|
|
3582
|
-
static fromTaggedCbor(cbor
|
|
3583
|
-
return new SymmetricKey(new Uint8Array(SYMMETRIC_KEY_SIZE)).fromTaggedCbor(cbor
|
|
3564
|
+
static fromTaggedCbor(cbor) {
|
|
3565
|
+
return new SymmetricKey(new Uint8Array(SYMMETRIC_KEY_SIZE)).fromTaggedCbor(cbor);
|
|
3584
3566
|
}
|
|
3585
3567
|
/**
|
|
3586
3568
|
* Static method to decode from tagged CBOR binary data.
|
|
3587
3569
|
*/
|
|
3588
3570
|
static fromTaggedCborData(data) {
|
|
3589
|
-
const cbor
|
|
3590
|
-
return SymmetricKey.fromTaggedCbor(cbor
|
|
3571
|
+
const cbor = decodeCbor(data);
|
|
3572
|
+
return SymmetricKey.fromTaggedCbor(cbor);
|
|
3591
3573
|
}
|
|
3592
3574
|
/**
|
|
3593
3575
|
* Static method to decode from untagged CBOR binary data.
|
|
@@ -3633,7 +3615,6 @@ var SymmetricKey = class SymmetricKey {
|
|
|
3633
3615
|
return SymmetricKey.fromURString(urString);
|
|
3634
3616
|
}
|
|
3635
3617
|
};
|
|
3636
|
-
|
|
3637
3618
|
//#endregion
|
|
3638
3619
|
//#region src/x25519/x25519-private-key.ts
|
|
3639
3620
|
/**
|
|
@@ -3845,37 +3826,37 @@ var X25519PrivateKey = class X25519PrivateKey {
|
|
|
3845
3826
|
/**
|
|
3846
3827
|
* Creates an X25519PrivateKey by decoding it from untagged CBOR.
|
|
3847
3828
|
*/
|
|
3848
|
-
fromUntaggedCbor(cbor
|
|
3849
|
-
const data = expectBytes(cbor
|
|
3829
|
+
fromUntaggedCbor(cbor) {
|
|
3830
|
+
const data = expectBytes(cbor);
|
|
3850
3831
|
return X25519PrivateKey.fromDataRef(data);
|
|
3851
3832
|
}
|
|
3852
3833
|
/**
|
|
3853
3834
|
* Creates an X25519PrivateKey by decoding it from tagged CBOR.
|
|
3854
3835
|
*/
|
|
3855
|
-
fromTaggedCbor(cbor
|
|
3856
|
-
validateTag(cbor
|
|
3857
|
-
const content = extractTaggedContent(cbor
|
|
3836
|
+
fromTaggedCbor(cbor) {
|
|
3837
|
+
validateTag(cbor, this.cborTags());
|
|
3838
|
+
const content = extractTaggedContent(cbor);
|
|
3858
3839
|
return this.fromUntaggedCbor(content);
|
|
3859
3840
|
}
|
|
3860
3841
|
/**
|
|
3861
3842
|
* Static method to decode from tagged CBOR.
|
|
3862
3843
|
*/
|
|
3863
|
-
static fromTaggedCbor(cbor
|
|
3864
|
-
return new X25519PrivateKey(new Uint8Array(X25519_PRIVATE_KEY_SIZE)).fromTaggedCbor(cbor
|
|
3844
|
+
static fromTaggedCbor(cbor) {
|
|
3845
|
+
return new X25519PrivateKey(new Uint8Array(X25519_PRIVATE_KEY_SIZE)).fromTaggedCbor(cbor);
|
|
3865
3846
|
}
|
|
3866
3847
|
/**
|
|
3867
3848
|
* Static method to decode from tagged CBOR binary data.
|
|
3868
3849
|
*/
|
|
3869
3850
|
static fromTaggedCborData(data) {
|
|
3870
|
-
const cbor
|
|
3871
|
-
return X25519PrivateKey.fromTaggedCbor(cbor
|
|
3851
|
+
const cbor = decodeCbor(data);
|
|
3852
|
+
return X25519PrivateKey.fromTaggedCbor(cbor);
|
|
3872
3853
|
}
|
|
3873
3854
|
/**
|
|
3874
3855
|
* Static method to decode from untagged CBOR binary data.
|
|
3875
3856
|
*/
|
|
3876
3857
|
static fromUntaggedCborData(data) {
|
|
3877
|
-
const cbor
|
|
3878
|
-
return new X25519PrivateKey(new Uint8Array(X25519_PRIVATE_KEY_SIZE)).fromUntaggedCbor(cbor
|
|
3858
|
+
const cbor = decodeCbor(data);
|
|
3859
|
+
return new X25519PrivateKey(new Uint8Array(X25519_PRIVATE_KEY_SIZE)).fromUntaggedCbor(cbor);
|
|
3879
3860
|
}
|
|
3880
3861
|
/**
|
|
3881
3862
|
* Returns the UR representation of the X25519PrivateKey.
|
|
@@ -3909,7 +3890,6 @@ var X25519PrivateKey = class X25519PrivateKey {
|
|
|
3909
3890
|
return X25519PrivateKey.fromUR(ur);
|
|
3910
3891
|
}
|
|
3911
3892
|
};
|
|
3912
|
-
|
|
3913
3893
|
//#endregion
|
|
3914
3894
|
//#region src/ed25519/ed25519-public-key.ts
|
|
3915
3895
|
/**
|
|
@@ -3982,7 +3962,6 @@ var Ed25519PublicKey = class Ed25519PublicKey {
|
|
|
3982
3962
|
return `Ed25519PublicKey(${this.toHex().substring(0, 16)}...)`;
|
|
3983
3963
|
}
|
|
3984
3964
|
};
|
|
3985
|
-
|
|
3986
3965
|
//#endregion
|
|
3987
3966
|
//#region src/ed25519/ed25519-private-key.ts
|
|
3988
3967
|
/**
|
|
@@ -4078,7 +4057,6 @@ var Ed25519PrivateKey = class Ed25519PrivateKey {
|
|
|
4078
4057
|
return `Ed25519PrivateKey(${this.toHex().substring(0, 16)}...)`;
|
|
4079
4058
|
}
|
|
4080
4059
|
};
|
|
4081
|
-
|
|
4082
4060
|
//#endregion
|
|
4083
4061
|
//#region src/sr25519/sr25519-public-key.ts
|
|
4084
4062
|
/**
|
|
@@ -4103,7 +4081,7 @@ var Ed25519PrivateKey = class Ed25519PrivateKey {
|
|
|
4103
4081
|
var Sr25519PublicKey = class Sr25519PublicKey {
|
|
4104
4082
|
_data;
|
|
4105
4083
|
constructor(data) {
|
|
4106
|
-
if (data.length !==
|
|
4084
|
+
if (data.length !== 32) throw new Error(`Sr25519PublicKey must be 32 bytes, got ${data.length}`);
|
|
4107
4085
|
this._data = new Uint8Array(data);
|
|
4108
4086
|
}
|
|
4109
4087
|
/**
|
|
@@ -4183,7 +4161,6 @@ var Sr25519PublicKey = class Sr25519PublicKey {
|
|
|
4183
4161
|
return `Sr25519PublicKey(${bytesToHex(this._data).substring(0, 16)}...)`;
|
|
4184
4162
|
}
|
|
4185
4163
|
};
|
|
4186
|
-
|
|
4187
4164
|
//#endregion
|
|
4188
4165
|
//#region src/sr25519/sr25519-private-key.ts
|
|
4189
4166
|
/**
|
|
@@ -4222,7 +4199,7 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
|
|
|
4222
4199
|
_seed;
|
|
4223
4200
|
_cachedPublicKey;
|
|
4224
4201
|
constructor(seed) {
|
|
4225
|
-
if (seed.length !==
|
|
4202
|
+
if (seed.length !== 32) throw new Error(`Sr25519PrivateKey seed must be 32 bytes, got ${seed.length}`);
|
|
4226
4203
|
this._seed = new Uint8Array(seed);
|
|
4227
4204
|
}
|
|
4228
4205
|
/**
|
|
@@ -4236,7 +4213,7 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
|
|
|
4236
4213
|
* Create a new random Sr25519 private key using the provided RNG.
|
|
4237
4214
|
*/
|
|
4238
4215
|
static randomUsing(rng) {
|
|
4239
|
-
return new Sr25519PrivateKey(rng.randomData(
|
|
4216
|
+
return new Sr25519PrivateKey(rng.randomData(32));
|
|
4240
4217
|
}
|
|
4241
4218
|
/**
|
|
4242
4219
|
* Create an Sr25519 private key from a 32-byte seed.
|
|
@@ -4267,7 +4244,7 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
|
|
|
4267
4244
|
* @returns A new Sr25519 private key
|
|
4268
4245
|
*/
|
|
4269
4246
|
static deriveFromKeyMaterial(keyMaterial) {
|
|
4270
|
-
return new Sr25519PrivateKey(blake2b(keyMaterial, { dkLen:
|
|
4247
|
+
return new Sr25519PrivateKey(blake2b(keyMaterial, { dkLen: 32 }));
|
|
4271
4248
|
}
|
|
4272
4249
|
/**
|
|
4273
4250
|
* Generate a keypair and return both private and public keys.
|
|
@@ -4356,7 +4333,6 @@ var Sr25519PrivateKey = class Sr25519PrivateKey {
|
|
|
4356
4333
|
return `Sr25519PrivateKey(${bytesToHex(this._seed).substring(0, 8)}...)`;
|
|
4357
4334
|
}
|
|
4358
4335
|
};
|
|
4359
|
-
|
|
4360
4336
|
//#endregion
|
|
4361
4337
|
//#region src/ec-key/ec-key-base.ts
|
|
4362
4338
|
/**
|
|
@@ -4381,7 +4357,6 @@ function isECPublicKeyBase(obj) {
|
|
|
4381
4357
|
if (!isECKey(obj)) return false;
|
|
4382
4358
|
return typeof obj.uncompressedPublicKey === "function";
|
|
4383
4359
|
}
|
|
4384
|
-
|
|
4385
4360
|
//#endregion
|
|
4386
4361
|
//#region src/ec-key/ec-uncompressed-public-key.ts
|
|
4387
4362
|
/**
|
|
@@ -4595,7 +4570,6 @@ var ECUncompressedPublicKey = class ECUncompressedPublicKey {
|
|
|
4595
4570
|
return ECUncompressedPublicKey.fromUR(ur);
|
|
4596
4571
|
}
|
|
4597
4572
|
};
|
|
4598
|
-
|
|
4599
4573
|
//#endregion
|
|
4600
4574
|
//#region src/ec-key/ec-public-key.ts
|
|
4601
4575
|
/**
|
|
@@ -4835,7 +4809,6 @@ var ECPublicKey = class ECPublicKey {
|
|
|
4835
4809
|
return ECPublicKey.fromUR(ur);
|
|
4836
4810
|
}
|
|
4837
4811
|
};
|
|
4838
|
-
|
|
4839
4812
|
//#endregion
|
|
4840
4813
|
//#region src/ec-key/schnorr-public-key.ts
|
|
4841
4814
|
/**
|
|
@@ -4958,7 +4931,6 @@ var SchnorrPublicKey = class SchnorrPublicKey {
|
|
|
4958
4931
|
return `SchnorrPublicKey(${this.toHex().substring(0, 16)}...)`;
|
|
4959
4932
|
}
|
|
4960
4933
|
};
|
|
4961
|
-
|
|
4962
4934
|
//#endregion
|
|
4963
4935
|
//#region src/ec-key/ec-private-key.ts
|
|
4964
4936
|
/**
|
|
@@ -5273,7 +5245,6 @@ var ECPrivateKey = class ECPrivateKey {
|
|
|
5273
5245
|
return ECPrivateKey.fromUR(ur);
|
|
5274
5246
|
}
|
|
5275
5247
|
};
|
|
5276
|
-
|
|
5277
5248
|
//#endregion
|
|
5278
5249
|
//#region src/mldsa/mldsa-level.ts
|
|
5279
5250
|
/**
|
|
@@ -5301,30 +5272,30 @@ var ECPrivateKey = class ECPrivateKey {
|
|
|
5301
5272
|
* - 3: NIST Level 3 (MLDSA65)
|
|
5302
5273
|
* - 5: NIST Level 5 (MLDSA87)
|
|
5303
5274
|
*/
|
|
5304
|
-
let MLDSALevel = /* @__PURE__ */ function(MLDSALevel
|
|
5275
|
+
let MLDSALevel = /* @__PURE__ */ function(MLDSALevel) {
|
|
5305
5276
|
/** NIST Level 2 - AES-128 equivalent security */
|
|
5306
|
-
MLDSALevel
|
|
5277
|
+
MLDSALevel[MLDSALevel["MLDSA44"] = 2] = "MLDSA44";
|
|
5307
5278
|
/** NIST Level 3 - AES-192 equivalent security */
|
|
5308
|
-
MLDSALevel
|
|
5279
|
+
MLDSALevel[MLDSALevel["MLDSA65"] = 3] = "MLDSA65";
|
|
5309
5280
|
/** NIST Level 5 - AES-256 equivalent security */
|
|
5310
|
-
MLDSALevel
|
|
5311
|
-
return MLDSALevel
|
|
5281
|
+
MLDSALevel[MLDSALevel["MLDSA87"] = 5] = "MLDSA87";
|
|
5282
|
+
return MLDSALevel;
|
|
5312
5283
|
}({});
|
|
5313
5284
|
/**
|
|
5314
5285
|
* Key sizes for each ML-DSA security level.
|
|
5315
5286
|
*/
|
|
5316
5287
|
const MLDSA_KEY_SIZES = {
|
|
5317
|
-
[
|
|
5288
|
+
[2]: {
|
|
5318
5289
|
privateKey: 2560,
|
|
5319
5290
|
publicKey: 1312,
|
|
5320
5291
|
signature: 2420
|
|
5321
5292
|
},
|
|
5322
|
-
[
|
|
5293
|
+
[3]: {
|
|
5323
5294
|
privateKey: 4032,
|
|
5324
5295
|
publicKey: 1952,
|
|
5325
5296
|
signature: 3309
|
|
5326
5297
|
},
|
|
5327
|
-
[
|
|
5298
|
+
[5]: {
|
|
5328
5299
|
privateKey: 4896,
|
|
5329
5300
|
publicKey: 2592,
|
|
5330
5301
|
signature: 4627
|
|
@@ -5353,9 +5324,9 @@ function mldsaSignatureSize(level) {
|
|
|
5353
5324
|
*/
|
|
5354
5325
|
function mldsaLevelToString(level) {
|
|
5355
5326
|
switch (level) {
|
|
5356
|
-
case
|
|
5357
|
-
case
|
|
5358
|
-
case
|
|
5327
|
+
case 2: return "MLDSA44";
|
|
5328
|
+
case 3: return "MLDSA65";
|
|
5329
|
+
case 5: return "MLDSA87";
|
|
5359
5330
|
}
|
|
5360
5331
|
}
|
|
5361
5332
|
/**
|
|
@@ -5363,9 +5334,9 @@ function mldsaLevelToString(level) {
|
|
|
5363
5334
|
*/
|
|
5364
5335
|
function mldsaLevelFromValue(value) {
|
|
5365
5336
|
switch (value) {
|
|
5366
|
-
case 2: return
|
|
5367
|
-
case 3: return
|
|
5368
|
-
case 5: return
|
|
5337
|
+
case 2: return 2;
|
|
5338
|
+
case 3: return 3;
|
|
5339
|
+
case 5: return 5;
|
|
5369
5340
|
default: throw new Error(`Invalid MLDSA level value: ${value}`);
|
|
5370
5341
|
}
|
|
5371
5342
|
}
|
|
@@ -5388,21 +5359,21 @@ function mldsaGenerateKeypair(level) {
|
|
|
5388
5359
|
function mldsaGenerateKeypairUsing(level, rng) {
|
|
5389
5360
|
const seed = rng.randomData(32);
|
|
5390
5361
|
switch (level) {
|
|
5391
|
-
case
|
|
5362
|
+
case 2: {
|
|
5392
5363
|
const keypair = ml_dsa44.keygen(seed);
|
|
5393
5364
|
return {
|
|
5394
5365
|
publicKey: keypair.publicKey,
|
|
5395
5366
|
secretKey: keypair.secretKey
|
|
5396
5367
|
};
|
|
5397
5368
|
}
|
|
5398
|
-
case
|
|
5369
|
+
case 3: {
|
|
5399
5370
|
const keypair = ml_dsa65.keygen(seed);
|
|
5400
5371
|
return {
|
|
5401
5372
|
publicKey: keypair.publicKey,
|
|
5402
5373
|
secretKey: keypair.secretKey
|
|
5403
5374
|
};
|
|
5404
5375
|
}
|
|
5405
|
-
case
|
|
5376
|
+
case 5: {
|
|
5406
5377
|
const keypair = ml_dsa87.keygen(seed);
|
|
5407
5378
|
return {
|
|
5408
5379
|
publicKey: keypair.publicKey,
|
|
@@ -5421,9 +5392,9 @@ function mldsaGenerateKeypairUsing(level, rng) {
|
|
|
5421
5392
|
*/
|
|
5422
5393
|
function mldsaSign(level, secretKey, message) {
|
|
5423
5394
|
switch (level) {
|
|
5424
|
-
case
|
|
5425
|
-
case
|
|
5426
|
-
case
|
|
5395
|
+
case 2: return ml_dsa44.sign(message, secretKey);
|
|
5396
|
+
case 3: return ml_dsa65.sign(message, secretKey);
|
|
5397
|
+
case 5: return ml_dsa87.sign(message, secretKey);
|
|
5427
5398
|
}
|
|
5428
5399
|
}
|
|
5429
5400
|
/**
|
|
@@ -5438,15 +5409,14 @@ function mldsaSign(level, secretKey, message) {
|
|
|
5438
5409
|
function mldsaVerify(level, publicKey, message, signature) {
|
|
5439
5410
|
try {
|
|
5440
5411
|
switch (level) {
|
|
5441
|
-
case
|
|
5442
|
-
case
|
|
5443
|
-
case
|
|
5412
|
+
case 2: return ml_dsa44.verify(signature, message, publicKey);
|
|
5413
|
+
case 3: return ml_dsa65.verify(signature, message, publicKey);
|
|
5414
|
+
case 5: return ml_dsa87.verify(signature, message, publicKey);
|
|
5444
5415
|
}
|
|
5445
5416
|
} catch {
|
|
5446
5417
|
return false;
|
|
5447
5418
|
}
|
|
5448
5419
|
}
|
|
5449
|
-
|
|
5450
5420
|
//#endregion
|
|
5451
5421
|
//#region src/mldsa/mldsa-public-key.ts
|
|
5452
5422
|
/**
|
|
@@ -5592,8 +5562,7 @@ var MLDSAPublicKey = class MLDSAPublicKey {
|
|
|
5592
5562
|
* Static method to decode from tagged CBOR.
|
|
5593
5563
|
*/
|
|
5594
5564
|
static fromTaggedCbor(cborValue) {
|
|
5595
|
-
|
|
5596
|
-
return new MLDSAPublicKey(MLDSALevel.MLDSA44, dummyData).fromTaggedCbor(cborValue);
|
|
5565
|
+
return new MLDSAPublicKey(2, new Uint8Array(mldsaPublicKeySize(2))).fromTaggedCbor(cborValue);
|
|
5597
5566
|
}
|
|
5598
5567
|
/**
|
|
5599
5568
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -5607,8 +5576,7 @@ var MLDSAPublicKey = class MLDSAPublicKey {
|
|
|
5607
5576
|
*/
|
|
5608
5577
|
static fromUntaggedCborData(data) {
|
|
5609
5578
|
const cborValue = decodeCbor(data);
|
|
5610
|
-
|
|
5611
|
-
return new MLDSAPublicKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(cborValue);
|
|
5579
|
+
return new MLDSAPublicKey(2, new Uint8Array(mldsaPublicKeySize(2))).fromUntaggedCbor(cborValue);
|
|
5612
5580
|
}
|
|
5613
5581
|
/**
|
|
5614
5582
|
* Returns the UR representation.
|
|
@@ -5629,8 +5597,7 @@ var MLDSAPublicKey = class MLDSAPublicKey {
|
|
|
5629
5597
|
*/
|
|
5630
5598
|
static fromUR(ur) {
|
|
5631
5599
|
if (ur.urTypeStr() !== MLDSA_PUBLIC_KEY.name) throw new Error(`Expected UR type ${MLDSA_PUBLIC_KEY.name}, got ${ur.urTypeStr()}`);
|
|
5632
|
-
|
|
5633
|
-
return new MLDSAPublicKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(ur.cbor());
|
|
5600
|
+
return new MLDSAPublicKey(2, new Uint8Array(mldsaPublicKeySize(2))).fromUntaggedCbor(ur.cbor());
|
|
5634
5601
|
}
|
|
5635
5602
|
/**
|
|
5636
5603
|
* Creates an MLDSAPublicKey from a UR string.
|
|
@@ -5640,7 +5607,6 @@ var MLDSAPublicKey = class MLDSAPublicKey {
|
|
|
5640
5607
|
return MLDSAPublicKey.fromUR(ur);
|
|
5641
5608
|
}
|
|
5642
5609
|
};
|
|
5643
|
-
|
|
5644
5610
|
//#endregion
|
|
5645
5611
|
//#region src/mldsa/mldsa-signature.ts
|
|
5646
5612
|
/**
|
|
@@ -5775,8 +5741,7 @@ var MLDSASignature = class MLDSASignature {
|
|
|
5775
5741
|
* Static method to decode from tagged CBOR.
|
|
5776
5742
|
*/
|
|
5777
5743
|
static fromTaggedCbor(cborValue) {
|
|
5778
|
-
|
|
5779
|
-
return new MLDSASignature(MLDSALevel.MLDSA44, dummyData).fromTaggedCbor(cborValue);
|
|
5744
|
+
return new MLDSASignature(2, new Uint8Array(mldsaSignatureSize(2))).fromTaggedCbor(cborValue);
|
|
5780
5745
|
}
|
|
5781
5746
|
/**
|
|
5782
5747
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -5790,8 +5755,7 @@ var MLDSASignature = class MLDSASignature {
|
|
|
5790
5755
|
*/
|
|
5791
5756
|
static fromUntaggedCborData(data) {
|
|
5792
5757
|
const cborValue = decodeCbor(data);
|
|
5793
|
-
|
|
5794
|
-
return new MLDSASignature(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(cborValue);
|
|
5758
|
+
return new MLDSASignature(2, new Uint8Array(mldsaSignatureSize(2))).fromUntaggedCbor(cborValue);
|
|
5795
5759
|
}
|
|
5796
5760
|
/**
|
|
5797
5761
|
* Returns the UR representation.
|
|
@@ -5812,8 +5776,7 @@ var MLDSASignature = class MLDSASignature {
|
|
|
5812
5776
|
*/
|
|
5813
5777
|
static fromUR(ur) {
|
|
5814
5778
|
if (ur.urTypeStr() !== MLDSA_SIGNATURE.name) throw new Error(`Expected UR type ${MLDSA_SIGNATURE.name}, got ${ur.urTypeStr()}`);
|
|
5815
|
-
|
|
5816
|
-
return new MLDSASignature(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(ur.cbor());
|
|
5779
|
+
return new MLDSASignature(2, new Uint8Array(mldsaSignatureSize(2))).fromUntaggedCbor(ur.cbor());
|
|
5817
5780
|
}
|
|
5818
5781
|
/**
|
|
5819
5782
|
* Creates an MLDSASignature from a UR string.
|
|
@@ -5823,7 +5786,6 @@ var MLDSASignature = class MLDSASignature {
|
|
|
5823
5786
|
return MLDSASignature.fromUR(ur);
|
|
5824
5787
|
}
|
|
5825
5788
|
};
|
|
5826
|
-
|
|
5827
5789
|
//#endregion
|
|
5828
5790
|
//#region src/mldsa/mldsa-private-key.ts
|
|
5829
5791
|
/**
|
|
@@ -5866,7 +5828,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
5866
5828
|
*
|
|
5867
5829
|
* @param level - The ML-DSA security level (default: MLDSA65)
|
|
5868
5830
|
*/
|
|
5869
|
-
static new(level =
|
|
5831
|
+
static new(level = 3) {
|
|
5870
5832
|
const rng = new SecureRandomNumberGenerator();
|
|
5871
5833
|
return MLDSAPrivateKey.newUsing(level, rng);
|
|
5872
5834
|
}
|
|
@@ -5894,7 +5856,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
5894
5856
|
* @param level - The ML-DSA security level (default: MLDSA65)
|
|
5895
5857
|
* @returns Tuple of [privateKey, publicKey]
|
|
5896
5858
|
*/
|
|
5897
|
-
static keypair(level =
|
|
5859
|
+
static keypair(level = 3) {
|
|
5898
5860
|
const rng = new SecureRandomNumberGenerator();
|
|
5899
5861
|
return MLDSAPrivateKey.keypairUsing(level, rng);
|
|
5900
5862
|
}
|
|
@@ -6017,8 +5979,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
6017
5979
|
* Static method to decode from tagged CBOR.
|
|
6018
5980
|
*/
|
|
6019
5981
|
static fromTaggedCbor(cborValue) {
|
|
6020
|
-
|
|
6021
|
-
return new MLDSAPrivateKey(MLDSALevel.MLDSA44, dummyData).fromTaggedCbor(cborValue);
|
|
5982
|
+
return new MLDSAPrivateKey(2, new Uint8Array(mldsaPrivateKeySize(2))).fromTaggedCbor(cborValue);
|
|
6022
5983
|
}
|
|
6023
5984
|
/**
|
|
6024
5985
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -6032,8 +5993,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
6032
5993
|
*/
|
|
6033
5994
|
static fromUntaggedCborData(data) {
|
|
6034
5995
|
const cborValue = decodeCbor(data);
|
|
6035
|
-
|
|
6036
|
-
return new MLDSAPrivateKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(cborValue);
|
|
5996
|
+
return new MLDSAPrivateKey(2, new Uint8Array(mldsaPrivateKeySize(2))).fromUntaggedCbor(cborValue);
|
|
6037
5997
|
}
|
|
6038
5998
|
/**
|
|
6039
5999
|
* Returns the UR representation.
|
|
@@ -6054,8 +6014,7 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
6054
6014
|
*/
|
|
6055
6015
|
static fromUR(ur) {
|
|
6056
6016
|
if (ur.urTypeStr() !== MLDSA_PRIVATE_KEY.name) throw new Error(`Expected UR type ${MLDSA_PRIVATE_KEY.name}, got ${ur.urTypeStr()}`);
|
|
6057
|
-
|
|
6058
|
-
return new MLDSAPrivateKey(MLDSALevel.MLDSA44, dummyData).fromUntaggedCbor(ur.cbor());
|
|
6017
|
+
return new MLDSAPrivateKey(2, new Uint8Array(mldsaPrivateKeySize(2))).fromUntaggedCbor(ur.cbor());
|
|
6059
6018
|
}
|
|
6060
6019
|
/**
|
|
6061
6020
|
* Creates an MLDSAPrivateKey from a UR string.
|
|
@@ -6065,7 +6024,6 @@ var MLDSAPrivateKey = class MLDSAPrivateKey {
|
|
|
6065
6024
|
return MLDSAPrivateKey.fromUR(ur);
|
|
6066
6025
|
}
|
|
6067
6026
|
};
|
|
6068
|
-
|
|
6069
6027
|
//#endregion
|
|
6070
6028
|
//#region src/signing/signature.ts
|
|
6071
6029
|
/**
|
|
@@ -6117,7 +6075,7 @@ var Signature = class Signature {
|
|
|
6117
6075
|
*/
|
|
6118
6076
|
static schnorrFromData(data) {
|
|
6119
6077
|
if (data.length !== SCHNORR_SIGNATURE_SIZE) throw CryptoError.invalidSize(SCHNORR_SIGNATURE_SIZE, data.length);
|
|
6120
|
-
return new Signature(
|
|
6078
|
+
return new Signature("Schnorr", data);
|
|
6121
6079
|
}
|
|
6122
6080
|
/**
|
|
6123
6081
|
* Creates a Schnorr signature from a hex string.
|
|
@@ -6136,7 +6094,7 @@ var Signature = class Signature {
|
|
|
6136
6094
|
*/
|
|
6137
6095
|
static ecdsaFromData(data) {
|
|
6138
6096
|
if (data.length !== ECDSA_SIGNATURE_SIZE) throw CryptoError.invalidSize(ECDSA_SIGNATURE_SIZE, data.length);
|
|
6139
|
-
return new Signature(
|
|
6097
|
+
return new Signature("Ecdsa", data);
|
|
6140
6098
|
}
|
|
6141
6099
|
/**
|
|
6142
6100
|
* Creates an ECDSA signature from a hex string.
|
|
@@ -6155,7 +6113,7 @@ var Signature = class Signature {
|
|
|
6155
6113
|
*/
|
|
6156
6114
|
static ed25519FromData(data) {
|
|
6157
6115
|
if (data.length !== ED25519_SIGNATURE_SIZE) throw CryptoError.invalidSize(ED25519_SIGNATURE_SIZE, data.length);
|
|
6158
|
-
return new Signature(
|
|
6116
|
+
return new Signature("Ed25519", data);
|
|
6159
6117
|
}
|
|
6160
6118
|
/**
|
|
6161
6119
|
* Creates an Ed25519 signature from a hex string.
|
|
@@ -6173,8 +6131,8 @@ var Signature = class Signature {
|
|
|
6173
6131
|
* @returns A new Sr25519 signature
|
|
6174
6132
|
*/
|
|
6175
6133
|
static sr25519FromData(data) {
|
|
6176
|
-
if (data.length !==
|
|
6177
|
-
return new Signature(
|
|
6134
|
+
if (data.length !== 64) throw CryptoError.invalidSize(64, data.length);
|
|
6135
|
+
return new Signature("Sr25519", data);
|
|
6178
6136
|
}
|
|
6179
6137
|
/**
|
|
6180
6138
|
* Creates an Sr25519 signature from a hex string.
|
|
@@ -6194,14 +6152,14 @@ var Signature = class Signature {
|
|
|
6194
6152
|
static mldsaFromSignature(sig) {
|
|
6195
6153
|
let scheme;
|
|
6196
6154
|
switch (sig.level()) {
|
|
6197
|
-
case
|
|
6198
|
-
scheme =
|
|
6155
|
+
case 2:
|
|
6156
|
+
scheme = "MLDSA44";
|
|
6199
6157
|
break;
|
|
6200
|
-
case
|
|
6201
|
-
scheme =
|
|
6158
|
+
case 3:
|
|
6159
|
+
scheme = "MLDSA65";
|
|
6202
6160
|
break;
|
|
6203
|
-
case
|
|
6204
|
-
scheme =
|
|
6161
|
+
case 5:
|
|
6162
|
+
scheme = "MLDSA87";
|
|
6205
6163
|
break;
|
|
6206
6164
|
default: throw new Error(`Unknown MLDSA level: ${sig.level()}`);
|
|
6207
6165
|
}
|
|
@@ -6219,17 +6177,17 @@ var Signature = class Signature {
|
|
|
6219
6177
|
*/
|
|
6220
6178
|
signatureType() {
|
|
6221
6179
|
switch (this._type) {
|
|
6222
|
-
case
|
|
6223
|
-
case
|
|
6224
|
-
case
|
|
6225
|
-
case
|
|
6226
|
-
case
|
|
6227
|
-
case
|
|
6228
|
-
case
|
|
6229
|
-
case
|
|
6230
|
-
case
|
|
6231
|
-
case
|
|
6232
|
-
case
|
|
6180
|
+
case "Ed25519": return "Ed25519";
|
|
6181
|
+
case "Schnorr": return "Schnorr";
|
|
6182
|
+
case "Ecdsa": return "Ecdsa";
|
|
6183
|
+
case "Sr25519": return "Sr25519";
|
|
6184
|
+
case "MLDSA44": return "MLDSA-44";
|
|
6185
|
+
case "MLDSA65": return "MLDSA-65";
|
|
6186
|
+
case "MLDSA87": return "MLDSA-87";
|
|
6187
|
+
case "SshEd25519": return "SshEd25519";
|
|
6188
|
+
case "SshDsa": return "SshDsa";
|
|
6189
|
+
case "SshEcdsaP256": return "SshEcdsaP256";
|
|
6190
|
+
case "SshEcdsaP384": return "SshEcdsaP384";
|
|
6233
6191
|
default: return this._type;
|
|
6234
6192
|
}
|
|
6235
6193
|
}
|
|
@@ -6245,14 +6203,14 @@ var Signature = class Signature {
|
|
|
6245
6203
|
* @returns The 64-byte signature data if this is a Schnorr signature, null otherwise
|
|
6246
6204
|
*/
|
|
6247
6205
|
toSchnorr() {
|
|
6248
|
-
if (this._type ===
|
|
6206
|
+
if (this._type === "Schnorr") return this._data;
|
|
6249
6207
|
return null;
|
|
6250
6208
|
}
|
|
6251
6209
|
/**
|
|
6252
6210
|
* Checks if this is a Schnorr signature.
|
|
6253
6211
|
*/
|
|
6254
6212
|
isSchnorr() {
|
|
6255
|
-
return this._type ===
|
|
6213
|
+
return this._type === "Schnorr";
|
|
6256
6214
|
}
|
|
6257
6215
|
/**
|
|
6258
6216
|
* Returns the ECDSA signature data if this is an ECDSA signature.
|
|
@@ -6260,14 +6218,14 @@ var Signature = class Signature {
|
|
|
6260
6218
|
* @returns The 64-byte signature data if this is an ECDSA signature, null otherwise
|
|
6261
6219
|
*/
|
|
6262
6220
|
toEcdsa() {
|
|
6263
|
-
if (this._type ===
|
|
6221
|
+
if (this._type === "Ecdsa") return this._data;
|
|
6264
6222
|
return null;
|
|
6265
6223
|
}
|
|
6266
6224
|
/**
|
|
6267
6225
|
* Checks if this is an ECDSA signature.
|
|
6268
6226
|
*/
|
|
6269
6227
|
isEcdsa() {
|
|
6270
|
-
return this._type ===
|
|
6228
|
+
return this._type === "Ecdsa";
|
|
6271
6229
|
}
|
|
6272
6230
|
/**
|
|
6273
6231
|
* Returns the Ed25519 signature data if this is an Ed25519 signature.
|
|
@@ -6275,14 +6233,14 @@ var Signature = class Signature {
|
|
|
6275
6233
|
* @returns The 64-byte signature data if this is an Ed25519 signature, null otherwise
|
|
6276
6234
|
*/
|
|
6277
6235
|
toEd25519() {
|
|
6278
|
-
if (this._type ===
|
|
6236
|
+
if (this._type === "Ed25519") return this._data;
|
|
6279
6237
|
return null;
|
|
6280
6238
|
}
|
|
6281
6239
|
/**
|
|
6282
6240
|
* Checks if this is an Ed25519 signature.
|
|
6283
6241
|
*/
|
|
6284
6242
|
isEd25519() {
|
|
6285
|
-
return this._type ===
|
|
6243
|
+
return this._type === "Ed25519";
|
|
6286
6244
|
}
|
|
6287
6245
|
/**
|
|
6288
6246
|
* Returns the Sr25519 signature data if this is an Sr25519 signature.
|
|
@@ -6290,14 +6248,14 @@ var Signature = class Signature {
|
|
|
6290
6248
|
* @returns The 64-byte signature data if this is an Sr25519 signature, null otherwise
|
|
6291
6249
|
*/
|
|
6292
6250
|
toSr25519() {
|
|
6293
|
-
if (this._type ===
|
|
6251
|
+
if (this._type === "Sr25519") return this._data;
|
|
6294
6252
|
return null;
|
|
6295
6253
|
}
|
|
6296
6254
|
/**
|
|
6297
6255
|
* Checks if this is an Sr25519 signature.
|
|
6298
6256
|
*/
|
|
6299
6257
|
isSr25519() {
|
|
6300
|
-
return this._type ===
|
|
6258
|
+
return this._type === "Sr25519";
|
|
6301
6259
|
}
|
|
6302
6260
|
/**
|
|
6303
6261
|
* Returns the MLDSASignature if this is an MLDSA signature.
|
|
@@ -6352,19 +6310,19 @@ var Signature = class Signature {
|
|
|
6352
6310
|
*/
|
|
6353
6311
|
untaggedCbor() {
|
|
6354
6312
|
switch (this._type) {
|
|
6355
|
-
case
|
|
6356
|
-
case
|
|
6357
|
-
case
|
|
6358
|
-
case
|
|
6359
|
-
case
|
|
6360
|
-
case
|
|
6361
|
-
case
|
|
6313
|
+
case "Schnorr": return toByteString(this._data);
|
|
6314
|
+
case "Ecdsa": return cbor([1, toByteString(this._data)]);
|
|
6315
|
+
case "Ed25519": return cbor([2, toByteString(this._data)]);
|
|
6316
|
+
case "Sr25519": return cbor([3, toByteString(this._data)]);
|
|
6317
|
+
case "MLDSA44":
|
|
6318
|
+
case "MLDSA65":
|
|
6319
|
+
case "MLDSA87":
|
|
6362
6320
|
if (this._mldsaSignature === void 0) throw new Error("MLDSA signature is missing");
|
|
6363
6321
|
return this._mldsaSignature.taggedCbor();
|
|
6364
|
-
case
|
|
6365
|
-
case
|
|
6366
|
-
case
|
|
6367
|
-
case
|
|
6322
|
+
case "SshEd25519":
|
|
6323
|
+
case "SshDsa":
|
|
6324
|
+
case "SshEcdsaP256":
|
|
6325
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported for CBOR encoding`);
|
|
6368
6326
|
}
|
|
6369
6327
|
}
|
|
6370
6328
|
/**
|
|
@@ -6425,7 +6383,7 @@ var Signature = class Signature {
|
|
|
6425
6383
|
* Static method to decode from tagged CBOR.
|
|
6426
6384
|
*/
|
|
6427
6385
|
static fromTaggedCbor(cborValue) {
|
|
6428
|
-
return new Signature(
|
|
6386
|
+
return new Signature("Ed25519", new Uint8Array(ED25519_SIGNATURE_SIZE)).fromTaggedCbor(cborValue);
|
|
6429
6387
|
}
|
|
6430
6388
|
/**
|
|
6431
6389
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -6439,7 +6397,7 @@ var Signature = class Signature {
|
|
|
6439
6397
|
*/
|
|
6440
6398
|
static fromUntaggedCborData(data) {
|
|
6441
6399
|
const cborValue = decodeCbor(data);
|
|
6442
|
-
return new Signature(
|
|
6400
|
+
return new Signature("Ed25519", new Uint8Array(ED25519_SIGNATURE_SIZE)).fromUntaggedCbor(cborValue);
|
|
6443
6401
|
}
|
|
6444
6402
|
/**
|
|
6445
6403
|
* Get the UR type for signatures.
|
|
@@ -6478,7 +6436,6 @@ var Signature = class Signature {
|
|
|
6478
6436
|
return Signature.fromURString(urString);
|
|
6479
6437
|
}
|
|
6480
6438
|
};
|
|
6481
|
-
|
|
6482
6439
|
//#endregion
|
|
6483
6440
|
//#region src/signing/signing-public-key.ts
|
|
6484
6441
|
/**
|
|
@@ -6537,7 +6494,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6537
6494
|
* @returns A new signing public key containing the Schnorr key
|
|
6538
6495
|
*/
|
|
6539
6496
|
static fromSchnorr(key) {
|
|
6540
|
-
return new SigningPublicKey(
|
|
6497
|
+
return new SigningPublicKey("Schnorr", key, void 0, void 0, void 0, void 0);
|
|
6541
6498
|
}
|
|
6542
6499
|
/**
|
|
6543
6500
|
* Creates a new signing public key from an ECDSA (compressed) public key.
|
|
@@ -6546,7 +6503,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6546
6503
|
* @returns A new signing public key containing the ECDSA key
|
|
6547
6504
|
*/
|
|
6548
6505
|
static fromEcdsa(key) {
|
|
6549
|
-
return new SigningPublicKey(
|
|
6506
|
+
return new SigningPublicKey("Ecdsa", void 0, key, void 0, void 0, void 0);
|
|
6550
6507
|
}
|
|
6551
6508
|
/**
|
|
6552
6509
|
* Creates a new signing public key from an Ed25519 public key.
|
|
@@ -6555,7 +6512,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6555
6512
|
* @returns A new signing public key containing the Ed25519 key
|
|
6556
6513
|
*/
|
|
6557
6514
|
static fromEd25519(key) {
|
|
6558
|
-
return new SigningPublicKey(
|
|
6515
|
+
return new SigningPublicKey("Ed25519", void 0, void 0, key, void 0, void 0);
|
|
6559
6516
|
}
|
|
6560
6517
|
/**
|
|
6561
6518
|
* Creates a new signing public key from an Sr25519 public key.
|
|
@@ -6564,7 +6521,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6564
6521
|
* @returns A new signing public key containing the Sr25519 key
|
|
6565
6522
|
*/
|
|
6566
6523
|
static fromSr25519(key) {
|
|
6567
|
-
return new SigningPublicKey(
|
|
6524
|
+
return new SigningPublicKey("Sr25519", void 0, void 0, void 0, key, void 0);
|
|
6568
6525
|
}
|
|
6569
6526
|
/**
|
|
6570
6527
|
* Creates a new signing public key from an MLDSAPublicKey.
|
|
@@ -6575,14 +6532,14 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6575
6532
|
static fromMldsa(key) {
|
|
6576
6533
|
let scheme;
|
|
6577
6534
|
switch (key.level()) {
|
|
6578
|
-
case
|
|
6579
|
-
scheme =
|
|
6535
|
+
case 2:
|
|
6536
|
+
scheme = "MLDSA44";
|
|
6580
6537
|
break;
|
|
6581
|
-
case
|
|
6582
|
-
scheme =
|
|
6538
|
+
case 3:
|
|
6539
|
+
scheme = "MLDSA65";
|
|
6583
6540
|
break;
|
|
6584
|
-
case
|
|
6585
|
-
scheme =
|
|
6541
|
+
case 5:
|
|
6542
|
+
scheme = "MLDSA87";
|
|
6586
6543
|
break;
|
|
6587
6544
|
default: throw new Error(`Unknown MLDSA level: ${key.level()}`);
|
|
6588
6545
|
}
|
|
@@ -6600,17 +6557,17 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6600
6557
|
*/
|
|
6601
6558
|
keyType() {
|
|
6602
6559
|
switch (this._type) {
|
|
6603
|
-
case
|
|
6604
|
-
case
|
|
6605
|
-
case
|
|
6606
|
-
case
|
|
6607
|
-
case
|
|
6608
|
-
case
|
|
6609
|
-
case
|
|
6610
|
-
case
|
|
6611
|
-
case
|
|
6612
|
-
case
|
|
6613
|
-
case
|
|
6560
|
+
case "Ed25519": return "Ed25519";
|
|
6561
|
+
case "Schnorr": return "Schnorr";
|
|
6562
|
+
case "Ecdsa": return "ECDSA";
|
|
6563
|
+
case "Sr25519": return "Sr25519";
|
|
6564
|
+
case "MLDSA44": return "MLDSA-44";
|
|
6565
|
+
case "MLDSA65": return "MLDSA-65";
|
|
6566
|
+
case "MLDSA87": return "MLDSA-87";
|
|
6567
|
+
case "SshEd25519": return "SSH-Ed25519";
|
|
6568
|
+
case "SshDsa": return "SSH-DSA";
|
|
6569
|
+
case "SshEcdsaP256": return "SSH-ECDSA-P256";
|
|
6570
|
+
case "SshEcdsaP384": return "SSH-ECDSA-P384";
|
|
6614
6571
|
default: return this._type;
|
|
6615
6572
|
}
|
|
6616
6573
|
}
|
|
@@ -6620,7 +6577,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6620
6577
|
* @returns The SchnorrPublicKey if this is a Schnorr key, null otherwise
|
|
6621
6578
|
*/
|
|
6622
6579
|
toSchnorr() {
|
|
6623
|
-
if (this._type ===
|
|
6580
|
+
if (this._type === "Schnorr" && this._schnorrKey !== void 0) return this._schnorrKey;
|
|
6624
6581
|
return null;
|
|
6625
6582
|
}
|
|
6626
6583
|
/**
|
|
@@ -6629,7 +6586,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6629
6586
|
* @returns The ECPublicKey if this is an ECDSA key, null otherwise
|
|
6630
6587
|
*/
|
|
6631
6588
|
toEcdsa() {
|
|
6632
|
-
if (this._type ===
|
|
6589
|
+
if (this._type === "Ecdsa" && this._ecdsaKey !== void 0) return this._ecdsaKey;
|
|
6633
6590
|
return null;
|
|
6634
6591
|
}
|
|
6635
6592
|
/**
|
|
@@ -6638,7 +6595,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6638
6595
|
* @returns The Ed25519 public key if this is an Ed25519 key, null otherwise
|
|
6639
6596
|
*/
|
|
6640
6597
|
toEd25519() {
|
|
6641
|
-
if (this._type ===
|
|
6598
|
+
if (this._type === "Ed25519" && this._ed25519Key !== void 0) return this._ed25519Key;
|
|
6642
6599
|
return null;
|
|
6643
6600
|
}
|
|
6644
6601
|
/**
|
|
@@ -6647,32 +6604,32 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6647
6604
|
* @returns The Sr25519 public key if this is an Sr25519 key, null otherwise
|
|
6648
6605
|
*/
|
|
6649
6606
|
toSr25519() {
|
|
6650
|
-
if (this._type ===
|
|
6607
|
+
if (this._type === "Sr25519" && this._sr25519Key !== void 0) return this._sr25519Key;
|
|
6651
6608
|
return null;
|
|
6652
6609
|
}
|
|
6653
6610
|
/**
|
|
6654
6611
|
* Checks if this is a Schnorr signing key.
|
|
6655
6612
|
*/
|
|
6656
6613
|
isSchnorr() {
|
|
6657
|
-
return this._type ===
|
|
6614
|
+
return this._type === "Schnorr";
|
|
6658
6615
|
}
|
|
6659
6616
|
/**
|
|
6660
6617
|
* Checks if this is an ECDSA signing key.
|
|
6661
6618
|
*/
|
|
6662
6619
|
isEcdsa() {
|
|
6663
|
-
return this._type ===
|
|
6620
|
+
return this._type === "Ecdsa";
|
|
6664
6621
|
}
|
|
6665
6622
|
/**
|
|
6666
6623
|
* Checks if this is an Ed25519 signing key.
|
|
6667
6624
|
*/
|
|
6668
6625
|
isEd25519() {
|
|
6669
|
-
return this._type ===
|
|
6626
|
+
return this._type === "Ed25519";
|
|
6670
6627
|
}
|
|
6671
6628
|
/**
|
|
6672
6629
|
* Checks if this is an Sr25519 signing key.
|
|
6673
6630
|
*/
|
|
6674
6631
|
isSr25519() {
|
|
6675
|
-
return this._type ===
|
|
6632
|
+
return this._type === "Sr25519";
|
|
6676
6633
|
}
|
|
6677
6634
|
/**
|
|
6678
6635
|
* Returns the underlying MLDSA public key if this is an MLDSA key.
|
|
@@ -6695,27 +6652,27 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6695
6652
|
equals(other) {
|
|
6696
6653
|
if (this._type !== other._type) return false;
|
|
6697
6654
|
switch (this._type) {
|
|
6698
|
-
case
|
|
6655
|
+
case "Schnorr":
|
|
6699
6656
|
if (this._schnorrKey === void 0 || other._schnorrKey === void 0) return false;
|
|
6700
6657
|
return this._schnorrKey.equals(other._schnorrKey);
|
|
6701
|
-
case
|
|
6658
|
+
case "Ecdsa":
|
|
6702
6659
|
if (this._ecdsaKey === void 0 || other._ecdsaKey === void 0) return false;
|
|
6703
6660
|
return this._ecdsaKey.equals(other._ecdsaKey);
|
|
6704
|
-
case
|
|
6661
|
+
case "Ed25519":
|
|
6705
6662
|
if (this._ed25519Key === void 0 || other._ed25519Key === void 0) return false;
|
|
6706
6663
|
return this._ed25519Key.equals(other._ed25519Key);
|
|
6707
|
-
case
|
|
6664
|
+
case "Sr25519":
|
|
6708
6665
|
if (this._sr25519Key === void 0 || other._sr25519Key === void 0) return false;
|
|
6709
6666
|
return this._sr25519Key.equals(other._sr25519Key);
|
|
6710
|
-
case
|
|
6711
|
-
case
|
|
6712
|
-
case
|
|
6667
|
+
case "MLDSA44":
|
|
6668
|
+
case "MLDSA65":
|
|
6669
|
+
case "MLDSA87":
|
|
6713
6670
|
if (this._mldsaKey === void 0 || other._mldsaKey === void 0) return false;
|
|
6714
6671
|
return this._mldsaKey.equals(other._mldsaKey);
|
|
6715
|
-
case
|
|
6716
|
-
case
|
|
6717
|
-
case
|
|
6718
|
-
case
|
|
6672
|
+
case "SshEd25519":
|
|
6673
|
+
case "SshDsa":
|
|
6674
|
+
case "SshEcdsaP256":
|
|
6675
|
+
case "SshEcdsaP384": return false;
|
|
6719
6676
|
}
|
|
6720
6677
|
}
|
|
6721
6678
|
/**
|
|
@@ -6723,17 +6680,17 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6723
6680
|
*/
|
|
6724
6681
|
toString() {
|
|
6725
6682
|
switch (this._type) {
|
|
6726
|
-
case
|
|
6727
|
-
case
|
|
6728
|
-
case
|
|
6729
|
-
case
|
|
6730
|
-
case
|
|
6731
|
-
case
|
|
6732
|
-
case
|
|
6733
|
-
case
|
|
6734
|
-
case
|
|
6735
|
-
case
|
|
6736
|
-
case
|
|
6683
|
+
case "Schnorr": return `SigningPublicKey(${this._type}, ${this._schnorrKey?.toHex().substring(0, 16)}...)`;
|
|
6684
|
+
case "Ecdsa": return `SigningPublicKey(${this._type}, ${this._ecdsaKey?.toHex().substring(0, 16)}...)`;
|
|
6685
|
+
case "Ed25519": return `SigningPublicKey(${this._type}, ${this._ed25519Key?.toHex().substring(0, 16)}...)`;
|
|
6686
|
+
case "Sr25519": return `SigningPublicKey(${this._type}, ${this._sr25519Key?.toHex().substring(0, 16)}...)`;
|
|
6687
|
+
case "MLDSA44":
|
|
6688
|
+
case "MLDSA65":
|
|
6689
|
+
case "MLDSA87": return `SigningPublicKey(${this._type}, ${this._mldsaKey?.toString().substring(0, 30)}...)`;
|
|
6690
|
+
case "SshEd25519":
|
|
6691
|
+
case "SshDsa":
|
|
6692
|
+
case "SshEcdsaP256":
|
|
6693
|
+
case "SshEcdsaP384": return `SigningPublicKey(${this._type}, SSH scheme not supported)`;
|
|
6737
6694
|
}
|
|
6738
6695
|
}
|
|
6739
6696
|
/**
|
|
@@ -6756,7 +6713,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6756
6713
|
verify(signature, message) {
|
|
6757
6714
|
if (signature.scheme() !== this._type) return false;
|
|
6758
6715
|
switch (this._type) {
|
|
6759
|
-
case
|
|
6716
|
+
case "Schnorr": {
|
|
6760
6717
|
if (this._schnorrKey === void 0) return false;
|
|
6761
6718
|
const sigData = signature.toSchnorr();
|
|
6762
6719
|
if (sigData === null) return false;
|
|
@@ -6766,7 +6723,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6766
6723
|
return false;
|
|
6767
6724
|
}
|
|
6768
6725
|
}
|
|
6769
|
-
case
|
|
6726
|
+
case "Ecdsa": {
|
|
6770
6727
|
if (this._ecdsaKey === void 0) return false;
|
|
6771
6728
|
const sigData = signature.toEcdsa();
|
|
6772
6729
|
if (sigData === null) return false;
|
|
@@ -6776,7 +6733,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6776
6733
|
return false;
|
|
6777
6734
|
}
|
|
6778
6735
|
}
|
|
6779
|
-
case
|
|
6736
|
+
case "Ed25519": {
|
|
6780
6737
|
if (this._ed25519Key === void 0) return false;
|
|
6781
6738
|
const sigData = signature.toEd25519();
|
|
6782
6739
|
if (sigData === null) return false;
|
|
@@ -6786,7 +6743,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6786
6743
|
return false;
|
|
6787
6744
|
}
|
|
6788
6745
|
}
|
|
6789
|
-
case
|
|
6746
|
+
case "Sr25519": {
|
|
6790
6747
|
if (this._sr25519Key === void 0) return false;
|
|
6791
6748
|
const sigData = signature.toSr25519();
|
|
6792
6749
|
if (sigData === null) return false;
|
|
@@ -6796,9 +6753,9 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6796
6753
|
return false;
|
|
6797
6754
|
}
|
|
6798
6755
|
}
|
|
6799
|
-
case
|
|
6800
|
-
case
|
|
6801
|
-
case
|
|
6756
|
+
case "MLDSA44":
|
|
6757
|
+
case "MLDSA65":
|
|
6758
|
+
case "MLDSA87": {
|
|
6802
6759
|
if (this._mldsaKey === void 0) return false;
|
|
6803
6760
|
const mldsaSig = signature.toMldsa();
|
|
6804
6761
|
if (mldsaSig === null) return false;
|
|
@@ -6808,10 +6765,10 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6808
6765
|
return false;
|
|
6809
6766
|
}
|
|
6810
6767
|
}
|
|
6811
|
-
case
|
|
6812
|
-
case
|
|
6813
|
-
case
|
|
6814
|
-
case
|
|
6768
|
+
case "SshEd25519":
|
|
6769
|
+
case "SshDsa":
|
|
6770
|
+
case "SshEcdsaP256":
|
|
6771
|
+
case "SshEcdsaP384": return false;
|
|
6815
6772
|
}
|
|
6816
6773
|
}
|
|
6817
6774
|
/**
|
|
@@ -6831,27 +6788,27 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6831
6788
|
*/
|
|
6832
6789
|
untaggedCbor() {
|
|
6833
6790
|
switch (this._type) {
|
|
6834
|
-
case
|
|
6791
|
+
case "Schnorr":
|
|
6835
6792
|
if (this._schnorrKey === void 0) throw new Error("Schnorr public key is missing");
|
|
6836
6793
|
return toByteString(this._schnorrKey.toData());
|
|
6837
|
-
case
|
|
6794
|
+
case "Ecdsa":
|
|
6838
6795
|
if (this._ecdsaKey === void 0) throw new Error("ECDSA public key is missing");
|
|
6839
6796
|
return cbor([1, toByteString(this._ecdsaKey.toData())]);
|
|
6840
|
-
case
|
|
6797
|
+
case "Ed25519":
|
|
6841
6798
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 public key is missing");
|
|
6842
6799
|
return cbor([2, toByteString(this._ed25519Key.toData())]);
|
|
6843
|
-
case
|
|
6800
|
+
case "Sr25519":
|
|
6844
6801
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 public key is missing");
|
|
6845
6802
|
return cbor([3, toByteString(this._sr25519Key.toData())]);
|
|
6846
|
-
case
|
|
6847
|
-
case
|
|
6848
|
-
case
|
|
6803
|
+
case "MLDSA44":
|
|
6804
|
+
case "MLDSA65":
|
|
6805
|
+
case "MLDSA87":
|
|
6849
6806
|
if (this._mldsaKey === void 0) throw new Error("MLDSA public key is missing");
|
|
6850
6807
|
return this._mldsaKey.taggedCbor();
|
|
6851
|
-
case
|
|
6852
|
-
case
|
|
6853
|
-
case
|
|
6854
|
-
case
|
|
6808
|
+
case "SshEd25519":
|
|
6809
|
+
case "SshDsa":
|
|
6810
|
+
case "SshEcdsaP256":
|
|
6811
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported for CBOR encoding`);
|
|
6855
6812
|
}
|
|
6856
6813
|
}
|
|
6857
6814
|
/**
|
|
@@ -6912,7 +6869,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6912
6869
|
* Static method to decode from tagged CBOR.
|
|
6913
6870
|
*/
|
|
6914
6871
|
static fromTaggedCbor(cborValue) {
|
|
6915
|
-
return new SigningPublicKey(
|
|
6872
|
+
return new SigningPublicKey("Ed25519", void 0, void 0, Ed25519PublicKey.from(new Uint8Array(ED25519_PUBLIC_KEY_SIZE))).fromTaggedCbor(cborValue);
|
|
6916
6873
|
}
|
|
6917
6874
|
/**
|
|
6918
6875
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -6926,7 +6883,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6926
6883
|
*/
|
|
6927
6884
|
static fromUntaggedCborData(data) {
|
|
6928
6885
|
const cborValue = decodeCbor(data);
|
|
6929
|
-
return new SigningPublicKey(
|
|
6886
|
+
return new SigningPublicKey("Ed25519", void 0, void 0, Ed25519PublicKey.from(new Uint8Array(ED25519_PUBLIC_KEY_SIZE))).fromUntaggedCbor(cborValue);
|
|
6930
6887
|
}
|
|
6931
6888
|
/**
|
|
6932
6889
|
* Get the UR type for signing public keys.
|
|
@@ -6969,7 +6926,7 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
6969
6926
|
* Currently only supports Ed25519 keys.
|
|
6970
6927
|
*/
|
|
6971
6928
|
toSsh(comment) {
|
|
6972
|
-
if (this._type !==
|
|
6929
|
+
if (this._type !== "Ed25519") throw new Error(`SSH export only supports Ed25519 keys, got ${this._type}`);
|
|
6973
6930
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 key not initialized");
|
|
6974
6931
|
const algorithm = "ssh-ed25519";
|
|
6975
6932
|
const algorithmBytes = new TextEncoder().encode(algorithm);
|
|
@@ -7005,7 +6962,6 @@ var SigningPublicKey = class SigningPublicKey {
|
|
|
7005
6962
|
return comment !== void 0 && comment !== "" ? `${result} ${comment}` : result;
|
|
7006
6963
|
}
|
|
7007
6964
|
};
|
|
7008
|
-
|
|
7009
6965
|
//#endregion
|
|
7010
6966
|
//#region src/signing/signing-private-key.ts
|
|
7011
6967
|
/**
|
|
@@ -7062,7 +7018,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7062
7018
|
* @returns A new Schnorr signing private key
|
|
7063
7019
|
*/
|
|
7064
7020
|
static newSchnorr(key) {
|
|
7065
|
-
return new SigningPrivateKey(
|
|
7021
|
+
return new SigningPrivateKey("Schnorr", key, void 0, void 0, void 0);
|
|
7066
7022
|
}
|
|
7067
7023
|
/**
|
|
7068
7024
|
* Creates a new ECDSA signing private key from an ECPrivateKey.
|
|
@@ -7071,7 +7027,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7071
7027
|
* @returns A new ECDSA signing private key
|
|
7072
7028
|
*/
|
|
7073
7029
|
static newEcdsa(key) {
|
|
7074
|
-
return new SigningPrivateKey(
|
|
7030
|
+
return new SigningPrivateKey("Ecdsa", key, void 0, void 0, void 0);
|
|
7075
7031
|
}
|
|
7076
7032
|
/**
|
|
7077
7033
|
* Creates a new Ed25519 signing private key from an Ed25519PrivateKey.
|
|
@@ -7080,7 +7036,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7080
7036
|
* @returns A new Ed25519 signing private key
|
|
7081
7037
|
*/
|
|
7082
7038
|
static newEd25519(key) {
|
|
7083
|
-
return new SigningPrivateKey(
|
|
7039
|
+
return new SigningPrivateKey("Ed25519", void 0, key, void 0, void 0);
|
|
7084
7040
|
}
|
|
7085
7041
|
/**
|
|
7086
7042
|
* Creates a new SR25519 signing private key from an Sr25519PrivateKey.
|
|
@@ -7089,7 +7045,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7089
7045
|
* @returns A new SR25519 signing private key
|
|
7090
7046
|
*/
|
|
7091
7047
|
static newSr25519(key) {
|
|
7092
|
-
return new SigningPrivateKey(
|
|
7048
|
+
return new SigningPrivateKey("Sr25519", void 0, void 0, key, void 0);
|
|
7093
7049
|
}
|
|
7094
7050
|
/**
|
|
7095
7051
|
* Creates a new MLDSA signing private key from an MLDSAPrivateKey.
|
|
@@ -7100,14 +7056,14 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7100
7056
|
static newMldsa(key) {
|
|
7101
7057
|
let scheme;
|
|
7102
7058
|
switch (key.level()) {
|
|
7103
|
-
case
|
|
7104
|
-
scheme =
|
|
7059
|
+
case 2:
|
|
7060
|
+
scheme = "MLDSA44";
|
|
7105
7061
|
break;
|
|
7106
|
-
case
|
|
7107
|
-
scheme =
|
|
7062
|
+
case 3:
|
|
7063
|
+
scheme = "MLDSA65";
|
|
7108
7064
|
break;
|
|
7109
|
-
case
|
|
7110
|
-
scheme =
|
|
7065
|
+
case 5:
|
|
7066
|
+
scheme = "MLDSA87";
|
|
7111
7067
|
break;
|
|
7112
7068
|
default: throw new Error(`Unknown MLDSA level: ${key.level()}`);
|
|
7113
7069
|
}
|
|
@@ -7157,17 +7113,17 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7157
7113
|
*/
|
|
7158
7114
|
keyType() {
|
|
7159
7115
|
switch (this._type) {
|
|
7160
|
-
case
|
|
7161
|
-
case
|
|
7162
|
-
case
|
|
7163
|
-
case
|
|
7164
|
-
case
|
|
7165
|
-
case
|
|
7166
|
-
case
|
|
7167
|
-
case
|
|
7168
|
-
case
|
|
7169
|
-
case
|
|
7170
|
-
case
|
|
7116
|
+
case "Ed25519": return "Ed25519";
|
|
7117
|
+
case "Schnorr": return "Schnorr";
|
|
7118
|
+
case "Ecdsa": return "ECDSA";
|
|
7119
|
+
case "Sr25519": return "Sr25519";
|
|
7120
|
+
case "MLDSA44": return "MLDSA-44";
|
|
7121
|
+
case "MLDSA65": return "MLDSA-65";
|
|
7122
|
+
case "MLDSA87": return "MLDSA-87";
|
|
7123
|
+
case "SshEd25519": return "SSH-Ed25519";
|
|
7124
|
+
case "SshDsa": return "SSH-DSA";
|
|
7125
|
+
case "SshEcdsaP256": return "SSH-ECDSA-P256";
|
|
7126
|
+
case "SshEcdsaP384": return "SSH-ECDSA-P384";
|
|
7171
7127
|
default: return this._type;
|
|
7172
7128
|
}
|
|
7173
7129
|
}
|
|
@@ -7177,7 +7133,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7177
7133
|
* @returns The EC private key if this is a Schnorr or ECDSA key, null otherwise
|
|
7178
7134
|
*/
|
|
7179
7135
|
toEc() {
|
|
7180
|
-
if ((this._type ===
|
|
7136
|
+
if ((this._type === "Schnorr" || this._type === "Ecdsa") && this._ecKey !== void 0) return this._ecKey;
|
|
7181
7137
|
return null;
|
|
7182
7138
|
}
|
|
7183
7139
|
/**
|
|
@@ -7186,7 +7142,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7186
7142
|
* @returns The EC private key if this is a Schnorr key, null otherwise
|
|
7187
7143
|
*/
|
|
7188
7144
|
toSchnorr() {
|
|
7189
|
-
if (this._type ===
|
|
7145
|
+
if (this._type === "Schnorr" && this._ecKey !== void 0) return this._ecKey;
|
|
7190
7146
|
return null;
|
|
7191
7147
|
}
|
|
7192
7148
|
/**
|
|
@@ -7195,7 +7151,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7195
7151
|
* @returns The EC private key if this is an ECDSA key, null otherwise
|
|
7196
7152
|
*/
|
|
7197
7153
|
toEcdsa() {
|
|
7198
|
-
if (this._type ===
|
|
7154
|
+
if (this._type === "Ecdsa" && this._ecKey !== void 0) return this._ecKey;
|
|
7199
7155
|
return null;
|
|
7200
7156
|
}
|
|
7201
7157
|
/**
|
|
@@ -7204,7 +7160,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7204
7160
|
* @returns The Ed25519 private key if this is an Ed25519 key, null otherwise
|
|
7205
7161
|
*/
|
|
7206
7162
|
toEd25519() {
|
|
7207
|
-
if (this._type ===
|
|
7163
|
+
if (this._type === "Ed25519" && this._ed25519Key !== void 0) return this._ed25519Key;
|
|
7208
7164
|
return null;
|
|
7209
7165
|
}
|
|
7210
7166
|
/**
|
|
@@ -7213,7 +7169,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7213
7169
|
* @returns The Sr25519 private key if this is an Sr25519 key, null otherwise
|
|
7214
7170
|
*/
|
|
7215
7171
|
toSr25519() {
|
|
7216
|
-
if (this._type ===
|
|
7172
|
+
if (this._type === "Sr25519" && this._sr25519Key !== void 0) return this._sr25519Key;
|
|
7217
7173
|
return null;
|
|
7218
7174
|
}
|
|
7219
7175
|
/**
|
|
@@ -7229,25 +7185,25 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7229
7185
|
* Checks if this is a Schnorr signing key.
|
|
7230
7186
|
*/
|
|
7231
7187
|
isSchnorr() {
|
|
7232
|
-
return this._type ===
|
|
7188
|
+
return this._type === "Schnorr";
|
|
7233
7189
|
}
|
|
7234
7190
|
/**
|
|
7235
7191
|
* Checks if this is an ECDSA signing key.
|
|
7236
7192
|
*/
|
|
7237
7193
|
isEcdsa() {
|
|
7238
|
-
return this._type ===
|
|
7194
|
+
return this._type === "Ecdsa";
|
|
7239
7195
|
}
|
|
7240
7196
|
/**
|
|
7241
7197
|
* Checks if this is an Ed25519 signing key.
|
|
7242
7198
|
*/
|
|
7243
7199
|
isEd25519() {
|
|
7244
|
-
return this._type ===
|
|
7200
|
+
return this._type === "Ed25519";
|
|
7245
7201
|
}
|
|
7246
7202
|
/**
|
|
7247
7203
|
* Checks if this is an Sr25519 signing key.
|
|
7248
7204
|
*/
|
|
7249
7205
|
isSr25519() {
|
|
7250
|
-
return this._type ===
|
|
7206
|
+
return this._type === "Sr25519";
|
|
7251
7207
|
}
|
|
7252
7208
|
/**
|
|
7253
7209
|
* Checks if this is an MLDSA signing key.
|
|
@@ -7262,27 +7218,27 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7262
7218
|
*/
|
|
7263
7219
|
publicKey() {
|
|
7264
7220
|
switch (this._type) {
|
|
7265
|
-
case
|
|
7221
|
+
case "Schnorr":
|
|
7266
7222
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7267
7223
|
return SigningPublicKey.fromSchnorr(this._ecKey.schnorrPublicKey());
|
|
7268
|
-
case
|
|
7224
|
+
case "Ecdsa":
|
|
7269
7225
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7270
7226
|
return SigningPublicKey.fromEcdsa(this._ecKey.publicKey());
|
|
7271
|
-
case
|
|
7227
|
+
case "Ed25519":
|
|
7272
7228
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 private key is missing");
|
|
7273
7229
|
return SigningPublicKey.fromEd25519(this._ed25519Key.publicKey());
|
|
7274
|
-
case
|
|
7230
|
+
case "Sr25519":
|
|
7275
7231
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 private key is missing");
|
|
7276
7232
|
return SigningPublicKey.fromSr25519(this._sr25519Key.publicKey());
|
|
7277
|
-
case
|
|
7278
|
-
case
|
|
7279
|
-
case
|
|
7233
|
+
case "MLDSA44":
|
|
7234
|
+
case "MLDSA65":
|
|
7235
|
+
case "MLDSA87":
|
|
7280
7236
|
if (this._mldsaKey === void 0) throw new Error("MLDSA private key is missing");
|
|
7281
7237
|
return SigningPublicKey.fromMldsa(this._mldsaKey.publicKey());
|
|
7282
|
-
case
|
|
7283
|
-
case
|
|
7284
|
-
case
|
|
7285
|
-
case
|
|
7238
|
+
case "SshEd25519":
|
|
7239
|
+
case "SshDsa":
|
|
7240
|
+
case "SshEcdsaP256":
|
|
7241
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported`);
|
|
7286
7242
|
}
|
|
7287
7243
|
}
|
|
7288
7244
|
/**
|
|
@@ -7291,25 +7247,25 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7291
7247
|
equals(other) {
|
|
7292
7248
|
if (this._type !== other._type) return false;
|
|
7293
7249
|
switch (this._type) {
|
|
7294
|
-
case
|
|
7295
|
-
case
|
|
7250
|
+
case "Schnorr":
|
|
7251
|
+
case "Ecdsa":
|
|
7296
7252
|
if (this._ecKey === void 0 || other._ecKey === void 0) return false;
|
|
7297
7253
|
return this._ecKey.equals(other._ecKey);
|
|
7298
|
-
case
|
|
7254
|
+
case "Ed25519":
|
|
7299
7255
|
if (this._ed25519Key === void 0 || other._ed25519Key === void 0) return false;
|
|
7300
7256
|
return this._ed25519Key.equals(other._ed25519Key);
|
|
7301
|
-
case
|
|
7257
|
+
case "Sr25519":
|
|
7302
7258
|
if (this._sr25519Key === void 0 || other._sr25519Key === void 0) return false;
|
|
7303
7259
|
return this._sr25519Key.equals(other._sr25519Key);
|
|
7304
|
-
case
|
|
7305
|
-
case
|
|
7306
|
-
case
|
|
7260
|
+
case "MLDSA44":
|
|
7261
|
+
case "MLDSA65":
|
|
7262
|
+
case "MLDSA87":
|
|
7307
7263
|
if (this._mldsaKey === void 0 || other._mldsaKey === void 0) return false;
|
|
7308
7264
|
return this._mldsaKey.equals(other._mldsaKey);
|
|
7309
|
-
case
|
|
7310
|
-
case
|
|
7311
|
-
case
|
|
7312
|
-
case
|
|
7265
|
+
case "SshEd25519":
|
|
7266
|
+
case "SshDsa":
|
|
7267
|
+
case "SshEcdsaP256":
|
|
7268
|
+
case "SshEcdsaP384": return false;
|
|
7313
7269
|
}
|
|
7314
7270
|
}
|
|
7315
7271
|
/**
|
|
@@ -7342,41 +7298,41 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7342
7298
|
*/
|
|
7343
7299
|
signWithOptions(message, options) {
|
|
7344
7300
|
switch (this._type) {
|
|
7345
|
-
case
|
|
7301
|
+
case "Schnorr": {
|
|
7346
7302
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7347
7303
|
if (options?.type === "Schnorr") {
|
|
7348
|
-
const sigData
|
|
7349
|
-
return Signature.schnorrFromData(sigData
|
|
7304
|
+
const sigData = this._ecKey.schnorrSignUsing(message, options.rng);
|
|
7305
|
+
return Signature.schnorrFromData(sigData);
|
|
7350
7306
|
}
|
|
7351
7307
|
const sigData = this._ecKey.schnorrSign(message);
|
|
7352
7308
|
return Signature.schnorrFromData(sigData);
|
|
7353
7309
|
}
|
|
7354
|
-
case
|
|
7310
|
+
case "Ecdsa": {
|
|
7355
7311
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7356
7312
|
const sigData = this._ecKey.ecdsaSign(message);
|
|
7357
7313
|
return Signature.ecdsaFromData(sigData);
|
|
7358
7314
|
}
|
|
7359
|
-
case
|
|
7315
|
+
case "Ed25519": {
|
|
7360
7316
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 private key is missing");
|
|
7361
7317
|
const sigData = this._ed25519Key.sign(message);
|
|
7362
7318
|
return Signature.ed25519FromData(sigData);
|
|
7363
7319
|
}
|
|
7364
|
-
case
|
|
7320
|
+
case "Sr25519": {
|
|
7365
7321
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 private key is missing");
|
|
7366
7322
|
const sigData = this._sr25519Key.sign(message);
|
|
7367
7323
|
return Signature.sr25519FromData(sigData);
|
|
7368
7324
|
}
|
|
7369
|
-
case
|
|
7370
|
-
case
|
|
7371
|
-
case
|
|
7325
|
+
case "MLDSA44":
|
|
7326
|
+
case "MLDSA65":
|
|
7327
|
+
case "MLDSA87": {
|
|
7372
7328
|
if (this._mldsaKey === void 0) throw new Error("MLDSA private key is missing");
|
|
7373
7329
|
const mldsaSig = this._mldsaKey.sign(message);
|
|
7374
7330
|
return Signature.mldsaFromSignature(mldsaSig);
|
|
7375
7331
|
}
|
|
7376
|
-
case
|
|
7377
|
-
case
|
|
7378
|
-
case
|
|
7379
|
-
case
|
|
7332
|
+
case "SshEd25519":
|
|
7333
|
+
case "SshDsa":
|
|
7334
|
+
case "SshEcdsaP256":
|
|
7335
|
+
case "SshEcdsaP384":
|
|
7380
7336
|
if (options?.type === "Ssh") throw new Error(`SSH signature scheme ${this._type} is not yet implemented. Namespace: ${options.namespace}, hashAlg: ${options.hashAlg}`);
|
|
7381
7337
|
throw new Error(`SSH signature scheme ${this._type} requires SigningOptions.Ssh`);
|
|
7382
7338
|
}
|
|
@@ -7496,27 +7452,27 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7496
7452
|
*/
|
|
7497
7453
|
untaggedCbor() {
|
|
7498
7454
|
switch (this._type) {
|
|
7499
|
-
case
|
|
7455
|
+
case "Schnorr":
|
|
7500
7456
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7501
7457
|
return toByteString(this._ecKey.toData());
|
|
7502
|
-
case
|
|
7458
|
+
case "Ecdsa":
|
|
7503
7459
|
if (this._ecKey === void 0) throw new Error("EC private key is missing");
|
|
7504
7460
|
return cbor([1, toByteString(this._ecKey.toData())]);
|
|
7505
|
-
case
|
|
7461
|
+
case "Ed25519":
|
|
7506
7462
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 private key is missing");
|
|
7507
7463
|
return cbor([2, toByteString(this._ed25519Key.toData())]);
|
|
7508
|
-
case
|
|
7464
|
+
case "Sr25519":
|
|
7509
7465
|
if (this._sr25519Key === void 0) throw new Error("Sr25519 private key is missing");
|
|
7510
7466
|
return cbor([3, toByteString(this._sr25519Key.toData())]);
|
|
7511
|
-
case
|
|
7512
|
-
case
|
|
7513
|
-
case
|
|
7467
|
+
case "MLDSA44":
|
|
7468
|
+
case "MLDSA65":
|
|
7469
|
+
case "MLDSA87":
|
|
7514
7470
|
if (this._mldsaKey === void 0) throw new Error("MLDSA private key is missing");
|
|
7515
7471
|
return this._mldsaKey.taggedCbor();
|
|
7516
|
-
case
|
|
7517
|
-
case
|
|
7518
|
-
case
|
|
7519
|
-
case
|
|
7472
|
+
case "SshEd25519":
|
|
7473
|
+
case "SshDsa":
|
|
7474
|
+
case "SshEcdsaP256":
|
|
7475
|
+
case "SshEcdsaP384": throw new Error(`SSH signature scheme ${this._type} is not supported for CBOR encoding`);
|
|
7520
7476
|
}
|
|
7521
7477
|
}
|
|
7522
7478
|
/**
|
|
@@ -7578,7 +7534,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7578
7534
|
* Static method to decode from tagged CBOR.
|
|
7579
7535
|
*/
|
|
7580
7536
|
static fromTaggedCbor(cborValue) {
|
|
7581
|
-
return new SigningPrivateKey(
|
|
7537
|
+
return new SigningPrivateKey("Ed25519", void 0, Ed25519PrivateKey.from(new Uint8Array(ED25519_PRIVATE_KEY_SIZE))).fromTaggedCbor(cborValue);
|
|
7582
7538
|
}
|
|
7583
7539
|
/**
|
|
7584
7540
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -7592,7 +7548,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7592
7548
|
*/
|
|
7593
7549
|
static fromUntaggedCborData(data) {
|
|
7594
7550
|
const cborValue = decodeCbor(data);
|
|
7595
|
-
return new SigningPrivateKey(
|
|
7551
|
+
return new SigningPrivateKey("Ed25519", void 0, Ed25519PrivateKey.from(new Uint8Array(ED25519_PRIVATE_KEY_SIZE))).fromUntaggedCbor(cborValue);
|
|
7596
7552
|
}
|
|
7597
7553
|
/**
|
|
7598
7554
|
* Get the UR type for signing private keys.
|
|
@@ -7635,7 +7591,7 @@ var SigningPrivateKey = class SigningPrivateKey {
|
|
|
7635
7591
|
* Currently only supports Ed25519 keys.
|
|
7636
7592
|
*/
|
|
7637
7593
|
toSsh(comment) {
|
|
7638
|
-
if (this._type !==
|
|
7594
|
+
if (this._type !== "Ed25519") throw new Error(`SSH export only supports Ed25519 keys, got ${this._type}`);
|
|
7639
7595
|
if (this._ed25519Key === void 0) throw new Error("Ed25519 key not initialized");
|
|
7640
7596
|
const publicKey = this._ed25519Key.publicKey();
|
|
7641
7597
|
const privateKeyBytes = this._ed25519Key.toData();
|
|
@@ -7656,7 +7612,6 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
7656
7612
|
-----END OPENSSH PRIVATE KEY-----`;
|
|
7657
7613
|
}
|
|
7658
7614
|
};
|
|
7659
|
-
|
|
7660
7615
|
//#endregion
|
|
7661
7616
|
//#region src/signing/signature-scheme.ts
|
|
7662
7617
|
/**
|
|
@@ -7675,65 +7630,65 @@ This requires bcrypt_pbkdf implementation for proper encryption.
|
|
|
7675
7630
|
* - SshEcdsaP256: ECDSA P-256 via SSH agent
|
|
7676
7631
|
* - SshEcdsaP384: ECDSA P-384 via SSH agent
|
|
7677
7632
|
*/
|
|
7678
|
-
let SignatureScheme = /* @__PURE__ */ function(SignatureScheme
|
|
7633
|
+
let SignatureScheme = /* @__PURE__ */ function(SignatureScheme) {
|
|
7679
7634
|
/**
|
|
7680
7635
|
* BIP-340 Schnorr signature scheme (secp256k1)
|
|
7681
7636
|
* Default scheme (matching Rust bc-components default when secp256k1 is enabled)
|
|
7682
7637
|
*/
|
|
7683
|
-
SignatureScheme
|
|
7638
|
+
SignatureScheme["Schnorr"] = "Schnorr";
|
|
7684
7639
|
/**
|
|
7685
7640
|
* ECDSA signature scheme (secp256k1)
|
|
7686
7641
|
*/
|
|
7687
|
-
SignatureScheme
|
|
7642
|
+
SignatureScheme["Ecdsa"] = "Ecdsa";
|
|
7688
7643
|
/**
|
|
7689
7644
|
* Ed25519 signature scheme (RFC 8032)
|
|
7690
7645
|
*/
|
|
7691
|
-
SignatureScheme
|
|
7646
|
+
SignatureScheme["Ed25519"] = "Ed25519";
|
|
7692
7647
|
/**
|
|
7693
7648
|
* SR25519 signature scheme (Schnorr over Ristretto25519)
|
|
7694
7649
|
* Used by Polkadot/Substrate
|
|
7695
7650
|
*/
|
|
7696
|
-
SignatureScheme
|
|
7651
|
+
SignatureScheme["Sr25519"] = "Sr25519";
|
|
7697
7652
|
/**
|
|
7698
7653
|
* ML-DSA44 post-quantum signature scheme (NIST level 2)
|
|
7699
7654
|
*/
|
|
7700
|
-
SignatureScheme
|
|
7655
|
+
SignatureScheme["MLDSA44"] = "MLDSA44";
|
|
7701
7656
|
/**
|
|
7702
7657
|
* ML-DSA65 post-quantum signature scheme (NIST level 3)
|
|
7703
7658
|
*/
|
|
7704
|
-
SignatureScheme
|
|
7659
|
+
SignatureScheme["MLDSA65"] = "MLDSA65";
|
|
7705
7660
|
/**
|
|
7706
7661
|
* ML-DSA87 post-quantum signature scheme (NIST level 5)
|
|
7707
7662
|
*/
|
|
7708
|
-
SignatureScheme
|
|
7663
|
+
SignatureScheme["MLDSA87"] = "MLDSA87";
|
|
7709
7664
|
/**
|
|
7710
7665
|
* Ed25519 signature via SSH agent.
|
|
7711
7666
|
* Requires SSH agent daemon support.
|
|
7712
7667
|
*/
|
|
7713
|
-
SignatureScheme
|
|
7668
|
+
SignatureScheme["SshEd25519"] = "SshEd25519";
|
|
7714
7669
|
/**
|
|
7715
7670
|
* DSA signature via SSH agent.
|
|
7716
7671
|
* Requires SSH agent daemon support.
|
|
7717
7672
|
*/
|
|
7718
|
-
SignatureScheme
|
|
7673
|
+
SignatureScheme["SshDsa"] = "SshDsa";
|
|
7719
7674
|
/**
|
|
7720
7675
|
* ECDSA P-256 signature via SSH agent.
|
|
7721
7676
|
* Requires SSH agent daemon support.
|
|
7722
7677
|
*/
|
|
7723
|
-
SignatureScheme
|
|
7678
|
+
SignatureScheme["SshEcdsaP256"] = "SshEcdsaP256";
|
|
7724
7679
|
/**
|
|
7725
7680
|
* ECDSA P-384 signature via SSH agent.
|
|
7726
7681
|
* Requires SSH agent daemon support.
|
|
7727
7682
|
*/
|
|
7728
|
-
SignatureScheme
|
|
7729
|
-
return SignatureScheme
|
|
7683
|
+
SignatureScheme["SshEcdsaP384"] = "SshEcdsaP384";
|
|
7684
|
+
return SignatureScheme;
|
|
7730
7685
|
}({});
|
|
7731
7686
|
/**
|
|
7732
7687
|
* Get the default signature scheme.
|
|
7733
7688
|
* Defaults to Schnorr (matching Rust bc-components default when secp256k1 is enabled).
|
|
7734
7689
|
*/
|
|
7735
7690
|
function defaultSignatureScheme() {
|
|
7736
|
-
return
|
|
7691
|
+
return "Schnorr";
|
|
7737
7692
|
}
|
|
7738
7693
|
/**
|
|
7739
7694
|
* Check if a signature scheme requires SSH agent support.
|
|
@@ -7742,7 +7697,7 @@ function defaultSignatureScheme() {
|
|
|
7742
7697
|
* @returns true if the scheme requires SSH agent
|
|
7743
7698
|
*/
|
|
7744
7699
|
function isSshScheme(scheme) {
|
|
7745
|
-
return scheme ===
|
|
7700
|
+
return scheme === "SshEd25519" || scheme === "SshDsa" || scheme === "SshEcdsaP256" || scheme === "SshEcdsaP384";
|
|
7746
7701
|
}
|
|
7747
7702
|
/**
|
|
7748
7703
|
* Check if a signature scheme is a post-quantum ML-DSA scheme.
|
|
@@ -7751,7 +7706,7 @@ function isSshScheme(scheme) {
|
|
|
7751
7706
|
* @returns true if the scheme is an ML-DSA scheme
|
|
7752
7707
|
*/
|
|
7753
7708
|
function isMldsaScheme(scheme) {
|
|
7754
|
-
return scheme ===
|
|
7709
|
+
return scheme === "MLDSA44" || scheme === "MLDSA65" || scheme === "MLDSA87";
|
|
7755
7710
|
}
|
|
7756
7711
|
/**
|
|
7757
7712
|
* Creates a new key pair for the signature scheme.
|
|
@@ -7762,45 +7717,45 @@ function isMldsaScheme(scheme) {
|
|
|
7762
7717
|
*/
|
|
7763
7718
|
function createKeypair(scheme) {
|
|
7764
7719
|
switch (scheme) {
|
|
7765
|
-
case
|
|
7720
|
+
case "Schnorr": {
|
|
7766
7721
|
const ecKey = ECPrivateKey.random();
|
|
7767
7722
|
const privateKey = SigningPrivateKey.newSchnorr(ecKey);
|
|
7768
7723
|
return [privateKey, privateKey.publicKey()];
|
|
7769
7724
|
}
|
|
7770
|
-
case
|
|
7725
|
+
case "Ecdsa": {
|
|
7771
7726
|
const ecKey = ECPrivateKey.random();
|
|
7772
7727
|
const privateKey = SigningPrivateKey.newEcdsa(ecKey);
|
|
7773
7728
|
return [privateKey, privateKey.publicKey()];
|
|
7774
7729
|
}
|
|
7775
|
-
case
|
|
7730
|
+
case "Ed25519": {
|
|
7776
7731
|
const ed25519Key = Ed25519PrivateKey.random();
|
|
7777
7732
|
const privateKey = SigningPrivateKey.newEd25519(ed25519Key);
|
|
7778
7733
|
return [privateKey, privateKey.publicKey()];
|
|
7779
7734
|
}
|
|
7780
|
-
case
|
|
7735
|
+
case "Sr25519": {
|
|
7781
7736
|
const sr25519Key = Sr25519PrivateKey.random();
|
|
7782
7737
|
const privateKey = SigningPrivateKey.newSr25519(sr25519Key);
|
|
7783
7738
|
return [privateKey, privateKey.publicKey()];
|
|
7784
7739
|
}
|
|
7785
|
-
case
|
|
7786
|
-
const mldsaKey = MLDSAPrivateKey.new(
|
|
7740
|
+
case "MLDSA44": {
|
|
7741
|
+
const mldsaKey = MLDSAPrivateKey.new(2);
|
|
7787
7742
|
const privateKey = SigningPrivateKey.newMldsa(mldsaKey);
|
|
7788
7743
|
return [privateKey, privateKey.publicKey()];
|
|
7789
7744
|
}
|
|
7790
|
-
case
|
|
7791
|
-
const mldsaKey = MLDSAPrivateKey.new(
|
|
7745
|
+
case "MLDSA65": {
|
|
7746
|
+
const mldsaKey = MLDSAPrivateKey.new(3);
|
|
7792
7747
|
const privateKey = SigningPrivateKey.newMldsa(mldsaKey);
|
|
7793
7748
|
return [privateKey, privateKey.publicKey()];
|
|
7794
7749
|
}
|
|
7795
|
-
case
|
|
7796
|
-
const mldsaKey = MLDSAPrivateKey.new(
|
|
7750
|
+
case "MLDSA87": {
|
|
7751
|
+
const mldsaKey = MLDSAPrivateKey.new(5);
|
|
7797
7752
|
const privateKey = SigningPrivateKey.newMldsa(mldsaKey);
|
|
7798
7753
|
return [privateKey, privateKey.publicKey()];
|
|
7799
7754
|
}
|
|
7800
|
-
case
|
|
7801
|
-
case
|
|
7802
|
-
case
|
|
7803
|
-
case
|
|
7755
|
+
case "SshEd25519":
|
|
7756
|
+
case "SshDsa":
|
|
7757
|
+
case "SshEcdsaP256":
|
|
7758
|
+
case "SshEcdsaP384": throw CryptoError.sshAgent(`SSH signature scheme ${scheme} requires SSH agent support which is not yet implemented. Use Ed25519, Sr25519, Schnorr, ECDSA, or MLDSA variants instead.`);
|
|
7804
7759
|
}
|
|
7805
7760
|
}
|
|
7806
7761
|
/**
|
|
@@ -7813,36 +7768,35 @@ function createKeypair(scheme) {
|
|
|
7813
7768
|
*/
|
|
7814
7769
|
function createKeypairUsing(scheme, rng) {
|
|
7815
7770
|
switch (scheme) {
|
|
7816
|
-
case
|
|
7771
|
+
case "Schnorr": {
|
|
7817
7772
|
const ecKey = ECPrivateKey.newUsing(rng);
|
|
7818
7773
|
const privateKey = SigningPrivateKey.newSchnorr(ecKey);
|
|
7819
7774
|
return [privateKey, privateKey.publicKey()];
|
|
7820
7775
|
}
|
|
7821
|
-
case
|
|
7776
|
+
case "Ecdsa": {
|
|
7822
7777
|
const ecKey = ECPrivateKey.newUsing(rng);
|
|
7823
7778
|
const privateKey = SigningPrivateKey.newEcdsa(ecKey);
|
|
7824
7779
|
return [privateKey, privateKey.publicKey()];
|
|
7825
7780
|
}
|
|
7826
|
-
case
|
|
7781
|
+
case "Ed25519": {
|
|
7827
7782
|
const ed25519Key = Ed25519PrivateKey.randomUsing(rng);
|
|
7828
7783
|
const privateKey = SigningPrivateKey.newEd25519(ed25519Key);
|
|
7829
7784
|
return [privateKey, privateKey.publicKey()];
|
|
7830
7785
|
}
|
|
7831
|
-
case
|
|
7786
|
+
case "Sr25519": {
|
|
7832
7787
|
const sr25519Key = Sr25519PrivateKey.randomUsing(rng);
|
|
7833
7788
|
const privateKey = SigningPrivateKey.newSr25519(sr25519Key);
|
|
7834
7789
|
return [privateKey, privateKey.publicKey()];
|
|
7835
7790
|
}
|
|
7836
|
-
case
|
|
7837
|
-
case
|
|
7838
|
-
case
|
|
7839
|
-
case
|
|
7840
|
-
case
|
|
7841
|
-
case
|
|
7842
|
-
case
|
|
7791
|
+
case "MLDSA44":
|
|
7792
|
+
case "MLDSA65":
|
|
7793
|
+
case "MLDSA87": throw CryptoError.general(`Deterministic keypair generation not supported for ${scheme}. Use createKeypair() instead.`);
|
|
7794
|
+
case "SshEd25519":
|
|
7795
|
+
case "SshDsa":
|
|
7796
|
+
case "SshEcdsaP256":
|
|
7797
|
+
case "SshEcdsaP384": throw CryptoError.sshAgent(`SSH signature scheme ${scheme} requires SSH agent support which is not yet implemented. Use Ed25519, Sr25519, Schnorr, ECDSA, or MLDSA variants instead.`);
|
|
7843
7798
|
}
|
|
7844
7799
|
}
|
|
7845
|
-
|
|
7846
7800
|
//#endregion
|
|
7847
7801
|
//#region src/mlkem/mlkem-level.ts
|
|
7848
7802
|
/**
|
|
@@ -7870,32 +7824,32 @@ function createKeypairUsing(scheme, rng) {
|
|
|
7870
7824
|
* - 768: ML-KEM-768 (NIST Level 3)
|
|
7871
7825
|
* - 1024: ML-KEM-1024 (NIST Level 5)
|
|
7872
7826
|
*/
|
|
7873
|
-
let MLKEMLevel = /* @__PURE__ */ function(MLKEMLevel
|
|
7827
|
+
let MLKEMLevel = /* @__PURE__ */ function(MLKEMLevel) {
|
|
7874
7828
|
/** NIST Level 1 - AES-128 equivalent security */
|
|
7875
|
-
MLKEMLevel
|
|
7829
|
+
MLKEMLevel[MLKEMLevel["MLKEM512"] = 512] = "MLKEM512";
|
|
7876
7830
|
/** NIST Level 3 - AES-192 equivalent security */
|
|
7877
|
-
MLKEMLevel
|
|
7831
|
+
MLKEMLevel[MLKEMLevel["MLKEM768"] = 768] = "MLKEM768";
|
|
7878
7832
|
/** NIST Level 5 - AES-256 equivalent security */
|
|
7879
|
-
MLKEMLevel
|
|
7880
|
-
return MLKEMLevel
|
|
7833
|
+
MLKEMLevel[MLKEMLevel["MLKEM1024"] = 1024] = "MLKEM1024";
|
|
7834
|
+
return MLKEMLevel;
|
|
7881
7835
|
}({});
|
|
7882
7836
|
/**
|
|
7883
7837
|
* Key sizes for each ML-KEM security level.
|
|
7884
7838
|
*/
|
|
7885
7839
|
const MLKEM_KEY_SIZES = {
|
|
7886
|
-
[
|
|
7840
|
+
[512]: {
|
|
7887
7841
|
privateKey: 1632,
|
|
7888
7842
|
publicKey: 800,
|
|
7889
7843
|
ciphertext: 768,
|
|
7890
7844
|
sharedSecret: 32
|
|
7891
7845
|
},
|
|
7892
|
-
[
|
|
7846
|
+
[768]: {
|
|
7893
7847
|
privateKey: 2400,
|
|
7894
7848
|
publicKey: 1184,
|
|
7895
7849
|
ciphertext: 1088,
|
|
7896
7850
|
sharedSecret: 32
|
|
7897
7851
|
},
|
|
7898
|
-
[
|
|
7852
|
+
[1024]: {
|
|
7899
7853
|
privateKey: 3168,
|
|
7900
7854
|
publicKey: 1568,
|
|
7901
7855
|
ciphertext: 1568,
|
|
@@ -7932,9 +7886,9 @@ function mlkemSharedSecretSize(level) {
|
|
|
7932
7886
|
*/
|
|
7933
7887
|
function mlkemLevelToString(level) {
|
|
7934
7888
|
switch (level) {
|
|
7935
|
-
case
|
|
7936
|
-
case
|
|
7937
|
-
case
|
|
7889
|
+
case 512: return "MLKEM512";
|
|
7890
|
+
case 768: return "MLKEM768";
|
|
7891
|
+
case 1024: return "MLKEM1024";
|
|
7938
7892
|
}
|
|
7939
7893
|
}
|
|
7940
7894
|
/**
|
|
@@ -7942,9 +7896,9 @@ function mlkemLevelToString(level) {
|
|
|
7942
7896
|
*/
|
|
7943
7897
|
function mlkemLevelFromValue(value) {
|
|
7944
7898
|
switch (value) {
|
|
7945
|
-
case 512: return
|
|
7946
|
-
case 768: return
|
|
7947
|
-
case 1024: return
|
|
7899
|
+
case 512: return 512;
|
|
7900
|
+
case 768: return 768;
|
|
7901
|
+
case 1024: return 1024;
|
|
7948
7902
|
default: throw new Error(`Invalid MLKEM level value: ${value}`);
|
|
7949
7903
|
}
|
|
7950
7904
|
}
|
|
@@ -7967,21 +7921,21 @@ function mlkemGenerateKeypair(level) {
|
|
|
7967
7921
|
function mlkemGenerateKeypairUsing(level, rng) {
|
|
7968
7922
|
const seed = rng.randomData(64);
|
|
7969
7923
|
switch (level) {
|
|
7970
|
-
case
|
|
7924
|
+
case 512: {
|
|
7971
7925
|
const keypair = ml_kem512.keygen(seed);
|
|
7972
7926
|
return {
|
|
7973
7927
|
publicKey: keypair.publicKey,
|
|
7974
7928
|
secretKey: keypair.secretKey
|
|
7975
7929
|
};
|
|
7976
7930
|
}
|
|
7977
|
-
case
|
|
7931
|
+
case 768: {
|
|
7978
7932
|
const keypair = ml_kem768.keygen(seed);
|
|
7979
7933
|
return {
|
|
7980
7934
|
publicKey: keypair.publicKey,
|
|
7981
7935
|
secretKey: keypair.secretKey
|
|
7982
7936
|
};
|
|
7983
7937
|
}
|
|
7984
|
-
case
|
|
7938
|
+
case 1024: {
|
|
7985
7939
|
const keypair = ml_kem1024.keygen(seed);
|
|
7986
7940
|
return {
|
|
7987
7941
|
publicKey: keypair.publicKey,
|
|
@@ -7999,21 +7953,21 @@ function mlkemGenerateKeypairUsing(level, rng) {
|
|
|
7999
7953
|
*/
|
|
8000
7954
|
function mlkemEncapsulate(level, publicKey) {
|
|
8001
7955
|
switch (level) {
|
|
8002
|
-
case
|
|
7956
|
+
case 512: {
|
|
8003
7957
|
const result = ml_kem512.encapsulate(publicKey);
|
|
8004
7958
|
return {
|
|
8005
7959
|
sharedSecret: result.sharedSecret,
|
|
8006
7960
|
ciphertext: result.cipherText
|
|
8007
7961
|
};
|
|
8008
7962
|
}
|
|
8009
|
-
case
|
|
7963
|
+
case 768: {
|
|
8010
7964
|
const result = ml_kem768.encapsulate(publicKey);
|
|
8011
7965
|
return {
|
|
8012
7966
|
sharedSecret: result.sharedSecret,
|
|
8013
7967
|
ciphertext: result.cipherText
|
|
8014
7968
|
};
|
|
8015
7969
|
}
|
|
8016
|
-
case
|
|
7970
|
+
case 1024: {
|
|
8017
7971
|
const result = ml_kem1024.encapsulate(publicKey);
|
|
8018
7972
|
return {
|
|
8019
7973
|
sharedSecret: result.sharedSecret,
|
|
@@ -8032,9 +7986,9 @@ function mlkemEncapsulate(level, publicKey) {
|
|
|
8032
7986
|
*/
|
|
8033
7987
|
function mlkemDecapsulate(level, secretKey, ciphertext) {
|
|
8034
7988
|
switch (level) {
|
|
8035
|
-
case
|
|
8036
|
-
case
|
|
8037
|
-
case
|
|
7989
|
+
case 512: return ml_kem512.decapsulate(ciphertext, secretKey);
|
|
7990
|
+
case 768: return ml_kem768.decapsulate(ciphertext, secretKey);
|
|
7991
|
+
case 1024: return ml_kem1024.decapsulate(ciphertext, secretKey);
|
|
8038
7992
|
}
|
|
8039
7993
|
}
|
|
8040
7994
|
/**
|
|
@@ -8043,9 +7997,9 @@ function mlkemDecapsulate(level, secretKey, ciphertext) {
|
|
|
8043
7997
|
* where dk_pke is the private portion before the public key.
|
|
8044
7998
|
*/
|
|
8045
7999
|
const MLKEM_DK_PKE_SIZES = {
|
|
8046
|
-
[
|
|
8047
|
-
[
|
|
8048
|
-
[
|
|
8000
|
+
[512]: 768,
|
|
8001
|
+
[768]: 1152,
|
|
8002
|
+
[1024]: 1536
|
|
8049
8003
|
};
|
|
8050
8004
|
/**
|
|
8051
8005
|
* Extract the public key from a secret key.
|
|
@@ -8063,7 +8017,6 @@ function mlkemExtractPublicKey(level, secretKey) {
|
|
|
8063
8017
|
const offset = dkPkeSize;
|
|
8064
8018
|
return secretKey.slice(offset, offset + publicKeySize);
|
|
8065
8019
|
}
|
|
8066
|
-
|
|
8067
8020
|
//#endregion
|
|
8068
8021
|
//#region src/mlkem/mlkem-ciphertext.ts
|
|
8069
8022
|
/**
|
|
@@ -8198,8 +8151,7 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8198
8151
|
* Static method to decode from tagged CBOR.
|
|
8199
8152
|
*/
|
|
8200
8153
|
static fromTaggedCbor(cborValue) {
|
|
8201
|
-
|
|
8202
|
-
return new MLKEMCiphertext(MLKEMLevel.MLKEM512, dummyData).fromTaggedCbor(cborValue);
|
|
8154
|
+
return new MLKEMCiphertext(512, new Uint8Array(mlkemCiphertextSize(512))).fromTaggedCbor(cborValue);
|
|
8203
8155
|
}
|
|
8204
8156
|
/**
|
|
8205
8157
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -8213,8 +8165,7 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8213
8165
|
*/
|
|
8214
8166
|
static fromUntaggedCborData(data) {
|
|
8215
8167
|
const cborValue = decodeCbor(data);
|
|
8216
|
-
|
|
8217
|
-
return new MLKEMCiphertext(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(cborValue);
|
|
8168
|
+
return new MLKEMCiphertext(512, new Uint8Array(mlkemCiphertextSize(512))).fromUntaggedCbor(cborValue);
|
|
8218
8169
|
}
|
|
8219
8170
|
/**
|
|
8220
8171
|
* Returns the UR representation.
|
|
@@ -8235,8 +8186,7 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8235
8186
|
*/
|
|
8236
8187
|
static fromUR(ur) {
|
|
8237
8188
|
if (ur.urTypeStr() !== MLKEM_CIPHERTEXT.name) throw new Error(`Expected UR type ${MLKEM_CIPHERTEXT.name}, got ${ur.urTypeStr()}`);
|
|
8238
|
-
|
|
8239
|
-
return new MLKEMCiphertext(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(ur.cbor());
|
|
8189
|
+
return new MLKEMCiphertext(512, new Uint8Array(mlkemCiphertextSize(512))).fromUntaggedCbor(ur.cbor());
|
|
8240
8190
|
}
|
|
8241
8191
|
/**
|
|
8242
8192
|
* Creates an MLKEMCiphertext from a UR string.
|
|
@@ -8246,7 +8196,6 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8246
8196
|
return MLKEMCiphertext.fromUR(ur);
|
|
8247
8197
|
}
|
|
8248
8198
|
};
|
|
8249
|
-
|
|
8250
8199
|
//#endregion
|
|
8251
8200
|
//#region src/encapsulation/encapsulation-ciphertext.ts
|
|
8252
8201
|
/**
|
|
@@ -8272,16 +8221,16 @@ var MLKEMCiphertext = class MLKEMCiphertext {
|
|
|
8272
8221
|
*/
|
|
8273
8222
|
function mlkemLevelToScheme$2(level) {
|
|
8274
8223
|
switch (level) {
|
|
8275
|
-
case
|
|
8276
|
-
case
|
|
8277
|
-
case
|
|
8224
|
+
case 512: return "mlkem512";
|
|
8225
|
+
case 768: return "mlkem768";
|
|
8226
|
+
case 1024: return "mlkem1024";
|
|
8278
8227
|
}
|
|
8279
8228
|
}
|
|
8280
8229
|
/**
|
|
8281
8230
|
* Check if a scheme is an MLKEM scheme
|
|
8282
8231
|
*/
|
|
8283
8232
|
function isMlkemScheme$2(scheme) {
|
|
8284
|
-
return scheme ===
|
|
8233
|
+
return scheme === "mlkem512" || scheme === "mlkem768" || scheme === "mlkem1024";
|
|
8285
8234
|
}
|
|
8286
8235
|
/**
|
|
8287
8236
|
* Represents the ciphertext from a key encapsulation operation.
|
|
@@ -8302,7 +8251,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8302
8251
|
* Create an EncapsulationCiphertext from an X25519PublicKey.
|
|
8303
8252
|
*/
|
|
8304
8253
|
static fromX25519PublicKey(publicKey) {
|
|
8305
|
-
return new EncapsulationCiphertext(
|
|
8254
|
+
return new EncapsulationCiphertext("x25519", publicKey, void 0);
|
|
8306
8255
|
}
|
|
8307
8256
|
/**
|
|
8308
8257
|
* Create an EncapsulationCiphertext from raw X25519 data.
|
|
@@ -8334,7 +8283,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8334
8283
|
* Returns true if this is an X25519 ciphertext.
|
|
8335
8284
|
*/
|
|
8336
8285
|
isX25519() {
|
|
8337
|
-
return this._scheme ===
|
|
8286
|
+
return this._scheme === "x25519";
|
|
8338
8287
|
}
|
|
8339
8288
|
/**
|
|
8340
8289
|
* Returns true if this is an MLKEM ciphertext.
|
|
@@ -8374,7 +8323,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8374
8323
|
* Returns the raw ciphertext data.
|
|
8375
8324
|
*/
|
|
8376
8325
|
data() {
|
|
8377
|
-
if (this._scheme ===
|
|
8326
|
+
if (this._scheme === "x25519") {
|
|
8378
8327
|
const pk = this._x25519PublicKey;
|
|
8379
8328
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8380
8329
|
return pk.data();
|
|
@@ -8390,7 +8339,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8390
8339
|
*/
|
|
8391
8340
|
equals(other) {
|
|
8392
8341
|
if (this._scheme !== other._scheme) return false;
|
|
8393
|
-
if (this._scheme ===
|
|
8342
|
+
if (this._scheme === "x25519") {
|
|
8394
8343
|
const thisPk = this._x25519PublicKey;
|
|
8395
8344
|
const otherPk = other._x25519PublicKey;
|
|
8396
8345
|
if (thisPk === void 0 || otherPk === void 0) return false;
|
|
@@ -8407,7 +8356,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8407
8356
|
* Get string representation.
|
|
8408
8357
|
*/
|
|
8409
8358
|
toString() {
|
|
8410
|
-
if (this._scheme ===
|
|
8359
|
+
if (this._scheme === "x25519") return `EncapsulationCiphertext(X25519, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
8411
8360
|
else if (isMlkemScheme$2(this._scheme)) return `EncapsulationCiphertext(${String(this._scheme)}, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
8412
8361
|
return `EncapsulationCiphertext(${String(this._scheme)})`;
|
|
8413
8362
|
}
|
|
@@ -8415,7 +8364,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8415
8364
|
* Returns the CBOR tags associated with this ciphertext.
|
|
8416
8365
|
*/
|
|
8417
8366
|
cborTags() {
|
|
8418
|
-
if (this._scheme ===
|
|
8367
|
+
if (this._scheme === "x25519") return tagsForValues([X25519_PUBLIC_KEY.value]);
|
|
8419
8368
|
else if (isMlkemScheme$2(this._scheme)) return tagsForValues([MLKEM_CIPHERTEXT.value]);
|
|
8420
8369
|
throw new Error(`Unsupported scheme: ${String(this._scheme)}`);
|
|
8421
8370
|
}
|
|
@@ -8423,7 +8372,7 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8423
8372
|
* Returns the untagged CBOR encoding.
|
|
8424
8373
|
*/
|
|
8425
8374
|
untaggedCbor() {
|
|
8426
|
-
if (this._scheme ===
|
|
8375
|
+
if (this._scheme === "x25519") {
|
|
8427
8376
|
const pk = this._x25519PublicKey;
|
|
8428
8377
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8429
8378
|
return toByteString(pk.data());
|
|
@@ -8492,7 +8441,6 @@ var EncapsulationCiphertext = class EncapsulationCiphertext {
|
|
|
8492
8441
|
return EncapsulationCiphertext.fromX25519PublicKey(X25519PublicKey.fromData(new Uint8Array(32))).fromUntaggedCbor(cborValue);
|
|
8493
8442
|
}
|
|
8494
8443
|
};
|
|
8495
|
-
|
|
8496
8444
|
//#endregion
|
|
8497
8445
|
//#region src/mlkem/mlkem-public-key.ts
|
|
8498
8446
|
/**
|
|
@@ -8643,8 +8591,7 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8643
8591
|
* Static method to decode from tagged CBOR.
|
|
8644
8592
|
*/
|
|
8645
8593
|
static fromTaggedCbor(cborValue) {
|
|
8646
|
-
|
|
8647
|
-
return new MLKEMPublicKey(MLKEMLevel.MLKEM512, dummyData).fromTaggedCbor(cborValue);
|
|
8594
|
+
return new MLKEMPublicKey(512, new Uint8Array(mlkemPublicKeySize(512))).fromTaggedCbor(cborValue);
|
|
8648
8595
|
}
|
|
8649
8596
|
/**
|
|
8650
8597
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -8658,8 +8605,7 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8658
8605
|
*/
|
|
8659
8606
|
static fromUntaggedCborData(data) {
|
|
8660
8607
|
const cborValue = decodeCbor(data);
|
|
8661
|
-
|
|
8662
|
-
return new MLKEMPublicKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(cborValue);
|
|
8608
|
+
return new MLKEMPublicKey(512, new Uint8Array(mlkemPublicKeySize(512))).fromUntaggedCbor(cborValue);
|
|
8663
8609
|
}
|
|
8664
8610
|
/**
|
|
8665
8611
|
* Returns the UR representation.
|
|
@@ -8680,8 +8626,7 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8680
8626
|
*/
|
|
8681
8627
|
static fromUR(ur) {
|
|
8682
8628
|
if (ur.urTypeStr() !== MLKEM_PUBLIC_KEY.name) throw new Error(`Expected UR type ${MLKEM_PUBLIC_KEY.name}, got ${ur.urTypeStr()}`);
|
|
8683
|
-
|
|
8684
|
-
return new MLKEMPublicKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(ur.cbor());
|
|
8629
|
+
return new MLKEMPublicKey(512, new Uint8Array(mlkemPublicKeySize(512))).fromUntaggedCbor(ur.cbor());
|
|
8685
8630
|
}
|
|
8686
8631
|
/**
|
|
8687
8632
|
* Creates an MLKEMPublicKey from a UR string.
|
|
@@ -8691,7 +8636,6 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8691
8636
|
return MLKEMPublicKey.fromUR(ur);
|
|
8692
8637
|
}
|
|
8693
8638
|
};
|
|
8694
|
-
|
|
8695
8639
|
//#endregion
|
|
8696
8640
|
//#region src/encapsulation/encapsulation-public-key.ts
|
|
8697
8641
|
/**
|
|
@@ -8725,16 +8669,16 @@ var MLKEMPublicKey = class MLKEMPublicKey {
|
|
|
8725
8669
|
*/
|
|
8726
8670
|
function mlkemLevelToScheme$1(level) {
|
|
8727
8671
|
switch (level) {
|
|
8728
|
-
case
|
|
8729
|
-
case
|
|
8730
|
-
case
|
|
8672
|
+
case 512: return "mlkem512";
|
|
8673
|
+
case 768: return "mlkem768";
|
|
8674
|
+
case 1024: return "mlkem1024";
|
|
8731
8675
|
}
|
|
8732
8676
|
}
|
|
8733
8677
|
/**
|
|
8734
8678
|
* Check if a scheme is an MLKEM scheme
|
|
8735
8679
|
*/
|
|
8736
8680
|
function isMlkemScheme$1(scheme) {
|
|
8737
|
-
return scheme ===
|
|
8681
|
+
return scheme === "mlkem512" || scheme === "mlkem768" || scheme === "mlkem1024";
|
|
8738
8682
|
}
|
|
8739
8683
|
/**
|
|
8740
8684
|
* Represents a public key for key encapsulation.
|
|
@@ -8754,7 +8698,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8754
8698
|
* Create an EncapsulationPublicKey from an X25519PublicKey.
|
|
8755
8699
|
*/
|
|
8756
8700
|
static fromX25519PublicKey(publicKey) {
|
|
8757
|
-
return new EncapsulationPublicKey(
|
|
8701
|
+
return new EncapsulationPublicKey("x25519", publicKey, void 0);
|
|
8758
8702
|
}
|
|
8759
8703
|
/**
|
|
8760
8704
|
* Create an EncapsulationPublicKey from raw X25519 public key bytes.
|
|
@@ -8786,7 +8730,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8786
8730
|
* Returns true if this is an X25519 public key.
|
|
8787
8731
|
*/
|
|
8788
8732
|
isX25519() {
|
|
8789
|
-
return this._scheme ===
|
|
8733
|
+
return this._scheme === "x25519";
|
|
8790
8734
|
}
|
|
8791
8735
|
/**
|
|
8792
8736
|
* Returns true if this is an MLKEM public key.
|
|
@@ -8826,7 +8770,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8826
8770
|
* Returns the raw public key data.
|
|
8827
8771
|
*/
|
|
8828
8772
|
data() {
|
|
8829
|
-
if (this._scheme ===
|
|
8773
|
+
if (this._scheme === "x25519") {
|
|
8830
8774
|
const pk = this._x25519PublicKey;
|
|
8831
8775
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8832
8776
|
return pk.data();
|
|
@@ -8857,7 +8801,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8857
8801
|
* @returns A tuple of [sharedSecret, ciphertext]
|
|
8858
8802
|
*/
|
|
8859
8803
|
encapsulateNewSharedSecret() {
|
|
8860
|
-
if (this._scheme ===
|
|
8804
|
+
if (this._scheme === "x25519") {
|
|
8861
8805
|
const pk = this._x25519PublicKey;
|
|
8862
8806
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8863
8807
|
const [ephemeralPrivate, ephemeralPublic] = X25519PrivateKey.keypair();
|
|
@@ -8875,7 +8819,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8875
8819
|
*/
|
|
8876
8820
|
equals(other) {
|
|
8877
8821
|
if (this._scheme !== other._scheme) return false;
|
|
8878
|
-
if (this._scheme ===
|
|
8822
|
+
if (this._scheme === "x25519") {
|
|
8879
8823
|
const thisPk = this._x25519PublicKey;
|
|
8880
8824
|
const otherPk = other._x25519PublicKey;
|
|
8881
8825
|
if (thisPk === void 0 || otherPk === void 0) return false;
|
|
@@ -8892,7 +8836,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8892
8836
|
* Get string representation.
|
|
8893
8837
|
*/
|
|
8894
8838
|
toString() {
|
|
8895
|
-
if (this._scheme ===
|
|
8839
|
+
if (this._scheme === "x25519") return `EncapsulationPublicKey(X25519, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
8896
8840
|
else if (isMlkemScheme$1(this._scheme)) return `EncapsulationPublicKey(${String(this._scheme)}, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
8897
8841
|
return `EncapsulationPublicKey(${String(this._scheme)})`;
|
|
8898
8842
|
}
|
|
@@ -8910,7 +8854,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8910
8854
|
* Returns the CBOR tags associated with this public key.
|
|
8911
8855
|
*/
|
|
8912
8856
|
cborTags() {
|
|
8913
|
-
if (this._scheme ===
|
|
8857
|
+
if (this._scheme === "x25519") return tagsForValues([X25519_PUBLIC_KEY.value]);
|
|
8914
8858
|
else if (isMlkemScheme$1(this._scheme)) return tagsForValues([MLKEM_PUBLIC_KEY.value]);
|
|
8915
8859
|
throw new Error(`Unsupported scheme: ${String(this._scheme)}`);
|
|
8916
8860
|
}
|
|
@@ -8918,7 +8862,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8918
8862
|
* Returns the untagged CBOR encoding.
|
|
8919
8863
|
*/
|
|
8920
8864
|
untaggedCbor() {
|
|
8921
|
-
if (this._scheme ===
|
|
8865
|
+
if (this._scheme === "x25519") {
|
|
8922
8866
|
const pk = this._x25519PublicKey;
|
|
8923
8867
|
if (pk === void 0) throw new Error("X25519 public key not set");
|
|
8924
8868
|
return toByteString(pk.data());
|
|
@@ -8990,7 +8934,7 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
8990
8934
|
* Returns the UR representation.
|
|
8991
8935
|
*/
|
|
8992
8936
|
ur() {
|
|
8993
|
-
if (this._scheme ===
|
|
8937
|
+
if (this._scheme === "x25519") {
|
|
8994
8938
|
const name = X25519_PUBLIC_KEY.name;
|
|
8995
8939
|
if (name === void 0) throw new Error("TAG_X25519_PUBLIC_KEY.name is undefined");
|
|
8996
8940
|
return UR.new(name, this.untaggedCbor());
|
|
@@ -9026,7 +8970,6 @@ var EncapsulationPublicKey = class EncapsulationPublicKey {
|
|
|
9026
8970
|
return EncapsulationPublicKey.fromUR(ur);
|
|
9027
8971
|
}
|
|
9028
8972
|
};
|
|
9029
|
-
|
|
9030
8973
|
//#endregion
|
|
9031
8974
|
//#region src/mlkem/mlkem-private-key.ts
|
|
9032
8975
|
/**
|
|
@@ -9069,7 +9012,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9069
9012
|
*
|
|
9070
9013
|
* @param level - The ML-KEM security level (default: MLKEM768)
|
|
9071
9014
|
*/
|
|
9072
|
-
static new(level =
|
|
9015
|
+
static new(level = 768) {
|
|
9073
9016
|
const rng = new SecureRandomNumberGenerator();
|
|
9074
9017
|
return MLKEMPrivateKey.newUsing(level, rng);
|
|
9075
9018
|
}
|
|
@@ -9097,7 +9040,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9097
9040
|
* @param level - The ML-KEM security level (default: MLKEM768)
|
|
9098
9041
|
* @returns Tuple of [privateKey, publicKey]
|
|
9099
9042
|
*/
|
|
9100
|
-
static keypair(level =
|
|
9043
|
+
static keypair(level = 768) {
|
|
9101
9044
|
const rng = new SecureRandomNumberGenerator();
|
|
9102
9045
|
return MLKEMPrivateKey.keypairUsing(level, rng);
|
|
9103
9046
|
}
|
|
@@ -9223,8 +9166,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9223
9166
|
* Static method to decode from tagged CBOR.
|
|
9224
9167
|
*/
|
|
9225
9168
|
static fromTaggedCbor(cborValue) {
|
|
9226
|
-
|
|
9227
|
-
return new MLKEMPrivateKey(MLKEMLevel.MLKEM512, dummyData).fromTaggedCbor(cborValue);
|
|
9169
|
+
return new MLKEMPrivateKey(512, new Uint8Array(mlkemPrivateKeySize(512))).fromTaggedCbor(cborValue);
|
|
9228
9170
|
}
|
|
9229
9171
|
/**
|
|
9230
9172
|
* Static method to decode from tagged CBOR binary data.
|
|
@@ -9238,8 +9180,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9238
9180
|
*/
|
|
9239
9181
|
static fromUntaggedCborData(data) {
|
|
9240
9182
|
const cborValue = decodeCbor(data);
|
|
9241
|
-
|
|
9242
|
-
return new MLKEMPrivateKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(cborValue);
|
|
9183
|
+
return new MLKEMPrivateKey(512, new Uint8Array(mlkemPrivateKeySize(512))).fromUntaggedCbor(cborValue);
|
|
9243
9184
|
}
|
|
9244
9185
|
/**
|
|
9245
9186
|
* Returns the UR representation.
|
|
@@ -9260,8 +9201,7 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9260
9201
|
*/
|
|
9261
9202
|
static fromUR(ur) {
|
|
9262
9203
|
if (ur.urTypeStr() !== MLKEM_PRIVATE_KEY.name) throw new Error(`Expected UR type ${MLKEM_PRIVATE_KEY.name}, got ${ur.urTypeStr()}`);
|
|
9263
|
-
|
|
9264
|
-
return new MLKEMPrivateKey(MLKEMLevel.MLKEM512, dummyData).fromUntaggedCbor(ur.cbor());
|
|
9204
|
+
return new MLKEMPrivateKey(512, new Uint8Array(mlkemPrivateKeySize(512))).fromUntaggedCbor(ur.cbor());
|
|
9265
9205
|
}
|
|
9266
9206
|
/**
|
|
9267
9207
|
* Creates an MLKEMPrivateKey from a UR string.
|
|
@@ -9271,7 +9211,6 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9271
9211
|
return MLKEMPrivateKey.fromUR(ur);
|
|
9272
9212
|
}
|
|
9273
9213
|
};
|
|
9274
|
-
|
|
9275
9214
|
//#endregion
|
|
9276
9215
|
//#region src/encapsulation/encapsulation-private-key.ts
|
|
9277
9216
|
/**
|
|
@@ -9303,16 +9242,16 @@ var MLKEMPrivateKey = class MLKEMPrivateKey {
|
|
|
9303
9242
|
*/
|
|
9304
9243
|
function mlkemLevelToScheme(level) {
|
|
9305
9244
|
switch (level) {
|
|
9306
|
-
case
|
|
9307
|
-
case
|
|
9308
|
-
case
|
|
9245
|
+
case 512: return "mlkem512";
|
|
9246
|
+
case 768: return "mlkem768";
|
|
9247
|
+
case 1024: return "mlkem1024";
|
|
9309
9248
|
}
|
|
9310
9249
|
}
|
|
9311
9250
|
/**
|
|
9312
9251
|
* Check if a scheme is an MLKEM scheme
|
|
9313
9252
|
*/
|
|
9314
9253
|
function isMlkemScheme(scheme) {
|
|
9315
|
-
return scheme ===
|
|
9254
|
+
return scheme === "mlkem512" || scheme === "mlkem768" || scheme === "mlkem1024";
|
|
9316
9255
|
}
|
|
9317
9256
|
/**
|
|
9318
9257
|
* Represents a private key for key encapsulation.
|
|
@@ -9332,7 +9271,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9332
9271
|
* Create an EncapsulationPrivateKey from an X25519PrivateKey.
|
|
9333
9272
|
*/
|
|
9334
9273
|
static fromX25519PrivateKey(privateKey) {
|
|
9335
|
-
return new EncapsulationPrivateKey(
|
|
9274
|
+
return new EncapsulationPrivateKey("x25519", privateKey, void 0);
|
|
9336
9275
|
}
|
|
9337
9276
|
/**
|
|
9338
9277
|
* Create an EncapsulationPrivateKey from raw X25519 private key bytes.
|
|
@@ -9377,7 +9316,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9377
9316
|
/**
|
|
9378
9317
|
* Generate a new MLKEM encapsulation private key.
|
|
9379
9318
|
*/
|
|
9380
|
-
static newMlkem(level =
|
|
9319
|
+
static newMlkem(level = 768) {
|
|
9381
9320
|
const mlkemPrivate = MLKEMPrivateKey.new(level);
|
|
9382
9321
|
return EncapsulationPrivateKey.fromMlkem(mlkemPrivate);
|
|
9383
9322
|
}
|
|
@@ -9405,7 +9344,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9405
9344
|
/**
|
|
9406
9345
|
* Generate a new MLKEM keypair.
|
|
9407
9346
|
*/
|
|
9408
|
-
static mlkemKeypair(level =
|
|
9347
|
+
static mlkemKeypair(level = 768) {
|
|
9409
9348
|
const [mlkemPrivate, mlkemPublic] = MLKEMPrivateKey.keypair(level);
|
|
9410
9349
|
return [EncapsulationPrivateKey.fromMlkem(mlkemPrivate), EncapsulationPublicKey.fromMlkem(mlkemPublic)];
|
|
9411
9350
|
}
|
|
@@ -9426,7 +9365,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9426
9365
|
* Returns true if this is an X25519 private key.
|
|
9427
9366
|
*/
|
|
9428
9367
|
isX25519() {
|
|
9429
|
-
return this._scheme ===
|
|
9368
|
+
return this._scheme === "x25519";
|
|
9430
9369
|
}
|
|
9431
9370
|
/**
|
|
9432
9371
|
* Returns true if this is an MLKEM private key.
|
|
@@ -9466,7 +9405,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9466
9405
|
* Returns the raw private key data.
|
|
9467
9406
|
*/
|
|
9468
9407
|
data() {
|
|
9469
|
-
if (this._scheme ===
|
|
9408
|
+
if (this._scheme === "x25519") {
|
|
9470
9409
|
const pk = this._x25519PrivateKey;
|
|
9471
9410
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
9472
9411
|
return pk.data();
|
|
@@ -9481,7 +9420,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9481
9420
|
* Get the public key corresponding to this private key.
|
|
9482
9421
|
*/
|
|
9483
9422
|
publicKey() {
|
|
9484
|
-
if (this._scheme ===
|
|
9423
|
+
if (this._scheme === "x25519") {
|
|
9485
9424
|
const pk = this._x25519PrivateKey;
|
|
9486
9425
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
9487
9426
|
const x25519Public = pk.publicKey();
|
|
@@ -9503,7 +9442,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9503
9442
|
*/
|
|
9504
9443
|
decapsulateSharedSecret(ciphertext) {
|
|
9505
9444
|
if (ciphertext.encapsulationScheme() !== this._scheme) throw CryptoError.invalidData(`Scheme mismatch: expected ${String(this._scheme)}, got ${String(ciphertext.encapsulationScheme())}`);
|
|
9506
|
-
if (this._scheme ===
|
|
9445
|
+
if (this._scheme === "x25519") {
|
|
9507
9446
|
const pk = this._x25519PrivateKey;
|
|
9508
9447
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
9509
9448
|
const ephemeralPublic = ciphertext.x25519PublicKey();
|
|
@@ -9521,7 +9460,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9521
9460
|
*/
|
|
9522
9461
|
equals(other) {
|
|
9523
9462
|
if (this._scheme !== other._scheme) return false;
|
|
9524
|
-
if (this._scheme ===
|
|
9463
|
+
if (this._scheme === "x25519") {
|
|
9525
9464
|
const thisPk = this._x25519PrivateKey;
|
|
9526
9465
|
const otherPk = other._x25519PrivateKey;
|
|
9527
9466
|
if (thisPk === void 0 || otherPk === void 0) return false;
|
|
@@ -9538,7 +9477,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9538
9477
|
* Get string representation.
|
|
9539
9478
|
*/
|
|
9540
9479
|
toString() {
|
|
9541
|
-
if (this._scheme ===
|
|
9480
|
+
if (this._scheme === "x25519") return `EncapsulationPrivateKey(X25519, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
9542
9481
|
else if (isMlkemScheme(this._scheme)) return `EncapsulationPrivateKey(${String(this._scheme)}, ${bytesToHex(this.data()).substring(0, 16)}...)`;
|
|
9543
9482
|
return `EncapsulationPrivateKey(${String(this._scheme)})`;
|
|
9544
9483
|
}
|
|
@@ -9556,7 +9495,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9556
9495
|
* Returns the CBOR tags associated with this private key.
|
|
9557
9496
|
*/
|
|
9558
9497
|
cborTags() {
|
|
9559
|
-
if (this._scheme ===
|
|
9498
|
+
if (this._scheme === "x25519") return tagsForValues([X25519_PRIVATE_KEY.value]);
|
|
9560
9499
|
else if (isMlkemScheme(this._scheme)) return tagsForValues([MLKEM_PRIVATE_KEY.value]);
|
|
9561
9500
|
throw new Error(`Unsupported scheme: ${String(this._scheme)}`);
|
|
9562
9501
|
}
|
|
@@ -9564,7 +9503,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9564
9503
|
* Returns the untagged CBOR encoding.
|
|
9565
9504
|
*/
|
|
9566
9505
|
untaggedCbor() {
|
|
9567
|
-
if (this._scheme ===
|
|
9506
|
+
if (this._scheme === "x25519") {
|
|
9568
9507
|
const pk = this._x25519PrivateKey;
|
|
9569
9508
|
if (pk === void 0) throw new Error("X25519 private key not set");
|
|
9570
9509
|
return toByteString(pk.data());
|
|
@@ -9636,7 +9575,7 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9636
9575
|
* Returns the UR representation.
|
|
9637
9576
|
*/
|
|
9638
9577
|
ur() {
|
|
9639
|
-
if (this._scheme ===
|
|
9578
|
+
if (this._scheme === "x25519") {
|
|
9640
9579
|
const name = X25519_PRIVATE_KEY.name;
|
|
9641
9580
|
if (name === void 0) throw new Error("TAG_X25519_PRIVATE_KEY.name is undefined");
|
|
9642
9581
|
return UR.new(name, this.untaggedCbor());
|
|
@@ -9672,37 +9611,36 @@ var EncapsulationPrivateKey = class EncapsulationPrivateKey {
|
|
|
9672
9611
|
return EncapsulationPrivateKey.fromUR(ur);
|
|
9673
9612
|
}
|
|
9674
9613
|
};
|
|
9675
|
-
|
|
9676
9614
|
//#endregion
|
|
9677
9615
|
//#region src/encapsulation/encapsulation-scheme.ts
|
|
9678
9616
|
/**
|
|
9679
9617
|
* Available key encapsulation schemes.
|
|
9680
9618
|
*/
|
|
9681
|
-
let EncapsulationScheme = /* @__PURE__ */ function(EncapsulationScheme
|
|
9619
|
+
let EncapsulationScheme = /* @__PURE__ */ function(EncapsulationScheme) {
|
|
9682
9620
|
/**
|
|
9683
9621
|
* X25519 Diffie-Hellman key exchange (default).
|
|
9684
9622
|
* Based on Curve25519 as defined in RFC 7748.
|
|
9685
9623
|
*/
|
|
9686
|
-
EncapsulationScheme
|
|
9624
|
+
EncapsulationScheme["X25519"] = "x25519";
|
|
9687
9625
|
/**
|
|
9688
9626
|
* ML-KEM-512 post-quantum key encapsulation (NIST security level 1).
|
|
9689
9627
|
*/
|
|
9690
|
-
EncapsulationScheme
|
|
9628
|
+
EncapsulationScheme["MLKEM512"] = "mlkem512";
|
|
9691
9629
|
/**
|
|
9692
9630
|
* ML-KEM-768 post-quantum key encapsulation (NIST security level 3).
|
|
9693
9631
|
*/
|
|
9694
|
-
EncapsulationScheme
|
|
9632
|
+
EncapsulationScheme["MLKEM768"] = "mlkem768";
|
|
9695
9633
|
/**
|
|
9696
9634
|
* ML-KEM-1024 post-quantum key encapsulation (NIST security level 5).
|
|
9697
9635
|
*/
|
|
9698
|
-
EncapsulationScheme
|
|
9699
|
-
return EncapsulationScheme
|
|
9636
|
+
EncapsulationScheme["MLKEM1024"] = "mlkem1024";
|
|
9637
|
+
return EncapsulationScheme;
|
|
9700
9638
|
}({});
|
|
9701
9639
|
/**
|
|
9702
9640
|
* Returns the default encapsulation scheme (X25519).
|
|
9703
9641
|
*/
|
|
9704
9642
|
function defaultEncapsulationScheme() {
|
|
9705
|
-
return
|
|
9643
|
+
return "x25519";
|
|
9706
9644
|
}
|
|
9707
9645
|
/**
|
|
9708
9646
|
* Generate a new keypair for the given encapsulation scheme.
|
|
@@ -9710,12 +9648,12 @@ function defaultEncapsulationScheme() {
|
|
|
9710
9648
|
* @param scheme - The encapsulation scheme to use (defaults to X25519)
|
|
9711
9649
|
* @returns A tuple of [privateKey, publicKey]
|
|
9712
9650
|
*/
|
|
9713
|
-
function createEncapsulationKeypair(scheme =
|
|
9651
|
+
function createEncapsulationKeypair(scheme = "x25519") {
|
|
9714
9652
|
switch (scheme) {
|
|
9715
|
-
case
|
|
9716
|
-
case
|
|
9717
|
-
case
|
|
9718
|
-
case
|
|
9653
|
+
case "x25519": return EncapsulationPrivateKey.keypair();
|
|
9654
|
+
case "mlkem512": return EncapsulationPrivateKey.mlkemKeypair(512);
|
|
9655
|
+
case "mlkem768": return EncapsulationPrivateKey.mlkemKeypair(768);
|
|
9656
|
+
case "mlkem1024": return EncapsulationPrivateKey.mlkemKeypair(1024);
|
|
9719
9657
|
}
|
|
9720
9658
|
}
|
|
9721
9659
|
/**
|
|
@@ -9729,15 +9667,14 @@ function createEncapsulationKeypair(scheme = EncapsulationScheme.X25519) {
|
|
|
9729
9667
|
* @returns A tuple of [privateKey, publicKey]
|
|
9730
9668
|
* @throws Error if the scheme doesn't support deterministic generation
|
|
9731
9669
|
*/
|
|
9732
|
-
function createEncapsulationKeypairUsing(rng, scheme =
|
|
9670
|
+
function createEncapsulationKeypairUsing(rng, scheme = "x25519") {
|
|
9733
9671
|
switch (scheme) {
|
|
9734
|
-
case
|
|
9735
|
-
case
|
|
9736
|
-
case
|
|
9737
|
-
case
|
|
9672
|
+
case "x25519": return EncapsulationPrivateKey.keypairUsing(rng);
|
|
9673
|
+
case "mlkem512":
|
|
9674
|
+
case "mlkem768":
|
|
9675
|
+
case "mlkem1024": throw new Error("Deterministic keypair generation not supported for this encapsulation scheme");
|
|
9738
9676
|
}
|
|
9739
9677
|
}
|
|
9740
|
-
|
|
9741
9678
|
//#endregion
|
|
9742
9679
|
//#region src/encapsulation/sealed-message.ts
|
|
9743
9680
|
/**
|
|
@@ -9968,7 +9905,6 @@ var SealedMessage = class SealedMessage {
|
|
|
9968
9905
|
return SealedMessage.fromUR(ur);
|
|
9969
9906
|
}
|
|
9970
9907
|
};
|
|
9971
|
-
|
|
9972
9908
|
//#endregion
|
|
9973
9909
|
//#region src/encrypted-key/hash-type.ts
|
|
9974
9910
|
/**
|
|
@@ -9992,20 +9928,20 @@ var SealedMessage = class SealedMessage {
|
|
|
9992
9928
|
/**
|
|
9993
9929
|
* Enum representing supported hash types for key derivation.
|
|
9994
9930
|
*/
|
|
9995
|
-
let HashType = /* @__PURE__ */ function(HashType
|
|
9931
|
+
let HashType = /* @__PURE__ */ function(HashType) {
|
|
9996
9932
|
/** SHA-256 hash algorithm */
|
|
9997
|
-
HashType
|
|
9933
|
+
HashType[HashType["SHA256"] = 0] = "SHA256";
|
|
9998
9934
|
/** SHA-512 hash algorithm */
|
|
9999
|
-
HashType
|
|
10000
|
-
return HashType
|
|
9935
|
+
HashType[HashType["SHA512"] = 1] = "SHA512";
|
|
9936
|
+
return HashType;
|
|
10001
9937
|
}({});
|
|
10002
9938
|
/**
|
|
10003
9939
|
* Convert HashType to its string representation.
|
|
10004
9940
|
*/
|
|
10005
9941
|
function hashTypeToString(hashType) {
|
|
10006
9942
|
switch (hashType) {
|
|
10007
|
-
case
|
|
10008
|
-
case
|
|
9943
|
+
case 0: return "SHA256";
|
|
9944
|
+
case 1: return "SHA512";
|
|
10009
9945
|
default: throw new Error(`Unknown HashType: ${String(hashType)}`);
|
|
10010
9946
|
}
|
|
10011
9947
|
}
|
|
@@ -10021,12 +9957,11 @@ function hashTypeToCbor(hashType) {
|
|
|
10021
9957
|
function hashTypeFromCbor(cborValue) {
|
|
10022
9958
|
const value = expectNumber(cborValue);
|
|
10023
9959
|
switch (value) {
|
|
10024
|
-
case 0: return
|
|
10025
|
-
case 1: return
|
|
9960
|
+
case 0: return 0;
|
|
9961
|
+
case 1: return 1;
|
|
10026
9962
|
default: throw new Error(`Invalid HashType: ${value}`);
|
|
10027
9963
|
}
|
|
10028
9964
|
}
|
|
10029
|
-
|
|
10030
9965
|
//#endregion
|
|
10031
9966
|
//#region src/encrypted-key/key-derivation-method.ts
|
|
10032
9967
|
/**
|
|
@@ -10053,24 +9988,24 @@ function hashTypeFromCbor(cborValue) {
|
|
|
10053
9988
|
/**
|
|
10054
9989
|
* Enum representing supported key derivation methods.
|
|
10055
9990
|
*/
|
|
10056
|
-
let KeyDerivationMethod = /* @__PURE__ */ function(KeyDerivationMethod
|
|
9991
|
+
let KeyDerivationMethod = /* @__PURE__ */ function(KeyDerivationMethod) {
|
|
10057
9992
|
/** HKDF (HMAC-based Key Derivation Function) - RFC 5869 */
|
|
10058
|
-
KeyDerivationMethod
|
|
9993
|
+
KeyDerivationMethod[KeyDerivationMethod["HKDF"] = 0] = "HKDF";
|
|
10059
9994
|
/** PBKDF2 (Password-Based Key Derivation Function 2) - RFC 8018 */
|
|
10060
|
-
KeyDerivationMethod
|
|
9995
|
+
KeyDerivationMethod[KeyDerivationMethod["PBKDF2"] = 1] = "PBKDF2";
|
|
10061
9996
|
/** Scrypt - RFC 7914 */
|
|
10062
|
-
KeyDerivationMethod
|
|
9997
|
+
KeyDerivationMethod[KeyDerivationMethod["Scrypt"] = 2] = "Scrypt";
|
|
10063
9998
|
/** Argon2id - RFC 9106 (default, most secure for passwords) */
|
|
10064
|
-
KeyDerivationMethod
|
|
9999
|
+
KeyDerivationMethod[KeyDerivationMethod["Argon2id"] = 3] = "Argon2id";
|
|
10065
10000
|
/** SSH Agent - Uses SSH agent for key derivation */
|
|
10066
|
-
KeyDerivationMethod
|
|
10067
|
-
return KeyDerivationMethod
|
|
10001
|
+
KeyDerivationMethod[KeyDerivationMethod["SSHAgent"] = 4] = "SSHAgent";
|
|
10002
|
+
return KeyDerivationMethod;
|
|
10068
10003
|
}({});
|
|
10069
10004
|
/**
|
|
10070
10005
|
* Returns the default key derivation method (Argon2id).
|
|
10071
10006
|
*/
|
|
10072
10007
|
function defaultKeyDerivationMethod() {
|
|
10073
|
-
return
|
|
10008
|
+
return 3;
|
|
10074
10009
|
}
|
|
10075
10010
|
/**
|
|
10076
10011
|
* Returns the zero-based index of the key derivation method.
|
|
@@ -10083,11 +10018,11 @@ function keyDerivationMethodIndex(method) {
|
|
|
10083
10018
|
*/
|
|
10084
10019
|
function keyDerivationMethodFromIndex(index) {
|
|
10085
10020
|
switch (index) {
|
|
10086
|
-
case 0: return
|
|
10087
|
-
case 1: return
|
|
10088
|
-
case 2: return
|
|
10089
|
-
case 3: return
|
|
10090
|
-
case 4: return
|
|
10021
|
+
case 0: return 0;
|
|
10022
|
+
case 1: return 1;
|
|
10023
|
+
case 2: return 2;
|
|
10024
|
+
case 3: return 3;
|
|
10025
|
+
case 4: return 4;
|
|
10091
10026
|
default: return;
|
|
10092
10027
|
}
|
|
10093
10028
|
}
|
|
@@ -10096,11 +10031,11 @@ function keyDerivationMethodFromIndex(index) {
|
|
|
10096
10031
|
*/
|
|
10097
10032
|
function keyDerivationMethodToString(method) {
|
|
10098
10033
|
switch (method) {
|
|
10099
|
-
case
|
|
10100
|
-
case
|
|
10101
|
-
case
|
|
10102
|
-
case
|
|
10103
|
-
case
|
|
10034
|
+
case 0: return "HKDF";
|
|
10035
|
+
case 1: return "PBKDF2";
|
|
10036
|
+
case 2: return "Scrypt";
|
|
10037
|
+
case 3: return "Argon2id";
|
|
10038
|
+
case 4: return "SSHAgent";
|
|
10104
10039
|
default: throw new Error(`Unknown KeyDerivationMethod: ${String(method)}`);
|
|
10105
10040
|
}
|
|
10106
10041
|
}
|
|
@@ -10113,7 +10048,6 @@ function keyDerivationMethodFromCbor(cborValue) {
|
|
|
10113
10048
|
if (method === void 0) throw new Error(`Invalid KeyDerivationMethod index: ${value}`);
|
|
10114
10049
|
return method;
|
|
10115
10050
|
}
|
|
10116
|
-
|
|
10117
10051
|
//#endregion
|
|
10118
10052
|
//#region src/encrypted-key/hkdf-params.ts
|
|
10119
10053
|
/**
|
|
@@ -10143,7 +10077,7 @@ const SALT_LEN = 16;
|
|
|
10143
10077
|
* but NOT for password-based key derivation.
|
|
10144
10078
|
*/
|
|
10145
10079
|
var HKDFParams = class HKDFParams {
|
|
10146
|
-
static INDEX =
|
|
10080
|
+
static INDEX = 0;
|
|
10147
10081
|
_salt;
|
|
10148
10082
|
_hashType;
|
|
10149
10083
|
constructor(salt, hashType) {
|
|
@@ -10155,7 +10089,7 @@ var HKDFParams = class HKDFParams {
|
|
|
10155
10089
|
* Uses a random 16-byte salt and SHA-256.
|
|
10156
10090
|
*/
|
|
10157
10091
|
static new() {
|
|
10158
|
-
return HKDFParams.newOpt(Salt.newWithLen(
|
|
10092
|
+
return HKDFParams.newOpt(Salt.newWithLen(16), 0);
|
|
10159
10093
|
}
|
|
10160
10094
|
/**
|
|
10161
10095
|
* Create HKDF parameters with custom settings.
|
|
@@ -10194,8 +10128,8 @@ var HKDFParams = class HKDFParams {
|
|
|
10194
10128
|
}
|
|
10195
10129
|
_deriveKey(secret) {
|
|
10196
10130
|
switch (this._hashType) {
|
|
10197
|
-
case
|
|
10198
|
-
case
|
|
10131
|
+
case 0: return hkdfHmacSha256(secret, this._salt.asBytes(), 32);
|
|
10132
|
+
case 1: return hkdfHmacSha512(secret, this._salt.asBytes(), 32);
|
|
10199
10133
|
default: throw new Error(`Unknown hash type: ${String(this._hashType)}`);
|
|
10200
10134
|
}
|
|
10201
10135
|
}
|
|
@@ -10240,7 +10174,6 @@ var HKDFParams = class HKDFParams {
|
|
|
10240
10174
|
return new HKDFParams(Salt.fromData(saltData), hashTypeFromCbor(array[2]));
|
|
10241
10175
|
}
|
|
10242
10176
|
};
|
|
10243
|
-
|
|
10244
10177
|
//#endregion
|
|
10245
10178
|
//#region src/encrypted-key/pbkdf2-params.ts
|
|
10246
10179
|
/**
|
|
@@ -10266,7 +10199,7 @@ const DEFAULT_PBKDF2_ITERATIONS = 1e5;
|
|
|
10266
10199
|
* PBKDF2 parameters for password-based key derivation.
|
|
10267
10200
|
*/
|
|
10268
10201
|
var PBKDF2Params = class PBKDF2Params {
|
|
10269
|
-
static INDEX =
|
|
10202
|
+
static INDEX = 1;
|
|
10270
10203
|
_salt;
|
|
10271
10204
|
_iterations;
|
|
10272
10205
|
_hashType;
|
|
@@ -10280,7 +10213,7 @@ var PBKDF2Params = class PBKDF2Params {
|
|
|
10280
10213
|
* Uses a random 16-byte salt, 100,000 iterations, and SHA-256.
|
|
10281
10214
|
*/
|
|
10282
10215
|
static new() {
|
|
10283
|
-
return PBKDF2Params.newOpt(Salt.newWithLen(
|
|
10216
|
+
return PBKDF2Params.newOpt(Salt.newWithLen(16), DEFAULT_PBKDF2_ITERATIONS, 0);
|
|
10284
10217
|
}
|
|
10285
10218
|
/**
|
|
10286
10219
|
* Create PBKDF2 parameters with custom settings.
|
|
@@ -10323,8 +10256,8 @@ var PBKDF2Params = class PBKDF2Params {
|
|
|
10323
10256
|
}
|
|
10324
10257
|
_deriveKey(secret) {
|
|
10325
10258
|
switch (this._hashType) {
|
|
10326
|
-
case
|
|
10327
|
-
case
|
|
10259
|
+
case 0: return pbkdf2HmacSha256(secret, this._salt.asBytes(), this._iterations, 32);
|
|
10260
|
+
case 1: return pbkdf2HmacSha512(secret, this._salt.asBytes(), this._iterations, 32);
|
|
10328
10261
|
default: throw new Error(`Unknown hash type: ${String(this._hashType)}`);
|
|
10329
10262
|
}
|
|
10330
10263
|
}
|
|
@@ -10370,7 +10303,6 @@ var PBKDF2Params = class PBKDF2Params {
|
|
|
10370
10303
|
return new PBKDF2Params(Salt.fromData(saltData), Number(expectNumber(array[2])), hashTypeFromCbor(array[3]));
|
|
10371
10304
|
}
|
|
10372
10305
|
};
|
|
10373
|
-
|
|
10374
10306
|
//#endregion
|
|
10375
10307
|
//#region src/encrypted-key/scrypt-params.ts
|
|
10376
10308
|
/**
|
|
@@ -10406,7 +10338,7 @@ const DEFAULT_SCRYPT_P = 1;
|
|
|
10406
10338
|
* - p: Parallelization parameter
|
|
10407
10339
|
*/
|
|
10408
10340
|
var ScryptParams = class ScryptParams {
|
|
10409
|
-
static INDEX =
|
|
10341
|
+
static INDEX = 2;
|
|
10410
10342
|
_salt;
|
|
10411
10343
|
_logN;
|
|
10412
10344
|
_r;
|
|
@@ -10422,7 +10354,7 @@ var ScryptParams = class ScryptParams {
|
|
|
10422
10354
|
* Uses a random 16-byte salt, log_n=15, r=8, p=1.
|
|
10423
10355
|
*/
|
|
10424
10356
|
static new() {
|
|
10425
|
-
return ScryptParams.newOpt(Salt.newWithLen(
|
|
10357
|
+
return ScryptParams.newOpt(Salt.newWithLen(16), 15, 8, 1);
|
|
10426
10358
|
}
|
|
10427
10359
|
/**
|
|
10428
10360
|
* Create Scrypt parameters with custom settings.
|
|
@@ -10513,7 +10445,6 @@ var ScryptParams = class ScryptParams {
|
|
|
10513
10445
|
return new ScryptParams(Salt.fromData(saltData), Number(expectNumber(array[2])), Number(expectNumber(array[3])), Number(expectNumber(array[4])));
|
|
10514
10446
|
}
|
|
10515
10447
|
};
|
|
10516
|
-
|
|
10517
10448
|
//#endregion
|
|
10518
10449
|
//#region src/encrypted-key/argon2id-params.ts
|
|
10519
10450
|
/**
|
|
@@ -10546,7 +10477,7 @@ var ScryptParams = class ScryptParams {
|
|
|
10546
10477
|
* attacks.
|
|
10547
10478
|
*/
|
|
10548
10479
|
var Argon2idParams = class Argon2idParams {
|
|
10549
|
-
static INDEX =
|
|
10480
|
+
static INDEX = 3;
|
|
10550
10481
|
_salt;
|
|
10551
10482
|
constructor(salt) {
|
|
10552
10483
|
this._salt = salt;
|
|
@@ -10556,7 +10487,7 @@ var Argon2idParams = class Argon2idParams {
|
|
|
10556
10487
|
* Uses a random 16-byte salt.
|
|
10557
10488
|
*/
|
|
10558
10489
|
static new() {
|
|
10559
|
-
return Argon2idParams.newOpt(Salt.newWithLen(
|
|
10490
|
+
return Argon2idParams.newOpt(Salt.newWithLen(16));
|
|
10560
10491
|
}
|
|
10561
10492
|
/**
|
|
10562
10493
|
* Create Argon2id parameters with a custom salt.
|
|
@@ -10629,28 +10560,6 @@ var Argon2idParams = class Argon2idParams {
|
|
|
10629
10560
|
return new Argon2idParams(Salt.fromData(saltData));
|
|
10630
10561
|
}
|
|
10631
10562
|
};
|
|
10632
|
-
|
|
10633
|
-
//#endregion
|
|
10634
|
-
//#region src/encrypted-key/ssh-agent-params.ts
|
|
10635
|
-
/**
|
|
10636
|
-
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
10637
|
-
* Copyright © 2025-2026 Parity Technologies
|
|
10638
|
-
*
|
|
10639
|
-
*
|
|
10640
|
-
* SSH Agent key derivation parameters
|
|
10641
|
-
*
|
|
10642
|
-
* SSH Agent uses an SSH agent daemon for key derivation. The agent signs
|
|
10643
|
-
* a challenge derived from the salt to produce the encryption key.
|
|
10644
|
-
*
|
|
10645
|
-
* CDDL:
|
|
10646
|
-
* ```cddl
|
|
10647
|
-
* SSHAgentParams = [4, Salt, id: tstr]
|
|
10648
|
-
* ```
|
|
10649
|
-
*
|
|
10650
|
-
* Ported from bc-components-rust/src/encrypted_key/ssh_agent_params.rs
|
|
10651
|
-
*/
|
|
10652
|
-
/** Default salt length for SSH agent key derivation */
|
|
10653
|
-
const SALT_LEN$1 = 16;
|
|
10654
10563
|
/**
|
|
10655
10564
|
* SSH Agent parameters for key derivation.
|
|
10656
10565
|
*
|
|
@@ -10663,7 +10572,7 @@ const SALT_LEN$1 = 16;
|
|
|
10663
10572
|
* methods will throw an error if SSH agent support is not available.
|
|
10664
10573
|
*/
|
|
10665
10574
|
var SSHAgentParams = class SSHAgentParams {
|
|
10666
|
-
static INDEX =
|
|
10575
|
+
static INDEX = 4;
|
|
10667
10576
|
_salt;
|
|
10668
10577
|
_id;
|
|
10669
10578
|
constructor(salt, id) {
|
|
@@ -10676,7 +10585,7 @@ var SSHAgentParams = class SSHAgentParams {
|
|
|
10676
10585
|
* @param id - The SSH key identity (usually the key comment or public key fingerprint)
|
|
10677
10586
|
*/
|
|
10678
10587
|
static new(id) {
|
|
10679
|
-
return SSHAgentParams.newOpt(Salt.newWithLen(
|
|
10588
|
+
return SSHAgentParams.newOpt(Salt.newWithLen(16), id);
|
|
10680
10589
|
}
|
|
10681
10590
|
/**
|
|
10682
10591
|
* Create SSH agent parameters with custom salt and key ID.
|
|
@@ -10764,7 +10673,6 @@ var SSHAgentParams = class SSHAgentParams {
|
|
|
10764
10673
|
return new SSHAgentParams(Salt.fromData(saltData), expectText(array[2]));
|
|
10765
10674
|
}
|
|
10766
10675
|
};
|
|
10767
|
-
|
|
10768
10676
|
//#endregion
|
|
10769
10677
|
//#region src/encrypted-key/key-derivation-params.ts
|
|
10770
10678
|
/**
|
|
@@ -10842,11 +10750,11 @@ function defaultKeyDerivationParams() {
|
|
|
10842
10750
|
*/
|
|
10843
10751
|
function keyDerivationParamsMethod(kdp) {
|
|
10844
10752
|
switch (kdp.type) {
|
|
10845
|
-
case "hkdf": return
|
|
10846
|
-
case "pbkdf2": return
|
|
10847
|
-
case "scrypt": return
|
|
10848
|
-
case "argon2id": return
|
|
10849
|
-
case "sshagent": return
|
|
10753
|
+
case "hkdf": return 0;
|
|
10754
|
+
case "pbkdf2": return 1;
|
|
10755
|
+
case "scrypt": return 2;
|
|
10756
|
+
case "argon2id": return 3;
|
|
10757
|
+
case "sshagent": return 4;
|
|
10850
10758
|
}
|
|
10851
10759
|
}
|
|
10852
10760
|
/**
|
|
@@ -10919,29 +10827,28 @@ function keyDerivationParamsFromCbor(cborValue) {
|
|
|
10919
10827
|
const method = keyDerivationMethodFromIndex(Number(index));
|
|
10920
10828
|
if (method === void 0) throw new Error(`Invalid KeyDerivationMethod index: ${index}`);
|
|
10921
10829
|
switch (method) {
|
|
10922
|
-
case
|
|
10830
|
+
case 0: return {
|
|
10923
10831
|
type: "hkdf",
|
|
10924
10832
|
params: HKDFParams.fromCbor(cborValue)
|
|
10925
10833
|
};
|
|
10926
|
-
case
|
|
10834
|
+
case 1: return {
|
|
10927
10835
|
type: "pbkdf2",
|
|
10928
10836
|
params: PBKDF2Params.fromCbor(cborValue)
|
|
10929
10837
|
};
|
|
10930
|
-
case
|
|
10838
|
+
case 2: return {
|
|
10931
10839
|
type: "scrypt",
|
|
10932
10840
|
params: ScryptParams.fromCbor(cborValue)
|
|
10933
10841
|
};
|
|
10934
|
-
case
|
|
10842
|
+
case 3: return {
|
|
10935
10843
|
type: "argon2id",
|
|
10936
10844
|
params: Argon2idParams.fromCbor(cborValue)
|
|
10937
10845
|
};
|
|
10938
|
-
case
|
|
10846
|
+
case 4: return {
|
|
10939
10847
|
type: "sshagent",
|
|
10940
10848
|
params: SSHAgentParams.fromCbor(cborValue)
|
|
10941
10849
|
};
|
|
10942
10850
|
}
|
|
10943
10851
|
}
|
|
10944
|
-
|
|
10945
10852
|
//#endregion
|
|
10946
10853
|
//#region src/encrypted-key/encrypted-key.ts
|
|
10947
10854
|
/**
|
|
@@ -11005,19 +10912,19 @@ var EncryptedKey = class EncryptedKey {
|
|
|
11005
10912
|
static lock(method, secret, contentKey) {
|
|
11006
10913
|
let params;
|
|
11007
10914
|
switch (method) {
|
|
11008
|
-
case
|
|
10915
|
+
case 0:
|
|
11009
10916
|
params = hkdfParams();
|
|
11010
10917
|
break;
|
|
11011
|
-
case
|
|
10918
|
+
case 1:
|
|
11012
10919
|
params = pbkdf2Params();
|
|
11013
10920
|
break;
|
|
11014
|
-
case
|
|
10921
|
+
case 2:
|
|
11015
10922
|
params = scryptParams();
|
|
11016
10923
|
break;
|
|
11017
|
-
case
|
|
10924
|
+
case 3:
|
|
11018
10925
|
params = argon2idParams();
|
|
11019
10926
|
break;
|
|
11020
|
-
case
|
|
10927
|
+
case 4: throw new Error("SSH Agent key derivation cannot be used with lock() - use lockOpt() with sshAgentParams() instead");
|
|
11021
10928
|
}
|
|
11022
10929
|
return EncryptedKey.lockOpt(params, secret, contentKey);
|
|
11023
10930
|
}
|
|
@@ -11179,7 +11086,6 @@ var EncryptedKey = class EncryptedKey {
|
|
|
11179
11086
|
return EncryptedKey.fromUR(ur);
|
|
11180
11087
|
}
|
|
11181
11088
|
};
|
|
11182
|
-
|
|
11183
11089
|
//#endregion
|
|
11184
11090
|
//#region src/public-keys.ts
|
|
11185
11091
|
/**
|
|
@@ -11408,7 +11314,6 @@ var PublicKeys = class PublicKeys {
|
|
|
11408
11314
|
return PublicKeys.fromUR(ur);
|
|
11409
11315
|
}
|
|
11410
11316
|
};
|
|
11411
|
-
|
|
11412
11317
|
//#endregion
|
|
11413
11318
|
//#region src/private-keys.ts
|
|
11414
11319
|
/**
|
|
@@ -11624,7 +11529,6 @@ var PrivateKeys = class PrivateKeys {
|
|
|
11624
11529
|
return PrivateKeys.fromUR(ur);
|
|
11625
11530
|
}
|
|
11626
11531
|
};
|
|
11627
|
-
|
|
11628
11532
|
//#endregion
|
|
11629
11533
|
//#region src/private-key-base.ts
|
|
11630
11534
|
/**
|
|
@@ -11898,7 +11802,6 @@ var PrivateKeyBase = class PrivateKeyBase {
|
|
|
11898
11802
|
return PrivateKeyBase.fromUR(ur);
|
|
11899
11803
|
}
|
|
11900
11804
|
};
|
|
11901
|
-
|
|
11902
11805
|
//#endregion
|
|
11903
11806
|
//#region src/sskr.ts
|
|
11904
11807
|
/**
|
|
@@ -12175,7 +12078,7 @@ function sskrGenerateSharesUsing(spec, masterSecret, rng) {
|
|
|
12175
12078
|
function sskrCombineShares(shares) {
|
|
12176
12079
|
return sskrCombine(shares.map((share) => share.data()));
|
|
12177
12080
|
}
|
|
12178
|
-
|
|
12179
12081
|
//#endregion
|
|
12180
12082
|
export { ARID, Argon2idParams, AuthenticationTag, COMPRESSED, Compressed, CryptoError, DEFAULT_PBKDF2_ITERATIONS, DEFAULT_SCRYPT_LOG_N, DEFAULT_SCRYPT_P, DEFAULT_SCRYPT_R, Digest, ECPrivateKey, ECPublicKey, ECUncompressedPublicKey, ENCRYPTED, ENVELOPE, Ed25519PrivateKey, Ed25519PublicKey, EncapsulationCiphertext, EncapsulationPrivateKey, EncapsulationPublicKey, EncapsulationScheme, EncryptedKey, EncryptedMessage, ErrorKind, HKDFParams, HKDFRng, HashType, JSON, KNOWN_VALUE, KeyDerivationMethod, LEAF, MLDSALevel, MLDSAPrivateKey, MLDSAPublicKey, MLDSASignature, MLDSA_KEY_SIZES, MLKEMCiphertext, MLKEMLevel, MLKEMPrivateKey, MLKEMPublicKey, MLKEM_KEY_SIZES, Nonce, PBKDF2Params, PrivateKeyBase, PrivateKeys, PublicKeys, Reference, SALT_LEN, SR25519_DEFAULT_CONTEXT, SR25519_PRIVATE_KEY_SIZE, SR25519_PUBLIC_KEY_SIZE, SR25519_SIGNATURE_SIZE, SSHAgentParams, SSKRGroupSpec, SSKRSecret, SSKRShare, SSKRShareCbor, SSKRSpec, Salt, SchnorrPublicKey, ScryptParams, SealedMessage, Seed, Signature, SignatureScheme, SigningPrivateKey, SigningPublicKey, Sr25519PrivateKey, Sr25519PublicKey, SymmetricKey, URI, UUID, X25519PrivateKey, X25519PublicKey, XID, argon2idParams, bytesEqual, bytesToHex, createEncapsulationKeypair, createEncapsulationKeypairUsing, createKeypair, createKeypairUsing, defaultEncapsulationScheme, defaultKeyDerivationMethod, defaultKeyDerivationParams, defaultSignatureScheme, digestFromBytes, fromBase64, hashTypeFromCbor, hashTypeToCbor, hashTypeToString, hexToBytes, hkdfParams, isCryptoError, isCryptoErrorKind, isDecrypter, isECKey, isECKeyBase, isECPublicKeyBase, isEncrypter, isError, isMldsaScheme, isPasswordBased, isPrivateKeyDataProvider, isReferenceProvider, isSshAgent, isSshScheme, keyDerivationMethodFromCbor, keyDerivationMethodFromIndex, keyDerivationMethodIndex, keyDerivationMethodToString, keyDerivationParamsFromCbor, keyDerivationParamsMethod, keyDerivationParamsToCbor, keyDerivationParamsToCborData, keyDerivationParamsToString, lockWithParams, mldsaGenerateKeypair, mldsaGenerateKeypairUsing, mldsaLevelFromValue, mldsaLevelToString, mldsaPrivateKeySize, mldsaPublicKeySize, mldsaSign, mldsaSignatureSize, mldsaVerify, mlkemCiphertextSize, mlkemDecapsulate, mlkemEncapsulate, mlkemGenerateKeypair, mlkemGenerateKeypairUsing, mlkemLevelFromValue, mlkemLevelToString, mlkemPrivateKeySize, mlkemPublicKeySize, mlkemSharedSecretSize, pbkdf2Params, scryptParams, sshAgentParams, sskrCombine, sskrCombineShares, sskrGenerate, sskrGenerateShares, sskrGenerateSharesUsing, sskrGenerateUsing, toBase64 };
|
|
12083
|
+
|
|
12181
12084
|
//# sourceMappingURL=index.mjs.map
|