diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-09-11 15:33:01 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-09-11 15:33:01 +0200 |
commit | dae8235928105f24f3178cdd2bcfa67ac0fb21c3 (patch) | |
tree | db60f58b780d8dffd43e3408cb978e654f46eca8 /src | |
parent | 3b99f24648f477a2b7afd890657bb2675e211d31 (diff) |
improve wallet_Data support in exchange APIs
Diffstat (limited to 'src')
-rw-r--r-- | src/auditor/taler-helper-auditor-coins.c | 3 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_batch-deposit.c | 1 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 1 | ||||
-rw-r--r-- | src/exchangedb/pg_get_coin_transactions.c | 5 | ||||
-rw-r--r-- | src/exchangedb/pg_select_coin_deposits_above_serial_id.c | 5 | ||||
-rw-r--r-- | src/include/taler_crypto_lib.h | 4 | ||||
-rw-r--r-- | src/include/taler_exchangedb_plugin.h | 20 | ||||
-rw-r--r-- | src/lib/exchange_api_common.c | 8 | ||||
-rw-r--r-- | src/lib/exchange_api_refund.c | 8 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_batch_deposit.c | 3 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_deposit.c | 3 | ||||
-rw-r--r-- | src/util/wallet_signatures.c | 8 |
12 files changed, 65 insertions, 4 deletions
diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index 5ce7fcb46..bfdc11c7e 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c @@ -1565,6 +1565,9 @@ deposit_cb (void *cls, &issue->fees.deposit, &h_wire, &deposit->h_contract_terms, + deposit->no_wallet_data_hash + ? NULL + : &deposit->wallet_data_hash, &deposit->coin.h_age_commitment, &deposit->h_policy, &h_denom_pub, diff --git a/src/exchange/taler-exchange-httpd_batch-deposit.c b/src/exchange/taler-exchange-httpd_batch-deposit.c index e2aac1f2a..4ef143084 100644 --- a/src/exchange/taler-exchange-httpd_batch-deposit.c +++ b/src/exchange/taler-exchange-httpd_batch-deposit.c @@ -468,6 +468,7 @@ parse_coin (struct MHD_Connection *connection, deposit_fee, &dc->h_wire, &bd->h_contract_terms, + &bd->wallet_data_hash, &cdi->coin.h_age_commitment, NULL != dc->policy_json ? &dc->h_policy : NULL, &cdi->coin.denom_pub_hash, diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 863166e00..1b601b873 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -76,6 +76,7 @@ TEH_RESPONSE_compile_transaction_history ( &deposit->deposit_fee, &h_wire, &deposit->h_contract_terms, + &deposit->wallet_data_hash, &deposit->h_age_commitment, &deposit->h_policy, &deposit->h_denom_pub, diff --git a/src/exchangedb/pg_get_coin_transactions.c b/src/exchangedb/pg_get_coin_transactions.c index ad0835fdc..e05fbbd95 100644 --- a/src/exchangedb/pg_get_coin_transactions.c +++ b/src/exchangedb/pg_get_coin_transactions.c @@ -100,6 +100,10 @@ add_coin_deposit (void *cls, GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash", &deposit->h_age_commitment), &deposit->no_age_commitment), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_auto_from_type ("wallet_data_hash", + &deposit->wallet_data_hash), + &deposit->no_wallet_data_hash), GNUNET_PQ_result_spec_timestamp ("wallet_timestamp", &deposit->timestamp), GNUNET_PQ_result_spec_timestamp ("refund_deadline", @@ -735,6 +739,7 @@ TEH_PG_get_coin_transactions ( ",bdep.wire_deadline" ",bdep.merchant_pub" ",bdep.h_contract_terms" + ",bdep.wallet_data_hash" ",bdep.wire_salt" ",wt.payto_uri" ",cdep.coin_sig" diff --git a/src/exchangedb/pg_select_coin_deposits_above_serial_id.c b/src/exchangedb/pg_select_coin_deposits_above_serial_id.c index 49065c175..000b908ed 100644 --- a/src/exchangedb/pg_select_coin_deposits_above_serial_id.c +++ b/src/exchangedb/pg_select_coin_deposits_above_serial_id.c @@ -93,6 +93,10 @@ coin_deposit_serial_helper_cb (void *cls, GNUNET_PQ_result_spec_auto_from_type ("age_commitment_hash", &deposit.coin.h_age_commitment), &deposit.coin.no_age_commitment), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_auto_from_type ("wallet_data_hash", + &deposit.wallet_data_hash), + &deposit.no_wallet_data_hash), GNUNET_PQ_result_spec_auto_from_type ("coin_sig", &deposit.csig), GNUNET_PQ_result_spec_timestamp ("refund_deadline", @@ -166,6 +170,7 @@ TEH_PG_select_coin_deposits_above_serial_id ( ",bdep.wallet_timestamp" ",bdep.exchange_timestamp" ",bdep.merchant_pub" + ",bdep.wallet_data_hash" ",denom.denom_pub" ",kc.coin_pub" ",kc.age_commitment_hash" diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index ee06f631c..67e5ff713 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -3548,6 +3548,7 @@ TALER_wallet_reserve_attest_request_verify ( * @param deposit_fee the deposit fee we expect to pay * @param h_wire hash of the merchant’s account details * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) + * @param wallet_data_hash hash over wallet inputs into the contract (maybe NULL) * @param h_age_commitment hash over the age commitment, if applicable to the denomination (maybe NULL) * @param h_policy hash over the policy extension * @param h_denom_pub hash of the coin denomination's public key @@ -3563,6 +3564,7 @@ TALER_wallet_deposit_sign ( const struct TALER_Amount *deposit_fee, const struct TALER_MerchantWireHashP *h_wire, const struct TALER_PrivateContractHashP *h_contract_terms, + const struct GNUNET_HashCode *wallet_data_hash, const struct TALER_AgeCommitmentHash *h_age_commitment, const struct TALER_ExtensionPolicyHashP *h_policy, const struct TALER_DenominationHashP *h_denom_pub, @@ -3580,6 +3582,7 @@ TALER_wallet_deposit_sign ( * @param deposit_fee the deposit fee we expect to pay * @param h_wire hash of the merchant’s account details * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) + * @param wallet_data_hash hash over wallet inputs into the contract (maybe NULL) * @param h_age_commitment hash over the age commitment (maybe all zeroes, if not applicable to the denomination) * @param h_policy hash over the policy extension * @param h_denom_pub hash of the coin denomination's public key @@ -3596,6 +3599,7 @@ TALER_wallet_deposit_verify ( const struct TALER_Amount *deposit_fee, const struct TALER_MerchantWireHashP *h_wire, const struct TALER_PrivateContractHashP *h_contract_terms, + const struct GNUNET_HashCode *wallet_data_hash, const struct TALER_AgeCommitmentHash *h_age_commitment, const struct TALER_ExtensionPolicyHashP *h_policy, const struct TALER_DenominationHashP *h_denom_pub, diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index c3be78b4b..8be26a75d 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -1862,6 +1862,11 @@ struct TALER_EXCHANGEDB_Deposit struct TALER_WireSaltP wire_salt; /** + * Hash over inputs from the wallet to customize the contract. + */ + struct GNUNET_HashCode wallet_data_hash; + + /** * Hash over the policy data for this deposit (remains unknown to the * Exchange). Needed for the verification of the deposit's signature */ @@ -1919,6 +1924,11 @@ struct TALER_EXCHANGEDB_Deposit */ bool has_policy; + /** + * True if @e wallet_data_hash is not in use. + */ + bool no_wallet_data_hash; + }; @@ -1950,6 +1960,11 @@ struct TALER_EXCHANGEDB_DepositListEntry struct TALER_PrivateContractHashP h_contract_terms; /** + * Hash over inputs from the wallet to customize the contract. + */ + struct GNUNET_HashCode wallet_data_hash; + + /** * Hash of the public denomination key used to sign the coin. */ struct TALER_DenominationHashP h_denom_pub; @@ -2024,6 +2039,11 @@ struct TALER_EXCHANGEDB_DepositListEntry bool no_age_commitment; /** + * true, if wallet data hash is not present + */ + bool no_wallet_data_hash; + + /** * True if a policy was provided with the deposit request */ bool has_policy; diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index ac0c46174..609a2f7ef 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -848,6 +848,8 @@ help_deposit (struct CoinHistoryParseContext *pc, struct TALER_PrivateContractHashP h_contract_terms; struct TALER_ExtensionPolicyHashP h_policy; bool no_h_policy; + struct GNUNET_HashCode wallet_data_hash; + bool no_wallet_data_hash; struct GNUNET_TIME_Timestamp wallet_timestamp; struct TALER_MerchantPublicKeyP merchant_pub; struct GNUNET_TIME_Timestamp refund_deadline = {0}; @@ -860,6 +862,10 @@ help_deposit (struct CoinHistoryParseContext *pc, &sig), GNUNET_JSON_spec_fixed_auto ("h_contract_terms", &h_contract_terms), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_fixed_auto ("wallet_data_hash", + &wallet_data_hash), + &no_wallet_data_hash), GNUNET_JSON_spec_fixed_auto ("h_wire", &h_wire), GNUNET_JSON_spec_mark_optional ( @@ -897,6 +903,7 @@ help_deposit (struct CoinHistoryParseContext *pc, &deposit_fee, &h_wire, &h_contract_terms, + no_wallet_data_hash ? NULL : &wallet_data_hash, no_hac ? NULL : &hac, no_h_policy ? NULL : &h_policy, &pc->dk->h_key, @@ -2145,6 +2152,7 @@ TALER_EXCHANGE_verify_deposit_signature_ ( &dki->fees.deposit, h_wire, &dcd->h_contract_terms, + &dcd->wallet_data_hash, &cdd->h_age_commitment, ech, &cdd->h_denom_pub, diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 83f9612df..3f12f28d6 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -234,6 +234,8 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, bool no_hac; struct TALER_ExtensionPolicyHashP h_policy; bool no_h_policy; + struct GNUNET_HashCode wallet_data_hash; + bool no_wallet_data_hash; struct GNUNET_TIME_Timestamp wallet_timestamp; struct TALER_MerchantPublicKeyP merchant_pub; struct GNUNET_TIME_Timestamp refund_deadline; @@ -253,6 +255,10 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, GNUNET_JSON_spec_fixed_auto ("h_policy", &h_policy), &no_h_policy), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_fixed_auto ("wallet_data_hash", + &wallet_data_hash), + &no_wallet_data_hash), GNUNET_JSON_spec_timestamp ("timestamp", &wallet_timestamp), GNUNET_JSON_spec_timestamp ("refund_deadline", @@ -277,6 +283,8 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh, &deposit_fee, &h_wire, &h_contract_terms, + no_wallet_data_hash ? NULL : + &wallet_data_hash, no_hac ? NULL : &h_age_commitment, no_h_policy ? NULL: &h_policy, &h_denom_pub, diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c index c1e973cb7..a3c25e355 100644 --- a/src/testing/testing_api_cmd_batch_deposit.c +++ b/src/testing/testing_api_cmd_batch_deposit.c @@ -364,8 +364,9 @@ batch_deposit_run (void *cls, &denom_pub->fees.deposit, &h_wire, &h_contract_terms, + NULL, /* wallet_data_hash */ &cdd->h_age_commitment, - NULL, /* FIXME #7270: add hash of extensions */ + NULL, /* hash of extensions */ &denom_pub->h_key, ds->wallet_timestamp, &merchant_pub, diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c index 0e17dc2ff..0ee6aa447 100644 --- a/src/testing/testing_api_cmd_deposit.c +++ b/src/testing/testing_api_cmd_deposit.c @@ -441,8 +441,9 @@ deposit_run (void *cls, &denom_pub->fees.deposit, &h_wire, &h_contract_terms, + NULL, /* wallet data hash */ phac, - NULL, /* FIXME #7270: add hash of extensions */ + NULL, /* hash of extensions */ &denom_pub->h_key, ds->wallet_timestamp, &merchant_pub, diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c index 89acecb35..4b2fab6e4 100644 --- a/src/util/wallet_signatures.c +++ b/src/util/wallet_signatures.c @@ -127,6 +127,7 @@ TALER_wallet_deposit_sign ( const struct TALER_Amount *deposit_fee, const struct TALER_MerchantWireHashP *h_wire, const struct TALER_PrivateContractHashP *h_contract_terms, + const struct GNUNET_HashCode *wallet_data_hash, const struct TALER_AgeCommitmentHash *h_age_commitment, const struct TALER_ExtensionPolicyHashP *h_policy, const struct TALER_DenominationHashP *h_denom_pub, @@ -147,6 +148,8 @@ TALER_wallet_deposit_sign ( .merchant = *merchant_pub }; + if (NULL != wallet_data_hash) + dr.wallet_data_hash = *wallet_data_hash; if (NULL != h_age_commitment) dr.h_age_commitment = *h_age_commitment; if (NULL != h_policy) @@ -167,6 +170,7 @@ TALER_wallet_deposit_verify ( const struct TALER_Amount *deposit_fee, const struct TALER_MerchantWireHashP *h_wire, const struct TALER_PrivateContractHashP *h_contract_terms, + const struct GNUNET_HashCode *wallet_data_hash, const struct TALER_AgeCommitmentHash *h_age_commitment, const struct TALER_ExtensionPolicyHashP *h_policy, const struct TALER_DenominationHashP *h_denom_pub, @@ -185,10 +189,10 @@ TALER_wallet_deposit_verify ( .wallet_timestamp = GNUNET_TIME_timestamp_hton (wallet_timestamp), .refund_deadline = GNUNET_TIME_timestamp_hton (refund_deadline), .merchant = *merchant_pub, - .h_age_commitment = {{{0}}}, - .h_policy = {{{0}}} }; + if (NULL != wallet_data_hash) + dr.wallet_data_hash = *wallet_data_hash; if (NULL != h_age_commitment) dr.h_age_commitment = *h_age_commitment; if (NULL != h_policy) |