diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-09-24 19:03:30 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-09-24 19:03:30 +0200 |
commit | c6f7bd46fe73236dd3464cc6d87a5bce92c1ef16 (patch) | |
tree | 9eb74c5348ffefac412c3adcbc0e2e1d81c5d217 /src/auditordb | |
parent | cb60a5695d330de0feea2fb4800ca853a8ffe0ed (diff) |
combine deposit confirmation signatures into one big signature
Diffstat (limited to 'src/auditordb')
-rw-r--r-- | src/auditordb/auditor-0001.sql | 7 | ||||
-rw-r--r-- | src/auditordb/pg_get_deposit_confirmations.c | 45 | ||||
-rw-r--r-- | src/auditordb/pg_insert_deposit_confirmation.c | 18 | ||||
-rw-r--r-- | src/auditordb/plugin_auditordb_postgres.c | 2 |
4 files changed, 51 insertions, 21 deletions
diff --git a/src/auditordb/auditor-0001.sql b/src/auditordb/auditor-0001.sql index a167e8555..b755da4b0 100644 --- a/src/auditordb/auditor-0001.sql +++ b/src/auditordb/auditor-0001.sql @@ -289,13 +289,14 @@ CREATE TABLE IF NOT EXISTS deposit_confirmations ,exchange_timestamp INT8 NOT NULL ,refund_deadline INT8 NOT NULL ,wire_deadline INT8 NOT NULL - ,amount_without_fee taler_amount NOT NULL - ,coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32) + ,total_without_fee taler_amount NOT NULL + ,coin_pubs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_pubs)>0) + ,coin_sigs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_sigs)=CARDINALITY(coin_pubs)) ,merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32) ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64) ,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32) ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64) - ,PRIMARY KEY (h_contract_terms,h_wire,coin_pub,merchant_pub,exchange_sig,exchange_pub,master_sig) + ,PRIMARY KEY (h_contract_terms,h_wire,merchant_pub,exchange_sig,exchange_pub,master_sig) ); COMMENT ON TABLE deposit_confirmations IS 'deposit confirmation sent to us by merchants; we must check that the exchange reported these properly.'; diff --git a/src/auditordb/pg_get_deposit_confirmations.c b/src/auditordb/pg_get_deposit_confirmations.c index 56306e105..86b6cdd8b 100644 --- a/src/auditordb/pg_get_deposit_confirmations.c +++ b/src/auditordb/pg_get_deposit_confirmations.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022-2023 Taler Systems SA 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 @@ -82,6 +82,10 @@ deposit_confirmation_cb (void *cls, struct TALER_AUDITORDB_DepositConfirmation dc = { .master_public_key = *dcc->master_pub }; + struct TALER_CoinSpendPublicKeyP *coin_pubs = NULL; + struct TALER_CoinSpendSignatureP *coin_sigs = NULL; + size_t num_pubs = 0; + size_t num_sigs = 0; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial_id", &serial_id), @@ -97,10 +101,16 @@ deposit_confirmation_cb (void *cls, &dc.refund_deadline), GNUNET_PQ_result_spec_timestamp ("wire_deadline", &dc.wire_deadline), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount_without_fee", - &dc.amount_without_fee), - GNUNET_PQ_result_spec_auto_from_type ("coin_pub", - &dc.coin_pub), + TALER_PQ_RESULT_SPEC_AMOUNT ("total_without_fee", + &dc.total_without_fee), + GNUNET_PQ_result_spec_auto_array_from_type (pg->conn, + "coin_pub", + &num_pubs, + coin_pubs), + GNUNET_PQ_result_spec_auto_array_from_type (pg->conn, + "coin_sigs", + &num_sigs, + coin_sigs), GNUNET_PQ_result_spec_auto_from_type ("merchant_pub", &dc.merchant), GNUNET_PQ_result_spec_auto_from_type ("exchange_sig", @@ -111,6 +121,7 @@ deposit_confirmation_cb (void *cls, &dc.master_sig), GNUNET_PQ_result_spec_end }; + enum GNUNET_GenericReturnValue rval; if (GNUNET_OK != GNUNET_PQ_extract_result (result, @@ -121,11 +132,22 @@ deposit_confirmation_cb (void *cls, dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; return; } + if (num_sigs != num_pubs) + { + GNUNET_break (0); + dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; + GNUNET_PQ_cleanup_result (rs); + return; + } dcc->qs = i + 1; - if (GNUNET_OK != - dcc->cb (dcc->cb_cls, - serial_id, - &dc)) + dc.coin_pubs = coin_pubs; + dc.coin_sigs = coin_sigs; + dc.num_coins = num_sigs; + rval = dcc->cb (dcc->cb_cls, + serial_id, + &dc); + GNUNET_PQ_cleanup_result (rs); + if (GNUNET_OK != rval) break; } } @@ -163,8 +185,9 @@ TAH_PG_get_deposit_confirmations ( ",exchange_timestamp" ",wire_deadline" ",refund_deadline" - ",amount_without_fee" - ",coin_pub" + ",total_without_fee" + ",coin_pubs" + ",coin_sigs" ",merchant_pub" ",exchange_sig" ",exchange_pub" diff --git a/src/auditordb/pg_insert_deposit_confirmation.c b/src/auditordb/pg_insert_deposit_confirmation.c index 7c54494d6..b811e267a 100644 --- a/src/auditordb/pg_insert_deposit_confirmation.c +++ b/src/auditordb/pg_insert_deposit_confirmation.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + Copyright (C) 2022, 2023 Taler Systems SA 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 @@ -41,8 +41,13 @@ TAH_PG_insert_deposit_confirmation ( GNUNET_PQ_query_param_timestamp (&dc->wire_deadline), GNUNET_PQ_query_param_timestamp (&dc->refund_deadline), TALER_PQ_query_param_amount (pg->conn, - &dc->amount_without_fee), - GNUNET_PQ_query_param_auto_from_type (&dc->coin_pub), + &dc->total_without_fee), + GNUNET_PQ_query_param_array_auto_from_type (dc->num_coins, + dc->coin_pubs, + pg->conn), + GNUNET_PQ_query_param_array_auto_from_type (dc->num_coins, + dc->coin_sigs, + pg->conn), GNUNET_PQ_query_param_auto_from_type (&dc->merchant), GNUNET_PQ_query_param_auto_from_type (&dc->exchange_sig), GNUNET_PQ_query_param_auto_from_type (&dc->exchange_pub), @@ -60,13 +65,14 @@ TAH_PG_insert_deposit_confirmation ( ",exchange_timestamp" ",wire_deadline" ",refund_deadline" - ",amount_without_fee" - ",coin_pub" + ",total_without_fee" + ",coin_pubs" + ",coin_sigs" ",merchant_pub" ",exchange_sig" ",exchange_pub" ",master_sig" /* master_sig could be normalized... */ - ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13);"); + ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "auditor_deposit_confirmation_insert", params); diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index 24d1768bf..2b722a5ea 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA + Copyright (C) 2014-2023 Taler Systems SA 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 |