diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2021-11-14 16:39:42 +0100 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2021-11-14 16:39:42 +0100 |
commit | c97979d00ab68915b0d354a1424e420ef84b7723 (patch) | |
tree | 7990098ab493ea5e164120f630e06c8fc6e5cc02 /src/util/crypto.c | |
parent | 7c510388b9d789c35fc05bead7677b3de52a318e (diff) |
age restriction (load per denomination). 3/n
Diffstat (limited to 'src/util/crypto.c')
-rw-r--r-- | src/util/crypto.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/util/crypto.c b/src/util/crypto.c index 67cf14b42..2d3a569a4 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); + } } |