Skip to content
Draft
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion multipaz-compose/golden-screenshots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ using Robolectric Native Graphics) alongside the native iOS SwiftUI
- [Movie Ticket Verification (SD-JWT VC)](#movie_ticket_sdjwt)
- [Unverified Proximity Reader Requesting Non-PII (Signed Certificate Not in Trust List)](#unverified_proximity_reader_age_over_21)
- [Anonymous Proximity Reader Requesting Non-PII (No Reader Certificate)](#anonymous_proximity_reader_age_over_21)
- **[2. Transactions — Built-In & Custom Transaction Renderers](#02_transactions)** (`02_transactions` — 4 scenarios)
- **[2. Transactions — Built-In & Custom Transaction Renderers](#02_transactions)** (`02_transactions` — 5 scenarios)
- [Payment Transaction with Card Claims & Card Switcher](#payment_with_claims)
- [Payment Confirmation Only (Zero Attribute Claims)](#payment_confirmation_only)
- [Transit Fare Selection (Custom Interactive Transaction Renderer)](#transit_fare_custom_renderer)
- [AP2 Payment Mandate Delegation (Summary + Signed Mandate Details)](#ap2_payment_delegate)
- [AP2 Delegation (SDK Default Renderer for DelegateTransaction)](#ap2_delegate_default_renderer)
- **[3. Multi-Credential & Optional Combinations](#03_multi_credential)** (`03_multi_credential` — 6 scenarios)
- [Compound Solution: ID + Boarding Pass in a Single Use-Case](#mdl_and_boarding_pass_single_use_case)
- [Alternative Credential Types: mDL OR Boarding Pass](#mdl_or_boarding_pass)
Expand Down Expand Up @@ -310,6 +311,20 @@ Delegating payment authority via an Agent Payments Protocol (AP2) intent mandate
| **Compose** | <img src="02_transactions/ap2_payment_delegate__main.png" alt="Compose: AP2 Payment Mandate Delegation (Summary + Signed Mandate Details) - Main AP2 delegate mandate prompt" width="260" /> | <img src="02_transactions/ap2_payment_delegate__tx_details.png" alt="Compose: AP2 Payment Mandate Delegation (Summary + Signed Mandate Details) - AP2 mandate transaction details page" width="260" /> |
| **SwiftUI** | <img src="../../multipaz-swiftui/golden-screenshots/02_transactions/ap2_payment_delegate__main.png" alt="SwiftUI: AP2 Payment Mandate Delegation (Summary + Signed Mandate Details) - Main AP2 delegate mandate prompt" width="260" /> | <img src="../../multipaz-swiftui/golden-screenshots/02_transactions/ap2_payment_delegate__tx_details.png" alt="SwiftUI: AP2 Payment Mandate Delegation (Summary + Signed Mandate Details) - AP2 mandate transaction details page" width="260" /> |

<a id="ap2_delegate_default_renderer"></a>

### `ap2_delegate_default_renderer` — AP2 Delegation (SDK Default Renderer for DelegateTransaction)

- **Relying Party:** Utopia Marketplace — Over-the-Internet (OpenID4VP)
- **Protocol / Credentials:** DigitalPaymentCredentialSdJwt + DelegateTransaction
- **Risk Assessment:** `NORMAL`

An AP2 `delegate` request, with the mandates as AP2 sends them, drawn by the SDK's DelegateTransactionRendererCompose. The summary sets the per-purchase and total limits large, then gives the merchant, the item, the expiry and the agent a row each. The details page lists both mandates in full, as they will be signed.

| `main` — Main spending permission prompt | `tx_details` — Spending permission details page |
| :---: | :---: |
| <img src="02_transactions/ap2_delegate_default_renderer__main.png" alt="Compose: AP2 Delegation (SDK Default Renderer for DelegateTransaction) - Main spending permission prompt" width="260" /> | <img src="02_transactions/ap2_delegate_default_renderer__tx_details.png" alt="Compose: AP2 Delegation (SDK Default Renderer for DelegateTransaction) - Spending permission details page" width="260" /> |

---

<a id="03_multi_credential"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import org.multipaz.request.OpenID4VPRequesterIdentity
import org.multipaz.request.Requester
import org.multipaz.request.TrustedRequesterIdentity
import org.multipaz.sdjwt.SdJwt
import org.multipaz.sdjwt.credential.KeyBoundSdJwtVcCredential
import org.multipaz.sdjwt.credential.KeylessSdJwtVcCredential
import org.multipaz.securearea.CreateKeySettings
import org.multipaz.securearea.SecureArea
Expand All @@ -115,10 +116,14 @@ import org.multipaz.storage.StorageTable
import org.multipaz.storage.StorageTableSpec
import org.multipaz.storage.ephemeral.EphemeralStorage
import org.multipaz.trustmanagement.TrustMetadata
import org.multipaz.util.toBase64Url
import org.multipaz.utopia.knowntypes.DelegateTransaction
import org.multipaz.utopia.knowntypes.DigitalPaymentCredential
import org.multipaz.utopia.knowntypes.DigitalPaymentCredentialSdJwt
import org.multipaz.utopia.knowntypes.Loyalty
import org.multipaz.utopia.knowntypes.UtopiaBoardingPass
import org.multipaz.utopia.knowntypes.UtopiaMovieTicket
import org.multipaz.utopia.knowntypes.addDelegateTransactionType
import org.robolectric.Shadows
import kotlin.math.abs
import kotlin.math.round
Expand Down Expand Up @@ -702,10 +707,13 @@ internal class ConsentGoldenEcosystem private constructor(
addDocumentType(paymentDocType)
addDocumentType(boardingPassDocType)
addDocumentType(avDocType)
addDocumentType(DigitalPaymentCredentialSdJwt.getDocumentType())
addDelegateTransactionType()
}
val transactionDataRendererRepository = TransactionDataRendererRepository().apply {
addRenderer(GoldenTransitFareTransaction.identifier, goldenTransitFareRenderer)
addRenderer(GoldenAp2MandateTransaction.identifier, goldenAp2MandateRenderer)
addRenderer(DelegateTransaction.identifier, DelegateTransactionRendererCompose)
}

val storage = DeterministicStorage()
Expand Down Expand Up @@ -1259,6 +1267,21 @@ internal class ConsentGoldenEcosystem private constructor(
keylessSdJwtVcDomain = "sdjwt",
)

// 11. Utopia Bank card as a key-bound SD-JWT VC, which can sign an AP2 delegation. Created
// last so the documents above, and what they draw from the random source, stay as they were.
val paymentSdJwtDoc = documentStore.createDocument(
displayName = "Utopia Bank Debit",
typeDisplayName = "Payment Card (**** 1234)",
cardArt = readResourceBytes("/cards/card_utopia_payment.png"),
)
createPaymentSdJwt(
document = paymentSdJwtDoc,
secureArea = secureArea,
createKeySettings = keySettings,
dsKey = dsKey,
randomProvider = rng,
)

return ConsentGoldenEcosystem(
locale = locale,
documentTypeRepository = documentTypeRepository,
Expand Down Expand Up @@ -1334,6 +1357,42 @@ internal class ConsentGoldenEcosystem private constructor(
return credential
}

private suspend fun createPaymentSdJwt(
document: Document,
secureArea: SecureArea,
createKeySettings: CreateKeySettings,
dsKey: AsymmetricKey.X509Certified,
randomProvider: Random,
): KeyBoundSdJwtVcCredential {
val credential = KeyBoundSdJwtVcCredential.create(
document = document,
asReplacementForIdentifier = null,
domain = "sdjwt",
secureArea = secureArea,
vct = DigitalPaymentCredentialSdJwt.CARD_VCT,
createKeySettings = createKeySettings,
)
val sdJwt = SdJwt.create(
issuerKey = dsKey,
kbKey = secureArea.getKeyInfo(credential.alias).publicKey,
claims = buildJsonObject {
put("credential_id", JsonPrimitive("UT-DPC-1234"))
put("network", JsonPrimitive("multipaz"))
put("last_four", JsonPrimitive("1234"))
},
nonSdClaims = buildJsonObject {
put("iss", "https://bank.utopia.example.com")
put("vct", DigitalPaymentCredentialSdJwt.CARD_VCT)
put("iat", VALID_FROM.epochSeconds)
put("nbf", VALID_FROM.epochSeconds)
put("exp", VALID_UNTIL.epochSeconds)
},
random = randomProvider,
)
credential.certify(sdJwt.compactSerialization.encodeToByteString())
return credential
}

private suspend fun createPaymentMdoc(
document: Document,
secureArea: SecureArea,
Expand Down Expand Up @@ -1556,6 +1615,27 @@ internal fun <PayloadT : Any> goldenTransactionData(
rawBytes = ByteString("${type.identifier}:$payload".encodeToByteArray()),
)

/**
* An AP2 `delegate` item as AP2 sends it: the mandates in `delegate_payload`, for an agent to
* buy headphones from one merchant within a per-purchase and a total limit, for 30 days.
*/
internal fun goldenDelegateTransactionData(): TransactionData<*> {
val exp = (ConsentGoldenEcosystem.NOW + 30.days).epochSeconds
val agent = """{"jwk":{"kty":"EC","crv":"P-256","x":"Fo9yTRgc4kXAdKpCV2mQe8Lw3sZ1HbuN6r0iJt7aPyE","y":"y"}}"""
val merchant = """{"id":"market.utopia.example.com","name":"Utopia Market","website":"https://market.utopia.example.com"}"""
val json = """{"type":"delegate","credential_ids":["payment_card"],"format":"dc+sd-jwt",
"transaction_data_hashes_alg":["sha-256"],"delegate_payload":[
{"vct":"mandate.checkout.open.1","exp":$exp,"cnf":$agent,"constraints":[
{"type":"checkout.allowed_merchants","allowed":[$merchant]},
{"type":"checkout.line_items","items":[{"id":"r1","quantity":1,
"acceptable_items":[{"id":"aurora","title":"Aurora headphones"}]}]}]},
{"vct":"mandate.payment.open.1","exp":$exp,"cnf":$agent,"constraints":[
{"type":"payment.amount_range","currency":"USD","max":25000},
{"type":"payment.budget","currency":"USD","max":400.00},
{"type":"payment.allowed_payees","allowed":[$merchant]}]}]}"""
return DelegateTransaction.parseJson(json.encodeToByteArray().toBase64Url().encodeToByteString())
}

internal fun utopiaPaymentTransactionData(
payeeName: String,
amount: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import org.multipaz.request.MdocRequestedClaim
import org.multipaz.request.Requester
import org.multipaz.request.TrustedRequesterIdentity
import org.multipaz.utopia.knowntypes.DigitalPaymentCredential
import org.multipaz.utopia.knowntypes.DigitalPaymentCredentialSdJwt
import org.multipaz.utopia.knowntypes.Loyalty
import org.multipaz.utopia.knowntypes.UtopiaBoardingPass
import org.multipaz.utopia.knowntypes.UtopiaMovieTicket
Expand Down Expand Up @@ -775,6 +776,48 @@ class ConsentGoldenScreenshotTest {
}
}

// 2.5 ap2_delegate_default_renderer
run {
val (req, trusted) = eco.trustedWebRequester(
rpId = ConsentGoldenEcosystem.RP_MARKETPLACE,
origin = "https://agent.utopiamarket.example.com",
)
val pd = eco.executeDcql(
dcqlJson = """
{
"credentials": [
{
"id": "payment_card",
"format": "dc+sd-jwt",
"meta": { "vct_values": ["${DigitalPaymentCredentialSdJwt.CARD_VCT}"] },
"claims": [ { "path": ["last_four"] } ]
}
]
}
""".trimIndent(),
transactionDataMap = mapOf("payment_card" to listOf(goldenDelegateTransactionData())),
)
runScenario(
categoryDir = cat2Dir,
categoryTitle = cat2Title,
categoryDescription = cat2Desc,
scenarioId = "ap2_delegate_default_renderer",
title = "AP2 Delegation (SDK Default Renderer for DelegateTransaction)",
requesterSummary = "Utopia Marketplace — Over-the-Internet (OpenID4VP)",
protocolSummary = "DigitalPaymentCredentialSdJwt + DelegateTransaction",
riskBadge = "NORMAL",
description = "An AP2 `delegate` request, with the mandates as AP2 sends them, drawn by the SDK's DelegateTransactionRendererCompose. The summary sets the per-purchase and total limits large, then gives the merchant, the item, the expiry and the agent a row each. The details page lists both mandates in full, as they will be signed.",
requester = req,
trustedRequesterIdentity = trusted,
presentmentData = pd,
) {
capture("main", "Main spending permission prompt")
// The first "View details" is the claims'; the second is the spending permission's.
clickViewDetails(index = 1)
capture("tx_details", "Spending permission details page")
}
}

// =========================================================================================
// Category 3: 03_multi_credential
// =========================================================================================
Expand Down
Loading
Loading