From 71af4c539e341b6ee5c5f05695f834c48a93cbad Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Fri, 18 Feb 2022 02:07:38 +0100 Subject: -reducing FIXMEs re: age restriction - deposit info now carries h_age_commitment - benchmark does age commitment, too --- src/benchmark/taler-aggregator-benchmark.c | 24 +++++++++++++++++++++++- src/exchange/taler-exchange-httpd_responses.c | 5 ++++- src/exchangedb/plugin_exchangedb_postgres.c | 20 ++++++++++++++------ src/include/taler_exchangedb_plugin.h | 6 ++++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/benchmark/taler-aggregator-benchmark.c b/src/benchmark/taler-aggregator-benchmark.c index 3eb6e7e94..dde8ad401 100644 --- a/src/benchmark/taler-aggregator-benchmark.c +++ b/src/benchmark/taler-aggregator-benchmark.c @@ -493,6 +493,7 @@ run (void *cls, struct TALER_PlanchetMasterSecretP ps; struct TALER_ExchangeWithdrawValues alg_values; struct TALER_CoinSpendPublicKeyP coin_pub; + struct TALER_AgeCommitmentHash hac; union TALER_DenominationBlindingKeyP bks; RANDOMIZE (&coin_pub); @@ -525,10 +526,31 @@ run (void *cls, TALER_planchet_blinding_secret_create (&ps, &alg_values, &bks); + + { + uint32_t seed; + struct TALER_AgeMask mask = { + .mask = 1 || 1 << 8 || 1 << 12 || 1 << 16 || 1 << 18 + }; + struct TALER_AgeCommitment ac = {0}; + + seed = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, + UINT32_MAX); + + GNUNET_assert (GNUNET_OK == + TALER_age_restriction_commit ( + &mask, + 13, + seed, + &ac)); + + TALER_age_commitment_hash (&ac, &hac); + } + GNUNET_assert (GNUNET_OK == TALER_denom_blind (&denom_pub, &bks, - NULL, /* FIXME-oec */ + &hac, &coin_pub, &alg_values, &c_hash, diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 00f047172..ad10cc18f 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -73,7 +73,7 @@ TEH_RESPONSE_compile_transaction_history ( &deposit->deposit_fee, &h_wire, &deposit->h_contract_terms, - NULL, /* h_age_commitment, FIXME-oec */ + &deposit->h_age_commitment, NULL /* h_extensions! */, &deposit->h_denom_pub, deposit->timestamp, @@ -110,6 +110,9 @@ TEH_RESPONSE_compile_transaction_history ( &h_wire), GNUNET_JSON_pack_data_auto ("h_denom_pub", &deposit->h_denom_pub), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_data_auto ("h_age_commitment", + &deposit->h_age_commitment)), GNUNET_JSON_pack_data_auto ("coin_sig", &deposit->csig)))) { diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 6437ca54d..3d52bcfbc 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1188,6 +1188,7 @@ prepare_statements (struct PostgresClosure *pg) ",denoms.fee_deposit_val" ",denoms.fee_deposit_frac" ",denoms.denom_pub_hash" + ",kc.age_hash" ",wallet_timestamp" ",refund_deadline" ",wire_deadline" @@ -3090,7 +3091,6 @@ postgres_insert_denomination_info ( const struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue) { struct PostgresClosure *pg = cls; - uint32_t age_mask = 0; /* FIXME-OEC */ struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&issue->properties.denom_hash), TALER_PQ_query_param_denom_pub (denom_pub), @@ -3104,7 +3104,7 @@ postgres_insert_denomination_info ( TALER_PQ_query_param_amount_nbo (&issue->properties.fees.deposit), TALER_PQ_query_param_amount_nbo (&issue->properties.fees.refresh), TALER_PQ_query_param_amount_nbo (&issue->properties.fees.refund), - GNUNET_PQ_query_param_uint32 (&age_mask), + GNUNET_PQ_query_param_uint32 (&denom_pub->age_mask.mask), GNUNET_PQ_query_param_end }; struct TALER_DenomFeeSet fees; @@ -5641,11 +5641,14 @@ 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_auto_from_type ("age_hash", - &coin_info->h_age_commitment), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_auto_from_type ("age_hash", + &coin_info->h_age_commitment), + &is_null), TALER_PQ_result_spec_denom_sig ("denom_sig", &coin_info->denom_sig), GNUNET_PQ_result_spec_end @@ -6583,6 +6586,7 @@ 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); @@ -6592,14 +6596,18 @@ add_coin_deposit (void *cls, &deposit->amount_with_fee), TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit", &deposit->deposit_fee), + GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", + &deposit->h_denom_pub), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_auto_from_type ("age_hash", + &deposit->h_age_commitment), + &is_null), GNUNET_PQ_result_spec_timestamp ("wallet_timestamp", &deposit->timestamp), GNUNET_PQ_result_spec_timestamp ("refund_deadline", &deposit->refund_deadline), GNUNET_PQ_result_spec_timestamp ("wire_deadline", &deposit->wire_deadline), - GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", - &deposit->h_denom_pub), GNUNET_PQ_result_spec_auto_from_type ("merchant_pub", &deposit->merchant_pub), GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms", diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 41231c984..b6eee195e 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -1119,6 +1119,12 @@ struct TALER_EXCHANGEDB_DepositListEntry */ struct TALER_DenominationHash h_denom_pub; + /** + * Age commitment hash, if applicable ot the denomination. Should be all + * zeroes if age commitment is not applicable to the denonimation. + */ + struct TALER_AgeCommitmentHash h_age_commitment; + /** * Detailed information about the receiver for executing the transaction. * URL in payto://-format. -- cgit v1.2.3