identity: the SD-JWT form of an AERE hybrid identity is judged on its ML-DSA-65 half by default, the Ed25519 half only on explicit request, and every verdict says postQuantum (rule sdjwt.hybrid-half); pq-pki: the signature algorithm a certificate or a revocation list declares must be its issuer key's (ALG_KEY, CRL_ALG_KEY); agents: an equivocation proof requires the agent's ML-DSA-65 key; pq-gateway: the status names the path to the backend and hybrid-only refuses a plain-HTTP backend; conformance 241 rules, 631 vectors

This commit is contained in:
Aere Network committed 2026-10-19 05:19:21 +03:00
1 parent 3ff21f7758
commit 0c8f1de3fd
122 files changed
+1205 -262

No files matched your search

+92 -26
View File
@@ -11,9 +11,20 @@
// nonce-ul lui CERUTE cand exista (sau se cere) Key Binding, cu `exp` cerut, cu tipul explicit al jetonului verificat
//
// ALGORITMII (JWS): ES256 (P-256, cel din exemplele RFC 9901), EdDSA / Ed25519 (RFC 8037) si ML-DSA-65 (post-cuantic; numele si forma
// cheii JWK "AKP" din RFC 9964, mai 2026). Un emitent AERE semneaza cu cheia lui Ed25519 (algoritm cunoscut tuturor bibliotecilor JOSE)
// sau cu cheia ML-DSA-65 (masurat 2026-10-18: jose 6.2.12 pe Node 24 o semneaza si o verifica); o semnatura hibrida in acelasi jeton ar
// cere serializarea JSON generala a JWS si nu e facuta aici.
// cheii JWK "AKP" din RFC 9964, mai 2026). O semnatura hibrida in acelasi jeton ar cere serializarea JSON generala a JWS si nu e facuta aici.
//
// JUMATATEA POST-CUANTICA (2026-10-19, AIP-25 constatarea C1, D-535): cheile unei identitati AERE sunt Ed25519 SI ML-DSA-65 (identity.mjs
// cere amandoua semnaturile). Un JWS poarta UNA. Pana pe 19 oct emiterea, cnf-ul detinatorului si verificarea alegeau implicit jumatatea
// Ed25519, deci cine spargea NUMAI cheia clasica a emitentului facea credentiale primite contra identitatii lui intregi (masurat de
// aips/aip25-inventar/masoara-constatari.mjs). De atunci, cu chei AERE (perechea privata, sau cheile publice {alg, ed25519, mldsa65}):
// - emiterea (alg), cnf-ul detinatorului (holderAlg), Key Binding-ul si lista de stare (sdjwt-vc.mjs) folosesc implicit ML-DSA-65;
// - verificarea cere implicit jumatatea ML-DSA-65; un jeton semnat cu jumatatea Ed25519 e refuzat pe regula `hybrid-half`;
// - jumatatea Ed25519 se foloseste si se judeca NUMAI la cererea explicita a apelantului (`classicalHalf: true`, pentru interoperarea
// clasica), si atunci verificatorul primeste jumatatea pe care o numeste jetonul (EdDSA sau ML-DSA-65);
// - verdictul spune `postQuantum`: true numai cand FIECARE semnatura judecata (a emitentului si, daca exista, Key Binding-ul) e ML-DSA-65.
// Un JWK simplu (o cheie straina, ES256 sau EdDSA, @sd-jwt/core, portofelele europene) ramane cum era: nu exista o jumatate post-cuantica
// de pierdut, iar verdictul spune la fel postQuantum false. Cine isi transforma singur cheile AERE intr-un JWK Ed25519 simplu
// (publicJwk(chei, 'EdDSA', { classicalHalf: true })) a cerut jumatatea clasica, si verdictul o spune.
//
// Revizuirea adversariala din 2026-09-30 (inainte de publicare) a gasit si s-au reparat: emitentul semna structura SD-JWT venita in valorile
// afirmatiilor (`_sd`, `{"...": d}`), deci detinatorul putea dezvalui afirmatii pe care emitentul nu le-a vazut; prezentarea arata un element
@@ -34,8 +45,10 @@ export const ALGS = ['ES256', 'EdDSA', 'Ed25519', 'ML-DSA-65'];
export const TYP = 'aere+sd-jwt';
const AERE_ALG = 'ed25519+ml-dsa-65';
/** regulile pe care le poate numi un refuz al lui verifySdJwt (ordinea e cea a verificarii; `form` si pentru ceasul verificatorului) */
export const REGULI = ['form', 'alg', 'typ', 'crit', 'key', 'signature', 'issuer', 'sd-alg', 'disclosure-form', 'disclosure-twice', 'digest-twice',
export const REGULI = ['form', 'alg', 'typ', 'crit', 'key', 'hybrid-half', 'signature', 'issuer', 'sd-alg', 'disclosure-form', 'disclosure-twice', 'digest-twice',
'disclosure-name', 'claim-conflict', 'unreferenced', 'time', 'kb-context', 'kb-required', 'kb-cnf', 'kb-claims', 'kb-audience', 'kb-nonce', 'kb-freshness', 'kb-sd-hash'];
// numele JOSE ale semnaturii Ed25519: EdDSA (RFC 8037) si Ed25519 (numele complet, RFC 9864)
const CLASIC = ['EdDSA', 'Ed25519'];
class Refuz extends Error { constructor(rule, message) { super(message); this.rule = rule; } }
const nu = (rule, msg) => { if (!REGULI.includes(rule)) throw new Error('sd-jwt: undeclared rule ' + rule); return new Refuz(rule, 'sd-jwt: ' + msg); };
// base64url CANONIC: decodat si recodat trebuie sa dea acelasi text (altfel aceeasi semnatura are mai multe scrieri, si un depozit de
@@ -51,18 +64,54 @@ const sha256b64u = (s) => crypto.createHash('sha256').update(Buffer.from(s, 'asc
const obiect = (x) => x !== null && typeof x === 'object' && !Array.isArray(x);
// ---------------------------------------------------------------- chei JWK si semnaturi JWS
/** Chei AERE: perechea (identity.mjs, cu `privat`) sau cheile publice ale unei identitati ({alg: 'ed25519+ml-dsa-65', ed25519, mldsa65}). */
const esteAere = (k) => !!k && !(k instanceof crypto.KeyObject) && (obiect(k.privat) || (obiect(k) && k.alg === AERE_ALG));
/** Algoritmul implicit al unei chei la EMITERE: ML-DSA-65 pentru chei AERE (AIP-25 C1), EdDSA altfel (ca pana acum). */
export const defaultAlg = (k) => (esteAere(k) ? 'ML-DSA-65' : 'EdDSA');
/**
* Jumatatea unei chei AERE ceruta de `alg` (implicit ML-DSA-65). Jumatatea Ed25519 NUMAI cu `classicalHalf` (AIP-25 C1): altfel refuz
* `hybrid-half`. Un algoritm pe care o identitate AERE nu il are (ES256) e refuz `key`, nu cheia Ed25519 data in tacere (pana pe 19 oct).
*/
function jumatateaAere(alg, classicalHalf) {
const a = alg == null ? 'ML-DSA-65' : alg;
if (a === 'ML-DSA-65') return 'mldsa65';
if (!CLASIC.includes(a)) throw nu('key', `an AERE hybrid identity has an Ed25519 and an ML-DSA-65 key, no ${a} key`);
if (!(classicalHalf === true /*PAZA:hybrid-half*/)) throw nu('hybrid-half', `${a} names the Ed25519 half of an AERE hybrid identity (Ed25519 + ML-DSA-65); that half alone is not post-quantum and is used only when the caller asks for it (classicalHalf: true); the post-quantum half is ML-DSA-65, the default`);
return 'ed25519';
}
/**
* Cheia PUBLICA ca JWK, din: o pereche de chei AERE (identity.mjs; `privat`), cheile publice ale unei identitati AERE ({alg, ed25519,
* mldsa65}), un KeyObject public sau privat, sau un JWK public. `alg` alege cheia AERE: 'EdDSA' (Ed25519) sau 'ML-DSA-65'.
* mldsa65}), un KeyObject public sau privat, sau un JWK public. Pentru chei AERE, `alg` alege jumatatea: implicit 'ML-DSA-65'; 'EdDSA' /
* 'Ed25519' (jumatatea clasica) numai cu { classicalHalf: true } (AIP-25 C1). Pentru celelalte chei `alg` nu conteaza (cheia e cea data).
*/
export function publicJwk(k, alg = 'EdDSA') {
const ml = alg === 'ML-DSA-65';
if (k && k.privat) k = ml ? k.privat.mldsa65 : k.privat.ed25519;
else if (obiect(k) && k.alg === AERE_ALG && typeof k.ed25519 === 'string') k = crypto.createPublicKey({ key: Buffer.from(ml ? k.mldsa65 : k.ed25519, 'base64'), format: 'der', type: 'spki' });
export function publicJwk(k, alg, { classicalHalf = false } = {}) {
if (esteAere(k)) {
const j = jumatateaAere(alg, classicalHalf);
let x = null;
try { x = k.privat ? k.privat[j] : crypto.createPublicKey({ key: Buffer.from(k[j], 'base64'), format: 'der', type: 'spki' }); } catch { x = null; }
if (!(x instanceof crypto.KeyObject)) throw nu('key', `the ${j === 'mldsa65' ? 'ML-DSA-65' : 'Ed25519'} half of the AERE identity keys cannot be read`);
k = x;
}
if (k instanceof crypto.KeyObject) return (k.type === 'public' ? k : crypto.createPublicKey(k)).export({ format: 'jwk' });
if (obiect(k) && k.kty) return k;
throw nu('key', 'not a key (a JWK, a Node key object, or AERE identity keys)');
}
/**
* Cheia cu care se judeca un JWS semnat de cheia `k` a emitentului (sau a listei de stare), data de verificator (AIP-25 C1, 2026-10-19).
* O cheie care nu e AERE: ea insasi, ca pana acum. Chei AERE: jumatatea `alg` daca verificatorul o numeste; altfel ML-DSA-65, sau, numai
* cu `classicalHalf`, jumatatea pe care o numeste antetul (EdDSA / Ed25519; verdictul spune atunci postQuantum false). Un jeton semnat cu
* jumatatea Ed25519, judecat de un verificator care cere jumatatea ML-DSA-65, e refuzat pe NUMELE lui (`hybrid-half`), nu ca "alta cheie".
*/
export function judgedJwk(k, alg, { classicalHalf = false, headerAlg } = {}) {
if (!esteAere(k)) return publicJwk(k, alg);
const a = alg != null ? alg : classicalHalf === true && CLASIC.includes(headerAlg) ? headerAlg : 'ML-DSA-65';
if (!(!(a === 'ML-DSA-65' && CLASIC.includes(headerAlg)) /*PAZA:hybrid-half*/)) throw nu('hybrid-half', `the JWS is signed ${headerAlg} with the Ed25519 half of an AERE hybrid identity alone (Ed25519 + ML-DSA-65): that half is not post-quantum, so it is judged only when the verifier asks for it (classicalHalf: true); by default the ML-DSA-65 half is required`);
return publicJwk(k, a, { classicalHalf });
}
/** Algoritmul din antetul unui JWS compact, citit fara sa fie crezut (numai ca sa se numeasca un refuz); undefined daca nu se citeste. */
export function headerAlgOf(jws) {
try { const h = jsonB64u(String(jws).split('.')[0], 'the JWS header'); return obiect(h) && typeof h.alg === 'string' ? h.alg : undefined; } catch { return undefined; }
}
function cheiePublica(jwk) {
if (!(obiect(jwk) && ['EC', 'OKP', 'AKP'].includes(jwk.kty) /*PAZA:key*/)) throw nu('key', 'the key is not an EC, OKP or AKP JWK');
if (!(!('d' in jwk) && !('priv' in jwk) /*PAZA:key*/)) throw nu('key', 'a private JWK was given where a public key belongs');
@@ -109,8 +158,14 @@ function semneazaJws(antet, corp, priv) {
const sig = antet.alg === 'ES256' ? crypto.sign('sha256', date, { key: priv, dsaEncoding: 'ieee-p1363' }) : crypto.sign(null, date, priv);
return cap + '.' + b64u(sig);
}
const cheiePrivata = (k, alg) => (k && k.privat ? (alg === 'ML-DSA-65' ? k.privat.mldsa65 : k.privat.ed25519) : k);
// pentru profilurile de deasupra (sdjwt-vc.mjs: Status List Token), ca semnatura JWS sa se faca intr-un singur loc
// cheia privata care semneaza: pentru chei AERE jumatatea numita de alg (Ed25519 numai cu classicalHalf, AIP-25 C1); altfel cheia data
function cheiePrivata(k, alg, classicalHalf = false) {
if (!(k && k.privat)) return k;
const j = jumatateaAere(alg, classicalHalf);
if (!k.privat[j]) throw new Error(`sd-jwt: these AERE keys have no private ${j === 'mldsa65' ? 'ML-DSA-65' : 'Ed25519'} half`);
return k.privat[j];
}
// pentru profilurile de deasupra (sdjwt-vc.mjs: Status List Token), ca semnatura JWS si alegerea jumatatii AERE sa se faca intr-un singur loc
export { verificaJws as verifyJws, semneazaJws as signJws, cheiePrivata as privateKeyOf };
// structura SD-JWT intr-o valoare: o cheie `_sd`/`_sd_alg` intr-un obiect sau un element {"...": x} intr-o lista, oriunde in adancime
function areStructuraSd(v) {
@@ -130,12 +185,14 @@ function areStructuraSd(v) {
* issuer: chei AERE sau KeyObject privat. holder: cheia PUBLICA a detinatorului (sau cheile lui AERE). disclosable: numele afirmatiilor de
* sus dezvaluibile; arrayDisclosable: listele de sus ale caror ELEMENTE sunt dezvaluibile una cate una. exp implicit: un an de la iat
* (null: fara exp, pe care verifySdJwt il refuza implicit). typ: tipul explicit al jetonului (implicit TYP; un profil ca SD-JWT VC isi
* pune al lui, "dc+sd-jwt"; RFC 9901 s.9.11). Intoarce { sdJwt, disclosures:[{name, value, disclosure}] }.
* pune al lui, "dc+sd-jwt"; RFC 9901 s.9.11). alg / holderAlg: implicit ML-DSA-65 pentru chei AERE, EdDSA pentru celelalte; jumatatea
* Ed25519 a unor chei AERE (emitent sau detinator) numai cu classicalHalf: true (AIP-25 C1). Intoarce { sdJwt, disclosures:[{name, value, disclosure}] }.
*/
export function issueSdJwt({ issuer, claims, disclosable = [], arrayDisclosable = [], holder, iss, iat = Math.floor(Date.now() / 1000), exp, nbf, alg = 'EdDSA', holderAlg = 'EdDSA', decoys = 0, typ = TYP }) {
export function issueSdJwt({ issuer, claims, disclosable = [], arrayDisclosable = [], holder, iss, iat = Math.floor(Date.now() / 1000), exp, nbf, alg, holderAlg, classicalHalf = false, decoys = 0, typ = TYP }) {
if (!obiect(claims)) throw new Error('sd-jwt: claims must be an object');
if (typeof iss !== 'string' || !iss) throw new Error('sd-jwt: iss is required');
if (!ALGS.includes(alg) || !ALGS.includes(holderAlg)) throw new Error('sd-jwt: unknown alg');
const algE = alg ?? defaultAlg(issuer), algH = holderAlg ?? defaultAlg(holder);
if (!ALGS.includes(algE) || !ALGS.includes(algH)) throw new Error('sd-jwt: unknown alg');
if (!tipBun(typ, undefined)) throw new Error('sd-jwt: typ must be an explicit SD-JWT type ("...+sd-jwt", RFC 9901 s.9.11)');
// RFC 9901 s.4.1 (regula 7 a emitentului): emitentul nu semneaza digesturi pe care nu le-a facut el; o valoare care poarta deja `_sd`,
// `_sd_alg` sau un element {"...": d} ar lasa detinatorul sa dezvaluie afirmatii nevazute de emitent
@@ -155,8 +212,8 @@ export function issueSdJwt({ issuer, claims, disclosable = [], arrayDisclosable
corp.iss = iss; corp.iat = iat;
const e = exp === undefined ? iat + 365 * 86400 : exp; if (e != null) corp.exp = e;
if (nbf != null) corp.nbf = nbf;
corp.cnf = { jwk: publicJwk(holder, holderAlg) };
const jwt = semneazaJws({ alg, typ }, corp, cheiePrivata(issuer, alg));
corp.cnf = { jwk: publicJwk(holder, algH, { classicalHalf }) };
const jwt = semneazaJws({ alg: algE, typ }, corp, cheiePrivata(issuer, algE, classicalHalf));
return { sdJwt: jwt + '~' + dez.map((x) => x.disclosure + '~').join(''), disclosures: dez };
}
@@ -164,12 +221,17 @@ export function issueSdJwt({ issuer, claims, disclosable = [], arrayDisclosable
* Detinatorul pastreaza numai dezvaluirile alese si leaga prezentarea de verificator. reveal: un sir = afirmatia de SUS cu acel nume;
* { element, in } = elementul cu acea valoare din lista de SUS `in` (numai din ea). O alegere care nu gaseste nimic e o eroare, nu o tacere.
*/
export function presentSdJwt({ sdJwt, reveal = [], holder, holderAlg = 'EdDSA', audience, nonce, iat = Math.floor(Date.now() / 1000) }) {
export function presentSdJwt({ sdJwt, reveal = [], holder, holderAlg, classicalHalf = false, audience, nonce, iat = Math.floor(Date.now() / 1000) }) {
if (typeof audience !== 'string' || !audience || typeof nonce !== 'string' || !nonce) throw new Error('sd-jwt: a presentation needs the verifier\'s audience and nonce');
const parti = String(sdJwt).split('~');
if (parti[parti.length - 1] !== '') throw new Error('sd-jwt: this SD-JWT already ends with a key binding JWT');
const jwt = parti[0], dez = parti.slice(1, -1);
const corp = jsonB64u(jwt.split('.')[1] || '', 'the issuer-signed JWT payload');
// AIP-25 C1 (2026-10-19): un detinator AERE semneaza Key Binding-ul cu jumatatea pe care emitentul a legat-o in cnf.jwk (ML-DSA-65 implicit;
// o cheie OKP in cnf inseamna ca emitentul a cerut jumatatea Ed25519, iar verdictul spune postQuantum false); un holderAlg dat castiga
const cnfKty = obiect(corp.cnf) && obiect(corp.cnf.jwk) ? corp.cnf.jwk.kty : null;
const urmeazaCnf = holderAlg == null && esteAere(holder) && cnfKty === 'OKP';
const algH = holderAlg ?? (urmeazaCnf ? 'EdDSA' : defaultAlg(holder));
// unde sta fiecare digest in JWT-ul emitentului: proprietate de sus, sau element al unei liste de sus (cu numele listei)
const loc = new Map();
for (const dg of Array.isArray(corp._sd) ? corp._sd : []) loc.set(dg, { tip: 'prop' });
@@ -189,7 +251,7 @@ export function presentSdJwt({ sdJwt, reveal = [], holder, holderAlg = 'EdDSA',
const lipsa = reveal.filter((_, i) => !gasite.has(i));
if (lipsa.length) throw new Error('sd-jwt: nothing to reveal for ' + JSON.stringify(lipsa) + ' (a name reveals a top-level claim; {element, in} an element of the top-level list named)');
const baza = jwt + '~' + alese.map((d) => d + '~').join('');
const kb = semneazaJws({ alg: holderAlg, typ: 'kb+jwt' }, { iat, aud: audience, nonce, sd_hash: sha256b64u(baza) }, cheiePrivata(holder, holderAlg));
const kb = semneazaJws({ alg: algH, typ: 'kb+jwt' }, { iat, aud: audience, nonce, sd_hash: sha256b64u(baza) }, cheiePrivata(holder, algH, classicalHalf || urmeazaCnf));
return baza + kb;
}
@@ -200,11 +262,13 @@ export function presentSdJwt({ sdJwt, reveal = [], holder, holderAlg = 'EdDSA',
* now?:Date, maxAgeS?:number, clockSkewS?:number, expectedTyp?:string|null}} o
* issuerKey: cheia EMITENTULUI data de verificator (JWK, KeyObject, cheile AERE ale emitentului); niciodata din jeton. audience si nonce
* sunt ale verificatorului si se CER cand exista (sau se cere) Key Binding. expectedTyp: implicit orice tip explicit "...+sd-jwt".
* Intoarce { valid, rule, reason, payload, disclosed:[nume], issuer, issuerChecked, keyBinding:{aud, nonce, iat, alg}|null }; `rule` e
* regula (din REGULI) care a refuzat, null cand e valid.
* Cu chei AERE (AIP-25 C1): implicit se cere jumatatea ML-DSA-65 (issuerAlg o poate numi); jumatatea Ed25519 numai cu classicalHalf: true.
* Intoarce { valid, rule, reason, payload, disclosed:[nume], issuer, issuerChecked, alg, postQuantum, keyBinding:{aud, nonce, iat, alg}|null };
* `rule` e regula (din REGULI) care a refuzat, null cand e valid; `postQuantum` e true numai cand fiecare semnatura judecata (a emitentului
* si Key Binding-ul, daca exista) e ML-DSA-65, si false pe orice refuz.
*/
export function verifySdJwt(sdJwt, { issuerKey, issuerAlg = 'EdDSA', expectedIssuer = null, audience = null, nonce = null, requireKeyBinding = true, requireExp = true, now = new Date(), maxAgeS = 300, clockSkewS = 60, expectedTyp } = {}) {
const refuz = (rule, reason) => ({ valid: false, rule, reason, payload: null, disclosed: [], keyBinding: null });
export function verifySdJwt(sdJwt, { issuerKey, issuerAlg, classicalHalf = false, expectedIssuer = null, audience = null, nonce = null, requireKeyBinding = true, requireExp = true, now = new Date(), maxAgeS = 300, clockSkewS = 60, expectedTyp } = {}) {
const refuz = (rule, reason) => ({ valid: false, rule, reason, payload: null, disclosed: [], keyBinding: null, postQuantum: false });
const motiv = (e) => String((e && e.message) || e).replace(/^sd-jwt: /, '');
const regula = (e) => (e instanceof Refuz ? e.rule : 'form');
try {
@@ -218,8 +282,8 @@ export function verifySdJwt(sdJwt, { issuerKey, issuerAlg = 'EdDSA', expectedIss
// RFC 9901 s.7.3 pasul 5: publicul si nonce-ul verificatorului se compara; fara ele, o prezentare facuta pentru altul ar trece
const context = typeof audience === 'string' && !!audience && typeof nonce === 'string' && !!nonce;
if (!(!(requireKeyBinding || kb !== '') || context /*PAZA:kb-context*/)) return refuz('kb-context', 'the verifier must give its audience and nonce to judge a key binding (RFC 9901 s.7.3)');
// 2. JWT-ul emitentului
const { antet, corp } = verificaJws(jwt, publicJwk(issuerKey, issuerAlg), { typ: expectedTyp });
// 2. JWT-ul emitentului, cu jumatatea ceruta a unor chei AERE (AIP-25 C1: implicit ML-DSA-65; Ed25519 numai cu classicalHalf)
const { antet, corp } = verificaJws(jwt, judgedJwk(issuerKey, issuerAlg, { classicalHalf, headerAlg: headerAlgOf(jwt) }), { typ: expectedTyp });
if (!(expectedIssuer == null || corp.iss === expectedIssuer /*PAZA:issuer*/)) return refuz('issuer', `issued by ${JSON.stringify(corp.iss)}, not ${expectedIssuer}`);
const alg = corp._sd_alg === undefined ? 'sha-256' : corp._sd_alg;
if (!(alg === 'sha-256' /*PAZA:sd-alg*/)) return refuz('sd-alg', `_sd_alg ${JSON.stringify(corp._sd_alg)} is not understood (only sha-256)`);
@@ -288,7 +352,9 @@ export function verifySdJwt(sdJwt, { issuerKey, issuerAlg = 'EdDSA', expectedIss
if (!(payload.exp === undefined || acum < payload.exp /*PAZA:time*/)) return refuz('time', `expired at ${payload.exp}`);
if (!(payload.nbf === undefined || payload.nbf - clockSkewS <= acum /*PAZA:time*/)) return refuz('time', `not valid before ${payload.nbf}`);
if (!(payload.iat === undefined || payload.iat - clockSkewS <= acum /*PAZA:time*/)) return refuz('time', `issued in the future (${payload.iat})`);
const rez = { valid: true, rule: null, reason: '', payload, disclosed, issuer: corp.iss, issuerChecked: expectedIssuer != null, alg: antet.alg };
// AIP-25 C1: verdictul spune daca semnatura emitentului judecata e post-cuantica (Key Binding-ul o poate cobori, mai jos)
const pqEmitent = antet.alg === 'ML-DSA-65';
const rez = { valid: true, rule: null, reason: '', payload, disclosed, issuer: corp.iss, issuerChecked: expectedIssuer != null, alg: antet.alg, postQuantum: pqEmitent };
// s.7.3: Key Binding JWT
if (kb === '') {
if (!(!requireKeyBinding /*PAZA:kb-required*/)) return refuz('kb-required', 'key binding is required and the SD-JWT has none (it ends with ~)');
@@ -307,6 +373,6 @@ export function verifySdJwt(sdJwt, { issuerKey, issuerAlg = 'EdDSA', expectedIss
if (!(K.nbf === undefined || (Number.isFinite(K.nbf) && K.nbf - clockSkewS <= acum) /*PAZA:kb-freshness*/)) return refuz('kb-freshness', `key binding: not valid before ${K.nbf}`);
const baza = sdJwt.slice(0, sdJwt.length - kb.length);
if (!(sha256b64u(baza) === K.sd_hash /*PAZA:kb-sd-hash*/)) return refuz('kb-sd-hash', 'key binding: sd_hash is not the hash of what was presented');
return { ...rez, keyBinding: { aud: K.aud, nonce: K.nonce, iat: K.iat, alg: k.antet.alg } };
return { ...rez, postQuantum: rez.postQuantum && k.antet.alg === 'ML-DSA-65', keyBinding: { aud: K.aud, nonce: K.nonce, iat: K.iat, alg: k.antet.alg } };
} catch (e) { return refuz(regula(e), motiv(e)); }
}