diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-05-16 11:55:47 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-05-16 11:55:47 +0200 |
commit | c8b9370413d6a330f3b457359ed309ac9e964533 (patch) | |
tree | 5ae6cc04d2d04731fdf802704ab2570dc3587040 /src/exchange | |
parent | 068dbf020b1f762d4364ca378c1396d16fa6eb1a (diff) | |
download | exchange-c8b9370413d6a330f3b457359ed309ac9e964533.tar.gz exchange-c8b9370413d6a330f3b457359ed309ac9e964533.tar.bz2 exchange-c8b9370413d6a330f3b457359ed309ac9e964533.zip |
fixing #3814 by removing ability to melt multiple oldcoins at the same time
Diffstat (limited to 'src/exchange')
-rw-r--r-- | src/exchange/taler-exchange-httpd_db.c | 295 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_db.h | 14 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_refresh.c | 330 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 80 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.h | 2 |
5 files changed, 246 insertions, 475 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index 7c67e14f0..b6d31dbc9 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c @@ -868,18 +868,18 @@ TMH_DB_execute_reserve_withdraw (struct MHD_Connection *connection, * @param key_state the exchange's key state * @param session_hash hash identifying the refresh session * @param coin_details details about the coin being melted - * @param oldcoin_index what is the number assigned to this coin + * @param[out] meltp on success, set to melt details * @return #GNUNET_OK on success, * #GNUNET_NO if an error message was generated, * #GNUNET_SYSERR on internal errors (no response generated) */ static int -refresh_accept_melts (struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - const struct TMH_KS_StateHandle *key_state, - const struct GNUNET_HashCode *session_hash, - const struct TMH_DB_MeltDetails *coin_details, - uint16_t oldcoin_index) +refresh_check_melt (struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + const struct TMH_KS_StateHandle *key_state, + const struct GNUNET_HashCode *session_hash, + const struct TMH_DB_MeltDetails *coin_details, + struct TALER_EXCHANGEDB_RefreshMelt *meltp) { struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dk; struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; @@ -887,7 +887,6 @@ refresh_accept_melts (struct MHD_Connection *connection, struct TALER_Amount coin_value; struct TALER_Amount coin_residual; struct TALER_Amount spent; - struct TALER_EXCHANGEDB_RefreshMelt melt; int res; dk = TMH_KS_denomination_key_lookup (key_state, @@ -943,22 +942,11 @@ refresh_accept_melts (struct MHD_Connection *connection, TMH_plugin->free_coin_transaction_list (TMH_plugin->cls, tl); - melt.coin = coin_details->coin_info; - melt.coin_sig = coin_details->melt_sig; - melt.session_hash = *session_hash; - melt.amount_with_fee = coin_details->melt_amount_with_fee; - melt.melt_fee = coin_details->melt_fee; - if (GNUNET_OK != - TMH_plugin->insert_refresh_melt (TMH_plugin->cls, - session, - oldcoin_index, - &melt)) - { - GNUNET_break (0); - return (MHD_YES == - TMH_RESPONSE_reply_internal_db_error (connection)) - ? GNUNET_NO : GNUNET_SYSERR; - } + meltp->coin = coin_details->coin_info; + meltp->coin_sig = coin_details->melt_sig; + meltp->session_hash = *session_hash; + meltp->amount_with_fee = coin_details->melt_amount_with_fee; + meltp->melt_fee = coin_details->melt_fee; return GNUNET_OK; } @@ -974,15 +962,13 @@ refresh_accept_melts (struct MHD_Connection *connection, * @param session_hash hash code of the session the coins are melted into * @param num_new_denoms number of entries in @a denom_pubs, size of y-dimension of @a commit_coin array * @param denom_pubs public keys of the coins we want to withdraw in the end - * @param coin_count number of entries in @a coin_melt_details, size of y-dimension of @a commit_link array - * @param coin_melt_details signatures and (residual) value of the respective coin should be melted + * @param coin_melt_detail signature and (residual) value of the respective coin should be melted * @param commit_coin 2d array of coin commitments (what the exchange is to sign * once the "/refres/reveal" of cut and choose is done), * x-dimension must be #TALER_CNC_KAPPA - * @param commit_link 2d array of coin link commitments (what the exchange is + * @param commit_link array of coin link commitments (what the exchange is * to return via "/refresh/link" to enable linkage in the - * future) - * x-dimension must be #TALER_CNC_KAPPA + * future) of length #TALER_CNC_KAPPA * @return MHD result code */ int @@ -990,10 +976,9 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, unsigned int num_new_denoms, const struct TALER_DenominationPublicKey *denom_pubs, - unsigned int coin_count, - const struct TMH_DB_MeltDetails *coin_melt_details, + const struct TMH_DB_MeltDetails *coin_melt_detail, struct TALER_EXCHANGEDB_RefreshCommitCoin *const* commit_coin, - struct TALER_RefreshCommitLinkP *const* commit_link) + const struct TALER_RefreshCommitLinkP *commit_link) { struct TMH_KS_StateHandle *key_state; struct TALER_EXCHANGEDB_RefreshSession refresh_session; @@ -1028,11 +1013,26 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, } /* store 'global' session data */ - refresh_session.num_oldcoins = coin_count; refresh_session.num_newcoins = num_new_denoms; refresh_session.noreveal_index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, TALER_CNC_KAPPA); + key_state = TMH_KS_acquire (); + if (GNUNET_OK != + (res = refresh_check_melt (connection, + session, + key_state, + session_hash, + coin_melt_detail, + &refresh_session.melt))) + { + TMH_KS_release (key_state); + TMH_plugin->rollback (TMH_plugin->cls, + session); + return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; + } + TMH_KS_release (key_state); + if (GNUNET_OK != (res = TMH_plugin->create_refresh_session (TMH_plugin->cls, session, @@ -1044,26 +1044,6 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, return TMH_RESPONSE_reply_internal_db_error (connection); } - /* Melt old coins and check that they had enough residual value */ - key_state = TMH_KS_acquire (); - for (i=0;i<coin_count;i++) - { - if (GNUNET_OK != - (res = refresh_accept_melts (connection, - session, - key_state, - session_hash, - &coin_melt_details[i], - i))) - { - TMH_KS_release (key_state); - TMH_plugin->rollback (TMH_plugin->cls, - session); - return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; - } - } - TMH_KS_release (key_state); - /* store requested new denominations */ if (GNUNET_OK != TMH_plugin->insert_refresh_order (TMH_plugin->cls, @@ -1095,12 +1075,11 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, for (i = 0; i < TALER_CNC_KAPPA; i++) { if (GNUNET_OK != - TMH_plugin->insert_refresh_commit_links (TMH_plugin->cls, - session, - session_hash, - i, - coin_count, - commit_link[i])) + TMH_plugin->insert_refresh_commit_link (TMH_plugin->cls, + session, + session_hash, + i, + &commit_link[i])) { TMH_plugin->rollback (TMH_plugin->cls, session); @@ -1122,8 +1101,9 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, * @param connection the MHD connection to handle * @param session database connection to use * @param session_hash hash of session to query + * @param rm details about the original melt * @param off commitment offset to check - * @param index index of the mismatch + * @param index index of the mismatch, UINT_MAX if there is no such index * @param object_name name of the object with the problem * @return #GNUNET_NO if we generated the error message * #GNUNET_SYSERR if we could not even generate an error message @@ -1132,6 +1112,7 @@ static int send_melt_commitment_error (struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, + const struct TALER_EXCHANGEDB_RefreshMelt *rm, unsigned int off, unsigned int index, const char *object_name) @@ -1152,6 +1133,7 @@ send_melt_commitment_error (struct MHD_Connection *connection, } ret = (MHD_YES == TMH_RESPONSE_reply_refresh_reveal_missmatch (connection, + rm, mc, off, index, @@ -1173,9 +1155,8 @@ send_melt_commitment_error (struct MHD_Connection *connection, * @param session database connection to use * @param session_hash hash of session to query * @param off commitment offset to check - * @param num_oldcoins size of the @a transfer_privs and @a melts arrays - * @param transfer_privs private transfer keys - * @param melts array of melted coins + * @param transfer_priv private transfer key + * @param melt information about the melted coin * @param num_newcoins number of newcoins being generated * @param denom_pubs array of @a num_newcoins keys for the new coins * @return #GNUNET_OK if the committment was honest, @@ -1187,91 +1168,58 @@ check_commitment (struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, unsigned int off, - unsigned int num_oldcoins, - const struct TALER_TransferPrivateKeyP *transfer_privs, - const struct TALER_EXCHANGEDB_RefreshMelt *melts, + const struct TALER_TransferPrivateKeyP *transfer_priv, + const struct TALER_EXCHANGEDB_RefreshMelt *melt, unsigned int num_newcoins, const struct TALER_DenominationPublicKey *denom_pubs) { - unsigned int j; - struct TALER_LinkSecretP last_shared_secret; - int secret_initialized = GNUNET_NO; - struct TALER_RefreshCommitLinkP *commit_links; + struct TALER_RefreshCommitLinkP commit_link; + struct TALER_LinkSecretP shared_secret; + struct TALER_TransferPublicKeyP transfer_pub_check; struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins; + unsigned int j; - commit_links = GNUNET_malloc (num_oldcoins * - sizeof (struct TALER_RefreshCommitLinkP)); if (GNUNET_OK != - TMH_plugin->get_refresh_commit_links (TMH_plugin->cls, - session, - session_hash, - off, - num_oldcoins, - commit_links)) + TMH_plugin->get_refresh_commit_link (TMH_plugin->cls, + session, + session_hash, + off, + &commit_link)) { GNUNET_break (0); - GNUNET_free (commit_links); return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection)) ? GNUNET_NO : GNUNET_SYSERR; } - for (j = 0; j < num_oldcoins; j++) + GNUNET_CRYPTO_ecdhe_key_get_public (&transfer_priv->ecdhe_priv, + &transfer_pub_check.ecdhe_pub); + if (0 != + memcmp (&transfer_pub_check, + &commit_link.transfer_pub, + sizeof (struct TALER_TransferPublicKeyP))) { - struct TALER_LinkSecretP shared_secret; - struct TALER_TransferPublicKeyP transfer_pub_check; - - GNUNET_CRYPTO_ecdhe_key_get_public (&transfer_privs[j].ecdhe_priv, - &transfer_pub_check.ecdhe_pub); - if (0 != - memcmp (&transfer_pub_check, - &commit_links[j].transfer_pub, - sizeof (struct TALER_TransferPublicKeyP))) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "transfer keys do not match\n"); - GNUNET_free (commit_links); - return send_melt_commitment_error (connection, - session, - session_hash, - off, - j, - "transfer key"); - } + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "transfer keys do not match\n"); + return send_melt_commitment_error (connection, + session, + session_hash, + melt, + off, + UINT_MAX, + "transfer key"); + } - if (GNUNET_OK != - TALER_link_decrypt_secret (&commit_links[j].shared_secret_enc, - &transfer_privs[j], - &melts[j].coin.coin_pub, - &shared_secret)) - { - GNUNET_free (commit_links); - return (MHD_YES == - TMH_RESPONSE_reply_internal_error (connection, - "Transfer secret decryption error")) - ? GNUNET_NO : GNUNET_SYSERR; - } - if (GNUNET_NO == secret_initialized) - { - secret_initialized = GNUNET_YES; - last_shared_secret = shared_secret; - } - else if (0 != memcmp (&shared_secret, - &last_shared_secret, - sizeof (struct GNUNET_HashCode))) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "shared secrets do not match\n"); - GNUNET_free (commit_links); - return send_melt_commitment_error (connection, - session, - session_hash, - off, - j, - "transfer secret"); - } + if (GNUNET_OK != + TALER_link_decrypt_secret (&commit_link.shared_secret_enc, + transfer_priv, + &melt->coin.coin_pub, + &shared_secret)) + { + return (MHD_YES == + TMH_RESPONSE_reply_internal_error (connection, + "Transfer secret decryption error")) + ? GNUNET_NO : GNUNET_SYSERR; } - GNUNET_break (GNUNET_YES == secret_initialized); - GNUNET_free (commit_links); /* Check that the commitments for all new coins were correct */ commit_coins = GNUNET_malloc (num_newcoins * @@ -1300,7 +1248,7 @@ check_commitment (struct MHD_Connection *connection, size_t buf_len; link_data = TALER_refresh_decrypt (commit_coins[j].refresh_link, - &last_shared_secret); + &shared_secret); if (NULL == link_data) { GNUNET_break (0); @@ -1342,6 +1290,7 @@ check_commitment (struct MHD_Connection *connection, return send_melt_commitment_error (connection, session, session_hash, + melt, off, j, "envelope"); @@ -1422,7 +1371,6 @@ refresh_exchange_coin (struct MHD_Connection *connection, * @param session database session * @param session_hash hash identifying the refresh session * @param refresh_session information about the refresh operation we are doing - * @param melts array of "num_oldcoins" with information about melted coins * @param denom_pubs array of "num_newcoins" denomination keys for the new coins * @param[out] ev_sigs where to store generated signatures for the new coins, * array of length "num_newcoins", memory released by the @@ -1436,7 +1384,6 @@ execute_refresh_reveal_transaction (struct MHD_Connection *connection, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, const struct TALER_EXCHANGEDB_RefreshSession *refresh_session, - const struct TALER_EXCHANGEDB_RefreshMelt *melts, const struct TALER_DenominationPublicKey *denom_pubs, struct TALER_DenominationSignature *ev_sigs, struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins) @@ -1461,12 +1408,12 @@ execute_refresh_reveal_transaction (struct MHD_Connection *connection, { if (NULL == ev_sigs[j].rsa_signature) /* could be non-NULL during retries */ ev_sigs[j] = refresh_exchange_coin (connection, - session, - session_hash, - key_state, - &denom_pubs[j], - &commit_coins[j], - j); + session, + session_hash, + key_state, + &denom_pubs[j], + &commit_coins[j], + j); if (NULL == ev_sigs[j].rsa_signature) { TMH_KS_release (key_state); @@ -1490,21 +1437,18 @@ execute_refresh_reveal_transaction (struct MHD_Connection *connection, * * @param connection the MHD connection to handle * @param session_hash hash identifying the refresh session - * @param num_oldcoins size of y-dimension of @a transfer_privs array * @param transfer_privs array with the revealed transfer keys, - * x-dimension must be #TALER_CNC_KAPPA - 1 + * length must be #TALER_CNC_KAPPA - 1 * @return MHD result code */ int TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, - unsigned int num_oldcoins, - struct TALER_TransferPrivateKeyP **transfer_privs) + struct TALER_TransferPrivateKeyP *transfer_privs) { int res; struct TALER_EXCHANGEDB_Session *session; struct TALER_EXCHANGEDB_RefreshSession refresh_session; - struct TALER_EXCHANGEDB_RefreshMelt *melts; struct TALER_DenominationPublicKey *denom_pubs; struct TALER_DenominationSignature *ev_sigs; struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins; @@ -1527,33 +1471,6 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection, "session_hash"); if (GNUNET_SYSERR == res) return TMH_RESPONSE_reply_internal_db_error (connection); - if (0 == refresh_session.num_oldcoins) - { - GNUNET_break (0); - return TMH_RESPONSE_reply_internal_db_error (connection); - } - - melts = GNUNET_malloc (refresh_session.num_oldcoins * - sizeof (struct TALER_EXCHANGEDB_RefreshMelt)); - for (j=0;j<refresh_session.num_oldcoins;j++) - { - if (GNUNET_OK != - TMH_plugin->get_refresh_melt (TMH_plugin->cls, - session, - session_hash, - j, - &melts[j])) - { - GNUNET_break (0); - for (i=0;i<j;i++) - { - GNUNET_CRYPTO_rsa_signature_free (melts[i].coin.denom_sig.rsa_signature); - GNUNET_CRYPTO_rsa_public_key_free (melts[i].coin.denom_pub.rsa_public_key); - } - GNUNET_free (melts); - return TMH_RESPONSE_reply_internal_db_error (connection); - } - } denom_pubs = GNUNET_malloc (refresh_session.num_newcoins * sizeof (struct TALER_DenominationPublicKey)); if (GNUNET_OK != @@ -1565,12 +1482,8 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection, { GNUNET_break (0); GNUNET_free (denom_pubs); - for (i=0;i<refresh_session.num_oldcoins;i++) - { - GNUNET_CRYPTO_rsa_signature_free (melts[i].coin.denom_sig.rsa_signature); - GNUNET_CRYPTO_rsa_public_key_free (melts[i].coin.denom_pub.rsa_public_key); - } - GNUNET_free (melts); + GNUNET_CRYPTO_rsa_signature_free (refresh_session.melt.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_public_key_free (refresh_session.melt.coin.denom_pub.rsa_public_key); return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection)) ? GNUNET_NO : GNUNET_SYSERR; } @@ -1586,30 +1499,19 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection, session, session_hash, i + off, - refresh_session.num_oldcoins, - transfer_privs[i], - melts, + &transfer_privs[i], + &refresh_session.melt, refresh_session.num_newcoins, denom_pubs))) { for (j=0;j<refresh_session.num_newcoins;j++) GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); - for (i=0;i<refresh_session.num_oldcoins;i++) - { - GNUNET_CRYPTO_rsa_signature_free (melts[i].coin.denom_sig.rsa_signature); - GNUNET_CRYPTO_rsa_public_key_free (melts[i].coin.denom_pub.rsa_public_key); - } - GNUNET_free (melts); + GNUNET_CRYPTO_rsa_signature_free (refresh_session.melt.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_public_key_free (refresh_session.melt.coin.denom_pub.rsa_public_key); return (GNUNET_NO == res) ? MHD_YES : MHD_NO; } } - for (i=0;i<refresh_session.num_oldcoins;i++) - { - GNUNET_CRYPTO_rsa_signature_free (melts[i].coin.denom_sig.rsa_signature); - GNUNET_CRYPTO_rsa_public_key_free (melts[i].coin.denom_pub.rsa_public_key); - } - GNUNET_free (melts); /* Client request OK, start transaction */ commit_coins = GNUNET_malloc (refresh_session.num_newcoins * @@ -1620,7 +1522,6 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection, session, session_hash, &refresh_session, - melts, denom_pubs, ev_sigs, commit_coins); @@ -1630,6 +1531,8 @@ TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection, for (j=0;j<refresh_session.num_newcoins;j++) if (NULL != denom_pubs[j].rsa_public_key) GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); + GNUNET_CRYPTO_rsa_signature_free (refresh_session.melt.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_public_key_free (refresh_session.melt.coin.denom_pub.rsa_public_key); GNUNET_free (ev_sigs); GNUNET_free (denom_pubs); GNUNET_free (commit_coins); diff --git a/src/exchange/taler-exchange-httpd_db.h b/src/exchange/taler-exchange-httpd_db.h index 7cf498285..c0fd110b6 100644 --- a/src/exchange/taler-exchange-httpd_db.h +++ b/src/exchange/taler-exchange-httpd_db.h @@ -133,13 +133,12 @@ struct TMH_DB_MeltDetails * @param session_hash hash code of the session the coins are melted into * @param num_new_denoms number of entries in @a denom_pubs, size of y-dimension of @a commit_coin array * @param denom_pubs array of public denomination keys for the refresh (?) - * @param coin_count number of entries in @ a coin_melt_details, size of y-dimension of @a commit_link array * @param coin_melt_details signatures and (residual) value of and information about the respective coin to be melted * @param commit_coin 2d array of coin commitments (what the exchange is to sign * once the "/refres/reveal" of cut and choose is done) - * @param commit_link 2d array of coin link commitments (what the exchange is + * @param commit_link array of coin link commitments (what the exchange is * to return via "/refresh/link" to enable linkage in the - * future) + * future) of length #TALER_CNC_KAPPA * @return MHD result code */ int @@ -147,10 +146,9 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, unsigned int num_new_denoms, const struct TALER_DenominationPublicKey *denom_pubs, - unsigned int coin_count, const struct TMH_DB_MeltDetails *coin_melt_details, struct TALER_EXCHANGEDB_RefreshCommitCoin *const* commit_coin, - struct TALER_RefreshCommitLinkP *const* commit_link); + const struct TALER_RefreshCommitLinkP *commit_link); /** @@ -162,15 +160,13 @@ TMH_DB_execute_refresh_melt (struct MHD_Connection *connection, * * @param connection the MHD connection to handle * @param session_hash hash over the refresh session - * @param num_oldcoins size of y-dimension of @a transfer_privs array - * @param transfer_privs array with the revealed transfer keys, #TALER_CNC_KAPPA is 1st-dimension + * @param transfer_privs array of length #TALER_CNC_KAPPA-1 with the revealed transfer keys * @return MHD result code */ int TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, - unsigned int num_oldcoins, - struct TALER_TransferPrivateKeyP **transfer_privs); + struct TALER_TransferPrivateKeyP *transfer_privs); /** diff --git a/src/exchange/taler-exchange-httpd_refresh.c b/src/exchange/taler-exchange-httpd_refresh.c index 2349d90ac..b147b57a9 100644 --- a/src/exchange/taler-exchange-httpd_refresh.c +++ b/src/exchange/taler-exchange-httpd_refresh.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. + Copyright (C) 2014, 2015, 2016 Inria & GNUnet e.V. 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 @@ -39,25 +39,23 @@ * @param connection the MHD connection to handle * @param num_new_denoms number of coins to be created, size of y-dimension of @a commit_link array * @param denom_pubs array of @a num_new_denoms keys - * @param coin_count number of coins to be melted, size of y-dimension of @a commit_coin array - * @param coin_melt_details array with @a coin_count entries with melting details + * @param coin_melt_details melting details * @param session_hash hash over the data that the client commits to * @param commit_coin 2d array of coin commitments (what the exchange is to sign * once the "/refres/reveal" of cut and choose is done) - * @param commit_link 2d array of coin link commitments (what the exchange is + * @param commit_link array of coin link commitments (what the exchange is * to return via "/refresh/link" to enable linkage in the - * future) + * future) of length #TALER_CNC_KAPPA * @return MHD result code */ static int handle_refresh_melt_binary (struct MHD_Connection *connection, unsigned int num_new_denoms, const struct TALER_DenominationPublicKey *denom_pubs, - unsigned int coin_count, const struct TMH_DB_MeltDetails *coin_melt_details, const struct GNUNET_HashCode *session_hash, struct TALER_EXCHANGEDB_RefreshCommitCoin *const* commit_coin, - struct TALER_RefreshCommitLinkP *const* commit_link) + const struct TALER_RefreshCommitLinkP * commit_link) { unsigned int i; struct TMH_KS_StateHandle *key_state; @@ -65,7 +63,6 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; struct TALER_Amount cost; struct TALER_Amount total_cost; - struct TALER_Amount melt; struct TALER_Amount value; struct TALER_Amount fee_withdraw; struct TALER_Amount fee_melt; @@ -108,45 +105,27 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, } } - GNUNET_assert (GNUNET_OK == - TALER_amount_get_zero (TMH_exchange_currency_string, - &total_melt)); - for (i=0;i<coin_count;i++) + dk = TMH_KS_denomination_key_lookup (key_state, + &coin_melt_details->coin_info.denom_pub, + TMH_KS_DKU_DEPOSIT); + if (NULL == dk) { - /* calculate contribution of the i-th melt by subtracting - the fee; add the rest to the total_melt value */ - dk = TMH_KS_denomination_key_lookup (key_state, - &coin_melt_details[i].coin_info.denom_pub, - TMH_KS_DKU_DEPOSIT); - if (NULL == dk) - { - GNUNET_break (0); - return TMH_RESPONSE_reply_arg_invalid (connection, - "denom_pub"); - } - dki = &dk->issue; - TALER_amount_ntoh (&fee_melt, - &dki->properties.fee_refresh); - if (GNUNET_OK != - TALER_amount_subtract (&melt, - &coin_melt_details->melt_amount_with_fee, - &fee_melt)) - { - GNUNET_break_op (0); - TMH_KS_release (key_state); - return TMH_RESPONSE_reply_external_error (connection, - "Melt contribution below melting fee"); - } - if (GNUNET_OK != - TALER_amount_add (&total_melt, - &melt, - &total_melt)) - { - GNUNET_break_op (0); - TMH_KS_release (key_state); - return TMH_RESPONSE_reply_internal_error (connection, - "balance calculation failure"); - } + GNUNET_break (0); + return TMH_RESPONSE_reply_arg_invalid (connection, + "denom_pub"); + } + dki = &dk->issue; + TALER_amount_ntoh (&fee_melt, + &dki->properties.fee_refresh); + if (GNUNET_OK != + TALER_amount_subtract (&total_melt, + &coin_melt_details->melt_amount_with_fee, + &fee_melt)) + { + GNUNET_break_op (0); + TMH_KS_release (key_state); + return TMH_RESPONSE_reply_external_error (connection, + "Melt contribution below melting fee"); } TMH_KS_release (key_state); if (0 != @@ -165,7 +144,6 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, session_hash, num_new_denoms, denom_pubs, - coin_count, coin_melt_details, commit_coin, commit_link); @@ -184,7 +162,7 @@ handle_refresh_melt_binary (struct MHD_Connection *connection, */ static int get_coin_public_info (struct MHD_Connection *connection, - json_t *coin_info, + const json_t *coin_info, struct TMH_DB_MeltDetails *r_melt_detail) { int ret; @@ -336,29 +314,6 @@ free_commit_coins (struct TALER_EXCHANGEDB_RefreshCommitCoin **commit_coin, /** - * Release memory from the @a commit_link array. - * - * @param commit_link array to release - * @param kappa size of 1st dimension - * @param num_old_coins size of 2nd dimension - */ -static void -free_commit_links (struct TALER_RefreshCommitLinkP **commit_link, - unsigned int kappa, - unsigned int num_old_coins) -{ - unsigned int i; - - for (i=0;i<kappa;i++) - { - if (NULL == commit_link[i]) - break; - GNUNET_free (commit_link[i]); - } -} - - -/** * Handle a "/refresh/melt" request after the first parsing has happened. * We now need to validate the coins being melted and the session signature * and then hand things of to execute the melt operation. This function @@ -367,23 +322,19 @@ free_commit_links (struct TALER_RefreshCommitLinkP **commit_link, * * @param connection the MHD connection to handle * @param new_denoms array of denomination keys - * @param melt_coins array of coins to melt - * @param num_oldcoins number of coins that are being melted - * @param transfer_pubs #TALER_CNC_KAPPA-dimensional array of @a num_oldcoins transfer keys - * @param secret_encs #TALER_CNC_KAPPA-dimensional array of @a num_oldcoins secrets - * @param num_newcoins number of coins that the refresh will generate - * @param coin_evs #TALER_CNC_KAPPA-dimensional array of @a num_newcoins envelopes to sign - * @param link_encs #TALER_CNC_KAPPA-dimensional array of @a num_newcoins encrypted links + * @param melt_coin coin to melt + * @param transfer_pubs #TALER_CNC_KAPPA-dimensional array of transfer keys + * @param secret_encs #TALER_CNC_KAPPA-dimensional array of old coin secrets + * @param coin_evs #TALER_CNC_KAPPA-dimensional array of envelopes to sign + * @param link_encs #TALER_CNC_KAPPA-dimensional array of `length(@a new_denoms)` encrypted links (2D array) * @return MHD result code */ static int handle_refresh_melt_json (struct MHD_Connection *connection, const json_t *new_denoms, - const json_t *melt_coins, - unsigned int num_oldcoins, + const json_t *melt_coin, const json_t *transfer_pubs, const json_t *secret_encs, - unsigned int num_newcoins, const json_t *coin_evs, const json_t *link_encs) { @@ -391,27 +342,26 @@ handle_refresh_melt_json (struct MHD_Connection *connection, unsigned int i; unsigned int j; struct TALER_DenominationPublicKey *denom_pubs; - unsigned int num_new_denoms; - struct TMH_DB_MeltDetails *coin_melt_details; - unsigned int coin_count; + unsigned int num_newcoins; + struct TMH_DB_MeltDetails coin_melt_details; struct GNUNET_HashCode session_hash; struct GNUNET_HashContext *hash_context; struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coin[TALER_CNC_KAPPA]; - struct TALER_RefreshCommitLinkP *commit_link[TALER_CNC_KAPPA]; + struct TALER_RefreshCommitLinkP commit_link[TALER_CNC_KAPPA]; /* For the signature check, we hash most of the inputs together (except for the signatures on the coins). */ hash_context = GNUNET_CRYPTO_hash_context_start (); - num_new_denoms = json_array_size (new_denoms); - denom_pubs = GNUNET_malloc (num_new_denoms * - sizeof (struct TALER_DenominationPublicKey)); - for (i=0;i<num_new_denoms;i++) + num_newcoins = json_array_size (new_denoms); + denom_pubs = GNUNET_new_array (num_newcoins, + struct TALER_DenominationPublicKey); + for (i=0;i<num_newcoins;i++) { char *buf; size_t buf_size; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_denomination_public_key (NULL, - &denom_pubs[i]), + &denom_pubs[i]), GNUNET_JSON_spec_end () }; @@ -432,42 +382,23 @@ handle_refresh_melt_json (struct MHD_Connection *connection, GNUNET_free (buf); } - coin_count = json_array_size (melt_coins); - coin_melt_details = GNUNET_new_array (coin_count, - struct TMH_DB_MeltDetails); - for (i=0;i<coin_count;i++) { /* decode JSON data on coin to melt */ struct TALER_AmountNBO melt_amount; - // FIXME: check json_array_get() return value for NULL! res = get_coin_public_info (connection, - json_array_get (melt_coins, i), - &coin_melt_details[i]); + melt_coin, + &coin_melt_details); if (GNUNET_OK != res) { GNUNET_break_op (0); res = (GNUNET_NO == res) ? MHD_YES : MHD_NO; goto cleanup_melt_details; } - /* Check that the client does not try to melt the same coin twice - into the same session! */ - for (j=0;j<i;j++) - { - if (0 == memcmp (&coin_melt_details[i].coin_info.coin_pub, - &coin_melt_details[j].coin_info.coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP))) - { - GNUNET_break_op (0); - res = TMH_RESPONSE_reply_external_error (connection, - "melting same coin twice in same session is not allowed"); - goto cleanup_melt_details; - } - } TALER_amount_hton (&melt_amount, - &coin_melt_details[i].melt_amount_with_fee); + &coin_melt_details.melt_amount_with_fee); GNUNET_CRYPTO_hash_context_read (hash_context, - &coin_melt_details[i].coin_info.coin_pub, + &coin_melt_details.coin_info.coin_pub, sizeof (struct TALER_CoinSpendPublicKeyP)); GNUNET_CRYPTO_hash_context_read (hash_context, &melt_amount, @@ -480,8 +411,8 @@ handle_refresh_melt_json (struct MHD_Connection *connection, memset (commit_link, 0, sizeof (commit_link)); for (i = 0; i < TALER_CNC_KAPPA; i++) { - commit_coin[i] = GNUNET_malloc (num_newcoins * - sizeof (struct TALER_EXCHANGEDB_RefreshCommitCoin)); + commit_coin[i] = GNUNET_new_array (num_newcoins, + struct TALER_EXCHANGEDB_RefreshCommitCoin); for (j = 0; j < num_newcoins; j++) { char *link_enc; @@ -536,68 +467,59 @@ handle_refresh_melt_json (struct MHD_Connection *connection, for (i = 0; i < TALER_CNC_KAPPA; i++) { - commit_link[i] = GNUNET_malloc (num_oldcoins * - sizeof (struct TALER_RefreshCommitLinkP)); - for (j = 0; j < num_oldcoins; j++) - { - struct TALER_RefreshCommitLinkP *rcl = &commit_link[i][j]; - struct GNUNET_JSON_Specification trans_spec[] = { - GNUNET_JSON_spec_fixed_auto (NULL, &rcl->transfer_pub), - GNUNET_JSON_spec_end () - }; - struct GNUNET_JSON_Specification sec_spec[] = { - GNUNET_JSON_spec_fixed_auto (NULL, &rcl->shared_secret_enc), - GNUNET_JSON_spec_end () - }; + struct TALER_RefreshCommitLinkP *rcl = &commit_link[i]; + struct GNUNET_JSON_Specification trans_spec[] = { + GNUNET_JSON_spec_fixed_auto (NULL, &rcl->transfer_pub), + GNUNET_JSON_spec_end () + }; + struct GNUNET_JSON_Specification sec_spec[] = { + GNUNET_JSON_spec_fixed_auto (NULL, &rcl->shared_secret_enc), + GNUNET_JSON_spec_end () + }; - res = TMH_PARSE_json_array (connection, - transfer_pubs, - trans_spec, - i, j, -1); - if (GNUNET_OK != res) - { - GNUNET_break_op (0); - res = (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; - goto cleanup; - } - res = TMH_PARSE_json_array (connection, - secret_encs, - sec_spec, - i, j, -1); - if (GNUNET_OK != res) - { - GNUNET_break_op (0); - res = (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; - goto cleanup; - } - GNUNET_CRYPTO_hash_context_read (hash_context, - rcl, - sizeof (struct TALER_RefreshCommitLinkP)); + res = TMH_PARSE_json_array (connection, + transfer_pubs, + trans_spec, + i, -1); + if (GNUNET_OK != res) + { + GNUNET_break_op (0); + res = (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; + goto cleanup; } - } - GNUNET_CRYPTO_hash_context_finish (hash_context, - &session_hash); - hash_context = NULL; - for (i=0;i<coin_count;i++) - { - /* verify signatures on coins to melt */ - res = verify_coin_public_info (connection, - &session_hash, - &coin_melt_details[i]); + res = TMH_PARSE_json_array (connection, + secret_encs, + sec_spec, + i, -1); if (GNUNET_OK != res) { GNUNET_break_op (0); - res = (GNUNET_NO == res) ? MHD_YES : MHD_NO; + res = (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; goto cleanup; } + GNUNET_CRYPTO_hash_context_read (hash_context, + rcl, + sizeof (struct TALER_RefreshCommitLinkP)); + } + GNUNET_CRYPTO_hash_context_finish (hash_context, + &session_hash); + hash_context = NULL; + /* verify signature on coins to melt */ + res = verify_coin_public_info (connection, + &session_hash, + &coin_melt_details); + if (GNUNET_OK != res) + { + GNUNET_break_op (0); + res = (GNUNET_NO == res) ? MHD_YES : MHD_NO; + goto cleanup; } /* execute commit */ res = handle_refresh_melt_binary (connection, - num_new_denoms, + num_newcoins, denom_pubs, - coin_count, - coin_melt_details, + &coin_melt_details, &session_hash, commit_coin, commit_link); @@ -605,20 +527,13 @@ handle_refresh_melt_json (struct MHD_Connection *connection, free_commit_coins (commit_coin, TALER_CNC_KAPPA, num_newcoins); - free_commit_links (commit_link, - TALER_CNC_KAPPA, - num_oldcoins); cleanup_melt_details: - for (j=0;j<coin_count;j++) - { - if (NULL != coin_melt_details[j].coin_info.denom_pub.rsa_public_key) - GNUNET_CRYPTO_rsa_public_key_free (coin_melt_details[j].coin_info.denom_pub.rsa_public_key); - if (NULL != coin_melt_details[j].coin_info.denom_sig.rsa_signature) - GNUNET_CRYPTO_rsa_signature_free (coin_melt_details[j].coin_info.denom_sig.rsa_signature); - } - GNUNET_free (coin_melt_details); + if (NULL != coin_melt_details.coin_info.denom_pub.rsa_public_key) + GNUNET_CRYPTO_rsa_public_key_free (coin_melt_details.coin_info.denom_pub.rsa_public_key); + if (NULL != coin_melt_details.coin_info.denom_sig.rsa_signature) + GNUNET_CRYPTO_rsa_signature_free (coin_melt_details.coin_info.denom_sig.rsa_signature); cleanup_denoms: - for (j=0;j<num_new_denoms;j++) + for (j=0;j<num_newcoins;j++) if (NULL != denom_pubs[j].rsa_public_key) GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key); GNUNET_free (denom_pubs); @@ -650,19 +565,16 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh, { json_t *root; json_t *new_denoms; - json_t *melt_coins; + json_t *melt_coin; json_t *coin_evs; json_t *link_encs; json_t *transfer_pubs; json_t *secret_encs; - unsigned int num_oldcoins; - unsigned int num_newcoins; json_t *coin_detail; - json_t *trans_detail; int res; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_json ("new_denoms", &new_denoms), - GNUNET_JSON_spec_json ("melt_coins", &melt_coins), + GNUNET_JSON_spec_json ("melt_coin", &melt_coin), GNUNET_JSON_spec_json ("coin_evs", &coin_evs), GNUNET_JSON_spec_json ("link_encs", &link_encs), GNUNET_JSON_spec_json ("transfer_pubs", &transfer_pubs), @@ -710,24 +622,11 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } - num_newcoins = json_array_size (coin_detail); - - trans_detail = json_array_get (transfer_pubs, 0); - if (NULL == trans_detail) - { - // FIXME: generate proper HTTP response! - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; - } - num_oldcoins = json_array_size (trans_detail); res = handle_refresh_melt_json (connection, new_denoms, - melt_coins, - num_oldcoins, + melt_coin, transfer_pubs, secret_encs, - num_newcoins, coin_evs, link_encs); GNUNET_JSON_parse_free (spec); @@ -744,53 +643,41 @@ TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh, * * @param connection the MHD connection to handle * @param session_hash hash identifying the melting session - * @param num_oldcoins length of the 2nd dimension of @a transfer_privs array * @param tp_json private transfer keys in JSON format * @return MHD result code */ static int handle_refresh_reveal_json (struct MHD_Connection *connection, const struct GNUNET_HashCode *session_hash, - unsigned int num_oldcoins, const json_t *tp_json) { - struct TALER_TransferPrivateKeyP *transfer_privs[TALER_CNC_KAPPA - 1]; + struct TALER_TransferPrivateKeyP transfer_privs[TALER_CNC_KAPPA - 1]; unsigned int i; - unsigned int j; int res; - for (i = 0; i < TALER_CNC_KAPPA - 1; i++) - transfer_privs[i] = GNUNET_malloc (num_oldcoins * - sizeof (struct TALER_TransferPrivateKeyP)); res = GNUNET_OK; for (i = 0; i < TALER_CNC_KAPPA - 1; i++) { if (GNUNET_OK != res) break; - for (j = 0; j < num_oldcoins; j++) - { - struct GNUNET_JSON_Specification tp_spec[] = { - GNUNET_JSON_spec_fixed_auto (NULL, &transfer_privs[i][j]), - GNUNET_JSON_spec_end () - }; - if (GNUNET_OK != res) - break; - res = TMH_PARSE_json_array (connection, - tp_json, - tp_spec, - i, j, -1); - GNUNET_break_op (GNUNET_OK == res); - } + struct GNUNET_JSON_Specification tp_spec[] = { + GNUNET_JSON_spec_fixed_auto (NULL, &transfer_privs[i]), + GNUNET_JSON_spec_end () + }; + if (GNUNET_OK != res) + break; + res = TMH_PARSE_json_array (connection, + tp_json, + tp_spec, + i, -1); + GNUNET_break_op (GNUNET_OK == res); } if (GNUNET_OK != res) res = (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; else res = TMH_DB_execute_refresh_reveal (connection, session_hash, - num_oldcoins, transfer_privs); - for (i = 0; i < TALER_CNC_KAPPA - 1; i++) - GNUNET_free (transfer_privs[i]); return res; } @@ -820,7 +707,6 @@ TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh, { struct GNUNET_HashCode session_hash; int res; - unsigned int num_oldcoins; json_t *reveal_detail; json_t *root; json_t *transfer_privs; @@ -866,10 +752,8 @@ TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh, GNUNET_break_op (0); return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; } - num_oldcoins = json_array_size (reveal_detail); res = handle_refresh_reveal_json (connection, &session_hash, - num_oldcoins, transfer_privs); GNUNET_JSON_parse_free (spec); return res; diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 6a21d8ac4..26f0d76a4 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015, 2016 GNUnet e.V. + Copyright (C) 2014, 2015, 2016 Inria & GNUnet e.V. 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 @@ -978,6 +978,7 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection, * revealed value(s) do not match the original commitment. * * @param connection the connection to send the response to + * @param rm details about the original melt * @param mc all information about the original commitment * @param off offset in the array of kappa-commitments where * the missmatch was detected @@ -989,43 +990,35 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection, */ int TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, + const struct TALER_EXCHANGEDB_RefreshMelt *rm, const struct TALER_EXCHANGEDB_MeltCommitment *mc, unsigned int off, unsigned int j, const char *missmatch_object) { - json_t *info_old; json_t *info_new; json_t *info_commit; json_t *info_links; unsigned int i; unsigned int k; + json_t *rm_json; + + rm_json = json_object (); + json_object_set_new (rm_json, + "coin_sig", + GNUNET_JSON_from_data (&rm->coin_sig, + sizeof (struct TALER_CoinSpendSignatureP))); + json_object_set_new (rm_json, + "coin_pub", + GNUNET_JSON_from_data (&rm->coin.coin_pub, + sizeof (struct TALER_CoinSpendPublicKeyP))); + json_object_set_new (rm_json, + "melt_amount_with_fee", + TALER_JSON_from_amount (&rm->amount_with_fee)); + json_object_set_new (rm_json, + "melt_fee", + TALER_JSON_from_amount (&rm->melt_fee)); - info_old = json_array (); - for (i=0;i<mc->num_oldcoins;i++) - { - const struct TALER_EXCHANGEDB_RefreshMelt *rm; - json_t *rm_json; - - rm = &mc->melts[i]; - rm_json = json_object (); - json_object_set_new (rm_json, - "coin_sig", - GNUNET_JSON_from_data (&rm->coin_sig, - sizeof (struct TALER_CoinSpendSignatureP))); - json_object_set_new (rm_json, - "coin_pub", - GNUNET_JSON_from_data (&rm->coin.coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP))); - json_object_set_new (rm_json, - "melt_amount_with_fee", - TALER_JSON_from_amount (&rm->amount_with_fee)); - json_object_set_new (rm_json, - "melt_fee", - TALER_JSON_from_amount (&rm->melt_fee)); - json_array_append_new (info_old, - rm_json); - } info_new = json_array (); for (i=0;i<mc->num_newcoins;i++) { @@ -1042,6 +1035,7 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, { json_t *info_commit_k; json_t *info_link_k; + const struct TALER_RefreshCommitLinkP *cl; info_commit_k = json_array (); for (i=0;i<mc->num_newcoins;i++) @@ -1069,25 +1063,17 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, } json_array_append_new (info_commit, info_commit_k); - info_link_k = json_array (); - for (i=0;i<mc->num_oldcoins;i++) - { - const struct TALER_RefreshCommitLinkP *cl; - json_t *cl_json; - - cl = &mc->commit_links[k][i]; - cl_json = json_object (); - json_object_set_new (cl_json, - "transfer_pub", - GNUNET_JSON_from_data (&cl->transfer_pub, - sizeof (struct TALER_TransferPublicKeyP))); - json_object_set_new (cl_json, - "shared_secret_enc", - GNUNET_JSON_from_data (&cl->shared_secret_enc, - sizeof (struct TALER_EncryptedLinkSecretP))); - json_array_append_new (info_link_k, - cl_json); - } + + info_link_k = json_object (); + cl = &mc->commit_links[k]; + json_object_set_new (info_link_k, + "transfer_pub", + GNUNET_JSON_from_data (&cl->transfer_pub, + sizeof (struct TALER_TransferPublicKeyP))); + json_object_set_new (info_link_k, + "shared_secret_enc", + GNUNET_JSON_from_data (&cl->shared_secret_enc, + sizeof (struct TALER_EncryptedLinkSecretP))); json_array_append_new (info_links, info_link_k); } @@ -1097,7 +1083,7 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, "error", "commitment violation", "offset", (int) off, "index", (int) j, - "oldcoin_infos", info_old, + "refresh_melt_info", rm_json, "newcoin_infos", info_new, "commit_infos", info_commit, "link_infos", info_links, diff --git a/src/exchange/taler-exchange-httpd_responses.h b/src/exchange/taler-exchange-httpd_responses.h index 85c2e1f32..57857560c 100644 --- a/src/exchange/taler-exchange-httpd_responses.h +++ b/src/exchange/taler-exchange-httpd_responses.h @@ -492,6 +492,7 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection, * revealed value(s) do not match the original commitment. * * @param connection the connection to send the response to + * @param rm details about the original melt * @param mc all information about the original commitment * @param off offset in the array of kappa-commitments where * the missmatch was detected @@ -503,6 +504,7 @@ TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection, */ int TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection, + const struct TALER_EXCHANGEDB_RefreshMelt *rm, const struct TALER_EXCHANGEDB_MeltCommitment *mc, unsigned int off, unsigned int j, |