diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c index 916277b96..a9c998af0 100644 --- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c +++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c @@ -365,6 +365,7 @@ refreshes_reveal_transaction (void *cls, struct TALER_RefreshCoinData *rcd = &rce->new_coins[j]; struct TALER_PlanchetSecretsP ps; struct TALER_PlanchetDetail pd; + struct GNUNET_HashCode c_hash; rcd->dk = &rctx->dkis[j]->denom_pub; TALER_planchet_setup_refresh (&ts, @@ -373,6 +374,7 @@ refreshes_reveal_transaction (void *cls, GNUNET_assert (GNUNET_OK == TALER_planchet_prepare (rcd->dk, &ps, + &c_hash, &pd)); rcd->coin_ev = pd.coin_ev; rcd->coin_ev_size = pd.coin_ev_size; diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 868bbebe9..3c5358144 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -445,13 +445,6 @@ struct TALER_PlanchetDetail */ struct GNUNET_HashCode denom_pub_hash; - /** - * Hash of the coin's public key. Kept around so we do not need to - * compute it again. Can be recomputed by hashing the public key - * of @a coin_priv if storage is at a premium. - */ - struct GNUNET_HashCode c_hash; - /** * Blinded coin (see GNUNET_CRYPTO_rsa_blind()). Note: is malloc()'ed! */ @@ -589,6 +582,7 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps); * * @param dk denomination key for the coin to be created * @param ps secret planchet internals (for #TALER_planchet_to_coin) + * @param[out] c_hash set to the hash of the public key of the coin (needed later) * @param[out] pd set to the planchet detail for TALER_MERCHANT_tip_pickup() and * other withdraw operations * @return #GNUNET_OK on success @@ -596,6 +590,7 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps); int TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, const struct TALER_PlanchetSecretsP *ps, + struct GNUNET_HashCode *c_hash, struct TALER_PlanchetDetail *pd); diff --git a/src/lib/exchange_api_link.c b/src/lib/exchange_api_link.c index f933edd95..ad0ad85dc 100644 --- a/src/lib/exchange_api_link.c +++ b/src/lib/exchange_api_link.c @@ -128,18 +128,21 @@ parse_link_coin (const struct TALER_EXCHANGE_LinkHandle *lh, rpub); /* verify link_sig */ { - struct TALER_LinkDataPS ldp; struct TALER_PlanchetDetail pd; + struct GNUNET_HashCode c_hash; + struct TALER_LinkDataPS ldp = { + .purpose.size = htonl (sizeof (ldp)), + .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_LINK), + .transfer_pub = *trans_pub + }; - ldp.purpose.size = htonl (sizeof (ldp)); - ldp.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_LINK); GNUNET_CRYPTO_eddsa_key_get_public (&lh->coin_priv.eddsa_priv, &ldp.old_coin_pub.eddsa_pub); - ldp.transfer_pub = *trans_pub; pub->rsa_public_key = rpub; if (GNUNET_OK != TALER_planchet_prepare (pub, &fc, + &c_hash, &pd)) { GNUNET_break (0); diff --git a/src/lib/exchange_api_refresh_common.c b/src/lib/exchange_api_refresh_common.c index 3aa72e541..b6656e25e 100644 --- a/src/lib/exchange_api_refresh_common.c +++ b/src/lib/exchange_api_refresh_common.c @@ -582,6 +582,7 @@ TALER_EXCHANGE_refresh_prepare ( struct TALER_PlanchetSecretsP *fc = &md.fresh_coins[i][j]; struct TALER_RefreshCoinData *rcd = &rce[i].new_coins[j]; struct TALER_PlanchetDetail pd; + struct GNUNET_HashCode c_hash; TALER_planchet_setup_refresh (&trans_sec[i], j, @@ -589,6 +590,7 @@ TALER_EXCHANGE_refresh_prepare ( if (GNUNET_OK != TALER_planchet_prepare (&md.fresh_pks[j], fc, + &c_hash, &pd)) { GNUNET_break_op (0); diff --git a/src/lib/exchange_api_refreshes_reveal.c b/src/lib/exchange_api_refreshes_reveal.c index e82d33a19..6ffbb9a34 100644 --- a/src/lib/exchange_api_refreshes_reveal.c +++ b/src/lib/exchange_api_refreshes_reveal.c @@ -361,6 +361,7 @@ TALER_EXCHANGE_refreshes_reveal ( { struct GNUNET_HashCode denom_hash; struct TALER_PlanchetDetail pd; + struct GNUNET_HashCode c_hash; GNUNET_CRYPTO_rsa_public_key_hash (md->fresh_pks[i].rsa_public_key, &denom_hash); @@ -372,6 +373,7 @@ TALER_EXCHANGE_refreshes_reveal ( if (GNUNET_OK != TALER_planchet_prepare (&md->fresh_pks[i], &md->fresh_coins[noreveal_index][i], + &c_hash, &pd)) { /* This should have been noticed during the preparation stage. */ diff --git a/src/lib/exchange_api_withdraw.c b/src/lib/exchange_api_withdraw.c index 6258053bb..8cd1ac012 100644 --- a/src/lib/exchange_api_withdraw.c +++ b/src/lib/exchange_api_withdraw.c @@ -381,6 +381,7 @@ handle_reserve_withdraw_finished (void *cls, * @param ps secrets of the planchet * caller must have committed this value to disk before the call (with @a pk) * @param pd planchet details matching @a ps + * @param c_hash hash over the coin's public key * @param res_cb the callback to call when the final result for this request is available * @param res_cb_cls closure for @a res_cb * @return NULL @@ -394,6 +395,7 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_PlanchetSecretsP *ps, const struct TALER_PlanchetDetail *pd, + const struct GNUNET_HashCode *c_hash, TALER_EXCHANGE_WithdrawCallback res_cb, void *res_cb_cls) { @@ -427,7 +429,7 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange, wh->pk.key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (pk->key.rsa_public_key); wh->reserve_pub = *reserve_pub; - wh->c_hash = pd->c_hash; + wh->c_hash = *c_hash; GNUNET_CRYPTO_rsa_public_key_hash (pk->key.rsa_public_key, &h_denom_pub); withdraw_obj = json_pack ("{s:o, s:o," /* denom_pub_hash and coin_ev */ @@ -510,6 +512,7 @@ TALER_EXCHANGE_withdraw ( struct TALER_WithdrawRequestPS req; struct TALER_PlanchetDetail pd; struct TALER_EXCHANGE_WithdrawHandle *wh; + struct GNUNET_HashCode c_hash; GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv, &req.reserve_pub.eddsa_pub); @@ -531,6 +534,7 @@ TALER_EXCHANGE_withdraw ( if (GNUNET_OK != TALER_planchet_prepare (&pk->key, ps, + &c_hash, &pd)) { GNUNET_break_op (0); @@ -549,6 +553,7 @@ TALER_EXCHANGE_withdraw ( &req.reserve_pub, ps, &pd, + &c_hash, res_cb, res_cb_cls); GNUNET_free (pd.coin_ev); @@ -589,11 +594,13 @@ TALER_EXCHANGE_withdraw2 ( void *res_cb_cls) { struct TALER_EXCHANGE_WithdrawHandle *wh; + struct GNUNET_HashCode c_hash; struct TALER_PlanchetDetail pd; if (GNUNET_OK != TALER_planchet_prepare (&pk->key, ps, + &c_hash, &pd)) { GNUNET_break_op (0); @@ -605,6 +612,7 @@ TALER_EXCHANGE_withdraw2 ( reserve_pub, ps, &pd, + &c_hash, res_cb, res_cb_cls); GNUNET_free (pd.coin_ev); diff --git a/src/util/crypto.c b/src/util/crypto.c index 99171ebc7..b75cd8b4e 100644 --- a/src/util/crypto.c +++ b/src/util/crypto.c @@ -226,6 +226,7 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps) * * @param dk denomination key for the coin to be created * @param ps secret planchet internals (for #TALER_planchet_to_coin) + * @param[out] c_hash set to the hash of the public key of the coin (needed later) * @param[out] pd set to the planchet detail for TALER_MERCHANT_tip_pickup() and * other withdraw operations * @return #GNUNET_OK on success @@ -233,6 +234,7 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps) int TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, const struct TALER_PlanchetSecretsP *ps, + struct GNUNET_HashCode *c_hash, struct TALER_PlanchetDetail *pd) { struct TALER_CoinSpendPublicKeyP coin_pub; @@ -241,9 +243,9 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, &coin_pub.eddsa_pub); GNUNET_CRYPTO_hash (&coin_pub.eddsa_pub, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), - &pd->c_hash); + c_hash); if (GNUNET_YES != - GNUNET_CRYPTO_rsa_blind (&pd->c_hash, + GNUNET_CRYPTO_rsa_blind (c_hash, &ps->blinding_key.bks, dk->rsa_public_key, &pd->coin_ev,