From b3cf788424d641fb945fe4c9abe29155a6c6e962 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 8 Feb 2022 14:02:27 +0100 Subject: -more test fixes --- src/lib/exchange_api_melt.c | 32 +++++++++++++++++++++----------- src/lib/exchange_api_refresh_common.c | 2 +- src/lib/exchange_api_refreshes_reveal.c | 3 +++ 3 files changed, 25 insertions(+), 12 deletions(-) (limited to 'src/lib') diff --git a/src/lib/exchange_api_melt.c b/src/lib/exchange_api_melt.c index 3308ffda6..c4d9fb16c 100644 --- a/src/lib/exchange_api_melt.c +++ b/src/lib/exchange_api_melt.c @@ -111,6 +111,12 @@ struct TALER_EXCHANGE_MeltHandle * @brief Public information about the coin's denomination key */ const struct TALER_EXCHANGE_DenomPublicKey *dki; + + /** + * Gamma value chosen by the exchange during melt. + */ + uint32_t noreveal_index; + }; @@ -118,17 +124,15 @@ struct TALER_EXCHANGE_MeltHandle * Verify that the signature on the "200 OK" response * from the exchange is valid. * - * @param mh melt handle + * @param[in,out] mh melt handle * @param json json reply with the signature * @param[out] exchange_pub public key of the exchange used for the signature - * @param[out] noreveal_index set to the noreveal index selected by the exchange * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not */ static enum GNUNET_GenericReturnValue verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh, const json_t *json, - struct TALER_ExchangePublicKeyP *exchange_pub, - uint32_t *noreveal_index) + struct TALER_ExchangePublicKeyP *exchange_pub) { struct TALER_ExchangeSignatureP exchange_sig; const struct TALER_EXCHANGE_Keys *key_state; @@ -138,7 +142,7 @@ verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh, GNUNET_JSON_spec_fixed_auto ("exchange_pub", exchange_pub), GNUNET_JSON_spec_uint32 ("noreveal_index", - noreveal_index), + &mh->noreveal_index), GNUNET_JSON_spec_end () }; @@ -161,7 +165,7 @@ verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh, } /* check that noreveal index is in permitted range */ - if (TALER_CNC_KAPPA <= *noreveal_index) + if (TALER_CNC_KAPPA <= mh->noreveal_index) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -173,7 +177,7 @@ verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh, .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_MELT), .purpose.size = htonl (sizeof (confirm)), .rc = mh->md.rc, - .noreveal_index = htonl (*noreveal_index) + .noreveal_index = htonl (mh->noreveal_index) }; if (GNUNET_OK != @@ -341,7 +345,6 @@ handle_melt_finished (void *cls, const void *response) { struct TALER_EXCHANGE_MeltHandle *mh = cls; - uint32_t noreveal_index = TALER_CNC_KAPPA; /* invalid value */ struct TALER_ExchangePublicKeyP exchange_pub; const json_t *j = response; struct TALER_EXCHANGE_HttpResponse hr = { @@ -359,8 +362,7 @@ handle_melt_finished (void *cls, if (GNUNET_OK != verify_melt_signature_ok (mh, j, - &exchange_pub, - &noreveal_index)) + &exchange_pub)) { GNUNET_break_op (0); hr.http_status = 0; @@ -379,7 +381,7 @@ handle_melt_finished (void *cls, (0 == hr.http_status) ? NULL : mh->bks, - noreveal_index, + mh->noreveal_index, (0 == hr.http_status) ? NULL : &exchange_pub); @@ -469,6 +471,13 @@ handle_melt_finished (void *cls, } +/** + * Start the actual melt operation, now that we have + * the exchange's input values. + * + * @param[in,out] mh melt operation to run + * @return #GNUNET_OK if we could start the operation + */ static enum GNUNET_GenericReturnValue start_melt (struct TALER_EXCHANGE_MeltHandle *mh) { @@ -644,6 +653,7 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, GNUNET_assert (GNUNET_YES == TEAH_handle_is_ready (exchange)); mh = GNUNET_new (struct TALER_EXCHANGE_MeltHandle); + mh->noreveal_index = TALER_CNC_KAPPA; /* invalid value */ mh->exchange = exchange; mh->rd = rd; mh->ps = ps; diff --git a/src/lib/exchange_api_refresh_common.c b/src/lib/exchange_api_refresh_common.c index 7d8f4c920..8891377eb 100644 --- a/src/lib/exchange_api_refresh_common.c +++ b/src/lib/exchange_api_refresh_common.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2021 Taler Systems SA + Copyright (C) 2015-2022 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software diff --git a/src/lib/exchange_api_refreshes_reveal.c b/src/lib/exchange_api_refreshes_reveal.c index acef3e19b..1d748e299 100644 --- a/src/lib/exchange_api_refreshes_reveal.c +++ b/src/lib/exchange_api_refreshes_reveal.c @@ -250,10 +250,12 @@ handle_refresh_reveal_finished (void *cls, } else { + GNUNET_assert (rrh->noreveal_index < TALER_CNC_KAPPA); rrh->reveal_cb (rrh->reveal_cb_cls, &hr, rrh->md.num_fresh_coins, coin_privs, + rrh->md.fresh_coins[rrh->noreveal_index], sigs); rrh->reveal_cb = NULL; } @@ -302,6 +304,7 @@ handle_refresh_reveal_finished (void *cls, &hr, 0, NULL, + NULL, NULL); TALER_EXCHANGE_refreshes_reveal_cancel (rrh); } -- cgit v1.2.3