Skip to content

Commit

Permalink
add factor manager interface
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshuchawla009 committed Jan 23, 2025
1 parent b678f3c commit 5d41e01
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
23 changes: 18 additions & 5 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import BN from "bn.js";

import { FactorKeyTypeShareDescription, TssShareType, USER_PATH, WEB3AUTH_NETWORK } from "./constants";
import { ISessionSigGenerator } from "./plugins/SessionSigGenerator/ISessionSigGenerator";
import { IDklsSignConfig, IFrostSignConfig, IRemoteFactor } from "./plugins/Signer/ISigner";
import { IDklsSignConfig, IFrostSignConfig, IRemoteFactor, ISigner } from "./plugins/Signer/ISigner";

export type CoreKitMode = UX_MODE_TYPE | "nodejs" | "react-native";

Expand Down Expand Up @@ -358,13 +358,26 @@ export interface ISignerContext {
}>;
preSetupDKLSSigningConfig(): Promise<IDklsSignConfig>;
preSetupFrostSigningConfig(): Promise<IFrostSignConfig>;
setCustomSigner(customSigner: ISigner, remoteFactor?: IRemoteFactor): Promise<void>;
}

export interface IFactorManagerContext {
stateEmitter: SafeEventEmitter;
config: Web3AuthOptionsWithDefaults;
status: COREKIT_STATUS;
state: Web3AuthState;
tKey: TKeyTSS;
keyType: KeyType;
sigType: SigType;
verifier: string;
verifierId: string;
getWeb3AuthNetwork(): WEB3AUTH_NETWORK_TYPE;
createFactor(createFactorParams: CreateFactorParams): Promise<string>;
inputFactorKey(factorKey: string): Promise<void>;
deleteFactor(factorPub: TkeyPoint, factorKey?: BNString): Promise<void>;
getKeyDetails(): Record<string, unknown> & { shareDescriptions: ShareDescriptionMap };
getMetadataKey(): string | undefined;
getMetadataPublicKey(): string | undefined;
getWeb3AuthNetwork(): WEB3AUTH_NETWORK_TYPE;
getKeyDetails(): Record<string, unknown> & {
shareDescriptions: ShareDescriptionMap;
};
}

export interface IMPCContext {
Expand Down
2 changes: 2 additions & 0 deletions src/mpcCoreKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
Web3AuthOptionsWithDefaults,
Web3AuthState,
} from "./interfaces";
import { DefaultSignerPlugin } from "./plugins";
import { DefaultSessionSigGeneratorPlugin } from "./plugins/SessionSigGenerator/DefaultSessionSigGenerator";
import { ISessionSigGenerator } from "./plugins/SessionSigGenerator/ISessionSigGenerator";
import { IDklsSignConfig, IFrostSignConfig, IRemoteFactor, ISigner } from "./plugins/Signer/ISigner";
Expand Down Expand Up @@ -140,6 +141,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext, ISignerContext
if (!options.hashedFactorNonce) options.hashedFactorNonce = options.web3AuthClientId;
if (options.disableSessionManager === undefined) options.disableSessionManager = false;
this.sessionSigGenerator = new DefaultSessionSigGeneratorPlugin(this);
this.signer = new DefaultSignerPlugin(this);
this.options = options as Web3AuthOptionsWithDefaults;

this.currentStorage = new AsyncStorage(this._storageBaseKey, options.storage);
Expand Down
8 changes: 0 additions & 8 deletions src/plugins/Signer/DefaultSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ export class DefaultSignerPlugin implements ISigner {
data = keccak256(data);
}

// // Custom Dkls Sign
// if (this.customDklsSign) {
// // PreSetup
// const setupSigningParams = await this.context.preSetupSigning();
// const result = await this.customDklsSign(setupSigningParams, data);
// return result;
// }

const isAlreadyPrecomputed = precomputedTssClient?.client && precomputedTssClient?.serverCoeffs;
const { client, serverCoeffs, signatures } = isAlreadyPrecomputed ? precomputedTssClient : await this.context.precomputeSecp256k1();

Expand Down

0 comments on commit 5d41e01

Please sign in to comment.