Skip to content
Trapdoor·Lab

Digital credentials in the browser

1Toy

Signed digests instead of data

A site that wants to check your age or identity now asks the browser for a credential from the wallet on your phone: navigator.credentials.get() with a digital member that names the protocol and carries the request (Digital Credentials API, a W3C Working Draft). The browser shows a credential picker and passes on the wallet’s answer. The API itself signs nothing — the cryptography lives in the credential format. The European digital identity wallet must support two: SD-JWT VC, built on SD-JWT (RFC 9901, November 2025), and mdoc from ISO/IEC 18013-5 (the driving licence on a phone). Both rest on the same idea of salted digests; the toy shows SD-JWT because its specification is open.

The issuer does not put the claims into the signed token. For each one it draws a salt — 128 bits, as RFC 9901 §9.3 recommends — and builds a Disclosure: the base64url of the JSON array [salt, name, value]. Only the SHA-256 of that text goes into the token, in the _sd list, and the token is signed with ES256, that is ECDSA on P-256 from the Signatures station. The holder gets the Disclosures. When she shows the credential she appends only the ones she picks; the verifier hashes them and looks them up in the signed list. This is the commitment from the Commitments station: the salt hides the value, and the digest under the issuer’s signature binds it. Being an adult is not computed at presentation time: “Over 18” is a separate claim the issuer computed and signed, so it can be shown without the date of birth.

Anyone holding a copy of the token and its Disclosures can show them. So the issuer writes the holder’s public key into the token (cnf.jwk), and at every presentation she signs a KB-JWT with her private key: the verifier’s address (aud), its one-time nonce, the time and sd_hash — a digest of the token with the chosen Disclosures up to the last ~, without the KB-JWT itself. That is proof of possession (Key Binding), as with passkeys: the private key never leaves the device, and in the toy it is a non-extractable CryptoKey from WebCrypto. Your browser computes every key, salt and signature; the toy’s verifier accepts the presentation from the example in RFC 9901 §5.2 and gives exactly the RFC’s result.

Issuer, holder, verifier

Alice’s record: Fictional Documents Office
Given name given_name
"Alice"
Family name family_name
"Example"
Date of birth birthdate
"1998-04-17"
Over 18 age_over_18
true
Town locality
"Gdańsk"
Nationality nationality
"PL"

“Over 18” is computed by the issuer from the date of birth and signed as a claim of its own. SD-JWT computes nothing for the holder: you can show or hide only what the issuer signed.

The issuer holds six claims about Alice. Each gets its own random salt (128 bits), and only its digest goes into the signed token.

2Break it

Digests that give away, copies that link

Hiding rests on the salt. Without one a Disclosure depends only on the name and the value, and the values of many claims can be enumerated: there are about 36,500 birth dates in the last hundred years. In the toy’s “Break it” mode above, the wine shop gets “Over 18” alone and hunts for the hidden date of birth among the digests. The Disclosure it was shown tells it the format and the salt; when the issuer does not salt, or gives every claim the same salt, the date falls out after a few tens of thousands of digests. With a separate 128-bit salt per claim no date matches — RFC 9901 §9.3 requires that unrevealed salts cannot be learned or guessed, even when others have been revealed.

Key Binding protects against something else: showing someone else’s presentation. Without it the verifier learns only that the issuer issued the credential — whoever has a copy can show it. RFC 9901 §9.5 adds that the verifier decides up front whether it requires Key Binding; if the presence of a KB-JWT decided it, the attacker would just cut it off. Try all three moves in the frame below.

A presentation in someone else’s hands

You are on the attacker’s side. You are the wine shop and want to get into the forum with the presentation Alice showed you.

Alice showed the wine shop “Over 18” with a KB-JWT for aud = the wine shop and its nonce. The Neighbourhood Forum also admits adults only and asks for a presentation with its own nonce. The wine shop has every byte of Alice’s presentation — but not her private key.

What the wine shop sends to the forum

Choose what the wine shop sends, then send it to the forum.

The attack on the map is subtler, because nothing here is broken. Selective disclosure hides values, not the credential: every presentation of the same copy carries the same issuer signature, the same digests in _sd, the same holder key and the same issuance time, whatever it discloses. Two services that received different claims join them into one profile by those values. RFC 9901 §10.1 recommends batches of copies: each service, or each session, gets a different copy, and each copy MUST have fresh salts and a fresh holder key, with times (iat, exp) randomised within a period or rounded, for example to the start of the day. The same RFC admits that this does not help against the issuer: the issuer recognises every copy it signed, and a verifier can hand it over — which holds for every construction built on salted digests, mdoc included. Hiding from the issuer takes other tools, such as zero-knowledge proofs (the Ali Baba’s cave station).

