gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: more BS bugfixes


From: gnunet
Subject: [taler-exchange] branch master updated: more BS bugfixes
Date: Sat, 28 Oct 2023 02:01:38 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 58783a8f more BS bugfixes
58783a8f is described below

commit 58783a8f2859f1bffc48a3417e6d66f76774a896
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Oct 28 02:01:35 2023 +0200

    more BS bugfixes
---
 src/lib/exchange_api_age_withdraw.c     | 54 +++++++++---------
 src/lib/exchange_api_batch_withdraw.c   | 97 ++++++++++++++-------------------
 src/lib/exchange_api_refreshes_reveal.c | 10 +---
 src/testing/testing_api_cmd_withdraw.c  |  4 +-
 4 files changed, 74 insertions(+), 91 deletions(-)

diff --git a/src/lib/exchange_api_age_withdraw.c 
b/src/lib/exchange_api_age_withdraw.c
index 6c6460b2..5111a56a 100644
--- a/src/lib/exchange_api_age_withdraw.c
+++ b/src/lib/exchange_api_age_withdraw.c
@@ -813,7 +813,9 @@ csr_withdraw_done (
     {
       bool success = false;
       /* Complete the initialization of the coin with CS denomination */
-      can->details.alg_values = csrr->details.ok.alg_values;
+
+      TALER_denom_ewv_deep_copy (&can->details.alg_values,
+                                 &csrr->details.ok.alg_values);
       GNUNET_assert (can->details.alg_values.blinding_inputs->cipher
                      == GNUNET_CRYPTO_BSA_CS);
       TALER_planchet_setup_coin_priv (&can->secret,
@@ -863,7 +865,6 @@ csr_withdraw_done (
   default:
     break;
   }
-
   TALER_EXCHANGE_age_withdraw_cancel (awh);
 }
 
@@ -907,11 +908,10 @@ prepare_coins (
   {
     struct CoinData *cd = &awh->coin_data[i];
     const struct TALER_EXCHANGE_AgeWithdrawCoinInput *input = &coin_inputs[i];
-    cd->denom_pub = *input->denom_pub;
 
+    cd->denom_pub = *input->denom_pub;
     /* The mask must be the same for all coins */
     FAIL_IF (awh->age_mask.bits != input->denom_pub->key.age_mask.bits);
-
     TALER_denom_pub_deep_copy (&cd->denom_pub.key,
                                &input->denom_pub->key);
 
@@ -935,28 +935,28 @@ prepare_coins (
       switch (input->denom_pub->key.bsign_pub_key->cipher)
       {
       case GNUNET_CRYPTO_BSA_RSA:
-        {
-          TALER_planchet_setup_coin_priv (&can->secret,
-                                          &can->details.alg_values,
-                                          &can->details.coin_priv);
-          TALER_planchet_blinding_secret_create (&can->secret,
-                                                 &can->details.alg_values,
-                                                 &can->details.blinding_key);
-          FAIL_IF (GNUNET_OK !=
-                   TALER_planchet_prepare (&cd->denom_pub.key,
-                                           NULL,
-                                           &can->details.blinding_key,
-                                           NULL,
-                                           &can->details.coin_priv,
-                                           &can->details.h_age_commitment,
-                                           &can->details.h_coin_pub,
-                                           planchet));
-          FAIL_IF (GNUNET_OK !=
-                   TALER_coin_ev_hash (&planchet->blinded_planchet,
-                                       &planchet->denom_pub_hash,
-                                       &can->blinded_coin_h));
-          break;
-        }
+        TALER_denom_ewv_deep_copy (&can->details.alg_values,
+                                   TALER_denom_ewv_rsa_singleton ());
+        TALER_planchet_setup_coin_priv (&can->secret,
+                                        &can->details.alg_values,
+                                        &can->details.coin_priv);
+        TALER_planchet_blinding_secret_create (&can->secret,
+                                               &can->details.alg_values,
+                                               &can->details.blinding_key);
+        FAIL_IF (GNUNET_OK !=
+                 TALER_planchet_prepare (&cd->denom_pub.key,
+                                         NULL,
+                                         &can->details.blinding_key,
+                                         NULL,
+                                         &can->details.coin_priv,
+                                         &can->details.h_age_commitment,
+                                         &can->details.h_coin_pub,
+                                         planchet));
+        FAIL_IF (GNUNET_OK !=
+                 TALER_coin_ev_hash (&planchet->blinded_planchet,
+                                     &planchet->denom_pub_hash,
+                                     &can->blinded_coin_h));
+        break;
       case GNUNET_CRYPTO_BSA_CS:
         {
           struct CSRClosure *cls = &cd->csr_cls[k];
@@ -1052,6 +1052,7 @@ TALER_EXCHANGE_age_withdraw_cancel (
     {
       struct TALER_PlanchetDetail *planchet = &cd->planchet_details[k];
       struct CSRClosure *cls = &cd->csr_cls[k];
+      struct CoinCandidate *can = &cd->coin_candidates[k];
 
       if (NULL != cls->csr_withdraw_handle)
       {
@@ -1059,6 +1060,7 @@ TALER_EXCHANGE_age_withdraw_cancel (
         cls->csr_withdraw_handle = NULL;
       }
       TALER_blinded_planchet_free (&planchet->blinded_planchet);
+      TALER_denom_ewv_free (&can->details.alg_values);
     }
     TALER_denom_pub_free (&cd->denom_pub.key);
   }
diff --git a/src/lib/exchange_api_batch_withdraw.c 
b/src/lib/exchange_api_batch_withdraw.c
index b8d40ef7..cd3286f3 100644
--- a/src/lib/exchange_api_batch_withdraw.c
+++ b/src/lib/exchange_api_batch_withdraw.c
@@ -192,10 +192,6 @@ handle_reserve_batch_withdraw_finished (
         struct CoinData *cd = &wh->coins[i];
         struct TALER_EXCHANGE_PrivateCoinDetails *coin = &coins[i];
         struct TALER_FreshCoin fc;
-        const struct TALER_ExchangeWithdrawValues *alg_values
-          = (GNUNET_CRYPTO_BSA_RSA != cd->pk.key.bsign_pub_key->cipher)
-          ? &cd->alg_values
-          : TALER_denom_ewv_rsa_singleton ();
 
         if (GNUNET_OK !=
             TALER_planchet_to_coin (&cd->pk.key,
@@ -204,7 +200,7 @@ handle_reserve_batch_withdraw_finished (
                                     &cd->priv,
                                     cd->ach,
                                     &cd->c_hash,
-                                    alg_values,
+                                    &cd->alg_values,
                                     &fc))
         {
           wr.hr.http_status = 0;
@@ -308,9 +304,8 @@ withdraw_cs_stage_two_callback (
   switch (csrr->hr.http_status)
   {
   case MHD_HTTP_OK:
-    cd->alg_values.blinding_inputs
-      = GNUNET_CRYPTO_blinding_input_values_incref (
-          csrr->details.ok.alg_values.blinding_inputs);
+    TALER_denom_ewv_deep_copy (&cd->alg_values,
+                               &csrr->details.ok.alg_values);
     TALER_planchet_setup_coin_priv (&cd->ps,
                                     &cd->alg_values,
                                     &cd->priv);
@@ -380,53 +375,48 @@ TALER_EXCHANGE_batch_withdraw (
     switch (wci->pk->key.bsign_pub_key->cipher)
     {
     case GNUNET_CRYPTO_BSA_RSA:
+      TALER_denom_ewv_deep_copy (&cd->alg_values,
+                                 TALER_denom_ewv_rsa_singleton ());
+      TALER_planchet_setup_coin_priv (&cd->ps,
+                                      &cd->alg_values,
+                                      &cd->priv);
+      TALER_planchet_blinding_secret_create (&cd->ps,
+                                             &cd->alg_values,
+                                             &cd->bks);
+      if (GNUNET_OK !=
+          TALER_planchet_prepare (&cd->pk.key,
+                                  &cd->alg_values,
+                                  &cd->bks,
+                                  NULL,
+                                  &cd->priv,
+                                  cd->ach,
+                                  &cd->c_hash,
+                                  &cd->pd))
       {
-        const struct TALER_ExchangeWithdrawValues *alg_values
-          = TALER_denom_ewv_rsa_singleton ();
-
-        TALER_planchet_setup_coin_priv (&cd->ps,
-                                        alg_values,
-                                        &cd->priv);
-        TALER_planchet_blinding_secret_create (&cd->ps,
-                                               alg_values,
-                                               &cd->bks);
-        if (GNUNET_OK !=
-            TALER_planchet_prepare (&cd->pk.key,
-                                    alg_values,
-                                    &cd->bks,
-                                    NULL,
-                                    &cd->priv,
-                                    cd->ach,
-                                    &cd->c_hash,
-                                    &cd->pd))
-        {
-          GNUNET_break (0);
-          TALER_EXCHANGE_batch_withdraw_cancel (wh);
-          return NULL;
-        }
-        break;
+        GNUNET_break (0);
+        TALER_EXCHANGE_batch_withdraw_cancel (wh);
+        return NULL;
       }
+      break;
     case GNUNET_CRYPTO_BSA_CS:
+      TALER_cs_withdraw_nonce_derive (
+        &cd->ps,
+        &cd->nonce.cs_nonce);
+      cd->csrh = TALER_EXCHANGE_csr_withdraw (
+        curl_ctx,
+        exchange_url,
+        &cd->pk,
+        &cd->nonce.cs_nonce,
+        &withdraw_cs_stage_two_callback,
+        cd);
+      if (NULL == cd->csrh)
       {
-        TALER_cs_withdraw_nonce_derive (
-          &cd->ps,
-          &cd->nonce.cs_nonce);
-        cd->csrh = TALER_EXCHANGE_csr_withdraw (
-          curl_ctx,
-          exchange_url,
-          &cd->pk,
-          &cd->nonce.cs_nonce,
-          &withdraw_cs_stage_two_callback,
-          cd);
-        if (NULL == cd->csrh)
-        {
-          GNUNET_break (0);
-          TALER_EXCHANGE_batch_withdraw_cancel (wh);
-          return NULL;
-        }
-        wh->cs_pending++;
-        break;
+        GNUNET_break (0);
+        TALER_EXCHANGE_batch_withdraw_cancel (wh);
+        return NULL;
       }
+      wh->cs_pending++;
+      break;
     default:
       GNUNET_break (0);
       TALER_EXCHANGE_batch_withdraw_cancel (wh);
@@ -452,12 +442,7 @@ TALER_EXCHANGE_batch_withdraw_cancel (
       TALER_EXCHANGE_csr_withdraw_cancel (cd->csrh);
       cd->csrh = NULL;
     }
-    if (NULL != cd->alg_values.blinding_inputs)
-    {
-      GNUNET_CRYPTO_blinding_input_values_decref (
-        cd->alg_values.blinding_inputs);
-      cd->alg_values.blinding_inputs = NULL;
-    }
+    TALER_denom_ewv_free (&cd->alg_values);
     TALER_blinded_planchet_free (&cd->pd.blinded_planchet);
     TALER_denom_pub_free (&cd->pk.key);
   }
diff --git a/src/lib/exchange_api_refreshes_reveal.c 
b/src/lib/exchange_api_refreshes_reveal.c
index 9161ac3d..7eadab22 100644
--- a/src/lib/exchange_api_refreshes_reveal.c
+++ b/src/lib/exchange_api_refreshes_reveal.c
@@ -144,17 +144,13 @@ refresh_reveal_ok (struct 
TALER_EXCHANGE_RefreshesRevealHandle *rrh,
     rci->ps = fcd->ps[rrh->noreveal_index];
     rci->bks = fcd->bks[rrh->noreveal_index];
     rci->age_commitment_proof = NULL;
-
     pk = &fcd->fresh_pk;
     jsonai = json_array_get (jsona, i);
-
     GNUNET_assert (NULL != jsonai);
-
     if (NULL != rrh->md.melted_coin.age_commitment_proof)
     {
-      rci->age_commitment_proof =
-        fcd->age_commitment_proofs[rrh->noreveal_index];
-
+      rci->age_commitment_proof
+        = fcd->age_commitment_proofs[rrh->noreveal_index];
       TALER_age_commitment_hash (&rci->age_commitment_proof->commitment,
                                  &rci->h_age_commitment);
       pah = &rci->h_age_commitment;
@@ -474,10 +470,8 @@ TALER_EXCHANGE_refreshes_reveal (
     = GNUNET_new_array (md.num_fresh_coins,
                         struct TALER_ExchangeWithdrawValues);
   for (unsigned int i = 0; i<md.num_fresh_coins; i++)
-  {
     TALER_denom_ewv_deep_copy (&rrh->alg_values[i],
                                &alg_values[i]);
-  }
   rrh->url = TALER_url_join (url,
                              arg_str,
                              NULL);
diff --git a/src/testing/testing_api_cmd_withdraw.c 
b/src/testing/testing_api_cmd_withdraw.c
index b9fde7ef..13162a34 100644
--- a/src/testing/testing_api_cmd_withdraw.c
+++ b/src/testing/testing_api_cmd_withdraw.c
@@ -297,7 +297,8 @@ reserve_withdraw_cb (void *cls,
                                &wr->details.ok.coins[0].sig);
     ws->coin_priv = wr->details.ok.coins[0].coin_priv;
     ws->bks = wr->details.ok.coins[0].bks;
-    ws->exchange_vals = wr->details.ok.coins[0].exchange_vals;
+    TALER_denom_ewv_deep_copy (&ws->exchange_vals,
+                               &wr->details.ok.coins[0].exchange_vals);
     if (0 != ws->total_backoff.rel_value_us)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -489,6 +490,7 @@ withdraw_cleanup (void *cls,
     ws->retry_task = NULL;
   }
   TALER_denom_sig_free (&ws->sig);
+  TALER_denom_ewv_free (&ws->exchange_vals);
   if (NULL != ws->pk)
   {
     TALER_EXCHANGE_destroy_denomination_key (ws->pk);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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