/// <summary> /// Gets claims matching the provided filter from the specified wallet. /// </summary> /// <remarks> /// <para> /// Claims can be filtered by Issuer, claim_def and/or Schema. To filter the results set the /// <paramref name="filterJson"/> parameter with a JSON string that conforms to the following /// format: /// <code> /// { /// "issuer_did": string, /// "schema_seq_no": string /// } /// </code> /// If <paramref name="filterJson"/> is null then all claims will be returned. /// </para> /// <para> /// Upon successful completion this method will return a JSON string containing an array of /// claims: /// <code> /// [ /// { /// "referent": string, /// "attrs": [{"attr_name" : "attr_value"}, ...], /// "schema_seq_no": string, /// "issuer_did": string, /// "revoc_reg_seq_no": string, /// }, /// ... /// ] /// </code> /// </para> /// </remarks> /// <param name="wallet">The target wallet.</param> /// <param name="filterJson">The filter JSON.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that, when the operation completes, resolves /// to a JSON string containing the claim request.</returns> public static Task <string> ProverGetClaimsAsync(Wallet wallet, string filterJson) { ParamGuard.NotNull(wallet, "wallet"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = NativeMethods.indy_prover_get_claims( commandHandle, wallet.Handle, filterJson, _proverGetClaimsCallback ); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Creates a new revocation registry for the provided claim definition. /// </summary> /// <remarks> /// The revocation registry is stored in the provided <see cref="Wallet"/> and is identified by /// a unique key which is returned in the revocation registry JSON string returned by the method. /// </remarks> /// <param name="wallet">The wallet to store the revocation registry in.</param> /// <param name="issuerDid">The DID of the issuer that signed the revoc_reg transaction to the ledger.</param> /// <param name="schemaSeqNo">The sequence number of a schema transaction in the ledger.</param> /// <param name="maxClaimNum">The maximum number of claims the new registry can process.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that, when the operation completes, resolves /// to a JSON string containing the revocation registry.</returns> public static Task <string> IssuerCreateAndStoreRevocRegAsync(Wallet wallet, string issuerDid, int schemaSeqNo, int maxClaimNum) { var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = IndyNativeMethods.indy_issuer_create_and_store_revoc_reg( commandHandle, wallet.Handle, issuerDid, schemaSeqNo, maxClaimNum, _issuerCreateAndStoreClaimRevocRegCallback ); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Closes the wallet. /// </summary> /// <returns>An asynchronous <see cref="Task"/> with no return value that completes when the operation completes.</returns> public Task CloseAsync() { _requiresClose = false; var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_close_wallet( commandHandle, Handle, CallbackHelper.TaskCompletingNoValueCallback); CallbackHelper.CheckResult(result); GC.SuppressFinalize(this); return(taskCompletionSource.Task); }
/// <summary> /// Builds a ledger request to get a DDO. /// </summary> /// <remarks> /// <para> /// This message builds a request message that is suitable for requesting a DDO from the ledger. /// </para> /// <para> /// The resulting message can be submitted to the ledger using the <see cref="SignAndSubmitRequestAsync(Pool, Wallet, string, string)"/> /// method or can be signed first using the <see cref="SignRequestAsync(Wallet, string, string)"/> /// method then submitted later using the <see cref="SubmitRequestAsync(Pool, string)"/> method. /// </para> /// </remarks> /// <param name="submitterDid">The DID of the party who will submit the request to the ledger.</param> /// <param name="targetDid">The DID of the DDO to get from the ledger.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a <see cref="string"/> /// containing the request JSON.</returns> public static Task <string> BuildGetDdoRequestAsync(string submitterDid, string targetDid) { ParamGuard.NotNullOrWhiteSpace(submitterDid, "submitterDid"); ParamGuard.NotNullOrWhiteSpace(targetDid, "targetDid"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_build_get_ddo_request( commandHandle, submitterDid, targetDid, _buildRequestCallback); CallbackHelper.CheckResult(result); 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); }
/// <summary> /// Decrypts the provided message using the public key associated with the specified DID using the anonymous-encryption scheme. /// </summary> /// <param name="wallet">The wallet containing the DID and associated secret key to use for decryption.</param> /// <param name="did">The DID of the encrypting party to use for verification.</param> /// <param name="encryptedMsg">The message to decrypt.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a byte array containing the decrypted message.</returns> public static Task <byte[]> DecryptSealedAsync(Wallet wallet, string did, byte[] encryptedMsg) { var taskCompletionSource = new TaskCompletionSource <byte[]>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = IndyNativeMethods.indy_decrypt_sealed( commandHandle, wallet.Handle, did, encryptedMsg, encryptedMsg.Length, _decryptSealedCallback ); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Builds a POOL_RESTART request. /// </summary> /// <param name="submitterDid">Id of Identity stored in secured Wallet.</param> /// <param name="action">Action that pool has to do after received transaction.</param> /// <param name="dateTime">Restart time in datetime format.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a <see cref="string"/> /// containing the request JSON. </returns> /// <remarks> /// A null can be passed for the <paramref name="dateTime"/> parameter to restart as early as possible. /// </remarks> public static Task <string> BuildPoolRestartRequestAsync(string submitterDid, string action, string dateTime) { ParamGuard.NotNullOrWhiteSpace(submitterDid, "submitterDid"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_build_pool_restart_request( commandHandle, submitterDid, action, dateTime, BuildRequestCallback); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Gets whether or not a pairwise record exists in the provided wallet for the specified DID . /// </summary> /// <param name="wallet">The wallet to check for a pairwise record.</param> /// <param name="theirDid">The DID to check.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to true if a pairwise exists for the /// DID, otherwise false.</returns> public static Task <bool> IsExistsAsync(Wallet wallet, string theirDid) { ParamGuard.NotNull(wallet, "wallet"); ParamGuard.NotNullOrWhiteSpace(theirDid, "theirDid"); var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); int result = NativeMethods.indy_is_pairwise_exists( commandHandle, wallet.Handle, theirDid, _isPairwiseExistsCallback); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Builds Indy request for getting UTXO list for payment address /// according to this payment method. /// /// Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change /// in the future releases. /// </summary> /// <returns>get_utxo_txn_json - Indy request for getting UTXO list for payment address /// payment_method</returns> /// <param name="wallet">Wallet.</param> /// <param name="submittedDid">DID of request sender</param> /// <param name="paymentAddress">target payment address</param> public static Task <PaymentResult> BuildGetPaymentSourcesAsync(Wallet wallet, string submittedDid, string paymentAddress) { ParamGuard.NotNullOrWhiteSpace(paymentAddress, "paymentAddress"); var taskCompletionSource = new TaskCompletionSource <PaymentResult>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_build_get_payment_sources_request( commandHandle, wallet.Handle, submittedDid, paymentAddress, BuildGetUtxoRequestCallback); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Builds a GET_REVOC_REG request. Request to get the accumulated state of the Revocation Registry /// by ID. The state is defined by the given timestamp. /// </summary> /// <returns>Request result as json..</returns> /// <param name="submitterDid">DID of the read request sender.</param> /// <param name="revocRegDefId">ID of the corresponding Revocation Registry Definition in ledger.</param> /// <param name="timestamp">Requested time represented as a total number of seconds from Unix Epoch</param> public static Task <string> BuildGetRevocRegRequestAsync(string submitterDid, string revocRegDefId, long timestamp) { ParamGuard.NotNullOrWhiteSpace(revocRegDefId, "revocRegDefId"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_build_get_revoc_reg_request( commandHandle, submitterDid, revocRegDefId, timestamp, BuildRequestCallback); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Signs the provided message using the specified DID. /// </summary> /// <remarks> /// The DID specified in the <paramref name="did"/> parameter must already be stored /// in the <see cref="Wallet"/> specified in the <paramref name="wallet"/> parameter /// with a signing key in order to be able to sign a message. See the /// <see cref="CreateAndStoreMyDidAsync(Wallet, string)"/> method for details. /// </remarks> /// <param name="wallet">The wallet that contains the DID.</param> /// <param name="did">The DID to sign with.</param> /// <param name="msg">The message to sign.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a byte array that contains signed message when signing is complete.</returns> public static Task <byte[]> SignAsync(Wallet wallet, string did, byte[] msg) { var taskCompletionSource = new TaskCompletionSource <byte[]>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = IndyNativeMethods.indy_sign( commandHandle, wallet.Handle, did, msg, msg.Length, _signCallback ); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
///// <summary> ///// Same as OpenWalletAsync(string config, string credentials) ///// </summary> ///// <returns>The wallet async.</returns> ///// <param name="config">Config.</param> ///// <param name="cred">Cred.</param> //public static Task<Wallet> OpenWalletAsync(WalletConfig config, Credentials cred) //{ // string configStr = JsonConvert.SerializeObject(config, Formatting.Indented); // string credStr = JsonConvert.SerializeObject(cred, Formatting.Indented); // return OpenWalletAsync(configStr, credStr); //} /// <summary> /// Exports opened wallet /// /// Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change /// in the future releases. /// </summary> /// <returns>The async.</returns> /// <param name="exportConfig"> /// <code> /// JSON containing settings for input operation. /// { /// "path": <string>, Path of the file that contains exported wallet content /// "key": <string>, Passphrase used to derive export key /// } /// </code> /// </param> public Task ExportAsync(string exportConfig) { ParamGuard.NotNullOrWhiteSpace(exportConfig, "exportConfig"); var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_export_wallet( commandHandle, this.Handle, exportConfig, CallbackHelper.TaskCompletingNoValueCallback ); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Sends a message to the connection. /// </summary> /// <remarks> /// <note type="note">Messages sent to a connection are automatically encrypted for the receiver /// prior to sending. /// </note> /// </remarks> /// <param name="message">The message to send.</param> /// <returns>An asynchronous <see cref="Task"/> completes once the operation completes.</returns> public Task SendAsync(string message) { ParamGuard.NotNull(message, "message"); var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = IndyNativeMethods.indy_agent_send( commandHandle, Handle, message, CallbackHelper.TaskCompletingNoValueCallback ); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Builds a GET_TXN request /// </summary> /// <param name="submitterDid">The DID of the submitter.</param> /// <param name="ledgerType">(Optional) type of the ledger the requested transaction belongs to: /// DOMAIN - used default, /// POOL, /// CONFIG /// any number</param> /// <param name="data">seq_no of transaction in ledger</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a <see cref="string"/> /// containing the request JSON. </returns> public static Task <string> BuildGetTxnRequestAsync(string submitterDid, string ledgerType, int data) { ParamGuard.NotNullOrWhiteSpace(submitterDid, "submitterDid"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_build_get_txn_request( commandHandle, submitterDid, ledgerType, data, BuildRequestCallback); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Adds an identity to the listener. /// </summary> /// <remarks> /// <para>Although an AgentListner instance can listen for incoming connections on a specified /// endpoint, any incoming connection to an identity not associated with the listener will be /// automatically rejected. This method adds an identity to the listener that will be authorized /// to accept connections. /// </para> /// <para>This method will perform a <see cref="Wallet"/> lookup to find the identity information /// for the DID to add and consequently the DID must have already been saved in the wallet using /// the <see cref="Hyperledger.Indy.SignusApi.CreateAndStoreMyDidResult"/> method prior to attempting to /// add it to the listener. /// </para> /// <para>Authorization to accept incoming connections to a DID on a listener can be removed using /// the <see cref="RemoveIdentityAsync(Wallet, string)"/> method. /// </para> /// </remarks> /// <seealso cref="Signus"/> /// <param name="pool">The node pool that will be used to verify the identity.</param> /// <param name="wallet">The Wallet that contains the identity.</param> /// <param name="did">The DID of the identity to authorize connections to.</param> /// <returns>An asynchronous <see cref="Task"/> completes once the operation completes.</returns> public Task AddIdentityAsync(Pool pool, Wallet wallet, string did) { var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = IndyNativeMethods.indy_agent_add_identity( commandHandle, Handle, pool.Handle, wallet.Handle, did, CallbackHelper.TaskCompletingNoValueCallback ); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Revokes a user identified by a revoc_id in a given revoc-registry. /// </summary> /// <remarks> /// <para> /// The corresponding claim definition and revocation registry must be already /// have been created and stored in the wallet. /// </para> /// </remarks> /// <param name="wallet">The target wallet.</param> /// <param name="issuerDid">The DID of the issuer.</param> /// <param name="schemaSequenceNumber">The sequence number of the schema.</param> /// <param name="userRevocIndex">index of the user in the revocation registry</param> /// <returns>An asynchronous <see cref="Task{T}"/> that, when the operation completes, resolves /// to a revocation registry update JSON with a revoked claim.</returns> public static Task <string> IssuerRevokeClaimAsync(Wallet wallet, string issuerDid, int schemaSequenceNumber, int userRevocIndex) { var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = IndyNativeMethods.indy_issuer_revoke_claim( commandHandle, wallet.Handle, issuerDid, schemaSequenceNumber, userRevocIndex, IssuerRevokeClaimCallback ); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Creates a new AgentListener that listens for incoming connections on the specified endpoint. /// </summary> /// <remarks> /// The endpoint specified must be in the format <c>address:port</c> where <c>address</c> is /// an IP address or host address and <c>port</c> is a numeric port number. /// </remarks> /// <param name="endpoint">The endpoint on which the incoming connections will listened for.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to an AgentListener instance /// once the listener has been created.</returns> public static Task <AgentListener> ListenAsync(string endpoint) { var listener = new AgentListener(); var taskCompletionSource = new TaskCompletionSource <AgentListener>(listener); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = IndyNativeMethods.indy_agent_listen( commandHandle, endpoint, _listenerCreatedCallback, listener.ConnectionEstablishedCallback, listener.MessageReceivedCallback); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Parses Indy response with information to verify receipt /// </summary> /// <returns>txn_json: { /// sources: [<str>, ] /// receipts: [ { /// recipient: <str>, // payment address of recipient /// receipt: <str>, // receipt that can be used for payment referencing and verification /// amount: <int>, // amount /// } ], /// extra: <str>, //optional data /// }</returns> /// <param name="paymentMethod">Payment method to use.</param> /// <param name="responseJson">Response of the ledger for verify txn.</param> public static Task <string> ParseVerifyPaymentResponseAsync(string paymentMethod, string responseJson) { ParamGuard.NotNullOrWhiteSpace(paymentMethod, "paymentMethod"); ParamGuard.NotNullOrWhiteSpace(responseJson, "responseJson"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_parse_verify_payment_response( commandHandle, paymentMethod, responseJson, ParseVerifyPaymentResponseDelegate); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Opens a pool and connects to the ledger nodes. /// </summary> /// <remarks> /// A Pool cannot be opened unless the a pool configuration with the specified name was previously /// configured using the <see cref="CreatePoolLedgerConfigAsync(string, string)"/> method. /// /// When opening a pool the runtime configuration can be specified using the <paramref name="config"/> /// parameter, which expects a JSON string with the following format: /// /// <code> /// { /// "refresh_on_open": bool (optional), Forces pool ledger to be refreshed immediately after opening. /// Defaults to true. /// "auto_refresh_time": int (optional), After this time in minutes pool ledger will be automatically refreshed. /// Use 0 to disable automatic refresh. Defaults to 24*60. /// "network_timeout": int (optional), Network timeout for communication with nodes in milliseconds. /// Defaults to 20000. /// } /// </code> /// /// If the <paramref name="config"/> parameter is null then the default configuration will be used. /// /// <note type="note">Attempting to open a pool with the same name more than once will result in an error.</note> /// </remarks> /// <param name="configName">The name of the pool configuration to use.</param> /// <param name="config">The runtime configuration to use.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a Pool instance once the pool is opened.</returns> public static Task <Pool> OpenPoolLedgerAsync(string configName, string config) { ParamGuard.NotNullOrWhiteSpace(configName, "configName"); var taskCompletionSource = new TaskCompletionSource <Pool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_open_pool_ledger( commandHandle, configName, config, OpenPoolLedgerCallback ); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Stores a remote party's DID for a pairwise connection in the specified wallet. /// </summary> /// <remarks> /// <para> /// The DID and optional associated parameters must be provided in the <paramref name="identityJson"/> /// parameter as a JSON string: /// </para> /// <code> /// { /// "did": string, /// "verkey": string, /// "crypto_type": string /// } /// </code> /// <para>The <c>did</c> member specifies the DID to store. This value is required.</para> /// <para>The <c>verkey</c> member specifies the verification key and is optional.</para> /// <para>The <c>crypto_type</c> member specifies the type of cryptographic algorithm will be /// used to generate they keys. If not provided then ed22519 curve will be used. /// <note type="note">The only value currently supported for this member is 'ed25519'.</note> /// </para> /// </remarks> /// <param name="wallet">The wallet to store the DID in.</param> /// <param name="identityJson">The identity JSON.</param> /// <returns>An asynchronous <see cref="Task"/> that with no return value the completes when the operation completes.</returns> public static Task StoreTheirDidAsync(Wallet wallet, string identityJson) { ParamGuard.NotNull(wallet, "wallet"); ParamGuard.NotNullOrWhiteSpace(identityJson, "identityJson"); var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = IndyNativeMethods.indy_store_their_did( commandHandle, wallet.Handle, identityJson, CallbackHelper.TaskCompletingNoValueCallback); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Creates a new local pool configuration with the specified name that can be used later to open a connection to /// pool nodes. /// </summary> /// <remarks> /// <para> /// If the configuration specified in the <paramref name="config"/> parameter is null then the /// default configuration will be used, however if specified the value should adhere to the following /// JSON format: /// <code> /// { /// "genesis_txn": "path/to/genesis/transaction/file" /// } /// </code> /// If the value of the <c>genesis_txn</c> key in the JSON is null then a default file will be /// used. If the file specified does not exist it will be created. /// </para> /// </remarks> /// <seealso cref="OpenPoolLedgerAsync(string, string)"/> /// <seealso cref="DeletePoolLedgerConfigAsync(string)"/> /// <param name="configName">The name for the configuration.</param> /// <param name="config">The configuration JSON.</param> /// <returns>An asynchronous <see cref="Task{T}"/> with no return value that completes when /// the configuration is created.</returns> public static Task CreatePoolLedgerConfigAsync(string configName, string config) { ParamGuard.NotNullOrWhiteSpace(configName, "configName"); var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_create_pool_ledger_config( commandHandle, configName, config, CallbackHelper.TaskCompletingNoValueCallback ); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Deletes a wallet. /// </summary> /// <remarks> /// <para>Deletes a wallet created earlier using the <see cref="CreateWalletAsync(string, string, string, string, string)"/> /// by name. /// </para> /// <para>The <paramref name="credentials"/> parameter is unused in the default wallet at present, /// however the value can be used by custom wallet implementations; it is up to the custom wallet /// type implementer to interpret the value. /// </para> /// </remarks> /// <param name="name">The name of the wallet to delete.</param> /// <param name="credentials">The wallet credentials.</param> /// <returns>An asynchronous <see cref="Task"/> with no return value that completes when the operation completes.</returns> public static Task DeleteWalletAsync(string name, string credentials) { ParamGuard.NotNullOrWhiteSpace(name, "name"); var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_delete_wallet( commandHandle, name, credentials, CallbackHelper.TaskCompletingNoValueCallback ); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Delete an existing wallet record in the wallet /// </summary> /// <returns>The record async.</returns> /// <param name="wallet">Wallet.</param> /// <param name="type">Type.</param> /// <param name="id">Identifier.</param> public static Task DeleteRecordAsync(Wallet wallet, string type, string id) { ParamGuard.NotNull(wallet, "wallet"); ParamGuard.NotNullOrWhiteSpace(type, "type"); ParamGuard.NotNullOrWhiteSpace(id, "id"); var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_delete_wallet_record( commandHandle, wallet.Handle, type, id, CallbackHelper.TaskCompletingNoValueCallback); return(taskCompletionSource.Task); }
/// <summary> /// Submits a request to the ledger. /// </summary> /// <remarks> /// This method publishes a message to the validator pool specified in the <paramref name="pool"/> parameter as-is /// and assumes that the message was previously prepared for submission. Requests can be signed prior to using this /// call to the <see cref="SignRequestAsync(Wallet, string, string)"/> method, or messages can be /// both signed and submitted using the <see cref="SignAndSubmitRequestAsync(Pool, Wallet, string, string)"/> /// method. /// </remarks> /// <param name="pool">The validator pool to submit the request to.</param> /// <param name="requestJson">The request to submit.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a JSON <see cref="string"/> /// containing the results when the operation completes.</returns> public static Task <string> SubmitRequestAsync(Pool pool, string requestJson) { ParamGuard.NotNull(pool, "pool"); ParamGuard.NotNullOrWhiteSpace(requestJson, "requestJson"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_submit_request( commandHandle, pool.Handle, requestJson, _submitRequestCallback); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }
/// <summary> /// Signs the provided claim for using the key provided in the specified claim request. /// </summary> /// <remarks> /// <para> /// The <paramref name="claimReqJson"/> parameter must be passed a claim request that was previously /// created using the <see cref="ProverCreateAndStoreClaimReqAsync(Wallet, string, string, string, string)"/> /// method. Usually the claim request will be received from another party that has performed this /// action. /// </para> /// <para> /// The claim to be signed is provided in the <paramref name="claimJson"/> parameter /// and the structure of the claim must conform to the schema from claim request provided in /// the <paramref name="claimReqJson"/> parameter. Claims must be structured as a series of /// attributes, each of which has two values; a human readable value and a hex encoded value. /// <code> /// { /// "attr1" : ["value1", "value1_as_int"], /// "attr2" : ["value2", "value2_as_int"] /// } /// </code> /// For example: /// <code> /// { /// 'name': ['Alex', '1139481716457488690172217916278103335'], /// 'height': ['175', '175'] /// } /// </code> /// </para> /// <para> /// This method results a revocation registry update JSON and a newly issued claim JSON. The /// claim JSON contains the issued claim, the DID of the issuer (<c>issuer_did</c>), /// schema sequence number (<c>schema_seq_no</c>) and revocation registry sequence number (<c> /// revoc_reg_seq_no</c>) used for issuance: /// <code> /// { /// "claim": <see claim_json above>, /// "signature": <signature>, /// "revoc_reg_seq_no", string, /// "issuer_did", string, /// "schema_seq_no", string, /// } /// </code> /// </para> /// </remarks> /// <param name="wallet">The wallet containing the keys to use for signing the claim.</param> /// <param name="claimReqJson">A claim request with a blinded secret.</param> /// <param name="claimJson">A claim containing attribute values for each of requested attribute names.</param> /// <param name="userRevocIndex">The index of a new user in the revocation registry or -1 if absentee.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that, when the operation completes, resolves to /// an <see cref="IssuerCreateClaimResult"/>.</returns> public static Task <IssuerCreateClaimResult> IssuerCreateClaimAsync(Wallet wallet, string claimReqJson, string claimJson, int userRevocIndex) { var taskCompletionSource = new TaskCompletionSource <IssuerCreateClaimResult>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = IndyNativeMethods.indy_issuer_create_claim( commandHandle, wallet.Handle, claimReqJson, claimJson, userRevocIndex, _issuerCreateClaimCallback ); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Applies temporary signing and encryption keys as main in the specified wallet for an existing DID owned by the caller /// </summary> /// <param name="wallet">The wallet the DID is stored in.</param> /// <param name="did">The did to replace the keys for.</param> /// <returns>An asynchronous <see cref="Task"/> that with no return value the completes when the operation completes.</returns> public static Task ReplaceKeysApplyAsync(Wallet wallet, string did) { ParamGuard.NotNull(wallet, "wallet"); ParamGuard.NotNullOrWhiteSpace(did, "did"); var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = NativeMethods.indy_replace_keys_apply( commandHandle, wallet.Handle, did, CallbackHelper.TaskCompletingNoValueCallback); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Retrieves abbreviated verkey if it is possible otherwise return full verkey. /// </summary> /// <returns>The verkey async.</returns> /// <param name="did">Did.</param> /// <param name="fullVerkey">Full verkey.</param> public static Task <string> AbbreviateVerkeyAsync(string did, string fullVerkey) { ParamGuard.NotNullOrWhiteSpace(did, "did"); ParamGuard.NotNullOrWhiteSpace(fullVerkey, "fullVerkey"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = NativeMethods.indy_abbreviate_verkey( commandHandle, did, fullVerkey, AbbreviateVerkeyCompletedCallback ); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Gets the verification key for the specified DID. /// </summary> /// <remarks> /// This method will obtain the verification key associated with the specified <paramref name="did"/>from the provided <paramref name="wallet"/> but will /// not attempt to retrieve the key from the ledger if not present in the wallet, nor will it perform any freshness check against the ledger to determine /// if the key is up-to-date. To ensure that the key is fresh use the <see cref="KeyForDidAsync(Pool, Wallet, string)"/> method instead. /// <note type="note"> /// The <see cref="CreateAndStoreMyDidAsync(Wallet, string)"/> and <see cref="Crypto.CreateKeyAsync(Wallet, string)"/> methods both create /// similar wallet records so the returned verification key in all generic crypto and messaging functions. /// </note> /// </remarks> /// <param name="wallet">The wallet to resolve the DID from.</param> /// <param name="did">The DID to get the verification key for.</param> /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to a string containing the verification key associated with the DID.</returns> /// <exception cref="WalletItemNotFoundException">Thrown if the DID could not be resolved from the <paramref name="wallet"/>.</exception> public static Task <string> KeyForLocalDidAsync(Wallet wallet, string did) { ParamGuard.NotNull(wallet, "wallet"); ParamGuard.NotNullOrWhiteSpace(did, "did"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = NativeMethods.indy_key_for_local_did( commandHandle, wallet.Handle, did, KeyForLocalDidCompletedCallback ); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Get info about My DID in format: DID, verkey, metadata /// </summary> /// <returns>The my did with meta async.</returns> /// <param name="wallet">Wallet.</param> /// <param name="myDid">My did.</param> public static Task <string> GetMyDidWithMetaAsync(Wallet wallet, string myDid) { ParamGuard.NotNull(wallet, "wallet"); ParamGuard.NotNullOrWhiteSpace(myDid, "myDid"); var taskCompletionSource = new TaskCompletionSource <string>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var commandResult = NativeMethods.indy_get_my_did_with_meta( commandHandle, wallet.Handle, myDid, GetMyDidWithMetaCompletedCallback ); CallbackHelper.CheckResult(commandResult); return(taskCompletionSource.Task); }
/// <summary> /// Opens the BLOB storage writer async. /// </summary> /// <returns>The BLOB storage writer async.</returns> /// <param name="type">Type.</param> /// <param name="configJson">Config json.</param> public static Task <BlobStorageWriter> OpenWriterAsync(string type, string configJson) { ParamGuard.NotNullOrWhiteSpace(type, "type"); ParamGuard.NotNullOrWhiteSpace(configJson, "configJson"); var taskCompletionSource = new TaskCompletionSource <BlobStorageWriter>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = NativeMethods.indy_open_blob_storage_writer( commandHandle, type, configJson, _openWriterCallback ); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }