public async Task <IActionResult> RegisterSchema()
        {
            var context = await _agentContextProvider.GetContextAsync();

            var issuer = await _provisionService.GetProvisioningAsync(context.Wallet);

            var Trustee = await Did.CreateAndStoreMyDidAsync(context.Wallet,
                                                             new { seed = "000000000000000000000000Steward1" }.ToJson());

            await Ledger.SignAndSubmitRequestAsync(await context.Pool, context.Wallet, Trustee.Did,
                                                   await Ledger.BuildNymRequestAsync(Trustee.Did, issuer.IssuerDid, issuer.IssuerVerkey, null, "ENDORSER"));

            var schemaId = await _schemaService.CreateSchemaAsync(
                context : context,
                issuerDid : issuer.IssuerDid,
                name : "degree-schema",
                version : "1.0",
                attributeNames : new[] { "name", "date", "degree", "age", "timestamp" });

            await _schemaService.CreateCredentialDefinitionAsync(context, new CredentialDefinitionConfiguration {
                SchemaId                    = schemaId,
                Tag                         = "default",
                EnableRevocation            = false,
                RevocationRegistrySize      = 0,
                RevocationRegistryBaseUri   = "",
                RevocationRegistryAutoScale = false,
                IssuerDid                   = issuer.IssuerDid
            });

            return(RedirectToAction("CredentialsForm"));
        }
Esempio n. 2
0
        public async Task TestAttribRequestWorksForEncValue()
        {
            var trusteeDidResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Did.CreateAndStoreMyDidAsync(wallet, "{}");

            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 attribRequest = await Ledger.BuildAttribRequestAsync(myDid, myDid, null, null, enc);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, attribRequest);

            var getAttribRequest = await Ledger.BuildGetAttribRequestAsync(myDid, myDid, null, null, enc);

            var getAttribResponse = await PoolUtils.EnsurePreviousRequestAppliedAsync(pool, getAttribRequest, response => {
                var getAttribResponseObject = JObject.Parse(response);
                return(enc == getAttribResponseObject["result"]["data"].ToString());
            });

            Assert.IsNotNull(getAttribResponse);
        }
Esempio n. 3
0
        public async Task  TestAttribRequestWorks()
        {
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            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 attribRequest = await Ledger.BuildAttribRequestAsync(myDid, myDid, null, _endpoint, null);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, attribRequest);

            var getAttribRequest = await Ledger.BuildGetAttribRequestAsync(myDid, myDid, "endpoint");

            var getAttribResponse = await Ledger.SubmitRequestAsync(pool, getAttribRequest);

            var jsonObject = JObject.Parse(getAttribResponse);

            Assert.AreEqual(_endpoint, jsonObject["result"]["data"]);
        }
        public async Task TestLedgerDemo()
        {
            // 1. Create ledger config from genesis txn file
            var poolName = PoolUtils.CreatePoolLedgerConfig();
            var pool     = await Pool.OpenPoolLedgerAsync(poolName, "{}");

            // 2. Create and Open My Wallet
            var myWalletConfig = JsonConvert.SerializeObject(new { id = "myWallet" });
            await Wallet.CreateWalletAsync(myWalletConfig, WALLET_CREDENTIALS);

            var myWallet = await Wallet.OpenWalletAsync(myWalletConfig, WALLET_CREDENTIALS);

            // 3. Create and Open Trustee Wallet
            var theirWalletConfig = JsonConvert.SerializeObject(new { id = "theirWallet" });
            await Wallet.CreateWalletAsync(theirWalletConfig, WALLET_CREDENTIALS);

            var trusteeWallet = await Wallet.OpenWalletAsync(theirWalletConfig, WALLET_CREDENTIALS);

            // 4. Create My Did
            var createMyDidResult = await Did.CreateAndStoreMyDidAsync(myWallet, "{}");

            Assert.IsNotNull(createMyDidResult);
            var myDid    = createMyDidResult.Did;
            var myVerkey = createMyDidResult.VerKey;

            // 5. Create Did from Trustee1 seed
            var createTheirDidResult = await Did.CreateAndStoreMyDidAsync(trusteeWallet, TRUSTEE_IDENTITY_JSON);

            Assert.IsNotNull(createTheirDidResult);
            var trusteeDid = createTheirDidResult.Did;

            // 6. Build Nym Request
            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null);

            Assert.IsNotNull(nymRequest);

            // 7. Trustee Sign Nym Request
            var nymResponseJson = await Ledger.SignAndSubmitRequestAsync(pool, trusteeWallet, trusteeDid, nymRequest);

            Assert.IsNotNull(nymResponseJson);

            var nymResponse     = JObject.Parse(nymResponseJson);
            var nymResponseData = nymResponse["result"]["txn"]["data"];

            Assert.AreEqual(myDid, nymResponseData["dest"]);
            Assert.AreEqual(myVerkey, nymResponseData["verkey"]);

            // 8. Close and delete My Wallet
            await myWallet.CloseAsync();

            await Wallet.DeleteWalletAsync(myWalletConfig, WALLET_CREDENTIALS);

            // 9. Close and delete Their Wallet
            await trusteeWallet.CloseAsync();

            await Wallet.DeleteWalletAsync(theirWalletConfig, WALLET_CREDENTIALS);

            // 10. Close Pool
            await pool.CloseAsync();
        }
