public async Task TestProverCreateProofWorksForUsingNotSatisfyClaim() { await InitCommonWallet(); var claimsJson = await AnonCreds.ProverGetClaimsAsync(commonWallet, "{}"); var claims = JArray.Parse(claimsJson); var claimUuid = claims[0].Value <string>("claim_uuid"); var proofRequest = "{\"nonce\":\"123432421212\",\n" + " \"name\":\"proof_req_1\",\n" + " \"version\":\"0.1\",\n" + " \"requested_attrs\":{\"attr1_uuid\":{\"schema_seq_no\":1, \"name\":\"some_attr\"}},\n" + " \"requested_predicates\":{}\n" + " }"; var requestedClaimsJson = string.Format("{{\"self_attested_attributes\":{{}},\n" + " \"requested_attrs\":{{\"attr1_uuid\":[\"{0}\", true]}},\n" + " \"requested_predicates\":{{}}\n" + " }}", claimUuid); var schemasJson = string.Format("{{\"{0}\":{1}}}", claimUuid, schema); var claimDefsJson = string.Format("{{\"{0}\":{1}}}", claimUuid, claimDef); var revocRegsJson = "{}"; var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() => AnonCreds.ProverCreateProofAsync(commonWallet, proofRequest, requestedClaimsJson, schemasJson, masterSecretName, claimDefsJson, revocRegsJson) ); }
public async Task TestProverGetClaimsForProofRequestWorksForInvalidPredicateType() { await InitCommonWallet(); var filter = string.Format("{{\"schema_seq_no\":\"{0}\"}}", 1); var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() => AnonCreds.ProverGetClaimsAsync(commonWallet, filter) ); }
public async Task TestProverGetClaimsWorksForEmptyFilter() { await InitCommonWallet(); var claims = await AnonCreds.ProverGetClaimsAsync(commonWallet, "{}"); var claimsArray = JArray.Parse(claims); Assert.AreEqual(1, claimsArray.Count); }
public async Task TestExerciseCustomWallet() { StorageUtils.CleanupStorage(); var walletName = "exerciseWalletTypeWorks"; await Wallet.CreateWalletAsync("default", walletName, "inmem", null, null); var wallet = await Wallet.OpenWalletAsync(walletName, null, null); Assert.IsNotNull(wallet); var schema = "{\"seqNo\":1,\"data\": {\"name\":\"gvt\",\"version\":\"1.0\",\"keys\":[\"age\",\"sex\",\"height\",\"name\"]}}"; var claimDef = await AnonCreds.IssuerCreateAndStoreClaimDefAsync(wallet, DID1, schema, null, false); var claimOfferTemplate = "{{\"issuer_did\":\"{0}\",\"schema_seq_no\":{1}}}"; await AnonCreds.ProverStoreClaimOfferAsync(wallet, string.Format(claimOfferTemplate, DID1, 1)); await AnonCreds.ProverStoreClaimOfferAsync(wallet, string.Format(claimOfferTemplate, DID1, 2)); var issuerDid2 = "CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW"; await AnonCreds.ProverStoreClaimOfferAsync(wallet, string.Format(claimOfferTemplate, issuerDid2, 2)); string masterSecretName = "master_secret_name"; await AnonCreds.ProverCreateMasterSecretAsync(wallet, masterSecretName); var claimOffer = string.Format("{{\"issuer_did\":\"{0}\",\"schema_seq_no\":{1}}}", DID1, 1); var claimRequest = await AnonCreds.ProverCreateAndStoreClaimReqAsync(wallet, "CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW", claimOffer, claimDef, masterSecretName); var claim = "{\"sex\":[\"male\",\"5944657099558967239210949258394887428692050081607692519917050011144233115103\"],\n" + " \"name\":[\"Alex\",\"1139481716457488690172217916278103335\"],\n" + " \"height\":[\"175\",\"175\"],\n" + " \"age\":[\"28\",\"28\"]\n" + " }"; var createClaimResult = await AnonCreds.IssuerCreateClaimAsync(wallet, claimRequest, claim, -1); var claimJson = createClaimResult.ClaimJson; await AnonCreds.ProverStoreClaimAsync(wallet, claimJson); var filter = string.Format("{{\"issuer_did\":\"{0}\"}}", DID1); var claims = await AnonCreds.ProverGetClaimsAsync(wallet, filter); var claimsArray = JArray.Parse(claims); Assert.AreEqual(1, claimsArray.Count); await wallet.CloseAsync(); }
public async Task TestProverGetClaimsWorksForEmptyResult() { await InitCommonWallet(); var filter = string.Format("{{\"schema_seq_no\":{0}}}", 10); var claims = await AnonCreds.ProverGetClaimsAsync(commonWallet, filter); var claimsArray = JArray.Parse(claims); Assert.AreEqual(0, claimsArray.Count); }
public async Task TestProverGetClaimsWorksForFilterByIssuerAndSchema() { await InitCommonWallet(); var filter = string.Format("{{\"issuer_did\":\"{0}\", \"schema_seq_no\":{1}}}", issuerDid, 1); var claims = await AnonCreds.ProverGetClaimsAsync(commonWallet, filter); var claimsArray = JArray.Parse(claims); Assert.AreEqual(1, claimsArray.Count); }
public async Task TestProverGetClaimsWorksForFilterByIssuer() { await InitCommonWallet(); var filter = string.Format("{{\"issuer_did\":\"{0}\"}}", _issuerDid); var claims = await AnonCreds.ProverGetClaimsAsync(_commonWallet, filter); var claimsArray = JArray.Parse(claims); Assert.AreEqual(1, claimsArray.Count); }