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:
1 parent
3ff21f7758
commit
0c8f1de3fd
122 files changed
+1205
-262
No files matched your search
+2
-2
@@ -112,13 +112,13 @@ Measured on 2026-09-29 (Node.js 24.14.1, Windows):
|
||||
| test | result |
|
||||
|---|---|
|
||||
| `node proba-agent-policy.mjs` | 27/27 with the AIP-23 reference verifier (`AERE_VERIFY_PROOF=<verify-proof.mjs from aere.network/tools>`); without it 25 run, 2 are reported as skipped and the exit code is 2 |
|
||||
| `node proba-agent-ledger.mjs` | 54/54 (measured 2026-10-05): a ledger written and signed with a classical key refused by name, by the verifier and by the writer; limits over the ledger, identity, tampering, a re-signed false decision, a looser policy under the real hash, backdating (refused when written; caught with anchors or `notBefore`), a branch, equivocation proofs, resuming |
|
||||
| `node proba-agent-ledger.mjs` | 59/59 (measured 2026-10-19; since then an equivocation proof must be made with the agent's ML-DSA-65 key, AIP-25 finding C2): a ledger written and signed with a classical key refused by name, by the verifier and by the writer; limits over the ledger, identity, tampering, a re-signed false decision, a looser policy under the real hash, backdating (refused when written; caught with anchors or `notBefore`), a branch, equivocation proofs, resuming |
|
||||
| `node proba-agent-aprobare.mjs` | 39/39: threshold, unnamed or repeated approvers, classical keys, another action or other tool arguments, reused nonces (also after a restart), expiry, approvals across branches, revocation, an omitted revocation |
|
||||
| `node proba-agent-cli.mjs` | 23/23 on Windows, through files and processes only; on Linux and macOS one more test checks the 0600 mode of the key (not measured here) |
|
||||
| `node proba-agent-ancora.mjs` | 26/26 without a network (the AIP-23 verifier's answer in its own form): the head, the time read from the finality level (pending, failed, a mismatched or unknown form: no anchor), an envelope that claims another time, backdating caught with the anchor and not without it, another branch, the refusals before any transaction (a modified head, chain 2800 without confirmation, no contract at the notary) |
|
||||
| `AERE_TESTNET_KEY_FILE=<funded testnet key> node proba-agent-ancora-testnet.mjs` | 7/7 on the public testnet 28001, measured 2026-09-30: a real ledger's head notarized, read back under a post-quantum certified anchor by the published AIP-23 verifier within 20 s, the certified time equal to the contract's first-seen time, the honest continuation valid with the anchor, a backdated continuation valid without it and caught with it, another branch refused; evidence in `dovezi-ancora-28001/` |
|
||||
| `node control-negativ-ancora.mjs` | 11/11: each anchoring guard removed in a copy turns its named test red |
|
||||
| `node control-negativ-aprobare.mjs` | 26/26: each guard is removed in a copy, one at a time, and the named test must fail for that reason; a test that stops before its summary counts as a failure of the control |
|
||||
| `node control-negativ-aprobare.mjs` | 28/28 (2026-10-19): each guard is removed in a copy, one at a time, and the named test must fail for that reason; a test that stops before its summary counts as a failure of the control |
|
||||
|
||||
The data format is version 2 (2026-09-29). Code comments, test names and most internal names are in Romanian; messages, data and
|
||||
the exported interface are in English. No third party has reviewed this component.
|
||||
@@ -307,6 +307,10 @@ export function verifyLedger(ledger, { policy: politicaData, policyHash: hashFix
|
||||
// DOVADA DE ECHIVOCARE: doua intrari semnate de aceeasi cheie de agent, cu aceeasi sesiune si acelasi seq, si continut diferit. Cum
|
||||
// sesiunea e una pe agent si politica, asta inseamna ca agentul a scris doua istorii diferite ale aceluiasi registru (o aprobare
|
||||
// folosita de doua ori, o cheltuiala dubla). Dovada se verifica fara incredere in cine o aduce: numai cheia publica si doua semnaturi.
|
||||
// 2026-10-19 (AIP-25 constatarea C2, D-536): si aici cheia trebuie sa fie ML-DSA-65, ca la verifyLedger (regula `cheie`). Pana atunci
|
||||
// findEquivocation si verifyEquivocation verificau cu orice cheie arata dovada, deci o "echivocare" semnata cu o cheie Ed25519 (agentId
|
||||
// derivat din ea) iesea ok, desi registrul aceleiasi chei e refuzat: o dovada impotriva a ceva ce nu e o identitate de agent.
|
||||
const cheieDeAgent = (pub) => !!pub && pub.asymmetricKeyType === ALG;
|
||||
function intrareSemnata(e, pub) {
|
||||
if (!e || !e.body || !Number.isInteger(e.seq) || e.body.seq !== e.seq) return false;
|
||||
let ok = false;
|
||||
@@ -320,6 +324,7 @@ function intrareSemnata(e, pub) {
|
||||
export function findEquivocation(a, b) {
|
||||
if (!a || !b || a.agentId !== b.agentId || a.session !== b.session) return null;
|
||||
let pub; try { pub = crypto.createPublicKey(a.publicKeyPem); } catch { return null; }
|
||||
if (!cheieDeAgent(pub)) return null; // AIP-25 C2: numai cheia unei identitati de agent (ML-DSA-65) face o dovada
|
||||
if (agentIdFromKey(pub) !== a.agentId) return null;
|
||||
const n = Math.min((a.entries || []).length, (b.entries || []).length);
|
||||
for (let i = 0; i < n; i++) {
|
||||
@@ -330,10 +335,11 @@ export function findEquivocation(a, b) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/** @returns {{ok:boolean, error?:string}} */
|
||||
/** @returns {{ok:boolean, error?:string, rule?:string}} (`rule: 'cheie'` cand cheia aratata nu e o cheie de agent ML-DSA-65, AIP-25 C2) */
|
||||
export function verifyEquivocation(p) {
|
||||
if (!p || p.kind !== 'aere-agent-equivocation' || p.v !== 1) return { ok: false, error: 'not an aere-agent-equivocation v1' };
|
||||
let pub; try { pub = crypto.createPublicKey(p.publicKeyPem); } catch { return { ok: false, error: 'the public key cannot be read' }; }
|
||||
if (!cheieDeAgent(pub)) return { ok: false, rule: 'cheie', error: `the agent key is ${pub.asymmetricKeyType}, not ML-DSA-65: an agent identity is an ML-DSA-65 key, so this proves nothing against an agent` };
|
||||
if (agentIdFromKey(pub) !== p.agentId) return { ok: false, error: 'agentId is not derived from the public key' };
|
||||
for (const e of [p.a, p.b]) {
|
||||
if (!e || !e.body || e.seq !== p.seq || e.body.agentId !== p.agentId || e.body.session !== p.session) return { ok: false, error: 'the two entries are not at the same position of the same ledger' };
|
||||
|
||||
@@ -34,6 +34,9 @@ const PLANTARI = [
|
||||
['verificatorul nu mai cere sesiunea registrului in intrare', 'agent-ledger.mjs', ' && b.session === ledger.session /*PAZA:corp*/)) return', ' /*PAZA:corp*/)) return', P.reg],
|
||||
['sesiunea registrului nu mai trebuie sa fie cea derivata', 'agent-ledger.mjs', 'if (!(ledger.session === sessionId(ledger.agentId, policyHash) /*PAZA:sesiune*/)) return', 'if (false) return', P.reg],
|
||||
['dovada de echivocare fara semnaturile agentului', 'agent-ledger.mjs', "if (!intrareSemnata(e, pub)) return { ok: false, error: 'an entry is not signed by the agent' };", '', P.reg],
|
||||
// 2026-10-19 (AIP-25 C2, D-536): dovada de echivocare cere cheia unei identitati de agent, ML-DSA-65, ca verifyLedger
|
||||
['AIP-25 C2: verifyEquivocation primeste o cheie care nu e ML-DSA-65', 'agent-ledger.mjs', "if (!cheieDeAgent(pub)) return { ok: false, rule: 'cheie',", "if (false) return { ok: false, rule: 'cheie',", P.reg],
|
||||
['AIP-25 C2: findEquivocation face o dovada din cheia oricui', 'agent-ledger.mjs', 'if (!cheieDeAgent(pub)) return null;', 'if (false) return null;', P.reg],
|
||||
['un registru atins se poate relua', 'agent-ledger.mjs', 'if (!v.ok) throw new Error(`agent-ledger: the ledger to resume does not verify', 'if (false) throw new Error(`agent-ledger: the ledger to resume does not verify', P.reg],
|
||||
['reluarea uita nonce-urile folosite', 'agent-ledger.mjs', 'for (const e of entries) for (const n of nonceuri(e.body.approvals)) folosite.add(n);', '', P.apr],
|
||||
['reluarea uita revocarea', 'agent-ledger.mjs', 'JSON.parse(JSON.stringify(ledger.entries)), v.revocations.revokedAt);', 'JSON.parse(JSON.stringify(ledger.entries)), null);', P.apr],
|
||||
|
||||
@@ -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;
|
||||
Reference in new issue
Block a user