Present a W3C VC
Present a Credential with OID4VP
To present a Credential, you will need to retrieve the correct credential from storage, and obtain permission from the user to share said credential, before relaying any information to a verifier. That is where the PermissionRequest and PermissionResponse come in.
The PermissionRequest is the structure that you use to interface with the user to obtain permission for the sharing of one or more credentials. Here, the user would also choose which credential to share if there is more than one appropriate credential present in the wallet. The PermissonResponse represents the outcome of that interaction, and holds the vp_token, which contains the verifiable presentation.
1. Create a PermissionRequest
// Create a PermissionRequest
fun CreatepermissionRequest(
url: String,
credentialPacksViewModel: CredentialPacksViewModel,
walletActivityLogsViewModel: WalletActivityLogsViewModel
) {
val credentialPacks = credentialPacksViewModel.credentialPacks
val credentials = mutableListOf<ParsedCredential>()
credentialPacks.value.forEach { credentialPack ->
credentials.addAll(credentialPack.list())
val signer = Signer("keyID")
holder = Holder.newWithCredentials(
credentials,
trustedDids,
signer,
getVCPlaygroundOID4VCIContext(ctx)
)
val PermissionRequest = holder!!.authorizationRequest(url)
}
2. The user selects the credential (and data fields)
Once you have a PermissionRequest, you can implement a CredentialSelector and a DataFieldSelector. The CredentialSelector should let the user pick which of their credentials to present. A DataFieldSelector can select/unselect which attributes within a credential should be shared or not.
3. Create a PermissionResponse
// Create a PermissionResponse
fun CreatePermissionResponse(holder: Holder, permissionRequest: PermissionRequest, selectedCredentials: [PresentableCredential], selectedFields:[[String]] ){
val permissionResponse = permissionRequest!!.createPermissionResponse(
selectedCredentials, selectedFields,
)
// And finally submit
holder!!.submitPermissionResponse(permissionResponse!!)
}
Last updated
Was this helpful?