Skip to content

Commit

Permalink
feat: add getKeyPairFromPublicKey method
Browse files Browse the repository at this point in the history
  • Loading branch information
janek26 committed Dec 13, 2021
1 parent fc1e086 commit 66d543d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/utils/ellipticCurve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export function getStarkKey(keyPair: KeyPair): string {
return addHexPrefix(sanitizeBytes((keyPair as any).pub.getX().toString(16), 2));
}

export function getKeyPairFromPublicKey(publicKey: BigNumberish): KeyPair {
const publicKeyBn = toBN(publicKey);
return ec.keyFromPublic(removeHexPrefix(toHex(publicKeyBn)), 'hex');
}

/*
Signs a message using the provided key.
key should be an KeyPair with a valid private key.
Expand Down

0 comments on commit 66d543d

Please sign in to comment.