docs: added case clarification for processing keys of different lengths.
This commit is contained in:
parent
b05fd4aebd
commit
27c9563ca5
@ -133,11 +133,13 @@ export class SigningKey {
|
|||||||
static computePublicKey(key: BytesLike, compressed?: boolean): string {
|
static computePublicKey(key: BytesLike, compressed?: boolean): string {
|
||||||
let bytes = getBytes(key, "key");
|
let bytes = getBytes(key, "key");
|
||||||
|
|
||||||
|
// private key
|
||||||
if (bytes.length === 32) {
|
if (bytes.length === 32) {
|
||||||
const pubKey = secp256k1.getPublicKey(bytes, !!compressed);
|
const pubKey = secp256k1.getPublicKey(bytes, !!compressed);
|
||||||
return hexlify(pubKey);
|
return hexlify(pubKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// raw public key; use uncompressed key with 0x04 prefix
|
||||||
if (bytes.length === 64) {
|
if (bytes.length === 64) {
|
||||||
const pub = new Uint8Array(65);
|
const pub = new Uint8Array(65);
|
||||||
pub[0] = 0x04;
|
pub[0] = 0x04;
|
||||||
|
Loading…
Reference in New Issue
Block a user