/// <summary> /// Creates and stores the local party's DID in the specified wallet. /// </summary> /// <param name="wallet">The wallet to store the DID in.</param> /// <param name="didJson">The DID JSON.</param> /// <returns>An asynchronous task that returns a CreateAndStoreMyDidResult.</returns> public static Task <CreateAndStoreMyDidResult> CreateAndStoreMyDidAsync(Wallet wallet, string didJson) { var taskCompletionSource = new TaskCompletionSource <CreateAndStoreMyDidResult>(); var commandHandle = AddTaskCompletionSource(taskCompletionSource); var commandResult = IndyNativeMethods.indy_create_and_store_my_did( commandHandle, wallet.Handle, didJson, _createAndStoreMyDidCallback); CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Creates signing and encryption keys in specified wallet for a new DID owned by the caller. /// </summary> /// <remarks> /// <para>Saves the identity DID with keys in a wallet so that it can be used to sign /// and encrypt transactions. Control over the created DID is provided through the /// <paramref name="didJson"/> parameter which accepts a JSON string with the following /// optional parameters: /// </para> /// <code> /// { /// "did": string, /// "seed": string, /// "crypto_type": string, /// "cid": bool /// } /// </code> /// <para>The <c>did</c> member specifies the DID of the new entry. If not /// provided and the <c>cid</c> member is <c>false</c> then the first 16 bits of the VerKey value /// generated will be used as a new DID. If not provided and the <c>cid</c> member is <c>true</c> then the full /// VerKey value will be used as a new DID. If the <c>did</c> member is provided then the keys will be /// replaced - this is normally used in the case of key rotation.</para> /// <para>The <c>seed</c> member specifies the seed to use when generating keys. If not provided /// then a random seed value will be created.</para> /// <para>The <c>crypto_type</c> member specifies the cryptographic algorithm used for generating /// keys. If not provided then ed25519 curve is used. /// <note type="note">The only value currently supported for this member is 'ed25519'.</note> /// </para> /// <para>The <c>cid</c> member indicates whether the DID should be used in creating the DID. /// If not provided then the value defaults to false.</para> /// </remarks> /// <param name="wallet">The wallet to store the DID in.</param> /// <param name="didJson">The DID JSON.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a <see cref="CreateAndStoreMyDidResult"/> when the operation completes.</returns> public static Task <CreateAndStoreMyDidResult> CreateAndStoreMyDidAsync(Wallet wallet, string didJson) { ParamGuard.NotNull(wallet, "wallet"); ParamGuard.NotNullOrWhiteSpace(didJson, "didJson"); var taskCompletionSource = new TaskCompletionSource <CreateAndStoreMyDidResult>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = IndyNativeMethods.indy_create_and_store_my_did( commandHandle, wallet.Handle, didJson, _createAndStoreMyDidCallback); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }