Skip to content

Commit 66d543d

Browse files
committed
feat: add getKeyPairFromPublicKey method
1 parent fc1e086 commit 66d543d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/utils/ellipticCurve.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ export function getStarkKey(keyPair: KeyPair): string {
5353
return addHexPrefix(sanitizeBytes((keyPair as any).pub.getX().toString(16), 2));
5454
}
5555

56+
export function getKeyPairFromPublicKey(publicKey: BigNumberish): KeyPair {
57+
const publicKeyBn = toBN(publicKey);
58+
return ec.keyFromPublic(removeHexPrefix(toHex(publicKeyBn)), 'hex');
59+
}
60+
5661
/*
5762
Signs a message using the provided key.
5863
key should be an KeyPair with a valid private key.

0 commit comments

Comments
 (0)