gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] 35/37: refactor TALER_coin_ev_hash


From: gnunet
Subject: [taler-exchange] 35/37: refactor TALER_coin_ev_hash
Date: Fri, 04 Feb 2022 16:54:05 +0100

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

gian-demarmels pushed a commit to branch master
in repository exchange.

commit 086cf05794e2936370223c97b35c1909fbc1a2c1
Author: Gian Demarmels <gian@demarmels.org>
AuthorDate: Mon Jan 17 19:36:19 2022 +0100

    refactor TALER_coin_ev_hash
---
 src/exchange/taler-exchange-httpd_recoup.c   |  2 +-
 src/exchange/taler-exchange-httpd_withdraw.c |  2 +-
 src/exchangedb/test_exchangedb.c             |  2 +-
 src/include/taler_crypto_lib.h               |  2 +-
 src/lib/exchange_api_withdraw2.c             |  2 +-
 src/util/crypto.c                            | 59 +++++++++++++++-------------
 6 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_recoup.c 
b/src/exchange/taler-exchange-httpd_recoup.c
index 388277c4..1978b58d 100644
--- a/src/exchange/taler-exchange-httpd_recoup.c
+++ b/src/exchange/taler-exchange-httpd_recoup.c
@@ -266,7 +266,7 @@ verify_and_execute_recoup (
         NULL);
     }
     if (GNUNET_OK != TALER_coin_ev_hash (&blinded_planchet,
-                                         &dk->denom_pub,
+                                         &coin->denom_pub_hash,
                                          &pc.h_blind))
     {
       GNUNET_break (0);
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c 
b/src/exchange/taler-exchange-httpd_withdraw.c
index c07250e3..aab1cafd 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -503,7 +503,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
   wc.wsrd.h_denomination_pub
     = wc.collectable.denom_pub_hash;
   if (GNUNET_OK != TALER_coin_ev_hash (&wc.blinded_planchet,
-                                       &dk->denom_pub,
+                                       &wc.collectable.denom_pub_hash,
                                        &wc.wsrd.h_coin_envelope))
   {
     GNUNET_break (0);
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 9dfae795..ad61d96f 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1732,7 +1732,7 @@ run (void *cls)
                                       &c_hash,
                                       &pd.blinded_planchet));
     GNUNET_assert (GNUNET_OK == TALER_coin_ev_hash (&pd.blinded_planchet,
-                                                    &dkp->pub,
+                                                    &cbc.denom_pub_hash,
                                                     &cbc.h_coin_envelope));
     GNUNET_assert (GNUNET_OK ==
                    TALER_denom_sign_blinded (&cbc.sig,
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 5475a802..d9565dd7 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -1264,7 +1264,7 @@ TALER_test_coin_valid (const struct TALER_CoinPublicInfo 
*coin_public_info,
  */
 enum GNUNET_GenericReturnValue
 TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet,
-                    const struct TALER_DenominationPublicKey *denom_pub,
+                    const struct TALER_DenominationHash *denom_hash,
                     struct TALER_BlindedCoinHash *bch);
 
 
diff --git a/src/lib/exchange_api_withdraw2.c b/src/lib/exchange_api_withdraw2.c
index 5341055b..c5a3a66a 100644
--- a/src/lib/exchange_api_withdraw2.c
+++ b/src/lib/exchange_api_withdraw2.c
@@ -438,7 +438,7 @@ TALER_EXCHANGE_withdraw2 (
     TALER_amount_hton (&req.amount_with_fee,
                        &wh->requested_amount);
     if (GNUNET_OK != TALER_coin_ev_hash (&pd->blinded_planchet,
-                                         &dk->key,
+                                         &pd->denom_pub_hash,
                                          &req.h_coin_envelope))
     {
       GNUNET_break (0);
diff --git a/src/util/crypto.c b/src/util/crypto.c
index bed70f3d..fee3f31e 100644
--- a/src/util/crypto.c
+++ b/src/util/crypto.c
@@ -502,43 +502,46 @@ TALER_refresh_get_commitment (struct 
TALER_RefreshCommitmentP *rc,
 
 enum GNUNET_GenericReturnValue
 TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet,
-                    const struct TALER_DenominationPublicKey *denom_pub,
+                    const struct TALER_DenominationHash *denom_hash,
                     struct TALER_BlindedCoinHash *bch)
 {
   switch (blinded_planchet->cipher)
   {
   case TALER_DENOMINATION_RSA:
-    // FIXME: Include denom_pub into hash
-    GNUNET_CRYPTO_hash (
-      blinded_planchet->details.rsa_blinded_planchet.blinded_msg,
-      blinded_planchet->details.rsa_blinded_planchet.blinded_msg_size,
-      &bch->hash);
-    return GNUNET_OK;
-  case TALER_DENOMINATION_CS:
     {
-      char delim = ':';
-      size_t buf_len = sizeof(denom_pub->details.cs_public_key)
-                       + sizeof (blinded_planchet->details.cs_blinded_planchet.
-                                 nonce)
-                       + sizeof(delim);
-      void*buf = GNUNET_malloc (buf_len);
-      memcpy (buf,
-              &denom_pub->details.cs_public_key,
-              sizeof(denom_pub->details.cs_public_key));
-      memcpy (buf + sizeof(denom_pub->details.cs_public_key),
-              &delim,
-              sizeof(delim));
-      memcpy (buf + sizeof(denom_pub->details.cs_public_key) + sizeof(delim),
-              &blinded_planchet->details.cs_blinded_planchet.nonce,
-              sizeof (blinded_planchet->details.cs_blinded_planchet.nonce));
-      GNUNET_CRYPTO_hash (
-        buf,
-        buf_len,
-        &bch->hash);
-      GNUNET_free (buf);
+      struct GNUNET_HashContext *hash_context;
+      hash_context = GNUNET_CRYPTO_hash_context_start ();
+
+      // // FIXME: Include denom_pub into hash
+      // GNUNET_CRYPTO_hash_context_read (hash_context,
+      //                                  &denom_hash->hash,
+      //                                  sizeof(denom_hash->hash));
+      GNUNET_CRYPTO_hash_context_read (hash_context,
+                                       blinded_planchet->details.
+                                       rsa_blinded_planchet.blinded_msg,
+                                       blinded_planchet->details.
+                                       rsa_blinded_planchet.blinded_msg_size);
+      GNUNET_CRYPTO_hash_context_finish (hash_context,
+                                         &bch->hash);
       return GNUNET_OK;
     }
+  case TALER_DENOMINATION_CS:
+    {
+      struct GNUNET_HashContext *hash_context;
+      hash_context = GNUNET_CRYPTO_hash_context_start ();
 
+      GNUNET_CRYPTO_hash_context_read (hash_context,
+                                       &denom_hash->hash,
+                                       sizeof(denom_hash->hash));
+      GNUNET_CRYPTO_hash_context_read (hash_context,
+                                       &blinded_planchet->details.
+                                       cs_blinded_planchet.nonce,
+                                       sizeof (blinded_planchet->details.
+                                               cs_blinded_planchet.nonce));
+      GNUNET_CRYPTO_hash_context_finish (hash_context,
+                                         &bch->hash);
+      return GNUNET_OK;
+    }
   default:
     GNUNET_break (0);
     return GNUNET_SYSERR;

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