From 06b4ab581d58b65b9a49da7a550f81819db404f4 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Fri, 20 May 2022 10:26:06 +1000 Subject: [PATCH] Remove `Buffer` from `isMessageSigned` --- src/lib/waku_message/version_1.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/waku_message/version_1.ts b/src/lib/waku_message/version_1.ts index c8d589ee58..aa533e6e96 100644 --- a/src/lib/waku_message/version_1.ts +++ b/src/lib/waku_message/version_1.ts @@ -98,7 +98,7 @@ export function clearDecode( start += sizeOfPayloadSizeField; const payload = buf.slice(start, start + payloadSize); - const isSigned = isMessageSigned(buf); + const isSigned = isMessageSigned(message); if (isSigned) { const signature = getSignature(message); const hash = getHash(message, isSigned); @@ -131,8 +131,9 @@ function getPayloadSize( return payloadSizeDataView.getInt32(0, true); } -function isMessageSigned(message: Buffer): boolean { - return (message.readUIntLE(0, 1) & IsSignedMask) == IsSignedMask; +function isMessageSigned(message: Uint8Array): boolean { + const messageDataView = new DataView(message.buffer); + return (messageDataView.getUint8(0) & IsSignedMask) == IsSignedMask; } /**