gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-exchange] branch master updated (a497ccff -> 4785bcb


From: gnunet
Subject: [GNUnet-SVN] [taler-exchange] branch master updated (a497ccff -> 4785bcb4)
Date: Mon, 15 Jul 2019 22:01:08 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository exchange.

    from a497ccff integrate test for #5777 into build, expected to fail for now
     new 28f790fa fix use of index in testing_api_cmd_refresh.c
     new 4785bcb4 towards #5777, adding todos/notes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/taler_crypto_lib.h         |  22 +++++
 src/include/taler_exchange_service.h   |  10 +-
 src/include/taler_testing_lib.h        |   6 +-
 src/lib/.gitignore                     |   1 +
 src/lib/test_exchange_api_revocation.c |   4 +-
 src/lib/testing_api_cmd_payback.c      |  37 +++++++-
 src/lib/testing_api_cmd_refresh.c      | 166 ++++++++++++++++++---------------
 src/lib/testing_api_trait_denom_pub.c  |   1 -
 8 files changed, 161 insertions(+), 86 deletions(-)

diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 18c214e1..4024123b 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -434,6 +434,28 @@ struct TALER_PlanchetSecretsP
 
 };
 
+
+/**
+ * Header for serializations of coin-specific information about the fresh
+ * coins we generate from refresh.  These are the secrets that arise during
+ * planchet generation, which is the first stage of creating a new coin from
+ * refresh.
+ */
+struct TALER_RefreshPlanchetSecretsP
+{
+
+  /**
+   * Private key of the coin.
+   */
+  struct TALER_CoinSpendPrivateKeyP coin_priv;
+
+  /**
+   * XXX. See #5777~0014690 - need a solution for this first!
+   */
+  struct TALER_TransferPrivateKeyP transfer_priv;
+
+};
+
 GNUNET_NETWORK_STRUCT_END
 
 
diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 880e6038..eebbf6c5 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -1130,7 +1130,7 @@ struct TALER_EXCHANGE_ReserveWithdrawHandle;
 typedef void
 (*TALER_EXCHANGE_ReserveWithdrawResultCallback) (void *cls,
                                                  unsigned int http_status,
-                                                enum TALER_ErrorCode ec,
+                                                 enum TALER_ErrorCode ec,
                                                  const struct 
TALER_DenominationSignature *sig,
                                                  const json_t *full_response);
 
@@ -1287,8 +1287,8 @@ struct TALER_EXCHANGE_RefreshMeltHandle;
 typedef void
 (*TALER_EXCHANGE_RefreshMeltCallback) (void *cls,
                                        unsigned int http_status,
-                                      enum TALER_ErrorCode ec,
-                                      uint32_t noreveal_index,
+                                       enum TALER_ErrorCode ec,
+                                       uint32_t noreveal_index,
                                        const struct TALER_ExchangePublicKeyP 
*sign_key,
                                        const json_t *full_response);
 
