コード例 #1
0
        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
        }
コード例 #2
0
        public void SubmitRequestNymRequestSuccessfully()
        {
            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           signedResult = ledger.SignRequest(_wallet, submitter, result);
            SignAndSubmitRequestResponse signResult   = ledger.SubmitRequest(_pool, signedResult);

            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}");
        }