Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SD-JWT Claims #11

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Use data provided by EU Wallets as a W3C VC, or ISO 18013-5 Credential, with the

Be sure to call `at.asitplus.wallet.eupid.Initializer.initWithVCK` first thing in your application.

See [PID Rule Book](https://github.com/eu-digital-identity-wallet/eudi-doc-architecture-and-reference-framework/blob/main/docs/annexes/annex-06-pid-rulebook.md) for a list of attributes. These are implemented:
See [PID Rule Book](https://github.com/eu-digital-identity-wallet/eudi-doc-architecture-and-reference-framework/blob/main/docs/annexes/annex-06-pid-rulebook.md) for a list of attributes.

These are implemented for ISO:
- `family_name`
- `given_name`
- `birth_date`
Expand Down Expand Up @@ -45,8 +47,44 @@ See [PID Rule Book](https://github.com/eu-digital-identity-wallet/eudi-doc-archi
- `issuing_country`
- `issuing_jurisdiction`

These are implemented for SD-JWT:
- `family_name`
- `given_name`
- `birthdate`
- `age_equal_or_over.12`
- `age_equal_or_over.14`
- `age_equal_or_over.16`
- `age_equal_or_over.18`
- `age_equal_or_over.21`
- `age_in_years`
- `age_birth_year`
- `birth_family_name`
- `birth_given_name`
- `place_of_birth.locality`
- `place_of_birth.country`
- `place_of_birth.region`
- `address.formatted`
- `address.country`
- `address.region`
- `address.locality`
- `address.postal_code`
- `address.street_address`
- `address.house_number`
- `gender`
- `nationalities`
- `iat`
- `exp`
- `issuing_authority`
- `document_number`
- `administrative_number`
- `issuing_country`
- `issuing_jurisdiction`

## Changelog

Release 2.3.0:
- Implement mapping to SD-JWT claim names according to <https://github.com/eu-digital-identity-wallet/eudi-doc-architecture-and-reference-framework/pull/160>

Release 2.2.3:
- VC-K 5.2.2
- Add additional claims: `age_over_12`, `age_over_14`, `age_over_16`, `age_over_21`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
package at.asitplus.wallet.eupid

import at.asitplus.wallet.eupid.EuPidScheme.SdJwtAttributes
import kotlinx.datetime.Instant
import kotlinx.datetime.LocalDate
import kotlinx.datetime.serializers.LocalDateIso8601Serializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable


/**
* PID according to [EU PID Rule Book, v1.0.0 from November 2023](https://github.com/eu-digital-identity-wallet/eudi-doc-architecture-and-reference-framework/blob/main/docs/annexes/annex-06-pid-rulebook.md)
* with mapping of claim names according to [PR #160](https://github.com/eu-digital-identity-wallet/eudi-doc-architecture-and-reference-framework/pull/160)
**/
@Serializable
data class EuPidCredentialSdJwt(
/** Current last name(s) or surname(s) of the PID User. */
@SerialName(SdJwtAttributes.FAMILY_NAME)
val familyName: String,

/** Current first name(s), including middle name(s), of the PID User. */
@SerialName(SdJwtAttributes.GIVEN_NAME)
val givenName: String,

/** Day, month, and year on which the PID User was born. */
@SerialName(SdJwtAttributes.BIRTH_DATE)
@Serializable(with = LocalDateIso8601Serializer::class)
val birthDate: LocalDate,

/** Additional current age attestations. */
@SerialName(SdJwtAttributes.PREFIX_AGE_EQUAL_OR_OVER)
val ageEqualOrOver: AgeEqualOrOverSdJwt,

/** The current age of the PID User in years. */
@SerialName(SdJwtAttributes.AGE_IN_YEARS)
val ageInYears: UInt? = null,

/** The year when the PID User was born. */
@SerialName(SdJwtAttributes.AGE_BIRTH_YEAR)
val ageBirthYear: UInt? = null,

/** Last name(s) or surname(s) of the PID User at the time of birth. */
@SerialName(SdJwtAttributes.FAMILY_NAME_BIRTH)
val familyNameBirth: String? = null,

/** First name(s), including middle name(s), of the PID User at the time of birth. */
@SerialName(SdJwtAttributes.GIVEN_NAME_BIRTH)
val givenNameBirth: String? = null,

/** Place of birth. */
@SerialName(SdJwtAttributes.PREFIX_PLACE_OF_BIRTH)
val placeOfBirth: PlaceOfBirthSdJwt,

/** Address. */
@SerialName(SdJwtAttributes.PREFIX_ADDRESS)
val address: AddressSdJwt,

/** PID User’s gender, using a string value like `female`, `male`, or custom text values. */
@SerialName(SdJwtAttributes.GENDER)
val gender: String? = null,

/** Array of Alpha-2 country code as specified in ISO 3166-1, representing the nationality of the PID User. */
@SerialName(SdJwtAttributes.NATIONALITIES)
val nationalities: Set<String>? = null,

/** Date (and possibly time) when the PID was issued. */
@SerialName(SdJwtAttributes.ISSUANCE_DATE)
val issuanceDate: Instant,

/** Date (and possibly time) when the PID will expire. */
@SerialName(SdJwtAttributes.EXPIRY_DATE)
val expiryDate: Instant,

/**
* Name of the administrative authority that has issued this PID instance, or
* the ISO 3166 Alpha-2 country code of the respective Member State if
* there is no separate authority authorized to issue PIDs.
*/
@SerialName(SdJwtAttributes.ISSUING_AUTHORITY)
val issuingAuthority: String,

/** A number for the PID, assigned by the PID Provider. */
@SerialName(SdJwtAttributes.DOCUMENT_NUMBER)
val documentNumber: String? = null,

/** A number assigned by the PID Provider for audit control or other purposes. */
@SerialName(SdJwtAttributes.ADMINISTRATIVE_NUMBER)
val administrativeNumber: String? = null,

/** Alpha-2 country code, as defined in ISO 3166-1, of the PID Provider's country or territory. */
@SerialName(SdJwtAttributes.ISSUING_COUNTRY)
val issuingCountry: String,

/**
* Country subdivision code of the jurisdiction that issued the PID, as
* defined in ISO 3166-2:2020, Clause 8. The first part of the code SHALL
* be the same as the value for [issuingCountry].
*/
@SerialName(SdJwtAttributes.ISSUING_JURISDICTION)
val issuingJurisdiction: String? = null,
)

@Serializable
data class AgeEqualOrOverSdJwt(
/** Additional current age attestations: Attesting whether the PID User is currently over 12 years old. */
@SerialName(SdJwtAttributes.AgeEqualOrOver.EQUAL_OR_OVER_12)
val equalOrOver12: Boolean? = null,

/** Additional current age attestations: Attesting whether the PID User is currently over 14 years old. */
@SerialName(SdJwtAttributes.AgeEqualOrOver.EQUAL_OR_OVER_14)
val equalOrOver14: Boolean? = null,

/** Additional current age attestations: Attesting whether the PID User is currently over 16 years old. */
@SerialName(SdJwtAttributes.AgeEqualOrOver.EQUAL_OR_OVER_16)
val equalOrOver16: Boolean? = null,

/** Attesting whether the PID User is currently an adult (true) or a minor (false). */
@SerialName(SdJwtAttributes.AgeEqualOrOver.EQUAL_OR_OVER_18)
val equalOrOver18: Boolean? = null,

/** Additional current age attestations: Attesting whether the PID User is currently over 21 years old. */
@SerialName(SdJwtAttributes.AgeEqualOrOver.EQUAL_OR_OVER_21)
val equalOrOver21: Boolean? = null,
)

@Serializable
data class PlaceOfBirthSdJwt(
/** The country where the PID User was born, as an Alpha-2 country code as specified in ISO 3166-1. */
@SerialName(SdJwtAttributes.PlaceOfBirth.COUNTRY)
val country: String? = null,

/** The state, province, district, or local area where the PID User was born. */
@SerialName(SdJwtAttributes.PlaceOfBirth.REGION)
val region: String? = null,

/** The municipality, city, town, or village where the PID User was born. */
@SerialName(SdJwtAttributes.PlaceOfBirth.LOCALITY)
val locality: String? = null,
)

@Serializable
data class AddressSdJwt(
/**
* The full address of the place where the PID User currently resides and/or can be contacted
* (street name, house number, city etc.).
*/
@SerialName(SdJwtAttributes.Address.FORMATTED)
val formatted: String? = null,

/** The country where the PID User currently resides, as an Alpha-2 country code as specified in ISO 3166-1. */
@SerialName(SdJwtAttributes.Address.COUNTRY)
val country: String? = null,

/** The state, province, district, or local area where the PID User currently resides. */
@SerialName(SdJwtAttributes.Address.REGION)
val region: String? = null,

/** The municipality, city, town, or village where the PID User currently resides. */
@SerialName(SdJwtAttributes.Address.LOCALITY)
val locality: String? = null,

/** Postal code of the place where the PID User currently resides. */
@SerialName(SdJwtAttributes.Address.POSTAL_CODE)
val postalCode: String? = null,

/** The name of the street where the PID User currently resides. */
@SerialName(SdJwtAttributes.Address.STREET)
val street: String? = null,

/** The house number where the PID User currently resides, including any affix or suffix. */
@SerialName(SdJwtAttributes.Address.HOUSE_NUMBER)
val houseNumber: String? = null,
)
Loading