public TestWallet(string walletName, string walletKey, string seed) { try { walletConfig = DefaultWalletConfig.build(walletName, walletKey); WalletUtil.tryCreateWallet(walletConfig); Wallet walletHandle = WalletUtil.openIndyWallet(walletConfig); Did theirResult = Did.createNewDid(walletHandle); this.verityPublicDID = theirResult.did; this.verityPublicVerkey = theirResult.verkey; Did theirPairwiseResult = Did.createNewDid(walletHandle); this.verityPairwiseVerkey = theirPairwiseResult.verkey; this.verityPairwiseDID = theirPairwiseResult.did; Did myPairwiseResult = Did.createNewDid(walletHandle, seed); this.sdkPairwiseDID = myPairwiseResult.did; this.sdkPairwiseVerkey = myPairwiseResult.verkey; walletHandle.CloseAsync().GetAwaiter().GetResult(); } catch (IndyException e) { throw new WalletException("Failed to initialize TestWallet", e); } }
/// <summary> /// Initializes a ContextBuilder from scratch for a verity-sdk without a provisioned agent on the /// verity-application. This involves three main steps. First, a new local wallet is created /// using the given wallet id and key. Second, a new local key-pair is created in the new created wallet that will /// be used by the verity-sdk. Third, the verity-application public DID and verkey a retrieved from the /// verity-application instance referenced by the given verkey url. After these two step, a given fields are loaded /// into a blank ContextBuilder and returned. /// </summary> /// <param name="walletId">the id for the local wallet</param> /// <param name="walletKey">the key (credential) for the local wallet</param> /// <param name="verityUrl">the url for the targeted instance of the verity-application</param> /// <param name="seed">the seed used to generate the local key-pair</param> /// <return>a ContextBuilder with given, retrieved and created fields</return> public static Context fromScratch(string walletId, string walletKey, string verityUrl, string seed) { WalletUtil.tryCreateWallet(walletId, walletKey); return(scratchContext(DefaultWalletConfig.build(walletId, walletKey), verityUrl, seed)); }
/// <summary> /// Initializes a ContextBuilder from scratch for a verity-sdk that is using an already provisioned agent on /// the verity-application. This involves three main steps. First, a new local wallet is created /// using the given wallet id and key. Second, a new local key-pair is created in the new created wallet that will /// be used by the verity-sdk. Third, the verity-application public DID and verkey a retrieved from the /// verity-application instance referenced by the given verkey url. After these two step, a given fields are loaded /// into a blank ContextBuilder and returned. /// </summary> /// <param name="walletId">the id for the local wallet</param> /// <param name="walletKey">the key (credential) for the local wallet</param> /// <param name="verityUrl">the url for the targeted instance of the verity-application</param> /// <param name="domainDID">the domain DID for the agent already provisioned</param> /// <param name="verityAgentVerKey">the verkey for the agent already provisioned</param> /// <param name="seed">the seed used to generate the local key-pair</param> /// <return>a ContextBuilder with given, retrieved and created fields</return> public static Context fromScratch(string walletId, string walletKey, string verityUrl, string domainDID, string verityAgentVerKey, string seed) { WalletUtil.tryCreateWallet(walletId, walletKey); Context inter = scratchContext(DefaultWalletConfig.build(walletId, walletKey), verityUrl, seed); return(withProvisionedAgent(inter, domainDID, verityAgentVerKey)); }
/// <summary> /// Loads the fields contained in the given JSON Object into this ContextBuilder. The JSON Object should be /// from a Context object that was converted to JSON ( see: {@link Context#toJson()} ) /// </summary> /// <param name="json">a JSON Object that contains properly formatted JSON</param> /// <return>this ContextBuilder with loaded fields</return> public ContextBuilder json(JsonObject json) { WalletConfig w = DefaultWalletConfig.build( json.GetValue("walletName"), json.GetValue("walletKey"), json.GetValue("walletPath") ); this.walletConfig(w); putElementIgnoreNull(ContextConstants.ENDPOINT_URL, json.GetValue(ContextConstants.ENDPOINT_URL)); putElementIgnoreNull(ContextConstants.VERITY_URL, json.GetValue(ContextConstants.VERITY_URL)); string version = json.GetValue(ContextConstants.VERSION); if (ContextConstants.V_0_2.Equals(version)) { return(json_0_2(json)); } return(json_0_1(json)); }