From 64ea36faa34dc05082b9d0176daa5360c0983a3d Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 19 May 2022 16:44:56 +1000 Subject: [PATCH] Remove `Buffer` from `ecRecoverPubKey` --- src/lib/waku_message/version_1.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/waku_message/version_1.ts b/src/lib/waku_message/version_1.ts index 05c6a2a929..0926fb1d89 100644 --- a/src/lib/waku_message/version_1.ts +++ b/src/lib/waku_message/version_1.ts @@ -252,9 +252,12 @@ function getHash(message: Uint8Array, isSigned: boolean): string { function ecRecoverPubKey( messageHash: string, - signature: Buffer + signature: Uint8Array ): 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)); return secp.recoverPublicKey(