DIDComm V2 Integration Guide
Overview
The TrustWeave DIDComm plugin integrates didcomm-java (org.didcommx:didcomm:0.3.2) through DidCommCryptoDidcomm. Packing and unpacking use DIDComm.packEncrypted / UnpackParams with forward(false) so messages are not wrapped for mediators unless you add that layer yourself.
What you must provide
suspend (String) -> DidDocument?— Resolve each DID to a W3C-shapedDidDocumentthat includes key agreement verification methods compatible with the keys you use for encryption (see didcomm-java curve matching).org.didcommx.didcomm.secret.SecretResolver— Resolve private key material for everykidinvolved (sender agreement key and recipient agreement key). For tests, useorg.trustweave.credential.didcomm.crypto.interop.MapSecretResolverwithorg.didcommx.didcomm.secret.Secretentries (VerificationMethodType.JSON_WEB_KEY_2020+ JWK string includingdis typical).BlockingDidDocResolveris used internally: your resolver runs onDispatchers.IOviarunBlockingwith a per-call timeout (default 30s) because didcomm-java’sDIDDocResolverAPI is synchronous. Do not call back into DIDComm pack/unpack from the resolver on the same thread (deadlock risk).
Factory methods
| Goal | API |
|---|---|
| Interoperable service | DidCommFactory.createInMemoryService(kms, resolveDid, secretResolver) |
| Interoperable packer | DidCommFactory.createPacker(kms, resolveDid, secretResolver) |
| Unsafe placeholder (dev only) | DidCommFactory.createInMemoryServiceWithPlaceholderCrypto(...) / createPackerWithPlaceholderCrypto(...) |
SPI (DidCommExchangeProtocolProvider)
Options map:
useProductionCrypto: defaults tofalse(placeholder crypto, noSecretResolver). Set totrueonly withsecretResolver; otherwise the provider throwsIllegalArgumentException.secretResolver:SecretResolver— required whenuseProductionCrypto == truefor didcomm-java.
DID document mapping
TrustWeaveDidDocMapper converts TrustWeave DidDocument → didcomm DIDDoc:
- Verification methods with
publicKeyJwk→JSON_WEB_KEY_2020(JWK serialized as a string). keyAgreementandauthenticationlists use full verification method IDs (did:…#fragment) as in didcomm-java.
Tests
See DidCommDidcommRoundTripTest in the plugin: X25519 OctetKeyPair (Nimbus), JsonWebKey2020 in DID docs, MapSecretResolver, then DidCommFactory.createPacker → pack / unpack.