addEventListener('message', message => {\r
const data = JSON.parse(new TextDecoder().decode(message.data ?? message))\r
for (const d of data) {\r
- d.publicKey = hexify(convert(d.privateKey).publicKey)\r
+ d.publicKey = convert(d.privateKey)\r
}\r
const buf = new TextEncoder().encode(JSON.stringify(data)).buffer\r
postMessage(buf, [buf])\r
function hexify (buf: Uint8Array): string {\r
let str = ''\r
for (let i = 0; i < buf.length; i++) {\r
- if (typeof next !== 'number')\r
- throw new TypeError(`expected number to convert to hex; received ${typeof next}`)\r
- if (next < 0 || next > 255)\r
- throw new RangeError(`expected byte value 0-255; received ${next}`)\r
+ if (typeof buf[i] !== 'number')\r
+ throw new TypeError(`expected number to convert to hex; received ${typeof buf[i]}`)\r
+ if (buf[i] < 0 || buf[i] > 255)\r
+ throw new RangeError(`expected byte value 0-255; received ${buf[i]}`)\r
str += buf[i].toString(16).padStart(2, '0')\r
}\r
return str\r