Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Split off and store disclosures with the SD-JWT
Browse files Browse the repository at this point in the history
  • Loading branch information
waltkb committed Nov 22, 2023
1 parent 07587e7 commit b63bef1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/kotlin/id/walt/service/SSIKit2WalletService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,15 @@ class SSIKit2WalletService(accountId: UUID, walletId: UUID) : WalletService(acco
val addableCredentials: List<WalletCredential> = credentialResponses.map { credentialResp ->
val credential = credentialResp.credential!!.jsonPrimitive.content

val credentialJwt = credential.decodeJws()
val credentialJwt = credential.decodeJws(withSignature = true)

when (val typ = credentialJwt.header["typ"]?.jsonPrimitive?.content?.lowercase()) {
"jwt" -> {
val credentialId = credentialJwt.payload["vc"]!!.jsonObject["id"]?.jsonPrimitive?.content?.takeIf { it.isNotBlank() }
?: randomUUID()

println("Got JWT credential: $credentialJwt")

WalletCredential(
wallet = walletId,
id = credentialId,
Expand All @@ -348,7 +350,11 @@ class SSIKit2WalletService(accountId: UUID, walletId: UUID) : WalletService(acco
val credentialId = credentialJwt.payload["id"]?.jsonPrimitive?.content?.takeIf { it.isNotBlank() }
?: randomUUID()

println("Got SD-JWT credential: $credentialJwt")

val disclosures = credentialJwt.signature.split("~").drop(1)
println("Disclosures (${disclosures.size}): $disclosures")

val disclosuresString = disclosures.joinToString("~")

WalletCredential(
Expand Down

0 comments on commit b63bef1

Please sign in to comment.