Verify a W3C VC

Verify a W3C Verifiable Credential with SpruceKit Mobile SDK

circle-info

This guide is for iOS applications. Building for Android? Look here: Verify a W3C VC

1. Verify an embedded credential

In this flow, the Verifier will scan a QR-code presented by the Wallet. The QR-Code will directly contain the verifiable presentation encoded as a JWT. As such, the Verifier has to engage the QRCodeScanner component.


import SwiftUI
import SpruceIDMobileSdkRs

// Here is an example View to scan and try verify a W3C VC JWT VP
struct VerifyVCView: View {
    
    @State var success: Bool?
    
    @Binding var path: NavigationPath
    
    var body: some View {
        if success == nil {
            // Engage the SpruceKit Mobile SDK ScanningComponent
            QRCodeScanner(
                        title: "Scan QR Code",
                        subtitle: "Looking...",
                        onRead: onRead: { code in
                        Task {
                            do {
                                try await verifyJwtVp(jwtVp: code)
                                success = true
                            } catch {
                                success = false
                                print(error)
                            }
                        }
                    },
                        onCancel: onCancel,
                        // example font values
                        titleFont: .customFont(font: .inter, style: .bold, size: .h0),
                        subtitleFont: .customFont(font: .inter, style: .bold, size: .h4),
                        cancelButtonFont: .customFont(font: .inter, style: .medium, size: .h3),
                        readerColor: .white
                    )
            )
        } else {
            // Plug in your Verifier results view
        }
        
    }
}

Verify VCs

Do you know what kind of credential format you are verifying?

The steps as explained above allow you to execute a verification offline by scanning a credential embedded in the QR code. You can also verify online with OID4VP, using the DelegatedVerifer component. The DelegatedVerifier allows your Mobile App Verifier to rely on your own web service to handle a PresentationRequest, and receive and validate the response. The Mobile App will then only receive an outcome back from your web service.

2. Delegated Verifier

In the delegated flow, the Verifier generates a QR-code to advertise the PresentationRequest to the Wallet. To use the DelegateVerifier, you will need a back end service that executes the OID4VP transaction. From your mobile application, you will only advertise the request and poll the status. To manage the UI during the verification, you will have to manage the DelegatedVerifierStatus. You can monitor that state, like in the example below, and manage your UI based on the state.

circle-info

To implement your OID4VP Server, take a look at our open source OID4VP libraryarrow-up-right

Last updated

Was this helpful?