From c97979d00ab68915b0d354a1424e420ef84b7723 Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Sun, 14 Nov 2021 16:39:42 +0100 Subject: age restriction (load per denomination). 3/n --- src/util/crypto.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src/util/crypto.c') diff --git a/src/util/crypto.c b/src/util/crypto.c index 67cf14b4..2d3a569a 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -320,10 +320,33 @@ void TALER_coin_pub_hash (const struct TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_CoinPubHash *coin_h) { - // FIXME-Oec: hash over age-restriction, too - GNUNET_CRYPTO_hash (&coin_pub->eddsa_pub, - sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), - &coin_h->hash); + if (GNUNET_is_zero (&coin_pub->age_commitment_hash)) + { + /* No age commitment was set */ + GNUNET_CRYPTO_hash (&coin_pub->eddsa_pub, + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), + &coin_h->hash); + } + else + { + /* 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_AgeHash); + char data[key_s + age_s]; + + GNUNET_memcpy (&data[0], + &coin_pub->eddsa_pub, + key_s); + + GNUNET_memcpy (&data[key_s], + &coin_pub->age_commitment_hash, + age_s); + + GNUNET_CRYPTO_hash (&data, + key_s + age_s, + &coin_h->hash); + } } -- cgit v1.2.3