diff options
Diffstat (limited to 'src/lib/exchange_api_refresh_common.h')
-rw-r--r-- | src/lib/exchange_api_refresh_common.h | 165 |
1 files changed, 69 insertions, 96 deletions
diff --git a/src/lib/exchange_api_refresh_common.h b/src/lib/exchange_api_refresh_common.h index 9f2715a1f..f596e1e90 100644 --- a/src/lib/exchange_api_refresh_common.h +++ b/src/lib/exchange_api_refresh_common.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2020 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 @@ -27,15 +27,10 @@ #include "taler_signatures.h" -/* structures for committing refresh data to disk before doing the - network interaction(s) */ - -GNUNET_NETWORK_STRUCT_BEGIN - /** - * Header of serialized information about a coin we are melting. + * Information about a coin we are melting. */ -struct MeltedCoinP +struct MeltedCoin { /** * Private key of the coin. @@ -45,103 +40,106 @@ struct MeltedCoinP /** * Amount this coin contributes to the melt, including fee. */ - struct TALER_AmountNBO melt_amount_with_fee; + struct TALER_Amount melt_amount_with_fee; /** - * The applicable fee for withdrawing a coin of this denomination + * The applicable fee for melting a coin of this denomination */ - struct TALER_AmountNBO fee_melt; + struct TALER_Amount fee_melt; /** * The original value of the coin. */ - struct TALER_AmountNBO original_value; + struct TALER_Amount original_value; /** - * Transfer private keys for each cut-and-choose dimension. + * The original age commitment, its proof and its hash. MUST be NULL if no + * age commitment was set. */ - struct TALER_TransferPrivateKeyP transfer_priv[TALER_CNC_KAPPA]; + const struct TALER_AgeCommitmentProof *age_commitment_proof; + const struct TALER_AgeCommitmentHash *h_age_commitment; /** * Timestamp indicating when coins of this denomination become invalid. */ - struct GNUNET_TIME_AbsoluteNBO expire_deposit; + struct GNUNET_TIME_Timestamp expire_deposit; /** - * Size of the encoded public key that follows. + * Denomination key of the original coin. */ - uint16_t pbuf_size; + struct TALER_DenominationPublicKey pub_key; /** - * Size of the encoded signature that follows. + * Exchange's signature over the coin. */ - uint16_t sbuf_size; + struct TALER_DenominationSignature sig; - /* Followed by serializations of: - 1) struct TALER_DenominationPublicKey pub_key; - 2) struct TALER_DenominationSignature sig; - */ }; /** - * Header of serialized data about a melt operation, suitable for - * persisting it on disk. + * Data we keep for each fresh coin created in the + * melt process. */ -struct MeltDataP +struct FreshCoinData { - /** - * Hash over the melting session. + * Denomination public key of the coin. */ - struct TALER_RefreshCommitmentP rc; + struct TALER_DenominationPublicKey fresh_pk; /** - * Number of coins we are melting, in NBO + * Array of planchet secrets for the coins, depending + * on the cut-and-choose. */ - uint16_t num_melted_coins GNUNET_PACKED; + struct TALER_PlanchetMasterSecretP ps[TALER_CNC_KAPPA]; /** - * Number of coins we are creating, in NBO + * Private key of the coin. */ - uint16_t num_fresh_coins GNUNET_PACKED; + struct TALER_CoinSpendPrivateKeyP coin_priv; - /* Followed by serializations of: - 1) struct MeltedCoinP melted_coins[num_melted_coins]; - 2) struct TALER_EXCHANGE_DenomPublicKey fresh_pks[num_fresh_coins]; - 3) TALER_CNC_KAPPA times: - 3a) struct TALER_PlanchetSecretsP fresh_coins[num_fresh_coins]; - */ -}; + /** + * Arrays of age commitments and proofs to be created, one for each + * cut-and-choose dimension. NULL if age restriction is not applicable. + */ + struct TALER_AgeCommitmentProof *age_commitment_proofs[TALER_CNC_KAPPA]; + /** + * Blinding key secrets for the coins, depending on the + * cut-and-choose. + */ + union GNUNET_CRYPTO_BlindingSecretP bks[TALER_CNC_KAPPA]; -GNUNET_NETWORK_STRUCT_END +}; /** - * Information about a coin we are melting. + * Melt data in non-serialized format for convenient processing. */ -struct MeltedCoin +struct MeltData { + /** - * Private key of the coin. + * Hash over the committed data during refresh operation. */ - struct TALER_CoinSpendPrivateKeyP coin_priv; + struct TALER_RefreshCommitmentP rc; /** - * Amount this coin contributes to the melt, including fee. + * Information about the melted coin. */ - struct TALER_Amount melt_amount_with_fee; + struct MeltedCoin melted_coin; /** - * The applicable fee for melting a coin of this denomination + * Array of length @e num_fresh_coins with information + * about each fresh coin. */ - struct TALER_Amount fee_melt; + struct FreshCoinData *fcds; /** - * The original value of the coin. + * Transfer secrets, one per cut and choose. */ - struct TALER_Amount original_value; + struct TALER_TransferSecretP trans_sec[TALER_CNC_KAPPA]; /** * Transfer private keys for each cut-and-choose dimension. @@ -149,77 +147,52 @@ struct MeltedCoin struct TALER_TransferPrivateKeyP transfer_priv[TALER_CNC_KAPPA]; /** - * Timestamp indicating when coins of this denomination become invalid. + * Transfer public key of this commitment. */ - struct GNUNET_TIME_Absolute expire_deposit; + struct TALER_TransferPublicKeyP transfer_pub[TALER_CNC_KAPPA]; /** - * Denomination key of the original coin. + * Transfer secrets, one per cut and choose. */ - struct TALER_DenominationPublicKey pub_key; + struct TALER_RefreshCommitmentEntry rce[TALER_CNC_KAPPA]; /** - * Exchange's signature over the coin. + * Blinded planchets and denominations of the fresh coins, depending on the cut-and-choose. Array of length + * @e num_fresh_coins. */ - struct TALER_DenominationSignature sig; - -}; - - -/** - * Melt data in non-serialized format for convenient processing. - */ -struct MeltData -{ - - /** - * Hash over the committed data during refresh operation. - */ - struct TALER_RefreshCommitmentP rc; + struct TALER_RefreshCoinData *rcd[TALER_CNC_KAPPA]; /** * Number of coins we are creating */ uint16_t num_fresh_coins; - /** - * Information about the melted coin. - */ - struct MeltedCoin melted_coin; - - /** - * Array of @e num_fresh_coins denomination keys for the coins to be - * freshly exchangeed. - */ - struct TALER_DenominationPublicKey *fresh_pks; - - /** - * Arrays of @e num_fresh_coins with information about the fresh - * coins to be created, for each cut-and-choose dimension. - */ - struct TALER_PlanchetSecretsP *fresh_coins[TALER_CNC_KAPPA]; }; /** - * Deserialize melt data. + * Compute the melt data from the refresh data and secret. * - * @param buf serialized data - * @param buf_size size of @a buf - * @return deserialized melt data, NULL on error + * @param rms secret internals of the refresh-reveal operation + * @param rd refresh data with the characteristics of the operation + * @param alg_values contributions from the exchange into the melt + * @param[out] md where to write the derived melt data */ -struct MeltData * -TALER_EXCHANGE_deserialize_melt_data_ (const char *buf, - size_t buf_size); +enum GNUNET_GenericReturnValue +TALER_EXCHANGE_get_melt_data_ ( + const struct TALER_RefreshMasterSecretP *rms, + const struct TALER_EXCHANGE_RefreshData *rd, + const struct TALER_ExchangeWithdrawValues *alg_values, + struct MeltData *md); /** * Free all information associated with a melting session. Note * that we allow the melting session to be only partially initialized, * as we use this function also when freeing melt data that was not - * fully initialized (i.e. due to failures in #TALER_EXCHANGE_deserialize_melt_data_()). + * fully initialized. * - * @param md melting data to release, the pointer itself is NOT + * @param[in] md melting data to release, the pointer itself is NOT * freed (as it is typically not allocated by itself) */ void |