public async Task TestBuildSchemaRequestWorksWithoutSignature() { var didResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var did = didResult.Did; var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA); var ex = await Assert.ThrowsExceptionAsync <InvalidLedgerTransactionException>(() => Ledger.SubmitRequestAsync(pool, schemaRequest) ); }
public async Task TestBuildSchemaRequestWorks() { var data = "{\"name\":\"name\",\"version\":\"1.0\",\"attr_names\":[\"name\",\"male\"]}"; var expectedResult = string.Format("\"identifier\":\"{0}\"," + "\"operation\":{{" + "\"type\":\"101\"," + "\"data\":{1}" + "}}", _identifier, data); var schemaRequest = await Ledger.BuildSchemaRequestAsync(_identifier, data); Assert.IsTrue(schemaRequest.Replace("\\", "").Contains(expectedResult)); }
public async Task TestGetTxnRequestWorksForInvalidSeqNo1() { var didResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var did = didResult.Did; var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA); var seqNo = 1; var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, LEDGER_TYPE, seqNo); var getTxnResponse = await Ledger.SubmitRequestAsync(pool, getTxnRequest); var getTxnResponseObj = JObject.Parse(getTxnResponse); Assert.IsNotNull(getTxnResponseObj["result"]["data"]); }
public async Task TestClaimDefRequestWorksWithoutSignature() { var trusteeJson = "{\"seed\":\"000000000000000000000000Trustee1\"}"; var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeJson); var trusteeDid = trusteeDidResult.Did; var myJson = "{}"; var myDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, myJson); var myDid = myDidResult.Did; var myVerkey = myDidResult.VerKey; var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null); await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, trusteeDid, nymRequest); var schemaData = "{\"name\":\"gvt2\",\"version\":\"2.0\",\"attr_names\": [\"name\", \"male\"]}"; var schemaRequest = await Ledger.BuildSchemaRequestAsync(myDid, schemaData); var schemaResponse = await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, myDid, schemaRequest); var schemaObj = JObject.Parse(schemaResponse); int schemaSeqNo = (int)schemaObj["result"]["seqNo"]; var claimDef = string.Format(_claimDefTemplate, schemaSeqNo, myDid); var claimDefObj = JObject.Parse(claimDef); var claimDefJson = claimDefObj["data"].ToString(); var claimDefRequest = await Ledger.BuildClaimDefTxnAsync(myDid, schemaSeqNo, _signatureType, claimDefJson); var ex = await Assert.ThrowsExceptionAsync <IndyException>(() => Ledger.SubmitRequestAsync(_pool, claimDefRequest) ); Assert.AreEqual(ErrorCode.LedgerInvalidTransaction, ex.ErrorCode); }
public async Task TestBuildSchemaRequestWorksWithoutSignature() { var didJson = "{\"seed\":\"000000000000000000000000Trustee1\"}"; var didResult = await Signus.CreateAndStoreMyDidAsync(_wallet, didJson); var did = didResult.Did; var schemaData = "{\"name\":\"gvt2\",\n" + " \"version\":\"2.0\",\n" + " \"attr_names\": [\"name\", \"male\"]}"; var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, schemaData); var ex = await Assert.ThrowsExceptionAsync <IndyException>(() => Ledger.SubmitRequestAsync(_pool, schemaRequest) ); Assert.AreEqual(ErrorCode.LedgerInvalidTransaction, ex.ErrorCode); }
public async Task <string> createSchema(string name, string version, string attributes) { var issuerDid = d_walletController.getActiveDid(); try { // issuer schema var schema = await AnonCreds.IssuerCreateSchemaAsync( issuerDid, name, version, attributes); // build schema var buildschema = await Ledger.BuildSchemaRequestAsync( issuerDid, schema.SchemaJson ); // publish schema to ledger var ledgerJSON = await Ledger.SignAndSubmitRequestAsync( d_poolController.getOpenPool(), d_walletController.getOpenWallet(), issuerDid, buildschema); string recordJson = "{"; recordJson += "\"issuer_did\": \"" + issuerDid + "\","; recordJson += "\"schema_id\": \"" + schema.SchemaId + "\","; recordJson += "\"schema_name\": \"" + name + "\","; recordJson += "\"schema_version\": \"" + version + "\""; recordJson += "}"; // add record to wallet that saves the schema information. await d_walletController.addRecord("schema", version, schema.SchemaJson, recordJson); return(schema.SchemaJson); } catch (Exception e) { Console.WriteLine($"Error create schema: {e.Message}"); return(e.Message); } }
public async Task TestGetTxnRequestWorksForInvalidSeqNo() { var did = await CreateStoreAndPublishDidFromTrusteeAsync(); var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA); var schemaResponse = await Ledger.SignAndSubmitRequestAsync(pool, wallet, did, schemaRequest); var schemaResponseObj = JObject.Parse(schemaResponse); var seqNo = (int)schemaResponseObj["result"]["txnMetadata"]["seqNo"] + 1; var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, null, seqNo); var getTxnResponse = await Ledger.SubmitRequestAsync(pool, getTxnRequest); var getTxnResponseObj = JObject.Parse(getTxnResponse); Assert.IsTrue(getTxnResponseObj["result"]["data"] != null); }
public async Task TestBuildSchemaRequestWorksWithoutSignature() { var didResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var did = didResult.Did; var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA); var submitRequestResponse = await Ledger.SubmitRequestAsync(pool, schemaRequest); /* SubmitRequestAsync will return error response as follows * { * "reason":"client request invalid: MissingSignature()", * "op":"REQNACK", * "reqId":1536945730478714000, * "identifier":"V4SGRU86Z58d6TV7PBUe6f" * } */ Assert.IsTrue(submitRequestResponse.Contains("\"op\":\"REQNACK\"")); Assert.IsTrue(submitRequestResponse.Contains("MissingSignature()")); }
public async Task CreateCredentialSchemaAsync(string userId, string name, string version, string[] attributes) { var walletData = await GetDefaultWalletDataAsync(userId); var schema = new { name, version, attr_names = attributes }; var wallet = await Wallet.OpenWalletAsync(walletData.Name, null, null); try { using (var pool = await PoolUtils.CreateAndOpenPoolLedgerAsync()) { var schemaRequest = await Ledger.BuildSchemaRequestAsync(walletData.Did, JsonConvert.SerializeObject(schema)); var result = await Ledger.SignAndSubmitRequestAsync(pool, wallet, walletData.Did, schemaRequest); Console.WriteLine("=============Schema Request Result==========="); Console.WriteLine(result); var schemaData = new CredentialSchema { Id = Guid.NewGuid(), AttributeArray = attributes, Name = name, Version = version, UserId = userId }; _dbContext.CredentialSchemas.Add(schemaData); await _dbContext.SaveChangesAsync(); } } catch (Exception) { throw; } finally { await wallet.CloseAsync(); } }
public async Task TestGetTxnRequestWorksForInvalidSeqNo() { var didResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var did = didResult.Did; var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA); var schemaResponse = await Ledger.SignAndSubmitRequestAsync(pool, wallet, did, schemaRequest); var schemaResponseObj = JObject.Parse(schemaResponse); var seqNo = (int)schemaResponseObj["result"]["seqNo"] + 1; var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, seqNo); var getTxnResponse = await Ledger.SubmitRequestAsync(pool, getTxnRequest); var getTxnResponseObj = JObject.Parse(getTxnResponse); Assert.IsFalse(getTxnResponseObj["result"]["data"].HasValues); }
[TestMethod] //Name of this test is bad. public async Task TestSchemaRequestWorks() { var didResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var did = didResult.Did; var schemaData = "{\"name\":\"gvt2\",\"version\":\"2.0\",\"attr_names\": [\"name\", \"male\"]}"; var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, schemaData); await Ledger.SignAndSubmitRequestAsync(pool, wallet, did, schemaRequest); var getSchemaData = "{\"name\":\"gvt2\",\"version\":\"2.0\"}"; var getSchemaRequest = await Ledger.BuildGetSchemaRequestAsync(did, did, getSchemaData); var getSchemaResponse = await Ledger.SubmitRequestAsync(pool, getSchemaRequest); var getSchemaResponseObject = JObject.Parse(getSchemaResponse); Assert.AreEqual("gvt2", (string)getSchemaResponseObject["result"]["data"]["name"]); Assert.AreEqual("2.0", (string)getSchemaResponseObject["result"]["data"]["version"]); }
public async Task TestReplaceKeysDemoWorks() { // 1. Create My Did var result = await Signus.CreateAndStoreMyDidAsync(wallet, "{}"); var myDid = result.Did; var myVerkey = result.VerKey; // 2. Create Their Did from Trustee1 seed var createTheirDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var trusteeDid = createTheirDidResult.Did; // 3. Build and send Nym Request var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null); await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDid, nymRequest); // 4. Start replacing of keys var newKeys = await Signus.ReplaceKeysStartAsync(wallet, myDid, "{}"); var newVerkey = newKeys.VerKey; // 5. Build and send Nym Request with new key nymRequest = await Ledger.BuildNymRequestAsync(myDid, myDid, newVerkey, null, null); await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, nymRequest); // 6. Apply replacing of keys await Signus.ReplaceKeysApplyAsync(wallet, myDid); // 7. Send schema request var schemaRequest = await Ledger.BuildSchemaRequestAsync(myDid, SCHEMA_DATA); await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, schemaRequest); }
public async Task TestClaimDefRequestWorks() { var trusteeJson = "{\"seed\":\"000000000000000000000000Trustee1\"}"; var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeJson); var trusteeDid = trusteeDidResult.Did; var myJson = "{}"; var myDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, myJson); var myDid = myDidResult.Did; var myVerkey = myDidResult.VerKey; var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null); await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, trusteeDid, nymRequest); var schemaData = "{\"name\":\"gvt2\",\"version\":\"2.0\",\"attr_names\": [\"name\", \"male\"]}"; var schemaRequest = await Ledger.BuildSchemaRequestAsync(myDid, schemaData); await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, myDid, schemaRequest); var getSchemaData = "{\"name\":\"gvt2\",\"version\":\"2.0\"}"; var getSchemaRequest = await Ledger.BuildGetSchemaRequestAsync(myDid, myDid, getSchemaData); var getSchemaResponse = await Ledger.SubmitRequestAsync(_pool, getSchemaRequest); var schemaObj = JObject.Parse(getSchemaResponse); var schemaSeqNo = (int)schemaObj["result"]["seqNo"]; var claimDef = string.Format(_claimDefTemplate, schemaSeqNo, myDid); var claimDefObj = JObject.Parse(claimDef); var claimDefJson = claimDefObj["data"]; var claimDefRequest = await Ledger.BuildClaimDefTxnAsync(myDid, schemaSeqNo, _signatureType, claimDefObj["data"].ToString()); var claimDefResponse = await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, myDid, claimDefRequest); var getClaimDefRequest = await Ledger.BuildGetClaimDefTxnAsync(myDid, schemaSeqNo, _signatureType, claimDefObj["origin"].ToString()); var getClaimDefResponse = await Ledger.SubmitRequestAsync(_pool, getClaimDefRequest); var getClaimDefResponseObj = JObject.Parse(getClaimDefResponse); var expectedClaimDef = claimDefObj["data"]["primary"]; var actualClaimDef = getClaimDefResponseObj["result"]["data"]["primary"]; Assert.AreEqual(expectedClaimDef["n"], actualClaimDef["n"]); Assert.AreEqual(expectedClaimDef["rms"], actualClaimDef["rms"]); Assert.AreEqual(expectedClaimDef["rctxt"], actualClaimDef["rctxt"]); Assert.AreEqual(expectedClaimDef["z"], actualClaimDef["z"]); Assert.AreEqual(expectedClaimDef["n"], actualClaimDef["n"]); //TODO: Check reworked asserts are correct. //JSON.NET does not guarantee the order of nodes in an object when serialized so the original test failed. var expectedR = (JObject)expectedClaimDef["r"]; var actualR = (JObject)actualClaimDef["r"]; Assert.AreEqual(expectedR.Value <string>("age"), actualR.Value <string>("age")); Assert.AreEqual(expectedR.Value <string>("sex"), actualR.Value <string>("sex")); Assert.AreEqual(expectedR.Value <string>("height"), actualR.Value <string>("height")); Assert.AreEqual(expectedR.Value <string>("name"), actualR.Value <string>("name")); }
/// <inheritdoc /> public virtual async Task RegisterSchemaAsync(IAgentContext context, string issuerDid, string schemaJson, TransactionCost paymentInfo = null) { var req = await Ledger.BuildSchemaRequestAsync(issuerDid, schemaJson); var res = await SignAndSubmitAsync(context, issuerDid, req, paymentInfo); }
public async Task testAnoncredsRevocationInteractionIssuanceByDefault() { // Issuer create DID var trusteeDidInfo = await Did.CreateAndStoreMyDidAsync(this.wallet, JsonConvert.SerializeObject(new { seed = TRUSTEE_SEED })); var issuerDidInfo = await Did.CreateAndStoreMyDidAsync(this.wallet, "{}"); var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDidInfo.Did, issuerDidInfo.Did, issuerDidInfo.VerKey, null, "TRUSTEE"); await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDidInfo.Did, nymRequest); var issuerDid = issuerDidInfo.Did; // Prover create DID var proverDidInfo = await Did.CreateAndStoreMyDidAsync(proverWallet, "{}"); var proverDid = proverDidInfo.Did; var proverVerkey = proverDidInfo.VerKey; // Issuer publish Prover DID nymRequest = await Ledger.BuildNymRequestAsync(issuerDid, proverDid, proverVerkey, null, null); await Ledger.SignAndSubmitRequestAsync(pool, wallet, issuerDid, nymRequest); // ISSUER post to Ledger Schema, CredentialDefinition, RevocationRegistry // Issuer creates Schema var schemaInfo = await AnonCreds.IssuerCreateSchemaAsync(issuerDidInfo.Did, GVT_SCHEMA_NAME, SCHEMA_VERSION, GVT_SCHEMA_ATTRIBUTES); var schemaJson = schemaInfo.SchemaJson; // Issuer posts Schema to Ledger var schemaRequest = await Ledger.BuildSchemaRequestAsync(issuerDid, schemaJson); await Ledger.SignAndSubmitRequestAsync(pool, wallet, issuerDid, schemaRequest); // Issuer get Schema from Ledger var getSchemaRequest = await Ledger.BuildGetSchemaRequestAsync(issuerDid, schemaInfo.SchemaId); var getSchemaResponse = await PoolUtils.EnsurePreviousRequestAppliedAsync(pool, getSchemaRequest, response => { var getSchemaResponseObject = JObject.Parse(response); return(getSchemaResponseObject["result"]["seqNo"] != null); }); // !!IMPORTANT!! // It is important to get Schema from Ledger and parse it to get the correct schema JSON and correspondent id in Ledger // After that we can create CredentialDefinition for received Schema(not for result of indy_issuer_create_schema) ParseResponseResult schemaInfo1 = await Ledger.ParseGetSchemaResponseAsync(getSchemaResponse); schemaJson = schemaInfo1.ObjectJson; // Issuer creates CredentialDefinition var credDefInfo = await AnonCreds.IssuerCreateAndStoreCredentialDefAsync(wallet, issuerDid, schemaJson, TAG, null, JsonConvert.SerializeObject(new { support_revocation = true })); var credDefId = credDefInfo.CredDefId; var credDefJson = credDefInfo.CredDefJson; // Issuer post CredentialDefinition to Ledger var credDefRequest = await Ledger.BuildCredDefRequestAsync(issuerDid, credDefJson); await Ledger.SignAndSubmitRequestAsync(pool, wallet, issuerDid, credDefRequest); // Issuer creates RevocationRegistry /* FIXME: getIndyHomePath hard coded forward slash "/". It will not work for Windows. */ var tailsWriterConfig = JsonConvert.SerializeObject( new { base_dir = EnvironmentUtils.GetIndyHomePath("tails"), uri_pattern = string.Empty } ); var tailsWriterHandle = await BlobStorage.OpenWriterAsync("default", tailsWriterConfig); var revRegInfo = await AnonCreds.IssuerCreateAndStoreRevocRegAsync(wallet, issuerDid, null, TAG, credDefId, JsonConvert.SerializeObject(new { max_cred_num = 5, issuance_type = "ISSUANCE_BY_DEFAULT" }), tailsWriterHandle); var revRegId = revRegInfo.RevRegId; var revRegDefJson = revRegInfo.RevRegDefJson; var revRegEntryJson = revRegInfo.RevRegEntryJson; // Issuer posts RevocationRegistryDefinition to Ledger var revRegDefRequest = await Ledger.BuildRevocRegDefRequestAsync(issuerDid, revRegDefJson); await Ledger.SignAndSubmitRequestAsync(pool, wallet, issuerDid, revRegDefRequest); // Issuer posts RevocationRegistryEntry to Ledger var revRegEntryRequest = await Ledger.BuildRevocRegEntryRequestAsync(issuerDid, revRegId, REVOC_REG_TYPE, revRegEntryJson); await Ledger.SignAndSubmitRequestAsync(pool, wallet, issuerDid, revRegEntryRequest); // Issuance Credential for Prover // Prover creates Master Secret await AnonCreds.ProverCreateMasterSecretAsync(proverWallet, COMMON_MASTER_SECRET); // Issuer creates Credential Offer var credOfferJson = await AnonCreds.IssuerCreateCredentialOfferAsync(wallet, credDefId); // Prover gets CredentialDefinition from Ledger var getCredDefRequest = await Ledger.BuildGetCredDefRequestAsync(proverDid, credDefInfo.CredDefId); var getCredDefResponse = await Ledger.SubmitRequestAsync(pool, getCredDefRequest); ParseResponseResult credDefIdInfo = await Ledger.ParseGetCredDefResponseAsync(getCredDefResponse); credDefId = credDefIdInfo.Id; credDefJson = credDefIdInfo.ObjectJson; // Prover creates Credential Request var credReqInfo = await AnonCreds.ProverCreateCredentialReqAsync(proverWallet, proverDid, credOfferJson, credDefJson, COMMON_MASTER_SECRET); var credReqJson = credReqInfo.CredentialRequestJson; var credReqMetadataJson = credReqInfo.CredentialRequestMetadataJson; // Issuer creates TailsReader BlobStorageReader blobStorageReader = await BlobStorage.OpenReaderAsync(TYPE, tailsWriterConfig); // Issuer creates Credential // Issuer must not post rev_reg_delta to ledger for ISSUANCE_BY_DEFAULT strategy var credRegInfo = await AnonCreds.IssuerCreateCredentialAsync(wallet, credOfferJson, credReqJson, GVT_CRED_VALUES, revRegId, blobStorageReader); var credJson = credRegInfo.CredentialJson; var credRevId = credRegInfo.RevocId; // Prover gets RevocationRegistryDefinition var getRevRegDefRequest = await Ledger.BuildGetRevocRegDefRequestAsync(proverDid, revRegId); var getRevRegDefResponse = await Ledger.SubmitRequestAsync(pool, getRevRegDefRequest); ParseResponseResult revRegInfo1 = await Ledger.ParseGetRevocRegDefResponseAsync(getRevRegDefResponse); revRegId = revRegInfo1.Id; var revocRegDefJson = revRegInfo1.ObjectJson; // Prover store received Credential await AnonCreds.ProverStoreCredentialAsync(proverWallet, "credential1_id", credReqMetadataJson, credJson, credDefJson, revocRegDefJson); // Verifying Prover Credential Thread.Sleep(3000); long to = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds / 1000; var proofRequest = JsonConvert.SerializeObject( new { nonce = "123432421212", name = "proof_req_1", version = "0.1", requested_attributes = new { attr1_referent = new { name = "name" } }, requested_predicates = new { predicate1_referent = new { name = "age", p_type = ">=", p_value = 18 } }, non_revoked = new { to = to } } ); // Prover gets Claims for Proof Request var credentialsJson = await AnonCreds.ProverGetCredentialsForProofReqAsync(proverWallet, proofRequest); var credentials = JObject.Parse(credentialsJson); var credsForReferent = (JArray)credentials["attrs"]["attr1_referent"]; var credential = credsForReferent[0]["cred_info"]; // Prover gets RevocationRegistryDelta from Ledger /* FIXME */ var getRevRegDeltaRequest = await Ledger.BuildGetRevocRegDeltaRequestAsync(proverDid, revRegId, -1, (int)to); var getRevRegDeltaResponse = await Ledger.SubmitRequestAsync(pool, getRevRegDeltaRequest); var revRegInfo2 = await Ledger.ParseGetRevocRegDeltaResponseAsync(getRevRegDeltaResponse); revRegId = revRegInfo2.Id; var revocRegDeltaJson = revRegInfo2.ObjectJson; // Prover creates RevocationState var timestamp = to; var revStateJson = await AnonCreds.CreateRevocationStateAsync(blobStorageReader, revocRegDefJson, revocRegDeltaJson, (int)timestamp, credRevId); // Prover gets Schema from Ledger getSchemaRequest = await Ledger.BuildGetSchemaRequestAsync(proverDid, schemaInfo1.Id); getSchemaResponse = await Ledger.SubmitRequestAsync(pool, getSchemaRequest); ParseResponseResult schemaInfo2 = await Ledger.ParseGetSchemaResponseAsync(getSchemaResponse); var schemaId = schemaInfo2.Id; schemaJson = schemaInfo2.ObjectJson; // Prover creates Proof var requestedCredentialsJson = JsonConvert.SerializeObject( new { self_attested_attributes = new { }, requested_attributes = new { attr1_referent = new { cred_id = credential["referent"], timestamp = timestamp, revealed = true } }, requested_predicates = new { predicate1_referent = new { cred_id = credential["referent"], timestamp = timestamp } } } ); var schemasJson = new JObject(new JProperty(schemaId, JObject.Parse(schemaJson))).ToString(); var credDefsJson = new JObject(new JProperty(credDefId, JObject.Parse(credDefJson))).ToString(); var revStatesJson = new JObject(new JProperty(revRegId, new JObject(new JProperty(timestamp.ToString(), JObject.Parse(revStateJson))))).ToString(); var proofJson = await AnonCreds.ProverCreateProofAsync(proverWallet, proofRequest, requestedCredentialsJson, COMMON_MASTER_SECRET, schemasJson, credDefsJson, revStatesJson); var proof = JObject.Parse(proofJson); // Verifier gets RevocationRegistry from Ledger var getRevRegReq = await Ledger.BuildGetRevocRegRequestAsync(DID_MY1, revRegId, (int)timestamp); var getRevRegResp = await Ledger.SubmitRequestAsync(pool, getRevRegReq); var revRegInfo3 = await Ledger.ParseGetRevocRegResponseAsync(getRevRegResp); revRegId = revRegInfo3.Id; var revRegJson = revRegInfo3.ObjectJson; // Verifier verifies proof Assert.AreNotEqual("Alex", proof["requested_proof"]["revealed_attrs"]["attr1_referent"].ToString()); var revRegDefsJson = new JObject(new JProperty(revRegId, JObject.Parse(revRegDefJson))).ToString(); var revRegsJson = new JObject(new JProperty(revRegId, new JObject(new JProperty(timestamp.ToString(), JObject.Parse(revRegJson))))).ToString(); var valid = await AnonCreds.VerifierVerifyProofAsync(proofRequest, proofJson, schemasJson, credDefsJson, revRegDefsJson, revRegsJson); Assert.IsTrue(valid); // Issuer revokes credential var revRegDeltaJson = await AnonCreds.IssuerRevokeCredentialAsync(wallet, blobStorageReader, revRegId, credRevId); // Issuer post RevocationRegistryDelta to Ledger revRegEntryRequest = await Ledger.BuildRevocRegEntryRequestAsync(issuerDid, revRegId, REVOC_REG_TYPE, revRegDeltaJson); await Ledger.SignAndSubmitRequestAsync(pool, wallet, issuerDid, revRegEntryRequest); // Verifying Prover Credential after Revocation Thread.Sleep(3000); long from = to; to = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds / 1000; // Prover gets RevocationRegistryDelta from Ledger getRevRegDeltaRequest = await Ledger.BuildGetRevocRegDeltaRequestAsync(proverDid, revRegId, (int)from, (int)to); getRevRegDeltaResponse = await Ledger.SubmitRequestAsync(pool, getRevRegDeltaRequest); var revRegInfo4 = await Ledger.ParseGetRevocRegDeltaResponseAsync(getRevRegDeltaResponse); revRegId = revRegInfo4.Id; revocRegDeltaJson = revRegInfo4.ObjectJson; timestamp = (long)revRegInfo4.Timestamp; // Prover creates RevocationState revStateJson = await AnonCreds.CreateRevocationStateAsync(blobStorageReader, revocRegDefJson, revocRegDeltaJson, (int)timestamp, credRevId); requestedCredentialsJson = JsonConvert.SerializeObject( new { self_attested_attributes = new { }, requested_attributes = new { attr1_referent = new { cred_id = credential["referent"], timestamp = timestamp, revealed = true } }, requested_predicates = new { predicate1_referent = new { cred_id = credential["referent"], timestamp = timestamp } } } ); revStatesJson = new JObject(new JProperty(revRegId, new JObject(new JProperty(timestamp.ToString(), JObject.Parse(revStateJson))))).ToString(); proofJson = await AnonCreds.ProverCreateProofAsync(proverWallet, proofRequest, requestedCredentialsJson, COMMON_MASTER_SECRET, schemasJson, credDefsJson, revStatesJson); // Verifier gets RevocationRegistry from Ledger getRevRegReq = await Ledger.BuildGetRevocRegRequestAsync(DID_MY1, revRegId, (int)timestamp); getRevRegResp = await Ledger.SubmitRequestAsync(pool, getRevRegReq); var revRegInfo5 = await Ledger.ParseGetRevocRegResponseAsync(getRevRegResp); revRegId = revRegInfo5.Id; revRegJson = revRegInfo5.ObjectJson; timestamp = (long)revRegInfo5.Timestamp; revRegsJson = new JObject(new JProperty(revRegId, new JObject(new JProperty(timestamp.ToString(), JObject.Parse(revRegJson))))).ToString(); valid = await AnonCreds.VerifierVerifyProofAsync(proofRequest, proofJson, schemasJson, credDefsJson, revRegDefsJson, revRegsJson); Assert.IsFalse(valid); }