Skip to content

[WAL-1344] feat(mdoc): add shared proximity protocol engine - #2155

Open
szijpeter wants to merge 12 commits into
mainfrom
feature/wal-1344-mdoc-proximity-engine
Open

[WAL-1344] feat(mdoc): add shared proximity protocol engine#2155
szijpeter wants to merge 12 commits into
mainfrom
feature/wal-1344-mdoc-proximity-engine

Conversation

@szijpeter

@szijpeter szijpeter commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

This adds the radio-independent Kotlin Multiplatform protocol foundation for ISO mdoc proximity presentation, covering the shared models, session engine, matching, authentication, trust seams, and response construction defined by WAL-1344.

The WAL-1344 commits are based directly on current main, including the holder-key foundation merged through walt-id/waltid-identity#2154. This PR is the root of the remaining WAL-1335 stack; each child targets its immediate predecessor. Proximity QR rendering is owned later by demo PR #2160, with no independent WAL-1376 dependency.

Architecture contract: walt-id/waltid-architecture#60.

What Changed

Protocol models

  • Completes DeviceEngagement, retrieval-method, session-message, status/termination, extended-request, encrypted-response, ZKP, and edition-2 use-case structures.
  • Preserves tagged embedded CBOR and RFU/extension fields at the structures where exact bytes are security-relevant.
  • Corrects typed mDL age identifiers and CBOR representations, including native Boolean age attestations and binary biometric templates with base64url text round-trips.
  • Represents device authentication as a sealed Signature/Mac hierarchy, so both-or-neither combinations cannot be constructed.
  • Tightens DeviceRequest and DeviceResponse invariants, version handling, and document-authentication boundaries.
  • Keeps 2021 and edition-2/DIS interoperability profiles explicit, deriving DeviceEngagement 1.0/1.1 from the capability fields selected for the session rather than from the profile label alone.

Shared holder engine

  • Adds cipher-suite 1 ECDH/XDH, HKDF-SHA-256, directional AES-GCM counters, replay rejection, limits, timeouts, repeated exchanges, and deterministic cleanup.
  • Publishes truthful engagement, connection, repeated-request, and termination phases instead of requiring higher layers to infer them.
  • Adds deterministic multi-document matching, alternatives, issuer constraints, wallet-retained presentation choices, use cases, response-size enforcement, selective disclosure, device signature/MAC, and HPKE document-response encryption.
  • Resolves requested age_over_NN statements to the nearest sufficient attestation and omits disclosure when the credential cannot prove the requested result.
  • Separates reader-signature validity from trust/path/revocation policy, preserving whole-request and per-document reader-authentication context with ReaderAuthAll, RICAL, and ZKP provider seams.
  • Enforces Android certificate constraints in the shared trust path instead of accepting platform-parser output as sufficient validation.
  • Carries wallet-validated, display-safe application-profile authorization details, eligible credential choices, and an opaque result-binding digest through preview, consent, and submission without interpreting ecosystem-specific extensions.
  • Produces the exact encoded device-key bytes once for both Device Engagement and transport configuration.

Transport and test boundaries

  • Defines a small opaque-message transport SPI plus fake/loopback implementations; Android and Apple radio APIs do not enter the protocol module.
  • Exercises the common engine on JVM and JS, including signed and MAC exchanges, malformed CBOR, replay, stale consent, oversize input, trust failures, cancellation, observable phase order, and resource cleanup.
  • Covers production response construction across QR, NFC static-handover, and NFC negotiated-handover transcripts for both DeviceSignature and DeviceMAC, with independent authentication verification.

Architecture Notes

  • Parsing, cryptography, credential selection, consent binding, trust evidence, and disclosure stay in common KMP code. Platform work is limited to radio/lifecycle adapters.
  • Exact request, transcript, and response bytes are immutable at trust and consent boundaries.
  • Transport support and protocol features are represented as explicit implemented/profile/runtime/session capabilities; unsupported key specifications fail closed.
  • The module uses focused walt-owned interfaces and existing crypto/CBOR building blocks rather than importing a full proximity stack.

