public void SignRequestNymRequestSuccessfully() { INymLedger ledger = IndyDotNet.Ledger.Factory.CreateNymLedger(); IDid submitter = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Trustee1" }); IDid target = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Trustee2" }); BuildRequestResult result = ledger.BuildRequest(submitter, target, null, null, NymRoles.NA); BuildRequestResult signResult = ledger.SignRequest(_wallet, submitter, result); Assert.IsNotNull(signResult, "failed to create SignAndSubmitRequestResult"); // Dids are submitter: V4SGRU86Z58d6TV7PBUe6f and target: LnXR1rPnncTPZvRdmJKhJQ Assert.IsNotNull(signResult, "failed to create BuildNymRequestResult"); Assert.IsTrue(0 < signResult.ReqId, "ReqId not set"); Assert.AreEqual(signResult.Identifier, submitter.Did, $"Identifer failed match to submitter: {submitter.Did}"); Assert.AreEqual(signResult.Operation.Dest, target.Did, $"Dest failed match to target: {target.Did}"); Assert.IsFalse(string.IsNullOrEmpty(signResult.Signature), $"Signature not found: '{signResult.Signature}'"); }
public void Demo() { // Initialization // 1. Creating a new local pool ledger configuration that can be used later to connect pool nodes. // 2. Open pool ledger and get the pool handle from libindy. // 3. Creates a new identity wallet // 4. Open identity wallet and get the wallet handle from libindy // SEE Initialize() above // 5. Generating and storing steward DID and Verkey IDid stewardDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Steward1" }); // 6. Generating and storing Trust Anchor DID and Verkey IDid trustAnchor = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, null); // 7. Build NYM request to add Trust Anchor to the ledger INymLedger nymLedger = IndyDotNet.Ledger.Factory.CreateNymLedger(); BuildRequestResult nymRequest = nymLedger.BuildRequest(stewardDid, trustAnchor, trustAnchor.VerKey, "", NymRoles.TrustAnchor); // 8. Sending the nym request to ledger SignAndSubmitRequestResponse nymResult = nymLedger.SignAndSubmitRequest(_pool, _wallet, stewardDid, nymRequest); // 9. Generating new Verkey of Trust Anchor in the wallet trustAnchor.ReplaceStart(); // 10. Building NYM request to update new verkey to ledger // Note: using TemnpVerKey which was set in step #9 BuildRequestResult updateNymRequest = nymLedger.BuildRequest(trustAnchor, trustAnchor, trustAnchor.TempVerKey, "", NymRoles.TrustAnchor); // 11. Sending NYM request to the ledger SignAndSubmitRequestResponse replaceKeyResult = nymLedger.SignAndSubmitRequest(_pool, _wallet, trustAnchor, updateNymRequest); // 12. Applying new Trust Anchor's Verkey in wallet trustAnchor.ReplaceApply(); // 13. Reading new Verkey from wallet trustAnchor.Refresh(true); // 14. Building GET_NYM request to get Trust Anchor from Verkey BuildRequestResult refreshNymRequest = nymLedger.BuildRequest(trustAnchor, trustAnchor, null, null, NymRoles.NA); // 15.Sending GET_NYM request to ledger SignAndSubmitRequestResponse refreshNymResult = nymLedger.SubmitRequest(_pool, refreshNymRequest); // 16. Comparing Trust Anchor verkeys Assert.AreEqual(trustAnchor.VerKey, refreshNymResult.Result.Transaction.TxnData.Dest); // clean up // Close and delete wallet // Close pool // Delete pool ledger config // SEE Cleanup() above }
public void Demo() { // Initialization // 1. Creating a new local pool ledger configuration that can be used later to connect pool nodes. // 2. Open pool ledger and get the pool handle from libindy. // 3. Creates a new identity wallet // 4. Open identity wallet and get the wallet handle from libindy // SEE Initialize() above // PART 2 // 5. Generating and storing steward DID and Verkey IDid stewardDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Steward1" }); // 6. Generating and storing Trust Anchor DID and Verkey IDid trustAnchor = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, null); // PART 3 // 7. Build NYM request to add Trust Anchor to the ledger INymLedger nymLedger = IndyDotNet.Ledger.Factory.CreateNymLedger(); BuildRequestResult nymRequest = nymLedger.BuildRequest(stewardDid, trustAnchor, trustAnchor.VerKey, "", NymRoles.TrustAnchor); // 8. Sending the nym request to ledger SignAndSubmitRequestResponse nymResult = nymLedger.SignAndSubmitRequest(_pool, _wallet, stewardDid, nymRequest); // PART 4 // 9. Generating and storing DID and Verkey to query the ledger with IDid clientDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, null); // 10. Building the GET_NYM request to query Trust Anchor's Verkey as the Client IGetNymLedger getNymLedger = IndyDotNet.Ledger.Factory.CreateGetNymLedger(); BuildRequestResult getNymRequest = getNymLedger.BuildGetRequest(clientDid, trustAnchor); // 11. Sending the GET_NYM request to the ledger GetNymSubmitReponse getNymSubmitRequest = getNymLedger.SubmitRequest(_pool, getNymRequest); // 12. Comparing Trust Anchor did as written by Steward and as retrieved in Client's query Assert.AreEqual(trustAnchor.Did, getNymSubmitRequest.Result.Dest, $"trustAnchor: Did = {trustAnchor.Did} VerKey = {trustAnchor.VerKey} and Result.Dest = {getNymSubmitRequest.Result.Dest}"); // clean up // 13. Close and delete wallet // 14. Close pool // 15. Delete pool ledger config // SEE Cleanup() above }
public void BuildNymRequestAsTrustAnchorSuccessfully() { INymLedger ledger = IndyDotNet.Ledger.Factory.CreateNymLedger(); IDid submitter = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Trustee1" }); IDid target = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Trustee2" }); BuildRequestResult result = ledger.BuildRequest(submitter, target, null, null, NymRoles.TrustAnchor); Assert.IsNotNull(result, $"failed to create BuildRequestResult"); Assert.AreEqual(result.Identifier, submitter.Did, $"Identifer failed match to submitter: {submitter.Did}"); Assert.AreEqual(result.Operation.Dest, target.Did, $"Dest failed match to target: {target.Did}"); }
public void SignAndSubmitRequestNymRequestSuccessfully() { INymLedger ledger = IndyDotNet.Ledger.Factory.CreateNymLedger(); IDid submitter = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Trustee1" }); IDid target = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Trustee2" }); BuildRequestResult result = ledger.BuildRequest(submitter, target, null, null, NymRoles.NA); SignAndSubmitRequestResponse signResult = ledger.SignAndSubmitRequest(_pool, _wallet, submitter, result); Assert.IsNotNull(signResult, "failed to create SignAndSubmitRequestResult"); // Dids are submitter: V4SGRU86Z58d6TV7PBUe6f and target: LnXR1rPnncTPZvRdmJKhJQ Assert.AreEqual(signResult.Result.Transaction.Metadata.From, submitter.Did, $"txn.metadata.from failed to match submitter: {submitter.Did}"); Assert.AreEqual(signResult.Result.Transaction.TxnData.Dest, target.Did, $"txn.data.dest failed to match target: {target.Did}"); }
public void Demo() { // Initialization // 1. Creating a new local pool ledger configuration that can be used later to connect pool nodes. // 2. Open pool ledger and get the pool handle from libindy. // 3. Creates a new identity wallet // 4. Open identity wallet and get the wallet handle from libindy // SEE Initialize() above // 5. Generating and storing steward DID and Verkey IDid stewardDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Steward1" }); // 6. Generating and storing Trust Anchor DID and Verkey IDid trustAnchor = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, null); // 7. Build NYM request to add Trust Anchor to the ledger INymLedger nymLedger = IndyDotNet.Ledger.Factory.CreateNymLedger(); BuildRequestResult nymRequest = nymLedger.BuildRequest(stewardDid, trustAnchor, trustAnchor.VerKey, "", NymRoles.TrustAnchor); // 8. Sending the nym request to ledger SignAndSubmitRequestResponse nymResult = nymLedger.SignAndSubmitRequest(_pool, _wallet, stewardDid, nymRequest); // 9. build the schema definition request SchemaDefinition schemaDefinition = new SchemaDefinition() { Name = "name", Version = "1.1", Id = "id" }; schemaDefinition.AttributeNames.Add("age"); schemaDefinition.AttributeNames.Add("height"); schemaDefinition.AttributeNames.Add("sex"); schemaDefinition.AttributeNames.Add("name"); ISchemaLedger schemaLedger = IndyDotNet.Ledger.Factory.CreateSchemaLedger(); BuildSchemaResult buildSchema = schemaLedger.BuildSchemaRequest(stewardDid, schemaDefinition); // 10. Sending the SCHEMA request to the ledger SignAndSubmitRequestResponse signAndSubmitRequestResponse = schemaLedger.SignAndSubmitRequest(_pool, _wallet, stewardDid, buildSchema); // 11. Creating and storing CLAIM DEFINITION using anoncreds as Trust Anchor, for the given Schema IIssuerAnonCreds issuer = IndyDotNet.AnonCreds.Factory.GetIssuerAnonCreds(_wallet); CredentialDefinitionSchema credentialDefinition = new CredentialDefinitionSchema() { SequenceNo = 1, Id = "id", Name = "name", Version = "1.1", Tag = "TAG" }; credentialDefinition.AttributeNames.Add("age"); credentialDefinition.AttributeNames.Add("height"); credentialDefinition.AttributeNames.Add("sex"); credentialDefinition.AttributeNames.Add("name"); IssuerCredentialDefinition result = issuer.CreateStoreCredentialDef(trustAnchor, credentialDefinition); Assert.IsNotNull(result); Assert.IsNotNull(result.SchemaId); Assert.IsNotNull(result.Tag); Assert.AreEqual(credentialDefinition.Tag, result.Tag); Assert.IsNotNull(result.Value); Assert.IsNotNull(result.Value.Primary); Assert.IsNotNull(result.Value.Primary.r); Assert.IsNotNull(result.Value.Primary.r.MasterSecret); Assert.AreEqual(credentialDefinition.AttributeNames.Count, result.Value.Primary.r.Attributes.Count); // clean up // Close and delete wallet // Close pool // Delete pool ledger config // SEE Cleanup() above }
public void Demo() { // Initialization // 1. Creating a new local pool ledger configuration that can be used later to connect pool nodes. // 2. Open pool ledger and get the pool handle from libindy. // 3. Creates a new identity wallet // 4. Open identity wallet and get the wallet handle from libindy // SEE Initialize() above // 5. Generating and storing steward DID and Verkey IDid stewardDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed() { Seed = "000000000000000000000000Steward1" }); // 6. Generating and storing Trust Anchor DID and Verkey IDid trustAnchor = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, null); // 7. Build NYM request to add Trust Anchor to the ledger INymLedger nymLedger = IndyDotNet.Ledger.Factory.CreateNymLedger(); BuildRequestResult nymRequest = nymLedger.BuildRequest(stewardDid, trustAnchor, trustAnchor.VerKey, "", NymRoles.TrustAnchor); // 8. Sending the nym request to ledger SignAndSubmitRequestResponse nymResult = nymLedger.SignAndSubmitRequest(_pool, _wallet, stewardDid, nymRequest); // 9. build the schema definition request SchemaDefinition schemaDefinition = new SchemaDefinition() { Name = "name", Version = "1.1", Id = "id" }; schemaDefinition.AttributeNames.Add("age"); schemaDefinition.AttributeNames.Add("height"); schemaDefinition.AttributeNames.Add("sex"); schemaDefinition.AttributeNames.Add("name"); ISchemaLedger schemaLedger = IndyDotNet.Ledger.Factory.CreateSchemaLedger(); BuildSchemaResult buildSchema = schemaLedger.BuildSchemaRequest(stewardDid, schemaDefinition); // 10. Sending the SCHEMA request to the ledger SignAndSubmitRequestResponse signAndSubmitRequestResponse = schemaLedger.SignAndSubmitRequest(_pool, _wallet, stewardDid, buildSchema); // 11. Creating and storing CLAIM DEFINITION using anoncreds as Trust Anchor, for the given Schema IIssuerAnonCreds issuer = IndyDotNet.AnonCreds.Factory.GetIssuerAnonCreds(_wallet); CredentialDefinitionSchema credentialschema = new CredentialDefinitionSchema() { SequenceNo = 1, Id = "id", Name = "name", Version = "1.1", Tag = "TAG" }; credentialschema.AttributeNames.Add("age"); credentialschema.AttributeNames.Add("height"); credentialschema.AttributeNames.Add("sex"); credentialschema.AttributeNames.Add("name"); IssuerCredentialDefinition credentialDefinition = issuer.CreateStoreCredentialDef(trustAnchor, credentialschema); // 12. Creating Prover wallet and opening it to get the handle WalletConfig config = new WalletConfig() { Id = "ProverIssueCredentialDemoWalletId" }; _proverWallet = IndyDotNet.Wallet.Factory.GetWallet(config, _credentials); _proverWallet.Create(); _proverWallet.Open(); // 13. Prover is creating Master Secret IProverAnonCreds prover = IndyDotNet.AnonCreds.Factory.GetProverAnonCreds(_proverWallet); prover.CreateMasterSecret("master_secret"); // 14. Issuer(Trust Anchor) is creating a Claim Offer for Prover IssuerCredentialOffer claimOffer = issuer.CreateCredentialOffer(credentialDefinition.Id); // 15. Prover creates Claim Request IDid proverDID = IndyDotNet.Did.Factory.CreateMyDid(_pool, _proverWallet, null); (ProverCredentialRequest credentialRequest, ProverCredentialRequestMetadata credentialRequestMetadata) = prover.CreateCredentialRequest(proverDID, claimOffer, credentialDefinition, "master_secret"); Assert.AreEqual(credentialRequest.CredDefId, claimOffer.CredDefId); Assert.AreEqual(credentialRequest.ProverDid, proverDID.Did); // 16. Issuer(Trust Anchor) creates Claim for Claim Request AttributeValuesList attributes = new AttributeValuesList(); attributes.Add(new AttributeWithValue() { Name = "age", Value = "27", CheckValue = "27" }); attributes.Add(new AttributeWithValue() { Name = "height", Value = "175", CheckValue = "175" }); attributes.Add(new AttributeWithValue() { Name = "name", Value = "Alex", CheckValue = "99262857098057710338306967609588410025648622308394250666849665532448612202874" }); attributes.Add(new AttributeWithValue() { Name = "sex", Value = "male", CheckValue = "5944657099558967239210949258394887428692050081607692519917050011144233115103" }); IssuerCredential issuerCredential = issuer.CreateCredential(claimOffer, credentialRequest, attributes); // 17. Prover processes and stores Claim string proverCredentialId = prover.SaveCredential(issuerCredential, credentialDefinition, credentialRequestMetadata); Assert.IsTrue(string.IsNullOrEmpty(proverCredentialId), "SaveCredential did not return proverCredentialId"); // clean up // Close and delete wallet // Close pool // Delete pool ledger config // SEE Cleanup() above }