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

+27 -13
View File
@@ -416,8 +416,9 @@ const PROASPETE_IN_PLUS = {
const iss = ID.generateKeys(), hol = ID.generateKeys(), strain = ID.generateKeys();
const AUD = 'https://verifier.example', NONCE = 'n-' + crypto.randomBytes(8).toString('hex'), ISS = 'https://issuer.example';
const CL = { given_name: 'Ada', family_name: 'Example', age_over_18: true, nationalities: ['RO', 'DE'], address: { locality: 'Cluj', country: 'RO' } };
const emite = (o = {}) => SJ.issueSdJwt({ issuer: iss, holder: hol, claims: CL, disclosable: ['given_name', 'family_name', 'age_over_18'], arrayDisclosable: ['nationalities'], iss: ISS, iat: NOW, exp: NOW + 365 * 86400, decoys: 2, ...o });
const arata = (sd, reveal, o = {}) => SJ.presentSdJwt({ sdJwt: sd, reveal, holder: hol, audience: AUD, nonce: NONCE, iat: NOW, ...o });
// 2026-10-19 (AIP-25 C1): the recorded source used the Ed25519 half of these AERE keys by default; it is asked for explicitly now
const emite = (o = {}) => SJ.issueSdJwt({ alg: 'EdDSA', holderAlg: 'EdDSA', classicalHalf: true, issuer: iss, holder: hol, claims: CL, disclosable: ['given_name', 'family_name', 'age_over_18'], arrayDisclosable: ['nationalities'], iss: ISS, iat: NOW, exp: NOW + 365 * 86400, decoys: 2, ...o });
const arata = (sd, reveal, o = {}) => SJ.presentSdJwt({ classicalHalf: true, sdJwt: sd, reveal, holder: hol, audience: AUD, nonce: NONCE, iat: NOW, ...o });
const b64u = (x) => Buffer.from(x).toString('base64url'); const dec = (s) => JSON.parse(Buffer.from(s, 'base64url').toString('utf8'));
const jwtDin = (antet, corp, cheie = iss.privat.ed25519) => { const cap = b64u(JSON.stringify(antet)) + '.' + b64u(JSON.stringify(corp)); return cap + '.' + b64u(crypto.sign(null, Buffer.from(cap), cheie)); };
const sha = (d) => crypto.createHash('sha256').update(d).digest('base64url');
@@ -427,11 +428,11 @@ const PROASPETE_IN_PLUS = {
const bazaDirect = direct.split('~').slice(0, -1).join('~') + '~';
const kbPeste = (baza, corpKb = {}, cheie = hol.privat.ed25519, antet = { alg: 'EdDSA', typ: 'kb+jwt' }) => baza + jwtDin(antet, { iat: NOW, aud: AUD, nonce: NONCE, sd_hash: sha(baza), ...corpKb }, cheie);
// a hand-made issuer-signed JWT (EdDSA, typ aere+sd-jwt, cnf = the holder key), no key binding
const jeton = (extra, antet = { alg: 'EdDSA', typ: SJ.TYP }) => jwtDin(antet, { iss: ISS, iat: NOW, exp: NOW + 365 * 86400, _sd_alg: 'sha-256', cnf: { jwk: SJ.publicJwk(hol) }, ...extra }) + '~';
const jeton = (extra, antet = { alg: 'EdDSA', typ: SJ.TYP }) => jwtDin(antet, { iss: ISS, iat: NOW, exp: NOW + 365 * 86400, _sd_alg: 'sha-256', cnf: { jwk: SJ.publicJwk(hol, 'EdDSA', { classicalHalf: true }) }, ...extra }) + '~';
const dz = (c) => { const d = b64u(JSON.stringify(c)); return { d, dg: sha(d) }; };
const d1 = dz(['salt-1', 'a', 1]), dSd = dz(['salt-2', '_sd', ['x']]), dRole = dz(['salt-3', 'role', 'admin']), dUnu = dz(['only-a-salt']);
return { now: iso(NOW + 60), later: iso(NOW + 3660), muchLater: iso(NOW + 400 * 86400), audience: AUD, nonce: NONCE, issuer: ISS,
issuerJwk: SJ.publicJwk(iss), issuerJwkMlDsa: SJ.publicJwk(iss, 'ML-DSA-65'), holderJwk: SJ.publicJwk(hol),
issuerJwk: SJ.publicJwk(iss, 'EdDSA', { classicalHalf: true }), issuerJwkMlDsa: SJ.publicJwk(iss, 'ML-DSA-65'), holderJwk: SJ.publicJwk(hol, 'EdDSA', { classicalHalf: true }),
issued: E.sdJwt, direct, directMlDsa: arata(M.sdJwt, ['age_over_18'], { holderAlg: 'ML-DSA-65' }),
forged: {
kbStranger: arata(E.sdJwt, ['age_over_18'], { holder: strain }),
@@ -464,26 +465,27 @@ const PROASPETE_IN_PLUS = {
const iss = ID.generateKeys(), hol = ID.generateKeys(), strain = ID.generateKeys();
const AUD = 'https://verifier.example', NONCE = 'n-' + crypto.randomBytes(8).toString('hex'), ISS = 'https://issuer.example', VCT = 'urn:eudi:pid:1', URI = 'https://issuer.example/status/pid/1', IDX = 5;
const CL = { given_name: 'Ada', family_name: 'Example', birthdate: '1990-01-01', age_over_18: true, nationalities: ['RO', 'DE'], address: { locality: 'Cluj', country: 'RO' }, issuing_authority: 'Example Authority', issuing_country: 'RO' };
const emite = (o = {}) => SV.issueSdJwtVc({ issuer: iss, holder: hol, vct: VCT, claims: CL, disclosable: ['given_name', 'family_name', 'birthdate', 'age_over_18', 'address'], arrayDisclosable: ['nationalities'], iss: ISS, iat: NOW, nbf: NOW, exp: NOW + 365 * 86400, status: { status_list: { idx: IDX, uri: URI } }, decoys: 2, ...o });
const arata = (sd, reveal, o = {}) => SV.presentSdJwtVc({ sdJwt: sd, reveal, holder: hol, audience: AUD, nonce: NONCE, iat: NOW, ...o });
const lista = (statuses, bits = 1, o = {}) => SV.issueStatusListJwt({ issuer: iss, uri: URI, statuses, bits, iat: NOW, exp: NOW + 3600, ...o });
// 2026-10-19 (AIP-25 C1): as in the source sdjwt, the Ed25519 half of these AERE keys is asked for explicitly where the recorded source used it
const emite = (o = {}) => SV.issueSdJwtVc({ alg: 'EdDSA', holderAlg: 'EdDSA', classicalHalf: true, issuer: iss, holder: hol, vct: VCT, claims: CL, disclosable: ['given_name', 'family_name', 'birthdate', 'age_over_18', 'address'], arrayDisclosable: ['nationalities'], iss: ISS, iat: NOW, nbf: NOW, exp: NOW + 365 * 86400, status: { status_list: { idx: IDX, uri: URI } }, decoys: 2, ...o });
const arata = (sd, reveal, o = {}) => SV.presentSdJwtVc({ classicalHalf: true, sdJwt: sd, reveal, holder: hol, audience: AUD, nonce: NONCE, iat: NOW, ...o });
const lista = (statuses, bits = 1, o = {}) => SV.issueStatusListJwt({ alg: 'EdDSA', classicalHalf: true, issuer: iss, uri: URI, statuses, bits, iat: NOW, exp: NOW + 3600, ...o });
const b64u = (x) => Buffer.from(x).toString('base64url');
const jwtDin = (antet, corp, cheie = iss.privat.ed25519) => { const cap = b64u(JSON.stringify(antet)) + '.' + b64u(JSON.stringify(corp)); return cap + '.' + b64u(crypto.sign(null, Buffer.from(cap), cheie)); };
const sha = (d) => crypto.createHash('sha256').update(d).digest('base64url');
const T0 = new Array(16).fill(0), REV = T0.map((_, i) => (i === IDX ? 1 : 0)), SUS = T0.map((_, i) => (i === IDX ? 2 : 0));
const E = emite(), M = emite({ alg: 'ML-DSA-65', holderAlg: 'ML-DSA-65' }), faraStare = SV.issueSdJwtVc({ issuer: iss, holder: hol, vct: VCT, claims: CL, disclosable: ['birthdate'], iss: ISS, iat: NOW, exp: NOW + 365 * 86400 });
const E = emite(), M = emite({ alg: 'ML-DSA-65', holderAlg: 'ML-DSA-65' }), faraStare = SV.issueSdJwtVc({ alg: 'EdDSA', holderAlg: 'EdDSA', classicalHalf: true, issuer: iss, holder: hol, vct: VCT, claims: CL, disclosable: ['birthdate'], iss: ISS, iat: NOW, exp: NOW + 365 * 86400 });
const reveal = ['birthdate', 'age_over_18', { element: 'RO', in: 'nationalities' }];
const corpL = JSON.parse(Buffer.from(lista(T0).split('.')[1], 'base64url').toString('utf8'));
const jeton = (extra, dezv = []) => jwtDin({ alg: 'EdDSA', typ: 'dc+sd-jwt' }, { vct: VCT, iss: ISS, iat: NOW, exp: NOW + 365 * 86400, _sd_alg: 'sha-256', cnf: { jwk: SJ.publicJwk(hol) }, ...extra }) + '~' + dezv.map((d) => d + '~').join('');
const jeton = (extra, dezv = []) => jwtDin({ alg: 'EdDSA', typ: 'dc+sd-jwt' }, { vct: VCT, iss: ISS, iat: NOW, exp: NOW + 365 * 86400, _sd_alg: 'sha-256', cnf: { jwk: SJ.publicJwk(hol, 'EdDSA', { classicalHalf: true }) }, ...extra }) + '~' + dezv.map((d) => d + '~').join('');
const dStatus = b64u(JSON.stringify(['salt-s', 'status', { status_list: { idx: 1, uri: URI } }]));
return { now: iso(NOW + 60), audience: AUD, nonce: NONCE, issuer: ISS, vct: VCT, uri: URI, idx: IDX, issuerJwk: SJ.publicJwk(iss), issuerJwkMlDsa: SJ.publicJwk(iss, 'ML-DSA-65'),
return { now: iso(NOW + 60), audience: AUD, nonce: NONCE, issuer: ISS, vct: VCT, uri: URI, idx: IDX, issuerJwk: SJ.publicJwk(iss, 'EdDSA', { classicalHalf: true }), issuerJwkMlDsa: SJ.publicJwk(iss, 'ML-DSA-65'),
direct: arata(E.sdJwt, reveal), directMlDsa: arata(M.sdJwt, reveal, { holderAlg: 'ML-DSA-65' }), noStatus: arata(faraStare.sdJwt, ['birthdate']),
lists: { clean: lista(T0), revoked: lista(REV), suspended: lista(SUS, 2), eightBits: lista(T0, 8), otherUri: lista(T0, 1, { uri: URI + '-other' }), expired: lista(T0, 1, { exp: NOW + 30 }),
stranger: SV.issueStatusListJwt({ issuer: strain, uri: URI, statuses: T0, iat: NOW }), short: SV.issueStatusListJwt({ issuer: iss, uri: URI, statuses: [0, 0, 0, 0], bits: 8, iat: NOW }),
stranger: SV.issueStatusListJwt({ alg: 'EdDSA', classicalHalf: true, issuer: strain, uri: URI, statuses: T0, iat: NOW }), short: SV.issueStatusListJwt({ alg: 'EdDSA', classicalHalf: true, issuer: iss, uri: URI, statuses: [0, 0, 0, 0], bits: 8, iat: NOW }),
typJwt: jwtDin({ alg: 'EdDSA', typ: 'JWT' }, corpL), noIat: jwtDin({ alg: 'EdDSA', typ: 'statuslist+jwt' }, (({ iat, ...r }) => r)(corpL)),
mlDsa: SV.issueStatusListJwt({ issuer: iss, alg: 'ML-DSA-65', uri: URI, statuses: T0, iat: NOW, exp: NOW + 3600 }) },
forged: {
noVct: arata(SJ.issueSdJwt({ issuer: iss, holder: hol, claims: { given_name: 'Ada' }, iss: ISS, iat: NOW, exp: NOW + 365 * 86400, typ: 'dc+sd-jwt' }).sdJwt, []),
noVct: arata(SJ.issueSdJwt({ alg: 'EdDSA', holderAlg: 'EdDSA', classicalHalf: true, issuer: iss, holder: hol, claims: { given_name: 'Ada' }, iss: ISS, iat: NOW, exp: NOW + 365 * 86400, typ: 'dc+sd-jwt' }).sdJwt, []),
statusDisclosed: jeton({ _sd: [sha(dStatus)] }, [dStatus]),
statusIdxNegative: jeton({ status: { status_list: { idx: -1, uri: URI } } }),
statusNotObject: jeton({ status: 'revoked' }),
@@ -1230,7 +1232,7 @@ function construieste() {
const srcA = 'producers (sdjwt.mjs: issueSdJwt, presentSdJwt), three hybrid key pairs made and discarded at generation';
const bo = 'sdjwt-presentation/aere.valid', bom = 'sdjwt-presentation/aere-ml-dsa-65.valid', bi = 'sdjwt-presentation/aere-issued.valid';
const intrareA = (sdJwt, o = {}) => ({ sdJwt, issuerKey: X.issuerJwk, issuerAlg: 'EdDSA', audience: X.audience, nonce: X.nonce, now: X.now, expectedIssuer: X.issuer, ...o });
valid(bo, A, 'an SD-JWT issued with AERE keys (EdDSA): two of three disclosable claims and one list element shown, two decoy digests, a key binding JWT for this verifier', srcA, intrareA(X.direct), { exercises: SK, levels: AP });
valid(bo, A, 'an SD-JWT issued with AERE keys (EdDSA), judged with the Ed25519 half given as a plain JWK (classical interoperation: the verdict is not post-quantum): two of three disclosable claims and one list element shown, two decoy digests, a key binding JWT for this verifier', srcA, intrareA(X.direct), { exercises: SK, levels: AP });
valid(bom, A, 'the same credential, issuer and holder keys ML-DSA-65 (RFC 9964, JWK type AKP)', srcA, intrareA(X.directMlDsa, { issuerKey: X.issuerJwkMlDsa, issuerAlg: 'ML-DSA-65' }), { exercises: SK, levels: AP });
valid(bi, A, 'the same SD-JWT as issued (every disclosure, no key binding), judged by a verifier that does not require key binding', srcA, { sdJwt: X.issued, issuerKey: X.issuerJwk, issuerAlg: 'EdDSA', now: X.now, requireKeyBinding: false }, { exercises: SK, levels: AP });
const F = X.forged;
@@ -1256,6 +1258,18 @@ function construieste() {
prod('sdjwt-presentation/aere-issued.disclosure-form-not-json', 'a disclosure that is base64url of text that is not JSON', bi, F.disclosureNotJson, 'sdjwt.disclosure-form', 'the issuer signed the digest of a disclosure whose bytes are not JSON');
prod('sdjwt-presentation/aere-issued.disclosure-form-sd', '_sd is a string, not a list of digests', bi, F.sdNotList, 'sdjwt.disclosure-form', 'the issuer signed a payload whose _sd is a string');
inv('sdjwt-presentation/aere-issued.time-years-later', 'the verifier clock is years later: the credential has expired', bi, { op: 'set', path: ['now'], value: X.muchLater }, 'sdjwt.time');
// 2026-10-19 (AIP-25 C1, D-535): the same issuer keys given the way an AERE identity publishes them ({alg, ed25519, mldsa65}, the output
// of `identity-cli.mjs pub`), rebuilt from the two public JWKs of the fresh source (the SPKI of a key is canonical, so this is the object of
// that identity). Against hybrid keys the ML-DSA-65 half is judged; the Ed25519 half only when the verifier asks for it (classicalHalf)
const spki = (jwk) => crypto.createPublicKey({ key: jwk, format: 'jwk' }).export({ type: 'spki', format: 'der' }).toString('base64');
const aerePub = { alg: 'ed25519+ml-dsa-65', ed25519: spki(X.issuerJwk), mldsa65: spki(X.issuerJwkMlDsa) };
const bh = 'sdjwt-presentation/aere-hybrid-keys.valid', bhc = 'sdjwt-presentation/aere-hybrid-keys-classical.valid';
const intrareH = (sdJwt, o = {}) => ({ sdJwt, issuerKey: aerePub, audience: X.audience, nonce: X.nonce, now: X.now, expectedIssuer: X.issuer, ...o });
valid(bh, A, 'the credential signed with the ML-DSA-65 half (issuer and holder), judged against the issuer\'s AERE hybrid keys ({alg, ed25519, mldsa65}) with no algorithm named: the ML-DSA-65 half is the one judged', srcA, intrareH(X.directMlDsa), { exercises: SK, levels: AP });
inv('sdjwt-presentation/aere-hybrid-keys.hybrid-half', 'a credential signed with the Ed25519 half of the same AERE identity alone, against its hybrid keys, by a verifier that asks for nothing (what a holder of the classical key alone can make)', bh, { op: 'set', path: ['sdJwt'], value: X.direct }, 'sdjwt.hybrid-half');
inv('sdjwt-presentation/aere-hybrid-keys.hybrid-half-named', 'the verifier names EdDSA for the AERE hybrid keys without asking for the classical half (classicalHalf)', bh, { op: 'add', path: ['issuerAlg'], value: 'EdDSA' }, 'sdjwt.hybrid-half');
valid(bhc, A, 'the credential signed with the Ed25519 half alone, against the AERE hybrid keys, by a verifier that asks for the classical half (classicalHalf): VALID, and the verdict says it is not post-quantum', srcA, intrareH(X.direct, { classicalHalf: true }), { exercises: SK, levels: AP });
inv('sdjwt-presentation/aere-hybrid-keys-classical.hybrid-half', 'the same, the verifier no longer asking for the classical half', bhc, { op: 'remove', path: ['classicalHalf'] }, 'sdjwt.hybrid-half');
// @sd-jwt/core (openwallet-foundation-labs/identity-common-ts), from the interop fixtures: its tokens, with its public test keys
const srcIo = `@sd-jwt/core ${IO.biblioteci['@sd-jwt/core']} with jose ${IO.biblioteci.jose} (interop/fixturi-interop-sdjwt.json of the identity component, generated ${IO.generat.slice(0, 10)}; its test keys made and discarded at generation)`;
const laIo = new Date(IO.ceasVerificare * 1000).toISOString();