conformance: 97 rules of 9 verifiers, 206 vectors; verify-layer and agents refuse a classical key under an ML-DSA-65 name; market-settlement reads the notarization time from the certified read; proof-of-ai README in English
This commit is contained in:
1 parent
c9f2932e04
commit
c9798a0013
111 files changed
+15871
-292
No files matched your search
@@ -11,6 +11,9 @@ const cer = (c, ce) => { linii.push((c ? 'OK ' : 'RAU ') + ce); c ? ok++ : ra
|
||||
const arunca = (fn) => { try { fn(); return null; } catch (e) { return e.message; } };
|
||||
|
||||
// identitate legata de cheie
|
||||
// (20) martorul probei cheii clasice: un registru de o intrare al unei identitati ML-DSA-65
|
||||
const id20 = newAgentIdentity(); const polBun20 = definePolicy({ agentId: id20.agentId, tools: ['retrieval'] });
|
||||
const regBun20 = () => { const l = openLedger({ identity: id20, policy: polBun20.policy, policyHash: polBun20.policyHash, now: () => 6000 }); l.record({ kind: 'tool', tool: 'retrieval' }); return l.export(); };
|
||||
const id = newAgentIdentity();
|
||||
cer(id.agentId.startsWith('aere-agent:') && id.agentId === agentIdFromKey(id.publicKey), '1. agentId derivat din cheia publica');
|
||||
const id2 = newAgentIdentity();
|
||||
@@ -209,6 +212,22 @@ cer(!vt4.ok && /false identity/.test(vt4.error), `11. CONTROL: cheia publica inl
|
||||
cer(/another agent/.test(arunca(() => resumeLedger({ identity: idC, policy: pc.policy, ledger: regX, now: () => 5010 })) || ''), '19. CONTROL: registrul altui agent nu se poate relua');
|
||||
}
|
||||
|
||||
// 20. o identitate de agent e o cheie ML-DSA-65: un registru scris cu o cheie CLASICA (Ed25519), cu agentId derivat din ea si fiecare
|
||||
// intrare semnata de ea, e refuzat pe nume. Pana la 2026-10-03 verifica: id-ul se deriva din orice cheie, iar crypto.verify(null, ...)
|
||||
// verifica cu orice cheie i se da, deci "identitatea post-cuantica" a agentului putea fi o cheie clasica.
|
||||
{
|
||||
const { publicKey, privateKey } = crypto.generateKeyPairSync('ed25519'); const agentId = agentIdFromKey(publicKey);
|
||||
const pc = definePolicy({ agentId, tools: ['retrieval'] }); const session = sessionId(agentId, pc.policyHash); const sha = (s) => crypto.createHash('sha256').update(Buffer.from(s, 'utf8')).digest('hex');
|
||||
const body = { v: 2, agentId, policyHash: pc.policyHash, session, at: 6000, action: { kind: 'tool', tool: 'retrieval', at: 6000 }, decision: { allowed: true, reason: 'tool allowed' }, provenance: null, seq: 0 };
|
||||
const prev = '0'.repeat(64); const signature = crypto.sign(null, Buffer.from(`0|${prev}|${canonical(body)}`, 'utf8'), privateKey).toString('base64');
|
||||
const clasic = { version: 2, agentId, publicKeyPem: publicKey.export({ type: 'spki', format: 'pem' }), policyHash: pc.policyHash, session, entries: [{ seq: 0, prev, body, signature, hash: sha(`0|${prev}|${canonical(body)}|${signature}`) }] };
|
||||
const v = verifyLedger(clasic, { policy: pc.policy, maxTime: 7000 });
|
||||
cer(!v.ok && v.rule === 'cheie' && /not ML-DSA-65/.test(v.error), `20. CONTROL: un registru al unei chei Ed25519 e refuzat pe nume (${v.rule}: ${String(v.error).slice(0, 60)})`);
|
||||
cer(/not ML-DSA-65/.test(arunca(() => openLedger({ identity: { agentId, publicKey, privateKey }, policy: pc.policy, policyHash: pc.policyHash, now: () => 6000 })) || ''), '20. CONTROL: nici scriitorul nu deschide un registru pentru o cheie care nu e ML-DSA-65');
|
||||
const bun = verifyLedger(regBun20(), { policy: polBun20.policy, maxTime: 7000 });
|
||||
cer(bun.ok === true && bun.rule === undefined, '20. martor: acelasi fel de registru, cu o cheie ML-DSA-65, verifica');
|
||||
}
|
||||
|
||||
for (const l of linii) console.log(l);
|
||||
console.log(`agent-ledger: ${ok}/${ok + rau} cum trebuia`);
|
||||
process.exitCode = rau ? 1 : 0;
|
||||
Reference in new issue
Block a user