Compare commits

...

3 Commits

Author SHA1 Message Date
7910ca183f
double melt test no works with age restriction
- added missing field h_age_commitment in exchange's error response
- slight refactoring
2022-02-22 18:35:10 +01:00
Christian Grothoff
fbdc1996a6
-use correct idx 2022-02-22 17:28:44 +01:00
Christian Grothoff
900b2d6fd9
-use correct idx 2022-02-22 17:26:27 +01:00
7 changed files with 40 additions and 29 deletions

View File

@ -111,6 +111,9 @@ TEH_RESPONSE_compile_transaction_history (
GNUNET_JSON_pack_data_auto ("h_denom_pub",
&deposit->h_denom_pub),
GNUNET_JSON_pack_allow_null (
deposit->no_age_commitment ?
GNUNET_JSON_pack_string (
"h_age_commitment", NULL) :
GNUNET_JSON_pack_data_auto ("h_age_commitment",
&deposit->h_age_commitment)),
GNUNET_JSON_pack_data_auto ("coin_sig",
@ -146,7 +149,7 @@ TEH_RESPONSE_compile_transaction_history (
/* Age restriction is optional. We communicate a NULL value to
* JSON_PACK below */
if (! TALER_AgeCommitmentHash_isNullOrZero (&melt->h_age_commitment))
if (! melt->no_age_commitment)
phac = &melt->h_age_commitment;
if (0 !=

View File

@ -5644,14 +5644,13 @@ postgres_get_known_coin (void *cls,
GNUNET_PQ_query_param_auto_from_type (coin_pub),
GNUNET_PQ_query_param_end
};
bool is_null;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
&coin_info->denom_pub_hash),
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash",
&coin_info->h_age_commitment),
&is_null),
&coin_info->no_age_commitment),
TALER_PQ_result_spec_denom_sig ("denom_sig",
&coin_info->denom_sig),
GNUNET_PQ_result_spec_end
@ -6590,7 +6589,6 @@ add_coin_deposit (void *cls,
struct TALER_EXCHANGEDB_DepositListEntry *deposit;
struct TALER_EXCHANGEDB_TransactionList *tl;
uint64_t serial_id;
bool is_null;
chc->have_deposit_or_melt = true;
deposit = GNUNET_new (struct TALER_EXCHANGEDB_DepositListEntry);
@ -6605,7 +6603,7 @@ add_coin_deposit (void *cls,
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash",
&deposit->h_age_commitment),
&is_null),
&deposit->no_age_commitment),
GNUNET_PQ_result_spec_timestamp ("wallet_timestamp",
&deposit->timestamp),
GNUNET_PQ_result_spec_timestamp ("refund_deadline",
@ -6671,7 +6669,6 @@ add_coin_melt (void *cls,
struct TALER_EXCHANGEDB_MeltListEntry *melt;
struct TALER_EXCHANGEDB_TransactionList *tl;
uint64_t serial_id;
bool hac_isnull;
chc->have_deposit_or_melt = true;
melt = GNUNET_new (struct TALER_EXCHANGEDB_MeltListEntry);
@ -6691,7 +6688,7 @@ add_coin_melt (void *cls,
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_auto_from_type ("h_age_commitment",
&melt->h_age_commitment),
&hac_isnull),
&melt->no_age_commitment),
GNUNET_PQ_result_spec_uint64 ("melt_serial_id",
&serial_id),
GNUNET_PQ_result_spec_end
@ -6708,9 +6705,6 @@ add_coin_melt (void *cls,
return;
}
if (hac_isnull)
memset (&melt->h_age_commitment, 0, sizeof(melt->h_age_commitment));
}
tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList);
tl->next = chc->head;

View File

