4.1.2. Architecture#

4.1.2.1. Components#

Taler exchange ── oauth2 KYC logic ─┐                         ┌─ swiyu-verifier ............. swiyu
(/setup, /authorize, /token, /info) │                         │
                                    ├──► KyCH ── adapters ────┼─ eudi-verifier ──┐
Beekeeper ── lookup worker ─────────┘    (OAuth 2.0, picker,  │  waltid-verifier ├ one chosen  eupid,
  (beekeeper-kych)                        sessions, evidence, │  kych-oid4vp ────┘             eupid-mdoc
                                          purge)              │        └── kych-trust (lists of trusted entities)
                                                              ├─ kych-eumw-bridge ── governikus-eumw ┐ one chosen  npa
                                                              │  kych-eid ───────────────────────────┘
                                                              └─ kych-eumw-bridge ── eidas-node-connector ..... eidas

The person’s wallet, or AusweisApp, or the browser on its way through the eIDAS network, talks to the helper, never to KyCH. KyCH talks to each helper’s private management interface, and the reverse proxy publishes only the paths the outside world needs.

KyCH’s own components:

kych-oauth2-gateway

The daemon. One PostgreSQL database (schema oauth2gw): clients, sessions, authorization codes, access tokens. One adapter per helper type turns KyCH’s request into the helper’s and the helper’s outcome into KyCH’s claims and evidence. The daemon keeps no state outside the database, so it can be restarted at any time.

kych-client-management, kych-dbinit, kych-dbconfig

Register clients from the configuration (sync), run the sweeper once (purge), create and migrate the database.

taler-exchange-kyc-kych-converter

Run by the exchange: turns /info into GANA attributes.

Its helpers (Features and limitations lists them with their upstreams):

  • OpenID4VP verifiers for the EU PID: eudi-verifier, waltid-verifier, kych-oid4vp; for the Swiss e-ID, swiyu-verifier.

  • kych-trust, the one place where the lists of trusted entities are fetched, verified and kept, so that the three EU PID verifiers take the same trust decisions.

  • eID servers for the German card: the Governikus eIDAS Middleware behind kych-eumw-bridge, or kych-eid.

  • The eIDAS-Node Connector, behind kych-eumw-bridge again.

Every program runs as a system user of its own, under systemd with hardening options (no new privileges, a private /tmp, a read-only view of the system; the helpers also restrict their address families), and keeps its secrets in files readable only by itself and, where needed, by KyCH.

4.1.2.2. Trust boundaries#

     Internet                     │ reverse proxy (TLS)  │ host: local users only
──────────────────────────────────┼──────────────────────┼─────────────────────────────────────
person's browser ─── /authorize, /status, /finalize, /return ──► KyCH        (kych-api socket)
client (exchange) ── /setup, /token, /info ────────────────────► KyCH
wallet ──────────── request object, response ───────────────► OID4VP helper (wallet paths only)
AusweisApp ──────── tcToken, PAOS ───────────────────────────► eID server    (eID paths only)
foreign proxy svc ◄─ browser ─► Connector, bridge ───────────► eIDAS paths only
                                  │                      │   KyCH ──► helpers' management APIs
                                  │                      │   helpers ──► kych-trust
                                  │                      │   helpers ──► KyCH /notification (loopback)
PID providers' lists, status lists ◄──────────────────────── kych-trust, OID4VP helpers (outbound)
BerCA (TR-03129) ◄────────────────────────────────────────── eID server (outbound, mutual TLS)

Four boundaries matter:

  1. The public interface. Everything a browser, a wallet, AusweisApp or a client reaches goes through the reverse proxy, which terminates TLS and forwards a fixed list of paths to Unix sockets. The proxy is the only process that listens on the network.

  2. The management interfaces. The upstream helpers – the EUDI verifier, walt.id, swiyu-verifier, the middleware’s eID paths, the Connector’s Hazelcast – authenticate nobody. Each is held to a Unix socket or to loopback, and the proxy never publishes its management paths. KyCH’s own helpers (kych-oid4vp, kych-eid, kych-eumw-bridge) authenticate KyCH with a bearer secret on top of the socket.

  3. The local host. Socket groups decide which local processes may connect to which socket (Sockets and groups). The eIDAS Connector’s Hazelcast caches have no authentication at all, so the host that runs them must have no untrusted local users.

  4. Trust anchors. What a helper accepts depends on configuration only the administrator controls: the lists of trusted entities and their signers (kych-trust), the eID card’s master and block lists and the authorisation certificate (eID server), the foreign nodes’ metadata signers (Connector), the accepted issuer DIDs (swiyu). Threat model and security analysis analyses what crossing each boundary would give an attacker.

