ai-trust, proof-of-ai, verifiable-data: the trust chain of an AI result, the AIP-23 envelope of an agent action, and a dataset whose answers are checkable without the data
ai-trust/ links six existing proofs (agent identity, model artifact attestation, host runtime record, policy and signed ledger,
Proof of AI envelope, on-chain witness) into one bundle judged by one verifier that checks only the links; 13/13 in the lab,
16/16 live on testnet 28001 (ledger head notarized). proof-of-ai/ is the AIP-23 envelope builder it uses. verifiable-data/
publishes append-only versions with an RFC 9162 root and a sorted index per field, range and equality queries proven correct
and complete, selective disclosure per field, availability by sampling, and the AIP-23 data envelope notarized (version 2 on
testnet 28001). agents/agent-ancora.mjs gains notarizeEnvelope({kind}), the general form of notarizeHead. Each README says what
is not built: zero-knowledge queries need a prover and are not here. No third party has reviewed any of this.
This commit is contained in:
1 parent
f84a5e8c18
commit
cf8c56792f
18 files changed
+1624
-3
No files matched your search
@@ -0,0 +1,18 @@
|
||||
# AERE Proof of AI (roadmap B2 / #38)
|
||||
|
||||
Un plic AERE Proof Protocol (AIP-23) care dovedeste provenienta unei actiuni de agent AI - ce model, ce versiune, ce prompt, ce
|
||||
unelte, ce iesire, ce agent, cine a cerut - verificat de ACELASI verificator ca orice alt proof AERE, fara niciun cod nou de
|
||||
verificare. Notarizarea si finalitatea post-cuantica vin din AIP-23 (statementHash notarizat pe AereNotary, acoperit de o ancora PQ).
|
||||
|
||||
```
|
||||
import { buildProofOfAi } from './proof-of-ai.mjs';
|
||||
const plic = buildProofOfAi({ model:{name,version,weightsSha256}, prompt, input, output, tools:[...], agentId, requester, createdAt });
|
||||
// -> plic AIP-23; se verifica cu tools/aere-proof-protocol/verify.mjs
|
||||
```
|
||||
|
||||
Plicul tine numai DIGESTURI (promptul, intrarea, iesirea, cine a cerut se stocheaza ca SHA-256, nu brut). Se aliniaza cu contractul
|
||||
de pe lant `contracts/contracts/compliance/AereAIProof.sol` (modelId, inputHash, outputHash, requesterHash), dar e PORTABIL: exista
|
||||
fara lant, il cere doar pentru finalitate.
|
||||
|
||||
Proba: `node proba-proof-of-ai.mjs` (6/6, cu control negativ: iesire schimbata dupa hash -> INVALID). Teza demonstrata: un standard,
|
||||
multe feluri de dovada - acelasi verificator, un fel de proof nou, zero cod nou.
|
||||
@@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
// Proba Proof-of-AI (B2): construieste un plic, il verifica cu ACELASI verificator AIP-23 (fara cod nou de verificare), si un
|
||||
// CONTROL NEGATIV: un plic caruia i se atinge statement-ul dupa hash pica la integritate. Dovedeste teza "un standard, multe feluri".
|
||||
// node proba-proof-of-ai.mjs -> 0 toate cum trebuia, 1 altfel
|
||||
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { buildProofOfAi, KIND } from './proof-of-ai.mjs';
|
||||
|
||||
const AICI = path.dirname(fileURLToPath(import.meta.url));
|
||||
// Verificatorul AIP-23: AERE_VERIFY_PROOF=<verify-proof.mjs> (copia publica, ca la agents/) sau, in depozitul de dezvoltare,
|
||||
// ../aere-proof-protocol/verify.mjs; fara el proba nu poate masura nimic si iese 2 (NEMASURAT), nu verde
|
||||
const VERIFY = process.env.AERE_VERIFY_PROOF || path.resolve(AICI, '..', 'aere-proof-protocol', 'verify.mjs');
|
||||
if (!fs.existsSync(VERIFY)) { console.log(`NEMASURAT: verificatorul AIP-23 nu e la ${VERIFY}; AERE_VERIFY_PROOF=<verify-proof.mjs>`); process.exit(2); }
|
||||
const T = fs.mkdtempSync(path.join(os.tmpdir(), 'poai-'));
|
||||
let rele = 0;
|
||||
const cer = (n, c) => { console.log(` [${c ? 'OK ' : 'RAU '}] ${n}`); if (!c) rele++; };
|
||||
function verif(plicPath) {
|
||||
try { return { cod: 0, out: execFileSync(process.execPath, [VERIFY, plicPath, '--json'], { encoding: 'utf8' }) }; }
|
||||
catch (e) { return { cod: e.status ?? 2, out: (e.stdout || '') + (e.stderr || '') }; }
|
||||
}
|
||||
const verdict = (o) => { try { return JSON.parse(o).verdict; } catch { return '?'; } };
|
||||
// verificatorul AIP-23 e in ENGLEZA (public-ready, D-402/B4): niveluri->levels, nivel->level, stare->state, TRECUT->PASSED, PICAT->FAILED
|
||||
const nivel = (o, n) => { try { return JSON.parse(o).levels.find((x) => x.level === n).state; } catch { return '?'; } };
|
||||
|
||||
try {
|
||||
const plic = buildProofOfAi({
|
||||
model: { name: 'aere-fable', version: '5.1', weightsSha256: '0x' + '22'.repeat(32) },
|
||||
prompt: 'rezuma documentul X',
|
||||
input: 'documentul X, 12kb',
|
||||
output: 'rezumatul: ...',
|
||||
tools: ['retrieval', 'calculator'],
|
||||
agentId: '0xa11ce00000000000000000000000000000000001',
|
||||
requester: 'client-42',
|
||||
createdAt: '2026-09-26T09:00:00.000Z',
|
||||
});
|
||||
cer('plicul are kind aere-proof-of-ai-attestation', plic.kind === KIND + '-attestation');
|
||||
cer('statement-ul are model, promptHash, inputHash, outputHash, tools', !!(plic.statement.model && plic.statement.promptHash && plic.statement.inputHash && plic.statement.outputHash && Array.isArray(plic.statement.tools)));
|
||||
cer('nu contine continut brut (doar digesturi)', !JSON.stringify(plic).includes('rezuma documentul X') && !JSON.stringify(plic).includes('rezumatul: ...'));
|
||||
|
||||
const f = path.join(T, 'ai.json'); fs.writeFileSync(f, JSON.stringify(plic, null, 1));
|
||||
const r = verif(f);
|
||||
cer('verificatorul AIP-23 il valideaza (fara cod nou)', verdict(r.out) === 'VALID' && nivel(r.out, 'integrity') === 'PASSED' && r.cod === 0);
|
||||
|
||||
// CONTROL NEGATIV: schimb outputHash dupa ce statementHash e fixat -> integritate PICAT
|
||||
const rau = JSON.parse(JSON.stringify(plic)); rau.statement.outputHash = '0x' + '33'.repeat(32);
|
||||
const fr = path.join(T, 'ai-rau.json'); fs.writeFileSync(fr, JSON.stringify(rau, null, 1));
|
||||
const rr = verif(fr);
|
||||
cer('CONTROL: iesire schimbata dupa hash -> INVALID', verdict(rr.out) === 'INVALID' && nivel(rr.out, 'integrity') === 'FAILED' && rr.cod === 1);
|
||||
|
||||
// acelasi statement -> acelasi hash (determinist)
|
||||
const plic2 = buildProofOfAi({ model: { name: 'aere-fable', version: '5.1', weightsSha256: '0x' + '22'.repeat(32) }, prompt: 'rezuma documentul X', input: 'documentul X, 12kb', output: 'rezumatul: ...', tools: ['retrieval', 'calculator'], agentId: '0xa11ce00000000000000000000000000000000001', requester: 'client-42', createdAt: '2026-09-26T09:00:00.000Z' });
|
||||
cer('determinist: acelasi continut -> acelasi statementHash', plic2.statementHash === plic.statementHash);
|
||||
} finally {
|
||||
fs.rmSync(T, { recursive: true, force: true });
|
||||
}
|
||||
console.log(`\nB2 proof-of-ai: ${6 - rele}/6 cum trebuia`);
|
||||
process.exit(rele ? 1 : 0);
|
||||
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
// AERE Proof of AI (roadmap B2 / #38): un plic AERE Proof Protocol (AIP-23) care dovedeste provenienta unei actiuni de agent AI -
|
||||
// ce model, ce versiune, ce prompt, ce unelte, ce iesire, ce agent, cine a cerut - astfel incat un tert sa verifice fara sa aiba
|
||||
// incredere in producator, cu ACELASI verificator ca orice alt proof AERE (tools/aere-proof-protocol/verify.mjs). Nu adauga niciun
|
||||
// cod nou de verificare: asta e chiar teza standardului ("un plic, multe feluri de dovada"). Notarizarea + finalitatea post-cuantica
|
||||
// vin gratis din AIP-23 (statementHash notarizat pe AereNotary, acoperit de o ancora PQ). Numai Node 24, node:crypto.
|
||||
//
|
||||
// Se aliniaza cu contractul de pe lant AereAIProof.sol (modelId, inputHash, outputHash, requesterHash): campurile de mai jos se pot
|
||||
// mapa la o atestare on-chain, dar plicul e PORTABIL (nu cere lantul ca sa existe; il cere doar ca sa capete finalitate).
|
||||
|
||||
import crypto from 'node:crypto';
|
||||
|
||||
export const KIND = 'aere-proof-of-ai';
|
||||
const sha256 = (b) => '0x' + crypto.createHash('sha256').update(b).digest('hex');
|
||||
const hexOf = (v) => {
|
||||
if (v == null) return null;
|
||||
if (typeof v === 'string' && /^0x[0-9a-fA-F]{64}$/.test(v)) return v.toLowerCase(); // deja un digest
|
||||
return sha256(Buffer.from(typeof v === 'string' ? v : JSON.stringify(v), 'utf8'));
|
||||
};
|
||||
|
||||
/**
|
||||
* Construieste un plic Proof-of-AI (AIP-23). Nu tine niciun continut sensibil: doar digesturi.
|
||||
* @param {object} p
|
||||
* @param {{name:string, version?:string, weightsSha256?:string}} p.model
|
||||
* @param {string} [p.prompt] promptul brut (se stocheaza doar digestul) SAU
|
||||
* @param {string} [p.promptHash] digestul promptului (0x+64) daca nu vrei sa-l dai brut
|
||||
* @param {string} [p.input] intrarea (digest stocat) SAU p.inputHash
|
||||
* @param {string} [p.output] iesirea (digest stocat) SAU p.outputHash
|
||||
* @param {string[]} [p.tools] uneltele pe care agentul avea voie sa le foloseasca / le-a folosit
|
||||
* @param {string} [p.agentId] identitatea agentului (adresa / id)
|
||||
* @param {string} [p.requester] cine a cerut (digest stocat) SAU p.requesterHash
|
||||
* @param {string} p.createdAt RFC3339
|
||||
* @returns {object} plicul AIP-23 { v, kind, statement, statementHash }
|
||||
*/
|
||||
export function buildProofOfAi(p) {
|
||||
if (!p || !p.model || !p.model.name) throw new Error('proof-of-ai: model.name e obligatoriu');
|
||||
if (!p.createdAt) throw new Error('proof-of-ai: createdAt e obligatoriu (RFC3339)');
|
||||
const statement = {
|
||||
v: 1,
|
||||
kind: KIND,
|
||||
model: { name: p.model.name, version: p.model.version || null, weightsSha256: p.model.weightsSha256 || null },
|
||||
promptHash: p.promptHash ? p.promptHash.toLowerCase() : hexOf(p.prompt),
|
||||
inputHash: p.inputHash ? p.inputHash.toLowerCase() : hexOf(p.input),
|
||||
outputHash: p.outputHash ? p.outputHash.toLowerCase() : hexOf(p.output),
|
||||
tools: Array.isArray(p.tools) ? [...p.tools] : [],
|
||||
agentId: p.agentId || null,
|
||||
requesterHash: p.requesterHash ? p.requesterHash.toLowerCase() : hexOf(p.requester),
|
||||
createdAt: p.createdAt,
|
||||
};
|
||||
const text = JSON.stringify(statement); // canonic AIP-23: ordinea de inserare, SHA-256
|
||||
return { v: 1, kind: KIND + '-attestation', statement, statementHash: sha256(Buffer.from(text, 'utf8')) };
|
||||
}
|
||||
Reference in new issue
Block a user