'use strict'; const crypto = require('crypto'); function joined(key, i, j) { i = BigInt(i); j = BigInt(j); if (i > j) [i, j] = [j, i]; const msg = Buffer.alloc(48); key.copy(msg, 0); msg.writeBigUInt64BE(i, 32); msg.writeBigUInt64BE(j, 40); return (crypto.createHash('sha256').update(msg).digest()[0] >> 7) === 1; } if (require.main === module) { const [key, i, j] = process.argv.slice(2); console.log(joined(Buffer.from(key, 'hex'), i, j) ? 1 : 0); } module.exports = { joined };