2020-02-29 16:42:10 +01:00
|
|
|
/*
|
|
|
|
This file is part of TALER
|
2022-02-04 23:58:41 +01:00
|
|
|
Copyright (C) 2015-2022 Taler Systems SA
|
2020-02-29 16:42:10 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
Foundation; either version 3, or (at your option) any later version.
|
|
|
|
|
|
|
|
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
TALER; see the file COPYING. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
/**
|
2020-02-29 17:13:43 +01:00
|
|
|
* @file lib/exchange_api_refresh_common.h
|
|
|
|
* @brief shared (serialization) logic for refresh protocol
|
2020-02-29 16:42:10 +01:00
|
|
|
* @author Christian Grothoff
|
|
|
|
*/
|
|
|
|
#ifndef REFRESH_COMMON_H
|
|
|
|
#define REFRESH_COMMON_H
|
|
|
|
#include <jansson.h>
|
|
|
|
#include "taler_json_lib.h"
|
|
|
|
#include "taler_exchange_service.h"
|
|
|
|
#include "taler_signatures.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Information about a coin we are melting.
|
|
|
|
*/
|
|
|
|
struct MeltedCoin
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Private key of the coin.
|
|
|
|
*/
|
|
|
|
struct TALER_CoinSpendPrivateKeyP coin_priv;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Amount this coin contributes to the melt, including fee.
|
|
|
|
*/
|
|
|
|
struct TALER_Amount melt_amount_with_fee;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The applicable fee for melting a coin of this denomination
|
|
|
|
*/
|
|
|
|
struct TALER_Amount fee_melt;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The original value of the coin.
|
|
|
|
*/
|
|
|
|
struct TALER_Amount original_value;
|
|
|
|
|
2022-02-16 22:01:05 +01:00
|
|
|
/**
|
2022-03-01 17:02:37 +01:00
|
|
|
* The original age commitment, its proof and its hash. MUST be NULL if no
|
|
|
|
* age commitment was set.
|
2022-02-16 22:01:05 +01:00
|
|
|
*/
|
2022-03-01 17:02:37 +01:00
|
|
|
const struct TALER_AgeCommitmentProof *age_commitment_proof;
|
2022-02-22 14:27:15 +01:00
|
|
|
const struct TALER_AgeCommitmentHash *h_age_commitment;
|
2022-02-16 22:01:05 +01:00
|
|
|
|
2020-02-29 16:42:10 +01:00
|
|
|
/**
|
|
|
|
* Timestamp indicating when coins of this denomination become invalid.
|
|
|
|
*/
|
2021-12-14 16:04:32 +01:00
|
|
|
struct GNUNET_TIME_Timestamp expire_deposit;
|
2020-02-29 16:42:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Denomination key of the original coin.
|
|
|
|
*/
|
|
|
|
struct TALER_DenominationPublicKey pub_key;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Exchange's signature over the coin.
|
|
|
|
*/
|
|
|
|
struct TALER_DenominationSignature sig;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-02-13 12:44:09 +01:00
|
|
|
/**
|
|
|
|
* Data we keep for each fresh coin created in the
|
|
|
|
* melt process.
|
|
|
|
*/
|
|
|
|
struct FreshCoinData
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Denomination public key of the coin.
|
|
|
|
*/
|
|
|
|
struct TALER_DenominationPublicKey fresh_pk;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of planchet secrets for the coins, depending
|
|
|
|
* on the cut-and-choose.
|
|
|
|
*/
|
|
|
|
struct TALER_PlanchetMasterSecretP ps[TALER_CNC_KAPPA];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private key of the coin.
|
|
|
|
*/
|
|
|
|
struct TALER_CoinSpendPrivateKeyP coin_priv;
|
|
|
|
|
2022-02-16 22:01:05 +01:00
|
|
|
/**
|
2022-03-01 17:02:37 +01:00
|
|
|
* Arrays of age commitments and proofs to be created, one for each
|
|
|
|
* cut-and-choose dimension. The entries in each list might be NULL and
|
|
|
|
* indicate no age commitment/restriction on the particular coin.
|
2022-02-16 22:01:05 +01:00
|
|
|
*/
|
2022-03-01 17:02:37 +01:00
|
|
|
struct TALER_AgeCommitmentProof *age_commitment_proof[TALER_CNC_KAPPA];
|
2022-02-16 22:01:05 +01:00
|
|
|
|
2022-02-13 12:44:09 +01:00
|
|
|
/**
|
|
|
|
* Blinding key secrets for the coins, depending on the
|
|
|
|
* cut-and-choose.
|
|
|
|
*/
|
|
|
|
union TALER_DenominationBlindingKeyP bks[TALER_CNC_KAPPA];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-02-29 16:42:10 +01:00
|
|
|
/**
|
|
|
|
* Melt data in non-serialized format for convenient processing.
|
|
|
|
*/
|
|
|
|
struct MeltData
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hash over the committed data during refresh operation.
|
|
|
|
*/
|
|
|
|
struct TALER_RefreshCommitmentP rc;
|
|
|
|
|
|
|
|
/**
|
2022-02-13 12:44:09 +01:00
|
|
|
* Information about the melted coin.
|
2020-02-29 16:42:10 +01:00
|
|
|
*/
|
2022-02-13 12:44:09 +01:00
|
|
|
struct MeltedCoin melted_coin;
|
2020-02-29 16:42:10 +01:00
|
|
|
|
|
|
|
/**
|
2022-02-13 12:44:09 +01:00
|
|
|
* Array of length @e num_fresh_coins with information
|
|
|
|
* about each fresh coin.
|
2020-02-29 16:42:10 +01:00
|
|
|
*/
|
2022-02-13 12:44:09 +01:00
|
|
|
struct FreshCoinData *fcds;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfer secrets, one per cut and choose.
|
|
|
|
*/
|
|
|
|
struct TALER_TransferSecretP trans_sec[TALER_CNC_KAPPA];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfer private keys for each cut-and-choose dimension.
|
|
|
|
*/
|
|
|
|
struct TALER_TransferPrivateKeyP transfer_priv[TALER_CNC_KAPPA];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfer public key of this commitment.
|
|
|
|
*/
|
|
|
|
struct TALER_TransferPublicKeyP transfer_pub[TALER_CNC_KAPPA];
|
2020-02-29 16:42:10 +01:00
|
|
|
|
|
|
|
/**
|
2022-02-13 12:44:09 +01:00
|
|
|
* Transfer secrets, one per cut and choose.
|
2020-02-29 16:42:10 +01:00
|
|
|
*/
|
2022-02-13 12:44:09 +01:00
|
|
|
struct TALER_RefreshCommitmentEntry rce[TALER_CNC_KAPPA];
|
2020-02-29 16:42:10 +01:00
|
|
|
|
|
|
|
/**
|
2022-02-13 12:44:09 +01:00
|
|
|
* Blinded planchets and denominations of the fresh coins, depending on the cut-and-choose. Array of length
|
|
|
|
* @e num_fresh_coins.
|
2020-02-29 16:42:10 +01:00
|
|
|
*/
|
2022-02-13 12:44:09 +01:00
|
|
|
struct TALER_RefreshCoinData *rcd[TALER_CNC_KAPPA];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of coins we are creating
|
|
|
|
*/
|
|
|
|
uint16_t num_fresh_coins;
|
|
|
|
|
2020-02-29 16:42:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2022-02-04 22:02:48 +01:00
|
|
|
* Compute the melt data from the refresh data and secret.
|
2020-02-29 16:42:10 +01:00
|
|
|
*
|
2022-02-11 09:36:01 +01:00
|
|
|
* @param rms secret internals of the refresh-reveal operation
|
2022-02-04 22:02:48 +01:00
|
|
|
* @param rd refresh data with the characteristics of the operation
|
2022-02-04 23:58:41 +01:00
|
|
|
* @param alg_values contributions from the exchange into the melt
|
2022-02-12 12:35:03 +01:00
|
|
|
* @param[out] md where to write the derived melt data
|
2020-02-29 16:42:10 +01:00
|
|
|
*/
|
2022-02-04 22:02:48 +01:00
|
|
|
enum GNUNET_GenericReturnValue
|
|
|
|
TALER_EXCHANGE_get_melt_data_ (
|
2022-02-11 09:36:01 +01:00
|
|
|
const struct TALER_RefreshMasterSecretP *rms,
|
2022-02-05 23:42:17 +01:00
|
|
|
const struct TALER_EXCHANGE_RefreshData *rd,
|
2022-02-04 23:58:41 +01:00
|
|
|
const struct TALER_ExchangeWithdrawValues *alg_values,
|
2022-02-04 22:02:48 +01:00
|
|
|
struct MeltData *md);
|
2020-02-29 16:42:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2022-02-12 12:35:03 +01:00
|
|
|
* fully initialized.
|
2020-02-29 16:42:10 +01:00
|
|
|
*
|
2021-10-27 13:23:14 +02:00
|
|
|
* @param[in] md melting data to release, the pointer itself is NOT
|
2020-02-29 16:42:10 +01:00
|
|
|
* freed (as it is typically not allocated by itself)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
TALER_EXCHANGE_free_melt_data_ (struct MeltData *md);
|
|
|
|
|
|
|
|
#endif
|