payments: the public reader of a receipt is tested on 20 named cases (was 14), including a run with no usable verifier, which now stops before reading the chain and says why (proba-plata-fara-verificator.mjs, new); proba-plata-28001.mjs exits with the reason when the verifier is missing; README counts updated (1255 files).

This commit is contained in:
Aere Network committed 2026-10-28 00:30:32 +02:00
1 parent 687e5e54a4
commit 5f1b781e7f
6 files changed
+269 -75

No files matched your search

+15
View File
@@ -33,6 +33,21 @@ const nem = (m) => { console.log('NEMASURAT: ' + m); process.exit(2); };
let verzi = 0, rosii = 0; const cer = (n, c, d = '') => { console.log(` [${c ? 'VERDE ' : 'ROSU '}] ${n}${d ? ' (' + String(d).slice(0, 220) + ')' : ''}`); c ? verzi++ : rosii++; };
if (!fs.existsSync(KF)) nem('no test key at ' + KF);
let ethers; try { ({ ethers } = createRequire(path.join(ETHERS_DIR, 'package.json'))('ethers')); } catch (e) { nem('ethers not loadable from ' + ETHERS_DIR + ': ' + e.message); }
// 2026-10-27 (R9-S10): the reference verifier is checked BEFORE anything is read from the chain or sent to it. Until this date the probe
// checked only the key and ethers, sent its payments on testnet and came out red only afterwards, on the rows of the verifier, which a
// public clone does not hold at the default path. A probe that cannot measure says so before it spends (proba-plata-fara-verificator.mjs).
const CERE_VP = 'AERE_VERIFY_PROOF=<verify-proof.mjs as served at aere.network/tools, with verify-anchor.mjs, mpt.mjs, falcon512.mjs, registry-v3.mjs and package.json beside it and npm install done there>';
if (!fs.existsSync(VERIFY_PROOF)) nem('no reference verifier at ' + VERIFY_PROOF + '; give ' + CERE_VP);
for (const x of ['verify-anchor.mjs', 'mpt.mjs', 'falcon512.mjs', 'registry-v3.mjs']) if (!fs.existsSync(path.join(path.dirname(VERIFY_PROOF), x))) nem('the reference verifier at ' + VERIFY_PROOF + ' has no ' + x + ' beside it (the finality of a notarization needs it); give ' + CERE_VP);
{
// it must also START: an envelope with a statement and its hash, judged offline (nothing leaves this machine), must come back VALID
const st = { kind: 'aere-probe-start', at: new Date().toISOString() }, f = path.join(os.tmpdir(), 'plata-pornire-' + crypto.randomUUID() + '.json');
fs.writeFileSync(f, JSON.stringify({ statement: st, statementHash: '0x' + crypto.createHash('sha256').update(JSON.stringify(st), 'utf8').digest('hex') }));
let j = null, ultim = '';
try { const r = spawnSync(process.execPath, [VERIFY_PROOF, f, '--json', '--offline'], { encoding: 'utf8', timeout: 120000 }); try { j = JSON.parse(r.stdout); } catch { j = null; } ultim = String(r.stderr || r.stdout || (r.error && r.error.message) || '').split(/\r?\n/).find((l) => /Error/.test(l)) || ''; }
finally { fs.rmSync(f, { force: true }); }
if (!j || j.verdict !== 'VALID') nem('the reference verifier at ' + VERIFY_PROOF + ' does not start or does not judge an envelope offline (' + (j ? 'verdict ' + j.verdict : (ultim.trim().slice(0, 160) || 'no JSON')) + '); give ' + CERE_VP);
}
const cheia = (f) => { const l = fs.readFileSync(f, 'utf8').split(/\r?\n/).map((x) => x.trim()).find((x) => /^(d|PRIVATE_KEY)=/.test(x)) || ''; const h = l.replace(/^(d|PRIVATE_KEY)=/, '').replace(/^0x/, ''); if (!/^[0-9a-fA-F]{1,64}$/.test(h)) nem('the key file has no d=<hex> line'); return '0x' + h.padStart(64, '0'); };
const provider = new ethers.JsonRpcProvider(RPC, undefined, { staticNetwork: false });
const chainId = Number((await provider.getNetwork()).chainId); if (chainId !== 28001) nem(`the RPC serves chain ${chainId}; only testnet 28001`);