remove c_hash from planchet detail where it does not logically belong

This commit is contained in:
Christian Grothoff 2020-04-12 16:44:28 +02:00
parent d28f18f240
commit 00350bc228
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
7 changed files with 28 additions and 14 deletions

View File

@ -365,6 +365,7 @@ refreshes_reveal_transaction (void *cls,
struct TALER_RefreshCoinData *rcd = &rce->new_coins[j]; struct TALER_RefreshCoinData *rcd = &rce->new_coins[j];
struct TALER_PlanchetSecretsP ps; struct TALER_PlanchetSecretsP ps;
struct TALER_PlanchetDetail pd; struct TALER_PlanchetDetail pd;
struct GNUNET_HashCode c_hash;
rcd->dk = &rctx->dkis[j]->denom_pub; rcd->dk = &rctx->dkis[j]->denom_pub;
TALER_planchet_setup_refresh (&ts, TALER_planchet_setup_refresh (&ts,
@ -373,6 +374,7 @@ refreshes_reveal_transaction (void *cls,
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_planchet_prepare (rcd->dk, TALER_planchet_prepare (rcd->dk,
&ps, &ps,
&c_hash,
&pd)); &pd));
rcd->coin_ev = pd.coin_ev; rcd->coin_ev = pd.coin_ev;
rcd->coin_ev_size = pd.coin_ev_size; rcd->coin_ev_size = pd.coin_ev_size;

View File

@ -445,13 +445,6 @@ struct TALER_PlanchetDetail
*/ */
struct GNUNET_HashCode denom_pub_hash; 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! * 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 dk denomination key for the coin to be created
* @param ps secret planchet internals (for #TALER_planchet_to_coin) * @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 * @param[out] pd set to the planchet detail for TALER_MERCHANT_tip_pickup() and
* other withdraw operations * other withdraw operations
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
@ -596,6 +590,7 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps);
int int
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
const struct TALER_PlanchetSecretsP *ps, const struct TALER_PlanchetSecretsP *ps,
struct GNUNET_HashCode *c_hash,
struct TALER_PlanchetDetail *pd); struct TALER_PlanchetDetail *pd);

View File