Esempio n. 5
0
        public async Task TestSignAndSubmitRequestWorksForIncompatibleWalletAndPool()
        {
            var walletName = "incompatibleWallet";

            await Wallet.CreateWalletAsync("otherPoolName", walletName, "default", null, null);

            var wallet = await Wallet.OpenWalletAsync(walletName, null, null);

            var trusteeDidJson   = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, trusteeDidJson);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var myDid = myDidResult.Did;

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, null, null, null);

            var ex = await Assert.ThrowsExceptionAsync <IndyException>(() =>
                                                                       Ledger.SignAndSubmitRequestAsync(_pool, wallet, trusteeDid, nymRequest)
                                                                       );

            Assert.AreEqual(ErrorCode.WalletIncompatiblePoolError, ex.ErrorCode);
        }
Esempio n. 6
0
        public async Task TestReplaceKeysWithoutNymTransaction()
        {
            // 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
            await Signus.ReplaceKeysStartAsync(wallet, myDid, "{}");

            // 5. Apply replacing of keys
            await Signus.ReplaceKeysApplyAsync(wallet, myDid);

            // 6. Send schema request
            var schemaRequest = await Ledger.BuildSchemaRequestAsync(myDid, SCHEMA_DATA);

            var ex = await Assert.ThrowsExceptionAsync <InvalidLedgerTransactionException>(() =>
                                                                                           Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, schemaRequest)
                                                                                           );
        }
Esempio n. 7
0
        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 newVerkey = await Signus.ReplaceKeysStartAsync(wallet, myDid, "{}");

            // 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);
        }
Esempio n. 8
0
        public async Task TestClaimDefRequestWorksWithoutSignature()
        {
            var trusteeDidResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Did.CreateAndStoreMyDidAsync(wallet, "{}");

            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 claimDef = string.Format(_claimDefTemplate, _seqNo, myDid);

            var claimDefObj  = JObject.Parse(claimDef);
            var claimDefJson = claimDefObj["data"].ToString();

            var claimDefRequest = await Ledger.BuildCredDefRequestAsync(myDid, claimDefJson);

            var ex = await Assert.ThrowsExceptionAsync <InvalidLedgerTransactionException>(() =>
                                                                                           Ledger.SubmitRequestAsync(pool, claimDefRequest)
                                                                                           );
        }
Esempio n. 9
0
        public async Task TestSendNymRequestsWorksForWrongSignerRole()
        {
            var trusteeDidJson   = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeDidJson);

            var trusteeDid = trusteeDidResult.Did;

            var myDidJson   = "{}";
            var myDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, myDidJson);

            var myDid = myDidResult.Did;

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, null, null, null);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, trusteeDid, nymRequest);

            var myDidJson2   = "{}";
            var myDidResult2 = await Signus.CreateAndStoreMyDidAsync(_wallet, myDidJson2);

            var myDid2 = myDidResult2.Did;

            var nymRequest2 = await Ledger.BuildNymRequestAsync(myDid, myDid2, null, null, null);

            var ex = await Assert.ThrowsExceptionAsync <IndyException>(() =>
                                                                       Ledger.SignAndSubmitRequestAsync(_pool, _wallet, myDid, nymRequest2)
                                                                       );

            Assert.AreEqual(ErrorCode.LedgerInvalidTransaction, ex.ErrorCode);
        }
