Skip to main content
Version: v0.13

Decentralized Identifiers (DIDs)

The IDK provides comprehensive support for Decentralized Identifiers (DIDs) following the W3C DID Core specification.

What are DIDs?

DIDs are globally unique identifiers that enable verifiable, decentralized digital identity. Unlike traditional identifiers, DIDs:

  • Are controlled by the subject, not a central authority
  • Can be resolved to DID Documents containing public keys and service endpoints
  • Support multiple methods for different use cases and trust models
DID Structure

Supported DID Methods

MethodDescriptionUse CaseNetwork Required
did:keyPublic key encoded in the identifierTesting, ephemeral identitiesNo
did:jwkJWK encoded in the identifierJOSE ecosystem interopNo
did:webWeb-hosted DID documentsProduction, organizationsYes

did:key

Self-contained DIDs where the public key is encoded directly in the identifier. No network access required for resolution.

did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK
└── Multibase-encoded public key

Supported key types:

  • Ed25519 (OKP) - Recommended
  • P-256, P-384, P-521 (EC)
  • secp256k1 (EC)

did:jwk

DIDs based on JSON Web Keys. The full JWK is base64url-encoded in the identifier.

did:jwk:eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2IiwieCI6Ii4uLiIsInkiOiIuLi4ifQ
└── Base64url-encoded JWK

did:web

Web-hosted DID documents. The identifier maps to a URL where the DID document is hosted.

did:web:example.com              → https://example.com/.well-known/did.json
did:web:example.com:users:alice → https://example.com/users/alice/did.json

Architecture

The IDK's DID support is organized into focused services:

DID Architecture

Managed vs External DIDs

The IDK distinguishes between two DID roles:

RoleDescriptionCapabilities
MANAGEDCreated and controlled locallyFull lifecycle: create, sign, update, deactivate
EXTERNALReceived from another partyResolution and verification only
import com.sphereon.did.manager.DidRole

// Check DID role
val managedDid = didManager.findByDid("did:key:z6Mk...")
when (managedDid?.role) {
DidRole.MANAGED -> println("Can sign with this DID")
DidRole.EXTERNAL -> println("Resolution only")
null -> println("DID not found")
}

DID Documents

A DID Document contains the public keys and service endpoints associated with a DID:

{
"@context": ["https://www.w3.org/ns/did/v1"],
"id": "did:web:example.com",
"verificationMethod": [{
"id": "did:web:example.com#key-1",
"type": "JsonWebKey2020",
"controller": "did:web:example.com",
"publicKeyJwk": {
"kty": "EC",
"crv": "P-256",
"x": "...",
"y": "..."
}
}],
"authentication": ["did:web:example.com#key-1"],
"assertionMethod": ["did:web:example.com#key-1"],
"service": [{
"id": "did:web:example.com#hub",
"type": "LinkedDomains",
"serviceEndpoint": "https://example.com"
}]
}

Verification Purposes

Keys can be assigned to different verification purposes:

PurposeDescription
authenticationProve control of the DID
assertionMethodIssue verifiable credentials
keyAgreementEstablish encrypted communication
capabilityInvocationInvoke capabilities
capabilityDelegationDelegate capabilities

Modules

ModuleDescription
lib-did-core-publicCore DID models and types
lib-did-resolver-public/implDID resolution
lib-did-manager-public/implDID lifecycle management
lib-did-methods-keydid:key method
lib-did-methods-jwkdid:jwk method
lib-did-methods-webdid:web method
lib-did-persistence-apiPersistence interfaces
lib-did-persistence-memoryIn-memory storage
lib-did-persistence-sqliteSQLite storage
lib-did-rest-resolver-serverUniversal Resolver REST API

Dependencies

Full DID Support

dependencies {
// Core
implementation("com.sphereon.idk:lib-did-core-public:0.13.0")

// Resolution
implementation("com.sphereon.idk:lib-did-resolver-public:0.13.0")
implementation("com.sphereon.idk:lib-did-resolver-impl:0.13.0")

// Management
implementation("com.sphereon.idk:lib-did-manager-public:0.13.0")
implementation("com.sphereon.idk:lib-did-manager-impl:0.13.0")

// Methods
implementation("com.sphereon.idk:lib-did-methods-key:0.13.0")
implementation("com.sphereon.idk:lib-did-methods-jwk:0.13.0")
implementation("com.sphereon.idk:lib-did-methods-web:0.13.0")

// Persistence
implementation("com.sphereon.idk:lib-did-persistence-api:0.13.0")
implementation("com.sphereon.idk:lib-did-persistence-sqlite:0.13.0")
}

Resolution Only

dependencies {
implementation("com.sphereon.idk:lib-did-core-public:0.13.0")
implementation("com.sphereon.idk:lib-did-resolver-public:0.13.0")
implementation("com.sphereon.idk:lib-did-resolver-impl:0.13.0")
implementation("com.sphereon.idk:lib-did-methods-web:0.13.0")
}

Next Steps