Identity online is rented, not owned
Your email address doubles as your login for most of the web, and a company you have never read the terms of service for can disable it â and every account hanging off it â without appeal. The same pattern repeats with phone numbers, government IDs uploaded to yet another dashboard, and employer badges that die on your last day. The common flaw is structural: the identifier is a loan from a central issuer who can revoke it, correlate its use, and monetize the logs.
Decentralized identifiers invert the control relationship. You generate an identifier locally, prove control of it with cryptographic keys you hold, and present selectively disclosed credentials issued by organizations that have vouched for specific claims. No registry can unilaterally delete the identifier, and no verifier learns more than the claim it asked for. This lesson walks through the W3C DID and verifiable credential model end to end, from DID documents to presentation exchanges to the key-management problems that dominate real deployments.
Prerequisites
- !Public-key cryptography basics
- !Blockchain transactions and addresses
- !How login sessions normally work
What You'll Learn
- 1Explain the roles of holder, issuer, and verifier
- 2Read a DID document and its verification methods
- 3Compare did:ethr, did:web, did:key, and did:ion
- 4Describe the issue â present â verify credential flow
The three-party model underneath every SSI system
Self-sovereign identity frameworks converge on the same triangle. An issuer signs a claim about a subject â a university asserting a degree, a bank asserting an account tier. A holder stores that signed credential in a wallet they control. A verifier requests a presentation, checks the issuer's signature against the issuer's public DID document, and decides whether to grant access. Notice what never happens: the verifier does not phone the university's API, and the university never learns where the holder presented the credential unless the holder chooses to link that.
Privacy follows from selective disclosure. A credential can contain name, date of birth, and student status, while the presentation reveals only an over-18 boolean derived cryptographically from the original attributes. W3C standardizes the data model; zero-knowledge techniques such as BBS+ signatures enable the disclosure proofs; and DIDs solve the key-distribution problem that would otherwise force everyone back through a central directory.
| Party | Holds | Trusts | Failure to design for |
|---|---|---|---|
| Issuer | Signing keys for its DID | Its own key custody | Key rotation without breaking old credentials |
| Holder | Credentials, private keys, the DID | Issuer honesty about claims | Device loss, inheritance, key rotation |
| Verifier | The presentation, the issuer DID | Issuer's attestation | Replay, revoked credentials, stale timestamps |
Anatomy of a DID and its document
A DID is a URI with three parts: the did scheme, a method name, and a method-specific identifier, for example did:ethr:0xabc123.... The DID itself is just a name. The power lives in the DID document that the method resolves to: a small JSON document listing verification methods (public keys), authentication capabilities, and service endpoints.
{
"@context": ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/jws-2020/v1"],
"id": "did:ethr:0x9A7e1f2A4cB0dD3eF5a8C1b2D3e4F5a6B7c8D9e0",
"verificationMethod": [
{
"id": "did:ethr:0x9A7e1f2A4cB0dD3eF5a8C1b2D3e4F5a6B7c8D9e0#controller",
"type": "EcdsaSecp256k1VerificationKey2019",
"controller": "did:ethr:0x9A7e1f2A4cB0dD3eF5a8C1b2D3e4F5a6B7c8D9e0",
"publicKeyHex": "0x04a1b2c3d4e5f6..."
}
],
"authentication": [
"did:ethr:0x9A7e1f2A4cB0dD3eF5a8C1b2D3e4F5a6B7c8D9e0#controller"
],
"service": [
{
"id": "did:ethr:0x9A7e1f2A4cB0dD3eF5a8C1b2D3e4F5a6B7c8D9e0#hub",
"type": "IdentityHub",
"serviceEndpoint": "https://hub.example.com/didcomm"
}
]
}
Resolution is method-specific. For did:ethr, the client derives the controller address and reads events from an Ethereum registry contract. For did:web, resolution is an HTTPS fetch of https://example.com/.well-known/did.json. For did:key, the DID document is derivable from the identifier itself with zero network calls. The verifier does not care which method ran â it only needs the verification method that signed the credential.
Comparing the four methods you will actually meet
No single method wins everywhere, and mixing them in one wallet is normal. The choice comes down to what must remain available if infrastructure disappears.
| Method | Resolves via | Key rotation | Offline usable | Typical use |
|---|---|---|---|---|
| did:ethr | Ethereum registry contract | Yes, via on-chain update events | After cache | On-chain apps, DeFi KYC |
| did:web | HTTPS on the domain | Yes, replace the JSON file | No | Enterprises, existing domains |
| did:key | Derived from the identifier | No â new DID per key | Yes | Throwaway sessions, demos |
| did:ion | Bitcoin-anchored Sidetree | Yes, via update operations | After sync | Long-lived public identities |
did:key deserves special mention: because the public key is the identifier, rotating the key means creating a brand-new DID. That is a feature for ephemeral contexts and a dead end for a lifelong identity. did:web inherits domain-expiry risk â lose the domain and you lose resolution. did:ethr and did:ion push availability guarantees into consensus security but add transaction latency and fees to every rotation.
Issuing, presenting, and verifying credentials
A verifiable credential is an ordinary JSON object plus a cryptographic proof that binds the issuer's DID to the content. The holder never transmits the credential directly during verification; instead the verifier sends a presentation request, and the holder returns a verifiable presentation â the credential, possibly predicate-redisclosed, plus a proof of possession of the holder's DID key.
{
"@context": ["https://www.w3.org/2018/credentials/v1"],
"id": "urn:uuid:3f8a2c1e-9b7d-4e2a-a1c0-8d5f6e7b4c3d",
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"issuer": "did:web:university.example.edu",
"issuanceDate": "2026-01-15T00:00:00Z",
"expirationDate": "2036-01-15T00:00:00Z",
"credentialSubject": {
"id": "did:ethr:0x9A7e1f2A4cB0dD3eF5a8C1b2D3e4F5a6B7c8D9e0",
"degree": { "type": "BachelorDegree", "name": "Computer Science" },
"gpa": "3.8"
},
"credentialSchema": { "id": "https://schema.example.edu/degree/v2", "type": "JsonSchemaValidator2018" },
"proof": {
"type": "Ed25519Signature2020",
"created": "2026-01-15T10:00:00Z",
"verificationMethod": "did:web:university.example.edu#key-1",
"proofPurpose": "assertionMethod",
"proofValue": "z58DadF1UWDsBhX7WnC..."
}
}
The verification checklist is short but easy to get wrong: resolve the issuer DID, confirm the proof's verificationMethod is authorized by that DID document for assertionMethod, check expirationDate against a trusted clock, consult a status list for revocation, match the credential against the expected schema, and confirm the presentation was created for this verifier (domain binding) to defeat replay. Skipping the last step is one of the most common implementation bugs in production wallets.
Putting a registry on-chain when you need one
Not every deployment needs an on-chain registry, but when issuers must be publicly discoverable or credential status must be censorship-resistant, a minimal contract suffices. The example below registers a DID hash per account and maintains a delegate set so a compromised device key can be rotated without changing the DID itself.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract DIDRegistry {
mapping(address => bytes32) public didDocumentHash;
mapping(address => mapping(address => bool)) public delegates;
mapping(bytes32 => uint64) public statusList; // 1 = active credential slot
event DIDRegistered(address indexed owner, bytes32 docHash);
event DelegateAdded(address indexed owner, address indexed delegate);
event DelegateRemoved(address indexed owner, address indexed delegate);
event CredentialStatusChanged(bytes32 indexed credentialId, uint64 status);
function registerDID(bytes32 docHash) external {
require(didDocumentHash[msg.sender] == bytes32(0), "already registered");
didDocumentHash[msg.sender] = docHash;
emit DIDRegistered(msg.sender, docHash);
}
function addDelegate(address delegate) external {
delegates[msg.sender][delegate] = true;
emit DelegateAdded(msg.sender, delegate);
}
function removeDelegate(address delegate) external {
delegates[msg.sender][delegate] = false;
emit DelegateRemoved(msg.sender, delegate);
}
function setCredentialStatus(bytes32 credentialId, uint64 status) external {
statusList[credentialId] = status;
emit CredentialStatusChanged(credentialId, status);
}
}
Storing a hash rather than the full document keeps gas costs flat and lets the holder host rich metadata elsewhere. The delegate mapping is the part people skip and later regret: real wallets rotate device keys every year or two, and without delegates, every rotation would orphan every credential already issued to the old key.
Key management is the actual product
DID tooling is largely solved; key custody is not. A holder who loses the private key loses the ability to authenticate as that DID, and unless recovery was designed in advance, every credential anchored to it becomes unusable. Production wallets address this with a layered approach: a high-security root key kept in cold storage or a hardware module, rotation-capable device keys registered as delegates, and social or institutional recovery where a threshold of trusted guardians can authorize a rotation. Verifiers must plan for the mirror-image problem â issuers go out of business, so status lists and document hashes should be anchored somewhere durable (on-chain or in a content-addressed store) long after the issuer's API is dark.
Common Mistakes
Verifying a credential signature without checking the presentation is bound to this verifier
Fix: Require a nonce and domain in the presentation request and verify them during proof validation
Treating did:key as suitable for a long-lived citizen identity
Fix: Reserve did:key for ephemeral sessions; use a rotatable method for durable identities
Skipping revocation because it feels un-private
Fix: Publish bitstring status lists â they reveal only whether a specific credential is revoked
Hard-coding one DID method across the whole stack
Fix: Abstract resolution behind an interface so wallets can support did:ethr, did:web, and did:key side by side
Ignoring key rotation at issuance time
Fix: Register delegates in the DID document before issuing, and verify delegate chains during presentation checks
Best Practices
- Follow the W3C DID Core and VC Data Model 2.0 specifications rather than bespoke JSON layouts
- Anchor credential status lists on-chain or in content-addressed storage so revocation survives issuer downtime
- Bind every presentation request to a nonce and an audience to prevent replay
- Separate the authentication key from the assertion key so a wallet compromise does not invalidate issued credentials
- Design recovery (guardians, hardware roots, institutional delegates) before the first credential is ever issued
Interview Questions
Q1: What problem do DIDs solve that a traditional PKI does not?
PKI ties identity to a certificate authority that issues, renews, and revokes on its terms. A DID lets the subject generate the identifier and control the keys; trust in claims comes from issuer signatures, not from the identifier provider, and no central CA can revoke the identifier itself.
Q2: How does selective disclosure work without revealing the original credential?
Modern proof systems such as BBS+ let the holder derive a proof over a subset of attributes, or evaluate predicates like age-over-18, while the verifier checks the issuer signature against the derived proof. The verifier never sees attributes that were not disclosed.
Q3: Why store only a hash of the DID document on-chain?
Gas cost and flexibility. The hash fixes the document content immutably for auditing, while the full document can evolve in cheaper storage. Anyone can present the document plus the hash and prove it was the registered version.
Q4: What happens when an issuer goes offline permanently?
Credentials already issued remain verifiable because verification only needs the issuer public key, which verifiers cache or resolve from durable anchors. New issuance stops, and status checking falls back to an anchored status list rather than a live API.
Key Takeaways
- DIDs separate the identifier from any issuer â control lives in keys the holder manages, resolved through method-specific documents
- did:ethr and did:ion offer rotatable, consensus-secured resolution; did:web depends on domain uptime; did:key is self-resolving but non-rotatable
- Verification means resolving the issuer DID, checking the proof purpose, validating expiry and revocation, and binding the presentation to this verifier
- Selective disclosure keeps presentations minimal: reveal the predicate, not the raw credential
- Key rotation, delegate management, and recovery design determine whether an identity survives a lost device