Remove `Buffer` from `isMessageSigned`

This commit is contained in:
Franck Royer 2022-05-20 10:26:06 +10:00
parent ce0c5cef07
commit 06b4ab581d
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 4 additions and 3 deletions

View File

@ -98,7 +98,7 @@ export function clearDecode(
start += sizeOfPayloadSizeField; start += sizeOfPayloadSizeField;
const payload = buf.slice(start, start + payloadSize); const payload = buf.slice(start, start + payloadSize);
const isSigned = isMessageSigned(buf); const isSigned = isMessageSigned(message);
if (isSigned) { if (isSigned) {
const signature = getSignature(message); const signature = getSignature(message);
const hash = getHash(message, isSigned); const hash = getHash(message, isSigned);
@ -131,8 +131,9 @@ function getPayloadSize(
return payloadSizeDataView.getInt32(0, true); return payloadSizeDataView.getInt32(0, true);
} }
function isMessageSigned(message: Buffer): boolean { function isMessageSigned(message: Uint8Array): boolean {
return (message.readUIntLE(0, 1) & IsSignedMask) == IsSignedMask; const messageDataView = new DataView(message.buffer);
return (messageDataView.getUint8(0) & IsSignedMask) == IsSignedMask;
} }
/** /**