23 lines
898 B
JavaScript
23 lines
898 B
JavaScript
|
|
#!/usr/bin/env node
|
||
|
|
/**
|
||
|
|
* Preview digest for off-chain attestation signing (fiat / XAU custodian flow).
|
||
|
|
* Uses keccak256(abi.encode(lineId, R, nonce, validUntil, evidenceKind)) — align with ops before HSM.
|
||
|
|
* Usage: node omnl-attestation-payload.mjs <lineId0x> <R> <nonce> <validUntil> <evidenceKind>
|
||
|
|
*/
|
||
|
|
import { keccak256, AbiCoder } from 'ethers';
|
||
|
|
|
||
|
|
const [, , lineId, R, nonce, validUntil, evidenceKind] = process.argv;
|
||
|
|
if (!evidenceKind) {
|
||
|
|
console.error(
|
||
|
|
'Usage: omnl-attestation-payload.mjs <lineId0x> <R> <nonce> <validUntil> <evidenceKind>'
|
||
|
|
);
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
const coder = AbiCoder.defaultAbiCoder();
|
||
|
|
const encoded = coder.encode(
|
||
|
|
['bytes32', 'uint256', 'uint256', 'uint256', 'string'],
|
||
|
|
[lineId, BigInt(R), BigInt(nonce), BigInt(validUntil), evidenceKind]
|
||
|
|
);
|
||
|
|
const digest = keccak256(encoded);
|
||
|
|
process.stdout.write(JSON.stringify({ digest, encoded }, null, 2) + '\n');
|