Skip to content

Remove the parseJson() overrides that repeat the base TransactionType.parseJson() #2216

Open

Description

@TheBlackBit

Once #2186 merges, TransactionType.parseJson() reads transaction_data_hashes_alg itself, using the payload from parseOpenId4VpRequest() and then parseJoseHashAlgorithms(). Three overrides do the same thing and can go:

  • PaymentTransaction.parseJson() in multipaz-doctypes
  • PingTransaction.parseJson() in multipaz-utopia
  • the test transaction type in DigitalCredentialsPresentmentTest in multipaz

Each already implements parseOpenId4VpRequest(), so the base function should give the same result.

Notes

  • Removing the override in DigitalCredentialsPresentmentTest also runs the base parseJson() through the existing presentment tests, which already ask for sha-384 and check the response. The tests added in Keep the verifier's hash algorithms for every transaction type. #2186 stop at TransactionData.hashAlgorithms.
  • The JsonData classes probably have to keep their transactionDataHashesAlg field, because their jsonFormat may not ignore unknown keys. Check this when removing the overrides.

Raised in review of #2186. Not part of that PR, to keep it to one change.

Activity

  1. self-assigned this
    on Nov 19, 2026
  2. moved this from Inbox to In Progress in Multipaz Iterationson Nov 19, 2026
  3. dzuluaga commented on Nov 19, 2026

    @dzuluaga
    Contributor

    A suggestion for this follow-up, from the DX review of #2186.

    With #2186, a new type writes nothing to have transaction_data_hashes_alg honoured. On the way out, though, every type still writes the whole OpenID4VP envelope by hand in serializeOpenId4VpRequest(): type, credential_ids and transaction_data_hashes_alg. Nothing in the KDoc says so, and the library's half isn't documented either: addTransactionType() leads to parseJson() being called for each item, and the developer never sees it.

    A type that leaves out transaction_data_hashes_alg silently drops the verifier's choice. The wallet answers with SHA-256, and verifyMdocResponse() accepts whichever algorithm the response names. The envelope is also parsed three times per item: in parseJsonTransactions(), in the base parseJson() and in parseOpenId4VpRequest().

    While removing the overrides, could the base class own the envelope both ways, so a type only maps its payload?

    override fun serializeOpenId4VpPayload(payload: String): JsonObject = buildJsonObject { put("note", payload) }
    override fun parseOpenId4VpPayload(json: JsonObject): String = json.getValue("note").jsonPrimitive.content

    That takes the NoteTransaction in TransactionTypeParseJsonTest from about 19 lines to about 8, and it can be added next to the existing functions without breaking them. It could also add the check that the response's algorithm is one the verifier requested. This is a trace; I didn't run it.

  4. moved this from In Progress to Backlog in Multipaz Iterationson Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions