26.94. taler-exchange-kyc-kych-converter(1)#

26.94.1. Name#

taler-exchange-kyc-kych-converter - turn KyCH’s identification result into KYC attributes for a GNU Taler exchange

26.94.2. Synopsis#

taler-exchange-kyc-kych-converter < INFO > ATTRIBUTES

26.94.3. Description#

A GNU Taler exchange can use KyCH as a KYC provider through its oauth2 KYC logic. When a person has identified at KyCH, the exchange fetches the result from KyCH’s /info endpoint, passes its JSON to the program named by KYC_OAUTH2_CONVERTER_HELPER on standard input, and expects the KYC attributes as a JSON object on standard output. taler-exchange-kyc-kych-converter is that program for KyCH. It is a shell script that runs jq(1) (1.6 or newer) and takes no arguments.

The attributes are those of GANA’s registry of GNU Taler form attributes (gnu-taler-form-attributes), so that the exchange’s AML programs and forms can read them without knowing which source of identity the person used.

26.94.3.1. Input#

The answer of /info (see KyCH’s REST API): the claims the person disclosed, under the native names of the session’s vocabulary, and three members of KyCH’s own – vocabulary (which source of identity was used), missing (the optional claims of the profile that the credential did not have) and evidence (how the result was obtained and checked). The converter knows the claims of the vocabularies KyCH ships, whichever profile asked for them: swiyu, eupid, eupid-mdoc, npa and eidas.

26.94.3.2. Output#

An object with:

FORM_ID

Always kych.

id

KyCH’s verification id (evidence.verification_id), which the exchange requires as the person’s identifier at the provider.

IDENTIFICATION_METHOD

The vocabulary.

IDENTIFICATION_LEVEL_OF_ASSURANCE

