createFromMetadata

suspend fun createFromMetadata(issuerKey: AsymmetricKey, kbKey: EcPublicKey?, claims: String, digestAlgorithm: Algorithm = Algorithm.SHA256, random: Random = Random.Default, saltSizeNumBits: Int = 128, creationTime: Instant = Instant.DISTANT_PAST, expiresIn: Duration? = null): SdJwt

Creates a SD-JWT.

This implementation uses DisclosureMetadata in the "_sd" claim of each nested JsonObject in the claims parameter to describe which claims to disclose.

Note: this variant with String instead of JsonObject only exists for interoperability with Swift.

Parameters

issuerKey

the key to sign the issuerSigned JWT with. If this is a AsymmetricKey.X509Certified the certificate chain will be included in the x5c claim and always be disclosed.

kbKey

if set, a cnf claim with this public key will be included in the Issuer-signed JWT.

claims

the object with claims that can be selectively disclosed.

digestAlgorithm

the hash algorithm to use, e.g. Algorithm.SHA256.

random

the Random to use to generate salts.

saltSizeNumBits

number of bits to use for each salt.

creationTime

the time the SD-JWT was created, pass Instant.DISTANT_PAST to not set iat claim.

expiresIn

the duration in which the SD-JWT expire or null.


suspend fun createFromMetadata(issuerKey: AsymmetricKey, kbKey: EcPublicKey?, claims: JsonObject, digestAlgorithm: Algorithm = Algorithm.SHA256, random: Random = Random.Default, saltSizeNumBits: Int = 128, creationTime: Instant = Instant.DISTANT_PAST, expiresIn: Duration? = null): SdJwt

Creates a SD-JWT.

This implementation uses DisclosureMetadata in the "_sd" claim of each nested JsonObject in the claims parameter to describe which claims to disclose.

Parameters

issuerKey

the key to sign the issuerSigned JWT with. If this is a AsymmetricKey.X509Certified the certificate chain will be included in the x5c claim and always be disclosed.

kbKey

if set, a cnf claim with this public key will be included in the Issuer-signed JWT.

claims

the object with claims that can be selectively disclosed.

digestAlgorithm

the hash algorithm to use, e.g. Algorithm.SHA256.

random

the Random to use to generate salts.

saltSizeNumBits

number of bits to use for each salt.

creationTime

the time the SD-JWT was created, pass Instant.DISTANT_PAST to not set iat claim.

expiresIn

the duration in which the SD-JWT expire or null.