Remove `buf` variable

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

View File

@ -87,18 +87,16 @@ export async function clearEncode(
export function clearDecode( export function clearDecode(
message: Uint8Array | Buffer message: Uint8Array | Buffer
): { payload: Uint8Array; sig?: Signature } | undefined { ): { payload: Uint8Array; sig?: Signature } | undefined {
const buf = Buffer.from(message);
let start = 1;
let sig;
const sizeOfPayloadSizeField = getSizeOfPayloadSizeField(message); const sizeOfPayloadSizeField = getSizeOfPayloadSizeField(message);
if (sizeOfPayloadSizeField === 0) return; if (sizeOfPayloadSizeField === 0) return;
const payloadSize = getPayloadSize(message, sizeOfPayloadSizeField); const payloadSize = getPayloadSize(message, sizeOfPayloadSizeField);
start += sizeOfPayloadSizeField; const payloadStart = 1 + sizeOfPayloadSizeField;
const payload = buf.slice(start, start + payloadSize); const payload = message.slice(payloadStart, payloadStart + payloadSize);
const isSigned = isMessageSigned(message); const isSigned = isMessageSigned(message);
let sig;
if (isSigned) { if (isSigned) {
const signature = getSignature(message); const signature = getSignature(message);
const hash = getHash(message, isSigned); const hash = getHash(message, isSigned);