From 8e03498a487d3d00c20167dc19c24f9a0fe1a647 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 8 Jul 2020 17:58:45 +0200 Subject: add h_denom to melt signatures (for #6416) --- src/auditor/taler-helper-auditor-coins.c | 4 ++++ src/exchange/taler-exchange-httpd_melt.c | 1 + src/exchange/taler-exchange-httpd_responses.c | 1 + src/include/taler_signatures.h | 3 +-- src/lib/exchange_api_common.c | 2 ++ src/lib/exchange_api_melt.c | 15 +++++++-------- 6 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index 1a03ac72d..b93521775 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c @@ -1283,6 +1283,8 @@ refresh_session_cb (void *cls, .coin_pub = *coin_pub }; + GNUNET_CRYPTO_rsa_public_key_hash (denom_pub->rsa_public_key, + &rmc.h_denom_pub); TALER_amount_hton (&rmc.amount_with_fee, amount_with_fee); if (GNUNET_OK != @@ -1620,6 +1622,8 @@ deposit_cb (void *cls, .coin_pub = *coin_pub }; + GNUNET_CRYPTO_rsa_public_key_hash (denom_pub->rsa_public_key, + &dr.h_denom_pub); if (GNUNET_OK != TALER_JSON_merchant_wire_signature_hash (receiver_wire_account, &dr.h_wire)) diff --git a/src/exchange/taler-exchange-httpd_melt.c b/src/exchange/taler-exchange-httpd_melt.c index 3a0195cfd..2eab4b4a9 100644 --- a/src/exchange/taler-exchange-httpd_melt.c +++ b/src/exchange/taler-exchange-httpd_melt.c @@ -380,6 +380,7 @@ handle_melt (struct MHD_Connection *connection, .purpose.size = htonl (sizeof (body)), .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT), .rc = rmc->refresh_session.rc, + .h_denom_pub = rmc->refresh_session.coin.denom_pub_hash, .coin_pub = rmc->refresh_session.coin.coin_pub }; diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index ee65cd6e0..979832958 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -131,6 +131,7 @@ TEH_RESPONSE_compile_transaction_history ( .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT), .purpose.size = htonl (sizeof (ms)), .rc = melt->rc, + .h_denom_pub = melt->h_denom_pub, .coin_pub = *coin_pub }; diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 81e2e1c82..3e4b893f8 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -586,9 +586,8 @@ struct TALER_RefreshMeltCoinAffirmationPS /** * Hash over the denomination public key used to sign the coin. - * FIXME: add here, initialize everywhere! */ - // struct GNUNET_HashCode h_denom_pub GNUNET_PACKED; + struct GNUNET_HashCode h_denom_pub GNUNET_PACKED; /** * How much of the value of the coin should be melted? This amount diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 27dbbb86c..17be0d51b 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -586,6 +586,8 @@ TALER_EXCHANGE_verify_coin_history ( &sig), GNUNET_JSON_spec_fixed_auto ("rc", &rm.rc), + GNUNET_JSON_spec_fixed_auto ("h_denom_pub", + &rm.h_denom_pub), TALER_JSON_spec_amount_nbo ("melt_fee", &rm.melt_fee), GNUNET_JSON_spec_end () diff --git a/src/lib/exchange_api_melt.c b/src/lib/exchange_api_melt.c index 0695f997b..1ef83bf73 100644 --- a/src/lib/exchange_api_melt.c +++ b/src/lib/exchange_api_melt.c @@ -392,9 +392,11 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, struct GNUNET_CURL_Context *ctx; struct MeltData *md; struct TALER_CoinSpendSignatureP confirm_sig; - struct TALER_RefreshMeltCoinAffirmationPS melt; - struct GNUNET_HashCode h_denom_pub; char arg_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2 + 32]; + struct TALER_RefreshMeltCoinAffirmationPS melt = { + .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT), + .purpose.size = htonl (sizeof (melt)), + }; GNUNET_assert (GNUNET_YES == TEAH_handle_is_ready (exchange)); @@ -405,9 +407,6 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, GNUNET_break (0); return NULL; } - melt.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); - melt.purpose.size = htonl (sizeof (struct - TALER_RefreshMeltCoinAffirmationPS)); melt.rc = md->rc; TALER_amount_hton (&melt.amount_with_fee, &md->melted_coin.melt_amount_with_fee); @@ -415,16 +414,16 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, &md->melted_coin.fee_melt); GNUNET_CRYPTO_eddsa_key_get_public (&md->melted_coin.coin_priv.eddsa_priv, &melt.coin_pub.eddsa_pub); + GNUNET_CRYPTO_rsa_public_key_hash (md->melted_coin.pub_key.rsa_public_key, + &melt.h_denom_pub); GNUNET_CRYPTO_eddsa_sign (&md->melted_coin.coin_priv.eddsa_priv, &melt, &confirm_sig.eddsa_signature); - GNUNET_CRYPTO_rsa_public_key_hash (md->melted_coin.pub_key.rsa_public_key, - &h_denom_pub); melt_obj = json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o}", "coin_pub", GNUNET_JSON_from_data_auto (&melt.coin_pub), "denom_pub_hash", - GNUNET_JSON_from_data_auto (&h_denom_pub), + GNUNET_JSON_from_data_auto (&melt.h_denom_pub), "denom_sig", GNUNET_JSON_from_rsa_signature ( md->melted_coin.sig.rsa_signature), -- cgit v1.2.3