public static async Task <bool> verifyDoctorProof(string proofJson) { string proofReqJson = getProofRequest(); proofReqJson = proofReqJson.Replace(" ", string.Empty); proofReqJson = proofReqJson.Replace(Environment.NewLine, string.Empty); try { EmergencyDoctorCredentialModel model = EmergencyDoctorCredentialModel.importFromJsonFile(); // IOFacilitator io = new IOFacilitator(); // DoctorCredDefInfoModel model = JsonConvert.DeserializeObject // <DoctorCredDefInfoModel>(File.ReadAllText( // io.getDoctorCredDefConfigPathAbs())); string schemas = "{"; schemas += "\"" + model.schema_id + "\":" + model.schema_json; schemas += "}"; string credDefs = "{"; credDefs += "\"" + model.cred_def_id + "\":" + model.cred_def_json; credDefs += "}"; bool result = await AnonCreds.VerifierVerifyProofAsync(proofReqJson, proofJson, schemas, credDefs, "{}", "{}"); return(result); } catch (Exception e) { Console.WriteLine($"Error: {e.Message}"); return(false); } }
/* * Proofs the holder of the open wallet is a doctor by using the first * credential that meets the docotr proof requirements. */ public static async Task <string> createDoctorProof( Wallet wallet, string masterKey = "doctor-certificate") { string proofReqJson = getProofRequest(); proofReqJson = proofReqJson.Replace(" ", string.Empty); proofReqJson = proofReqJson.Replace(Environment.NewLine, string.Empty); try { var credList = await AnonCreds.ProverSearchCredentialsForProofRequestAsync( wallet, proofReqJson); string attr1Cred = await getCredentialforRequest( credList, "attr1_referent"); string attr2Cred = await getCredentialforRequest( credList, "attr2_referent"); string predicate1Cred = await getCredentialforRequest( credList, "predicate1_referent"); string requestedCreds = proverDoctorRequestCreds( getReferentFromCredential(attr1Cred), getReferentFromCredential(attr2Cred), getReferentFromCredential(predicate1Cred)); EmergencyDoctorCredentialModel model = EmergencyDoctorCredentialModel.importFromJsonFile(); // IOFacilitator io = new IOFacilitator(); // DoctorCredDefInfoModel model = JsonConvert.DeserializeObject // <DoctorCredDefInfoModel>(File.ReadAllText( // io.getDoctorCredDefConfigPathAbs())); string schemas = "{"; schemas += "\"" + model.schema_id + "\":" + model.schema_json; schemas += "}"; string credDefs = "{"; credDefs += "\"" + model.cred_def_id + "\":" + model.cred_def_json; credDefs += "}"; string res = await AnonCreds.ProverCreateProofAsync( wallet, proofReqJson, requestedCreds, masterKey, schemas, credDefs, "{}" ); return(res); } catch (InvalidOperationException e) { return(e.Message); } catch (Exception e) { return($"Error: {e.Message}"); } }