@ -1055,6 +1055,11 @@ struct TALER_CoinPublicInfo
*/
struct TALER_AgeCommitmentHash h_age_commitment;
/**
* True, if age commitment is not applicable.
*/
bool no_age_commitment;
/**
* (Unblinded) signature over @e coin_pub with @e denom_pub,
* which demonstrates that the coin is valid.

View File

@ -1126,6 +1126,11 @@ struct TALER_EXCHANGEDB_DepositListEntry
*/
struct TALER_AgeCommitmentHash h_age_commitment;
/**
* true, if age commitment is not applicable
*/
bool no_age_commitment;
/**
* Detailed information about the receiver for executing the transaction.
* URL in payto://-format.
@ -1321,6 +1326,11 @@ struct TALER_EXCHANGEDB_MeltListEntry
*/
struct TALER_AgeCommitmentHash h_age_commitment;
/**
* true, if no h_age_commitment is applicable
*/
bool no_age_commitment;
/**
* How much value is being melted? This amount includes the fees,
* so the final amount contributed to the melt is this value minus

View File

@ -477,7 +477,7 @@ TALER_EXCHANGE_verify_coin_history (
struct TALER_MerchantPublicKeyP merchant_pub;
struct GNUNET_TIME_Timestamp refund_deadline = {0};
struct TALER_CoinSpendSignatureP sig;
struct TALER_AgeCommitmentHash *hac = NULL;
struct TALER_AgeCommitmentHash hac = {0};
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("coin_sig",
&sig),
@ -487,6 +487,9 @@ TALER_EXCHANGE_verify_coin_history (
&h_wire),
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
h_denom_pub),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
&hac)),
GNUNET_JSON_spec_timestamp ("timestamp",
&wallet_timestamp),
GNUNET_JSON_spec_mark_optional (
@ -508,18 +511,19 @@ TALER_EXCHANGE_verify_coin_history (
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
TALER_wallet_deposit_verify (&amount,
&fee,
&h_wire,
&h_contract_terms,
hac,
NULL /* h_extensions! */,
h_denom_pub,
wallet_timestamp,
&merchant_pub,
refund_deadline,
coin_pub,
&sig))
TALER_wallet_deposit_verify (
&amount,
&fee,
&h_wire,
&h_contract_terms,
TALER_AgeCommitmentHash_isNullOrZero (&hac) ? NULL : &hac,
NULL /* h_extensions! */,
h_denom_pub,
wallet_timestamp,
&merchant_pub,
refund_deadline,
coin_pub,
&sig))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;

View File

@ -81,7 +81,6 @@ struct TALER_EXCHANGE_LinkHandle
*
* @param lh link handle
* @param json json reply with the data for one coin
* @param coin_num number of the coin
* @param trans_pub our transfer public key
* @param[out] lci where to return coin details
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
@ -89,7 +88,6 @@ struct TALER_EXCHANGE_LinkHandle
static enum GNUNET_GenericReturnValue
parse_link_coin (const struct TALER_EXCHANGE_LinkHandle *lh,
const json_t *json,
uint32_t coin_num,
const struct TALER_TransferPublicKeyP *trans_pub,
struct TALER_EXCHANGE_LinkedCoinInfo *lci)
{
@ -136,7 +134,7 @@ parse_link_coin (const struct TALER_EXCHANGE_LinkHandle *lh,
&lh->coin_priv,
&secret);
TALER_transfer_secret_to_planchet_secret (&secret,
coin_num,
coin_idx,
&lci->ps);
TALER_planchet_setup_coin_priv (&lci->ps,
&alg_values,
@ -349,7 +347,6 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,
parse_link_coin (lh,
json_array_get (jsona,
i),
i,
&trans_pub,
lci))
{

View File

@ -644,7 +644,6 @@ run (void *cls,
GNUNET_TIME_UNIT_ZERO,
"EUR:0.1",
MHD_HTTP_OK),
#if 0 /* FIXME oec */
/* Test running a failing melt operation (same operation
* again must fail) */
TALER_TESTING_cmd_melt ("refresh-melt-failing-age",
@ -658,7 +657,6 @@ run (void *cls,
MHD_HTTP_CONFLICT,
NULL),
#endif
TALER_TESTING_cmd_end ()
};