gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: implement batch operation in han


From: gnunet
Subject: [taler-exchange] branch master updated: implement batch operation in handlers
Date: Mon, 14 Nov 2022 06:43:23 +0100

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 41e3c1ec implement batch operation in handlers
41e3c1ec is described below

commit 41e3c1ecbf0c437f58be3084a9401aa71c515a62
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Nov 14 06:43:21 2022 +0100

    implement batch operation in handlers
---
 src/exchange/taler-exchange-httpd_batch-withdraw.c | 30 +++++++++-------
 src/exchange/taler-exchange-httpd_csr.c            | 42 ++++++++++------------
 .../taler-exchange-httpd_refreshes_reveal.c        | 24 +++++++------
 3 files changed, 49 insertions(+), 47 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c 
b/src/exchange/taler-exchange-httpd_batch-withdraw.c
index de1b67e5..a923784b 100644
--- a/src/exchange/taler-exchange-httpd_batch-withdraw.c
+++ b/src/exchange/taler-exchange-httpd_batch-withdraw.c
@@ -413,24 +413,24 @@ static MHD_RESULT
 prepare_transaction (const struct TEH_RequestContext *rc,
                      struct BatchWithdrawContext *wc)
 {
-  /* Note: We could check the reserve balance here,
-     just to be reasonably sure that the reserve has
-     a sufficient balance before doing the "expensive"
-     signatures... */
-  /* Sign before transaction! */
+  struct TEH_CoinSignData csds[wc->planchets_length];
+  struct TALER_BlindedDenominationSignature bss[wc->planchets_length];
+
   for (unsigned int i = 0; i<wc->planchets_length; i++)
   {
     struct PlanchetContext *pc = &wc->planchets[i];
+
+    csds[i].h_denom_pub = &pc->collectable.denom_pub_hash;
+    csds[i].bp = &pc->blinded_planchet;
+  }
+  {
     enum TALER_ErrorCode ec;
-    struct TEH_CoinSignData csds = {
-      .h_denom_pub = &pc->collectable.denom_pub_hash,
-      .bp = &pc->blinded_planchet
-    };
 
-    ec = TEH_keys_denomination_sign (
-      &csds,
+    ec = TEH_keys_denomination_batch_sign (
+      csds,
+      wc->planchets_length,
       false,
-      &pc->collectable.sig);
+      bss);
     if (TALER_EC_NONE != ec)
     {
       GNUNET_break (0);
@@ -439,6 +439,12 @@ prepare_transaction (const struct TEH_RequestContext *rc,
                                       NULL);
     }
   }
+  for (unsigned int i = 0; i<wc->planchets_length; i++)
+  {
+    struct PlanchetContext *pc = &wc->planchets[i];
+
+    pc->collectable.sig = bss[i];
+  }
 
   /* run transaction */
   {
diff --git a/src/exchange/taler-exchange-httpd_csr.c 
b/src/exchange/taler-exchange-httpd_csr.c
index 7e9e7a58..a22fdfff 100644
--- a/src/exchange/taler-exchange-httpd_csr.c
+++ b/src/exchange/taler-exchange-httpd_csr.c
@@ -75,10 +75,11 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
 
   {
     struct TALER_ExchangeWithdrawValues ewvs[csr_requests_num];
-
     {
       struct TALER_CsNonce nonces[csr_requests_num];
       struct TALER_DenominationHashP denom_pub_hashes[csr_requests_num];
+      struct TEH_CsDeriveData cdds[csr_requests_num];
+      struct TALER_DenominationCSPublicRPairP r_pubs[csr_requests_num];
 
       for (unsigned int i = 0; i < csr_requests_num; i++)
       {
@@ -114,8 +115,6 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
         const struct TALER_CsNonce *nonce = &nonces[i];
         const struct TALER_DenominationHashP *denom_pub_hash =
           &denom_pub_hashes[i];
-        struct TALER_DenominationCSPublicRPairP *r_pub
-          = &ewvs[i].details.cs_values;
 
         ewvs[i].cipher = TALER_DENOMINATION_CS;
         /* check denomination referenced by denom_pub_hash */
@@ -176,28 +175,23 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
               denom_pub_hash);
           }
         }
-
-        /* derive r_pub */
-        // FIXME-#7272: bundle all requests into one derivation request 
(TEH_keys_..., crypto helper, security module)
-        {
-          const struct TEH_CsDeriveData cdd = {
-            .h_denom_pub = denom_pub_hash,
-            .nonce = nonce
-          };
-
-          ec = TEH_keys_denomination_cs_r_pub (&cdd,
-                                               true,
-                                               r_pub);
-        }
-        if (TALER_EC_NONE != ec)
-        {
-          GNUNET_break (0);
-          return TALER_MHD_reply_with_ec (rc->connection,
-                                          ec,
-                                          NULL);
-        }
+        cdds[i].h_denom_pub = denom_pub_hash;
+        cdds[i].nonce = nonce;
+      } /* for (i) */
+      ec = TEH_keys_denomination_cs_batch_r_pub (cdds,
+                                                 csr_requests_num,
+                                                 true,
+                                                 r_pubs);
+      if (TALER_EC_NONE != ec)
+      {
+        GNUNET_break (0);
+        return TALER_MHD_reply_with_ec (rc->connection,
+                                        ec,
+                                        NULL);
       }
-    }
+      for (unsigned int i = 0; i < csr_requests_num; i++)
+        ewvs[i].details.cs_values = r_pubs[i];
+    } /* end scope */
 
     /* send response */
     {
diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c 
b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
index 56848d58..08a85265 100644
--- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
@@ -750,20 +750,21 @@ clean_age:
               (unsigned int) rctx->num_fresh_coins);
 
   /* create fresh coin signatures */
-  for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
   {
+    struct TEH_CoinSignData csds[rctx->num_fresh_coins];
+    struct TALER_BlindedDenominationSignature bss[rctx->num_fresh_coins];
     enum TALER_ErrorCode ec;
-    struct TEH_CoinSignData csd = {
-      .h_denom_pub = &rrcs[i].h_denom_pub,
-      .bp = &rcds[i].blinded_planchet
-    };
 
-    // FIXME #7272: replace with a batch call that
-    // passes all coins in once go!
-    ec = TEH_keys_denomination_sign (
-      &csd,
+    for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
+    {
+      csds[i].h_denom_pub = &rrcs[i].h_denom_pub;
+      csds[i].bp = &rcds[i].blinded_planchet;
+    }
+    ec = TEH_keys_denomination_batch_sign (
+      csds,
+      rctx->num_fresh_coins,
       true,
-      &rrcs[i].coin_sig);
+      bss);
     if (TALER_EC_NONE != ec)
     {
       GNUNET_break (0);
@@ -772,8 +773,9 @@ clean_age:
                                      NULL);
       goto cleanup;
     }
+    for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
+      rrcs[i].coin_sig = bss[i];
   }
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Signatures ready, starting DB interaction\n");
 

-- 
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]