TrustRegistry

interface TrustRegistry : TypeAwareTrustEvaluator

Trust registry for managing trust anchors and discovering trust paths.

A trust registry maintains a graph of trusted DIDs (trust anchors) and allows verification of whether an issuer is trusted, either directly or through a trust path.

Example Usage:

val registry: TrustRegistry = InMemoryTrustRegistry()

// Add a trust anchor
registry.addTrustAnchor(
anchorDid = "did:key:trusted-issuer",
metadata = TrustAnchorMetadata(
credentialTypes = listOf("EducationCredential"),
description = "Trusted university",
addedAt = Clock.System.now()
)
)

// Check if issuer is trusted
val isTrusted = registry.isTrustedIssuer("did:key:trusted-issuer", "EducationCredential")

// Find trust path
val path = registry.findTrustPath(
VerifierIdentity(Did("did:key:verifier")),
IssuerIdentity(Did("did:key:issuer"))
)

Functions

Link copied to clipboard
abstract suspend fun addTrustAnchor(anchorDid: String, metadata: TrustAnchorMetadata): Boolean

Adds a trust anchor to the registry.

Link copied to clipboard
infix fun TrustEvaluator.and(other: TrustEvaluator): TrustEvaluator

Policy composition operators for combining trust policies.

Link copied to clipboard
abstract suspend fun findTrustPath(from: VerifierIdentity, to: IssuerIdentity): TrustPath

Finds a trust path between two identities (first-class type).

Link copied to clipboard
abstract suspend fun getTrustedIssuers(credentialType: String?): List<String>

Gets all trusted issuers for a specific credential type.

open suspend fun getTrustedIssuers(credentialType: CredentialType?): List<Did>

Gets all trusted issuers for a specific credential type (type-safe overload).

Link copied to clipboard
open suspend override fun isTrusted(issuer: Did): Boolean

CredentialTrustPolicy without a credential type: trusted only if the anchor is trusted for every type (isTrustedForAllTypes). Verification uses the typed overload when it knows the credential's types.

open suspend override fun isTrusted(issuer: Did, credentialTypes: List<String>): Boolean

Checks trust for a credential with the given type entries. Every type other than the base VerifiableCredential must be permitted by the anchor; with no specific type, the base type must be. An empty list is a typeless question and is answered by isTrusted (fail closed for a type-restricted anchor).

Link copied to clipboard
open suspend fun isTrustedForAllTypes(issuerDid: String): Boolean

Whether issuerDid is a trust anchor trusted for every credential type, i.e. one with no type restriction.

Link copied to clipboard
abstract suspend fun isTrustedIssuer(issuerDid: String, credentialType: String?): Boolean

Checks if an issuer DID is trusted for a specific credential type.

open suspend fun isTrustedIssuer(issuer: IssuerIdentity, credentialType: CredentialType?): Boolean

Checks if an issuer is trusted for a specific credential type (type-safe overload).

Link copied to clipboard
operator fun TrustEvaluator.not(): TrustEvaluator

Negate a trust policy.

Link copied to clipboard
infix fun TrustEvaluator.or(other: TrustEvaluator): TrustEvaluator

Compose two trust policies with OR logic.

Link copied to clipboard
abstract suspend fun removeTrustAnchor(anchorDid: String): Boolean

Removes a trust anchor from the registry.