verifyVP function

Future<bool> verifyVP(
  1. String encodedVP,
  2. String challenge
)

Implementation

Future<bool> verifyVP(
  String encodedVP,
  String challenge,
) async {
  try {
    String jsonStringVP = utf8.decode(base64Url.decode(encodedVP));
    Map<String, dynamic> vp = json.decode(jsonStringVP);

    if (vp["proofOptions"]["challenge"] != challenge) {
      return false;
    }

    InfraSS58DIDResolver resolver =
        InfraSS58DIDResolver("wss://did.stage.infrablockspace.net");
    bool isVerified =
        await InfraSS58VerifiablePresentation().verifyVp(vp, resolver);

    return isVerified;
  } catch (e) {
    print(e);
    return false;
  }
}