Esempio n. 10
0
        public async Task TestNymRequestsWorks()
        {
            var trusteeDidJson   = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeDidJson);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, "{}");

            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 getNymRequest = await Ledger.BuildGetNymRequestAsync(myDid, myDid);

            var getNymResponse = await Ledger.SubmitRequestAsync(_pool, getNymRequest);

            var getNymResponseObj = JObject.Parse(getNymResponse);

            Assert.AreEqual("REPLY", (string)getNymResponseObj["op"]);
            Assert.AreEqual("105", (string)getNymResponseObj["result"]["type"]);
            Assert.AreEqual(myDid, (string)getNymResponseObj["result"]["dest"]);
        }
Esempio n. 11
0
        public async Task TestSendNodeRequestWorksForNewSteward()
        {
            var trusteeDidJson   = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeDidJson);

            var trusteeDid = trusteeDidResult.Did;

            var myDidJson   = "{}";
            var myDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, myDidJson);

            var myDid    = myDidResult.Did;
            var myVerkey = myDidResult.VerKey;

            var role = "STEWARD";

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, role);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, trusteeDid, nymRequest);

            var data = "{\"node_ip\":\"10.0.0.100\"," +
                       "\"node_port\":910," +
                       "\"client_ip\":\"10.0.0.100\"," +
                       "\"client_port\":911," +
                       "\"alias\":\"some\"," +
                       "\"services\":[\"VALIDATOR\"]}";

            var dest = "A5iWQVT3k8Zo9nXj4otmeqaUziPQPCiDqcydXkAJBk1Y";

            var nodeRequest = await Ledger.BuildNodeRequestAsync(myDid, dest, data);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, myDid, nodeRequest);
        }
Esempio n. 12
0
        public async Task TestSendNymRequestsWorksForWrongSignerRole()
        {
            var trusteeDidResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Did.CreateAndStoreMyDidAsync(wallet, "{}");

            var myDid = myDidResult.Did;

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, null, null, null);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDid, nymRequest);

            var myDidResult2 = await Did.CreateAndStoreMyDidAsync(wallet, "{}");

            var myDid2 = myDidResult2.Did;

            var nymRequest2 = await Ledger.BuildNymRequestAsync(myDid, myDid2, null, null, null);

            var result = await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, nymRequest2);

            Assert.IsTrue(result.Contains("\"op\":\"REQNACK\""), "expected REQNACK in {0}", result);
            Assert.IsTrue(result.Contains("CouldNotAuthenticate"), "expected CouldNotAuthenticate in {0}", result);
        }
Esempio n. 13
0
        public async Task TestReplaceKeysWithoutNymTransaction()
        {
            // 1. Create My Did
            var result = await Did.CreateAndStoreMyDidAsync(wallet, "{}");

            var myDid    = result.Did;
            var myVerkey = result.VerKey;

            // 2. Create Their Did from Trustee1 seed
            var theirDidJson         = JsonConvert.SerializeObject(new { seed = TRUSTEE_SEED });
            var createTheirDidResult = await Did.CreateAndStoreMyDidAsync(wallet, theirDidJson);

            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
            await Did.ReplaceKeysStartAsync(wallet, myDid, "{}");

            // 5. Apply replacing of keys
            await Did.ReplaceKeysApplyAsync(wallet, myDid);

            // 6. Send schema request
            var schemaRequest = await Ledger.BuildSchemaRequestAsync(myDid, SCHEMA_DATA);

            var response = await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, schemaRequest);

            CheckResponseType(response, "REQNACK");
        }
