summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-02-08 14:02:27 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-08 14:02:27 +0100
commitb3cf788424d641fb945fe4c9abe29155a6c6e962 (patch)
tree1a2c6b637dde250f5cbceefa6581cdb4e8dcea61
parent8cbe16a2203d581ad2bdfcd7240653d1ee416634 (diff)
downloadexchange-b3cf788424d641fb945fe4c9abe29155a6c6e962.tar.gz
exchange-b3cf788424d641fb945fe4c9abe29155a6c6e962.tar.bz2
exchange-b3cf788424d641fb945fe4c9abe29155a6c6e962.zip
-more test fixes
-rw-r--r--src/include/taler_exchange_service.h5
-rw-r--r--src/lib/exchange_api_melt.c32
-rw-r--r--src/lib/exchange_api_refresh_common.c2
-rw-r--r--src/lib/exchange_api_refreshes_reveal.c3
-rw-r--r--src/testing/Makefile.am3
-rw-r--r--src/testing/test_exchange_api_expire_reserve_now-cs.conf (renamed from src/testing/test_exchange_api_expire_reserve_now.conf)2
-rw-r--r--src/testing/test_exchange_api_expire_reserve_now-rsa.conf4
-rw-r--r--src/testing/testing_api_cmd_recoup_refresh.c13
-rw-r--r--src/testing/testing_api_cmd_refresh.c28
-rw-r--r--src/testing/testing_api_cmd_withdraw.c2
10 files changed, 69 insertions, 25 deletions
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index 65b8d72b6..a65e796a5 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -1705,9 +1705,9 @@ TALER_EXCHANGE_melt_cancel (struct TALER_EXCHANGE_MeltHandle *mh);
*
* @param cls closure
* @param hr HTTP response data
- * @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed
- * @param exchange_vals array of contributions from the exchange on the refreshes
+ * @param num_coins number of fresh coins created, length of the @a sigs, @a psa and @a coin_privs arrays, 0 if the operation failed
* @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error
+ * @param psa array of @a num_coins planchet secrets (derived from the transfer secret) for each of the coins
* @param sigs array of signature over @a num_coins coins, NULL on error
*/
typedef void
@@ -1716,6 +1716,7 @@ typedef void
const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs,
+ const struct TALER_PlanchetSecretsP *psa,
const struct TALER_DenominationSignature *sigs);
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);
}
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 16c7a563f..1704f3cb4 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -503,7 +503,8 @@ EXTRA_DIST = \
test_exchange_api_twisted.conf \
test_exchange_api_keys_cherry_picking-cs.conf \
test_exchange_api_keys_cherry_picking-rsa.conf \
- test_exchange_api_expire_reserve_now.conf \
+ test_exchange_api_expire_reserve_now-cs.conf \
+ test_exchange_api_expire_reserve_now-rsa.conf \
test_taler_exchange_httpd_home/.config/taler/account-1.json \
test_taler_exchange_httpd_home/.local/share/taler/exchange-offline/master.priv \
test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv \
diff --git a/src/testing/test_exchange_api_expire_reserve_now.conf b/src/testing/test_exchange_api_expire_reserve_now-cs.conf
index 05bca956b..2cc4e0917 100644
--- a/src/testing/test_exchange_api_expire_reserve_now.conf
+++ b/src/testing/test_exchange_api_expire_reserve_now-cs.conf
@@ -1,4 +1,4 @@
-@INLINE@ test_exchange_api.conf
+@INLINE@ test_exchange_api-cs.conf
[exchangedb]
IDLE_RESERVE_EXPIRATION_TIME = 0 s
diff --git a/src/testing/test_exchange_api_expire_reserve_now-rsa.conf b/src/testing/test_exchange_api_expire_reserve_now-rsa.conf
new file mode 100644
index 000000000..52b829871
--- /dev/null
+++ b/src/testing/test_exchange_api_expire_reserve_now-rsa.conf
@@ -0,0 +1,4 @@
+@INLINE@ test_exchange_api-rsa.conf
+
+[exchangedb]
+IDLE_RESERVE_EXPIRATION_TIME = 0 s
diff --git a/src/testing/testing_api_cmd_recoup_refresh.c b/src/testing/testing_api_cmd_recoup_refresh.c
index a1f34f70e..fd8f1c36c 100644
--- a/src/testing/testing_api_cmd_recoup_refresh.c
+++ b/src/testing/testing_api_cmd_recoup_refresh.c
@@ -230,6 +230,7 @@ recoup_refresh_run (void *cls,
{
struct RecoupRefreshState *ps = cls;
const struct TALER_TESTING_Command *coin_cmd;
+ const struct TALER_TESTING_Command *melt_cmd;
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
const struct TALER_EXCHANGE_DenomPublicKey *denom_pub;
const struct TALER_DenominationSignature *coin_sig;
@@ -251,13 +252,21 @@ recoup_refresh_run (void *cls,
coin_cmd = TALER_TESTING_interpreter_lookup_command (is,
cref);
GNUNET_free (cref);
-
if (NULL == coin_cmd)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
+ melt_cmd = TALER_TESTING_interpreter_lookup_command (is,
+ ps->melt_reference);
+ if (NULL == melt_cmd)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (is);
+ return;
+ }
+
if (GNUNET_OK !=
TALER_TESTING_get_trait_coin_priv (coin_cmd,
idx,
@@ -268,7 +277,7 @@ recoup_refresh_run (void *cls,
return;
}
if (GNUNET_OK !=
- TALER_TESTING_get_trait_exchange_wd_value (coin_cmd,
+ TALER_TESTING_get_trait_exchange_wd_value (melt_cmd,
idx,
&ewv))
{
diff --git a/src/testing/testing_api_cmd_refresh.c b/src/testing/testing_api_cmd_refresh.c
index 07476a7b3..88c694934 100644
--- a/src/testing/testing_api_cmd_refresh.c
+++ b/src/testing/testing_api_cmd_refresh.c
@@ -117,12 +117,12 @@ struct RefreshMeltState
struct TALER_EXCHANGE_DenomPublicKey *fresh_pks;
/**
- * Array of @a num_fresh_coins of exchange values contributed to the refresh operation
+ * Array of @e num_fresh_coins of exchange values contributed to the refresh operation
*/
struct TALER_ExchangeWithdrawValues *alg_values;
/**
- * Array of @a num_fresh_coins of blinding key secrets
+ * Array of @e num_fresh_coins of blinding key secrets
* created during the melt operation.
*/
union TALER_DenominationBlindingKeyP *bks;
@@ -215,6 +215,12 @@ struct RefreshRevealState
struct TALER_TESTING_FreshCoinData *fresh_coins;
/**
+ * Array of @e num_fresh_coins planchet secrets derived
+ * from the transfer secret per fresh coin.
+ */
+ struct TALER_PlanchetSecretsP *psa;
+
+ /**
* Interpreter state.
*/
struct TALER_TESTING_Interpreter *is;
@@ -346,6 +352,7 @@ do_reveal_retry (void *cls)
* failed.
* @param coin_privs array of @a num_coins private keys for the
* coins that were created, NULL on error.
+ * @param psa array of @a num_coins planchet secrets (derived from the transfer secret) for each of the coins
* @param sigs array of signature over @a num_coins coins,
* NULL on error.
*/
@@ -354,6 +361,7 @@ reveal_cb (void *cls,
const struct TALER_EXCHANGE_HttpResponse *hr,
unsigned int num_coins,
const struct TALER_CoinSpendPrivateKeyP *coin_privs,
+ const struct TALER_PlanchetSecretsP *psa,
const struct TALER_DenominationSignature *sigs)
{
struct RefreshRevealState *rrs = cls;
@@ -413,6 +421,9 @@ reveal_cb (void *cls,
switch (hr->http_status)
{
case MHD_HTTP_OK:
+ rrs->psa = GNUNET_memdup (psa,
+ num_coins
+ * sizeof (struct TALER_PlanchetSecretsP));
rrs->fresh_coins = GNUNET_new_array (num_coins,
struct TALER_TESTING_FreshCoinData);
for (unsigned int i = 0; i<num_coins; i++)
@@ -540,7 +551,7 @@ refresh_reveal_cleanup (void *cls,
TALER_denom_sig_free (&rrs->fresh_coins[j].sig);
GNUNET_free (rrs->fresh_coins);
- rrs->fresh_coins = NULL;
+ GNUNET_free (rrs->psa);
rrs->num_fresh_coins = 0;
GNUNET_free (rrs);
}
@@ -806,8 +817,10 @@ refresh_link_run (void *cls,
}
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
- if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
- (coin_cmd, 0, &coin_priv))
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_coin_priv (coin_cmd,
+ 0,
+ &coin_priv))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rls->is);
@@ -1216,9 +1229,10 @@ melt_traits (void *cls,
&rms->fresh_pks[index]),
TALER_TESTING_make_trait_coin_priv (0,
rms->melt_priv),
- // ????
TALER_TESTING_make_trait_blinding_key (index,
&rms->bks[index]),
+ TALER_TESTING_make_trait_exchange_wd_value (index,
+ &rms->alg_values[index]),
TALER_TESTING_trait_end ()
};
@@ -1392,6 +1406,8 @@ refresh_reveal_traits (void *cls,
&rrs->num_fresh_coins),
TALER_TESTING_make_trait_fresh_coins (
(const struct TALER_TESTING_FreshCoinData **) &rrs->fresh_coins),
+ TALER_TESTING_make_trait_planchet_secrets (index,
+ &rrs->psa[index]),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c
index 306409155..f1b38fd41 100644
--- a/src/testing/testing_api_cmd_withdraw.c
+++ b/src/testing/testing_api_cmd_withdraw.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2018-2021 Taler Systems SA
+ Copyright (C) 2018-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