Two services compare notes

You are on the attacker’s side. The wine shop and the forum join their data to find out whether they served the same person.

Alice shows the wine shop only “Over 18” and the forum only her town. Each presentation has its own KB-JWT and each one verifies. Neither service knows Alice’s name.

Alice has one copy of the credential and shows it everywhere.

Alice has one copy of the credential. Show it to both services.

The second attack on the map will come from a quantum computer. The SHA-256 digests survive, but issuers usually sign with ECDSA today (ES256 in the toy), and Shor’s algorithm recovers an ECDSA private key from the public one (the Signatures station). Whoever has such a computer and the issuer’s public key can issue any credential with any claims. The answer is post-quantum signatures such as ML-DSA from FIPS 204; the ML-DSA station covers them.

3In the real world

Where a credential is shown from a phone

  • Chrome 141 (2025)Since Chrome 141 the Digital Credentials API is enabled by default. A site asks for a credential by calling navigator.credentials.get() with a digital parameter; Chrome supports the OpenID4VP protocol and ISO 18013-7 (Annex C). On Android an installed wallet provides the credential; on desktop a phone connected by QR code and Bluetooth does.Source (Chrome 141 (2025))
  • Safari 26 (2025)WebKit for Safari 26.0 supports the Digital Credentials API with the org-iso-mdoc protocol (ISO/IEC 18013-7, Annex C). A site can request a document such as a driver’s license from Apple Wallet or from an app registered as an identity document provider.Source (Safari 26 (2025))
  • European Digital Identity Wallet (EUDI)The EU wallet architecture (ARF, chapter 5) requires wallets to support two formats: ISO/IEC 18013-5 (mdoc, CBOR) and SD-JWT VC. A provider may issue a batch of “technical” copies of the identity credential and require a different one at every presentation, so that relying parties, even colluding ones, cannot link presentations by shared elements such as public keys.Source (European Digital Identity Wallet (EUDI))
  • EU age verification blueprintThe European Commission’s specification describes a proof of age in mdoc format with an age_over_18 attribute. The proofs are single-use and issued in batches — the recommended batch is 30, each valid for at most 3 months — so that colluding services cannot track the user.Source (EU age verification blueprint)
  • Google: zero-knowledge proofs (2025)On 3 July 2025 Google open-sourced its zero-knowledge proof libraries (google/longfellow-zk), which let a person visiting a website prove they are over 18 without sharing anything else. Google ties them to age assurance in the EU and the EUDI wallet.Source (Google: zero-knowledge proofs (2025))
4Take it to your project

A salt per claim, Key Binding up front, a copy used once

Good practice

The verifier hashes the Disclosure text it received — not the parsed JSON — and looks the digest up in the signed list. It decides before checking whether it requires Key Binding, and then checks the KB-JWT signature with the key in cnf.jwk, its own aud and nonce, the age of iat and sd_hash. It takes the signature algorithm from its own configuration, not from the token header. The issuer draws a separate salt (at least 128 bits) for every claim, sorts the digests, and issues batches of single-use copies with fresh salts, a fresh holder key and a rounded iat.

JavaScript
const b64url = (buf) => btoa(String.fromCharCode(...new Uint8Array(buf)))
  .replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
const sha = async (text) =>
  b64url(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text)));
// policy fixed up front, not by what the holder sent
const REQUIRE_KB = true;
const [jwt, ...rest] = presentation.split('~');
const kbJwt = rest.pop(); // '' = no KB-JWT
if (REQUIRE_KB && kbJwt === '') throw new Error('no key binding');
// … the issuer's ES256 signature, then payload._sd from the signed token
const signed = new Set(payload._sd);
for (const d of rest) {
  if (!signed.has(await sha(d))) throw new Error('Disclosure not signed');
}
Anti-pattern

Do not issue digests without a salt, or with one salt for every claim — a hidden date of birth falls out after a few tens of thousands of digests. Do not hash re-encoded JSON: the RFC has no canonical form, so such a verifier rejects valid credentials or accepts bytes other than those signed. Do not make Key Binding depend on whether a KB-JWT is present. Do not show one copy to every service, and do not promise users anonymity: SD-JWT hides values, and the issuer always recognises its own signature.

JavaScript
// ✕ empty salt: anyone can recompute the birthdate's digest
const d = b64url(new TextEncoder().encode(JSON.stringify(['', 'birthdate', '1998-04-17'])));
// ✕ policy taken from the presentation: cutting off the KB-JWT is enough
const requireKb = kbJwt !== '';