Remove `Buffer` from `ecRecoverPubKey`

This commit is contained in:
Franck Royer 2022-05-19 16:44:56 +10:00
parent 76777744f0
commit 64ea36faa3
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 5 additions and 2 deletions

View File

@ -252,9 +252,12 @@ function getHash(message: Uint8Array, isSigned: boolean): string {
function ecRecoverPubKey( function ecRecoverPubKey(
messageHash: string, messageHash: string,
signature: Buffer signature: Uint8Array
): Uint8Array | undefined { ): Uint8Array | undefined {
const recovery = signature.slice(64).readIntBE(0, 1); // TODO: This is only needed because we are getting a `Buffer` instance.
signature = new Uint8Array(signature);
const recoveryDataView = new DataView(signature.slice(64).buffer);
const recovery = recoveryDataView.getUint8(0);
const _signature = secp.Signature.fromCompact(signature.slice(0, 64)); const _signature = secp.Signature.fromCompact(signature.slice(0, 64));
return secp.recoverPublicKey( return secp.recoverPublicKey(