@ -128,18 +128,21 @@ parse_link_coin (const struct TALER_EXCHANGE_LinkHandle *lh,
rpub); rpub);
/* verify link_sig */ /* verify link_sig */
{ {
struct TALER_LinkDataPS ldp;
struct TALER_PlanchetDetail pd; 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, GNUNET_CRYPTO_eddsa_key_get_public (&lh->coin_priv.eddsa_priv,
&ldp.old_coin_pub.eddsa_pub); &ldp.old_coin_pub.eddsa_pub);
ldp.transfer_pub = *trans_pub;
pub->rsa_public_key = rpub; pub->rsa_public_key = rpub;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_planchet_prepare (pub, TALER_planchet_prepare (pub,
&fc, &fc,
&c_hash,
&pd)) &pd))
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -582,6 +582,7 @@ TALER_EXCHANGE_refresh_prepare (
struct TALER_PlanchetSecretsP *fc = &md.fresh_coins[i][j]; struct TALER_PlanchetSecretsP *fc = &md.fresh_coins[i][j];
struct TALER_RefreshCoinData *rcd = &rce[i].new_coins[j]; struct TALER_RefreshCoinData *rcd = &rce[i].new_coins[j];
struct TALER_PlanchetDetail pd; struct TALER_PlanchetDetail pd;
struct GNUNET_HashCode c_hash;
TALER_planchet_setup_refresh (&trans_sec[i], TALER_planchet_setup_refresh (&trans_sec[i],
j, j,
@ -589,6 +590,7 @@ TALER_EXCHANGE_refresh_prepare (
if (GNUNET_OK != if (GNUNET_OK !=
TALER_planchet_prepare (&md.fresh_pks[j], TALER_planchet_prepare (&md.fresh_pks[j],
fc, fc,
&c_hash,
&pd)) &pd))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);

View File

@ -361,6 +361,7 @@ TALER_EXCHANGE_refreshes_reveal (
{ {
struct GNUNET_HashCode denom_hash; struct GNUNET_HashCode denom_hash;
struct TALER_PlanchetDetail pd; struct TALER_PlanchetDetail pd;
struct GNUNET_HashCode c_hash;
GNUNET_CRYPTO_rsa_public_key_hash (md->fresh_pks[i].rsa_public_key, GNUNET_CRYPTO_rsa_public_key_hash (md->fresh_pks[i].rsa_public_key,
&denom_hash); &denom_hash);
@ -372,6 +373,7 @@ TALER_EXCHANGE_refreshes_reveal (
if (GNUNET_OK != if (GNUNET_OK !=
TALER_planchet_prepare (&md->fresh_pks[i], TALER_planchet_prepare (&md->fresh_pks[i],
&md->fresh_coins[noreveal_index][i], &md->fresh_coins[noreveal_index][i],
&c_hash,
&pd)) &pd))
{ {
/* This should have been noticed during the preparation stage. */ /* This should have been noticed during the preparation stage. */

View File

@ -381,6 +381,7 @@ handle_reserve_withdraw_finished (void *cls,
* @param ps secrets of the planchet * @param ps secrets of the planchet
* caller must have committed this value to disk before the call (with @a pk) * caller must have committed this value to disk before the call (with @a pk)
* @param pd planchet details matching @a ps * @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 the callback to call when the final result for this request is available
* @param res_cb_cls closure for @a res_cb * @param res_cb_cls closure for @a res_cb
* @return NULL * @return NULL
@ -394,6 +395,7 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_PlanchetSecretsP *ps, const struct TALER_PlanchetSecretsP *ps,
const struct TALER_PlanchetDetail *pd, const struct TALER_PlanchetDetail *pd,
const struct GNUNET_HashCode *c_hash,
TALER_EXCHANGE_WithdrawCallback res_cb, TALER_EXCHANGE_WithdrawCallback res_cb,
void *res_cb_cls) void *res_cb_cls)
{ {
@ -427,7 +429,7 @@ reserve_withdraw_internal (struct TALER_EXCHANGE_Handle *exchange,
wh->pk.key.rsa_public_key wh->pk.key.rsa_public_key
= GNUNET_CRYPTO_rsa_public_key_dup (pk->key.rsa_public_key); = GNUNET_CRYPTO_rsa_public_key_dup (pk->key.rsa_public_key);
wh->reserve_pub = *reserve_pub; 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, GNUNET_CRYPTO_rsa_public_key_hash (pk->key.rsa_public_key,
&h_denom_pub); &h_denom_pub);
withdraw_obj = json_pack ("{s:o, s:o," /* denom_pub_hash and coin_ev */ 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_WithdrawRequestPS req;
struct TALER_PlanchetDetail pd; struct TALER_PlanchetDetail pd;
struct TALER_EXCHANGE_WithdrawHandle *wh; struct TALER_EXCHANGE_WithdrawHandle *wh;
struct GNUNET_HashCode c_hash;
GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv, GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
&req.reserve_pub.eddsa_pub); &req.reserve_pub.eddsa_pub);
@ -531,6 +534,7 @@ TALER_EXCHANGE_withdraw (
if (GNUNET_OK != if (GNUNET_OK !=
TALER_planchet_prepare (&pk->key, TALER_planchet_prepare (&pk->key,
ps, ps,
&c_hash,
&pd)) &pd))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
@ -549,6 +553,7 @@ TALER_EXCHANGE_withdraw (
&req.reserve_pub, &req.reserve_pub,
ps, ps,
&pd, &pd,
&c_hash,
res_cb, res_cb,
res_cb_cls); res_cb_cls);
GNUNET_free (pd.coin_ev); GNUNET_free (pd.coin_ev);
@ -589,11 +594,13 @@ TALER_EXCHANGE_withdraw2 (
void *res_cb_cls) void *res_cb_cls)
{ {
struct TALER_EXCHANGE_WithdrawHandle *wh; struct TALER_EXCHANGE_WithdrawHandle *wh;
struct GNUNET_HashCode c_hash;
struct TALER_PlanchetDetail pd; struct TALER_PlanchetDetail pd;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_planchet_prepare (&pk->key, TALER_planchet_prepare (&pk->key,
ps, ps,
&c_hash,
&pd)) &pd))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
@ -605,6 +612,7 @@ TALER_EXCHANGE_withdraw2 (
reserve_pub, reserve_pub,
ps, ps,
&pd, &pd,
&c_hash,
res_cb, res_cb,
res_cb_cls); res_cb_cls);
GNUNET_free (pd.coin_ev); GNUNET_free (pd.coin_ev);

View File

@ -226,6 +226,7 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps)
* *
* @param dk denomination key for the coin to be created * @param dk denomination key for the coin to be created
* @param ps secret planchet internals (for #TALER_planchet_to_coin) * @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 * @param[out] pd set to the planchet detail for TALER_MERCHANT_tip_pickup() and
* other withdraw operations * other withdraw operations
* @return #GNUNET_OK on success * @return #GNUNET_OK on success
@ -233,6 +234,7 @@ TALER_planchet_setup_random (struct TALER_PlanchetSecretsP *ps)
int int
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
const struct TALER_PlanchetSecretsP *ps, const struct TALER_PlanchetSecretsP *ps,
struct GNUNET_HashCode *c_hash,
struct TALER_PlanchetDetail *pd) struct TALER_PlanchetDetail *pd)
{ {
struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_CoinSpendPublicKeyP coin_pub;
@ -241,9 +243,9 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
&coin_pub.eddsa_pub); &coin_pub.eddsa_pub);
GNUNET_CRYPTO_hash (&coin_pub.eddsa_pub, GNUNET_CRYPTO_hash (&coin_pub.eddsa_pub,
sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
&pd->c_hash); c_hash);
if (GNUNET_YES != if (GNUNET_YES !=
GNUNET_CRYPTO_rsa_blind (&pd->c_hash, GNUNET_CRYPTO_rsa_blind (c_hash,
&ps->blinding_key.bks, &ps->blinding_key.bks,
dk->rsa_public_key, dk->rsa_public_key,
&pd->coin_ev, &pd->coin_ev,