conformance: the identity presentation verifier enrolled (134 rules of 10 verifiers, 273 vectors); the reference verifier instruction names all five files beside verify-proof.mjs; module READMEs point to aere.network/tools

This commit is contained in:
Aere Network committed 2026-10-05 18:53:32 +03:00
1 parent c9798a0013
commit 5fb38c5d0b
88 files changed
+20246 -179

No files matched your search

+27 -3
View File
@@ -182,6 +182,30 @@ structure (`_sd`, `_sd_alg`, `{"...": digest}`), which would let a holder disclo
SD-JWT VC (no `vct`, no type metadata), and no status list inside the token (revocation stays with the AERE credential's list).
Checked against the RFC's vectors, not against another SD-JWT library: that is not measured.
## Named rules
Since 2026-10-05 every refusal of `verifyPresentation` names its rule. A row is `{ name, pass, detail, rule }`; a row that was not
judged is `{ name, pass: null, detail, unjudged }` with its cause. The result carries `rules`, the sorted ids of the rules that
refused, and `unjudged`, the sorted causes of what was not judged. The module exports the lists: `REGULI` (37 rules), `NEJUDECATE`
(7 causes) and `OPRIRI` (the four rules after whose refusal other checks were not made: `form`, `chain-length`, `delegation-form`,
`unreadable`). A time field that cannot be read (a credential's validity, a delegation's or a presentation's bounds) and a malformed
earlier link are reported as `unreadable`, which is one of the stopping rules: the checks after it are not made. The verifier does
not stop at its first refusal: it makes every check it can reach. `valid` is unchanged: true when
no row failed, also when rows were not judged; a caller that needs "nothing left unjudged" reads `unjudged`.
With these ids the presentation verifier is enrolled in the conformance suite beside this folder (`conformance/`: 37 rules,
65 vectors of the artifact kind `identity-presentation`, each rule taken out of a copy of the verifier in turn). SD-JWT, Travel Rule
and compliance are not enrolled there.
Two things changed in behaviour that day, both measured by `proba-identity.mjs`, each with its planting in the negative control:
- found while the verifier was being enrolled: when the issuer keys in a credential could not be read (for example an Ed25519 key in
the `mldsa65` field), the verifier also reported that the holder id is not the id of its keys. The two ids were derived in one
step, and the first failure left the second underived. The credential was refused either way; the report named the holder for a
fault of the issuer's keys. Each id is now derived on its own;
- a `statusLists` or `revocations` argument that is not a list is an error of the caller and throws, like a `trustedIssuers` that
is not a list; until then the first two came back as an unreadable presentation.
## What it does not do
It does not bind a key to hardware: a device key is a key like any other, and no TPM or secure-enclave attestation is checked here. It
@@ -192,14 +216,14 @@ line is reported as not judged. The private key files are written with mode 0600
## Tests
```
node proba-identity.mjs # 44: the paths above, and each attack of the adversarial review as its own test
node control-negativ-identity.mjs # on a copy, each of 49 guards removed -> its own named test turns red
node proba-identity.mjs # 46: the paths above, each attack of the adversarial review as its own test, the named rules
node control-negativ-identity.mjs # on a copy, each of 53 guards removed -> its own named test turns red
node proba-conformitate.mjs # 15: compliance policies judged on real presentations, the record without personal data, the command line
node control-negativ-conformitate.mjs # on a copy, each of 14 guards removed -> its own named test turns red
node proba-travel-rule.mjs # 19: two VASPs with registry credentials, the whole exchange, and each attack of the review
node control-negativ-travel-rule.mjs # on a copy, each of 19 guards removed -> its own named test turns red
node proba-sdjwt.mjs # 23: the RFC 9901 vectors, SD-JWTs issued with AERE keys (EdDSA and ML-DSA-65), each attack
node control-negativ-sdjwt.mjs # on a copy, each of 28 guards removed -> its own named test turns red
node control-negativ-sdjwt.mjs # on a copy, each of 29 guards removed -> its own named test turns red
```
The envelope test needs the AIP-23 reference verifier (`AERE_VERIFY_PROOF=<verify-proof.mjs>`); without it that test is reported as
+35 -30
View File
@@ -14,54 +14,59 @@ const VERIFY = process.env.AERE_VERIFY_PROOF || (fs.existsSync(DEV_VERIFY) ? DEV
const L = 'identity.mjs', C = 'identity-cli.mjs';
const PLANTARI = [
// B-30: forma publicata in aec0ccb (fara toleranta de ceas pe inceputuri, revocarea numai pe ceasul exact)
['fara toleranta pe validFrom (B-30)', L, 'vf - sk <= acum && acum <= vu,', 'vf <= acum && acum <= vu,', 'B-30'],
['toleranta si pe sfarsit (validUntil prelungit)', L, 'vf - sk <= acum && acum <= vu,', 'vf - sk <= acum && acum <= vu + sk,', 'B-30'],
['revocarea fara toleranta prudenta (B-30)', L, 'ok(`${et}: not revoked`, at > acum + sk,', 'ok(`${et}: not revoked`, at > acum,', 'revocarea: detinatorul revoca'],
['fara toleranta pe validFrom (B-30)', L, 'vf - sk <= acum && acum <= vu /*PAZA:credential-window*/,', 'vf <= acum && acum <= vu,', 'B-30'],
['toleranta si pe sfarsit (validUntil prelungit)', L, 'vf - sk <= acum && acum <= vu /*PAZA:credential-window*/,', 'vf - sk <= acum && acum <= vu + sk,', 'B-30'],
['revocarea fara toleranta prudenta (B-30)', L, "ok('delegation-revoked', `${et}: not revoked`, at > acum + sk /*PAZA:delegation-revoked*/,", "ok('delegation-revoked', `${et}: not revoked`, at > acum,", 'revocarea: detinatorul revoca'],
// [nume, fisier, tipar, inlocuire, proba (inceputul numelui ei)]
['o dezvaluire nesemnata de emitent primita', L, 'if (!sd.has(dg)) {', 'if (false) {', 'ATAC: o dezvaluire fabricata'],
['aceeasi dezvaluire primita de doua ori', L, 'if (vazuteD.has(dg) || vazuteN.has(d.name)) {', 'if (false) {', 'ATAC: aceeasi dezvaluire de doua ori'],
['o dezvaluire care acopera o afirmatie in clar primita', L, 'if (Object.hasOwn(S.claims, d.name)) {', 'if (false) {', 'ATAC: un emitent semneaza in sd o afirmatie'],
['digesturile dublate din sd primite', L, "ok('credential: the digests it signs are distinct', sd.size === S.sd.length,", "ok('credential: the digests it signs are distinct', true,", 'ATAC: un digest de doua ori in sd'],
['o dezvaluire nesemnata de emitent primita', L, 'if (!(sd.has(dg) /*PAZA:disclosure-signed*/)) {', 'if (false) {', 'ATAC: o dezvaluire fabricata'],
['aceeasi dezvaluire primita de doua ori', L, 'if (!(!(vazuteD.has(dg) || vazuteN.has(d.name)) /*PAZA:disclosure-once*/)) {', 'if (false) {', 'ATAC: aceeasi dezvaluire de doua ori'],
['o dezvaluire care acopera o afirmatie in clar primita', L, 'if (!(!Object.hasOwn(S.claims, d.name) /*PAZA:disclosure-plain*/)) {', 'if (false) {', 'ATAC: un emitent semneaza in sd o afirmatie'],
['digesturile dublate din sd primite', L, 'sd.size === S.sd.length /*PAZA:sd-distinct*/,', 'true,', 'ATAC: un digest de doua ori in sd'],
['numele rezervate (__proto__) primite', L, "return typeof n === 'string' && NUME.test(n) && !REZERVATE.has(n);", "return typeof n === 'string' && NUME.test(n);", 'ATAC: o dezvaluire cu numele __proto__'],
['alta codare base64url a aceleiasi dezvaluiri primita', L, "if (b.toString('base64url') !== enc) throw", 'if (false) throw', 'ATAC: o dezvaluire in alta codare base64url'],
['publicul verificatorului nu se mai compara', L, 'B.audience === audience,', 'true,', 'ATAC: reluata la alt verificator'],
['nonce-ul verificatorului nu se mai compara', L, 'B.nonce === nonce,', 'true,', 'ATAC: reluata la alt verificator'],
['prospetimea prezentarii nu se mai cere', L, 'Math.abs(acum - t) <= maxAgeS * 1000,', 'true,', 'ATAC: prezentare veche'],
['oricine poate prezenta credentialul detinatorului', L, 'asteptat && B.presenter.id === asteptat.id && canonical(B.presenter.keys) === canonical(asteptat.keys),', 'true,', 'ATAC: un strain prezinta'],
['prezentatorul nu mai trebuie sa fie ultimul delegat', L, 'asteptat && B.presenter.id === asteptat.id && canonical(B.presenter.keys) === canonical(asteptat.keys),', 'true,', 'ATAC: detinatorul prezinta singur'],
['dezvaluirile nu mai sunt legate de semnatura prezentarii', L, 'B.disclosuresHash === hashOf(p.disclosures),', 'true,', 'ATAC: dezvaluiri adaugate dupa semnare'],
['lantul de delegare nu mai e legat de semnatura prezentarii', L, 'canonical(B.delegations) === canonical(p.delegations.map(delegationHash)),', 'true,', 'ATAC: lantul scos sau inversat'],
['publicul verificatorului nu se mai compara', L, 'B.audience === audience /*PAZA:audience*/,', 'true,', 'ATAC: reluata la alt verificator'],
['nonce-ul verificatorului nu se mai compara', L, 'B.nonce === nonce /*PAZA:nonce*/,', 'true,', 'ATAC: reluata la alt verificator'],
['prospetimea prezentarii nu se mai cere', L, 'Math.abs(acum - t) <= maxAgeS * 1000 /*PAZA:freshness*/,', 'true,', 'ATAC: prezentare veche'],
['oricine poate prezenta credentialul detinatorului', L, 'asteptat && B.presenter.id === asteptat.id && canonical(B.presenter.keys) === canonical(asteptat.keys) /*PAZA:presenter*/,', 'true,', 'ATAC: un strain prezinta'],
['prezentatorul nu mai trebuie sa fie ultimul delegat', L, 'asteptat && B.presenter.id === asteptat.id && canonical(B.presenter.keys) === canonical(asteptat.keys) /*PAZA:presenter*/,', 'true,', 'ATAC: detinatorul prezinta singur'],
['dezvaluirile nu mai sunt legate de semnatura prezentarii', L, 'B.disclosuresHash === hashOf(p.disclosures) /*PAZA:binding-disclosures*/,', 'true,', 'ATAC: dezvaluiri adaugate dupa semnare'],
['lantul de delegare nu mai e legat de semnatura prezentarii', L, 'canonical(B.delegations) === canonical(p.delegations.map(delegationHash)) /*PAZA:binding-delegations*/,', 'true,', 'ATAC: lantul scos sau inversat'],
['fara separare de domeniu (acelasi mesaj pe toate scopurile)', L, "return Buffer.from(DOMENIU + scop + '\\n' + text, 'utf8');", "return Buffer.from(text, 'utf8');", 'ATAC: semnatura de DELEGARE'],
['una din cele doua semnaturi ajunge', L, "Buffer.from(sig.ed25519, 'base64')) && crypto.verify(", "Buffer.from(sig.ed25519, 'base64')) || crypto.verify(", 'ATAC: partea ML-DSA a semnaturii'],
['algoritmul declarat nu se mai cere', L, "if (!sig || sig.alg !== ALG || typeof sig.ed25519 !== 'string'", "if (!sig || typeof sig.ed25519 !== 'string'", 'ATAC: partea Ed25519 lipsa sau alg retrogradat'],
['id-ul emitentului nu mai e derivat din chei', L, "ok('credential: the issuer id is the id of its keys', idE && idE === S.issuer.id,", "ok('credential: the issuer id is the id of its keys', true,", 'ATAC: id-ul emitentului schimbat'],
['id-ul emitentului nu mai e derivat din chei', L, 'idE && idE === S.issuer.id /*PAZA:issuer-id*/,', 'true,', 'ATAC: id-ul emitentului schimbat'],
['tipul cheii publice nu se mai verifica', L, 'if (k.asymmetricKeyType !== tip) throw', 'if (false) throw', 'ATAC: o cheie ML-DSA pusa in campul ed25519'],
['emitentii de incredere nu se mai cer', L, "ok('credential: issuer trusted', idsIncredere.includes(S.issuer.id),", "ok('credential: issuer trusted', true,", 'CONTROL: emitent in afara celor de incredere'],
['fereastra credentialului nu se mai cere', L, 'vf - sk <= acum && acum <= vu,', 'true,', 'CONTROL: emitent in afara celor de incredere'],
['emitentii de incredere nu se mai cer', L, 'idsIncredere.includes(S.issuer.id) /*PAZA:issuer-trusted*/,', 'true,', 'CONTROL: emitent in afara celor de incredere'],
['fereastra credentialului nu se mai cere', L, 'vf - sk <= acum && acum <= vu /*PAZA:credential-window*/,', 'true,', 'CONTROL: emitent in afara celor de incredere'],
['un fisier de chei cu partea publica a altcuiva primit', L, 'if (canonical(keys.public) !== canonical(j.public) || keys.id !== j.id) throw', 'if (false) throw', 'cheile: exportKeys'],
['bitul de revocare ignorat', L, '!rev,', 'true,', 'lista de stare: bitul 42'],
['bitul de revocare ignorat', L, '!rev /*PAZA:credential-revoked*/,', 'true,', 'lista de stare: bitul 42'],
['cu doua liste, ultima castiga (revocarea se ridica)', L, 'rev = statusBit(L, S.status.index) || rev;', 'rev = statusBit(L, S.status.index);', 'lista de stare: bitul 42'],
['bitul 0 numarat de la coada octetului', L, 'biti[i >> 3] |= 0x80 >> (i & 7);', 'biti[i >> 3] |= 1 << (i & 7);', 'lista de stare: bitul 0'],
['o lista a altui emitent crezuta', L, "try { return l.statement.kind === 'aere-status-list'", "try { return true || l.statement.kind === 'aere-status-list'", 'ATAC: o lista cu acelasi id semnata de ALT emitent'],
['o lista expirata tacuta', L, 'else if (!curente.length) nejudecat(', 'else if (false) nejudecat(', 'lista expirata sau lipsa'],
['lista decomprimata fara plafon', L, "{ maxOutputLength: S.size / 8 }", '{}', 'ATAC: o lista care se decomprima peste'],
['marimea declarata a listei nu mai e marginita', L, 'if (!Number.isInteger(S.size) || S.size < 8 || S.size % 8 || S.size > MAX_STATUS_BITS) throw new Error(\'the list declares', 'if (false) throw new Error(\'the list declares', 'ATAC: o lista care se decomprima peste'],
['veriga poate fi data de oricine', L, 'dela && D.from.id === dela.id && canonical(D.from.keys) === canonical(dela.keys),', 'true,', 'ATAC: lantul rupt'],
['prima veriga poate fi data de altcineva decat detinatorul', L, 'dela && D.from.id === dela.id && canonical(D.from.keys) === canonical(dela.keys),', 'true,', 'ATAC: prima veriga data de altcineva'],
['semnatura verigii nu se mai verifica', L, "verifyText('delegation', canonical(D), lant[i].signature, D.from.keys),", 'true,', 'ATAC: o veriga in numele telefonului semnata de un strain'],
['veriga-parinte nu se mai compara', L, 'D.parent === (i === 0 ? null : delegationHash(lant[i - 1])),', 'true,', 'ATAC: veriga-parinte numita gresit'],
['adancimea nu se mai cere', L, 'Number.isInteger(D.maxDepth) && D.maxDepth >= lant.length - 1 - i,', 'true,', 'ATAC: adancimea'],
['re-delegarea poate largi', L, "ok(`${et}: only narrows the previous link`, ingust &&", "ok(`${et}: only narrows the previous link`, true ||", 'ATAC: re-delegarea largeste scopul'],
['veriga poate fi data de oricine', L, 'dela && D.from.id === dela.id && canonical(D.from.keys) === canonical(dela.keys) /*PAZA:delegation-from*/,', 'true,', 'ATAC: lantul rupt'],
['prima veriga poate fi data de altcineva decat detinatorul', L, 'dela && D.from.id === dela.id && canonical(D.from.keys) === canonical(dela.keys) /*PAZA:delegation-from*/,', 'true,', 'ATAC: prima veriga data de altcineva'],
['semnatura verigii nu se mai verifica', L, "verifyText('delegation', canonical(D), lant[i].signature, D.from.keys) /*PAZA:delegation-signature*/,", 'true,', 'ATAC: o veriga in numele telefonului semnata de un strain'],
['veriga-parinte nu se mai compara', L, 'D.parent === (i === 0 ? null : delegationHash(lant[i - 1])) /*PAZA:delegation-parent*/,', 'true,', 'ATAC: veriga-parinte numita gresit'],
['adancimea nu se mai cere', L, 'Number.isInteger(D.maxDepth) && D.maxDepth >= lant.length - 1 - i /*PAZA:delegation-depth*/,', 'true,', 'ATAC: adancimea'],
['re-delegarea poate largi', L, "ok('delegation-narrows', `${et}: only narrows the previous link`, ingust &&", "ok('delegation-narrows', `${et}: only narrows the previous link`, true ||", 'ATAC: re-delegarea largeste scopul'],
['biblioteca scrie o re-delegare mai larga', L, "if (!inclus(sc[k], P.scope[k])) throw", 'if (false) throw', 'ATAC: re-delegarea largeste scopul'],
['scopul nu mai limiteaza afirmatiile aratate', L, 'ok(`${et}: covers the disclosed claims`, !afara.length,', 'ok(`${et}: covers the disclosed claims`, true,', 'ATAC: delegatul arata o afirmatie din afara scopului'],
['scopul nu mai limiteaza publicul', L, 'permite(sc.audiences, B.audience),', 'true,', 'ATAC: delegatul arata o afirmatie din afara scopului'],
['scopul nu mai limiteaza credentialul', L, 'permite(sc.credentials, S.id),', 'true,', 'ATAC: delegatul arata o afirmatie din afara scopului'],
['fereastra verigii nu se mai cere', L, 'nb - sk <= acum && acum <= na && nb - sk <= t && t <= na,', 'true,', 'ATAC: veriga expirata'],
['scopul nu mai limiteaza afirmatiile aratate', L, '!afara.length /*PAZA:delegation-claims*/,', 'true,', 'ATAC: delegatul arata o afirmatie din afara scopului'],
['scopul nu mai limiteaza publicul', L, 'permite(sc.audiences, B.audience) /*PAZA:delegation-audience*/,', 'true,', 'ATAC: delegatul arata o afirmatie din afara scopului'],
['scopul nu mai limiteaza credentialul', L, 'permite(sc.credentials, S.id) /*PAZA:delegation-credential*/,', 'true,', 'ATAC: delegatul arata o afirmatie din afara scopului'],
['fereastra verigii nu se mai cere', L, 'nb - sk <= acum && acum <= na && nb - sk <= t && t <= na /*PAZA:delegation-window*/,', 'true,', 'ATAC: veriga expirata'],
['oricine poate revoca o veriga', L, 'const autor = R.by && (R.by.id === D.from.id || R.by.id === S.holder.id);', 'const autor = true;', 'revocarea: detinatorul revoca'],
['o revocare se aplica inainte de momentul ei', L, 'ok(`${et}: not revoked`, at > acum + sk,', 'ok(`${et}: not revoked`, false,', 'revocarea: detinatorul revoca'],
['o revocare se aplica inainte de momentul ei', L, "ok('delegation-revoked', `${et}: not revoked`, at > acum + sk /*PAZA:delegation-revoked*/,", "ok('delegation-revoked', `${et}: not revoked`, false,", 'revocarea: detinatorul revoca'],
['revocarea acceptata sub scopul delegarii', L, "verifyText('revocation', canonical(R), r.signature, R.by.keys)", "verifyText('delegation', canonical(R), r.signature, R.by.keys)", 'ATAC: o revocare cu semnatura detinatorului dar alt scop'],
['o lista stricata acuza credentialul', L, "verifyText('status-list', canonical(l.statement), l.signature, S.issuer.keys); } catch { return false; } });", "verifyText('status-list', canonical(l.statement), l.signature, S.issuer.keys); } catch (e) { throw e; } });", 'intrari stricate date verificatorului'],
['o revocare stricata acuza prezentarea', L, "try { canonical(R); } catch { nejudecat(`${et}: a revocation`, 'ignored: not readable'); continue; }", '', 'intrari stricate date verificatorului'],
['o revocare stricata acuza prezentarea', L, "try { canonical(R); } catch { nejudecat('revocation-ignored', `${et}: a revocation`, 'ignored: not readable'); continue; }", '', 'intrari stricate date verificatorului'],
// 2026-10-05: regulile numite
['cheile emitentului necitibile acuza si detinatorul (forma dinainte de 2026-10-05)', L, "try { idE = idOf(S.issuer.keys); } catch (e) { /* randul de mai jos spune */ }\n try { idH = idOf(S.holder.keys); }", 'try { idE = idOf(S.issuer.keys); idH = idOf(S.holder.keys); }', 'ATAC: emitent cu o cheie Ed25519 in campul mldsa65'],
['rezultatul nu mai numeste regulile care au refuzat', L, "rules: [...new Set(rows.filter((r) => r.pass === false).map((r) => r.rule))].sort(),", 'rules: [],', 'fiecare refuz isi numeste regula'],
['un rand nejudecat fara cauza', L, "rows.push({ name, pass: null, detail, unjudged: cauza });", 'rows.push({ name, pass: null, detail });', 'fiecare refuz isi numeste regula'],
['o lista de stare care nu e lista acuza prezentarea', L, 'if (!Array.isArray(statusLists) || !Array.isArray(revocations)) throw', 'if (false) throw', 'fiecare refuz isi numeste regula'],
['linia de comanda suprascrie o cheie', C, 'if (privat && fs.existsSync(f)) throw new Folosire(', 'if (false) throw new Folosire(', 'linia de comanda'],
// 2026-09-30: tiparul poarta randul de dinainte, fiindca verify-sdjwt are si el `return r.valid ? 0 : 1;`
['verify din linia de comanda iese 0 si pe INVALID', C, "JSON.stringify(r.claims));\n }\n return r.valid ? 0 : 1;", "JSON.stringify(r.claims));\n }\n return 0;", 'linia de comanda'],
+77 -57
View File
@@ -285,40 +285,59 @@ export function present({ credential, disclosures = [], reveal = [], presenter,
// (validFrom al credentialului si al listei de stare, notBefore al delegarii) si in sensul prudent pe revocari (o revocare cu momentul
// pana la clockSkewS in viitor se aplica deja); niciodata pe sfarsituri (validUntil, notAfter), unde ar prelungi o valabilitate.
export const CLOCK_SKEW_S = 60;
// 2026-10-05 (conformance suite): every refusal of verifyPresentation NAMES its rule. REGULI is the list of the rules it can name (the
// helper throws on any other); every check of a rule carries a PAZA marker with the rule id, read by the suite's derivation
// (declared == marked == mapped there). A row is { name, pass, detail, rule }; a row that was not judged is { name, pass: null, detail,
// unjudged: <cause> } with the cause from NEJUDECATE. The result carries `rules` (the sorted ids that refused) and `unjudged` (the
// sorted causes). OPRIRI are the rules after whose refusal other checks were NOT made (the verifier returned, or skipped a link).
export const REGULI = ['form', 'issuer-id', 'holder-id', 'credential-signature', 'issuer-trusted', 'credential-window', 'status-list', 'credential-revoked', 'sd-distinct',
'disclosure-readable', 'disclosure-signed', 'disclosure-once', 'disclosure-plain', 'claim-name', 'binding-credential', 'binding-disclosures', 'binding-delegations', 'presenter',
'presentation-signature', 'audience', 'nonce', 'freshness', 'chain-length', 'delegation-form', 'delegation-ids', 'delegation-from', 'delegation-parent', 'delegation-signature',
'delegation-scope', 'delegation-window', 'delegation-depth', 'delegation-narrows', 'delegation-credential', 'delegation-claims', 'delegation-audience', 'delegation-revoked', 'unreadable'];
export const NEJUDECATE = ['issuer-trust', 'status-none', 'status-unread', 'audience', 'nonce', 'revocation-ignored', 'revocations-none'];
export const OPRIRI = ['form', 'chain-length', 'delegation-form', 'unreadable'];
class Nedeclarata extends Error {}
export function verifyPresentation(p, { audience = null, nonce = null, now = new Date(), trustedIssuers = null, statusLists = [], revocations = [], maxAgeS = 300, clockSkewS = CLOCK_SKEW_S } = {}) {
const rows = [];
const ok = (name, pass, detail = '') => { rows.push({ name, pass: !!pass, detail: pass ? '' : detail }); return !!pass; };
const nejudecat = (name, detail) => rows.push({ name, pass: null, detail });
const ok = (rule, name, pass, detail = '') => { if (!REGULI.includes(rule)) throw new Nedeclarata('aere-identity: undeclared rule ' + rule); rows.push({ name, pass: !!pass, detail: pass ? '' : detail, rule }); return !!pass; };
const nejudecat = (cauza, name, detail) => { if (!NEJUDECATE.includes(cauza)) throw new Nedeclarata('aere-identity: undeclared cause ' + cauza); rows.push({ name, pass: null, detail, unjudged: cauza }); };
const acum = new Date(now).getTime();
if (!Number.isInteger(clockSkewS) || clockSkewS < 0 || clockSkewS > 600) throw new Error('verifyPresentation: clockSkewS is 0..600 seconds');
const sk = clockSkewS * 1000;
// 2026-09-30 (API-ul Identity din Cloud): o prezentare VALIDA spune si despre cine e (tip, credential, emitent, detinator, cine a
// prezentat), ca verificatorul care nu a dat trustedIssuers sa vada pe cine ar trebui sa creada; numai pe drumul care ajunge la capat
const gata = (claims = null, subject = null) => { const valid = rows.every((r) => r.pass !== false); return { valid, rows, notJudged: rows.filter((r) => r.pass === null).length, claims: valid ? claims : null, subject: valid ? subject : null }; };
const gata = (claims = null, subject = null) => { const valid = rows.every((r) => r.pass !== false); return { valid, rows, notJudged: rows.filter((r) => r.pass === null).length,
rules: [...new Set(rows.filter((r) => r.pass === false).map((r) => r.rule))].sort(), unjudged: [...new Set(rows.filter((r) => r.pass === null).map((r) => r.unjudged))].sort(),
claims: valid ? claims : null, subject: valid ? subject : null }; };
// configuratia verificatorului se valideaza inainte (o cheie de incredere stricata e o greseala a lui, nu o prezentare invalida)
if (trustedIssuers != null && !Array.isArray(trustedIssuers)) throw new Error('verifyPresentation: trustedIssuers is a list of ids or public keys');
const idsIncredere = trustedIssuers == null ? null : trustedIssuers.map((x) => (typeof x === 'string' && ID.test(x) ? x : idOf(x)));
if (!Array.isArray(statusLists) || !Array.isArray(revocations)) throw new Error('verifyPresentation: statusLists and revocations are lists');
try {
if (!p || p.kind !== 'aere-presentation' || p.v !== VERSION || !p.credential || !p.binding || !Array.isArray(p.disclosures) || !Array.isArray(p.delegations)) {
ok('presentation: well formed', false, 'not an aere-presentation'); return gata();
if (!((!!p && p.kind === 'aere-presentation' && p.v === VERSION && !!p.credential && !!p.binding && Array.isArray(p.disclosures) && Array.isArray(p.delegations)) /*PAZA:form*/)) {
ok('form', 'presentation: well formed', false, 'not an aere-presentation'); return gata();
}
const c = p.credential, S = c.statement, B = p.binding;
if (!S || S.kind !== 'aere-credential' || S.v !== VERSION || !S.issuer || !S.holder || !Array.isArray(S.sd) || !S.claims || typeof S.claims !== 'object' || Array.isArray(S.claims)) {
ok('credential: well formed', false, 'not an aere-credential'); return gata();
if (!((!!S && S.kind === 'aere-credential' && S.v === VERSION && !!S.issuer && !!S.holder && Array.isArray(S.sd) && !!S.claims && typeof S.claims === 'object' && !Array.isArray(S.claims)) /*PAZA:form*/)) {
ok('form', 'credential: well formed', false, 'not an aere-credential'); return gata();
}
// 1. emitentul si detinatorul, legati de chei
let idE = null, idH = null; try { idE = idOf(S.issuer.keys); idH = idOf(S.holder.keys); } catch (e) { /* randurile de mai jos spun */ }
ok('credential: the issuer id is the id of its keys', idE && idE === S.issuer.id, `issuer id ${S.issuer.id} is not derived from the keys in the credential`);
ok('credential: the holder id is the id of its keys', idH && idH === S.holder.id, `holder id ${S.holder.id} is not derived from the keys in the credential`);
ok(`credential: signed by ${String(S.issuer.id)} (Ed25519 and ML-DSA-65, both)`, verifyText('credential', canonical(S), c.signature, S.issuer.keys), 'the hybrid signature does not verify with the issuer\'s keys');
if (trustedIssuers == null) nejudecat('credential: issuer trusted', 'not judged: anyone can issue a credential with their own keys; pass trustedIssuers (ids or public keys) to require who issued');
// 2026-10-05: each id in its own try. In one try, issuer keys that could not be read left the holder id underived too, and the
// verdict named the holder (holder-id) for a fault of the issuer's keys.
let idE = null, idH = null; try { idE = idOf(S.issuer.keys); } catch (e) { /* randul de mai jos spune */ }
try { idH = idOf(S.holder.keys); } catch (e) { /* randul de mai jos spune */ }
ok('issuer-id', 'credential: the issuer id is the id of its keys', idE && idE === S.issuer.id /*PAZA:issuer-id*/, `issuer id ${S.issuer.id} is not derived from the keys in the credential`);
ok('holder-id', 'credential: the holder id is the id of its keys', idH && idH === S.holder.id /*PAZA:holder-id*/, `holder id ${S.holder.id} is not derived from the keys in the credential`);
ok('credential-signature', `credential: signed by ${String(S.issuer.id)} (Ed25519 and ML-DSA-65, both)`, verifyText('credential', canonical(S), c.signature, S.issuer.keys) /*PAZA:credential-signature*/, 'the hybrid signature does not verify with the issuer\'s keys');
if (trustedIssuers == null) nejudecat('issuer-trust', 'credential: issuer trusted', 'not judged: anyone can issue a credential with their own keys; pass trustedIssuers (ids or public keys) to require who issued');
else {
ok('credential: issuer trusted', idsIncredere.includes(S.issuer.id), `${S.issuer.id} is not among the ${idsIncredere.length} trusted issuer(s)`);
ok('issuer-trusted', 'credential: issuer trusted', idsIncredere.includes(S.issuer.id) /*PAZA:issuer-trusted*/, `${S.issuer.id} is not among the ${idsIncredere.length} trusted issuer(s)`);
}
// 2. fereastra, pe ceasul verificatorului
const vf = data(S.validFrom, 'validFrom'), vu = data(S.validUntil, 'validUntil');
ok(`credential: valid at ${iso(acum)}`, vf - sk <= acum && acum <= vu, `valid from ${S.validFrom} until ${S.validUntil}`);
ok('credential-window', `credential: valid at ${iso(acum)}`, vf - sk <= acum && acum <= vu /*PAZA:credential-window*/, `valid from ${S.validFrom} until ${S.validUntil}`);
// 3. starea (revocarea) credentialului
if (!S.status) nejudecat('credential: status', 'the credential names no status list, so its issuer cannot revoke it');
if (!S.status) nejudecat('status-none', 'credential: status', 'the credential names no status list, so its issuer cannot revoke it');
else {
const liste = statusLists.filter((l) => l && l.statement && l.statement.id === S.status.list);
// o lista stricata (adusa de pe retea, de pilda) nu acuza credentialul: e ignorata, ca una a altui emitent
@@ -326,89 +345,90 @@ export function verifyPresentation(p, { audience = null, nonce = null, now = new
&& canonical(l.statement.issuer.keys) === canonical(S.issuer.keys) && verifyText('status-list', canonical(l.statement), l.signature, S.issuer.keys); } catch { return false; } });
// numai listele emitentului valabile ACUM; cu mai multe, un bit pus in oricare inseamna revocat (revocarea nu se ridica)
const curente = aEmitentului.filter((l) => { try { return data(l.statement.validFrom, 'status validFrom') - sk <= acum && acum <= data(l.statement.validUntil, 'status validUntil'); } catch { return false; } });
if (!aEmitentului.length) nejudecat(`credential: status in ${S.status.list}`, liste.length ? 'the status list(s) given with this id are not signed by the issuer: ignored' : 'the status list was not handed to the verifier; a revocation it was not handed cannot be seen');
else if (!curente.length) nejudecat(`credential: status in ${S.status.list}`, `the issuer's status list(s) given are not valid at ${iso(acum)}: fetch a current one`);
if (!aEmitentului.length) nejudecat('status-unread', `credential: status in ${S.status.list}`, liste.length ? 'the status list(s) given with this id are not signed by the issuer: ignored' : 'the status list was not handed to the verifier; a revocation it was not handed cannot be seen');
else if (!curente.length) nejudecat('status-unread', `credential: status in ${S.status.list}`, `the issuer's status list(s) given are not valid at ${iso(acum)}: fetch a current one`);
else {
let rev = false, citite = 0;
for (const L of curente) { try { rev = statusBit(L, S.status.index) || rev; citite++; } catch (e) { ok(`credential: status in ${S.status.list}`, false, String(e.message)); } }
if (citite) ok(`credential: not revoked (status list ${S.status.list}, index ${S.status.index})`, !rev, 'the issuer revoked this credential');
for (const L of curente) { try { rev = statusBit(L, S.status.index) || rev; citite++; } catch (e) { if (!(false /*PAZA:status-list*/)) ok('status-list', `credential: status in ${S.status.list}`, false, String(e.message)); } }
if (citite) ok('credential-revoked', `credential: not revoked (status list ${S.status.list}, index ${S.status.index})`, !rev /*PAZA:credential-revoked*/, 'the issuer revoked this credential');
}
}
// 4. dezvaluirile: fiecare semnata (digestul in sd), o singura data, fara sa acopere o afirmatie in clar
const sd = new Set(S.sd);
ok('credential: the digests it signs are distinct', sd.size === S.sd.length, 'a digest appears twice in sd');
ok('sd-distinct', 'credential: the digests it signs are distinct', sd.size === S.sd.length /*PAZA:sd-distinct*/, 'a digest appears twice in sd');
const dezvaluite = []; const vazuteD = new Set(), vazuteN = new Set(); let bune = true;
for (const enc of p.disclosures) {
let d; try { d = decodeDisclosure(enc); } catch (e) { bune = ok('disclosure: readable', false, e.message); continue; }
let d; try { d = decodeDisclosure(enc); } catch (e) { if (!(false /*PAZA:disclosure-readable*/)) bune = ok('disclosure-readable', 'disclosure: readable', false, e.message); continue; }
const dg = digestOf(enc);
if (!sd.has(dg)) { bune = ok(`disclosure ${d.name}: signed by the issuer`, false, 'its digest is not in the credential'); continue; }
if (vazuteD.has(dg) || vazuteN.has(d.name)) { bune = ok(`disclosure ${d.name}: shown once`, false, 'the same claim is disclosed twice'); continue; }
if (Object.hasOwn(S.claims, d.name)) { bune = ok(`disclosure ${d.name}: does not cover a plain claim`, false, 'the credential has this claim in the clear too'); continue; }
if (!(sd.has(dg) /*PAZA:disclosure-signed*/)) { bune = ok('disclosure-signed', `disclosure ${d.name}: signed by the issuer`, false, 'its digest is not in the credential'); continue; }
if (!(!(vazuteD.has(dg) || vazuteN.has(d.name)) /*PAZA:disclosure-once*/)) { bune = ok('disclosure-once', `disclosure ${d.name}: shown once`, false, 'the same claim is disclosed twice'); continue; }
if (!(!Object.hasOwn(S.claims, d.name) /*PAZA:disclosure-plain*/)) { bune = ok('disclosure-plain', `disclosure ${d.name}: does not cover a plain claim`, false, 'the credential has this claim in the clear too'); continue; }
vazuteD.add(dg); vazuteN.add(d.name); dezvaluite.push(d);
}
if (bune) ok(`disclosures: ${dezvaluite.length} shown, each signed by the issuer, once`, true);
for (const n of Object.keys(S.claims)) if (!numeValid(n)) ok(`credential: claim name ${n}`, false, 'a claim name that is not allowed');
if (bune) ok('disclosure-signed', `disclosures: ${dezvaluite.length} shown, each signed by the issuer, once`, true);
for (const n of Object.keys(S.claims)) if (!(numeValid(n) /*PAZA:claim-name*/)) ok('claim-name', `credential: claim name ${n}`, false, 'a claim name that is not allowed');
// 5. legatura prezentarii: ce credential, ce dezvaluiri, ce lant, cine prezinta
if (!B || B.kind !== 'aere-presentation-binding' || B.v !== VERSION || !B.presenter) { ok('presentation: binding well formed', false, 'not an aere-presentation-binding'); return gata(); }
ok('presentation: names this credential', B.credentialHash === credentialHash(c), 'the binding names another credential');
ok('presentation: names exactly these disclosures', B.disclosuresHash === hashOf(p.disclosures), 'disclosures added, removed or changed after signing');
ok('presentation: names exactly this delegation chain', Array.isArray(B.delegations) && canonical(B.delegations) === canonical(p.delegations.map(delegationHash)), 'the delegation chain is not the one signed');
if (!((!!B && B.kind === 'aere-presentation-binding' && B.v === VERSION && !!B.presenter) /*PAZA:form*/)) { ok('form', 'presentation: binding well formed', false, 'not an aere-presentation-binding'); return gata(); }
ok('binding-credential', 'presentation: names this credential', B.credentialHash === credentialHash(c) /*PAZA:binding-credential*/, 'the binding names another credential');
ok('binding-disclosures', 'presentation: names exactly these disclosures', B.disclosuresHash === hashOf(p.disclosures) /*PAZA:binding-disclosures*/, 'disclosures added, removed or changed after signing');
ok('binding-delegations', 'presentation: names exactly this delegation chain', Array.isArray(B.delegations) && canonical(B.delegations) === canonical(p.delegations.map(delegationHash)) /*PAZA:binding-delegations*/, 'the delegation chain is not the one signed');
const lant = p.delegations;
const asteptat = lant.length ? lant[lant.length - 1].statement && lant[lant.length - 1].statement.to : S.holder;
const cine = lant.length ? 'the last delegate' : 'the holder';
ok(`presentation: presented by ${cine}`, asteptat && B.presenter.id === asteptat.id && canonical(B.presenter.keys) === canonical(asteptat.keys), `presented by ${B.presenter.id}, expected ${asteptat && asteptat.id}`);
ok('presentation: signed by the presenter (Ed25519 and ML-DSA-65, both)', verifyText('presentation', canonical(B), p.signature, B.presenter.keys), 'the hybrid signature does not verify with the presenter\'s keys');
ok('presenter', `presentation: presented by ${cine}`, asteptat && B.presenter.id === asteptat.id && canonical(B.presenter.keys) === canonical(asteptat.keys) /*PAZA:presenter*/, `presented by ${B.presenter.id}, expected ${asteptat && asteptat.id}`);
ok('presentation-signature', 'presentation: signed by the presenter (Ed25519 and ML-DSA-65, both)', verifyText('presentation', canonical(B), p.signature, B.presenter.keys) /*PAZA:presentation-signature*/, 'the hybrid signature does not verify with the presenter\'s keys');
// 6. publicul, nonce-ul, prospetimea
if (audience == null) nejudecat('presentation: audience', 'not judged: without the verifier\'s own audience a presentation made for another verifier is accepted');
else ok(`presentation: made for ${audience}`, B.audience === audience, `made for ${B.audience}`);
if (nonce == null) nejudecat('presentation: nonce', 'not judged: without the verifier\'s nonce an old presentation can be replayed');
else ok('presentation: carries the verifier\'s nonce', B.nonce === nonce, 'another nonce');
if (audience == null) nejudecat('audience', 'presentation: audience', 'not judged: without the verifier\'s own audience a presentation made for another verifier is accepted');
else ok('audience', `presentation: made for ${audience}`, B.audience === audience /*PAZA:audience*/, `made for ${B.audience}`);
if (nonce == null) nejudecat('nonce', 'presentation: nonce', 'not judged: without the verifier\'s nonce an old presentation can be replayed');
else ok('nonce', 'presentation: carries the verifier\'s nonce', B.nonce === nonce /*PAZA:nonce*/, 'another nonce');
const t = data(B.createdAt, 'createdAt');
ok(`presentation: made within ${maxAgeS} s of the verifier's clock`, Math.abs(acum - t) <= maxAgeS * 1000, `made at ${B.createdAt}`);
ok('freshness', `presentation: made within ${maxAgeS} s of the verifier's clock`, Math.abs(acum - t) <= maxAgeS * 1000 /*PAZA:freshness*/, `made at ${B.createdAt}`);
// 7. lantul de delegare
if (lant.length > MAX_CHAIN) { ok('delegation: chain length', false, `${lant.length} links, at most ${MAX_CHAIN}`); return gata(); }
if (!(lant.length <= MAX_CHAIN /*PAZA:chain-length*/)) { ok('chain-length', 'delegation: chain length', false, `${lant.length} links, at most ${MAX_CHAIN}`); return gata(); }
for (let i = 0; i < lant.length; i++) {
const D = lant[i] && lant[i].statement, et = `delegation ${i + 1}/${lant.length}`;
if (!D || D.kind !== 'aere-delegation' || D.v !== VERSION || !D.from || !D.to || !D.scope) { ok(`${et}: well formed`, false, 'not an aere-delegation'); continue; }
if (!((!!D && D.kind === 'aere-delegation' && D.v === VERSION && !!D.from && !!D.to && !!D.scope) /*PAZA:delegation-form*/)) { ok('delegation-form', `${et}: well formed`, false, 'not an aere-delegation'); continue; }
const dela = i === 0 ? S.holder : lant[i - 1].statement.to;
let idF = null, idT = null; try { idF = idOf(D.from.keys); idT = idOf(D.to.keys); } catch { /* spus mai jos */ }
ok(`${et}: from and to are the ids of their keys`, idF === D.from.id && idT === D.to.id, 'an id not derived from its keys');
ok(`${et}: given by ${i === 0 ? 'the holder' : 'the previous delegate'}`, dela && D.from.id === dela.id && canonical(D.from.keys) === canonical(dela.keys), `given by ${D.from.id}`);
ok(`${et}: names its parent link`, D.parent === (i === 0 ? null : delegationHash(lant[i - 1])), 'the parent hash is not the previous link');
ok(`${et}: signed by who gave it (Ed25519 and ML-DSA-65, both)`, verifyText('delegation', canonical(D), lant[i].signature, D.from.keys), 'the hybrid signature does not verify');
let sc = null; try { sc = scopNormal(D.scope); } catch (e) { ok(`${et}: scope`, false, e.message); }
if (sc && canonical(sc) !== canonical(D.scope)) ok(`${et}: scope in normal form`, false, 'the scope is not sorted or has duplicates');
ok('delegation-ids', `${et}: from and to are the ids of their keys`, idF === D.from.id && idT === D.to.id /*PAZA:delegation-ids*/, 'an id not derived from its keys');
ok('delegation-from', `${et}: given by ${i === 0 ? 'the holder' : 'the previous delegate'}`, dela && D.from.id === dela.id && canonical(D.from.keys) === canonical(dela.keys) /*PAZA:delegation-from*/, `given by ${D.from.id}`);
ok('delegation-parent', `${et}: names its parent link`, D.parent === (i === 0 ? null : delegationHash(lant[i - 1])) /*PAZA:delegation-parent*/, 'the parent hash is not the previous link');
ok('delegation-signature', `${et}: signed by who gave it (Ed25519 and ML-DSA-65, both)`, verifyText('delegation', canonical(D), lant[i].signature, D.from.keys) /*PAZA:delegation-signature*/, 'the hybrid signature does not verify');
let sc = null; try { sc = scopNormal(D.scope); } catch (e) { if (!(false /*PAZA:delegation-scope*/)) ok('delegation-scope', `${et}: scope`, false, e.message); }
if (sc && !(canonical(sc) === canonical(D.scope) /*PAZA:delegation-scope*/)) ok('delegation-scope', `${et}: scope in normal form`, false, 'the scope is not sorted or has duplicates');
const nb = data(D.notBefore, 'notBefore'), na = data(D.notAfter, 'notAfter');
ok(`${et}: valid at ${iso(acum)} and when the presentation was made`, nb - sk <= acum && acum <= na && nb - sk <= t && t <= na, `valid from ${D.notBefore} until ${D.notAfter}`);
ok(`${et}: allows the links after it`, Number.isInteger(D.maxDepth) && D.maxDepth >= lant.length - 1 - i, `maxDepth ${D.maxDepth}, ${lant.length - 1 - i} link(s) after it`);
ok('delegation-window', `${et}: valid at ${iso(acum)} and when the presentation was made`, nb - sk <= acum && acum <= na && nb - sk <= t && t <= na /*PAZA:delegation-window*/, `valid from ${D.notBefore} until ${D.notAfter}`);
ok('delegation-depth', `${et}: allows the links after it`, Number.isInteger(D.maxDepth) && D.maxDepth >= lant.length - 1 - i /*PAZA:delegation-depth*/, `maxDepth ${D.maxDepth}, ${lant.length - 1 - i} link(s) after it`);
if (i > 0 && sc) {
const P = lant[i - 1].statement;
const ingust = ['credentials', 'claims', 'audiences'].every((k) => inclus(sc[k], P.scope[k]));
ok(`${et}: only narrows the previous link`, ingust && nb >= data(P.notBefore, 'notBefore') && na <= data(P.notAfter, 'notAfter') && D.maxDepth <= P.maxDepth - 1, 'a wider scope, a wider window or a deeper delegation than the link it comes from');
ok('delegation-narrows', `${et}: only narrows the previous link`, ingust && nb >= data(P.notBefore, 'notBefore') && na <= data(P.notAfter, 'notAfter') && D.maxDepth <= P.maxDepth - 1 /*PAZA:delegation-narrows*/, 'a wider scope, a wider window or a deeper delegation than the link it comes from');
}
if (sc) {
ok(`${et}: covers this credential`, permite(sc.credentials, S.id), `${S.id} is outside its scope`);
ok('delegation-credential', `${et}: covers this credential`, permite(sc.credentials, S.id) /*PAZA:delegation-credential*/, `${S.id} is outside its scope`);
const afara = dezvaluite.map((d) => d.name).filter((n) => !permite(sc.claims, n));
ok(`${et}: covers the disclosed claims`, !afara.length, 'outside its scope: ' + afara.join(', '));
ok(`${et}: covers the audience`, permite(sc.audiences, B.audience), `${B.audience} is outside its scope`);
ok('delegation-claims', `${et}: covers the disclosed claims`, !afara.length /*PAZA:delegation-claims*/, 'outside its scope: ' + afara.join(', '));
ok('delegation-audience', `${et}: covers the audience`, permite(sc.audiences, B.audience) /*PAZA:delegation-audience*/, `${B.audience} is outside its scope`);
}
// revocarile: semnate de cel care a dat veriga sau de detinator, pe ceasul verificatorului
const h = delegationHash(lant[i]);
for (const r of revocations) {
const R = r && r.statement; if (!R || R.kind !== 'aere-revocation' || R.target !== h) continue;
try { canonical(R); } catch { nejudecat(`${et}: a revocation`, 'ignored: not readable'); continue; }
try { canonical(R); } catch { nejudecat('revocation-ignored', `${et}: a revocation`, 'ignored: not readable'); continue; }
const autor = R.by && (R.by.id === D.from.id || R.by.id === S.holder.id);
let idR = null; try { idR = idOf(R.by.keys); } catch { /* ignorata */ }
if (!autor || idR !== R.by.id || !verifyText('revocation', canonical(R), r.signature, R.by.keys)) { nejudecat(`${et}: a revocation`, `ignored: not signed by who gave the link or by the holder (${R.by && R.by.id})`); continue; }
let at = null; try { at = data(R.at, 'revocation at'); } catch { nejudecat(`${et}: a revocation`, 'ignored: its time is not an RFC 3339 UTC time'); continue; }
ok(`${et}: not revoked`, at > acum + sk, `revoked by ${R.by.id} at ${R.at}`);
if (!autor || idR !== R.by.id || !verifyText('revocation', canonical(R), r.signature, R.by.keys)) { nejudecat('revocation-ignored', `${et}: a revocation`, `ignored: not signed by who gave the link or by the holder (${R.by && R.by.id})`); continue; }
let at = null; try { at = data(R.at, 'revocation at'); } catch { nejudecat('revocation-ignored', `${et}: a revocation`, 'ignored: its time is not an RFC 3339 UTC time'); continue; }
ok('delegation-revoked', `${et}: not revoked`, at > acum + sk /*PAZA:delegation-revoked*/, `revoked by ${R.by.id} at ${R.at}`);
}
}
if (lant.length && !revocations.length) nejudecat('delegation: revocations', 'none given; a revocation the verifier was not handed cannot be seen');
if (lant.length && !revocations.length) nejudecat('revocations-none', 'delegation: revocations', 'none given; a revocation the verifier was not handed cannot be seen');
const claims = Object.fromEntries([...Object.entries(S.claims), ...dezvaluite.map((d) => [d.name, d.value])].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
return gata(claims, { type: S.type, credential: S.id, issuer: S.issuer.id, holder: S.holder.id, presenter: B.presenter.id, delegations: lant.length });
} catch (e) {
ok('presentation: readable', false, String(e && e.message || e).slice(0, 200));
if (e instanceof Nedeclarata) throw e;
if (!(false /*PAZA:unreadable*/)) ok('unreadable', 'presentation: readable', false, String(e && e.message || e).slice(0, 200));
return gata();
}
}
+18
View File
@@ -281,6 +281,24 @@ test('intrari stricate date verificatorului (lista fara chei, revocare cu o valo
const r2 = I.verifyPresentation(prezD(), { ...toate, revocations: [rv] }); cere(r2.valid && r2.rows.some((x) => x.pass === null && /not readable/.test(x.detail)), fals(r2) || 'aplicata');
cere(/public keys must be/.test(arunca(() => I.verifyPresentation(prez(), { ...toate, trustedIssuers: [{ alg: 'x' }] })) || ''), 'cheia de incredere stricata primita');
});
// 2026-10-05 (gasit la inrolarea in suita de conformitate): cheile emitentului necitibile nu acuza si detinatorul
test('ATAC: emitent cu o cheie Ed25519 in campul mldsa65 -> refuzat pentru emitent (issuer-id, credential-signature), nu si pentru detinator', () => {
const c = clon(credential); c.statement.issuer.keys = { ...c.statement.issuer.keys, mldsa65: c.statement.issuer.keys.ed25519 };
const r = I.verifyPresentation(I.present({ credential: c, disclosures, reveal: ['age_over_18'], presenter: hol, audience: AUD, nonce: NONCE, now: NOW }), toate);
cere(!r.valid && r.rules.join() === 'credential-signature,issuer-id', JSON.stringify(r.rules));
});
// 2026-10-05 (suita de conformitate): fiecare refuz isi numeste regula
test('fiecare refuz isi numeste regula: randul picat poarta rule (din REGULI), cel nejudecat unjudged (din NEJUDECATE), rezultatul rules si unjudged; o configuratie care nu e lista arunca, nu acuza prezentarea', () => {
const r = I.verifyPresentation(prez(), { ...toate, audience: 'https://alt.example', nonce: 'alt' });
cere(!r.valid && r.rules.join() === 'audience,nonce', JSON.stringify(r.rules));
cere(r.rows.every((x) => (x.pass === null ? I.NEJUDECATE.includes(x.unjudged) : I.REGULI.includes(x.rule))), 'un rand fara regula declarata');
const r0 = I.verifyPresentation(prez(), { now: NOW });
cere(r0.valid && r0.rules.length === 0 && r0.unjudged.join() === 'audience,issuer-trust,nonce,status-unread', JSON.stringify(r0.unjudged));
const rd = I.verifyPresentation(prezD(), toate); cere(rd.valid && rd.unjudged.join() === 'revocations-none', JSON.stringify(rd.unjudged));
cere(/statusLists and revocations are lists/.test(arunca(() => I.verifyPresentation(prez(), { ...toate, statusLists: 'x' })) || ''), 'statusLists care nu e lista: prezentarea acuzata in loc de configuratie');
cere(/statusLists and revocations are lists/.test(arunca(() => I.verifyPresentation(prezD(), { ...toate, revocations: {} })) || ''), 'revocations care nu e lista primit');
cere(/trustedIssuers is a list/.test(arunca(() => I.verifyPresentation(prez(), { ...toate, trustedIssuers: 'x' })) || ''), 'trustedIssuers care nu e lista');
});
test('o afirmatie in clar numita in reveal nu cere dezvaluire (se vede oricum)', () => {
const r = I.verifyPresentation(I.present({ credential, disclosures, reveal: ['employer', 'age_over_18'], presenter: hol, audience: AUD, nonce: NONCE, now: NOW }), toate);
cere(r.valid && r.claims.employer === 'Example Ltd' && r.claims.age_over_18 === true && !('name' in r.claims), fals(r) || JSON.stringify(r.claims));