Verify a W3C VC
Verify a W3C Verifiable Credential with SpruceKit Mobile SDK
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.
// Example View for a VC Verifier
fun VerifyVCView(
navController: NavController
) {
var success by remember {
mutableStateOf<Boolean?>(null)
}
fun onRead(content: String) {
GlobalScope.launch {
try {
verifyJwtVp(jwtVp = content)
success = true
} catch (e: Exception) {
success = false
e.printStackTrace()
}
}
}
fun back() {
navController.navigate(
Screen.HomeScreen.route.replace("{tab}", "verifier")
) {
popUpTo(0)
}
}
if (success == null) {
QRCodeScanner(
title = "Scan QR Code",
subtitle = "Looking",
cancelButtonLabel = "Cancel",
onRead = onRead,
isMatch = "true",
onCancel = onCancel,
fontFamily = Inter,
readerColor = Color.White,
guidesColor = Color.White,
textColor = Color.White,
backgroundOpacity = 0.5f
)
} else {
// Call your Verifier results View here
}
}Verify VCs
Do you know what you are scanning? You can select what you need from the functions below
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.
2. Delegated Verifier
In the delegated flow, the Verifier generates a QR code to advertise the PresentationRequest to the Wallet. That PresentationRequest can be retrieved by the Wallet from the advertised endpoint. That endpoint should be your own backend service. To use the DelegateVerifier, you will need a back-end service that supports 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.
Last updated
Was this helpful?