4.1.2.3. Sockets and groups#

KyCH and its helpers talk over Unix domain sockets, and a socket’s group decides who may connect. KyCH’s own socket has a group of its own, kych-api, so that the gateway’s clients are kept away from the helpers’ unauthenticated management APIs, which share the group www-data with the reverse proxy.

Socket

Owner:group, mode

Who connects

/run/kych/kych.sock

kych:kych-api 0660

the reverse proxy (www-data is a member of kych-api); Beekeeper’s lookup worker when beekeeper-kych uses UNIXPATH; a helper whose NOTIFY_URL is http+unix:// (its user joins kych-api)

/run/eudi-verifier/http.sock

group www-data

the proxy (/wallet/ only), KyCH (whole API)

/run/waltid-verifier/http.sock

group www-data, 0770

the proxy (the two wallet paths), KyCH

/run/kych-oid4vp/api.sock

group kych-oid4vp

KyCH (member of kych-oid4vp), with the API secret

/run/kych-oid4vp-wallet.sock

kych-oid4vp:www-data 0660

the proxy (request/, response/)

/run/kych-eid/api.sock

group kych-eid

KyCH (member of kych-eid), with the API secret

/run/kych-eid-public.sock

kych-eid:www-data 0660

the proxy (start/, tctoken/, paos/, refresh/)

/run/kych-eumw-bridge/api.sock

group www-data, 0660

KyCH, with the API secret

/run/kych-eumw-bridge/public.sock

group www-data, 0660

the proxy (/npa/, /eidas/)

/run/kych-trust/kych-trust.sock

group kych-trust, 0660

KyCH and kych-oid4vp; with the EUDI verifier, kych-trust listens on 127.0.0.1:18090 instead (the verifier cannot reach a socket)

/run/eidas-node-connector/http.sock

group www-data

the proxy (/EidasNodeConnector/)

127.0.0.1:8095, :8096

Governikus middleware

the proxy (/eidas-middleware/); the admin interface on 8096 by SSH tunnel only

127.0.0.1:8080

swiyu-verifier (default)

KyCH; or its Unix socket, if configured

127.0.0.1:18444

the proxy’s loopback server

helpers posting their notification to KyCH’s /notification

KyCH runs with kych-api as its primary group (so the socket it creates gets it) and with kych (to read its configuration) and www-data (to reach the helpers) as supplementary groups. A client of KyCH must never be given www-data: it would reach the helpers’ management APIs directly. A process gets a new group only when it starts, so the proxy needs a reload and a worker a restart after adduser.

4.1.2.4. The session state machine#

Everything hangs off one row of oauth2gw.verification_sessions:

  POST /setup           GET /authorize                outcome                   POST /token
