Sphereon-Opensource / SIOP-OID4VP

Self Issued OpenID Provider v2 (SIOP) with optional OpenID for Verifiable Presentations (OpenID4VP)
Apache License 2.0
77 stars 25 forks source link

Validate presentations against definition optimizations #80

Open Haza85 opened 2 months ago

Haza85 commented 2 months ago

During presentation exchange I noticed that the same validations or decoding of jwt token in underlying methods happens multiple times.

Problem in PresentationExchange.validatePresentationsAgainstDefinition(). Here you have filterOutCorrectPresentation() method that invoke pex.evaluatePresentation() and do filtering to get only correct presentation definitions. After that in validatePresentationsAgainstDefinition() you have the same pex.evaluatePresentation() to do validation. But actually you made this validation previously, so no point to do this one more time. And at the end of method you have PresentationExchange.validatePresentationAgainstDefinition() where you one more time create PEX and call evaluatePresentation() for validation.

So maybe you can revise this method and optimize it so that you don't do the same checks multiple times. Because it slows down the presentation exchange process.