Skip to content

Commit

Permalink
Send only one doc per time to zkp library
Browse files Browse the repository at this point in the history
  • Loading branch information
code28 committed Aug 26, 2024
1 parent 373dfd4 commit 23e88e5
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,20 @@ class PostWalletResponseLive(
val key = presentation.zkpKeys?.get(descriptorId)
ensureNotNull(key) { raise(WalletResponseValidationError.InvalidVPToken) }

val proofed = token.let {
// ---

val data = DataElement.fromCBOR<MapElement>(Base64.getUrlDecoder().decode(token))
val documents = data.value[MapKey("documents")] as? ListElement
ensureNotNull(documents) {
logger.error("No documents found in MDoc")
WalletResponseValidationError.InvalidMdoc
}
val firstDocument = documents.value[0] as MapElement
val firstDoc = Base64.getUrlEncoder().encodeToString(firstDocument.toCBOR())

// ---

val proofed = firstDoc.let {
verifier.verifyChallenge(VpTokenFormat.MSOMDOC, it, key)
}
ensure(proofed) {
Expand Down

0 comments on commit 23e88e5

Please sign in to comment.