summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-07-08 15:46:51 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-08 15:46:51 +0200
commit97dfbec0811b1a0b92618f195e228c43376e4828 (patch)
tree38cd327fcc2a7113dfcdd53b627152f82b7a6a32 /src
parent1ca062fc7a303202130f194a15739ea7ce6c2dc2 (diff)
downloadexchange-97dfbec0811b1a0b92618f195e228c43376e4828.tar.gz
exchange-97dfbec0811b1a0b92618f195e228c43376e4828.tar.bz2
exchange-97dfbec0811b1a0b92618f195e228c43376e4828.zip
add h_denom_pub to deposit signatures
Diffstat (limited to 'src')
-rw-r--r--src/exchange/taler-exchange-httpd_deposit.c1
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c21
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c28
-rw-r--r--src/include/taler_exchange_service.h2
-rw-r--r--src/include/taler_exchangedb_plugin.h15
-rw-r--r--src/include/taler_signatures.h11
-rw-r--r--src/lib/exchange_api_common.c2
-rw-r--r--src/lib/exchange_api_deposit.c4
-rw-r--r--src/testing/testing_api_cmd_deposit.c1
9 files changed, 72 insertions, 13 deletions
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c
index 95143758d..c2610b4b9 100644
--- a/src/exchange/taler-exchange-httpd_deposit.c
+++ b/src/exchange/taler-exchange-httpd_deposit.c
@@ -520,6 +520,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
.purpose.size = htonl (sizeof (dr)),
.h_contract_terms = deposit.h_contract_terms,
.h_wire = deposit.h_wire,
+ .h_denom_pub = deposit.coin.denom_pub_hash,
.wallet_timestamp = GNUNET_TIME_absolute_hton (deposit.timestamp),
.refund_deadline = GNUNET_TIME_absolute_hton (deposit.refund_deadline),
.merchant = deposit.merchant_pub,
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index f65951614..ee65cd6e0 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -66,6 +66,7 @@ TEH_RESPONSE_compile_transaction_history (
.purpose.size = htonl (sizeof (dr)),
.h_contract_terms = deposit->h_contract_terms,
.h_wire = deposit->h_wire,
+ .h_denom_pub = deposit->h_denom_pub,
.wallet_timestamp = GNUNET_TIME_absolute_hton (deposit->timestamp),
.refund_deadline = GNUNET_TIME_absolute_hton (
deposit->refund_deadline),
@@ -94,7 +95,7 @@ TEH_RESPONSE_compile_transaction_history (
json_array_append_new (
history,
json_pack (
- "{s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
+ "{s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
"type",
"DEPOSIT",
"amount",
@@ -111,6 +112,8 @@ TEH_RESPONSE_compile_transaction_history (
GNUNET_JSON_from_data_auto (&deposit->h_contract_terms),
"h_wire",
GNUNET_JSON_from_data_auto (&deposit->h_wire),
+ "h_denom_pub",
+ GNUNET_JSON_from_data_auto (&deposit->h_denom_pub),
"coin_sig",
GNUNET_JSON_from_data_auto (&deposit->csig))))
{
@@ -151,7 +154,7 @@ TEH_RESPONSE_compile_transaction_history (
if (0 !=
json_array_append_new (
history,
- json_pack ("{s:s, s:o, s:o, s:o, s:o}",
+ json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
"type",
"MELT",
"amount",
@@ -160,6 +163,8 @@ TEH_RESPONSE_compile_transaction_history (
TALER_JSON_from_amount (&melt->melt_fee),
"rc",
GNUNET_JSON_from_data_auto (&melt->rc),
+ "h_denom_pub",
+ GNUNET_JSON_from_data_auto (&melt->h_denom_pub),
"coin_sig",
GNUNET_JSON_from_data_auto (&melt->coin_sig))))
{
@@ -267,7 +272,7 @@ TEH_RESPONSE_compile_transaction_history (
if (0 !=
json_array_append_new (
history,
- json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
+ json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o, s:o}",
"type",
"OLD-COIN-RECOUP",
"amount",
@@ -278,6 +283,8 @@ TEH_RESPONSE_compile_transaction_history (
GNUNET_JSON_from_data_auto (&epub),
"coin_pub",
GNUNET_JSON_from_data_auto (&pr->coin.coin_pub),
+ "h_denom_pub",
+ GNUNET_JSON_from_data_auto (&pr->coin.denom_pub_hash),
"timestamp",
GNUNET_JSON_from_time_abs (pr->timestamp))))
{
@@ -315,7 +322,7 @@ TEH_RESPONSE_compile_transaction_history (
if (0 !=
json_array_append_new (
history,
- json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
+ json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o, s:o}",
"type",
"RECOUP",
"amount",
@@ -326,6 +333,8 @@ TEH_RESPONSE_compile_transaction_history (
GNUNET_JSON_from_data_auto (&epub),
"reserve_pub",
GNUNET_JSON_from_data_auto (&recoup->reserve_pub),
+ "h_denom_pub",
+ GNUNET_JSON_from_data_auto (&recoup->h_denom_pub),
"timestamp",
GNUNET_JSON_from_time_abs (recoup->timestamp))))
{
@@ -369,7 +378,7 @@ TEH_RESPONSE_compile_transaction_history (
if (0 !=
json_array_append_new (
history,
- json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
+ json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o, s:o}",
"type",
"RECOUP-REFRESH",
"amount",
@@ -380,6 +389,8 @@ TEH_RESPONSE_compile_transaction_history (
GNUNET_JSON_from_data_auto (&epub),
"old_coin_pub",
GNUNET_JSON_from_data_auto (&pr->old_coin_pub),
+ "h_denom_pub",
+ GNUNET_JSON_from_data_auto (&pr->coin.denom_pub_hash),
"timestamp",
GNUNET_JSON_from_time_abs (pr->timestamp))))
{
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 98b3c170b..0f96f0e86 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -662,13 +662,15 @@ postgres_get_session (void *cls)
",old_coin_sig"
",amount_with_fee_val"
",amount_with_fee_frac"
+ ",kc.denom_pub_hash"
",denom.fee_refresh_val "
",denom.fee_refresh_frac "
",melt_serial_id"
" FROM refresh_commitments"
- " JOIN known_coins "
- " ON (refresh_commitments.old_coin_pub = known_coins.coin_pub)"
- " JOIN denominations denom USING (denom_pub_hash)"
+ " JOIN known_coins kc"
+ " ON (refresh_commitments.old_coin_pub = kc.coin_pub)"
+ " JOIN denominations denom"
+ " USING (denom_pub_hash)"
" WHERE old_coin_pub=$1;",
1),
@@ -953,6 +955,7 @@ postgres_get_session (void *cls)
",amount_with_fee_frac"
",denom.fee_deposit_val"
",denom.fee_deposit_frac"
+ ",kc.denom_pub_hash"
",wallet_timestamp"
",refund_deadline"
",wire_deadline"
@@ -963,7 +966,7 @@ postgres_get_session (void *cls)
",coin_sig"
",deposit_serial_id"
" FROM deposits"
- " JOIN known_coins"
+ " JOIN known_coins kc"
" USING (coin_pub)"
" JOIN denominations denom"
" USING (denom_pub_hash)"
@@ -1296,8 +1299,8 @@ postgres_get_session (void *cls)
",coins.denom_sig"
",recoup_refresh_uuid"
" FROM recoup_refresh"
- " JOIN known_coins coins"
- " USING (coin_pub)"
+ " JOIN known_coins coins"
+ " USING (coin_pub)"
" WHERE h_blind_ev IN"
" (SELECT rrc.h_coin_ev"
" FROM refresh_commitments"
@@ -1340,6 +1343,7 @@ postgres_get_session (void *cls)
GNUNET_PQ_make_prepare ("recoup_by_coin",
"SELECT"
" ro.reserve_pub"
+ ",coins.denom_pub_hash"
",coin_sig"
",coin_blind"
",amount_val"
@@ -1347,8 +1351,10 @@ postgres_get_session (void *cls)
",timestamp"
",recoup_uuid"
" FROM recoup"
- " JOIN reserves_out ro"
- " USING (h_blind_ev)"
+ " JOIN reserves_out ro"
+ " USING (h_blind_ev)"
+ " JOIN known_coins coins"
+ " USING (coin_pub)"
" WHERE recoup.coin_pub=$1"
" FOR UPDATE;",
1),
@@ -4079,6 +4085,8 @@ add_coin_deposit (void *cls,
&deposit->refund_deadline),
TALER_PQ_result_spec_absolute_time ("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",
@@ -4144,6 +4152,8 @@ add_coin_melt (void *cls,
GNUNET_PQ_result_spec_auto_from_type ("rc",
&melt->rc),
/* oldcoin_index not needed */
+ GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
+ &melt->h_denom_pub),
GNUNET_PQ_result_spec_auto_from_type ("old_coin_sig",
&melt->coin_sig),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
@@ -4335,6 +4345,8 @@ add_coin_recoup (void *cls,
&recoup->reserve_pub),
GNUNET_PQ_result_spec_auto_from_type ("coin_sig",
&recoup->coin_sig),
+ GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
+ &recoup->h_denom_pub),
GNUNET_PQ_result_spec_auto_from_type ("coin_blind",
&recoup->coin_blind),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index 02ab182f2..b12edb05c 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -751,6 +751,7 @@ TALER_EXCHANGE_wire_cancel (struct TALER_EXCHANGE_WireHandle *wh);
* @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 h_denom_pub hash of the coin denomination's public key
* @param coin_priv coin’s private key
* @param wallet_timestamp timestamp when the contract was finalized, must not be too far in the future
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
@@ -763,6 +764,7 @@ TALER_EXCHANGE_deposit_permission_sign (
const struct TALER_Amount *deposit_fee,
const struct GNUNET_HashCode *h_wire,
const struct GNUNET_HashCode *h_contract_terms,
+ const struct GNUNET_HashCode *h_denom_pub,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct GNUNET_TIME_Absolute wallet_timestamp,
const struct TALER_MerchantPublicKeyP *merchant_pub,
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index d069bd2ec..a12aaa426 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -336,6 +336,11 @@ struct TALER_EXCHANGEDB_RecoupListEntry
struct TALER_CoinSpendSignatureP coin_sig;
/**
+ * Hash of the public denomination key used to sign the coin.
+ */
+ struct GNUNET_HashCode h_denom_pub;
+
+ /**
* Public key of the reserve the coin was paid back into.
*/
struct TALER_ReservePublicKeyP reserve_pub;
@@ -609,6 +614,11 @@ struct TALER_EXCHANGEDB_DepositListEntry
struct GNUNET_HashCode h_wire;
/**
+ * Hash of the public denomination key used to sign the coin.
+ */
+ struct GNUNET_HashCode h_denom_pub;
+
+ /**
* Detailed information about the receiver for executing the transaction.
* Includes URL in payto://-format and salt.
*/
@@ -782,6 +792,11 @@ struct TALER_EXCHANGEDB_MeltListEntry
struct TALER_RefreshCommitmentP rc;
/**
+ * Hash of the public denomination key used to sign the coin.
+ */
+ struct GNUNET_HashCode h_denom_pub;
+
+ /**
* How much value is being melted? This amount includes the fees,
* so the final amount contributed to the melt is this value minus
* the fee for melting the coin. We include the fee in what is
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 7f9e090a1..81e2e1c82 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -351,6 +351,11 @@ struct TALER_DepositRequestPS
struct GNUNET_HashCode h_wire GNUNET_PACKED;
/**
+ * Hash over the denomination public key used to sign the coin.
+ */
+ struct GNUNET_HashCode h_denom_pub GNUNET_PACKED;
+
+ /**
* Time when this request was generated. Used, for example, to
* assess when (roughly) the income was achieved for tax purposes.
* Note that the Exchange will only check that the timestamp is not "too
@@ -580,6 +585,12 @@ struct TALER_RefreshMeltCoinAffirmationPS
struct TALER_RefreshCommitmentP rc GNUNET_PACKED;
/**
+ * Hash over the denomination public key used to sign the coin.
+ * FIXME: add here, initialize everywhere!
+ */
+ // struct GNUNET_HashCode h_denom_pub GNUNET_PACKED;
+
+ /**
* How much of the value of the coin should be melted? This amount
* includes the fees, so the final amount contributed to the melt is
* this value minus the fee for melting the coin. We include the
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index 52c0e20ac..27dbbb86c 100644
--- a/src/lib/exchange_api_common.c
+++ b/src/lib/exchange_api_common.c
@@ -523,6 +523,8 @@ TALER_EXCHANGE_verify_coin_history (
&dr.h_contract_terms),
GNUNET_JSON_spec_fixed_auto ("h_wire",
&dr.h_wire),
+ GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
+ &dr.h_denom_pub),
TALER_JSON_spec_absolute_time_nbo ("timestamp",
&dr.wallet_timestamp),
TALER_JSON_spec_absolute_time_nbo ("refund_deadline",
diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c
index bb56ce1c9..ba3ba48e0 100644
--- a/src/lib/exchange_api_deposit.c
+++ b/src/lib/exchange_api_deposit.c
@@ -432,6 +432,7 @@ verify_signatures (const struct TALER_EXCHANGE_DenomPublicKey *dki,
.purpose.size = htonl (sizeof (dr)),
.h_contract_terms = *h_contract_terms,
.h_wire = *h_wire,
+ .h_denom_pub = *denom_pub_hash,
.wallet_timestamp = GNUNET_TIME_absolute_hton (timestamp),
.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline),
.merchant = *merchant_pub,
@@ -497,6 +498,7 @@ verify_signatures (const struct TALER_EXCHANGE_DenomPublicKey *dki,
* @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 h_denom_pub hash of the coin denomination's public key
* @param coin_priv coin’s private key
* @param wallet_timestamp timestamp when the contract was finalized, must not be too far in the future
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
@@ -509,6 +511,7 @@ TALER_EXCHANGE_deposit_permission_sign (
const struct TALER_Amount *deposit_fee,
const struct GNUNET_HashCode *h_wire,
const struct GNUNET_HashCode *h_contract_terms,
+ const struct GNUNET_HashCode *h_denom_pub,
const struct TALER_CoinSpendPrivateKeyP *coin_priv,
struct GNUNET_TIME_Absolute wallet_timestamp,
const struct TALER_MerchantPublicKeyP *merchant_pub,
@@ -522,6 +525,7 @@ TALER_EXCHANGE_deposit_permission_sign (
(TALER_SIGNATURE_WALLET_COIN_DEPOSIT),
.h_contract_terms = *h_contract_terms,
.h_wire = *h_wire,
+ .h_denom_pub = *h_denom_pub,
.wallet_timestamp = GNUNET_TIME_absolute_hton (wallet_timestamp),
.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline),
.merchant = *merchant_pub
diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c
index e7a4c2988..613f981b5 100644
--- a/src/testing/testing_api_cmd_deposit.c
+++ b/src/testing/testing_api_cmd_deposit.c
@@ -409,6 +409,7 @@ deposit_run (void *cls,
&denom_pub->fee_deposit,
&h_wire,
&h_contract_terms,
+ &denom_pub->h_key,
coin_priv,
ds->wallet_timestamp,
&merchant_pub,