diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-11-27 23:42:17 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-11-29 20:23:08 +0100 |
commit | 499247a4805583dc67b9d6fef850ae86b4be1e32 (patch) | |
tree | abf9bf358bc00149a78d8128101bfc43540af8f2 /src/include/taler_exchangedb_plugin.h | |
parent | 9041840d6e1caa5a0a4f8222b312b547ccd2ab1b (diff) | |
download | exchange-499247a4805583dc67b9d6fef850ae86b4be1e32.tar.xz |
fixing #5178
Diffstat (limited to 'src/include/taler_exchangedb_plugin.h')
-rw-r--r-- | src/include/taler_exchangedb_plugin.h | 372 |
1 files changed, 118 insertions, 254 deletions
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 006ea3981..e64b0ad4c 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2017 GNUnet e.V. + Copyright (C) 2014-2017 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 @@ -465,7 +465,7 @@ struct TALER_EXCHANGEDB_Refund /** * @brief Specification for coin in a /refresh/melt operation. */ -struct TALER_EXCHANGEDB_RefreshMelt +struct TALER_EXCHANGEDB_RefreshSession { /** * Information about the coin that is being melted. @@ -478,9 +478,9 @@ struct TALER_EXCHANGEDB_RefreshMelt struct TALER_CoinSpendSignatureP coin_sig; /** - * Hash of the refresh session this coin is melted into. + * Refresh commitment this coin is melted into. */ - struct GNUNET_HashCode session_hash; + struct TALER_RefreshCommitmentP rc; /** * How much value is being melted? This amount includes the fees, @@ -493,64 +493,29 @@ struct TALER_EXCHANGEDB_RefreshMelt struct TALER_Amount amount_with_fee; /** - * Melting fee charged by the exchange. This must match the Exchange's - * denomination key's melting fee. If the client puts in an invalid - * melting fee (too high or too low) that does not match the Exchange's - * denomination key, the melting operation is invalid and will be - * rejected by the exchange. The @e amount_with_fee minus the @e - * melt_fee is the amount that will be credited to the melting - * session. - */ - struct TALER_Amount melt_fee; - -}; - - -/** - * @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; + uint32_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 - * sets). These are the coins we ask the exchange to sign if the - * respective set is selected. + * Information about a /refresh/melt operation in the transaction history. */ -struct TALER_EXCHANGEDB_RefreshCommitCoin +struct TALER_EXCHANGEDB_RefreshMelt { /** - * Blinded message to be signed (in envelope), with @e coin_env_size bytes. + * Overall session data. */ - char *coin_ev; + struct TALER_EXCHANGEDB_RefreshSession session; /** - * Number of bytes in @e coin_ev. + * Melt fee the exchange charged. */ - size_t coin_ev_size; + struct TALER_Amount melt_fee; }; @@ -752,9 +717,8 @@ typedef int * @param coin_pub public key of the coin * @param coin_sig signature from the coin * @param amount_with_fee amount that was deposited including fee - * @param num_newcoins how many coins were issued * @param noreveal_index which index was picked by the exchange in cut-and-choose - * @param session_hash what is the session hash + * @param rc what is the commitment * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ typedef int @@ -764,9 +728,56 @@ typedef int const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendSignatureP *coin_sig, const struct TALER_Amount *amount_with_fee, - uint16_t num_newcoins, - uint16_t noreveal_index, - const struct GNUNET_HashCode *session_hash); + uint32_t noreveal_index, + const struct TALER_RefreshCommitmentP *rc); + + +/** + * Information about a coin that was revealed to the exchange + * during /refresh/reveal. + */ +struct TALER_EXCHANGEDB_RefreshRevealedCoin +{ + /** + * Public denomination key of the coin. + */ + struct TALER_DenominationPublicKey denom_pub; + + /** + * Blinded message to be signed (in envelope), with @e coin_env_size bytes. + */ + char *coin_ev; + + /** + * Number of bytes in @e coin_ev. + */ + size_t coin_ev_size; + + /** + * Signature generated by the exchange over the coin (in blinded format). + */ + struct TALER_DenominationSignature coin_sig; +}; + + +/** + * Function called with information about a refresh order. + * + * @param cls closure + * @param rowid unique serial ID for the row in our database + * @param num_newcoins size of the @a rrcs array + * @param rrcs array of @a num_newcoins information about coins to be created + * @param num_tprivs number of entries in @a tprivs, should be #TALER_CNC_KAPPA - 1 + * @param tprivs array of @e num_tprivs transfer private keys + * @param tp transfer public key information + */ +typedef void +(*TALER_EXCHANGEDB_RefreshCallback)(void *cls, + uint32_t num_newcoins, + const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, + unsigned int num_tprivs, + const struct TALER_TransferPrivateKeyP *tprivs, + const struct TALER_TransferPublicKeyP *tp); /** @@ -851,14 +862,13 @@ typedef int * information for a given coin. * * @param cls closure - * @param session_hash a session the coin was melted in * @param transfer_pub public transfer key for the session - * @param shared_secret_enc set to shared secret for the session + * @param ldl link data for @a transfer_pub */ typedef void -(*TALER_EXCHANGEDB_TransferDataCallback)(void *cls, - const struct GNUNET_HashCode *session_hash, - const struct TALER_TransferPublicKeyP *transfer_pub); +(*TALER_EXCHANGEDB_LinkDataCallback)(void *cls, + const struct TALER_TransferPublicKeyP *transfer_pub, + const struct TALER_EXCHANGEDB_LinkDataList *ldl); /** @@ -1235,7 +1245,7 @@ struct TALER_EXCHANGEDB_Plugin * @param[out] wire_reference_size set to number of bytes in @a wire_reference * @return transaction status code */ - enum GNUNET_DB_QueryStatus + enum GNUNET_DB_QueryStatus (*get_latest_reserve_in_reference)(void *cls, struct TALER_EXCHANGEDB_Session *db, void **wire_reference, @@ -1254,7 +1264,7 @@ struct TALER_EXCHANGEDB_Plugin * if a coin is found * @return statement execution status */ - enum GNUNET_DB_QueryStatus + enum GNUNET_DB_QueryStatus (*get_withdraw_info) (void *cls, struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *h_blind, @@ -1454,225 +1464,79 @@ struct TALER_EXCHANGEDB_Plugin /** - * Lookup refresh session data under the given @a session_hash. + * Store new refresh melt commitment data. * * @param cls the @e cls of this struct with the plugin-specific state * @param session database handle to use - * @param session_hash hash over the melt to use for the lookup - * @param[out] refresh_session where to store the result - * @return transaction status - */ - enum GNUNET_DB_QueryStatus - (*get_refresh_session) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - struct TALER_EXCHANGEDB_RefreshSession *refresh_session); - - - /** - * Store new refresh session data under the given @a session_hash. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param session database handle to use - * @param session_hash hash over the melt to use to locate the session - * @param refresh_session session data to store - * @return query status for the transaction - */ - enum GNUNET_DB_QueryStatus - (*create_refresh_session) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - const struct TALER_EXCHANGEDB_RefreshSession *refresh_session); - - - /** - * Store in the database which coin(s) we want to create - * in a given refresh operation. - * - * @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 num_newcoins number of coins to generate, size of the @a denom_pubs array - * @param denom_pubs array denominations of the coins to create - * @return query status for the transaction - */ - enum GNUNET_DB_QueryStatus - (*insert_refresh_order) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - uint16_t num_newcoins, - const struct TALER_DenominationPublicKey *denom_pubs); - - - /** - * Lookup in the database for the @a num_newcoins coins that we want to - * create in the given refresh operation. - * - * @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 num_newcoins size of the @a denom_pubs array - * @param[out] denom_pubs where to write @a num_newcoins denomination keys - * @return transaction status - */ - enum GNUNET_DB_QueryStatus - (*get_refresh_order) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - uint16_t num_newcoins, - struct TALER_DenominationPublicKey *denom_pubs); - - - /** - * Store information about the commitments of the given index @a i - * for the given refresh session in the database. - * - * @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 num_newcoins coin index size of the @a commit_coins array - * @param commit_coin array of coin commitments to store + * @param refresh_session operational data to store * @return query status for the transaction */ enum GNUNET_DB_QueryStatus - (*insert_refresh_commit_coins) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - uint16_t num_newcoins, - const struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins); + (*insert_melt) (void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_RefreshSession *refresh_session); /** - * Obtain information about the commitment of the - * given coin of the given refresh session from the database. + * Lookup refresh metl commitment data under the given @a rc. * * @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 num_coins size of the @a commit_coins array - * @param[out] commit_coins array of coin commitments to return + * @param session database handle to use + * @param rc commitment to use for the lookup + * @param[out] refresh_melt where to store the result * @return transaction status */ enum GNUNET_DB_QueryStatus - (*get_refresh_commit_coins) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - uint16_t num_coins, - struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins); - - /** - * Free refresh @a commit_coins data obtained via @e get_refresh_commit_coins. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param num_coins size of the @a commit_coins array - * @param commit_coins array of coin commitments to free - */ - void - (*free_refresh_commit_coins) (void *cls, - unsigned int num_coins, - struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins); + (*get_melt) (void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_RefreshCommitmentP *rc, + struct TALER_EXCHANGEDB_RefreshMelt *refresh_melt); /** - * Store the commitment to the given (encrypted) refresh link data - * for the given refresh session. + * Store in the database which coin(s) the wallet wanted to create + * in a given refresh operation and all of the other information + * we learned or created in the /refresh/reveal step. * * @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 session database connection + * @param rc identify commitment and thus refresh operation + * @param num_rrcs_newcoins number of coins to generate, size of the + * @a rrcs array + * @param rrcs information about the new coins + * @param num_tprivs number of entries in @a tprivs, should be #TALER_CNC_KAPPA - 1 + * @param tprivs transfer private keys to store * @param tp public key to store * @return query status for the transaction */ enum GNUNET_DB_QueryStatus - (*insert_refresh_transfer_public_key) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - const struct TALER_TransferPublicKeyP *tp); - - /** - * Obtain the commited (encrypted) refresh link data - * for the given refresh session. - * - * @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[out] tp information to return - * @return transaction status - */ - enum GNUNET_DB_QueryStatus - (*get_refresh_transfer_public_key) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - struct TALER_TransferPublicKeyP *tp); - - - /** - * Get signature of a new coin generated during refresh into - * the database indexed by the refresh session and the index - * of the coin. - * - * @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 newcoin_index coin index - * @param[out] ev_sig coin signature - * @return transaction result status - */ - enum GNUNET_DB_QueryStatus - (*get_refresh_out) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - uint16_t newcoin_index, - struct TALER_DenominationSignature *ev_sig); - - - /** - * Insert signature of a new coin generated during refresh into - * the database indexed by the refresh session and the index - * of the coin. This data is later used should an old coin - * be used to try to obtain the private keys during "/refresh/link". - * - * @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 newcoin_index coin index - * @param ev_sig coin signature - * @return transaction result status - */ - enum GNUNET_DB_QueryStatus - (*insert_refresh_out) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - uint16_t newcoin_index, - const struct TALER_DenominationSignature *ev_sig); + (*insert_refresh_reveal) (void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_RefreshCommitmentP *rc, + uint32_t num_rrcs, + const struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrcs, + unsigned int num_tprivs, + const struct TALER_TransferPrivateKeyP *tprivs, + const struct TALER_TransferPublicKeyP *tp); /** - * Obtain the link data of a coin, that is the encrypted link - * information, the denomination keys and the signatures. + * Lookup in the database for the @a num_newcoins coins that we + * created in the given refresh operation. * * @param cls the @e cls of this struct with the plugin-specific state * @param session database connection - * @param session_hash session to get linkage data for - * @param[out] ldldp set to all known link data for the session - * @return status of the transaction + * @param rc identify commitment and thus refresh operation + * @param cb function to call with the results + * @param cb_cls closure for @a cb + * @return transaction status */ enum GNUNET_DB_QueryStatus - (*get_link_data_list) (void *cls, + (*get_refresh_reveal) (void *cls, struct TALER_EXCHANGEDB_Session *session, - const struct GNUNET_HashCode *session_hash, - struct TALER_EXCHANGEDB_LinkDataList **ldlp); - - - /** - * Free memory of the link data list. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param ldl link data list to release - */ - void - (*free_link_data_list) (void *cls, - struct TALER_EXCHANGEDB_LinkDataList *ldl); + const struct TALER_RefreshCommitmentP *rc, + TALER_EXCHANGEDB_RefreshCallback cb, + void *cb_cls); /** @@ -1684,16 +1548,16 @@ struct TALER_EXCHANGEDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session database connection * @param coin_pub public key of the coin - * @param tdc function to call for each session the coin was melted into - * @param tdc_cls closure for @a tdc + * @param ldc function to call for each session the coin was melted into + * @param ldc_cls closure for @a tdc * @return statement execution status */ enum GNUNET_DB_QueryStatus - (*get_transfer) (void *cls, - struct TALER_EXCHANGEDB_Session *session, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - TALER_EXCHANGEDB_TransferDataCallback tdc, - void *tdc_cls); + (*get_link_data) (void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + TALER_EXCHANGEDB_LinkDataCallback ldc, + void *tdc_cls); /** @@ -1806,7 +1670,7 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_Amount *wire_fee, const struct TALER_MasterSignatureP *master_sig); - + /** * Obtain wire fee from database. * @@ -2233,7 +2097,7 @@ struct TALER_EXCHANGEDB_Plugin struct GNUNET_TIME_Absolute end_date, TALER_EXCHANGEDB_WireMissingCallback cb, void *cb_cls); - + }; |