─────────────► pending ───────────────► authorized ─────────────► verified ─────────────► completed
                  │      (picker first,      │      (webhook, poll       │                       │
                  │       if no vocabulary   │       or /return)         │                       │
                  │       is fixed)          ├───────► failed            │                       │
                  │                          │   (helper refused,        │                       │
                  │                          │    person cancelled)      │                       │
                  └──────────┬───────────────┘                           │                       │
                             ▼ 15 min after /setup                       ▼ code unused,          ▼ token expires
                          expired                                       10 min                 (1 h); claims
                                                                                                purged earlier
  • POST /setup/CLIENT_ID creates the session (pending) and answers a nonce; a body {"vocabulary": ..., "profile": ...} may fix either.

  • GET /authorize/NONCE records scope, redirect_uri and state, resolves the scope against the profile, and – once the vocabulary is fixed – starts a session at the vocabulary’s helper and pins the helper section on the KyCH session (authorized). Re-entry replays the helper’s stored answer instead of starting a second verification. POST /authorize/NONCE is the picker’s choice.

  • The outcome arrives by one of three paths that share one completion statement, which changes only a session still authorized: the helper’s webhook to /notification (swiyu, and walt.id, kych-oid4vp, kych-eid and the bridge when given a NOTIFY_URL); KyCH asking the helper while the browser polls /status (at most once a second per session, and every ten seconds as a fallback for walt.id and KyCH’s own helpers when they have a webhook; swiyu-verifier is never asked); or the browser coming back to /return/VERIFICATION_ID from a redirect helper. KyCH then fetches the claims and the evidence from the helper, keeps only the requested claims, and mints the authorization code (verified) – or records the reason (failed).

  • GET /finalize/VERIFICATION_ID redirects to the client with the code, or, for a failed or expired session, with error=access_denied.

  • POST /token exchanges the code (single use) for an access token (completed); GET /info, with that bearer token [RFC6750], returns the claims, vocabulary, missing and evidence, and starts the purge grace.

Each multi-step change is one SQL statement, so that two requests racing (the webhook and a poll, two browser tabs) cannot both complete a session. KyCH OAuth2 Gateway RESTful API describes every endpoint.

4.1.2.5. Flows by helper kind#

4.1.2.5.1. OpenID4VP helpers (eupid, eupid-mdoc, swiyu)#

browser          KyCH                  helper (verifier)          wallet
   │ /authorize    │                          │                     │
   │──────────────►│ start: DCQL query,       │                     │
   │               │ trust, registration cert │                     │
   │               │─────────────────────────►│                     │
   │               │◄── request URI, deep link│                     │
   │◄── QR code, deep link                    │                     │
   │ ··· person scans or taps ···························► fetches  │
   │               │                          │◄── signed request ──│
   │               │                          │    (once only)      │
   │               │                          │◄── vp_token ────────│  (direct_post.jwt,
   │               │                          │  checks: signature, │   encrypted to the
   │               │                          │  trust (kych-trust),│   helper)
   │               │                          │  status list, holder│
   │               │                          │  binding            │
   │               │◄── webhook (or poll) ────│                     │
   │ /status ─────►│── outcome? ─────────────►│                     │
   │◄── verified   │◄── claims + evidence ────│                     │
   │ /finalize ───►│                          │                     │
   │◄── 302 redirect_uri?code=...&state=...   │                     │

A wallet on the same device as the browser returns the person to /return/VERIFICATION_ID when the helper hands it KyCH’s BASE_URL (the EUDI verifier and walt.id do, for an https base). The request object is a signed JWT [RFC7519] (JAR, [RFC9101]), signed with the relying party’s access certificate; its client id is the certificate’s hash (HAIP’s x509_hash) or its DNS name, and it carries the registration certificate of the intended use. The wallet’s answer is encrypted to a key of the helper (direct_post.jwt, a JWE [RFC7516]).

4.1.2.5.2. eID server (npa)#

browser        KyCH        kych-eumw-bridge     middleware            AusweisApp + card
   │/authorize   │                │                  │                        │
   │────────────►│ POST /sessions │                  │                        │
   │             │───────────────►│                  │                        │
   │◄── 302 to the bridge's start page               │                        │
   │─────────────────────────────►│ signed SAML      │                        │
   │◄── POST to the middleware ───│ AuthnRequest     │                        │
   │────────────────────────────────────────────────►│ tcToken, PAOS, EAC ───►│ PIN
   │                              │                  │◄── data groups ────────│
   │◄── SAML response (signed, encrypted) ───────────│                        │
   │─────────────────────────────►│ decrypt, verify  │                        │
   │             │◄── notification│                  │                        │
   │◄── 302 /return/ID ───────────│                  │                        │
   │────────────►│ outcome, claims, evidence         │                        │
   │◄── 302 redirect_uri?code=...                    │                        │

