From c8b9370413d6a330f3b457359ed309ac9e964533 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 16 May 2016 11:55:47 +0200 Subject: fixing #3814 by removing ability to melt multiple oldcoins at the same time --- src/include/taler_exchange_service.h | 44 ++++++----- src/include/taler_exchangedb_plugin.h | 135 +++++++++++----------------------- 2 files changed, 63 insertions(+), 116 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 09cbd7868..fd09b5286 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -711,12 +711,12 @@ typedef void */ struct TALER_EXCHANGE_ReserveWithdrawHandle * TALER_EXCHANGE_reserve_withdraw (struct TALER_EXCHANGE_Handle *exchange, - const struct TALER_EXCHANGE_DenomPublicKey *pk, - const struct TALER_ReservePrivateKeyP *reserve_priv, - const struct TALER_CoinSpendPrivateKeyP *coin_priv, - const struct TALER_DenominationBlindingKey *blinding_key, - TALER_EXCHANGE_ReserveWithdrawResultCallback res_cb, - void *res_cb_cls); + const struct TALER_EXCHANGE_DenomPublicKey *pk, + const struct TALER_ReservePrivateKeyP *reserve_priv, + const struct TALER_CoinSpendPrivateKeyP *coin_priv, + const struct TALER_DenominationBlindingKey *blinding_key, + TALER_EXCHANGE_ReserveWithdrawResultCallback res_cb, + void *res_cb_cls); /** @@ -745,8 +745,8 @@ TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHan * to #TALER_EXCHANGE_refresh_melt() that will generate the request. * * This function does verify that the given request data is internally - * consistent. However, the @a melts_sigs are only verified if @a - * check_sigs is set to #GNUNET_YES, as this may be relatively + * consistent. However, the @a melts_sig is only verified if @a + * check_sig is set to #GNUNET_YES, as this may be relatively * expensive and should be redundant. * * Aside from some non-trivial cryptographic operations that might @@ -754,17 +754,16 @@ TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHan * its result immediately and does not start any asynchronous * processing. This function is also thread-safe. * - * @param num_melts number of coins that are being melted (typically 1) - * @param melt_privs array of @a num_melts private keys of the coins to melt - * @param melt_amounts array of @a num_melts amounts specifying how much - * each coin will contribute to the melt (including fee) - * @param melt_sigs array of @a num_melts signatures affirming the + * @param melt_priv private keys of the coin to melt + * @param melt_amount amount specifying how much + * the coin will contribute to the melt (including fee) + * @param melt_sig signatures affirming the * validity of the public keys corresponding to the - * @a melt_privs private keys - * @param melt_pks array of @a num_melts denomination key information - * records corresponding to the @a melt_sigs + * @a melt_priv private key + * @param melt_pk denomination key information + * record corresponding to the @a melt_sig * validity of the keys - * @param check_sigs verify the validity of the signatures of @a melt_sigs + * @param check_sig verify the validity of the signatures of @a melt_sig * @param fresh_pks_len length of the @a pks array * @param fresh_pks array of @a pks_len denominations of fresh coins to create * @param[out] res_size set to the size of the return value, or 0 on error @@ -775,12 +774,11 @@ TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHan * Non-null results should be freed using #GNUNET_free(). */ char * -TALER_EXCHANGE_refresh_prepare (unsigned int num_melts, - const struct TALER_CoinSpendPrivateKeyP *melt_privs, - const struct TALER_Amount *melt_amounts, - const struct TALER_DenominationSignature *melt_sigs, - const struct TALER_EXCHANGE_DenomPublicKey *melt_pks, - int check_sigs, +TALER_EXCHANGE_refresh_prepare (const struct TALER_CoinSpendPrivateKeyP *melt_priv, + const struct TALER_Amount *melt_amount, + const struct TALER_DenominationSignature *melt_sig, + const struct TALER_EXCHANGE_DenomPublicKey *melt_pk, + int check_sig, unsigned int fresh_pks_len, const struct TALER_EXCHANGE_DenomPublicKey *fresh_pks, size_t *res_size); diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index fff6e251d..2cc3b439c 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -358,33 +358,6 @@ struct TALER_EXCHANGEDB_Refund }; -/** - * @brief Global information for a refreshing session. Includes - * dimensions of the operation, security parameters and - * client signatures from "/refresh/melt" and "/refresh/commit". - */ -struct TALER_EXCHANGEDB_RefreshSession -{ - - /** - * Number of coins we are melting. - */ - uint16_t num_oldcoins; - - /** - * Number of new coins we are creating. - */ - uint16_t num_newcoins; - - /** - * Index (smaller #TALER_CNC_KAPPA) which the exchange has chosen to not - * have revealed during cut and choose. - */ - uint16_t noreveal_index; - -}; - - /** * @brief Specification for coin in a /refresh/melt operation. */ @@ -429,6 +402,33 @@ struct TALER_EXCHANGEDB_RefreshMelt }; +/** + * @brief Global information for a refreshing session. Includes + * dimensions of the operation, security parameters and + * client signatures from "/refresh/melt" and "/refresh/commit". + */ +struct TALER_EXCHANGEDB_RefreshSession +{ + + /** + * Melt operation details. + */ + struct TALER_EXCHANGEDB_RefreshMelt melt; + + /** + * Number of new coins we are creating. + */ + uint16_t num_newcoins; + + /** + * Index (smaller #TALER_CNC_KAPPA) which the exchange has chosen to not + * have revealed during cut and choose. + */ + uint16_t noreveal_index; + +}; + + /** * @brief We have as many `struct TALER_EXCHANGEDB_RefreshCommitCoin` as there are new * coins being created by the refresh (for each of the #TALER_CNC_KAPPA @@ -557,21 +557,11 @@ struct TALER_EXCHANGEDB_TransactionList struct TALER_EXCHANGEDB_MeltCommitment { - /** - * Number of coins we are melting. - */ - uint16_t num_oldcoins; - /** * Number of new coins we are creating. */ uint16_t num_newcoins; - /** - * Array of @e num_oldcoins melt operation details. - */ - struct TALER_EXCHANGEDB_RefreshMelt *melts; - /** * Array of @e num_newcoins denomination keys */ @@ -583,9 +573,9 @@ struct TALER_EXCHANGEDB_MeltCommitment struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins[TALER_CNC_KAPPA]; /** - * 2D-Array of #TALER_CNC_KAPPA and @e new_oldcoins links. + * Array of #TALER_CNC_KAPPA links. */ - struct TALER_RefreshCommitLinkP *commit_links[TALER_CNC_KAPPA]; + struct TALER_RefreshCommitLinkP commit_links[TALER_CNC_KAPPA]; }; @@ -1116,43 +1106,6 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_EXCHANGEDB_RefreshSession *refresh_session); - /** - * Store the given /refresh/melt request in the database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param session database connection - * @param oldcoin_index index of the coin to store - * @param melt coin melt operation details to store; includes - * the session hash of the melt - * @return #GNUNET_OK on success - * #GNUNET_SYSERR on internal error - */ - int - (*insert_refresh_melt) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - uint16_t oldcoin_index, - const struct TALER_EXCHANGEDB_RefreshMelt *melt); - - - /** - * Get information about melted coin details from the database. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param session database connection - * @param session_hash hash to identify refresh session - * @param oldcoin_index index of the coin to retrieve - * @param melt melt data to fill in, can be NULL - * @return #GNUNET_OK on success - * #GNUNET_SYSERR on internal error - */ - int - (*get_refresh_melt) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - uint16_t oldcoin_index, - struct TALER_EXCHANGEDB_RefreshMelt *melt); - - /** * Store in the database which coin(s) we want to create * in a given refresh operation. @@ -1245,18 +1198,16 @@ struct TALER_EXCHANGEDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session database connection to use * @param session_hash hash to identify refresh session - * @param cnc_index cut and choose index (1st dimension), relating to #TALER_CNC_KAPPA - * @param num_links size of the @a commit_link array - * @param commit_links array of link information to store + * @param cnc_index cut and choose index, relating to #TALER_CNC_KAPPA + * @param link link information to store * @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success */ int - (*insert_refresh_commit_links) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - uint16_t cnc_index, - uint16_t num_links, - const struct TALER_RefreshCommitLinkP *commit_links); + (*insert_refresh_commit_link) (void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct GNUNET_HashCode *session_hash, + uint16_t cnc_index, + const struct TALER_RefreshCommitLinkP *link); /** * Obtain the commited (encrypted) refresh link data @@ -1266,19 +1217,17 @@ struct TALER_EXCHANGEDB_Plugin * @param session database connection to use * @param session_hash hash to identify refresh session * @param cnc_index cut and choose index (1st dimension) - * @param num_links size of the @a links array to return - * @param[out] links array link information to return + * @param[out] link information to return * @return #GNUNET_SYSERR on internal error, * #GNUNET_NO if commitment was not found * #GNUNET_OK on success */ int - (*get_refresh_commit_links) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - uint16_t cnc_index, - uint16_t num_links, - struct TALER_RefreshCommitLinkP *links); + (*get_refresh_commit_link) (void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct GNUNET_HashCode *session_hash, + uint16_t cnc_index, + struct TALER_RefreshCommitLinkP *link); /** -- cgit v1.2.3