verify-layer: the audit log as a Merkle tree (RFC 9162) - signed tree heads, and inclusion and consistency proofs anyone checks without the log
This commit is contained in:
1 parent
f75c33454a
commit
082b862d78
7 files changed
+487
-4
No files matched your search
@@ -23,6 +23,11 @@
|
||||
// sidecar keygen --out <dosar> -> cheia ML-DSA-65 cu care operatorul semneaza capetele (head.key.pem 0600, head.pub.pem)
|
||||
// sidecar notarize-head --head cap.json --rpc URL --key-file f [--notary 0x..] [--out f]
|
||||
// sidecar bundle --log p [--out f] -> buraf {host, count, head, entries[]} pentru consola planului de control
|
||||
// sidecar tree-head --log p [--sign-key k] [--out f] -> capul de ARBORE (RFC 9162): marimea si radacina, plic AIP-23
|
||||
// sidecar prove-inclusion --log p --seq N [--size S] [--out f] -> dovada ca intrarea N e in arbore (log2 n hash-uri)
|
||||
// sidecar prove-consistency --log p --from M [--to N] [--out f] -> dovada ca arborele de M e un prefix al celui de N
|
||||
// sidecar verify-inclusion --proof f [--head cap.json [--signer pub]] -> 0 inclusa, 1 nu (FARA jurnal)
|
||||
// sidecar verify-consistency --proof f --old cap1.json --new cap2.json [--signer pub] -> 0 capul nou il continua pe cel vechi
|
||||
// Mesajele catre utilizator sunt in engleza. Numai Node 24 (ethers numai pentru notarize-head).
|
||||
|
||||
import fs from 'node:fs';
|
||||
@@ -372,6 +377,35 @@ async function main() {
|
||||
return 0;
|
||||
} catch (e) { console.error('the notarization failed: ' + taie(e.shortMessage || e.message)); return 1; }
|
||||
}
|
||||
// 2026-09-30 (punctul 34): jurnalul si ca arbore Merkle (RFC 9162, jurnal-arbore.mjs): capul de arbore, dovezile de includere si de
|
||||
// consistenta, si verificarea lor FARA jurnal
|
||||
case 'tree-head':
|
||||
case 'prove-inclusion':
|
||||
case 'prove-consistency':
|
||||
case 'verify-inclusion':
|
||||
case 'verify-consistency': {
|
||||
const A = await import(pathToFileURL(path.join(AICI, 'jurnal-arbore.mjs')).href);
|
||||
const citeste = (f, ce) => { if (!f) throw new Error(`${cmd} needs ${ce}`); return JSON.parse(fs.readFileSync(f, 'utf8')); };
|
||||
const scrie = (o) => { const out = get('--out'); const s = JSON.stringify(o, null, 1); if (out) { fs.writeFileSync(out, s); console.log('written', out); } else console.log(s); };
|
||||
const semnatar = get('--signer') ? fs.readFileSync(get('--signer'), 'utf8') : null;
|
||||
try {
|
||||
if (cmd === 'tree-head') {
|
||||
const kf = get('--sign-key');
|
||||
const cap = A.capDeArbore(citesteJurnal(log), { host, createdAt: at, signKeyPem: kf ? fs.readFileSync(kf, 'utf8') : null });
|
||||
scrie(cap); return 0;
|
||||
}
|
||||
if (cmd === 'prove-inclusion') { scrie(A.dovadaIncludere(citesteJurnal(log), Number(get('--seq')), get('--size') ? Number(get('--size')) : undefined)); return 0; }
|
||||
if (cmd === 'prove-consistency') { scrie(A.dovadaConsistenta(citesteJurnal(log), Number(get('--from')), get('--to') ? Number(get('--to')) : undefined)); return 0; }
|
||||
if (cmd === 'verify-inclusion') {
|
||||
const r = A.verificaIncludere(citeste(get('--proof'), '--proof'), { cap: get('--head') ? citeste(get('--head'), '--head') : null, semnatar });
|
||||
console.log(r.ok ? `entry INCLUDED${get('--head') ? ' in the tree of the given head' + (r.semnatDe ? `, signed by key ${r.semnatDe.slice(0, 18)}${semnatar ? ' (the expected signer)' : ' (not checked against an expected signer: --signer)'}` : ' (unsigned head)') : ' in the tree the proof names (pass --head to bind it to an attested head)'}` : `NOT included: ${r.motiv}`);
|
||||
return r.ok ? 0 : 1;
|
||||
}
|
||||
const r = A.verificaConsistenta(citeste(get('--proof'), '--proof'), { vechi: citeste(get('--old'), '--old'), nou: citeste(get('--new'), '--new'), semnatar });
|
||||
console.log(r.ok ? 'the new head EXTENDS the old one (the history up to the old head was not rewritten)' : `NOT consistent: ${r.motiv}`);
|
||||
return r.ok ? 0 : 1;
|
||||
} catch (e) { console.log(`${cmd}: ${String(e.message).replace(/[0-9a-fA-F]{32,}/g, '<hex>').slice(0, 200)}`); return 2; }
|
||||
}
|
||||
case 'bundle': {
|
||||
const intrari = citesteJurnal(log);
|
||||
const v = verificaJurnal(intrari);
|
||||
@@ -381,7 +415,7 @@ async function main() {
|
||||
return v.ok ? 0 : 1;
|
||||
}
|
||||
default:
|
||||
console.log('AERE Verification Layer (sidecar). Commands: record | scan | verify-log | attest-head | notarize-head | bundle');
|
||||
console.log('AERE Verification Layer (sidecar). Commands: record | scan | verify-log | attest-head | notarize-head | bundle | tree-head | prove-inclusion | prove-consistency | verify-inclusion | verify-consistency');
|
||||
console.log(' sidecar record --kind runtime --artifact f --attested 0x.. sidecar verify-log --log p [--attested cap.json [--signer head.pub.pem]] sidecar attest-head --log p --out f [--sign-key head.key.pem] sidecar keygen --out dir');
|
||||
return cmd ? 1 : 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user