/// <inheritdoc /> public async Task ProvisionAgentAsync(AgentOptions agentOptions) { if (agentOptions is null) { throw new ArgumentNullException(nameof(agentOptions)); } // Create agent wallet await WalletService.CreateWalletAsync( configuration : agentOptions.WalletConfiguration, credentials : agentOptions.WalletCredentials); var wallet = await WalletService.GetWalletAsync( configuration : agentOptions.WalletConfiguration, credentials : agentOptions.WalletCredentials); // Configure agent endpoint AgentEndpoint endpoint = null; if (agentOptions.EndpointUri != null) { endpoint = new AgentEndpoint { Uri = agentOptions.EndpointUri.ToString() }; if (agentOptions.AgentKeySeed != null) { var agent = await Did.CreateAndStoreMyDidAsync(wallet, new { seed = agentOptions.AgentKeySeed }.ToJson()); endpoint.Did = agent.Did; endpoint.Verkey = new[] { agent.VerKey }; } else if (agentOptions.AgentKey != null) { endpoint.Did = agentOptions.AgentDid; endpoint.Verkey = new[] { agentOptions.AgentKey }; } else { var agent = await Did.CreateAndStoreMyDidAsync(wallet, "{}"); endpoint.Did = agent.Did; endpoint.Verkey = new[] { agent.VerKey }; } } var masterSecretId = await AnonCreds.ProverCreateMasterSecretAsync(wallet, null); var record = new ProvisioningRecord { MasterSecretId = masterSecretId, Endpoint = endpoint, Owner = { Name = agentOptions.AgentName, ImageUrl = agentOptions.AgentImageUri } }; // Issuer Configuration if (agentOptions.IssuerKeySeed == null) { agentOptions.IssuerKeySeed = CryptoUtils.GetUniqueKey(32); } var issuer = await Did.CreateAndStoreMyDidAsync( wallet : wallet, didJson : new { did = agentOptions.IssuerDid, seed = agentOptions.IssuerKeySeed }.ToJson()); record.IssuerSeed = agentOptions.IssuerKeySeed; record.IssuerDid = issuer.Did; record.IssuerVerkey = issuer.VerKey; record.TailsBaseUri = agentOptions.EndpointUri != null ? new Uri(new Uri(agentOptions.EndpointUri), "tails/").ToString() : null; record.UseMessageTypesHttps = agentOptions.UseMessageTypesHttps; record.SetTag("AgentKeySeed", agentOptions.AgentKeySeed); record.SetTag("IssuerKeySeed", agentOptions.IssuerKeySeed); // Add record to wallet await RecordService.AddAsync(wallet, record); }