docs: added case clarification for processing keys of different lengths.

This commit is contained in:
Richard Moore 2023-01-22 16:38:38 -05:00
parent b05fd4aebd
commit 27c9563ca5

@ -133,11 +133,13 @@ export class SigningKey {
static computePublicKey(key: BytesLike, compressed?: boolean): string {
let bytes = getBytes(key, "key");
// private key
if (bytes.length === 32) {
const pubKey = secp256k1.getPublicKey(bytes, !!compressed);
return hexlify(pubKey);
}
// raw public key; use uncompressed key with 0x04 prefix
if (bytes.length === 64) {
const pub = new Uint8Array(65);
pub[0] = 0x04;