simplify hash generation of age commitment

This commit is contained in:
Özgür Kesim 2023-03-11 11:48:44 +01:00
parent 257f2eb91b
commit e3d5672cbd
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7

View File

@ -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 /* Coin comes with age commitment. Take the hash of the age commitment
* into account */ * into account */
const size_t key_s = sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey); struct GNUNET_HashContext *hash_context;
const size_t age_s = sizeof(struct TALER_AgeCommitmentHash);
char data[key_s + age_s];
GNUNET_memcpy (&data[0], hash_context = GNUNET_CRYPTO_hash_context_start ();
&coin_pub->eddsa_pub,
key_s); GNUNET_CRYPTO_hash_context_read (
GNUNET_memcpy (&data[key_s], hash_context,
ach, &coin_pub->eddsa_pub,
age_s); sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey));
GNUNET_CRYPTO_hash (&data,
key_s + age_s, GNUNET_CRYPTO_hash_context_read (
&coin_h->hash); hash_context,
ach,
sizeof(struct TALER_AgeCommitmentHash));
GNUNET_CRYPTO_hash_context_finish (
hash_context,
&coin_h->hash);
} }
} }