identity: the SD-JWT form of an AERE hybrid identity is judged on its ML-DSA-65 half by default, the Ed25519 half only on explicit request, and every verdict says postQuantum (rule sdjwt.hybrid-half); pq-pki: the signature algorithm a certificate or a revocation list declares must be its issuer key's (ALG_KEY, CRL_ALG_KEY); agents: an equivocation proof requires the agent's ML-DSA-65 key; pq-gateway: the status names the path to the backend and hybrid-only refuses a plain-HTTP backend; conformance 241 rules, 631 vectors

This commit is contained in:
Aere Network committed 2026-10-19 05:19:21 +03:00
1 parent 3ff21f7758
commit 0c8f1de3fd
122 files changed
+1205 -262

No files matched your search

+27
View File
@@ -228,6 +228,33 @@ cer(!vt4.ok && /false identity/.test(vt4.error), `11. CONTROL: cheia publica inl
cer(bun.ok === true && bun.rule === undefined, '20. martor: acelasi fel de registru, cu o cheie ML-DSA-65, verifica');
}
// 21. AIP-25 C2 (D-536, 2026-10-19): dovada de echivocare cere aceeasi cheie ca registrul, ML-DSA-65. Pana atunci findEquivocation si
// verifyEquivocation verificau cu orice cheie arata dovada, deci o "echivocare" a unei chei Ed25519 (agentId derivat din ea) iesea ok,
// desi verifyLedger (proba 20) refuza registrul aceleiasi chei: o dovada impotriva unei identitati care nu e o identitate de agent.
{
const sha = (s) => crypto.createHash('sha256').update(Buffer.from(s, 'utf8')).digest('hex');
// doua intrari la seq 0, cu continut diferit, semnate cu cheia `priv`, pentru agentul derivat din `pub`
const echivocare = (pub, priv, semnaB = priv) => {
const agentId = agentIdFromKey(pub); const pc = definePolicy({ agentId, tools: ['retrieval', 'search'] }); const session = sessionId(agentId, pc.policyHash);
const intrare = (tool, cheie) => { const body = { v: 2, agentId, policyHash: pc.policyHash, session, at: 6000, action: { kind: 'tool', tool, 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'), cheie).toString('base64'); return { seq: 0, prev, body, signature, hash: sha(`0|${prev}|${canonical(body)}|${signature}`) }; };
const a = intrare('retrieval', priv), b = intrare('search', semnaB);
const exp = (e) => ({ version: 2, agentId, publicKeyPem: pub.export({ type: 'spki', format: 'pem' }), policyHash: pc.policyHash, session, entries: [e] });
return { dovada: { v: 1, kind: 'aere-agent-equivocation', agentId, session, publicKeyPem: pub.export({ type: 'spki', format: 'pem' }), seq: 0, a, b }, A: exp(a), B: exp(b) };
};
const ed = crypto.generateKeyPairSync('ed25519'); const E = echivocare(ed.publicKey, ed.privateKey);
const v = verifyEquivocation(E.dovada);
cer(!v.ok && v.rule === 'cheie' && /not ML-DSA-65/.test(String(v.error)), `21. AIP-25 C2: o echivocare semnata cu o cheie Ed25519 e refuzata pe nume (${v.ok ? 'ok' : v.rule + ': ' + String(v.error).slice(0, 60)})`);
cer(findEquivocation(E.A, E.B) === null, '21. AIP-25 C2: findEquivocation nu face o dovada din doua exporturi ale unei chei Ed25519');
const m44 = crypto.generateKeyPairSync('ml-dsa-44'); const v44 = verifyEquivocation(echivocare(m44.publicKey, m44.privateKey).dovada);
cer(!v44.ok && v44.rule === 'cheie', `21. AIP-25 C2 ATAC: si o cheie post-cuantica de alt fel (ML-DSA-44) e refuzata: identitatea agentului e ML-DSA-65 (${v44.ok ? 'ok' : v44.error})`);
// chei de feluri diferite in cele doua intrari: cheia aratata e ML-DSA-65, a doua intrare e semnata cu o cheie Ed25519 -> nu e semnata de agent
const m65 = crypto.generateKeyPairSync('ml-dsa-65'); const Mx = echivocare(m65.publicKey, m65.privateKey, ed.privateKey);
const vx = verifyEquivocation(Mx.dovada); cer(!vx.ok && /not signed by the agent/.test(String(vx.error)), `21. AIP-25 C2 ATAC: o intrare semnata cu alt fel de cheie decat cea aratata -> refuzata (${vx.ok ? 'ok' : vx.error})`);
const M = echivocare(m65.publicKey, m65.privateKey);
cer(verifyEquivocation(M.dovada).ok === true && !!findEquivocation(M.A, M.B), '21. martor: aceeasi echivocare, cu o cheie ML-DSA-65, e o dovada (verifyEquivocation ok, findEquivocation o gaseste)');
}
for (const l of linii) console.log(l);
console.log(`agent-ledger: ${ok}/${ok + rau} cum trebuia`);
process.exitCode = rau ? 1 : 0;