agents: the hosted witness for agent ledgers (sandbox on testnet 28001), its probe and negative control; crypto-inventory 0.4.1 resolves a minimum TLS version given through a constant or a ternary; proof-kinds and conformance gain the agent-witness-checkpoint kind; the reproduction scripts of the Shield recipes no longer carry a workstation path

This commit is contained in:
Aere Network committed 2026-10-20 01:04:12 +03:00
1 parent 0c8f1de3fd
commit a654c3d522
27 files changed
+4737 -43

No files matched your search

+18 -5
View File
@@ -2,7 +2,7 @@
A generic builder of AERE Proof Protocol envelopes (AIP-23) for the standard proof kinds: `data`, `execution`, `identity`,
`compliance`, `runtime`, `location`, `device`, `payment`, `ownership`, `time`, `block`, `authorization`, `settlement`,
`provenance` and, since 2026-10-18, `secret-access`. Every kind produces the same envelope (`statement` plus `statementHash`, the
`provenance`, since 2026-10-18 `secret-access` and since 2026-10-19 `agent-witness-checkpoint`. Every kind produces the same envelope (`statement` plus `statementHash`, the
SHA-256 of the canonical statement text), so the same AIP-23 reference verifier checks all of them with no kind-specific
verification code.
@@ -25,15 +25,28 @@ review of the secrets service) it may also carry `requestHash` (the digest of th
`claimedHolder` / `claimedPresenter` (ids a presentation claimed and nobody verified) and `judged` (on a refusal, each grant judged
with the rules it refused on); envelopes without these fields are byte for byte what they were.
`agent-witness-checkpoint` is the checkpoint of the hosted agents witness (`agents/martor-agenti.mjs`), in the form of a transparency log
checkpoint (C2SP tlog-checkpoint: the log's name, its size, its RFC 9162 root): `root` and `previous` (the statementHash of the checkpoint
before it, absent on the first) are already 32-byte hashes and are refused in another form; `log`, `witness` (the id derived from the
witness's ML-DSA-65 key, which signs the envelope), `chainId` (where checkpoints are notarized), `treeSize` and `maxMergeDelay` (seconds
between receiving a head and covering it with a notarized checkpoint) have a vocabulary (below). The leaves of the tree are digests of the
signed ledger heads it received, nothing of any ledger.
**A kind may have a vocabulary** (`valori` in its schema: per field, a predicate and what it says), judged by `buildProof` on every
field present; `secret-access` is the only kind with one: `verdict` is `allowed`, `refused` or `failed`, `operation` one of the
field present; two kinds have one. `secret-access`: `verdict` is `allowed`, `refused` or `failed`, `operation` one of the
operations of the secrets service (`SECRET_ACCESS.operations`, which the service requires to be its own list), `version` an integer of
at least 1 or `null`, `rules` a list of rule names, ids `aere-id:` + 40 hex or `null`, `createdAt` an RFC 3339 time. An envelope with
the verdict `banana` is no longer built. The reference verifier does not judge vocabularies (it judges the form and the hash of any
kind), so an envelope written by hand with such values stays `VALID` there: the vocabulary is the builder's promise, not the
verifier's. `KINDS.json` of the published copy names the values of each field that has them.
verifier's. `agent-witness-checkpoint` (since 2026-10-19, the adversarial review of the hosted witness): `root` and `previous` 0x + 64
lowercase hex, `log` 1 to 256 printable ASCII characters without spaces, `witness` `aere-witness:` + 40 lowercase hex, `chainId`, `treeSize`
and `maxMergeDelay` integers of at least 1, `createdAt` an RFC 3339 time; the vocabulary is one exported object (`AGENT_WITNESS_CHECKPOINT`)
that the witness's own judge of a checkpoint (`verificaPunct` in `agents/martor-agenti.mjs`) imports, so the builder and the judge cannot
drift apart. Until then a checkpoint with `treeSize` "5" or `maxMergeDelay` 0 was built, and `VALID` at the reference verifier, while the
witness refused it. `KINDS.json` of the published copy names the values of each field that has them.
Test: `node proba-proof-kinds.mjs` (28 checks: every kind built and found `VALID` by the reference verifier, seven negative
Test: `node proba-proof-kinds.mjs` (32 checks since 2026-10-19, after the review of the hosted witness: every kind built and found `VALID` by the reference verifier, eight negative
controls such as content changed after hashing, a required field missing or a `secret-access` value outside its vocabulary, no raw
content in any envelope, bytes hashed as bytes, the new `secret-access` fields, the vocabulary held by that kind alone). It needs the AIP-23 reference verifier: `AERE_VERIFY_PROOF=<path to verify-proof.mjs>` (as published at
content in any envelope, bytes hashed as bytes, the new `secret-access` fields, the two vocabularies held by those two kinds alone, eleven values outside the vocabulary of the witness checkpoint
refused, and that vocabulary being the very object the witness imports). It needs the AIP-23 reference verifier: `AERE_VERIFY_PROOF=<path to verify-proof.mjs>` (as published at
aere.network/tools, with `verify-anchor.mjs`, `mpt.mjs`, `falcon512.mjs`, `registry-v3.mjs` and `package.json` beside it and `npm install` done there); without it the test reports that it did not measure and exits with 2. Node.js 24.
+21 -5
View File
@@ -5,7 +5,7 @@
import fs from 'node:fs'; import crypto from 'node:crypto'; import os from 'node:os'; import path from 'node:path';
import { execFileSync } from 'node:child_process'; import { fileURLToPath } from 'node:url';
import { buildProof, KINDS, SCHEME } from './proof-kinds.mjs';
import { buildProof, KINDS, SCHEME, AGENT_WITNESS_CHECKPOINT } from './proof-kinds.mjs';
const AICI = path.dirname(fileURLToPath(import.meta.url));
const VERIFY = process.env.AERE_VERIFY_PROOF ? path.resolve(process.env.AERE_VERIFY_PROOF) : path.resolve(AICI, '..', 'aere-proof-protocol', 'verify.mjs');
@@ -33,10 +33,12 @@ const INTRARI = {
settlement: { chainId: 2800, txHash: '0x' + '12'.repeat(32), blockHash: '0x' + '34'.repeat(32), from: '0xa', to: '0xb', amount: '100', asset: 'AERE', instruction: BRUT, createdAt: '2026-09-28T09:00:00Z' },
provenance: { subject: BRUT, parents: [BRUT + '1', BRUT + '2'], process: BRUT + 'p', actor: 'build-bot', createdAt: '2026-09-28T09:00:00Z' },
'secret-access': { service: 'https://secrets.example', secret: DB, version: 2, operation: 'get', verdict: 'allowed', rules: [], grant: 'deployers', holder: 'aere-id:' + '0'.repeat(40), presenter: 'aere-id:' + '1'.repeat(40), presentation: BRUT, policy: BRUT + 'pol', createdAt: '2026-10-18T09:00:00Z' },
// 2026-10-19 (B3): capul de jurnal al martorului gazduit al agentilor (radacina si capul de dinainte sunt deja hash-uri de 32 de octeti)
'agent-witness-checkpoint': { root: '0x' + '5a'.repeat(32), previous: '0x' + '6b'.repeat(32), log: 'aere-agent-witness/28001', witness: 'aere-witness:' + '7c'.repeat(20), chainId: 28001, treeSize: 3, maxMergeDelay: 1800, createdAt: '2026-10-19T09:00:00Z' },
};
try {
cer('schema acopera cele 15 feluri (10 + bloc + autorizare, decontare, provenienta + acces la secret)', KINDS.length >= 15 && ['authorization', 'settlement', 'provenance', 'secret-access'].every((k) => KINDS.includes(k)));
cer('schema acopera cele 16 feluri (10 + bloc + autorizare, decontare, provenienta + acces la secret + capul martorului agentilor)', KINDS.length >= 16 && ['authorization', 'settlement', 'provenance', 'secret-access', 'agent-witness-checkpoint'].every((k) => KINDS.includes(k)));
for (const k of KINDS) {
// fiecare fel se judeca separat: un fel care nu se mai poate construi e un RAU numit, nu o exceptie care opreste proba (2026-09-28)
let plic; try { plic = buildProof(k, INTRARI[k]); } catch (e) { cer(`${k}: constructia a cazut (${e.message})`, false); continue; }
@@ -80,8 +82,22 @@ try {
const vechi = buildProof('secret-access', SA);
cer('acces la secret: requestHash, claimedPresenter, judged si verdictul failed se construiesc; fara ele declaratia are exact campurile de dinainte, in ordinea lor',
nou.statement.requestHash === '0x' + 'ab'.repeat(32) && nou.statement.verdict === 'failed' && Object.keys(vechi.statement).join(',') === 'v,kind,presentationHash,policyHash,service,secret,version,operation,verdict,rules,grant,holder,presenter,createdAt');
cer('vocabularul e numai al felului secret-access (celelalte feluri se construiesc exact ca ieri)', KINDS.filter((k) => SCHEME[k].valori).join(',') === 'secret-access');
cer('vocabularul e numai al felurilor secret-access si agent-witness-checkpoint (celelalte se construiesc exact ca ieri)', KINDS.filter((k) => SCHEME[k].valori).join(',') === 'secret-access,agent-witness-checkpoint');
// 2026-10-19 (B3): capul martorului agentilor: radacina trebuie sa fie deja un hash de 32 de octeti (nu se hashuieste), primul cap nu are
// `previous`, iar ordinea campurilor e cea a constructorului (semnatura martorului e peste exact acest text)
const AW = INTRARI['agent-witness-checkpoint'];
const primul = buildProof('agent-witness-checkpoint', { ...AW, previous: undefined });
cer('CONTROL: capul martorului cu radacina care nu e hash de 32 de octeti, sau fara maxMergeDelay -> eroare; primul cap fara previous; campurile in ordinea constructorului',
arunca(() => buildProof('agent-witness-checkpoint', { ...AW, root: 'radacina' })) && arunca(() => buildProof('agent-witness-checkpoint', { ...AW, maxMergeDelay: undefined }))
&& !('previous' in primul.statement) && Object.keys(buildProof('agent-witness-checkpoint', AW).statement).join(',') === 'v,kind,root,previous,log,witness,chainId,treeSize,maxMergeDelay,createdAt');
// 2026-10-19 (revizia adversariala B3, constatarea 8): VOCABULARUL capului martorului, scris o data (AGENT_WITNESS_CHECKPOINT) si importat si
// de judecatorul martorului (verificaPunct). Pana azi treeSize "5", maxMergeDelay 0 sau witness "x" se construiau si erau VALID la verificator.
const releAW = [['treeSize', '5'], ['treeSize', 0], ['chainId', '28001'], ['chainId', 0], ['maxMergeDelay', 0], ['maxMergeDelay', 1.5], ['witness', 'x'], ['witness', 'aere-witness:' + 'AB'.repeat(20)],
['log', ''], ['log', 'cu spatiu'], ['createdAt', 'ieri']].filter(([c, v]) => !arunca(() => buildProof('agent-witness-checkpoint', { ...AW, [c]: v })));
cer('CONTROL: capul martorului cu valori in afara vocabularului (treeSize "5" sau 0, chainId "28001" sau 0, maxMergeDelay 0 sau 1.5, witness "x" sau cu majuscule, log gol sau cu spatiu, createdAt "ieri") -> eroare la constructie' + (releAW.length ? ': construite ' + releAW.map(([c, v]) => c + '=' + JSON.stringify(v)).join(', ') : ''), releAW.length === 0);
cer('capul martorului: vocabularul e chiar obiectul exportat (AGENT_WITNESS_CHECKPOINT.valori), pe care il importa judecatorul martorului; valorile bune se construiesc octet cu octet ca ieri',
SCHEME['agent-witness-checkpoint'].valori === AGENT_WITNESS_CHECKPOINT.valori && Object.isFrozen(AGENT_WITNESS_CHECKPOINT.valori) && buildProof('agent-witness-checkpoint', AW).statementHash === '0x' + crypto.createHash('sha256').update(JSON.stringify({ v: 1, kind: 'aere-proof-of-agent-witness-checkpoint', root: AW.root, previous: AW.previous, log: AW.log, witness: AW.witness, chainId: AW.chainId, treeSize: AW.treeSize, maxMergeDelay: AW.maxMergeDelay, createdAt: AW.createdAt }), 'utf8').digest('hex'));
} finally { fs.rmSync(T, { recursive: true, force: true }); }
const total = KINDS.length + 13;
console.log(`\nProof of everything: ${total - rele}/${total} cum trebuia (${KINDS.length} feluri + 7 controale negative + acoperire + Buffer + parinti + campurile noi + vocabularul)`);
const total = KINDS.length + 16;
console.log(`\nProof of everything: ${total - rele}/${total} cum trebuia (${KINDS.length} feluri + 9 controale negative + acoperire + Buffer + parinti + campurile noi + doua vocabulare + capul martorului)`);
process.exit(rele ? 1 : 0);
+29
View File
@@ -29,6 +29,26 @@ const NUME_IN_SERVICIU = /^[a-z0-9][a-z0-9_-]{0,63}$/;
const eRegula = (r) => typeof r === 'string' && /^[a-z][a-z0-9-]{0,63}$/.test(r);
const eGrant = (g) => typeof g === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,63}$/.test(g);
const eIdSauNull = (v) => v === null || (typeof v === 'string' && /^aere-id:[0-9a-f]{40}$/.test(v));
const eRfc3339 = (v) => typeof v === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/.test(v) && !Number.isNaN(Date.parse(v));
const eHash32 = (v) => typeof v === 'string' && /^0x[0-9a-f]{64}$/.test(v);
// 2026-10-19 (revizia adversariala B3, constatarea 8): VOCABULARUL capului de jurnal al martorului gazduit al agentilor, scris O SINGURA DATA
// aici. Pana azi constructorul felului copia campurile ca atare (treeSize '5', maxMergeDelay 0, witness 'x' se construiau, iar plicul era
// VALID la verificatorul AIP-23), in timp ce martorul (tools/agent-policy/martor-agenti.mjs, verificaPunct) judeca forma cu propria lui copie a
// regulilor. Acum verificaPunct importa exact acest obiect, deci cele doua nu mai pot diverge. Valorile bune nu se schimba: vectorii
// publicati raman octet cu octet aceiasi.
export const AGENT_WITNESS_CHECKPOINT = Object.freeze({
valori: Object.freeze({
root: [eHash32, 'a 32-byte hash, 0x + 64 lowercase hex (the RFC 9162 root of the log)'],
previous: [eHash32, 'the statementHash of the checkpoint before, 0x + 64 lowercase hex (absent on the first)'],
log: [(v) => typeof v === 'string' && v.length >= 1 && v.length <= 256 && /^[\x21-\x7e]+$/.test(v), '1 to 256 printable ASCII characters without spaces (the log name)'],
witness: [(v) => typeof v === 'string' && /^aere-witness:[0-9a-f]{40}$/.test(v), 'aere-witness: + 40 lowercase hex (derived from the ML-DSA-65 key of the witness)'],
chainId: [(v) => Number.isSafeInteger(v) && v >= 1, 'a positive integer (the chain the checkpoints are notarized on)'],
treeSize: [(v) => Number.isSafeInteger(v) && v >= 1, 'an integer >= 1 (the number of heads in the log)'],
maxMergeDelay: [(v) => Number.isSafeInteger(v) && v >= 1, 'an integer number of seconds >= 1 (the maximum merge delay)'],
createdAt: [eRfc3339, 'an RFC 3339 time'],
}),
});
// schema fiecarui fel: campuri de tip 'digest' (se hashuiesc), 'plain' (raman ca atare), 'bool', 'list'. Toate obligatorii daca in `req`.
export const SCHEME = {
@@ -81,6 +101,15 @@ export const SCHEME = {
judged: [(v) => Array.isArray(v) && v.length <= 64 && v.every((x) => x && typeof x === 'object' && !Array.isArray(x) && Object.keys(x).sort().join(',') === 'grant,rules' && eGrant(x.grant) && Array.isArray(x.rules) && x.rules.length <= 64 && x.rules.every(eRegula)), 'a list of { grant, rules }, at most 64'],
createdAt: [(v) => typeof v === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/.test(v) && !Number.isNaN(Date.parse(v)), 'an RFC 3339 time'],
} },
// 2026-10-19 (roadmap pista B, B3, linia Agents): CAPUL DE JURNAL al martorului gazduit al agentilor (tools/agent-policy/martor-agenti.mjs),
// in forma unui checkpoint de jurnal transparent (C2SP tlog-checkpoint: numele jurnalului, marimea, radacina RFC 9162): marimea si radacina
// arborelui capetelor de registru primite, capul de dinainte (statementHash-ul lui), numele jurnalului, id-ul martorului (derivat din cheia
// lui ML-DSA-65, care semneaza plicul), lantul pe care se notarizeaza capetele (28001 in sandbox) si intarzierea maxima promisa intre primirea
// unui cap si acoperirea lui de un cap notarizat (secunde, ca MMD-ul din RFC 9162). Nimic din vreun registru: frunzele sunt digesturi.
// Felurile de dinainte nu se schimba cu nimic.
// 2026-10-19 (revizia B3): cu vocabularul de mai sus (AGENT_WITNESS_CHECKPOINT), importat si de judecatorul martorului.
'agent-witness-checkpoint': { hash: ['root', 'previous'], plain: { log: 'log', witness: 'witness', chainId: 'chainId', treeSize: 'treeSize', maxMergeDelay: 'maxMergeDelay' }, req: ['root', 'log', 'witness', 'chainId', 'treeSize', 'maxMergeDelay'],
valori: AGENT_WITNESS_CHECKPOINT.valori },
};
export const KINDS = Object.keys(SCHEME);