summaryrefslogtreecommitdiff
path: root/src/util/crypto.c
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-03-11 11:48:44 +0100
committerÖzgür Kesim <oec-taler@kesim.org>2023-03-11 11:48:44 +0100
commite3d5672cbd8fdcbc7df9c52f90b7d639ad1675d9 (patch)
treee9157ba5a064fca22f740613cdbdb3dac5f32dd9 /src/util/crypto.c
parent257f2eb91b5e488e222f5e9f66cf7b54c8cec3e2 (diff)
downloadexchange-e3d5672cbd8fdcbc7df9c52f90b7d639ad1675d9.tar.gz
exchange-e3d5672cbd8fdcbc7df9c52f90b7d639ad1675d9.tar.bz2
exchange-e3d5672cbd8fdcbc7df9c52f90b7d639ad1675d9.zip
simplify hash generation of age commitment
Diffstat (limited to 'src/util/crypto.c')
-rw-r--r--src/util/crypto.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/util/crypto.c b/src/util/crypto.c
index d164b8a50..bb14b6cdc 100644
--- a/src/util/crypto.c
+++ b/src/util/crypto.c
@@ -421,19 +421,23 @@ TALER_coin_pub_hash (const struct TALER_CoinSpendPublicKeyP *coin_pub,
{
/* Coin comes with age commitment. Take the hash of the age commitment
* into account */
- const size_t key_s = sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey);
- const size_t age_s = sizeof(struct TALER_AgeCommitmentHash);
- char data[key_s + age_s];
-
- GNUNET_memcpy (&data[0],
- &coin_pub->eddsa_pub,
- key_s);
- GNUNET_memcpy (&data[key_s],
- ach,
- age_s);
- GNUNET_CRYPTO_hash (&data,
- key_s + age_s,
- &coin_h->hash);
+ struct GNUNET_HashContext *hash_context;
+
+ hash_context = GNUNET_CRYPTO_hash_context_start ();
+
+ GNUNET_CRYPTO_hash_context_read (
+ hash_context,
+ &coin_pub->eddsa_pub,
+ sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey));
+
+ GNUNET_CRYPTO_hash_context_read (
+ hash_context,
+ ach,
+ sizeof(struct TALER_AgeCommitmentHash));
+
+ GNUNET_CRYPTO_hash_context_finish (
+ hash_context,
+ &coin_h->hash);
}
}