gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -refactoring in preparation of f


From: gnunet
Subject: [taler-exchange] branch master updated: -refactoring in preparation of fixing #7272
Date: Mon, 14 Nov 2022 05:34:22 +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 053faa25 -refactoring in preparation of fixing #7272
053faa25 is described below

commit 053faa252c2afed8ecbb65bdd6fe8ec6f9ad9ef9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Nov 14 05:34:19 2022 +0100

    -refactoring in preparation of fixing #7272
---
 src/exchange/taler-exchange-httpd_batch-withdraw.c |  7 ++-
 src/exchange/taler-exchange-httpd_keys.c           | 64 ++++++++++++++++++++--
 src/exchange/taler-exchange-httpd_keys.h           | 64 ++++++++++++++++++----
 .../taler-exchange-httpd_refreshes_reveal.c        |  7 ++-
 src/exchange/taler-exchange-httpd_withdraw.c       | 16 ++++--
 5 files changed, 133 insertions(+), 25 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_batch-withdraw.c 
b/src/exchange/taler-exchange-httpd_batch-withdraw.c
index 541d6572..7352edfd 100644
--- a/src/exchange/taler-exchange-httpd_batch-withdraw.c
+++ b/src/exchange/taler-exchange-httpd_batch-withdraw.c
@@ -422,10 +422,13 @@ prepare_transaction (const struct TEH_RequestContext *rc,
   {
     struct PlanchetContext *pc = &wc->planchets[i];
     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_withdraw (
-      &pc->collectable.denom_pub_hash,
-      &pc->blinded_planchet,
+      &csds,
       &pc->collectable.sig);
     if (TALER_EC_NONE != ec)
     {
diff --git a/src/exchange/taler-exchange-httpd_keys.c 
b/src/exchange/taler-exchange-httpd_keys.c
index cf20985c..d430946c 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -2747,12 +2747,66 @@ TEH_keys_denomination_by_hash2 (
 
 enum TALER_ErrorCode
 TEH_keys_denomination_sign_withdraw (
-  const struct TALER_DenominationHashP *h_denom_pub,
-  const struct TALER_BlindedPlanchet *bp,
+  const struct TEH_CoinSignData *csd,
   struct TALER_BlindedDenominationSignature *bs)
 {
   struct TEH_KeyStateHandle *ksh;
   struct HelperDenomination *hd;
+  const struct TALER_DenominationHashP *h_denom_pub = csd->h_denom_pub;
+  const struct TALER_BlindedPlanchet *bp = csd->bp;
+
+  ksh = TEH_keys_get_state ();
+  if (NULL == ksh)
+    return TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING;
+  hd = GNUNET_CONTAINER_multihashmap_get (ksh->helpers->denom_keys,
+                                          &h_denom_pub->hash);
+  if (NULL == hd)
+    return TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN;
+  if (bp->cipher != hd->denom_pub.cipher)
+    return TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE;
+  switch (hd->denom_pub.cipher)
+  {
+  case TALER_DENOMINATION_RSA:
+    TEH_METRICS_num_signatures[TEH_MT_SIGNATURE_RSA]++;
+    {
+      struct TALER_CRYPTO_RsaSignRequest rsr = {
+        .h_rsa = &hd->h_details.h_rsa,
+        .msg = bp->details.rsa_blinded_planchet.blinded_msg,
+        .msg_size = bp->details.rsa_blinded_planchet.blinded_msg_size
+      };
+
+      return TALER_CRYPTO_helper_rsa_sign (
+        ksh->helpers->rsadh,
+        &rsr,
+        bs);
+    }
+  case TALER_DENOMINATION_CS:
+    TEH_METRICS_num_signatures[TEH_MT_SIGNATURE_CS]++;
+    {
+      struct TALER_CRYPTO_CsSignRequest csr;
+
+      csr.h_cs = &hd->h_details.h_cs;
+      csr.blinded_planchet = &bp->details.cs_blinded_planchet;
+      return TALER_CRYPTO_helper_cs_sign_withdraw (
+        ksh->helpers->csdh,
+        &csr,
+        bs);
+    }
+  default:
+    return TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE;
+  }
+}
+
+
+enum TALER_ErrorCode
+TEH_keys_denomination_batch_sign_withdraw (
+  const struct TEH_CoinSignData *csds,
+  unsigned int csds_length,
+  struct TALER_BlindedDenominationSignature *bss)
+{
+  struct TEH_KeyStateHandle *ksh;
+  struct HelperDenomination *hd;
+#if 0
 
   ksh = TEH_keys_get_state ();
   if (NULL == ksh)
@@ -2794,15 +2848,17 @@ TEH_keys_denomination_sign_withdraw (
   default:
     return TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE;
   }
+#endif
 }
 
 
 enum TALER_ErrorCode
 TEH_keys_denomination_sign_melt (
-  const struct TALER_DenominationHashP *h_denom_pub,
-  const struct TALER_BlindedPlanchet *bp,
+  const struct TEH_CoinSignData *csd,
   struct TALER_BlindedDenominationSignature *bs)
 {
+  const struct TALER_DenominationHashP *h_denom_pub = csd->h_denom_pub;
+  const struct TALER_BlindedPlanchet *bp = csd->bp;
   struct TEH_KeyStateHandle *ksh;
   struct HelperDenomination *hd;
 
diff --git a/src/exchange/taler-exchange-httpd_keys.h 
b/src/exchange/taler-exchange-httpd_keys.h
index 01ba1f95..24ba1467 100644
--- a/src/exchange/taler-exchange-httpd_keys.h
+++ b/src/exchange/taler-exchange-httpd_keys.h
@@ -246,39 +246,79 @@ TEH_keys_denomination_by_hash2 (
   struct MHD_Connection *conn,
   MHD_RESULT *mret);
 
+/**
+ * Information needed to create a blind signature.
+ */
+struct TEH_CoinSignData
+{
+  /**
+   * Hash of key to sign with.
+   */
+  const struct TALER_DenominationHashP *h_denom_pub;
+
+  /**
+   * Blinded planchet to sign over.
+   */
+  const struct TALER_BlindedPlanchet *bp;
+};
+
 
 /**
- * Request to sign @a msg using the public key corresponding to
- * @a h_denom_pub during a withdraw operation.
+ * Request to sign @a csd for regular withdrawing.
  *
- * @param h_denom_pub hash of the public key to use to sign
- * @param bp blinded planchet to sign
+ * @param csd identifies data to blindly sign and key to sign with
  * @param[out] bs set to the blind signature on success
  * @return #TALER_EC_NONE on success
  */
 enum TALER_ErrorCode
 TEH_keys_denomination_sign_withdraw (
-  const struct TALER_DenominationHashP *h_denom_pub,
-  const struct TALER_BlindedPlanchet *bp,
+  const struct TEH_CoinSignData *csd,
   struct TALER_BlindedDenominationSignature *bs);
 
 
 /**
- * Request to sign @a msg using the public key corresponding to
- * @a h_denom_pub during a refresh operation.
+ * Request to sign @a csds for regular withdrawing.
+ *
+ * @param csds array with data to blindly sign (and keys to sign with)
+ * @param csds_length length of @a csds array
+ * @param[out] bss array set to the blind signature on success; must be of 
length @a csds_length
+ * @return #TALER_EC_NONE on success
+ */
+enum TALER_ErrorCode
+TEH_keys_denomination_batch_sign_withdraw (
+  const struct TEH_CoinSignData *csds,
+  unsigned int csds_length,
+  struct TALER_BlindedDenominationSignature *bss);
+
+
+/**
+ * Request to sign @a csd for melting.
  *
- * @param h_denom_pub hash of the public key to use to sign
- * @param bp blinded planchet to sign
+ * @param csd identifies data to blindly sign and key to sign with
  * @param[out] bs set to the blind signature on success
  * @return #TALER_EC_NONE on success
  */
 enum TALER_ErrorCode
 TEH_keys_denomination_sign_melt (
-  const struct TALER_DenominationHashP *h_denom_pub,
-  const struct TALER_BlindedPlanchet *bp,
+  const struct TEH_CoinSignData *csd,
   struct TALER_BlindedDenominationSignature *bs);
 
 
+/**
+ * Request to sign @a csds for melting.
+ *
+ * @param csds array with data to blindly sign (and keys to sign with)
+ * @param csds_length length of @a csds array
+ * @param[out] bss array set to the blind signature on success; must be of 
length @a csds_length
+ * @return #TALER_EC_NONE on success
+ */
+enum TALER_ErrorCode
+TEH_keys_denomination_batch_sign_melt (
+  const struct TEH_CoinSignData *csds,
+  unsigned int csds_length,
+  struct TALER_BlindedDenominationSignature *bss);
+
+
 /**
  * Request to derive CS @a r_pub using the denomination corresponding to @a 
h_denom_pub
  * and @a nonce for withdrawing.
diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c 
b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
index 85090ced..a0c8a666 100644
--- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
@@ -749,12 +749,15 @@ clean_age:
   for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
   {
     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_melt (
-      &rrcs[i].h_denom_pub,
-      &rcds[i].blinded_planchet,
+      &csd,
       &rrcs[i].coin_sig);
     if (TALER_EC_NONE != ec)
     {
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c 
b/src/exchange/taler-exchange-httpd_withdraw.c
index 27b17672..71128bf5 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -448,11 +448,17 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
                                        NULL);
   }
 
-  /* Sign before transaction! */
-  ec = TEH_keys_denomination_sign_withdraw (
-    &wc.collectable.denom_pub_hash,
-    &wc.blinded_planchet,
-    &wc.collectable.sig);
+  {
+    struct TEH_CoinSignData csd = {
+      .h_denom_pub = &wc.collectable.denom_pub_hash,
+      .bp = &wc.blinded_planchet
+    };
+
+    /* Sign before transaction! */
+    ec = TEH_keys_denomination_sign_withdraw (
+      &csd,
+      &wc.collectable.sig);
+  }
   if (TALER_EC_NONE != ec)
   {
     GNUNET_break (0);

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