@dynamic-labs-wallet/forward-mpc-shared 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +269 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +584 -39
- package/dist/index.d.ts +584 -39
- package/dist/index.js +257 -35
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { either } from 'fp-ts';
|
|
2
|
-
import { Type, failure, success, type, partial, number, string, union, undefined as _undefined, intersection, literal, identity, unknown } from 'io-ts';
|
|
2
|
+
import { Type, failure, success, type, partial, number, string, union, undefined as _undefined, intersection, literal, identity, unknown, array } from 'io-ts';
|
|
3
3
|
import { hexToBytes, bytesToHex, randomBytes } from '@noble/hashes/utils.js';
|
|
4
4
|
import { SigningAlgorithm } from '@dynamic-labs-wallet/core';
|
|
5
5
|
import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
|
|
@@ -82,7 +82,7 @@ var Uint32ArrayCodec = new Type(
|
|
|
82
82
|
return bytesToHex(uint8Array);
|
|
83
83
|
}
|
|
84
84
|
);
|
|
85
|
-
var
|
|
85
|
+
var EncryptedPayloadCodec = type({
|
|
86
86
|
salt: Uint8ArrayCodec,
|
|
87
87
|
encryptedPayload: Uint8ArrayCodec
|
|
88
88
|
});
|
|
@@ -189,7 +189,7 @@ function createSimpleMessage(config) {
|
|
|
189
189
|
...data
|
|
190
190
|
}), "encodeData"),
|
|
191
191
|
decodeData: /* @__PURE__ */ __name((decoded) => {
|
|
192
|
-
const { type:
|
|
192
|
+
const { type: type8, version, ...data } = decoded;
|
|
193
193
|
return data;
|
|
194
194
|
}, "decodeData")
|
|
195
195
|
});
|
|
@@ -468,7 +468,7 @@ var Uint8ArrayOrHexCodec = new Type(
|
|
|
468
468
|
// src/messages/SignMessageV1Request.ts
|
|
469
469
|
var SignMessageRequestSchema = buildMessageSchema("signMessage", 1, {
|
|
470
470
|
relayDomain: DomainCodec,
|
|
471
|
-
keyshare:
|
|
471
|
+
keyshare: EncryptedPayloadCodec,
|
|
472
472
|
message: Uint8ArrayOrHexCodec,
|
|
473
473
|
roomUuid: string,
|
|
474
474
|
userId: OptionalStringCodec,
|
|
@@ -483,7 +483,7 @@ var SignMessageV1RequestMessage = createStandardMessage({
|
|
|
483
483
|
signingAlgo: /* @__PURE__ */ __name((value) => fromDynamicSigningAlgorithm(value), "signingAlgo"),
|
|
484
484
|
derivationPath: /* @__PURE__ */ __name((value) => Uint32ArrayCodec.encode(value), "derivationPath"),
|
|
485
485
|
tweak: /* @__PURE__ */ __name((value) => Uint8ArrayCodec.encode(value), "tweak"),
|
|
486
|
-
keyshare: /* @__PURE__ */ __name((value) =>
|
|
486
|
+
keyshare: /* @__PURE__ */ __name((value) => EncryptedPayloadCodec.encode(value), "keyshare"),
|
|
487
487
|
message: /* @__PURE__ */ __name((value) => Uint8ArrayOrHexCodec.encode(value), "message")
|
|
488
488
|
}),
|
|
489
489
|
decodeData: createStandardDecoder((decoded) => ({
|
|
@@ -553,6 +553,139 @@ var ConnectionAckV1ResponseMessage = createSimpleMessage({
|
|
|
553
553
|
version: 1,
|
|
554
554
|
schema: ConnectionAckResponseSchema
|
|
555
555
|
});
|
|
556
|
+
var BaseKeygenParamsCodec = type({
|
|
557
|
+
relayDomain: DomainCodec,
|
|
558
|
+
roomUuid: string,
|
|
559
|
+
numParties: number,
|
|
560
|
+
threshold: number,
|
|
561
|
+
keygenInit: EncryptedPayloadCodec,
|
|
562
|
+
keygenIds: array(string),
|
|
563
|
+
userId: OptionalStringCodec,
|
|
564
|
+
environmentId: OptionalStringCodec,
|
|
565
|
+
traceContext: TraceContextCodec
|
|
566
|
+
});
|
|
567
|
+
var EcdsaKeygenParamsCodec = type({
|
|
568
|
+
...BaseKeygenParamsCodec.props,
|
|
569
|
+
signingAlgo: literal("ecdsa")
|
|
570
|
+
});
|
|
571
|
+
var BIP340KeygenParamsCodec = type({
|
|
572
|
+
...BaseKeygenParamsCodec.props,
|
|
573
|
+
signingAlgo: literal("bip340")
|
|
574
|
+
});
|
|
575
|
+
var KeygenAlgoParamsCodec = union([
|
|
576
|
+
EcdsaKeygenParamsCodec,
|
|
577
|
+
BIP340KeygenParamsCodec
|
|
578
|
+
]);
|
|
579
|
+
var KeygenRequestSchema = buildMessageSchema("keygen", 1, {
|
|
580
|
+
relayDomain: DomainCodec,
|
|
581
|
+
roomUuid: string,
|
|
582
|
+
numParties: number,
|
|
583
|
+
threshold: number,
|
|
584
|
+
keygenInit: EncryptedPayloadCodec,
|
|
585
|
+
keygenIds: array(string),
|
|
586
|
+
userId: OptionalStringCodec,
|
|
587
|
+
environmentId: OptionalStringCodec,
|
|
588
|
+
traceContext: TraceContextCodec
|
|
589
|
+
}, KeygenAlgoParamsCodec);
|
|
590
|
+
var KeygenV1RequestMessage = createStandardMessage({
|
|
591
|
+
messageType: "keygen",
|
|
592
|
+
version: 1,
|
|
593
|
+
schema: KeygenRequestSchema,
|
|
594
|
+
encodeData: createComplexEncoder("keygen", 1, {
|
|
595
|
+
signingAlgo: /* @__PURE__ */ __name((value) => fromDynamicSigningAlgorithm(value), "signingAlgo"),
|
|
596
|
+
keygenInit: /* @__PURE__ */ __name((value) => EncryptedPayloadCodec.encode(value), "keygenInit")
|
|
597
|
+
}),
|
|
598
|
+
decodeData: createStandardDecoder((decoded) => ({
|
|
599
|
+
relayDomain: decoded.relayDomain,
|
|
600
|
+
signingAlgo: decoded.signingAlgo,
|
|
601
|
+
roomUuid: decoded.roomUuid,
|
|
602
|
+
numParties: decoded.numParties,
|
|
603
|
+
threshold: decoded.threshold,
|
|
604
|
+
keygenInit: decoded.keygenInit,
|
|
605
|
+
keygenIds: decoded.keygenIds,
|
|
606
|
+
userId: decoded.userId,
|
|
607
|
+
environmentId: decoded.environmentId,
|
|
608
|
+
traceContext: decoded.traceContext
|
|
609
|
+
}))
|
|
610
|
+
});
|
|
611
|
+
var KeygenResponseSchema = buildMessageSchema("keygen_response", 1, {
|
|
612
|
+
keygenResult: union([
|
|
613
|
+
EncryptedPayloadCodec,
|
|
614
|
+
_undefined
|
|
615
|
+
]),
|
|
616
|
+
error: union([
|
|
617
|
+
WebSocketErrorCodec,
|
|
618
|
+
_undefined
|
|
619
|
+
])
|
|
620
|
+
});
|
|
621
|
+
var KeygenV1ResponseMessage = createStandardMessage({
|
|
622
|
+
messageType: "keygen_response",
|
|
623
|
+
version: 1,
|
|
624
|
+
schema: KeygenResponseSchema,
|
|
625
|
+
encodeData: createComplexEncoder("keygen_response", 1, {
|
|
626
|
+
keygenResult: /* @__PURE__ */ __name((value) => EncryptedPayloadCodec.encode(value), "keygenResult")
|
|
627
|
+
}),
|
|
628
|
+
decodeData: createStandardDecoder((decoded) => ({
|
|
629
|
+
keygenResult: decoded.keygenResult,
|
|
630
|
+
error: decoded.error
|
|
631
|
+
}))
|
|
632
|
+
});
|
|
633
|
+
var ReceiveKeyRequestSchema = buildMessageSchema("receiveKey", 1, {
|
|
634
|
+
relayDomain: DomainCodec,
|
|
635
|
+
signingAlgo: literal("ed25519"),
|
|
636
|
+
roomUuid: string,
|
|
637
|
+
numParties: number,
|
|
638
|
+
threshold: number,
|
|
639
|
+
keygenInit: EncryptedPayloadCodec,
|
|
640
|
+
keygenIds: array(string),
|
|
641
|
+
userId: OptionalStringCodec,
|
|
642
|
+
environmentId: OptionalStringCodec,
|
|
643
|
+
traceContext: TraceContextCodec
|
|
644
|
+
});
|
|
645
|
+
var ReceiveKeyV1RequestMessage = createStandardMessage({
|
|
646
|
+
messageType: "receiveKey",
|
|
647
|
+
version: 1,
|
|
648
|
+
schema: ReceiveKeyRequestSchema,
|
|
649
|
+
encodeData: /* @__PURE__ */ __name((data) => ReceiveKeyRequestSchema.encode({
|
|
650
|
+
type: "receiveKey",
|
|
651
|
+
version: 1,
|
|
652
|
+
...data
|
|
653
|
+
}), "encodeData"),
|
|
654
|
+
decodeData: createStandardDecoder((decoded) => ({
|
|
655
|
+
relayDomain: decoded.relayDomain,
|
|
656
|
+
signingAlgo: decoded.signingAlgo,
|
|
657
|
+
roomUuid: decoded.roomUuid,
|
|
658
|
+
numParties: decoded.numParties,
|
|
659
|
+
threshold: decoded.threshold,
|
|
660
|
+
keygenInit: decoded.keygenInit,
|
|
661
|
+
keygenIds: decoded.keygenIds,
|
|
662
|
+
userId: decoded.userId,
|
|
663
|
+
environmentId: decoded.environmentId,
|
|
664
|
+
traceContext: decoded.traceContext
|
|
665
|
+
}))
|
|
666
|
+
});
|
|
667
|
+
var ReceiveKeyResponseSchema = buildMessageSchema("receiveKey_response", 1, {
|
|
668
|
+
keygenResult: union([
|
|
669
|
+
EncryptedPayloadCodec,
|
|
670
|
+
_undefined
|
|
671
|
+
]),
|
|
672
|
+
error: union([
|
|
673
|
+
WebSocketErrorCodec,
|
|
674
|
+
_undefined
|
|
675
|
+
])
|
|
676
|
+
});
|
|
677
|
+
var ReceiveKeyV1ResponseMessage = createStandardMessage({
|
|
678
|
+
messageType: "receiveKey_response",
|
|
679
|
+
version: 1,
|
|
680
|
+
schema: ReceiveKeyResponseSchema,
|
|
681
|
+
encodeData: createComplexEncoder("receiveKey_response", 1, {
|
|
682
|
+
keygenResult: /* @__PURE__ */ __name((value) => EncryptedPayloadCodec.encode(value), "keygenResult")
|
|
683
|
+
}),
|
|
684
|
+
decodeData: createStandardDecoder((decoded) => ({
|
|
685
|
+
keygenResult: decoded.keygenResult,
|
|
686
|
+
error: decoded.error
|
|
687
|
+
}))
|
|
688
|
+
});
|
|
556
689
|
|
|
557
690
|
// src/messages/allMessages.ts
|
|
558
691
|
var ALL_MESSAGE_CLASSES = {
|
|
@@ -561,37 +694,41 @@ var ALL_MESSAGE_CLASSES = {
|
|
|
561
694
|
"signMessage@1": SignMessageV1RequestMessage,
|
|
562
695
|
"signMessage_response@1": SignMessageV1ResponseMessage,
|
|
563
696
|
"connection_ack@1": ConnectionAckV1RequestMessage,
|
|
564
|
-
"connection_ack_response@1": ConnectionAckV1ResponseMessage
|
|
697
|
+
"connection_ack_response@1": ConnectionAckV1ResponseMessage,
|
|
698
|
+
"keygen@1": KeygenV1RequestMessage,
|
|
699
|
+
"keygen_response@1": KeygenV1ResponseMessage,
|
|
700
|
+
"receiveKey@1": ReceiveKeyV1RequestMessage,
|
|
701
|
+
"receiveKey_response@1": ReceiveKeyV1ResponseMessage
|
|
565
702
|
};
|
|
566
703
|
var ALL_MESSAGE_KEYS = Object.keys(ALL_MESSAGE_CLASSES);
|
|
567
|
-
function getMessageClass(
|
|
568
|
-
const key = `${
|
|
704
|
+
function getMessageClass(type8, version) {
|
|
705
|
+
const key = `${type8}@${version}`;
|
|
569
706
|
const MessageClass = ALL_MESSAGE_CLASSES[key];
|
|
570
707
|
if (!MessageClass) {
|
|
571
|
-
throw new Error(`Unknown message type: ${
|
|
708
|
+
throw new Error(`Unknown message type: ${type8} version ${version}`);
|
|
572
709
|
}
|
|
573
710
|
return MessageClass;
|
|
574
711
|
}
|
|
575
712
|
__name(getMessageClass, "getMessageClass");
|
|
576
|
-
function isValidMessageType(
|
|
577
|
-
const key = `${
|
|
713
|
+
function isValidMessageType(type8, version) {
|
|
714
|
+
const key = `${type8}@${version}`;
|
|
578
715
|
return key in ALL_MESSAGE_CLASSES;
|
|
579
716
|
}
|
|
580
717
|
__name(isValidMessageType, "isValidMessageType");
|
|
581
718
|
function getAllSupportedMessages() {
|
|
582
719
|
return ALL_MESSAGE_KEYS.map((key) => {
|
|
583
|
-
const [
|
|
720
|
+
const [type8, versionStr] = key.split("@");
|
|
584
721
|
return {
|
|
585
|
-
type:
|
|
722
|
+
type: type8,
|
|
586
723
|
version: parseInt(versionStr, 10)
|
|
587
724
|
};
|
|
588
725
|
});
|
|
589
726
|
}
|
|
590
727
|
__name(getAllSupportedMessages, "getAllSupportedMessages");
|
|
591
728
|
function parseMessageKey(key) {
|
|
592
|
-
const [
|
|
729
|
+
const [type8, versionStr] = key.split("@");
|
|
593
730
|
return {
|
|
594
|
-
type:
|
|
731
|
+
type: type8,
|
|
595
732
|
version: parseInt(versionStr, 10)
|
|
596
733
|
};
|
|
597
734
|
}
|
|
@@ -614,9 +751,9 @@ var MessageRegistry = class _MessageRegistry {
|
|
|
614
751
|
/**
|
|
615
752
|
* Get a message class by type and version (derived from single source)
|
|
616
753
|
*/
|
|
617
|
-
getMessageClass(
|
|
754
|
+
getMessageClass(type8, version) {
|
|
618
755
|
try {
|
|
619
|
-
return getMessageClass(
|
|
756
|
+
return getMessageClass(type8, version);
|
|
620
757
|
} catch {
|
|
621
758
|
return void 0;
|
|
622
759
|
}
|
|
@@ -631,18 +768,18 @@ var MessageRegistry = class _MessageRegistry {
|
|
|
631
768
|
left: "Invalid wire data: must be an object"
|
|
632
769
|
};
|
|
633
770
|
}
|
|
634
|
-
const { type:
|
|
635
|
-
if (!
|
|
771
|
+
const { type: type8, version } = wireData;
|
|
772
|
+
if (!type8 || !version) {
|
|
636
773
|
return {
|
|
637
774
|
_tag: "Left",
|
|
638
775
|
left: "Invalid wire data: missing type or version"
|
|
639
776
|
};
|
|
640
777
|
}
|
|
641
|
-
const MessageClass = this.getMessageClass(
|
|
778
|
+
const MessageClass = this.getMessageClass(type8, version);
|
|
642
779
|
if (!MessageClass) {
|
|
643
780
|
return {
|
|
644
781
|
_tag: "Left",
|
|
645
|
-
left: `Unknown message type: ${
|
|
782
|
+
left: `Unknown message type: ${type8}@${version}`
|
|
646
783
|
};
|
|
647
784
|
}
|
|
648
785
|
const result = MessageClass.decode(wireData);
|
|
@@ -667,7 +804,7 @@ var MessageRegistry = class _MessageRegistry {
|
|
|
667
804
|
* Get all registered message types (derived from single source)
|
|
668
805
|
*/
|
|
669
806
|
getRegisteredTypes() {
|
|
670
|
-
return getAllSupportedMessages().map(({ type:
|
|
807
|
+
return getAllSupportedMessages().map(({ type: type8, version }) => `${type8}@${version}`);
|
|
671
808
|
}
|
|
672
809
|
};
|
|
673
810
|
var messageRegistry = MessageRegistry.getInstance();
|
|
@@ -715,6 +852,13 @@ var AES_256_GCM_KEY_SIZE = 32;
|
|
|
715
852
|
var AES_256_GCM_NONCE_SIZE = 12;
|
|
716
853
|
var AES_256_GCM_TAG_SIZE = 16;
|
|
717
854
|
var HKDF_SALT_SIZE = 32;
|
|
855
|
+
var EncryptionPurpose = /* @__PURE__ */ (function(EncryptionPurpose2) {
|
|
856
|
+
EncryptionPurpose2["KEYSHARE"] = "keyshare";
|
|
857
|
+
EncryptionPurpose2["KEYGEN_INIT"] = "keygen_init";
|
|
858
|
+
EncryptionPurpose2["KEYGEN_RESULT"] = "keygen_result";
|
|
859
|
+
EncryptionPurpose2["TEST"] = "test";
|
|
860
|
+
return EncryptionPurpose2;
|
|
861
|
+
})({});
|
|
718
862
|
function deriveAESKey(sharedSecret, salt, info) {
|
|
719
863
|
const infoBytes = new TextEncoder().encode(info);
|
|
720
864
|
return hkdf(sha256, sharedSecret, salt, infoBytes, AES_256_GCM_KEY_SIZE);
|
|
@@ -724,19 +868,23 @@ function createKeyDerivationInfo(purpose, connectionId, version = 1) {
|
|
|
724
868
|
return `forward-mpc-${purpose}-v${version}-${connectionId}`;
|
|
725
869
|
}
|
|
726
870
|
__name(createKeyDerivationInfo, "createKeyDerivationInfo");
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
871
|
+
var HKDF_SALT_SIZE2 = 32;
|
|
872
|
+
var AES_GCM_NONCE_SIZE = 12;
|
|
873
|
+
var MIN_SHARED_SECRET_SIZE = 32;
|
|
874
|
+
function encryptPayload(options) {
|
|
875
|
+
const { payload, sharedSecret, connectionId, purpose } = options;
|
|
876
|
+
if (!sharedSecret || sharedSecret.length < MIN_SHARED_SECRET_SIZE) {
|
|
877
|
+
throw new Error(`Invalid shared secret: must be at least ${MIN_SHARED_SECRET_SIZE} bytes`);
|
|
878
|
+
}
|
|
879
|
+
if (!connectionId || connectionId.trim().length === 0) {
|
|
880
|
+
throw new Error("Invalid connectionId: must be non-empty string");
|
|
881
|
+
}
|
|
882
|
+
const salt = randomBytes(HKDF_SALT_SIZE2);
|
|
883
|
+
const info = createKeyDerivationInfo(purpose, connectionId);
|
|
884
|
+
const aesKey = deriveAESKey(sharedSecret, salt, info);
|
|
885
|
+
const nonce = randomBytes(AES_GCM_NONCE_SIZE);
|
|
738
886
|
const aes256Gcm = gcm(aesKey, nonce);
|
|
739
|
-
const plaintext = new TextEncoder().encode(JSON.stringify(
|
|
887
|
+
const plaintext = new TextEncoder().encode(JSON.stringify(payload));
|
|
740
888
|
const ciphertext = aes256Gcm.encrypt(plaintext);
|
|
741
889
|
const encryptedPayload = new Uint8Array(nonce.length + ciphertext.length);
|
|
742
890
|
encryptedPayload.set(nonce, 0);
|
|
@@ -747,8 +895,82 @@ async function encryptKeyshare(keyshare, sharedSecret, connectionId, signingAlgo
|
|
|
747
895
|
encryptedPayload
|
|
748
896
|
};
|
|
749
897
|
}
|
|
898
|
+
__name(encryptPayload, "encryptPayload");
|
|
899
|
+
function decryptPayload(options) {
|
|
900
|
+
const { encrypted, sharedSecret, connectionId, purpose } = options;
|
|
901
|
+
if (!sharedSecret || sharedSecret.length < MIN_SHARED_SECRET_SIZE) {
|
|
902
|
+
throw new Error(`Invalid shared secret: must be at least ${MIN_SHARED_SECRET_SIZE} bytes`);
|
|
903
|
+
}
|
|
904
|
+
if (!connectionId || connectionId.trim().length === 0) {
|
|
905
|
+
throw new Error("Invalid connectionId: must be non-empty string");
|
|
906
|
+
}
|
|
907
|
+
if (!encrypted.encryptedPayload || encrypted.encryptedPayload.length < AES_GCM_NONCE_SIZE) {
|
|
908
|
+
throw new Error(`Invalid encrypted payload: must be at least ${AES_GCM_NONCE_SIZE} bytes`);
|
|
909
|
+
}
|
|
910
|
+
const info = createKeyDerivationInfo(purpose, connectionId);
|
|
911
|
+
const aesKey = deriveAESKey(sharedSecret, encrypted.salt, info);
|
|
912
|
+
const nonce = encrypted.encryptedPayload.slice(0, AES_GCM_NONCE_SIZE);
|
|
913
|
+
const ciphertext = encrypted.encryptedPayload.slice(AES_GCM_NONCE_SIZE);
|
|
914
|
+
const aes256Gcm = gcm(aesKey, nonce);
|
|
915
|
+
const plaintext = aes256Gcm.decrypt(ciphertext);
|
|
916
|
+
const decryptedText = new TextDecoder().decode(plaintext);
|
|
917
|
+
const data = JSON.parse(decryptedText);
|
|
918
|
+
aesKey.fill(0);
|
|
919
|
+
return data;
|
|
920
|
+
}
|
|
921
|
+
__name(decryptPayload, "decryptPayload");
|
|
922
|
+
function encryptKeyshare(keyshare, sharedSecret, connectionId, signingAlgorithm) {
|
|
923
|
+
const keyshareData = {
|
|
924
|
+
keyshare,
|
|
925
|
+
signingAlgorithm,
|
|
926
|
+
timestamp: Date.now(),
|
|
927
|
+
nonce: bytesToHex(randomBytes(16))
|
|
928
|
+
};
|
|
929
|
+
return encryptPayload({
|
|
930
|
+
payload: keyshareData,
|
|
931
|
+
sharedSecret,
|
|
932
|
+
connectionId,
|
|
933
|
+
purpose: EncryptionPurpose.KEYSHARE
|
|
934
|
+
});
|
|
935
|
+
}
|
|
750
936
|
__name(encryptKeyshare, "encryptKeyshare");
|
|
751
937
|
|
|
938
|
+
// src/crypto/keygenEncryption.ts
|
|
939
|
+
function encryptKeygenInit(keygenInit, sharedSecret, connectionId) {
|
|
940
|
+
if (!keygenInit.keygenId || keygenInit.keygenId.trim().length === 0) {
|
|
941
|
+
throw new Error("Invalid keygenInit: keygenId must be non-empty string");
|
|
942
|
+
}
|
|
943
|
+
if (!keygenInit.keygenSecret || keygenInit.keygenSecret.trim().length === 0) {
|
|
944
|
+
throw new Error("Invalid keygenInit: keygenSecret must be non-empty string");
|
|
945
|
+
}
|
|
946
|
+
return encryptPayload({
|
|
947
|
+
payload: keygenInit,
|
|
948
|
+
sharedSecret,
|
|
949
|
+
connectionId,
|
|
950
|
+
purpose: EncryptionPurpose.KEYGEN_INIT
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
__name(encryptKeygenInit, "encryptKeygenInit");
|
|
954
|
+
function decryptKeygenResult(encrypted, sharedSecret, connectionId) {
|
|
955
|
+
const data = decryptPayload({
|
|
956
|
+
encrypted,
|
|
957
|
+
sharedSecret,
|
|
958
|
+
connectionId,
|
|
959
|
+
purpose: EncryptionPurpose.KEYGEN_RESULT
|
|
960
|
+
});
|
|
961
|
+
if (!data.pubkey || !Array.isArray(data.pubkey)) {
|
|
962
|
+
throw new Error("Invalid keygen result: pubkey must be an array");
|
|
963
|
+
}
|
|
964
|
+
if (!data.secretShare || typeof data.secretShare !== "string" || data.secretShare.trim().length === 0) {
|
|
965
|
+
throw new Error("Invalid keygen result: secretShare must be non-empty string");
|
|
966
|
+
}
|
|
967
|
+
return {
|
|
968
|
+
pubkey: new Uint8Array(data.pubkey),
|
|
969
|
+
secretShare: data.secretShare
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
__name(decryptKeygenResult, "decryptKeygenResult");
|
|
973
|
+
|
|
752
974
|
// src/signing/registry.ts
|
|
753
975
|
var SigningAlgorithmRegistry = class SigningAlgorithmRegistry2 {
|
|
754
976
|
static {
|
|
@@ -785,6 +1007,6 @@ var SigningAlgorithmRegistry = class SigningAlgorithmRegistry2 {
|
|
|
785
1007
|
};
|
|
786
1008
|
var signingAlgorithmRegistry = new SigningAlgorithmRegistry();
|
|
787
1009
|
|
|
788
|
-
export { AES_256_GCM_KEY_SIZE, AES_256_GCM_NONCE_SIZE, AES_256_GCM_TAG_SIZE, ALGORITHMS, ALL_MESSAGE_CLASSES, ALL_MESSAGE_KEYS, ALL_SIGNING_ALGORITHM_NAMES, ALL_SIGNING_ALGORITHM_SCHEMA, BIP340SigningAlgorithm, BaseMessage, BaseSigningAlgorithm, ConnectionAckRequestSchema, ConnectionAckResponseSchema, ConnectionAckV1RequestMessage, ConnectionAckV1ResponseMessage, EcdsaSigningAlgorithm, Ed25519SigningAlgorithm,
|
|
1010
|
+
export { AES_256_GCM_KEY_SIZE, AES_256_GCM_NONCE_SIZE, AES_256_GCM_TAG_SIZE, ALGORITHMS, ALL_MESSAGE_CLASSES, ALL_MESSAGE_KEYS, ALL_SIGNING_ALGORITHM_NAMES, ALL_SIGNING_ALGORITHM_SCHEMA, BIP340SigningAlgorithm, BaseMessage, BaseSigningAlgorithm, ConnectionAckRequestSchema, ConnectionAckResponseSchema, ConnectionAckV1RequestMessage, ConnectionAckV1ResponseMessage, EcdsaSigningAlgorithm, Ed25519SigningAlgorithm, EncryptedPayloadCodec, EncryptionPurpose, HKDF_SALT_SIZE, HandshakeRequestSchema, HandshakeResponseSchema, HandshakeV1RequestMessage, HandshakeV1ResponseMessage, KeygenRequestSchema, KeygenResponseSchema, KeygenV1RequestMessage, KeygenV1ResponseMessage, MessageRegistry, OptionalStringCodec, ReceiveKeyRequestSchema, ReceiveKeyResponseSchema, ReceiveKeyV1RequestMessage, ReceiveKeyV1ResponseMessage, SIGNING_ALGORITHM_CLASSES, SIGNING_ALGORITHM_INSTANCES, SignMessageRequestSchema, SignMessageResponseSchema, SignMessageV1RequestMessage, SignMessageV1ResponseMessage, SignatureAlgoSchema, TraceContextCodec, Uint32ArrayCodec, Uint8ArrayCodec, WebSocketErrorType, assertDefined, assertNotNull, createKeyDerivationInfo, createKeygenResultFromSecretShare, decapsulateMlKem768, decryptKeygenResult, decryptPayload, deriveAESKey, encapsulateMlKem768, encryptKeygenInit, encryptKeyshare, encryptPayload, fromDynamicSigningAlgorithm, generateMlKem768Keypair, getAllSupportedMessages, getDefined, getMessageClass, isValidMessageType, isValidSigningAlgorithm, messageRegistry, parseMessageKey, signingAlgorithmRegistry, toDynamicSigningAlgorithm };
|
|
789
1011
|
//# sourceMappingURL=index.js.map
|
|
790
1012
|
//# sourceMappingURL=index.js.map
|