From: Chris Duncan Date: Tue, 3 Dec 2024 22:55:09 +0000 (-0800) Subject: Fix hexification. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=4868e215b67efb09b59be835d9a8683243689b38;p=libnemo.git Fix hexification. --- diff --git a/src/lib/nano-nacl.ts b/src/lib/nano-nacl.ts index 62d2732..9a38cf8 100644 --- a/src/lib/nano-nacl.ts +++ b/src/lib/nano-nacl.ts @@ -24,7 +24,7 @@ const n = () => { addEventListener('message', message => { const data = JSON.parse(new TextDecoder().decode(message.data ?? message)) for (const d of data) { - d.publicKey = hexify(convert(d.privateKey).publicKey) + d.publicKey = convert(d.privateKey) } const buf = new TextEncoder().encode(JSON.stringify(data)).buffer postMessage(buf, [buf]) @@ -759,10 +759,10 @@ const n = () => { function hexify (buf: Uint8Array): string { let str = '' for (let i = 0; i < buf.length; i++) { - if (typeof next !== 'number') - throw new TypeError(`expected number to convert to hex; received ${typeof next}`) - if (next < 0 || next > 255) - throw new RangeError(`expected byte value 0-255; received ${next}`) + if (typeof buf[i] !== 'number') + throw new TypeError(`expected number to convert to hex; received ${typeof buf[i]}`) + if (buf[i] < 0 || buf[i] > 255) + throw new RangeError(`expected byte value 0-255; received ${buf[i]}`) str += buf[i].toString(16).padStart(2, '0') } return str