From 5d32877357e1bbe58fbc4fca1427be382554e594 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 19 May 2022 16:20:04 +1000 Subject: [PATCH] Remove `Buffer` from `getSignature`, `getHash`, `getPublicKey` --- src/lib/waku_message/version_1.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/waku_message/version_1.ts b/src/lib/waku_message/version_1.ts index acf54530de..600316f5b4 100644 --- a/src/lib/waku_message/version_1.ts +++ b/src/lib/waku_message/version_1.ts @@ -103,7 +103,7 @@ export function clearDecode( if (isSigned) { const signature = getSignature(buf); const hash = getHash(buf, isSigned); - const publicKey = ecRecoverPubKey(hash, signature); + const publicKey = ecRecoverPubKey(hash, Buffer.from(signature)); sig = { signature, publicKey }; } @@ -202,7 +202,7 @@ export function generateSymmetricKey(): Uint8Array { * Return the public key for the given private key, to be used for asymmetric * encryption. */ -export function getPublicKey(privateKey: Uint8Array | Buffer): Uint8Array { +export function getPublicKey(privateKey: Uint8Array): Uint8Array { return secp.getPublicKey(privateKey, false); } @@ -244,11 +244,11 @@ function validateDataIntegrity( ); } -function getSignature(message: Buffer): Buffer { +function getSignature(message: Uint8Array): Uint8Array { return message.slice(message.length - SignatureLength, message.length); } -function getHash(message: Buffer, isSigned: boolean): string { +function getHash(message: Uint8Array, isSigned: boolean): string { if (isSigned) { return keccak256(message.slice(0, message.length - SignatureLength)); }