fromCbor

open suspend override fun fromCbor(bytes: ByteArray): VerifiableCredential

Convert CBOR to credential.

Deserializes CBOR-encoded bytes back to a VerifiableCredential. The CBOR bytes are first converted to JSON format, then parsed using kotlinx.serialization.

Implementation Details:

  • Uses Jackson CBOR mapper to parse CBOR bytes to JSON tree model

  • Converts JSON tree to JSON string

  • Uses kotlinx.serialization to deserialize JSON string to VerifiableCredential

  • Handles all credential structures including nested objects and arrays

Error Handling:

  • Throws IllegalArgumentException if CBOR bytes are invalid

  • Throws SerializationException if credential structure is invalid

Recommended: Use the extension function cborBytes.fromCbor() instead for a more elegant API.

Return

Verifiable credential

Parameters

bytes

CBOR-encoded bytes

See also

For encoding credentials to CBOR

Extension function

Throws

if CBOR bytes cannot be parsed

kotlinx.serialization.SerializationException

if credential deserialization fails