SpruceKit
SpruceID
  • 🌲SpruceKit Introduction
    • Decentralized Identity Overview
    • Glossary
  • ⚡Quickstart
  • SpruceKit Mobile
    • SpruceKit Showcase App
      • Installation
      • Getting Started
      • Issue a Showcase Credential
      • Present a Showcase Credential
    • SpruceKit Mobile SDK
      • Introduction
      • Core Components
        • StorageManager
        • KeyManager
        • CredentialPack
        • Card
        • IsoMdlPresentation
        • mDocReader/IsomDLReader
        • Document Scanner
      • SpruceKit iOS SDK
        • Installation
        • Build a Wallet
          • Accept a W3C VC
          • Present a W3C VC
          • Present mDL in-person/offline
          • Present an mDL over the internet
        • Build a Verifier
          • Verify a W3C VC
          • Verify an mDL in-person/offline
          • Verify an mDL over the internet
      • SpruceKit Android SDK
        • Installation
        • Build a Wallet
          • Accept a W3C VC
          • Present a W3C VC
          • Present an mDL in-person/offline
          • Present an mDL over the internet
        • Build a Verifier
          • Verify a W3C VC
          • Verify an mDL in-person/offline
          • Verify an mDL over the internet
  • Verifiable Digital Credentials
    • ⚙️DIDKit
      • Installation
      • Core Concepts
      • DID Methods
      • Runtime Configuration
      • Specifications and Dependencies
      • Quickstart
      • DIDKit Packages
        • Command Line Interface
        • HTTP Server
        • Rust Crate
        • C Interface
        • Java and Android
        • Python
        • Javascript
      • DIDKit Examples
        • Core Functions (CLI)
        • Core Functions (HTTP)
        • did-web in minutes
        • Batch Generation & Verification
    • 🪪ISO mDL
      • Quickstart
      • Core Concepts
      • User Guide
  • Schema Definition Language
    • 🔗TreeLDR
      • TreeLDR Quickstart
        • First Schema
        • Compilation into JSON Schema
        • Compilation into JSON-LD Context
        • Writing a Layout
        • Simple Rust Integration
      • Types
        • Literal Types
      • Layouts
        • Primitive Layouts
        • Literal Layouts
        • Enumeration
        • Array Layout
        • References
      • Compiling
        • Schema Definition Formats
          • JSON Schema
          • JSON-LD Context
          • Resource Description Framework (RDF)
        • Programming Languages
          • Compiling to Rust
      • RDF Vocabulary
      • 💡TreeLDR Basics
        • Types and Layouts
        • Properties
        • Syntax
  • Witness for Credential Claims
    • 🔭Rebase
      • Core Library
      • Rust Client/Witness SDK
      • WASM Client SDK
      • Simple "Basic Post" Schema
      • DNS Witness Flow Schema
  • References
    • Contributing
    • Code of Conduct
Powered by GitBook
On this page
  • 1. Create a PermissionRequest
  • 2. The user selects the credential (and data fields)
  • 3. Create a PermissionResponse

Was this helpful?

  1. SpruceKit Mobile
  2. SpruceKit Mobile SDK
  3. SpruceKit Android SDK
  4. Build a Wallet

Present a W3C VC

Present a Credential with OID4VP

PreviousAccept a W3C VCNextPresent an mDL in-person/offline

Last updated 3 months ago

Was this helpful?

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 and 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)
}

Here is an example value, pulled from VC Playground, of the url scanned in an oid4vp QR code. This one in particular is for a VCDM 1.1 Driver's License credential with the veresexchanger verifier.

openid4vp://authorize?client_id=https%3A%2F%2Fqa.veresexchanger.dev%2Fexchangers%2Fz19vRLNoFaBKDeDaMzRjUj8hi%2Fexchanges%2Fz19jRTd4zJFwDJ9hph9A4Ujv7%2Fopenid%2Fclient%2Fauthorization%2Fresponse&request_uri=https%3A%2F%2Fqa.veresexchanger.dev%2Fexchangers%2Fz19vRLNoFaBKDeDaMzRjUj8hi%2Fexchanges%2Fz19jRTd4zJFwDJ9hph9A4Ujv7%2Fopenid%2Fclient%2Fauthorization%2Frequest

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!!) 
}

How you implement your Selector code determines the UX in your mobile application. We give an example of what that could look like in our .

PermissionRequest
PermissionResponse
example application