evidence.level_of_assurance: low, substantial or high (an eIDAS URI such as http://eidas.europa.eu/LoA/high is shortened to its level). Absent when KyCH did not establish one – it never does for a Swiss e-ID, nor for an EU PID whose issuer is on a simulated trust list.

IDENTIFICATION_EVIDENCE

The whole evidence object, the raw presentation included, so that the exchange keeps it once KyCH has purged its own copy.

and the person’s data, as each vocabulary carries it:

Attribute

swiyu

eupid

eupid-mdoc

npa

eidas

PERSON_FIRST_NAMES

given_name

given_name

given_name

GivenNames

CurrentGivenName

PERSON_LAST_NAME

family_name

family_name

family_name

FamilyNames

CurrentFamilyName

FULL_NAME

both, given names first

both

both

both

both

DATE_OF_BIRTH

birth_date

birthdate

birth_date

DateOfBirth

DateOfBirth

PLACE_OF_BIRTH

birth_place

place_of_birth: locality, region

the same

PlaceOfBirth: free text, or City, State

TownOfBirth, else PlaceOfBirth

COUNTRY_OF_BIRTH

place_of_birth.country

the same

PlaceOfBirth: Country

CountryOfBirth

NATIONALITIES, NATIONALITY

nationality

nationalities

nationality

Nationality

Nationality

ADDRESS_STREET_NAME

address.street_address

resident_street (with the number)

PlaceOfResidence: Street

CurrentAddress: Thoroughfare

ADDRESS_STREET_NUMBER

address.house_number

LocatorDesignator

ADDRESS_ZIPCODE

address.postal_code

resident_postal_code

ZipCode

PostCode

ADDRESS_TOWN_LOCATION

address.locality

resident_city

City

PostName

ADDRESS_COUNTRY_SUBDIVISION

address.region

resident_state

State

AdminunitSecondline

ADDRESS_COUNTRY

address.country

resident_country

Country

AdminunitFirstline

ADDRESS_LINES

street and number, postal code and town, on two lines; else address.formatted

the same; else resident_address

the same; else the free-text place

the same; else FullCvaddress

PERSONAL_IDENTIFICATION_DOCUMENT_TYPE

evidence.credential_type

evidence.credential_type (the vct)

evidence.credential_type (the doctype)

DocumentType

PERSONAL_IDENTIFICATION_DOCUMENT_NUMBER

document_number

document_number

document_number

PERSONAL_IDENTIFICATION_DOCUMENT_ISSUER

issuing_authority

issuing_authority

issuing_authority

PERSONAL_IDENTIFICATION_DOCUMENT_COUNTRY

issuing_country

issuing_country

issuing_country

IssuingState

PERSONAL_IDENTIFICATION_DOCUMENT_EXPIRATION

expiry_date

date_of_expiry

expiry_date

DateOfExpiry

IDENTIFICATION_PERSON_IDENTIFIER

RestrictedID (its ID)

PersonIdentifier

The eidas claims are named by their URIs, http://eidas.europa.eu/attributes/naturalperson/ followed by the name in the table; the bare name is accepted as well. Its CurrentAddress is the base64 encoding of the address elements, as the eIDAS SAML attribute profile has it, or those elements as an object.

The values are normalised:

  • Dates become YYYY-MM-DD. The German eID card’s dates may come as YYYYMMDD or as {"DateValue", "DateString"}; a date the card holds incompletely (unknown day or month) is left out.

  • Country codes become ISO 3166-1 alpha-2. The German eID card uses ICAO 9303 codes – D for Germany, three letters otherwise – which are converted; a code that cannot be is left out. Through kych-eumw-bridge the nationality already arrives as alpha-2 (the eIDAS Middleware converts it), the country of the place of residence as the card has it; both work.

  • NATIONALITIES holds every nationality once, in the order given; NATIONALITY, which forms and AML programs of earlier versions read, the first of them.

  • Places of the German eID card are structured (StructuredPlace), free text (FreetextPlace) or NoPlaceInfo, which gives nothing. Through kych-eumw-bridge the place of birth is always free text (a structured one’s city), and a place of residence that is not structured is missing.

Anything absent is left out. A claim the credential did not have is not in the input – KyCH lists it in missing – and neither are the attributes made from it, so that the exchange’s AML program can tell what is still to be collected and ask for it by another measure (an address check, say, for a Swiss e-ID, which carries no address). The converter never makes up a value.

26.94.4. Exit status#

0

The attributes were written.

5

The input is not one JSON object, it has no evidence.verification_id (it is not the /info of a KyCH session with vocabularies), or its vocabulary is one the converter does not know (the exit status of jq(1); the reason is on standard error). The exchange then reports a failure of the KYC provider.

Adapt a copy of the script for other vocabularies, and name the copy in KYC_OAUTH2_CONVERTER_HELPER.

26.94.5. Configuring the exchange#

Register the exchange as a client of KyCH, in kych.conf(5), and run kych-client-management sync:

[client_exchange]
CLIENT_ID = exchange
CLIENT_SECRET = SECRET
REDIRECT_URI = https://exchange.example.com/kyc-proof/kych
VOCABULARIES = {eupid, eupid-mdoc, npa}
PROFILES = {kyc}

The redirect URI is the exchange’s base URL followed by kyc-proof/ and the name of the provider section without kyc-provider-, and no trailing slash. Then add the provider to the exchange’s configuration, where https://kych.example.com/ is KyCH’s BASE_URL:

[kyc-provider-kych]
LOGIC = oauth2
KYC_OAUTH2_VALIDITY = 365 d
KYC_OAUTH2_AUTHORIZE_URL = "https://kych.example.com/authorize#setup"
KYC_OAUTH2_TOKEN_URL = https://kych.example.com/token
KYC_OAUTH2_INFO_URL = https://kych.example.com/info
KYC_OAUTH2_CLIENT_ID = exchange
KYC_OAUTH2_CLIENT_SECRET = SECRET
KYC_OAUTH2_SCOPE = kyc
KYC_OAUTH2_POST_URL = https://exchange.example.com/kyc-done
KYC_OAUTH2_CONVERTER_HELPER = taler-exchange-kyc-kych-converter

#setup, which has to come right after authorize and inside quotes, makes the exchange call https://kych.example.com/setup/exchange before it sends the person to https://kych.example.com/authorize/NONCE. The person then picks one of the client’s vocabularies on KyCH’s page. A measure can pick it instead, with a setup_body in its CONTEXT, which the exchange sends as the body of /setup:

[kyc-measure-eid-npa]
CHECK_NAME = eid-kych
PROGRAM = identification-check
CONTEXT = {"setup_body": {"vocabulary": "npa"}, "lift_rules": ["withdraw-identification"]}

Exchanges whose oauth2 logic does not know setup_body yet get the same with a second provider section and a second KyCH client that may use the one vocabulary only. The exchange’s source tree has a complete example, contrib/kyc-kych-example.conf: the eID through KyCH, the documents through Beekeeper as the alternative, and an AML program that asks for what the eID did not deliver.

The exchange runs the program itself, so it must be installed on the exchange’s host, on the $PATH of taler-exchange-httpd. The Debian package kych installs it to /usr/bin; on a host without KyCH, copy the script, which is in the public domain.

26.94.6. Examples#

For the input:

{"family_name": "Mustermann", "given_name": "Erika",
 "birthdate": "1964-08-12",
 "place_of_birth": {"country": "DE", "locality": "Berlin"},
 "nationalities": ["DE"],
 "issuing_authority": "DE", "issuing_country": "DE",
 "vocabulary": "eupid",
 "missing": ["address.street_address", "address.postal_code",
             "address.locality", "address.country"],
 "evidence": {"verification_id": "0b6f5c1e-2a7d-4e39-8f10-5d3c9a7b1e24",
              "format": "dc+sd-jwt", "credential_type": "urn:eudi:pid:de:1",
              "level_of_assurance": "high", "...": "..."}}

the program writes:

{
  "FORM_ID": "kych",
  "id": "0b6f5c1e-2a7d-4e39-8f10-5d3c9a7b1e24",
  "IDENTIFICATION_METHOD": "eupid",
  "IDENTIFICATION_LEVEL_OF_ASSURANCE": "high",
  "FULL_NAME": "Erika Mustermann",
  "PERSON_FIRST_NAMES": "Erika",
  "PERSON_LAST_NAME": "Mustermann",
  "DATE_OF_BIRTH": "1964-08-12",
  "PLACE_OF_BIRTH": "Berlin",
  "COUNTRY_OF_BIRTH": "DE",
  "NATIONALITIES": ["DE"],
  "NATIONALITY": "DE",
  "PERSONAL_IDENTIFICATION_DOCUMENT_TYPE": "urn:eudi:pid:de:1",
  "PERSONAL_IDENTIFICATION_DOCUMENT_ISSUER": "DE",
  "PERSONAL_IDENTIFICATION_DOCUMENT_COUNTRY": "DE",
  "IDENTIFICATION_EVIDENCE": {"verification_id": "0b6f5c1e-...", "...": "..."}
}

and no ADDRESS_*: the AML program asks for the address.

26.94.7. See also#

kych.conf(5), kych-client-management(1), kych-oauth2-gateway(1), taler-exchange.conf(5), jq(1)