diff options
Diffstat (limited to 'src/exchange/taler-exchange-httpd_recoup-refresh.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_recoup-refresh.c | 68 |
1 files changed, 52 insertions, 16 deletions
diff --git a/src/exchange/taler-exchange-httpd_recoup-refresh.c b/src/exchange/taler-exchange-httpd_recoup-refresh.c index 78a454c85..a5d5b2ab4 100644 --- a/src/exchange/taler-exchange-httpd_recoup-refresh.c +++ b/src/exchange/taler-exchange-httpd_recoup-refresh.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2017-2021 Taler Systems SA + Copyright (C) 2017-2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -55,7 +55,7 @@ struct RecoupContext /** * Key used to blind the coin. */ - const union TALER_DenominationBlindingKeyP *coin_bks; + const union GNUNET_CRYPTO_BlindingSecretP *coin_bks; /** * Signature of the coin requesting recoup. @@ -146,6 +146,7 @@ recoup_refresh_transaction (void *cls, *mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds ( connection, TALER_EC_EXCHANGE_GENERIC_INSUFFICIENT_FUNDS, + &pc->coin->denom_pub_hash, &pc->coin->coin_pub); return GNUNET_DB_STATUS_HARD_ERROR; } @@ -162,7 +163,10 @@ recoup_refresh_transaction (void *cls, * * @param connection the MHD connection to handle * @param coin information about the coin + * @param exchange_vals values contributed by the exchange + * during refresh * @param coin_bks blinding data of the coin (to be checked) + * @param nonce withdraw nonce (if CS is used) * @param coin_sig signature of the coin * @return MHD result code */ @@ -170,13 +174,15 @@ static MHD_RESULT verify_and_execute_recoup_refresh ( struct MHD_Connection *connection, const struct TALER_CoinPublicInfo *coin, - const union TALER_DenominationBlindingKeyP *coin_bks, + const struct TALER_ExchangeWithdrawValues *exchange_vals, + const union GNUNET_CRYPTO_BlindingSecretP *coin_bks, + const union GNUNET_CRYPTO_BlindSessionNonce *nonce, const struct TALER_CoinSpendSignatureP *coin_sig) { struct RecoupContext pc; const struct TEH_DenominationKey *dk; MHD_RESULT mret; - struct TALER_BlindedCoinHash h_blind; + struct TALER_BlindedCoinHashP h_blind; /* check denomination exists and is in recoup mode */ dk = TEH_keys_denomination_by_hash (&coin->denom_pub_hash, @@ -213,6 +219,17 @@ verify_and_execute_recoup_refresh ( } /* check denomination signature */ + switch (dk->denom_pub.bsign_pub_key->cipher) + { + case GNUNET_CRYPTO_BSA_RSA: + TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_RSA]++; + break; + case GNUNET_CRYPTO_BSA_CS: + TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_CS]++; + break; + default: + break; + } if (GNUNET_YES != TALER_test_coin_valid (coin, &dk->denom_pub)) @@ -226,6 +243,7 @@ verify_and_execute_recoup_refresh ( } /* check recoup request signature */ + TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++; if (GNUNET_OK != TALER_wallet_recoup_refresh_verify (&coin->denom_pub_hash, coin_bks, @@ -241,18 +259,18 @@ verify_and_execute_recoup_refresh ( } { - void *coin_ev; - size_t coin_ev_size; - struct TALER_CoinPubHash c_hash; + struct TALER_CoinPubHashP c_hash; + struct TALER_BlindedPlanchet blinded_planchet; if (GNUNET_OK != TALER_denom_blind (&dk->denom_pub, coin_bks, - NULL, /* FIXME-Oec: TALER_AgeHash * */ + nonce, + &coin->h_age_commitment, &coin->coin_pub, + exchange_vals, &c_hash, - &coin_ev, - &coin_ev_size)) + &blinded_planchet)) { GNUNET_break (0); return TALER_MHD_reply_with_error ( @@ -261,10 +279,10 @@ verify_and_execute_recoup_refresh ( TALER_EC_EXCHANGE_RECOUP_REFRESH_BLINDING_FAILED, NULL); } - TALER_coin_ev_hash (coin_ev, - coin_ev_size, + TALER_coin_ev_hash (&blinded_planchet, + &coin->denom_pub_hash, &h_blind); - GNUNET_free (coin_ev); + TALER_blinded_planchet_free (&blinded_planchet); } pc.coin_sig = coin_sig; @@ -322,7 +340,7 @@ verify_and_execute_recoup_refresh ( if (GNUNET_OK != TEH_DB_run_transaction (connection, "run recoup-refresh", - TEH_MT_OTHER, + TEH_MT_REQUEST_OTHER, &mhd_ret, &recoup_refresh_transaction, &pc)) @@ -354,18 +372,32 @@ TEH_handler_recoup_refresh (struct MHD_Connection *connection, const json_t *root) { enum GNUNET_GenericReturnValue ret; - struct TALER_CoinPublicInfo coin; - union TALER_DenominationBlindingKeyP coin_bks; + struct TALER_CoinPublicInfo coin = {0}; + union GNUNET_CRYPTO_BlindingSecretP coin_bks; struct TALER_CoinSpendSignatureP coin_sig; + struct TALER_ExchangeWithdrawValues exchange_vals; + union GNUNET_CRYPTO_BlindSessionNonce nonce; + bool no_nonce; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", &coin.denom_pub_hash), TALER_JSON_spec_denom_sig ("denom_sig", &coin.denom_sig), + TALER_JSON_spec_exchange_withdraw_values ("ewv", + &exchange_vals), GNUNET_JSON_spec_fixed_auto ("coin_blind_key_secret", &coin_bks), GNUNET_JSON_spec_fixed_auto ("coin_sig", &coin_sig), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_fixed_auto ("h_age_commitment", + &coin.h_age_commitment), + &coin.no_age_commitment), + // FIXME: rename to just 'nonce' + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_fixed_auto ("cs_nonce", + &nonce), + &no_nonce), GNUNET_JSON_spec_end () }; @@ -385,7 +417,11 @@ TEH_handler_recoup_refresh (struct MHD_Connection *connection, res = verify_and_execute_recoup_refresh (connection, &coin, + &exchange_vals, &coin_bks, + no_nonce + ? NULL + : &nonce, &coin_sig); GNUNET_JSON_parse_free (spec); return res; |