Esempio n. 14
0
        public async Task TestLedgerDemo()
        {
            // 1. Create ledger config from genesis txn file
            var poolName = PoolUtils.CreatePoolLedgerConfig();

            var pool = await Pool.OpenPoolLedgerAsync(poolName, "{}");

            // 2. Create and Open My Wallet
            await Wallet.CreateWalletAsync(poolName, "myWallet", "default", null, null);

            var myWallet = await Wallet.OpenWalletAsync("myWallet", null, null);

            // 3. Create and Open Trustee Wallet
            await Wallet.CreateWalletAsync(poolName, "theirWallet", "default", null, null);

            var trusteeWallet = await Wallet.OpenWalletAsync("theirWallet", null, null);

            // 4. Create My Did
            var createMyDidResult = await Signus.CreateAndStoreMyDidAsync(myWallet, "{}");

            Assert.IsNotNull(createMyDidResult);
            var myDid    = createMyDidResult.Did;
            var myVerkey = createMyDidResult.VerKey;

            // 5. Create Did from Trustee1 seed
            var theirDidJson = "{\"seed\":\"000000000000000000000000Trustee1\"}";

            var createTheirDidResult = await Signus.CreateAndStoreMyDidAsync(trusteeWallet, theirDidJson);

            Assert.IsNotNull(createTheirDidResult);
            var trusteeDid = createTheirDidResult.Did;

            // 6. Build Nym Request
            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null);

            Assert.IsNotNull(nymRequest);

            // 7. Trustee Sign Nym Request
            var nymResponseJson = await Ledger.SignAndSubmitRequestAsync(pool, trusteeWallet, trusteeDid, nymRequest);

            Assert.IsNotNull(nymResponseJson);

            var nymResponse = JObject.Parse(nymResponseJson);

            Assert.AreEqual(myDid, nymResponse["result"].Value <string>("dest"));
            Assert.AreEqual(myVerkey, nymResponse["result"].Value <string>("verkey"));

            // 8. Close and delete My Wallet
            await myWallet.CloseAsync();

            await Wallet.DeleteWalletAsync("myWallet", null);

            // 9. Close and delete Their Wallet
            await trusteeWallet.CloseAsync();

            await Wallet.DeleteWalletAsync("theirWallet", null);

            // 10. Close Pool
            await pool.CloseAsync();
        }
Esempio n. 15
0
        public async Task sendNymRequest(string did, string verkey,
                                         string alias, string role)
        {
            var myDid = d_walletController.getActiveDid();

            try
            {
                // build nym request for owner of did
                var nymJson = await Ledger.BuildNymRequestAsync(myDid, did,
                                                                verkey, alias, role);

                // Trustee sends nym request
                var nymResponseJson = await Ledger.SignAndSubmitRequestAsync(
                    d_poolController.getOpenPool(),
                    d_walletController.getOpenWallet(),
                    myDid,
                    nymJson);

                Console.WriteLine("Identity published to ledger.");
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error: {e.Message}");
            }
        }
Esempio n. 16
0
        public async Task TestNymRequestsWorks()
        {
            var trusteeDidResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Did.CreateAndStoreMyDidAsync(wallet, "{}");

            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 getNymRequest = await Ledger.BuildGetNymRequestAsync(myDid, myDid);

            var getNymResponse = await Ledger.SubmitRequestAsync(pool, getNymRequest);

            var getNymResponseObj = JObject.Parse(getNymResponse);

            Assert.AreEqual("REPLY", (string)getNymResponseObj["op"]);
            Assert.AreEqual("105", (string)getNymResponseObj["result"]["type"]);
            Assert.AreEqual(myDid, (string)getNymResponseObj["result"]["dest"]);
        }
Esempio n. 17
0
        public async Task Before()
        {
            var poolName = PoolUtils.CreatePoolLedgerConfig();

            _pool = await Pool.OpenPoolLedgerAsync(poolName, "{}");

            await Wallet.CreateWalletAsync(poolName, _walletName, "default", null, null);

            _wallet = await Wallet.OpenWalletAsync(_walletName, null, null);

            var trusteeJson = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var result      = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeJson);

            _trusteeDid    = result.Did;
            _trusteeVerkey = result.VerKey;

            var otherDid = "{\"seed\":\"00000000000000000000000000000My1\"}";
            var nym      = await Signus.CreateAndStoreMyDidAsync(_wallet, otherDid);

            _did    = nym.Did;
            _verkey = nym.VerKey;

            var nymRequest = await Ledger.BuildNymRequestAsync(_trusteeDid, _did, _verkey, null, null);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, _trusteeDid, nymRequest);
        }
