AbstractBlockchainDidMethod

Abstract base class for blockchain-based DID method implementations.

Provides common functionality for DID methods that store documents on blockchain:

  • Integration with BlockchainAnchorClient for on-chain storage

  • Document anchoring to blockchain

  • Document resolution from blockchain

  • Fallback to in-memory storage for testing

Local deactivation is authoritative, even over a successful chain read. The DID Resolution 1.0 CR does not settle where a blockchain-backed method should learn of deactivation from, so resolveFromBlockchain makes an explicit, fail-safe choice: once this instance has recorded a DID as deactivated (via deactivateDocumentOnBlockchain), every subsequent resolution returns DidResolutionResult.Deactivated for that DID — whether the chain read fails and falls back to the stored document, or the chain read succeeds and returns a live, still-anchored (pre-deactivation) document. A revoked DID must never verify; treating the chain as authoritative over local state would let a stale or unpruned on-chain anchor silently resurrect a DID TrustWeave believes is dead. The accepted tradeoff is that a DID deactivated on one instance still resolves live on another instance that never observed the deactivation, since this state is local and is not propagated to, or re-derived from, the chain. This mirrors the same rule applied to did:web in AbstractWebDidMethod.resolveFromHttp.

Subclasses should implement:

Pattern: Reuses existing blockchain anchoring infrastructure.

Example Usage:

class EthrDidMethod(
kms: KeyManagementService,
private val anchorClient: BlockchainAnchorClient,
private val chainId: String = "eip155:1"
) : AbstractBlockchainDidMethod("ethr", kms) {

override fun getBlockchainAnchorClient(): BlockchainAnchorClient = anchorClient

override fun getChainId(): String = chainId

override suspend fun createDid(options: DidCreationOptions): DidDocument {
// Create DID document
val document = createDocument(options)

// Anchor to blockchain
anchorDocument(document)

return document
}

override suspend fun resolveDid(did: String): DidResolutionResult {
// Resolve from blockchain
return resolveFromBlockchain(did)
}
}

Constructors

Link copied to clipboard
constructor(method: String, kms: KeyManagementService)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
open override val method: String

Functions

Link copied to clipboard
abstract suspend fun createDid(options: DidCreationOptions): DidDocument
Link copied to clipboard
open suspend override fun deactivateDid(did: Did): Boolean

Default implementation of deactivateDid using in-memory storage.

Link copied to clipboard
abstract suspend override fun resolveDid(did: Did): DidResolutionResult
open suspend fun resolveDid(did: Did, options: ResolutionOptions): DidResolutionResult
Link copied to clipboard
open suspend override fun updateDid(did: Did, updater: (DidDocument) -> DidDocument): DidDocument

Default implementation of updateDid using in-memory storage.