aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-12-16 20:18:44 +0100
committerChristian Grothoff <christian@grothoff.org>2021-12-16 20:18:44 +0100
commit1acc851deb38c52e4212823100eec8a00d5f385a (patch)
tree67d62b84291996a0def04e9cec16e06025a285ed /src/lib
parent3b6a0dd5994b824ecbf246bb17e5be7611e89386 (diff)
downloadexchange-1acc851deb38c52e4212823100eec8a00d5f385a.tar.xz
-fix recoup ugliness
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/exchange_api_common.c46
-rw-r--r--src/lib/exchange_api_recoup.c30
2 files changed, 36 insertions, 40 deletions
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index b14714ac6..93b992e65 100644
--- a/src/lib/exchange_api_common.c
+++ b/src/lib/exchange_api_common.c
@@ -688,17 +688,16 @@ TALER_EXCHANGE_verify_coin_history (
.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP),
.coin_pub = *coin_pub
};
- struct TALER_RecoupRequestPS rr = {
- .purpose.size = htonl (sizeof (pc)),
- .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_RECOUP),
- .coin_pub = *coin_pub
- };
+ union TALER_DenominationBlindingKeyP coin_bks;
+ struct TALER_Amount recoup_amount;
struct TALER_ExchangePublicKeyP exchange_pub;
struct TALER_ExchangeSignatureP exchange_sig;
struct TALER_CoinSpendSignatureP coin_sig;
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount_any_nbo ("amount",
&pc.recoup_amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &recoup_amount),
GNUNET_JSON_spec_fixed_auto ("exchange_sig",
&exchange_sig),
GNUNET_JSON_spec_fixed_auto ("exchange_pub",
@@ -708,9 +707,9 @@ TALER_EXCHANGE_verify_coin_history (
GNUNET_JSON_spec_fixed_auto ("coin_sig",
&coin_sig),
GNUNET_JSON_spec_fixed_auto ("coin_blind",
- &rr.coin_blind),
+ &coin_bks),
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
- &rr.h_denom_pub),
+ h_denom_pub),
GNUNET_JSON_spec_timestamp_nbo ("timestamp",
&pc.timestamp),
GNUNET_JSON_spec_end ()
@@ -736,15 +735,15 @@ TALER_EXCHANGE_verify_coin_history (
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_RECOUP,
- &rr,
- &coin_sig.eddsa_signature,
- &coin_pub->eddsa_pub))
+ TALER_wallet_recoup_verify (h_denom_pub,
+ &coin_bks,
+ &recoup_amount,
+ coin_pub,
+ &coin_sig))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- *h_denom_pub = rr.h_denom_pub;
add = GNUNET_YES;
}
else if (0 == strcasecmp (type,
@@ -758,17 +757,16 @@ TALER_EXCHANGE_verify_coin_history (
TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH),
.coin_pub = *coin_pub
};
- struct TALER_RecoupRequestPS rr = {
- .purpose.size = htonl (sizeof (pc)),
- .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_RECOUP),
- .coin_pub = *coin_pub
- };
+ union TALER_DenominationBlindingKeyP coin_bks;
+ struct TALER_Amount recoup_amount;
struct TALER_ExchangePublicKeyP exchange_pub;
struct TALER_ExchangeSignatureP exchange_sig;
struct TALER_CoinSpendSignatureP coin_sig;
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount_any_nbo ("amount",
&pc.recoup_amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &recoup_amount),
GNUNET_JSON_spec_fixed_auto ("exchange_sig",
&exchange_sig),
GNUNET_JSON_spec_fixed_auto ("exchange_pub",
@@ -778,9 +776,9 @@ TALER_EXCHANGE_verify_coin_history (
GNUNET_JSON_spec_fixed_auto ("old_coin_pub",
&pc.old_coin_pub),
GNUNET_JSON_spec_fixed_auto ("coin_blind",
- &rr.coin_blind),
+ &coin_bks),
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
- &rr.h_denom_pub),
+ h_denom_pub),
GNUNET_JSON_spec_timestamp_nbo ("timestamp",
&pc.timestamp),
GNUNET_JSON_spec_end ()
@@ -807,15 +805,15 @@ TALER_EXCHANGE_verify_coin_history (
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_RECOUP,
- &rr,
- &coin_sig.eddsa_signature,
- &coin_pub->eddsa_pub))
+ TALER_wallet_recoup_verify (h_denom_pub,
+ &coin_bks,
+ &recoup_amount,
+ coin_pub,
+ &coin_sig))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- *h_denom_pub = rr.h_denom_pub;
add = GNUNET_YES;
}
else if (0 == strcasecmp (type,
diff --git a/src/lib/exchange_api_recoup.c b/src/lib/exchange_api_recoup.c
index 92b59f4b0..05012926f 100644
--- a/src/lib/exchange_api_recoup.c
+++ b/src/lib/exchange_api_recoup.c
@@ -95,7 +95,7 @@ struct TALER_EXCHANGE_RecoupHandle
* @return #GNUNET_OK if the signature is valid and we called the callback;
* #GNUNET_SYSERR if not (callback must still be called)
*/
-static int
+static enum GNUNET_GenericReturnValue
process_recoup_response (const struct TALER_EXCHANGE_RecoupHandle *ph,
const json_t *json)
{
@@ -312,8 +312,8 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange,
{
struct TALER_EXCHANGE_RecoupHandle *ph;
struct GNUNET_CURL_Context *ctx;
- struct TALER_RecoupRequestPS pr;
struct TALER_CoinSpendSignatureP coin_sig;
+ struct TALER_CoinSpendPublicKeyP coin_pub;
struct TALER_DenominationHash h_denom_pub;
json_t *recoup_obj;
CURL *eh;
@@ -321,17 +321,15 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_assert (GNUNET_YES ==
TEAH_handle_is_ready (exchange));
- pr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_RECOUP);
- pr.purpose.size = htonl (sizeof (struct TALER_RecoupRequestPS));
GNUNET_CRYPTO_eddsa_key_get_public (&ps->coin_priv.eddsa_priv,
- &pr.coin_pub.eddsa_pub);
+ &coin_pub.eddsa_pub);
TALER_denom_pub_hash (&pk->key,
&h_denom_pub);
- pr.h_denom_pub = pk->h_key;
- pr.coin_blind = ps->blinding_key;
- GNUNET_CRYPTO_eddsa_sign (&ps->coin_priv.eddsa_priv,
- &pr,
- &coin_sig.eddsa_signature);
+ TALER_wallet_recoup_sign (&h_denom_pub,
+ &ps->blinding_key,
+ amount,
+ &ps->coin_priv,
+ &coin_sig);
recoup_obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("denom_pub_hash",
&h_denom_pub),
@@ -349,11 +347,11 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange,
char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2];
char *end;
- end = GNUNET_STRINGS_data_to_string (&pr.coin_pub,
- sizeof (struct
- TALER_CoinSpendPublicKeyP),
- pub_str,
- sizeof (pub_str));
+ end = GNUNET_STRINGS_data_to_string (
+ &coin_pub,
+ sizeof (struct TALER_CoinSpendPublicKeyP),
+ pub_str,
+ sizeof (pub_str));
*end = '\0';
GNUNET_snprintf (arg_str,
sizeof (arg_str),
@@ -362,7 +360,7 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange,
}
ph = GNUNET_new (struct TALER_EXCHANGE_RecoupHandle);
- ph->coin_pub = pr.coin_pub;
+ ph->coin_pub = coin_pub;
ph->exchange = exchange;
ph->pk = *pk;
memset (&ph->pk.key,