Esempio n. 18
0
        public async Task TestBuildNymRequestWorksForEmptyRole()
        {
            var expectedResult = string.Format("\"identifier\":\"{0}\",\"operation\":{{\"dest\":\"{1}\",\"role\":null,\"type\":\"1\"}}", DID1, _dest);

            var nymRequest = await Ledger.BuildNymRequestAsync(DID1, _dest, null, null, string.Empty);

            Assert.IsTrue(nymRequest.Contains(expectedResult));
        }
Esempio n. 19
0
        public async Task TestBuildNymRequestWorksForOnlyRequiredFields()
        {
            var expectedResult = string.Format("\"identifier\":\"{0}\",\"operation\":{{\"type\":\"1\",\"dest\":\"{1}\"}}", _identifier, _dest);

            var nymRequest = await Ledger.BuildNymRequestAsync(_identifier, _dest, null, null, null);

            Assert.IsTrue(nymRequest.Contains(expectedResult));
        }
Esempio n. 20
0
        public async Task TestSendNymRequestsWorksForWrongRole()
        {
            var ex = await Assert.ThrowsExceptionAsync <IndyException>(() =>
                                                                       Ledger.BuildNymRequestAsync(_identifier, _dest, null, null, "WRONG_ROLE")
                                                                       );

            Assert.AreEqual(ErrorCode.CommonInvalidStructure, ex.ErrorCode);
        }
        async Task <CreateAndStoreMyDidResult> PromoteTrustee(string seed)
        {
            var trustee = await Did.CreateAndStoreMyDidAsync(Context.Wallet, new { seed = seed }.ToJson());

            await Ledger.SignAndSubmitRequestAsync(await Context.Pool, Context.Wallet, Trustee.Did,
                                                   await Ledger.BuildNymRequestAsync(Trustee.Did, trustee.Did, trustee.VerKey, null, "TRUSTEE"));

            return(trustee);
        }
Esempio n. 22
0
        public async Task TestNymRequestWorksWithoutSignature()
        {
            var didResult = await Did.CreateAndStoreMyDidAsync(wallet, "{}");

            var did = didResult.Did;

            var nymRequest = await Ledger.BuildNymRequestAsync(did, did, null, null, null);

            var response = await Ledger.SubmitRequestAsync(pool, nymRequest);

            CheckResponseType(response, "REQNACK");
        }
        /// <inheritdoc />
        public virtual async Task RegisterNymAsync(IAgentContext context, string submitterDid, string theirDid,
                                                   string theirVerkey, string role, TransactionCost paymentInfo = null)
        {
            if (DidUtils.IsFullVerkey(theirVerkey))
            {
                theirVerkey = await Did.AbbreviateVerkeyAsync(theirDid, theirVerkey);
            }

            var req = await Ledger.BuildNymRequestAsync(submitterDid, theirDid, theirVerkey, null, role);

            var res = await SignAndSubmitAsync(context, submitterDid, req, paymentInfo);
        }
Esempio n. 24
0
        public async Task TestNymRequestWorksWithoutSignature()
        {
            var didResult = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var did = didResult.Did;

            var nymRequest = await Ledger.BuildNymRequestAsync(did, did, null, null, null);

            var ex = await Assert.ThrowsExceptionAsync <InvalidLedgerTransactionException>(() =>
                                                                                           Ledger.SubmitRequestAsync(pool, nymRequest)
                                                                                           );
        }
        protected async Task PromoteTrustAnchor()
        {
            var record = await Host.Services.GetService <IProvisioningService>().GetProvisioningAsync(Context.Wallet);

            if (record.IssuerDid == null || record.IssuerVerkey == null)
            {
                throw new AriesFrameworkException(ErrorCode.InvalidRecordData, "Agent not set up as issuer");
            }

            await Ledger.SignAndSubmitRequestAsync(await Context.Pool, Context.Wallet, Trustee.Did,
                                                   await Ledger.BuildNymRequestAsync(Trustee.Did, record.IssuerDid, record.IssuerVerkey, null, "ENDORSER"));
        }
