Skip to content

Commit 80ee266

Browse files
reuse session sigs
1 parent 4935a36 commit 80ee266

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/mpcCoreKit.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,11 +714,12 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
714714
return p.getX().toBuffer("be", 32);
715715
}
716716

717-
public async precompute_secp256k1(): Promise<{
717+
public async precompute_secp256k1(params?: { sessionSignatures?: string[] }): Promise<{
718718
client: Client;
719719
serverCoeffs: Record<string, string>;
720720
signatures: string[];
721721
}> {
722+
const { sessionSignatures } = params || {};
722723
this.wasmLib = await this.loadTssWasm();
723724
// PreSetup
724725
const { tssShareIndex } = this.state;
@@ -767,7 +768,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
767768
throw CoreKitError.activeSessionNotFound();
768769
}
769770

770-
const signatures = await this.getSessionSignatures();
771+
const signatures = sessionSignatures || (await this.getSessionSignatures());
771772
if (!signatures) {
772773
throw CoreKitError.signaturesNotPresent();
773774
}
@@ -1254,7 +1255,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
12541255
if (!postBoxKey || !factorKey || !tssShare || !tssPubKey || !userInfo) {
12551256
throw CoreKitError.userNotLoggedIn();
12561257
}
1257-
const sessionSigs = await this.getSessionSignatures();
1258+
const sessionSigs = this.state.signatures;
12581259
const payload: SessionData = {
12591260
postBoxKey,
12601261
postboxKeyNodeIndexes: postboxKeyNodeIndexes || [],
@@ -1475,7 +1476,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
14751476
throw error;
14761477
}
14771478
// Retry with new client if precomputed client failed, this is to handle the case when precomputed session might have expired
1478-
const { client: newClient, serverCoeffs: newServerCoeffs } = await this.precompute_secp256k1();
1479+
const { client: newClient, serverCoeffs: newServerCoeffs } = await this.precompute_secp256k1({ sessionSignatures: signatures });
14791480
const result = await executeSign(newClient, newServerCoeffs, data, signatures);
14801481

14811482
return result;

0 commit comments

Comments
 (0)