This guide covers the did:jwk method integration for TrustWeave. The did:jwk plugin provides W3C-standard DID resolution using JSON Web Keys directly.
Overview
The did/plugins/jwk module provides an implementation of TrustWeave’s DidMethod interface using the W3C did:jwk specification. This integration enables you to:
Create and resolve DIDs from JSON Web Keys (JWK) directly
Use standard JWK format without multicodec prefixes
Support all JWK key types (OKP, EC, RSA)
Zero external dependencies - documents are derived from JWK
Why did:jwk?
did:jwk offers a standardized approach to DIDs:
W3C Standard: Official W3C specification
JWK Native: Uses JSON Web Key format directly
Simple: No multicodec encoding required
Standardized: Works with any JWK-compatible system
When the module is on the classpath, did:jwk is automatically available:
1
2
3
4
5
6
7
8
9
10
11
12
importcom.trustweave.did.*importjava.util.ServiceLoader// Discover did:jwk providervalproviders=ServiceLoader.load(DidMethodProvider::class.java)valjwkProvider=providers.find{it.supportedMethods.contains("jwk")}// Create methodvaloptions=didCreationOptions{// KMS will be discovered automatically if not provided}valmethod=jwkProvider?.create("jwk",options)
Usage Examples
Creating a did:jwk
1
2
3
4
5
6
7
8
9
10
11
12
valkms=InMemoryKeyManagementService()valmethod=JwkDidMethod(kms)// Create DID with Ed25519 keyvaloptions=didCreationOptions{algorithm=KeyAlgorithm.ED25519purpose(KeyPurpose.AUTHENTICATION)purpose(KeyPurpose.ASSERTION)}valdocument=method.createDid(options)println("Created: ${document.id}")// did:jwk:eyJ...
Resolving a did:jwk
1
2
3
4
5
6
7
// Resolve DID (derived from JWK)valresult=method.resolveDid("did:jwk:eyJkIjoieCIsImNydiI6IkVkMjU1MTkiLCJrdHkiOiJPS1AifQ")result.document?.let{doc->println("Resolved: ${doc.id}")println("Verification methods: ${doc.verificationMethod.size}")}?:println("Not found")