Example #1
0
        /// <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": &lt;see claim_json above&gt;,
        ///     "signature": &lt;signature&gt;,
        ///     "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);
        }