Esempio n. 26
0
        public async Task TestAgentConnectWorksForRemoteData()
        {
            var endpoint           = "127.0.0.1:9605";
            var listenerWalletName = "listenerWallet";
            var trusteeWalletName  = "trusteeWallet";

            await Wallet.CreateWalletAsync(_poolName, listenerWalletName, "default", null, null);

            var listenerWallet = await Wallet.OpenWalletAsync(listenerWalletName, null, null);

            await Wallet.CreateWalletAsync(_poolName, trusteeWalletName, "default", null, null);

            var trusteeWallet = await Wallet.OpenWalletAsync(trusteeWalletName, null, null);

            var senderWallet = trusteeWallet;

            var createMyDidResult = await Signus.CreateAndStoreMyDidAsync(listenerWallet, "{}");

            var listenerDid    = createMyDidResult.Did;
            var listenerVerkey = createMyDidResult.VerKey;
            var listenerPk     = createMyDidResult.Pk;

            var trusteeDidJson = "{\"seed\":\"000000000000000000000000Trustee1\"}";

            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(trusteeWallet, trusteeDidJson);

            var trusteeDid = trusteeDidResult.Did;
            var senderDid  = trusteeDid;

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, listenerDid, listenerVerkey, null, null);

            await Ledger.SignAndSubmitRequestAsync(_pool, trusteeWallet, trusteeDid, nymRequest);

            var attribRequest = await Ledger.BuildAttribRequestAsync(listenerDid, listenerDid, null,
                                                                     string.Format("{{\"endpoint\":{{\"ha\":\"{0}\",\"verkey\":\"{1}\"}}}}", endpoint, listenerPk), null);

            await Ledger.SignAndSubmitRequestAsync(_pool, listenerWallet, listenerDid, attribRequest);

            var activeListener = await AgentListener.ListenAsync(endpoint);

            await activeListener.AddIdentityAsync(_pool, listenerWallet, listenerDid);

            await AgentConnection.ConnectAsync(_pool, senderWallet, senderDid, listenerDid);

            await listenerWallet.CloseAsync();

            await Wallet.DeleteWalletAsync(listenerWalletName, null);

            await trusteeWallet.CloseAsync();

            await Wallet.DeleteWalletAsync(trusteeWalletName, null);
        }
Esempio n. 27
0
        public async Task TestNymRequestWorksWithoutSignature()
        {
            var didResult = await Did.CreateAndStoreMyDidAsync(wallet, "{}");

            var did = didResult.Did;

            var nymRequest = await Ledger.BuildNymRequestAsync(did, did, null, null, null);

            var result = await Ledger.SubmitRequestAsync(pool, nymRequest);

            Assert.IsTrue(result.Contains("\"op\":\"REQNACK\""), "expected REQNACK in {0}", result);
            Assert.IsTrue(result.Contains("MissingSignature"), "expected CouldNotAuthenticate in {0}", result);
        }
Esempio n. 28
0
        private async Task CreateNewNymWithDidInLedgerAsync()
        {
            var json = "{\"seed\":\"00000000000000000000000000000My1\"}";

            var result = await Signus.CreateAndStoreMyDidAsync(_wallet, json);

            _newDid = result.Did;
            var newVerkey = result.VerKey;

            var nymRequest = await Ledger.BuildNymRequestAsync(_trusteeDid, _newDid, newVerkey, null, null);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, _trusteeDid, nymRequest);
        }
        /// <inheritdoc />
        public virtual async Task RegisterNymAsync(Wallet wallet, Pool pool, string submitterDid, string theirDid,
                                                   string theirVerkey, string role)
        {
            if (DidUtils.IsFullVerkey(theirVerkey))
            {
                theirVerkey = await Did.AbbreviateVerkeyAsync(theirDid, theirVerkey);
            }

            var req = await Ledger.BuildNymRequestAsync(submitterDid, theirDid, theirVerkey, null, role);

            var res = await Ledger.SignAndSubmitRequestAsync(pool, wallet, submitterDid, req);

            EnsureSuccessResponse(res);
        }
Esempio n. 30
0
        public async Task TestNymRequestWorksWithoutSignature()
        {
            var didResult = await Signus.CreateAndStoreMyDidAsync(_wallet, "{}");

            var did = didResult.Did;

            var nymRequest = await Ledger.BuildNymRequestAsync(did, did, null, null, null);

            var ex = await Assert.ThrowsExceptionAsync <IndyException>(() =>
                                                                       Ledger.SubmitRequestAsync(_pool, nymRequest)
                                                                       );

            Assert.AreEqual(ErrorCode.LedgerInvalidTransaction, ex.ErrorCode);
        }