// Copyright © Albert Lane. All Rights Reserved. // Proprietary and Confidential — Albert Lane Proprietary Software License. // Unauthorized use, copying, modification, or distribution is prohibited. // License inquiries: https://albertlane.net // t1237 cross-implementation check: JS (Worker core) verifies a Python human signature and co-signs with the TEST ONLY robot key. // Usage: node cross.mjs in.bin out.bin import fs from "node:fs"; import * as B from "../worker/src/binding.js"; const [, , inp, out, albert, robotKey] = process.argv; const p = B.decodePacket(new Uint8Array(fs.readFileSync(inp))); const signer = B.recover(B.hHuman(p), p.human_sig); if (signer !== albert.toLowerCase()) { console.error("JS: human signer mismatch", signer); process.exit(1); } p.robot_sig = B.personalSign(B.hRobot(p.human_sig, p.instr), robotKey); fs.writeFileSync(out, B.encodePacket(p)); console.log(JSON.stringify({ js_human_signer: signer, js_robot_addr: B.addressOfKey(robotKey), h_human: B.hex(B.hHuman(p)), summary: B.summarize(p.decoded), reencode_equal: B.hex(B.encodePacket({ ...p, robot_sig: new Uint8Array(0) })) === B.hex(new Uint8Array(fs.readFileSync(inp))) }));