eu-digital-identity-wallet / eudi-lib-jvm-presentation-exchange-kt

Implementation of DIF Presentation Exchange v2 specification in Kotlin (jvm)
Apache License 2.0
5 stars 3 forks source link
kotlin-library presentation-exchange

EUDI Presentation Exchange v2 library

:heavy_exclamation_mark: Important! Before you proceed, please read the EUDI Wallet Reference Implementation project description

License

Table of contents

Overview

The eudi-lib-jvm-presentation-exchange-kt is a kotlin library that implements the functionality as described in Presentation Exchange v2.

This is a specification that defines:

The use of this specification is mandatory by OpenID4VP

Disclaimer

The released software is a initial development release version:

Library functionality

Presentation Exchange optional features supported

The table bellow summarizes the set of optional features defined by Presentation Exchange v2 which are supported by the library. Currently, no optional features are being supported, except retention

Feature Status
Submission requirement
Predicate
Relational constraint
Credential status constraint
JSON-LD framing
Retention

How to Use

Verifier: Produce a valid PresentationDefinition

Precondition:

Library should offer a factory/builder to produce the PresentationDefinition. The resulting PresentationDefinition should

In order to create a presentation definition just instantiate the PresentationDefinition data class which enforces the syntactic a conditional rules as defined in the specification.

Holder: Parse/Validate a PresentationDefinition

The holder should be able to verify that a JSON object is a syntactically valid PresentationDefintion:

import eu.europa.ec.eudi.prex.*

// Decoding a presentation definition json (string)
val pdJsonStr : String = TODO("provide a presentation definition json")
val pd = PresentationExchange.parser.decodePresentationDefinition(pdJsonStr).getOrThrow()

Holder: Match a PresentationDefinition

import eu.europa.ec.eudi.prex.*

// Decoding a presentation definition json (string)
val pdJsonStr : String = TODO("provide a presentation definition json")
val pd = PresentationExchange.parser.decodePresentationDefinition(pdJsonStr).getOrThrow()

// Check whether a list of candidate claims can satisfy the 
// presentation definition requirements
val candidateClaims : List<Claim> = TODO("provide a list of candidate claims")
val result = PresentationExchange.matcher.match(pd, candidateClaims)
when(result){
    is Matched -> println(result.matches)
    is NotMatched -> println("Not matched")
}

For a concrete example please check MatcherSample

Presentation Definition Data Model

classDiagram
    class PresentationDefinition
    class InputDescriptor
    class FieldConstraint
    class LimitDisclosure
    PresentationDefinition *-- "1..*" InputDescriptor
    InputDescriptor o-- "*" FieldConstraint
    InputDescriptor --> "0..1" LimitDisclosure
    FieldConstraint -- "1..*" Path
    FieldConstraint : +Boolean optional
    note for InputDescriptor "Constraints for a single claim"

References

How to contribute

We welcome contributions to this project. To ensure that the process is smooth for everyone involved, follow the guidelines found in CONTRIBUTING.md.

License

Third-party component

License details

Copyright (c) 2023 European Commission

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.