Skip to content

Commit

Permalink
add import key flow to loginWithJWt
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu committed Aug 22, 2024
1 parent f98c953 commit d3ce6ae
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/mpcCoreKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ export class Web3AuthMPCCoreKit implements ICoreKit {

let importTssKey = providedImportTssKey;

// use import key flow by default for ed25519
if (!importTssKey && !this.options.useDkg) {
if (this.keyType === KeyType.ed25519) {
importTssKey = bytesToHex(randomBytes(32));
Expand Down Expand Up @@ -380,8 +379,17 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
throw CoreKitError.prefetchValueExceeded(`The prefetch value '${prefetchTssPublicKeys}' exceeds the maximum allowed limit of 3.`);
}

const { verifier, verifierId, idToken, importTssKey } = params;

const { verifier, verifierId, idToken, importTssKey: providedImportTssKey } = params;
let importTssKey = providedImportTssKey;
if (!importTssKey && !this.options.useDkg) {
if (this.keyType === KeyType.ed25519) {
importTssKey = bytesToHex(randomBytes(32));
} else if (this.keyType === KeyType.secp256k1) {
importTssKey = generateFactorKey().private.toString("hex", 64);
} else {
throw CoreKitError.default("Unsupported key type");
}
}
this.torusSp.verifierName = verifier;
this.torusSp.verifierId = verifierId;

Expand Down

0 comments on commit d3ce6ae

Please sign in to comment.