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

+31 -1
View File
@@ -12,7 +12,7 @@ import path from 'node:path';
import { spawnSync } from 'node:child_process';
import { createRequire } from 'node:module';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { newAgentIdentity, openLedger } from '../agents/agent-ledger.mjs';
import { newAgentIdentity, openLedger, agentIdFromKey, sessionId, canonical as canonicLedger } from '../agents/agent-ledger.mjs';
import { definePolicy } from '../agents/agent-policy.mjs';
import { buildProofOfAi } from '../proof-of-ai/proof-of-ai.mjs';
import { ledgerHeadEnvelope, notarizeHead, cheiaDinFisier } from '../agents/agent-ancora.mjs';
@@ -94,6 +94,32 @@ export async function proba(mod, cer, { viu = false } = {}) {
const v = await mod.verifica(b, { verifyProof: VERIFY_PROOF });
cer('F5', 'unealta nepermisa de politica: intrarea REFUZATA exista, iesirea nu poate fi "permisa" -> permissions FAILED action-refused', !L2.allowed && v.levels.permissions === 'FAILED' && v.details.permissions.reason === 'action-refused' ? 'VERDE' : 'ROSU', `${v.verdict} ${v.details.permissions.reason || ''}`);
}
// 2026-10-05: what the chain INHERITS from its children since 2026-10-03 (a classical key under an ML-DSA-65 name is refused by the
// agents' ledger verifier and by the audit log verifier), and the list of every rule that refused
{
// the ledger producer refuses a key that is not ML-DSA-65, so this ledger is written the way only the holder of such a key could:
// one entry, with the ledger's published formulas (the id derived from the key, the session from the id and the policy, the
// signature over seq|prev|canonical body, the hash over that and the signature)
const cl = crypto.generateKeyPairSync('ed25519'); const id = agentIdFromKey(cl.publicKey); const pc = definePolicy({ agentId: id, tools: ['model:aere-model-proba'] }); const ses = sessionId(id, pc.policyHash);
const poa = buildProofOfAi({ model: { name: 'aere-model-proba', version: '1.0.0' }, prompt: 'summarise document X', input: 'document X, 12 kB', output: 'a summary of document X', tools: ['model:aere-model-proba'], agentId: id, requester: 'tester', createdAt: new Date(L.t1 * 1000).toISOString() });
const body = { v: 2, agentId: id, policyHash: pc.policyHash, session: ses, at: L.t1, action: { kind: 'tool', tool: 'model:aere-model-proba', at: L.t1 }, decision: { allowed: true, reason: 'tool allowed' }, provenance: null, seq: 0 };
const prev = '0'.repeat(64); const signature = crypto.sign(null, Buffer.from(`0|${prev}|${canonicLedger(body)}`, 'utf8'), cl.privateKey).toString('base64');
const ledger = { version: L.ledger.export().version, agentId: id, publicKeyPem: cl.publicKey.export({ type: 'spki', format: 'pem' }), policyHash: pc.policyHash, session: ses,
entries: [{ seq: 0, prev, body, signature, hash: crypto.createHash('sha256').update(Buffer.from(`0|${prev}|${canonicLedger(body)}|${signature}`, 'utf8')).digest('hex') }] };
const v = await mod.verifica(mod.construieste({ ledger, policy: { policy: pc.policy, policyHash: pc.policyHash }, proofOfAi: poa }), { verifyProof: VERIFY_PROOF });
cer('F11', 'agentul are o cheie Ed25519 (id-ul derivat din ea, registrul semnat cu ea): permissions FAILED ledger-invalid, mostenit de la verificatorul registrului', v.verdict === 'INVALID' && v.levels.permissions === 'FAILED' && v.details.permissions.reason === 'ledger-invalid' && /ML-DSA-65/.test(String(v.details.permissions.detail)) ? 'VERDE' : 'ROSU', `${v.verdict} (${v.reason}); permissions ${v.levels.permissions} ${v.details.permissions.reason || ''}: ${String(v.details.permissions.detail || '').slice(0, 90)}`);
}
{
const cl = crypto.generateKeyPairSync('ed25519'); const b = clone(bundle);
b.runtime.head.signature = { scheme: 'ml-dsa-65', publicKey: cl.publicKey.export({ type: 'spki', format: 'der' }).toString('base64'), signature: crypto.sign(null, Buffer.from(JSON.stringify(b.runtime.head.statement), 'utf8'), cl.privateKey).toString('base64') };
const v = await mod.verifica(b, { verifyProof: VERIFY_PROOF });
cer('F12', 'capul jurnalului de audit semnat cu o cheie Ed25519 care se declara ml-dsa-65: runtime FAILED audit-head, mostenit de la verificatorul jurnalului', v.verdict === 'INVALID' && v.levels.runtime === 'FAILED' && v.details.runtime.reason === 'audit-head' && /ed25519/.test(String(v.details.runtime.detail)) ? 'VERDE' : 'ROSU', `${v.verdict} (${v.reason}); runtime ${v.levels.runtime} ${v.details.runtime.reason || ''}: ${String(v.details.runtime.detail || '').slice(0, 110)}`);
}
{
const b = clone(bundle); b.version.attestation.statement.artifacts[0].sha256 = '0x' + 'ef'.repeat(32); b.runtime.auditLog[0].hash = '0x' + '77'.repeat(32); // the mutations of F9 and F10 together
const v = await mod.verifica(b, { verifyProof: VERIFY_PROOF });
cer('F13', 'doua verigi rupte deodata: verdictul are campul rules cu FIECARE regula care a refuzat, sortate (reason e doar prima)', v.verdict === 'INVALID' && Array.isArray(v.rules) && v.rules.join() === 'audit-log-broken,version-attestation' ? 'VERDE' : 'ROSU', `${v.verdict} (${v.reason}); rules ${JSON.stringify(v.rules)}`);
}
if (viu) {
// the witness: the ledger head notarized on 28001 with the laboratory test key (gas only), read back under a certified anchor
const require = createRequire(path.join(ETHERS_DIR, 'package.json'));
@@ -127,6 +153,10 @@ if (process.argv.includes('--control-negativ')) {
// (measured 2026-10-02: `|| true` made the honest rows fail instead of letting the fixture pass)
{ nume: '(f) decizia refuzata luata drept permisa', de: '/*PAZA:allowed*/', cu: "&& String(1) === '2' /*PLANTAT*/", rosii: ['F5'] },
{ nume: '(g) inregistrarea necautata in jurnalul de audit', de: '/*PAZA:audit*/', cu: "&& String(1) === '2' /*PLANTAT*/", rosii: ['F8'] },
// 2026-10-05: the inherited refusals and the list of rules
{ nume: '(i) capul jurnalului necomparat (verificatorul jurnalului neascultat)', de: "if (!c.ok) fail('runtime', 'audit-head',", cu: "if (String(1) === '2') fail('runtime', 'audit-head',", rosii: ['F12'] },
{ nume: '(j) registrul neverificat (verificatorul registrului neascultat)', de: "if (!v.ok) fail('permissions', 'ledger-invalid',", cu: "if (String(1) === '2') fail('permissions', 'ledger-invalid',", rosii: ['F7', 'F11'] },
{ nume: '(k) verdictul fara lista regulilor', de: "rules: LEVELS.filter((l) => levels[l].state === 'FAILED').map((l) => levels[l].reason).sort(),", cu: 'rules: [],', rosii: ['F13'] },
{ nume: '(h) controlul controlului: o ancora care nu exista', de: '/*PAZA:nu-exista*/', cu: 'x', rosii: [], asteapta: 'STRICAT' },
];
let bune = 0;