Exemplo n.º 1
0
        /// <summary>
        /// Creates a proof for the provided proof request.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Either a corresponding claim with optionally revealed attributes or self-attested attribute
        /// must be provided for each requested attribute - see the
        /// <see cref="ProverGetClaimsForProofReqAsync(Wallet, string)"/> method.
        /// A proof request may request multiple claims from different schema and different issuers.
        /// All required schema, public keys and revocation registries must be provided.
        /// The proof request also contains a nonce.
        /// The proof contains either proof or self-attested attribute value for each requested attribute.
        /// </para>
        /// <para>
        /// The <paramref name="proofReqJson"/> parameter expects a JSON string containing a proof request
        /// from the party that will verify the proof.  E.g.:
        /// <code>
        ///  {
        ///     "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>
        /// </para>
        /// <para>
        /// The <paramref name="requestedClaimsJson"/> parameter should contain either a claim or a
        /// self-attested attribute for each attribute requested in the proof request.  E.g.:
        /// <code>
        /// {
        ///     "requested_attr1_uuid": [claim1_uuid_in_wallet, true &lt;reveal_attr&gt;],
        ///     "requested_attr2_uuid": [self_attested_attribute],
        ///     "requested_attr3_uuid": [claim2_seq_no_in_wallet, false]
        ///     "requested_attr4_uuid": [claim2_seq_no_in_wallet, true]
        ///     "requested_predicate_1_uuid": [claim2_seq_no_in_wallet],
        ///     "requested_predicate_2_uuid": [claim3_seq_no_in_wallet],
        /// }
        /// </code>
        /// </para>
        /// <para>
        /// The <paramref name="schemasJson"/> parameter expects the JSON for each schema that participates
        /// in the proof request.  E.g.:
        /// <code>
        /// {
        ///     "claim1_uuid_in_wallet": &lt;schema1&gt;,
        ///     "claim2_uuid_in_wallet": &lt;schema2&gt;,
        ///     "claim3_uuid_in_wallet": &lt;schema3&gt;,
        /// }
        /// </code>
        /// </para>
        /// <para>
        /// The <paramref name="masterSecretName"/> specifies the name of the master secret stored in
        /// the wallet.
        /// </para>
        /// <para>
        /// The <paramref name="claimDefsJson"/> parameter expects the JSON for each claim definition
        /// participating in the proof request. E.g.:
        /// <code>
        /// {
        ///     "claim1_uuid_in_wallet": &lt;claim_def1&gt;,
        ///     "claim2_uuid_in_wallet": &lt;claim_def2&gt;,
        ///     "claim3_uuid_in_wallet": &lt;claim_def3&gt;,
        /// }
        /// </code>
        /// </para>
        /// <para>
        /// The <paramref name="revocRegsJson"/> parameter expects the JSON for each revocation registry
        /// participating in the proof request.  E.g.:
        /// <code>
        /// {
        ///     "claim1_uuid_in_wallet": &lt;revoc_reg1&gt;,
        ///     "claim2_uuid_in_wallet": &lt;revoc_reg2&gt;,
        ///     "claim3_uuid_in_wallet": &lt;revoc_reg3&gt;,
        /// }
        /// </code>
        /// </para>
        /// Upon successful completion the operation will return a JSON string.
        /// For each requested attribute either a proof (with optionally revealed attribute value) or
        /// self-attested attribute value is provided.
        /// Each proof is associated with a claim and corresponding schema_seq_no, issuer_did and revoc_reg_seq_no.
        /// There is also aggregated proof part common for all claim proofs.
        /// <code>
        /// {
        ///     "requested": {
        ///         "requested_attr1_id": [claim_proof1_uuid, revealed_attr1, revealed_attr1_as_int],
        ///         "requested_attr2_id": [self_attested_attribute],
        ///         "requested_attr3_id": [claim_proof2_uuid]
        ///         "requested_attr4_id": [claim_proof2_uuid, revealed_attr4, revealed_attr4_as_int],
        ///         "requested_predicate_1_uuid": [claim_proof2_uuid],
        ///         "requested_predicate_2_uuid": [claim_proof3_uuid],
        ///         }
        ///     "claim_proofs": {
        ///         "claim_proof1_uuid": [&lt;claim_proof&gt;, issuer_did, schema_seq_no, revoc_reg_seq_no],
        ///         "claim_proof2_uuid": [&lt;claim_proof&gt;, issuer_did, schema_seq_no, revoc_reg_seq_no],
        ///         "claim_proof3_uuid": [&lt;claim_proof&gt;, issuer_did, schema_seq_no, revoc_reg_seq_no]
        ///     },
        ///     "aggregated_proof": &lt;aggregated_proof&gt;
        /// }
        /// </code>
        /// </remarks>
        /// <param name="wallet">The target wallet.</param>
        /// <param name="proofReqJson">The proof request JSON.</param>
        /// <param name="requestedClaimsJson">The requested claims JSON.</param>
        /// <param name="schemasJson">The schema JSON.</param>
        /// <param name="masterSecretName">The master secret name.</param>
        /// <param name="claimDefsJson">The claim definitions JSON.</param>
        /// <param name="revocRegsJson">The revocation registries JSON.</param>
        /// <returns>An asynchronous <see cref="Task{T}"/> that, when the operation completes, resolves
        /// to a JSON string containing the proof.</returns>
        public static Task <string> ProverCreateProofAsync(Wallet wallet, string proofReqJson, string requestedClaimsJson, string schemasJson, string masterSecretName, string claimDefsJson, string revocRegsJson)
        {
            ParamGuard.NotNull(wallet, "wallet");
            ParamGuard.NotNullOrWhiteSpace(proofReqJson, "proofReqJson");
            ParamGuard.NotNullOrWhiteSpace(requestedClaimsJson, "requestedClaimsJson");
            ParamGuard.NotNullOrWhiteSpace(schemasJson, "schemasJson");
            ParamGuard.NotNullOrWhiteSpace(masterSecretName, "masterSecretName");
            ParamGuard.NotNullOrWhiteSpace(claimDefsJson, "claimDefsJson");
            ParamGuard.NotNullOrWhiteSpace(revocRegsJson, "revocRegsJson");

            var taskCompletionSource = new TaskCompletionSource <string>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var commandResult = IndyNativeMethods.indy_prover_create_proof(
                commandHandle,
                wallet.Handle,
                proofReqJson,
                requestedClaimsJson,
                schemasJson,
                masterSecretName,
                claimDefsJson,
                revocRegsJson,
                _proverCreateProofCallback);

            CallbackHelper.CheckResult(commandResult);

            return(taskCompletionSource.Task);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a proof for a prover.
        /// </summary>
        /// <param name="wallet">The target wallet.</param>
        /// <param name="proofReqJson">The proof request JSON.</param>
        /// <param name="requestedClaimsJson">The requested claims JSON.</param>
        /// <param name="schemasJson">The schemas JSON.</param>
        /// <param name="masterSecretName">The master secret name.</param>
        /// <param name="claimDefsJson">The claim definitions JSON.</param>
        /// <param name="revocRegsJson">The recovation registries JSON.</param>
        /// <returns>An asynchronous task that returns proof JSON.</returns>
        public static Task <string> ProverCreateProofAsync(Wallet wallet, string proofReqJson, string requestedClaimsJson, string schemasJson, string masterSecretName, string claimDefsJson, string revocRegsJson)
        {
            var taskCompletionSource = new TaskCompletionSource <string>();
            var commandHandle        = AddTaskCompletionSource(taskCompletionSource);

            var commandResult = IndyNativeMethods.indy_prover_create_proof(
                commandHandle,
                wallet.Handle,
                proofReqJson,
                requestedClaimsJson,
                schemasJson,
                masterSecretName,
                claimDefsJson,
                revocRegsJson,
                _proverCreateProofCallback);

            CheckResult(commandResult);

            return(taskCompletionSource.Task);
        }