Skip to content

Commit

Permalink
fix: address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Feb 27, 2025
1 parent 270a36c commit 6d824dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/helpers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ export const generatePrivateKey = (ecCurve: EC, buf: typeof Buffer): Buffer => {
return ecCurve.genKeyPair().getPrivate().toArrayLike(buf);
};

const secp256k1EC = new EC("secp256k1");
const ed25519EC = new EC("ed25519");
let secp256k1EC: EC;
let ed25519EC: EC;

export const getKeyCurve = (keyType: KeyType) => {
if (keyType === KEY_TYPE.SECP256K1) {
if (!secp256k1EC) secp256k1EC = new EC("secp256k1");
return secp256k1EC;
} else if (keyType === KEY_TYPE.ED25519) {
if (!ed25519EC) ed25519EC = new EC("ed25519");
return ed25519EC;
}
throw new Error(`Invalid keyType: ${keyType}`);
Expand Down
3 changes: 2 additions & 1 deletion src/torus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class Torus {
{ verifier, verifierId, extendedVerifierId, keyType }: { verifier: string; verifierId: string; extendedVerifierId?: string; keyType?: KeyType }
): Promise<TorusPublicKey> {
log.info(torusNodePubs, { verifier, verifierId, extendedVerifierId });
return this.getNewPublicAddress(endpoints, { verifier, verifierId, extendedVerifierId, keyType }, this.enableOneKey);
const localKeyType = keyType ?? this.keyType;
return this.getNewPublicAddress(endpoints, { verifier, verifierId, extendedVerifierId, keyType: localKeyType }, this.enableOneKey);
}

async importPrivateKey(params: ImportKeyParams): Promise<TorusKey> {
Expand Down

0 comments on commit 6d824dc

Please sign in to comment.