Exemplo n.º 1
0
        /// <summary>
        /// Gets claims matching the provided proof request from the specified wallet.
        /// </summary>
        /// <remarks>
        /// The proof request provided in the <paramref name="proofRequestJson"/> parameter must conform
        /// to the format:
        /// <code>
        /// {
        ///     "name": string,
        ///     "version": string,
        ///     "nonce": string,
        ///     "requested_attr1_uuid": &lt;attr_info&gt;,
        ///     "requested_attr2_uuid": &lt;attr_info&gt;,
        ///     "requested_attr3_uuid": &lt;attr_info&gt;,
        ///     "requested_predicate_1_uuid": &lt;predicate_info&gt;,
        ///     "requested_predicate_2_uuid": &lt;predicate_info&gt;,
        /// }
        /// </code>
        /// The method will return a JSON string with claims matching the given proof request in the following format:
        /// <code>
        /// {
        ///     "requested_attr1_uuid": [claim1, claim2],
        ///     "requested_attr2_uuid": [],
        ///     "requested_attr3_uuid": [claim3],
        ///     "requested_predicate_1_uuid": [claim1, claim3],
        ///     "requested_predicate_2_uuid": [claim2],
        /// }
        /// </code>
        /// Each claim in the result consists of a uuid (<c>claim_uuid</c>), human-readable attributes as
        /// a key-value map (<c>attrs</c>), a schema sequence number (<c>schema_seq_no</c>) an issuer DID
        /// (<c>issuer_did</c>) and a revocation registry sequence number (<c>revoc_reg_seq_no</c>):
        /// <code>
        /// {
        ///     "claim_uuid": string,
        ///     "attrs": [{"attr_name" : "attr_value"}],
        ///     "schema_seq_no": string,
        ///     "issuer_did": string,
        ///     "revoc_reg_seq_no": string,
        /// }
        /// </code>
        /// </remarks>
        /// <param name="wallet">The target wallet.</param>
        /// <param name="proofRequestJson">The proof request JSON.</param>
        /// <returns>An asynchronous <see cref="Task{T}"/> that, when the operation completes, resolves
        /// to a JSON string containing the claims for the proof request.</returns>
        public static Task <string> ProverGetClaimsForProofReqAsync(Wallet wallet, string proofRequestJson)
        {
            var taskCompletionSource = new TaskCompletionSource <string>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var commandResult = IndyNativeMethods.indy_prover_get_claims_for_proof_req(
                commandHandle,
                wallet.Handle,
                proofRequestJson,
                _proverGetClaimsForProofCallback
                );

            CallbackHelper.CheckResult(commandResult);

            return(taskCompletionSource.Task);
        }