device-operation: machine operation log and reputation; conformance: 260 rules, 17 verifiers, 791 vectors

This commit is contained in:
Aere Network committed 2026-10-20 22:47:47 +03:00
1 parent c1721b3bf1
commit 6ba33c477f
281 files changed
+115161 -46

No files matched your search

+39 -2
View File
@@ -4,7 +4,8 @@
// risk module, a receipt by the receipt verifier, a market timeline by the market judge, a dataset record, answer, consistency proof
// or sample by the dataset module, a presentation of a credential by the identity verifier, a device bundle by the device verifier, an
// SD-JWT or SD-JWT VC presentation by the SD-JWT verifiers, a Travel Rule binding, message or receipt by the Travel Rule verifier, a
// compliance presentation by the compliance verifier. What it adds is the translation: the rule ids those verifiers name -> the public rule ids and
// compliance presentation by the compliance verifier, a machine's operation log by the operation verifier and a stated reputation by the
// reputation check (2026-10-20). What it adds is the translation: the rule ids those verifiers name -> the public rule ids and
// the level of each (reguli.mjs), and the composition (a receipt or a timeline that carries an AIP-23 envelope gets that envelope
// judged too, so one verdict covers the artifact).
//
@@ -16,7 +17,7 @@
// verdict says so (PARTIAL: claim-not-checked). With --online the envelope goes to the reference verifier with the chain's endpoint.
// Exit: 0 VALID, 1 INVALID, 2 PARTIAL, 3 the artifact could not be judged at all (not a verdict).
import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { spawn } from 'node:child_process';
import { VERIFICATOARE, FINALITY_SITES, VERIFY_PROOF, NEJUDECATE_IDENTITY, NEJUDECATE_DEVICE, NEJUDECATE_COMPLIANCE, incarca } from './reguli.mjs';
import { VERIFICATOARE, FINALITY_SITES, VERIFY_PROOF, NEJUDECATE_IDENTITY, NEJUDECATE_DEVICE, NEJUDECATE_COMPLIANCE, NEJUDECATE_OPERATION, incarca } from './reguli.mjs';
import { acumulator, pica, trece, nemasurat, verdictUnic } from './verdict.mjs';
const RPC = { 2800: process.env.AERE_CONFORMANCE_RPC_2800 || 'https://rpc.aere.network', 28001: process.env.AERE_CONFORMANCE_RPC_28001 || 'https://testnet-rpc.aere.network' };
@@ -245,6 +246,42 @@ async function judeca(artifact, input, online) {
const NEJ = NEJUDECATE_COMPLIANCE;
for (const c of r.unjudged) { if (!(c in NEJ)) throw new Error('the compliance verifier left unjudged for a cause this suite does not map: ' + c); if (NEJ[c]) nemasurat(acc, NEJ[c][0], NEJ[c][1], c === 'request' ? 'the presentation commits to a request and the verifier gave none to compare it with' : 'the credential names a status list and the verifier read none; the policy waived the status (requireStatus false)'); }
for (const l of ['anchoring', 'finality']) nemasurat(acc, l, 'not-judged', 'a compliance judgement is anchored by notarizing its record (an AIP-23 compliance envelope without personal data), judged as the artifact `envelope`');
} else if (artifact === 'device-operation-log') {
// the operation log of a machine (2026-10-20, B7), judged by the operation verifier with what THIS verifier brings: its clock (required)
// and the tolerance of it, the manufacturers it trusts, the recall lists and the manufacturer's status records it read, its own readings
// of the notarized anchors and of the blocks the records name, records of the machine it holds from elsewhere. The verifier makes every
// check of each record it reaches and names every rule that refused; the log is accepted up to the first record a rule refuses
const M = await incarca('operation'); const R = VERIFICATOARE['device-operation'].reguli;
if (typeof input.now !== 'string') throw new Error('an operation log is judged on the verifier\'s clock: input.now (an RFC 3339 time) is required');
const o = { now: input.now }; for (const k of ['clockSkewS', 'trustedManufacturers', 'statusLists', 'statusRecords', 'readings', 'beacons', 'otherRecords']) if (input[k] !== undefined) o[k] = input[k];
const r = M.verifyOperation(input.log, o);
if (r.valid !== (r.rules.length === 0)) throw new Error('the operation verifier refused without naming a rule');
for (const s of r.rules) { if (!R[s]) throw new Error('the operation verifier named a rule this suite does not map: ' + s); pica(acc, R[s][1], R[s][0], r.rows.filter((x) => x.pass === false && x.rule === s).map((x) => x.name + ': ' + x.detail).join('; ')); }
const oprit = r.rules.find((s) => M.OPRIRI.includes(s));
// the walk stops at a record whose key's credential was refused: when that is the first key, no record was judged at all, and integrity
// is then not reached (the authenticity level names the refusal); a credential refused later leaves the records before it judged
const recorduri = r.rows.filter((x) => x.scope === 'record' && x.pass !== null).length;
if (!r.rules.some((s) => R[s][1] === 'integrity')) {
if (r.rules.length && !recorduri) nemasurat(acc, 'integrity', 'not-reached', 'the manufacture credential of the key that signs the first record was refused: no record of the log was judged');
else { trece(acc, 'integrity', `no integrity rule of the operation verifier refused: ${r.accepted} record(s) accepted, ${r.counted} counted, ${r.rows.filter((x) => x.pass === true).length} checks held` + (r.rules.length ? ' (the records after the first refusal were not judged)' : ''));
// what the verifier NAMES without changing the verdict (time no witness bounds, a block not read, a key used after a rotation or a
// retirement, a retirement not in effect yet, records beside the log that are not of its keys): said here, in the reason
const notate = r.rows.filter((x) => x.pass === null && NEJUDECATE_OPERATION[x.unjudged] === null); if (notate.length) trece(acc, 'integrity', 'named by the verifier, the verdict stands: ' + notate.map((x) => x.unjudged + ' (' + x.name + ': ' + x.detail + ')').join('; ')); }
}
if (!r.rules.some((s) => R[s][1] === 'authenticity')) { if (oprit) nemasurat(acc, 'authenticity', 'not-reached', 'the verifier stopped at ' + R[oprit][0] + ' before every signature was looked at'); else trece(acc, 'authenticity', 'the manufacture credential of each key is accepted by the device verifier, and every record judged is signed (ML-DSA-65) by the key in force at its position'); }
// what the verifier did not judge: the causes the module declares as keeping the verdict from VALID are exactly the ones mapped here
const NEJ = NEJUDECATE_OPERATION; if (M.NEJUDECATE.some((c) => !(c in NEJ) || !!NEJ[c] !== M.PARTIALE.includes(c)) || Object.keys(NEJ).some((c) => !M.NEJUDECATE.includes(c))) throw new Error('the operation verifier declares causes of not judging that this suite does not map the same way');
for (const c of r.unjudged) { if (!(c in NEJ)) throw new Error('the operation verifier left unjudged for a cause this suite does not map: ' + c); if (NEJ[c]) nemasurat(acc, NEJ[c][0], NEJ[c][1], r.rows.filter((x) => x.unjudged === c).map((x) => x.name + ': ' + x.detail).join('; ')); }
for (const l of ['anchoring', 'finality']) nemasurat(acc, l, 'not-judged', 'an anchor of a record is an AIP-23 time envelope, notarized and judged as the artifact `envelope`; here the verifier brings its own readings of the notarized anchors and of the blocks, and the bounds they give are in the facts');
const v = verdictUnic(artifact, acc); if (v.verdict !== r.verdict) throw new Error('the verdict of the suite (' + v.verdict + ') is not the verdict of the operation verifier (' + r.verdict + ')');
return v;
} else if (artifact === 'device-reputation') {
// the reputation of a machine (2026-10-20, B7): the figures somebody states for the facts of an operation log and the parameters chosen,
// checked by computing the published formula again. It is a computation, not a signed statement: the other levels are not judged
const M = await incarca('reputation'); const c = M.checkReputation(input);
if ((c.verdict === 'VALID') !== (c.rules.length === 0)) throw new Error('the reputation check refused without naming a rule');
reguli(acc, 'device-reputation', c.rules, [c.reason], 'the stated reputation is what the formula ' + M.FORMULA + ' gives for these facts and parameters');
for (const l of ['authenticity', 'anchoring', 'finality']) nemasurat(acc, l, 'not-judged', 'a reputation is a computation over the facts a verifier derived from an operation log: it carries no signature and no notarization of its own (the log is judged as the artifact `device-operation-log`)');
} else if (artifact.startsWith('dataset-')) {
const M = await incarca('baza'); let r;
if (artifact === 'dataset-record') r = M.verificaInregistrare(input.record, input.commitment);