Skip to content

Commit 7723c8a

Browse files
committed
fix: get keyType and SigType from frostLib
1 parent 214e1e9 commit 7723c8a

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/mpcCoreKit.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,10 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
916916
if (!frostlib) {
917917
throw CoreKitError.default(`frostlib not loaded for ed25519`);
918918
}
919-
return this.sign_frost({ data: Buffer.from(data), keyType: KeyType.secp256k1, sigType: SIG_TYPE.BIP340, frostlib, keyTweak: opts?.keyTweak });
919+
if (frostlib.keyType !== KeyType.secp256k1) {
920+
throw CoreKitError.default("frostlib keyType not matched");
921+
}
922+
return this.sign_frost({ data: Buffer.from(data), frostlib, keyTweak: opts?.keyTweak });
920923
}
921924

922925
public async signEd25519(data: Uint8Array) {
@@ -932,7 +935,10 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
932935
if (!frostlib) {
933936
throw CoreKitError.default(`frostlib not loaded for ed25519`);
934937
}
935-
return this.sign_frost({ data: Buffer.from(data), keyType: KeyType.ed25519, sigType: SIG_TYPE.ED25519, frostlib });
938+
if (frostlib.keyType !== KeyType.ed25519) {
939+
throw CoreKitError.default(`frostlib keyType not matched - forstlib keyType ${frostlib.keyType}`);
940+
}
941+
return this.sign_frost({ data: Buffer.from(data), frostlib });
936942
}
937943

938944
// mutation function
@@ -1672,14 +1678,12 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
16721678
}
16731679
}
16741680

1675-
private async sign_frost(args: {
1676-
data: Buffer;
1677-
keyTweak?: BN;
1678-
keyType: KeyType;
1679-
sigType: WEB3AUTH_SIG_TYPE;
1680-
frostlib: FrostWasmLibEd25519 | FrostWasmLibBip340;
1681-
}): Promise<Buffer> {
1682-
const { data, keyTweak, keyType, sigType, frostlib } = args;
1681+
private async sign_frost(args: { data: Buffer; keyTweak?: BN; frostlib: FrostWasmLibEd25519 | FrostWasmLibBip340 }): Promise<Buffer> {
1682+
const { data, keyTweak, frostlib } = args;
1683+
1684+
const keyType = frostlib.keyType as KeyType;
1685+
const sigType = frostlib.sigType as WEB3AUTH_SIG_TYPE;
1686+
16831687
const nodeDetails = fetchLocalConfig(this.options.web3AuthNetwork, keyType, sigType);
16841688
if (!nodeDetails.torusNodeTSSEndpoints) {
16851689
throw CoreKitError.default("could not fetch tss node endpoints");

0 commit comments

Comments
 (0)