conformance: the identity presentation verifier enrolled (134 rules of 10 verifiers, 273 vectors); the reference verifier instruction names all five files beside verify-proof.mjs; module READMEs point to aere.network/tools

This commit is contained in:
Aere Network committed 2026-10-05 18:53:32 +03:00
1 parent c9798a0013
commit 5fb38c5d0b
88 files changed
+20246 -179

No files matched your search

+47 -4
View File
@@ -16,7 +16,7 @@
// vectors need the AIP-23 reference verifier (AERE_VERIFY_PROOF=<verify-proof.mjs>, with `npm install` done beside it); --online
// reads testnet 28001 (nothing is sent).
import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { spawn, spawnSync } from 'node:child_process'; import { fileURLToPath, pathToFileURL } from 'node:url';
import { deriva, hartaPublica, VERIFICATOARE, MODULE, VERIFY_PROOF, FINALITY_SITES, incarca, marcajul } from './reguli.mjs';
import { deriva, hartaPublica, VERIFICATOARE, MODULE, VERIFY_PROOF, FINALITY_SITES, NEJUDECATE_IDENTITY, incarca, marcajul } from './reguli.mjs';
import { incarcaVectorii, ruleazaSuita } from './conformance.mjs';
import { aplica, plicuriKinds } from './genereaza-vectori.mjs';
@@ -91,25 +91,30 @@ const ramase = () => [...Object.values(MODULE).map((m) => path.dirname(fileURLTo
/**
* Every path of every offline vector that is not INVALID, removed or replaced by null, a string, a number, a list, an object, and given
* to the module verifiers directly. Left out, and said: the policy of a payment (a policy that cannot be defined is refused by
* definePolicy by throwing, by design: nothing is judged under it), the public task of a market job (each replay costs seconds), and
* definePolicy by throwing, by design: nothing is judged under it), the configuration of an identity verifier (the issuers it trusts,
* and the two lists themselves: a configuration that cannot be read makes it throw, by design; the entries of the lists are damaged like
* everything else), the public task of a market job (each replay costs seconds), and
* the ai-trust bundle (its verifier runs the reference verifier, a program, several times per case).
* @returns {{ cazuri: number, aruncate: string[], acceptate: string[] }} acceptate = the paths (without array positions) whose damage was accepted
*/
async function malformate() {
const R = await incarca('risc'), C = await incarca('chitanta'), P = await incarca('piata'), B = await incarca('baza'), SC = await incarca('sidecar'), AR = await incarca('arbore'), L = await incarca('ledger'); const clona = (x) => JSON.parse(JSON.stringify(x));
const R = await incarca('risc'), C = await incarca('chitanta'), P = await incarca('piata'), B = await incarca('baza'), SC = await incarca('sidecar'), AR = await incarca('arbore'), L = await incarca('ledger'), ID = await incarca('identity'); const clona = (x) => JSON.parse(JSON.stringify(x));
const J = { 'payment-risk': (i) => R.judeca(i.policy, i.inputs).decision === 'ALLOW', 'payment-receipt': (i) => C.verificaChitanta(i.receipt, { policy: i.policy, inputs: i.inputs, tx: i.tx, receipt: i.txReceipt }).verdict === 'VALID', 'market-timeline': (i) => P.judeca(i).verdict === 'VALID',
'dataset-record': (i) => B.verificaInregistrare(i.record, i.commitment).ok, 'dataset-answer': (i) => B.verificaRaspuns(i.answer, i.commitment).verdict === 'VALID', 'dataset-consistency': (i) => B.verificaConsistentaVersiuni(i.proof, i.older, i.newer).ok,
// the verifiers enrolled after the first four (2026-10-05), called the way the adapter calls them; ai-trust is not here: each case would run the reference verifier several times
'audit-log': (i) => (i.head !== undefined ? SC.verificaFataDeCap(i.log, i.head, { semnatar: i.signer || null }) : SC.verificaJurnal(i.log)).ok,
'audit-inclusion': (i) => AR.verificaIncludere(i.proof, { cap: i.head || null, semnatar: i.signer || null }).ok,
'audit-consistency': (i) => AR.verificaConsistenta(i.proof, { vechi: i.older, nou: i.newer, semnatar: i.signer || null }).ok,
'agent-ledger': (i) => { const o = { policy: i.policy, policyHash: i.policyHash, anchors: i.anchors || [], notBefore: i.notBefore === undefined ? null : i.notBefore, revocations: i.revocations || [] }; if (i.maxTime !== undefined) o.maxTime = i.maxTime; return L.verifyLedger(i.ledger, o).ok; } };
'agent-ledger': (i) => { const o = { policy: i.policy, policyHash: i.policyHash, anchors: i.anchors || [], notBefore: i.notBefore === undefined ? null : i.notBefore, revocations: i.revocations || [] }; if (i.maxTime !== undefined) o.maxTime = i.maxTime; return L.verifyLedger(i.ledger, o).ok; },
// identity (2026-10-05): the presentation and everything handed with it; the verifier's own configuration is left out below
'identity-presentation': (i) => { const o = { now: i.now }; for (const k of ['audience', 'nonce', 'trustedIssuers', 'statusLists', 'revocations', 'maxAgeS']) if (i[k] !== undefined) o[k] = i[k]; const r = ID.verifyPresentation(i.presentation, o); return r.valid && !r.unjudged.some((c) => NEJUDECATE_IDENTITY[c]); } }; // accepted = what the suite would call VALID, not PARTIAL
const cai = (x, p = []) => (x !== null && typeof x === 'object' ? [p, ...Object.keys(x).flatMap((k) => cai(x[k], [...p, Array.isArray(x) ? Number(k) : k]))] : [p]).filter((q) => q.length);
const VAL = [null, 'x', 7, [], {}]; let cazuri = 0; const aruncate = [], acceptate = [];
for (const v of vectori) {
if (!J[v.artifact] || v.expected.verdict === 'INVALID' || v.requires.length) continue;
const inp = clona(v.input); if (v.artifact === 'market-timeline') delete inp.spec;
for (const p of cai(inp)) { if (p[0] === 'policy' && v.artifact.startsWith('payment-')) continue;
if (v.artifact === 'identity-presentation' && (p[0] === 'trustedIssuers' || (p.length === 1 && (p[0] === 'statusLists' || p[0] === 'revocations')))) continue;
for (const op of ['remove', 0, 1, 2, 3, 4]) { const c = clona(inp); let o = c; for (const k of p.slice(0, -1)) o = o[k]; const k = p[p.length - 1];
if (op === 'remove') { if (Array.isArray(o)) o.splice(k, 1); else delete o[k]; } else { if (JSON.stringify(o[k]) === JSON.stringify(VAL[op])) continue; o[k] = clona(VAL[op]); }
cazuri++; try { if (J[v.artifact](c)) acceptate.push(v.artifact + ':' + p.filter((x) => typeof x !== 'number').join('.')); } catch (e) { aruncate.push(v.id + ' ' + p.join('.') + ' <- ' + (op === 'remove' ? 'removed' : JSON.stringify(VAL[op])) + ': ' + String(e.message).slice(0, 60)); } } }
@@ -117,6 +122,34 @@ async function malformate() {
return { cazuri, aruncate, acceptate };
}
/**
* The reference verifier is a PROGRAM: it is given files. Every path of two envelopes (a tree head signed with ML-DSA-65; the recorded
* envelope with its notarization claim) removed or replaced by null, a string, a number, a list, an object, and files that are not
* envelopes at all (null, a number, a string, true, lists, an empty object, text that is not JSON, an empty file), each written to a
* file and given to the program. NO public endpoint is contacted: the program goes to the chain whenever a file claims a notarization
* (to the default endpoint of the chain the claim names, mainnet when it names none it knows), so a file that still carries a
* `notarization` is run with a closed local endpoint and an empty local manifest directory, and its finality level comes out not
* measured. A case has a verdict when the program prints JSON with a verdict and its levels.
* @returns {{ cazuri: number, faraVerdict: string[], valide: string[] }} valide = the damaged files it still calls VALID
*/
async function plicuriMalformate(vp = VERIFY_PROOF) {
const clona = (x) => JSON.parse(JSON.stringify(x)); const cai = (x, p = []) => (x !== null && typeof x === 'object' ? [p, ...Object.keys(x).flatMap((k) => cai(x[k], [...p, Array.isArray(x) ? Number(k) : k]))] : [p]).filter((q) => q.length);
const baze = ['envelope/signed-head.valid', 'envelope/notarized-claim.partial'].map((id) => { const v = vectori.find((x) => x.id === id); if (!v) throw new Error('the vector ' + id + ' is gone'); return v.input.envelope; });
const VAL = [null, 'x', 7, [], {}]; const fisiere = [];
baze.forEach((env, b) => { for (const p of cai(env)) for (const op of ['remove', 0, 1, 2, 3, 4]) { const c = clona(env); let o = c; for (const k of p.slice(0, -1)) o = o[k]; const k = p[p.length - 1];
if (op === 'remove') { if (Array.isArray(o)) o.splice(k, 1); else delete o[k]; } else { if (JSON.stringify(o[k]) === JSON.stringify(VAL[op])) continue; o[k] = clona(VAL[op]); }
fisiere.push([`envelope ${b + 1}: ${p.join('.')} <- ${op === 'remove' ? 'removed' : JSON.stringify(VAL[op])}`, JSON.stringify(c)]); } });
for (const [n, t] of [['null', 'null'], ['a number', '7'], ['a string', '"x"'], ['true', 'true'], ['an empty list', '[]'], ['a list with the envelope inside', JSON.stringify([baze[0]])], ['an empty object', '{}'], ['text that is not JSON', JSON.stringify(baze[0]).slice(0, 60)], ['an empty file', '']]) fisiere.push(['the file holds ' + n, t]);
const T = fs.mkdtempSync(path.join(os.tmpdir(), 'aere-conf-plic-')); const faraVerdict = [], valide = []; const gol = path.join(T, 'no-manifests'); fs.mkdirSync(gol);
const MORT = ['--rpc', 'http://127.0.0.1:9', '--manifests', gol]; const pretinde = (t) => { try { const j = JSON.parse(t); return !!j && typeof j === 'object' && !!j.notarization; } catch { return false; } };
try {
await inParalel(fisiere.map(([nume, text], k) => () => new Promise((gata) => { const f = path.join(T, k + '.json'); fs.writeFileSync(f, text);
const c = spawn(process.execPath, [vp, f, '--json', ...(pretinde(text) ? MORT : [])], { stdio: ['ignore', 'pipe', 'pipe'] }); let out = ''; const t = setTimeout(() => c.kill(), 60000); c.stdout.on('data', (d) => { out += d; });
c.on('close', (cod) => { clearTimeout(t); let j = null; try { j = JSON.parse(out); } catch { /* no verdict */ } if (!j || typeof j.verdict !== 'string' || !Array.isArray(j.levels) || !j.levels.length) faraVerdict.push(nume + ' (exit ' + cod + ')'); else if (j.verdict === 'VALID') valide.push(nume); gata(); }); })), 8);
} finally { fs.rmSync(T, { recursive: true, force: true }); }
return { cazuri: fisiere.length, faraVerdict, valide };
}
if (!control && !peLoc) {
console.log('A. the rules and the vectors are derived, and nothing is typed in their place');
const D = await deriva();
@@ -169,6 +202,10 @@ if (!control && !peLoc) {
const cai = [...new Set(m.acceptate)].sort(); const peFel = {}; for (const c of cai) { const k = c.split(':')[0]; peFel[k] = (peFel[k] || 0) + 1; }
rand('INFO', `measured, not a gate: ${m.acceptate.length} of them were still accepted, at ${cai.length} distinct paths (${Object.entries(peFel).map(([k, n]) => k + ' ' + n).join(', ')}): parts a verifier treats as optional (the transaction facts of a receipt, the envelope of a timeline) and fields no rule reads; --acceptate lists them`);
if (a.includes('--acceptate')) for (const c of cai) console.log(' ' + c); }
{ const m = await plicuriMalformate();
cer(m.cazuri > 100 && !m.faraVerdict.length, `${m.cazuri} malformed envelope files (every path of a signed head and of a notarized envelope removed or replaced; files that hold null, a number, a string, true, a list, an empty object, text that is not JSON, nothing) given to the reference verifier, the program: each got a verdict`, m.faraVerdict.slice(0, 3).join(' | ') + (m.faraVerdict.length > 3 ? ' ... ' + m.faraVerdict.length + ' in all' : ''));
rand('INFO', `measured, not a gate: ${m.valide.length} of those files the reference verifier still calls VALID (an envelope without its signature or without its notarization claim is an unsigned, unnotarized envelope; the fields v and kind beside the statement are not read). No public endpoint was contacted: a file that still claims a notarization was given a closed local endpoint, and its finality is not measured; --acceptate lists them`);
if (a.includes('--acceptate')) for (const c of m.valide.sort()) console.log(' ' + c); }
} else if (control) {
console.log('CONTROL: every rule planted out of its verifier, one at a time; the vectors that expect the rule, and only they, must fail');
// Under a planting the suite runs the vectors of every artifact kind that can load the planted verifier (the kinds whose vectors
@@ -214,6 +251,12 @@ if (!control && !peLoc) {
else { fs.writeFileSync(copie, src.replace(anc, "catch (e) { throw e; return { verdict: 'INVALID', motive: ['malformed timeline: '").split('/*PAZA:forma*/').join(PLANT)); process.env[MODULE.piata.env] = copie; const m = await malformate(); delete process.env[MODULE.piata.env];
cer(m.aruncate.length > 0 && m.aruncate.every((x) => x.startsWith('market-timeline/')), `the malformed-input row goes red when a judge throws again (the market judge without its form check and its catch: ${m.aruncate.length} of ${m.cazuri} inputs thrown)`); }
} finally { delete process.env[MODULE.piata.env]; fs.rmSync(copie, { force: true }); } }
{ // the malformed-envelope row can go red: the reference verifier without the first half of its form check throws on a file that holds null
const src = fs.readFileSync(VERIFY_PROOF, 'utf8'); const anc = PLANT_VP.form[0]; const copie = path.join(path.dirname(VERIFY_PROOF), `.plantat-conf-${process.pid}-arunca.mjs`);
try { if (src.split(anc).length !== 2) rand('STRICAT', 'the anchor of the throwing planting is not in the reference verifier');
else { fs.writeFileSync(copie, src.replace(anc, () => 'const formOk = obj(env.statement)')); const bun = await plicuriMalformate(), m = await plicuriMalformate(copie);
cer(!bun.faraVerdict.length && m.faraVerdict.length > 0 && m.faraVerdict.some((x) => x.startsWith('the file holds null')), `the malformed-envelope row goes red when the reference verifier throws again (without the first half of its form check: ${m.faraVerdict.length} of ${m.cazuri} files without a verdict; as published: ${bun.faraVerdict.length})`, m.faraVerdict.slice(0, 2).join(' | ')); }
} finally { fs.rmSync(copie, { force: true }); } }
const r = ramase(); cer(!r.length, 'no planted copy is left behind', r.join(', '));
console.log(`CONTROL: ${bune} of ${cazuri.length} rules proven load-bearing through their vectors`);
} else {