Caveats and Follow-Ups

Breaking

  • DeviceAuth is a sealed Signature/Mac hierarchy; callers construct and pattern-match one variant instead of nullable signature/MAC fields.
  • DeviceResponse document collections use non-empty List values when present.
  • Legacy waltid-crypto mdoc device-authentication overloads are removed; the shared path uses crypto2 keys and explicit algorithm policy.

@szijpeter szijpeter added the ci:mobile Run mobile related CI workflows for this PR label Aug 27, 2026
@linear-code

linear-code Bot commented Aug 27, 2026

Copy link
Copy Markdown

WAL-1344

@szijpeter szijpeter self-assigned this Aug 27, 2026
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: c1e5f66b-a1d5-41eb-8464-90521ef038a3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@szijpeter
szijpeter changed the base branch from feature/wal-1335-proximity-presentation to feature/wal-1343-bind-mdoc-holder-keys August 27, 2026 06:32
@szijpeter szijpeter changed the title feat(mdoc): add shared proximity protocol engine [WAL-1344] feat(mdoc): add shared proximity protocol engine Aug 27, 2026
@szijpeter
szijpeter marked this pull request as ready for review August 27, 2026 09:01
@szijpeter
szijpeter force-pushed the feature/wal-1344-mdoc-proximity-engine branch from ded9b59 to 87d3d89 Compare August 27, 2026 10:43
@szijpeter
szijpeter force-pushed the feature/wal-1343-bind-mdoc-holder-keys branch from a5ed417 to c401aee Compare August 27, 2026 14:42
@szijpeter
szijpeter force-pushed the feature/wal-1344-mdoc-proximity-engine branch from 87d3d89 to 7a5eb5d Compare August 27, 2026 14:42
@szijpeter
szijpeter force-pushed the feature/wal-1344-mdoc-proximity-engine branch 3 times, most recently from 37308f0 to 87069a1 Compare August 28, 2026 15:01
@szijpeter
szijpeter force-pushed the feature/wal-1343-bind-mdoc-holder-keys branch from 91e307e to 4607867 Compare August 28, 2026 15:01
@szijpeter
szijpeter force-pushed the feature/wal-1344-mdoc-proximity-engine branch 2 times, most recently from 334b97e to 1ba6463 Compare August 28, 2026 18:23
Base automatically changed from feature/wal-1343-bind-mdoc-holder-keys to main August 31, 2026 09:55
@szijpeter
szijpeter force-pushed the feature/wal-1344-mdoc-proximity-engine branch 3 times, most recently from 336775a to 9a70398 Compare September 2, 2026 08:54
@szijpeter
szijpeter changed the base branch from main to feature/mobile-credential-image-viewer September 2, 2026 08:55
@szijpeter
szijpeter force-pushed the feature/mobile-credential-image-viewer branch 2 times, most recently from 7b41283 to 58c14ff Compare September 2, 2026 13:16
@szijpeter
szijpeter force-pushed the feature/wal-1344-mdoc-proximity-engine branch from 9a70398 to 11ca286 Compare September 2, 2026 14:58
@szijpeter
szijpeter force-pushed the feature/mobile-credential-image-viewer branch from 58c14ff to a3981ac Compare September 2, 2026 19:25
@szijpeter
szijpeter force-pushed the feature/wal-1344-mdoc-proximity-engine branch 2 times, most recently from 8d2c611 to 1575eca Compare September 3, 2026 14:12
@szijpeter
szijpeter changed the base branch from feature/mobile-credential-image-viewer to main September 3, 2026 14:13
@szijpeter
szijpeter force-pushed the feature/wal-1344-mdoc-proximity-engine branch from 1575eca to 1aa432d Compare September 4, 2026 12:04
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:mobile Run mobile related CI workflows for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant