getPublicKey

abstract suspend fun getPublicKey(keyId: KeyId): GetPublicKeyResult

Retrieves the public key information for a given key ID.

Returns a GetPublicKeyResult for type-safe error handling. Key not found is an expected failure and is represented as a result.

Example Usage:

when (val result = kms.getPublicKey(keyId)) {
is GetPublicKeyResult.Success -> {
val handle = result.keyHandle
// Use key handle
}
is GetPublicKeyResult.Failure.KeyNotFound -> {
// Expected: Key doesn't exist
println("Key not found: ${result.keyId}")
}
is GetPublicKeyResult.Failure.Error -> {
// Unexpected error
println("Error: ${result.reason}")
}
}

Return

Result containing the key handle or failure information

Parameters

keyId

Type-safe key identifier