With kych-eid the middle two columns are one program and there is no SAML: KyCH sends the browser to kych-eid’s start page, which starts AusweisApp (http://127.0.0.1:24727/eID-Client?tcTokenURL=...); AusweisApp fetches the tcToken and runs the PAOS dialogue with kych-eid, which performs Terminal Authentication with the authorisation certificate, Chip Authentication, Passive Authentication against the master list, the block-list check and the reading of the data groups, then sends the browser to /return. The result never travels through the browser.

4.1.2.5.3. eIDAS (eidas)#

browser        KyCH     kych-eumw-bridge        Connector (DE)         foreign proxy service
   │/authorize   │             │                       │                        │
   │────────────►│ POST /sessions                      │                        │
   │◄── 302 to the bridge: choose the country          │                        │
   │──────────────────────────►│ light request into   │                        │
   │                           │ Hazelcast, light token                         │
   │◄── POST light token to the Connector ─────────────│                        │
   │──────────────────────────────────────────────────►│ signed SAML request    │
   │◄──────────────────────────────────────────────────│───────────────────────►│ person identifies
   │◄── SAML response (signed, encrypted) ─────────────────────────────────────│ with home eID
   │──────────────────────────────────────────────────►│ decrypt, verify        │
   │                           │◄── light response ────│ (metadata trust)       │
   │◄── 302 /return/ID ────────│ check LoA, attributes │                        │
   │────────────►│ outcome, claims, evidence           │                        │

Every XML signature and decryption is the Connector’s; the bridge checks the level of assurance and the attributes and, with KyCH’s patch, receives the signed response and the decrypted assertion for the evidence.

4.1.2.6. The KyCH-native helper API#

KyCH’s own helpers – kych-oid4vp, kych-eid and kych-eumw-bridge – speak one HTTP API, designed so that other helpers could implement it later (KyCH-native Helper RESTful API):

  • GET /config – the protocol version, the kinds (oid4vp, eid-server, eidas-saml) and formats the helper serves, whether it is available (kych-eid says unavailable with an expired terminal certificate or a stale block list).

  • POST /sessions – {kind, vocabulary, request, trust, registration_certificate, return_url, notify_url, expires, reference}, where request is a DCQL query or a list of attributes, each required or optional; the answer names a wallet_url and deeplink or a browser_url.

  • GET /sessions/ID[?wait=SECONDS] – pending, verified, failed or expired, with the claims and the evidence in KyCH’s own shape, or an error {code, kind, hint}; it can long-poll.

  • DELETE /sessions/ID, and the notification POST notify_url {"session_id"}, which carries no personal data: KyCH fetches the outcome itself.

Authentication is a bearer secret on top of a Unix socket or loopback; kych-oid4vp and kych-eid compare it in constant time.

4.1.2.7. How the exchange and Beekeeper use KyCH#

The exchange uses its oauth2 KYC logic: a [kyc-provider-*] section with KyCH’s URLs, the #setup suffix that makes it call /setup first, the scope kyc and the converter taler-exchange-kyc-kych-converter, which turns /info into GANA attributes – names, birth data, NATIONALITIES, the address, the document data, IDENTIFICATION_METHOD, IDENTIFICATION_LEVEL_OF_ASSURANCE, IDENTIFICATION_EVIDENCE and IDENTIFICATION_PERSON_IDENTIFIER. A measure’s CONTEXT.setup_body becomes the body of /setup and so can preselect a vocabulary. The AML program taler-exchange-helper-measure-identification-check then decides whether the identification is complete and of an accepted method and level, and otherwise triggers a fallback measure (documents through Beekeeper). The exchange does not fall back from one provider to another by itself.

Beekeeper has no HTTP client in its web server by design. An eid question in a Beekeeper form makes its lookup worker run the helper beekeeper-kych, which calls /setup and later /token and /info over KyCH’s socket or public URL; the browser goes to KyCH and back to Beekeeper’s return endpoint. The claims fill the question’s answer, the evidence becomes its analysis result, and a mismatch with the names or dates a company stated sends the case to a reviewer. This is how every natural person of a KYB case – representatives, beneficial owners – identifies by eID on their own device, with a documents fallback and a recorded reason when that fails.

The exchange and Beekeeper gives the configuration of both.