@@ -1354,8 +1354,10 @@ TALER_EXCHANGE_refresh_melt_cancel (struct 
TALER_EXCHANGE_RefreshMeltHandle *rmh
 typedef void
 (*TALER_EXCHANGE_RefreshRevealCallback) (void *cls,
                                          unsigned int http_status,
-                                        enum TALER_ErrorCode ec,
+                                         enum TALER_ErrorCode ec,
                                          unsigned int num_coins,
+                                         /* TODO (#5777): possibly replace
+                                            by a `struct 
TALER_RefreshPlanchetSecretsP` */
                                          const struct 
TALER_CoinSpendPrivateKeyP *coin_privs,
                                          const struct 
TALER_DenominationSignature *sigs,
                                          const json_t *full_response);
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
index 99be529b..20641002 100644
--- a/src/include/taler_testing_lib.h
+++ b/src/include/taler_testing_lib.h
@@ -1384,7 +1384,9 @@ TALER_TESTING_cmd_refund (const char *label,
  * @param label the command label
  * @param expected_response_code expected HTTP status code
  * @param coin_reference reference to any command which
- *        offers a coin & reserve private key.
+ *        offers a coin and reserve private key.  May specify
+ *        the index of the coin using "$LABEL#$INDEX" syntax.
+ *        Here, $INDEX must be a non-negative number.
  * @param amount denomination to pay back.
  *
  * @return the command.
@@ -1948,6 +1950,8 @@ TALER_TESTING_get_trait_uint
 /**
  * Information about a fresh coin generated by the refresh
  * operation. FIXME: should go away from here!
+ *
+ * FIXME: should be renamed, easily confused with `struct TALER_FreshCoin`!
  */
 struct FreshCoin
 {
diff --git a/src/lib/.gitignore b/src/lib/.gitignore
index 20268443..77a0f711 100644
--- a/src/lib/.gitignore
+++ b/src/lib/.gitignore
@@ -1 +1,2 @@
 test_auditor_api_version
+test_exchange_api_revocation
diff --git a/src/lib/test_exchange_api_revocation.c 
b/src/lib/test_exchange_api_revocation.c
index 08be5020..e2e3e4b4 100644
--- a/src/lib/test_exchange_api_revocation.c
+++ b/src/lib/test_exchange_api_revocation.c
@@ -161,7 +161,7 @@ run (void *cls,
     /* Refund coin to original coin */
     TALER_TESTING_cmd_payback ("payback-1",
                                MHD_HTTP_OK,
-                               "refresh-melt-1",
+                               "refresh-reveal-1",
                                "EUR:5"),
     /**
      * Melt original coin AGAIN
@@ -178,7 +178,7 @@ run (void *cls,
     /* Make refreshed coin invalid */
     TALER_TESTING_cmd_revoke ("revoke-2",
                               MHD_HTTP_OK,
-                              "refresh-melt-2",
+                              "refresh-reveal-2",
                               CONFIG_FILE),
     /* Make also original coin invalid */
     TALER_TESTING_cmd_revoke ("revoke-3",
diff --git a/src/lib/testing_api_cmd_payback.c 
b/src/lib/testing_api_cmd_payback.c
index 9b49108c..ac4fd641 100644
--- a/src/lib/testing_api_cmd_payback.c
+++ b/src/lib/testing_api_cmd_payback.c
@@ -124,7 +124,6 @@ payback_cb (void *cls,
             const struct TALER_ReservePublicKeyP *reserve_pub,
             const json_t *full_response)
 {
-
   struct PaybackState *ps = cls;
   struct TALER_TESTING_Interpreter *is = ps->is;
   struct TALER_TESTING_Command *cmd = &is->commands[is->ip];
@@ -132,6 +131,9 @@ payback_cb (void *cls,
   const struct TALER_ReservePrivateKeyP *reserve_priv;
   struct TALER_ReservePublicKeyP rp;
   struct TALER_Amount expected_amount;
+  char *cref;
+  const char *index;
+  unsigned int idx;
 
   ps->ph = NULL;
   if (ps->expected_response_code != http_status)
@@ -148,8 +150,37 @@ payback_cb (void *cls,
     return;
   }
 
+  /* We allow command referneces of the form "$LABEL#$INDEX" or
+     just "$LABEL", which implies the index is 0. Figure out
+     which one it is. */
+  index = strchr (ps->coin_reference, '#');
+  if (NULL == index)
+  {
+    idx = 0;
+    cref = GNUNET_strdup (ps->coin_reference);
+  }
+  else
+  {
+    cref = GNUNET_strndup (ps->coin_reference,
+                           index - ps->coin_reference);
+    if (1 != sscanf (index,
+                     "%u",
+                     &idx))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Numeric index (not `%s') required after `#' in command 
reference of command %s in %s:%u\n",
+                  index,
+                  cmd->label,
+                  __FILE__,
+                  __LINE__);
+      TALER_TESTING_interpreter_fail (is);
+      GNUNET_free (cref);
+      return;
+    }
+  }
   reserve_cmd = TALER_TESTING_interpreter_lookup_command
-    (is, ps->coin_reference);
+    (is, cref);
+  GNUNET_free (cref);
 
   if (NULL == reserve_cmd)
   {
@@ -159,7 +190,7 @@ payback_cb (void *cls,
   }
 
   if (GNUNET_OK != TALER_TESTING_get_trait_reserve_priv
-    (reserve_cmd, 0, &reserve_priv))
+    (reserve_cmd, idx, &reserve_priv))
   {
     GNUNET_break (0);
     TALER_TESTING_interpreter_fail (is);
diff --git a/src/lib/testing_api_cmd_refresh.c 
b/src/lib/testing_api_cmd_refresh.c
index d0b589b1..3fb52d83 100644
--- a/src/lib/testing_api_cmd_refresh.c
+++ b/src/lib/testing_api_cmd_refresh.c
@@ -83,7 +83,7 @@ struct RefreshMeltState
 
   /**
    * Array of the denomination public keys
-   * corresponding to the @e fresh_amounts.
+   * corresponding to the @e num_fresh_coins;
    */
   struct TALER_EXCHANGE_DenomPublicKey *fresh_pks;
 
@@ -103,6 +103,11 @@ struct RefreshMeltState
   size_t refresh_data_length;
 
   /**
+   * Number of fresh coins generated by the melt.
+   */
+  unsigned int num_fresh_coins;
+
+  /**
    * Expected HTTP response code.
    */
   unsigned int expected_response_code;
@@ -282,7 +287,7 @@ do_reveal_retry (void *cls)
 static void
 reveal_cb (void *cls,
            unsigned int http_status,
-          enum TALER_ErrorCode ec,
+           enum TALER_ErrorCode ec,
            unsigned int num_coins,
            const struct TALER_CoinSpendPrivateKeyP *coin_privs,
            const struct TALER_DenominationSignature *sigs,
@@ -340,24 +345,19 @@ reveal_cb (void *cls,
   case MHD_HTTP_OK:
     rrs->fresh_coins = GNUNET_new_array
       (num_coins, struct FreshCoin);
-
-    const struct TALER_EXCHANGE_DenomPublicKey *fresh_pks;
-
-    if (GNUNET_OK !=
-        TALER_TESTING_get_trait_denom_pub (melt_cmd,
-                                           0,
-                                           &fresh_pks))
-    {
-      GNUNET_break (0);
-      TALER_TESTING_interpreter_fail (rrs->is);
-      return;
-    }
-
     for (unsigned int i=0; i<num_coins; i++)
     {
       struct FreshCoin *fc = &rrs->fresh_coins[i];
 
-      fc->pk = &fresh_pks[i];
+      if (GNUNET_OK !=
+          TALER_TESTING_get_trait_denom_pub (melt_cmd,
+                                             i,
+                                             &fc->pk))
+      {
+        GNUNET_break (0);
+        TALER_TESTING_interpreter_fail (rrs->is);
+        return;
+      }
       fc->coin_priv = coin_privs[i];
       fc->sig.rsa_signature = GNUNET_CRYPTO_rsa_signature_dup
         (sigs[i].rsa_signature);
@@ -611,18 +611,18 @@ link_cb (void *cls,
     for (unsigned int i=0;i<num_coins;i++)
       for (unsigned int j=0;j<num_coins;j++)
       {
-       if ( (0 == GNUNET_memcmp
-          (&coin_privs[i], &fc[j].coin_priv)) &&
-            (0 == GNUNET_CRYPTO_rsa_signature_cmp
-                (fc[i].sig.rsa_signature,
-                 sigs[j].rsa_signature)) &&
-            (0 == GNUNET_CRYPTO_rsa_public_key_cmp
-               (fc[i].pk->key.rsa_public_key,
-                pubs[j].rsa_public_key)) )
-       {
-         found++;
-         break;
-       }
+        if ( (0 == GNUNET_memcmp
+              (&coin_privs[i], &fc[j].coin_priv)) &&
+             (0 == GNUNET_CRYPTO_rsa_signature_cmp
+              (fc[i].sig.rsa_signature,
+               sigs[j].rsa_signature)) &&
+             (0 == GNUNET_CRYPTO_rsa_public_key_cmp
+              (fc[i].pk->key.rsa_public_key,
+               pubs[j].rsa_public_key)) )
+        {
+          found++;
+          break;
+        }
       }
     if (found != num_coins)
     {
@@ -799,7 +799,7 @@ do_melt_retry (void *cls)
 static void
 melt_cb (void *cls,
          unsigned int http_status,
-        enum TALER_ErrorCode ec,
+         enum TALER_ErrorCode ec,
          uint32_t noreveal_index,
          const struct TALER_ExchangePublicKeyP *exchange_pub,
          const json_t *full_response)
@@ -883,7 +883,7 @@ refresh_melt_run (void *cls,
   for (num_fresh_coins=0;
        NULL != melt_fresh_amounts[num_fresh_coins];
        num_fresh_coins++) ;
-
+  rms->num_fresh_coins = num_fresh_coins;
   rms->fresh_pks = GNUNET_new_array
     (num_fresh_coins,
      struct TALER_EXCHANGE_DenomPublicKey);
@@ -935,13 +935,12 @@ refresh_melt_run (void *cls,
       return;
     }
     if (GNUNET_OK != TALER_TESTING_get_trait_denom_pub
-      (coin_command, 0, &melt_denom_pub))
+        (coin_command, 0, &melt_denom_pub))
     {
       GNUNET_break (0);
       TALER_TESTING_interpreter_fail (rms->is);
       return;
     }
-
     for (unsigned int i=0;i<num_fresh_coins;i++)
     {
       const struct TALER_EXCHANGE_DenomPublicKey *fresh_pk;
@@ -1035,7 +1034,6 @@ refresh_melt_cleanup (void *cls,
  * @param ret[out] result (could be anything).
  * @param trait name of the trait.
  * @param index index number of the object to offer.
- *
  * @return #GNUNET_OK on success.
  */
 static int
@@ -1046,15 +1044,22 @@ refresh_melt_traits (void *cls,
 {
   struct RefreshMeltState *rms = cls;
 
-  struct TALER_TESTING_Trait traits[] = {
-    TALER_TESTING_make_trait_denom_pub (0, rms->fresh_pks),
-    TALER_TESTING_trait_end ()
-  };
-
-  return TALER_TESTING_get_trait (traits,
-                                  ret,
-                                  trait,
-                                  index);
+  if (index >= rms->num_fresh_coins)
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
+  {
+    struct TALER_TESTING_Trait traits[] = {
+      TALER_TESTING_make_trait_denom_pub (index, &rms->fresh_pks[index]),
+      TALER_TESTING_trait_end ()
+    };
+
+    return TALER_TESTING_get_trait (traits,
+                                    ret,
+                                    trait,
+                                    index);
+  }
 }
 
 
@@ -1081,20 +1086,20 @@ TALER_TESTING_cmd_refresh_melt
 
   md.coin_reference = coin_reference;
   md.amount = amount;
-
   rms = GNUNET_new (struct RefreshMeltState);
   rms->melted_coin = md;
   rms->expected_response_code = expected_response_code;
-
-  struct TALER_TESTING_Command cmd = {
-    .label = label,
-    .cls = rms,
-    .run = &refresh_melt_run,
-    .cleanup = &refresh_melt_cleanup,
-    .traits = &refresh_melt_traits
-  };
-
-  return cmd;
+  {
+    struct TALER_TESTING_Command cmd = {
+      .label = label,
+      .cls = rms,
+      .run = &refresh_melt_run,
+      .cleanup = &refresh_melt_cleanup,
+      .traits = &refresh_melt_traits
+    };
+
+    return cmd;
+  }
 }
 
 
@@ -1109,7 +1114,6 @@ TALER_TESTING_cmd_refresh_melt
  * @param coin_reference reference to a command that will provide
  *        a coin to refresh
  * @param expected_response_code expected HTTP code
- *
  * @return the command.
  */
 struct TALER_TESTING_Command
@@ -1124,21 +1128,21 @@ TALER_TESTING_cmd_refresh_melt_double
 
   md.coin_reference = coin_reference;
   md.amount = amount;
-
   rms = GNUNET_new (struct RefreshMeltState);
   rms->melted_coin = md;
   rms->expected_response_code = expected_response_code;
   rms->double_melt = GNUNET_YES;
-
-  struct TALER_TESTING_Command cmd = {
-    .label = label,
-    .cls = rms,
-    .run = &refresh_melt_run,
-    .cleanup = &refresh_melt_cleanup,
-    .traits = &refresh_melt_traits
-  };
-
-  return cmd;
+  {
+    struct TALER_TESTING_Command cmd = {
+      .label = label,
+      .cls = rms,
+      .run = &refresh_melt_run,
+      .cleanup = &refresh_melt_cleanup,
+      .traits = &refresh_melt_traits
+    };
+
+    return cmd;
+  }
 }
 
 
@@ -1197,6 +1201,17 @@ refresh_reveal_traits (void *cls,
     traits[(num_coins * 2) + i]
       = TALER_TESTING_make_trait_denom_sig
         (i, &rrs->fresh_coins[i].sig);
+#if 0
+  /* FIXME: need *some* trait for #5777 here, but we don't have
+     the blinding keys at hand, and #5777 asks for the transfer
+     private keys, which according to bugnote 14690 is a bad idea.
+     So what should we do here? */
+  /* blinding key traits */
+  for (unsigned int i=0; i<num_coins; i++)
+    traits[(num_coins * 3) + i]
+      = TALER_TESTING_make_trait_blinding_key (i,
+                                               
&rrs->fresh_coins[i].blinding_key),
+#endif
 
   /* number of fresh coins */
   traits[(num_coins * 3)] = TALER_TESTING_make_trait_uint
@@ -1237,16 +1252,17 @@ TALER_TESTING_cmd_refresh_reveal
   rrs = GNUNET_new (struct RefreshRevealState);
   rrs->melt_reference = melt_reference;
   rrs->expected_response_code = expected_response_code;
-
-  struct TALER_TESTING_Command cmd = {
-    .cls = rrs,
-    .label = label,
-    .run = &refresh_reveal_run,
-    .cleanup = &refresh_reveal_cleanup,
-    .traits = &refresh_reveal_traits
-  };
-
-  return cmd;
+  {
+    struct TALER_TESTING_Command cmd = {
+      .cls = rrs,
+      .label = label,
+      .run = &refresh_reveal_run,
+      .cleanup = &refresh_reveal_cleanup,
+      .traits = &refresh_reveal_traits
+    };
+
+    return cmd;
+  }
 }
 
 
diff --git a/src/lib/testing_api_trait_denom_pub.c 
b/src/lib/testing_api_trait_denom_pub.c
index 448a262c..8bc48217 100644
--- a/src/lib/testing_api_trait_denom_pub.c
+++ b/src/lib/testing_api_trait_denom_pub.c
@@ -59,7 +59,6 @@ TALER_TESTING_get_trait_denom_pub
  *
  * @param index index number to associate to the offered denom pub.
  * @param denom_pub denom pub to offer with this trait.
- *
  * @return the trait.
  */
 struct TALER_TESTING_Trait

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]