commit 1a63275d9804762f0bcdc1cd23060c2e9b364fbb
parent af3c92f9d5a9e0d674ab2b1d8028268552ab9f5b
Author: Özgür Kesim <oec-taler@kesim.org>
Date: Mon, 1 May 2023 14:05:58 +0200
WiP: age-withdraw, finished reveal-request, 10/n
- /age-withdraw/$ACH/reveal handler now fully implemented
- for consistency with api: rename of tables from withdraw_age_... to
age_withdraw
Diffstat:
14 files changed, 548 insertions(+), 407 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c b/src/exchange/taler-exchange-httpd_age-withdraw_reveal.c
@@ -22,6 +22,8 @@
#include <gnunet/gnunet_util_lib.h>
#include <jansson.h>
#include <microhttpd.h>
+#include "taler-exchange-httpd_metrics.h"
+#include "taler_exchangedb_plugin.h"
#include "taler_mhd_lib.h"
#include "taler-exchange-httpd_mhd.h"
#include "taler-exchange-httpd_age-withdraw_reveal.h"
@@ -387,12 +389,10 @@ denomination_is_valid (
struct TEH_DenominationKey *dks,
MHD_RESULT *result)
{
- dks = TEH_keys_denomination_by_hash2 (
- ksh,
- denom_h,
- connection,
- result);
-
+ dks = TEH_keys_denomination_by_hash2 (ksh,
+ denom_h,
+ connection,
+ result);
if (NULL == dks)
{
/* The denomination doesn't exist */
@@ -785,6 +785,43 @@ verify_commitment_and_max_age (
/**
+ * @brief Send a response for "/age-withdraw/$RCH/reveal"
+ *
+ * @param connection The http connection to the client to send the reponse to
+ * @param num_coins Number of new coins with age restriction for which we reveal data
+ * @param awrcs array of @a num_coins signatures revealed
+ * @return a MHD result code
+ */
+static MHD_RESULT
+reply_age_withdraw_reveal_success (
+ struct MHD_Connection *connection,
+ unsigned int num_coins,
+ const struct TALER_EXCHANGEDB_AgeWithdrawRevealedCoin *awrcs)
+{
+ json_t *list = json_array ();
+ GNUNET_assert (NULL != list);
+
+ for (unsigned int index = 0;
+ index < num_coins;
+ index++)
+ {
+ json_t *obj = GNUNET_JSON_PACK (
+ TALER_JSON_pack_blinded_denom_sig ("ev_sig",
+ &awrcs[index].coin_sig));
+ GNUNET_assert (0 ==
+ json_array_append_new (list,
+ obj));
+ }
+
+ return TALER_MHD_REPLY_JSON_PACK (
+ connection,
+ MHD_HTTP_OK,
+ GNUNET_JSON_pack_array_steal ("ev_sigs",
+ list));
+}
+
+
+/**
* @brief Signs and persists the undisclosed coins
*
* @param connection HTTP-connection to the client
@@ -796,7 +833,7 @@ verify_commitment_and_max_age (
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise
*/
static enum GNUNET_GenericReturnValue
-finalize_age_withdraw_and_sign (
+sign_and_finalize_age_withdraw (
struct MHD_Connection *connection,
const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
const uint32_t num_coins,
@@ -806,7 +843,9 @@ finalize_age_withdraw_and_sign (
{
enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR;
struct TEH_CoinSignData csds[num_coins];
- struct TALER_BlindedDenominationSignature bss[num_coins];
+ struct TALER_BlindedDenominationSignature bds[num_coins];
+ struct TALER_EXCHANGEDB_AgeWithdrawRevealedCoin awrcs[num_coins];
+ enum GNUNET_DB_QueryStatus qs;
for (uint32_t i = 0; i<num_coins; i++)
{
@@ -814,13 +853,13 @@ finalize_age_withdraw_and_sign (
csds[i].bp = &coin_evs[i];
}
- /* First, sign the the blinded coins */
+ /* Sign the the blinded coins first */
{
enum TALER_ErrorCode ec;
ec = TEH_keys_denomination_batch_sign (csds,
num_coins,
false,
- bss);
+ bds);
if (TALER_EC_NONE != ec)
{
GNUNET_break (0);
@@ -831,12 +870,104 @@ finalize_age_withdraw_and_sign (
}
}
- /* TODO[oec]:
- * - in a transaction: save the coins.
- * - add signature response
- */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Signatures ready, starting DB interaction\n");
+
+ /* Prepare the data for insertion */
+ for (uint32_t i = 0; i<num_coins; i++)
+ {
+ TALER_coin_ev_hash (&coin_evs[i],
+ csds[i].h_denom_pub,
+ &awrcs[i].h_coin_ev);
+ awrcs[i].h_denom_pub = *csds[i].h_denom_pub;
+ awrcs[i].coin_sig = bds[i];
+ }
+
+ /* Persist operation result in DB, transactionally */
+ for (unsigned int r = 0; r < MAX_TRANSACTION_COMMIT_RETRIES; r++)
+ {
+ bool changed = false;
+
+ /* Transaction start */
+ if (GNUNET_OK !=
+ TEH_plugin->start (TEH_plugin->cls,
+ "insert_age_withdraw_reveal batch"))
+ {
+ GNUNET_break (0);
+ ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_START_FAILED,
+ NULL);
+ goto cleanup;
+ }
+
+ qs = TEH_plugin->insert_age_withdraw_reveal (TEH_plugin->cls,
+ h_commitment,
+ num_coins,
+ awrcs);
+
+ if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+ {
+ TEH_plugin->rollback (TEH_plugin->cls);
+ continue;
+ }
+ else if (GNUNET_DB_STATUS_HARD_ERROR == qs)
+ {
+ GNUNET_break (0);
+ TEH_plugin->rollback (TEH_plugin->cls);
+ ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_STORE_FAILED,
+ "insert_age_withdraw_reveal");
+ goto cleanup;
+ }
+
+ changed = (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs);
+
+ /* Commit the transaction */
+ qs = TEH_plugin->commit (TEH_plugin->cls);
+ if (qs >= 0)
+ {
+ if (changed)
+ TEH_METRICS_num_success[TEH_MT_SUCCESS_AGE_WITHDRAW_REVEAL]++;
+
+ break; /* success */
-#pragma message "FIXME[oec]: implement finalize_age_withdraw_and_sign"
+ }
+ else if (GNUNET_DB_STATUS_HARD_ERROR == qs)
+ {
+ GNUNET_break (0);
+ TEH_plugin->rollback (TEH_plugin->cls);
+ ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_COMMIT_FAILED,
+ NULL);
+ goto cleanup;
+ }
+ else
+ {
+ TEH_plugin->rollback (TEH_plugin->cls);
+ }
+ } /* end of retry */
+
+ if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+ {
+ GNUNET_break (0);
+ TEH_plugin->rollback (TEH_plugin->cls);
+ ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_SOFT_FAILURE,
+ NULL);
+ goto cleanup;
+ }
+
+ /* Generate final (positive) response */
+ ret = reply_age_withdraw_reveal_success (connection,
+ num_coins,
+ awrcs);
+cleanup:
+ // TODO[oec]: handle error cases
+ // TODO[oec]: cleanup!
return ret;
}
@@ -922,7 +1053,7 @@ TEH_handler_age_withdraw_reveal (
break;
/* Finally, sign and persist the coins */
- if (GNUNET_OK != finalize_age_withdraw_and_sign (
+ if (GNUNET_OK != sign_and_finalize_age_withdraw (
rc->connection,
&actx.commitment.h_commitment,
actx.num_coins,
diff --git a/src/exchange/taler-exchange-httpd_metrics.h b/src/exchange/taler-exchange-httpd_metrics.h
@@ -61,7 +61,8 @@ enum TEH_MetricTypeSuccess
TEH_MT_SUCCESS_BATCH_WITHDRAW = 3,
TEH_MT_SUCCESS_MELT = 4,
TEH_MT_SUCCESS_REFRESH_REVEAL = 5,
- TEH_MT_SUCCESS_COUNT = 6 /* MUST BE LAST! */
+ TEH_MT_SUCCESS_AGE_WITHDRAW_REVEAL = 6,
+ TEH_MT_SUCCESS_COUNT = 7 /* MUST BE LAST! */
};
/**
diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
@@ -773,12 +773,17 @@ clean_age:
NULL);
goto cleanup;
}
+
for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
+ {
rrcs[i].coin_sig = bss[i];
+ rrcs[i].blinded_planchet = rcds[i].blinded_planchet;
+ }
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Signatures ready, starting DB interaction\n");
+
for (unsigned int r = 0; r<MAX_TRANSACTION_COMMIT_RETRIES; r++)
{
bool changed;
@@ -795,12 +800,7 @@ clean_age:
NULL);
goto cleanup;
}
- for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)
- {
- struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i];
- rrc->blinded_planchet = rcds[i].blinded_planchet;
- }
qs = TEH_plugin->insert_refresh_reveal (
TEH_plugin->cls,
melt_serial_id,
diff --git a/src/exchangedb/0003-age_withdraw_commitments.sql b/src/exchangedb/0003-age_withdraw_commitments.sql
@@ -0,0 +1,134 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2022 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
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+
+CREATE FUNCTION create_table_age_withdraw_commitments(
+ IN partition_suffix VARCHAR DEFAULT NULL
+)
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ table_name VARCHAR DEFAULT 'age_withdraw_commitments';
+BEGIN
+ PERFORM create_partitioned_table(
+ 'CREATE TABLE %I'
+ '(age_withdraw_commitment_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
+ ',h_commitment BYTEA CHECK (LENGTH(h_commitment)=64)'
+ ',amount_with_fee_val INT8 NOT NULL'
+ ',amount_with_fee_frac INT4 NOT NULL'
+ ',max_age INT2 NOT NULL'
+ ',reserve_pub BYTEA CHECK (LENGTH(reserve_pub)=32)'
+ ',reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64)'
+ ',noreveal_index INT4 NOT NULL'
+ ') %s ;'
+ ,table_name
+ ,'PARTITION BY HASH (reserve_pub)'
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_table(
+ 'Commitments made when withdrawing coins with age restriction and the gamma value chosen by the exchange.'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'The gamma value chosen by the exchange in the cut-and-choose protocol'
+ ,'noreveal_index'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'The maximum age (in years) that the client commits to with this request'
+ ,'max_age'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Commitment made by the client, hash over the various client inputs in the cut-and-choose protocol'
+ ,'h_commitment'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Reference to the public key of the reserve from which the coins are going to be withdrawn'
+ ,'reserve_pub'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Signature of the reserve''s private key over the withdraw-age request'
+ ,'reserve_sig'
+ ,table_name
+ ,partition_suffix
+ );
+END
+$$;
+
+
+CREATE FUNCTION constrain_table_age_withdraw_commitments(
+ IN partition_suffix VARCHAR
+)
+RETURNS void
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ table_name VARCHAR DEFAULT 'age_withdraw_commitments';
+BEGIN
+ table_name = concat_ws('_', table_name, partition_suffix);
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD PRIMARY KEY (h_commitment);'
+ );
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_h_commitment_reserve_pub_key'
+ ' UNIQUE (h_commitment, reserve_pub);'
+ );
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_age_withdraw_commitment_id_key'
+ ' UNIQUE (age_withdraw_commitment_id);'
+ );
+END
+$$;
+
+
+CREATE FUNCTION foreign_table_age_withdraw_commitments()
+RETURNS void
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ table_name VARCHAR DEFAULT 'age_withdraw_commitments';
+BEGIN
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_foreign_reserve_pub'
+ ' FOREIGN KEY (reserve_pub)'
+ ' REFERENCES reserves(reserve_pub) ON DELETE CASCADE;'
+ );
+END
+$$;
+
+
+INSERT INTO exchange_tables
+ (name
+ ,version
+ ,action
+ ,partitioned
+ ,by_range)
+VALUES
+ ('age_withdraw_commitments', 'exchange-0003', 'create', TRUE ,FALSE),
+ ('age_withdraw_commitments', 'exchange-0003', 'constrain',TRUE ,FALSE),
+ ('age_withdraw_commitments', 'exchange-0003', 'foreign', TRUE ,FALSE);
diff --git a/src/exchangedb/0003-age_withdraw_reveals.sql b/src/exchangedb/0003-age_withdraw_reveals.sql
@@ -0,0 +1,152 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2022 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
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+
+CREATE FUNCTION create_table_age_withdraw_revealed_coins(
+ IN partition_suffix VARCHAR DEFAULT NULL
+)
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ table_name VARCHAR DEFAULT 'age_withdraw_revealed_coins';
+BEGIN
+ PERFORM create_partitioned_table(
+ 'CREATE TABLE %I'
+ '(age_withdraw_revealed_coins_id BIGINT GENERATED BY DEFAULT AS IDENTITY' -- UNIQUE
+ ',h_commitment BYTEA NOT NULL CHECK (LENGTH(h_commitment)=64)'
+ ',freshcoin_index INT4 NOT NULL'
+ ',denominations_serial INT8 NOT NULL'
+ ',coin_ev BYTEA NOT NULL'
+ ',h_coin_ev BYTEA CHECK (LENGTH(h_coin_ev)=64)'
+ ',ev_sig BYTEA NOT NULL'
+ ') %s ;'
+ ,table_name
+ ,'PARTITION BY HASH (h_commitment)'
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_table(
+ 'Reveal of proofs of the correct age restriction after the commitment when withdrawing coins with age restriction'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Foreign key reference to the corresponding commitment'
+ ,'h_commitment'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Index of the coin in the withdraw-age request, which is implicitly a batch request'
+ ,'freshcoin_index'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Foreign key reference to the denominations'
+ ,'denominations_serial'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Envelope of the new coin to be signed'
+ ,'coin_ev'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Hash of the envelope of the new coin to be signed (for lookups)'
+ ,'h_coin_ev'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Exchange signature over the envelope'
+ ,'ev_sig'
+ ,table_name
+ ,partition_suffix
+ );
+END
+$$;
+
+CREATE FUNCTION constrain_table_age_withdraw_revealed_coins(
+ IN partition_suffix VARCHAR
+)
+RETURNS void
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ table_name VARCHAR DEFAULT 'age_withdraw_revealed_coins';
+BEGIN
+ table_name = concat_ws('_', table_name, partition_suffix);
+
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_age_withdraw_revealed_coins_id_key'
+ ' UNIQUE (age_withdraw_revealed_coins_id);'
+ );
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_freshcoin_index_and_h_commitment_uniqueness'
+ ' UNIQUE (freshcoin_index, h_commitment);'
+ );
+END
+$$;
+
+CREATE FUNCTION foreign_table_age_withdraw_revealed_coins()
+RETURNS void
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ table_name VARCHAR DEFAULT 'age_withdraw_revealed_coins';
+BEGIN
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_foreign_h_commitment'
+ ' FOREIGN KEY (h_commitment)'
+ ' REFERENCES age_withdraw_commitments (h_commitment) ON DELETE CASCADE;'
+ );
+ EXECUTE FORMAT (
+ 'ALTER TABLE ' || table_name ||
+ ' ADD CONSTRAINT ' || table_name || '_foreign_denominations_serial'
+ ' FOREIGN KEY (denominations_serial) '
+ ' REFERENCES denominations (denominations_serial) ON DELETE CASCADE;'
+ );
+END
+$$;
+
+
+INSERT INTO exchange_tables
+ (name
+ ,version
+ ,action
+ ,partitioned
+ ,by_range)
+ VALUES
+ ('age_withdraw_revealed_coins'
+ ,'exchange-0003'
+ ,'create'
+ ,TRUE
+ ,FALSE),
+ ('age_withdraw_revealed_coins'
+ ,'exchange-0003'
+ ,'constrain'
+ ,TRUE
+ ,FALSE),
+ ('age_withdraw_revealed_coins'
+ ,'exchange-0003'
+ ,'foreign'
+ ,TRUE
+ ,FALSE);
diff --git a/src/exchangedb/0003-withdraw_age_commitments.sql b/src/exchangedb/0003-withdraw_age_commitments.sql
@@ -1,142 +0,0 @@
---
--- This file is part of TALER
--- Copyright (C) 2022 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
--- Foundation; either version 3, or (at your option) any later version.
---
--- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
--- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
--- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License along with
--- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
---
-
-CREATE FUNCTION create_table_withdraw_age_commitments(
- IN partition_suffix VARCHAR DEFAULT NULL
-)
-RETURNS VOID
-LANGUAGE plpgsql
-AS $$
-DECLARE
- table_name VARCHAR DEFAULT 'withdraw_age_commitments';
-BEGIN
- PERFORM create_partitioned_table(
- 'CREATE TABLE %I'
- '(withdraw_age_commitment_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
- ',h_commitment BYTEA PRIMARY KEY CHECK (LENGTH(h_commitment)=64)'
- ',amount_with_fee_val INT8 NOT NULL'
- ',amount_with_fee_frac INT4 NOT NULL'
- ',max_age INT2 NOT NULL'
- ',reserve_pub BYTEA NOT NULL CHECK (LENGTH(reserve_pub)=32)'
- ',reserve_sig BYTEA CHECK (LENGTH(reserve_sig)=64)'
- ',noreveal_index INT4 NOT NULL'
- ') %s ;'
- ,table_name
- ,'PARTITION BY HASH (reserve_pub)'
- ,partition_suffix
- );
- PERFORM comment_partitioned_table(
- 'Commitments made when withdrawing coins with age restriction and the gamma value chosen by the exchange.'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'The gamma value chosen by the exchange in the cut-and-choose protocol'
- ,'noreveal_index'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'The maximum age (in years) that the client commits to with this request'
- ,'max_age'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Commitment made by the client, hash over the various client inputs in the cut-and-choose protocol'
- ,'h_commitment'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Reference to the public key of the reserve from which the coins are going to be withdrawn'
- ,'reserve_pub'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Signature of the reserve''s private key over the withdraw-age request'
- ,'reserve_sig'
- ,table_name
- ,partition_suffix
- );
-END
-$$;
-
-
-CREATE FUNCTION constrain_table_withdraw_age_commitments(
- IN partition_suffix VARCHAR
-)
-RETURNS void
-LANGUAGE plpgsql
-AS $$
-DECLARE
- table_name VARCHAR DEFAULT 'withdraw_age_commitments';
-BEGIN
- table_name = concat_ws('_', table_name, partition_suffix);
-
- EXECUTE FORMAT (
- 'ALTER TABLE ' || table_name ||
- ' ADD PRIMARY KEY (h_commitment, reserve_pub);'
- );
- EXECUTE FORMAT (
- 'ALTER TABLE ' || table_name ||
- ' ADD CONSTRAINT ' || table_name || '_withdraw_age_commitment_id_key'
- ' UNIQUE (withdraw_age_commitment_id);'
- );
-END
-$$;
-
-
-CREATE FUNCTION foreign_table_withdraw_age_commitments()
-RETURNS void
-LANGUAGE plpgsql
-AS $$
-DECLARE
- table_name VARCHAR DEFAULT 'withdraw_age_commitments';
-BEGIN
- EXECUTE FORMAT (
- 'ALTER TABLE ' || table_name ||
- ' ADD CONSTRAINT ' || table_name || '_foreign_reserve_pub'
- ' FOREIGN KEY (reserve_pub)'
- ' REFERENCES reserves (reserve_pub) ON DELETE CASCADE;'
- );
-END
-$$;
-
-
-INSERT INTO exchange_tables
- (name
- ,version
- ,action
- ,partitioned
- ,by_range)
- VALUES
- ('withdraw_age_commitments'
- ,'exchange-0003'
- ,'create'
- ,TRUE
- ,FALSE),
- ('withdraw_age_commitments'
- ,'exchange-0003'
- ,'constrain'
- ,TRUE
- ,FALSE),
- ('withdraw_age_commitments'
- ,'exchange-0003'
- ,'foreign'
- ,TRUE
- ,FALSE);
diff --git a/src/exchangedb/0003-withdraw_age_reveals.sql b/src/exchangedb/0003-withdraw_age_reveals.sql
@@ -1,159 +0,0 @@
---
--- This file is part of TALER
--- Copyright (C) 2022 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
--- Foundation; either version 3, or (at your option) any later version.
---
--- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
--- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
--- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License along with
--- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
---
-
-CREATE FUNCTION create_table_withdraw_age_revealed_coins(
- IN partition_suffix VARCHAR DEFAULT NULL
-)
-RETURNS VOID
-LANGUAGE plpgsql
-AS $$
-DECLARE
- table_name VARCHAR DEFAULT 'withdraw_age_revealed_coins';
-BEGIN
- PERFORM create_partitioned_table(
- 'CREATE TABLE %I'
- '(withdraw_age_revealed_coins_id BIGINT GENERATED BY DEFAULT AS IDENTITY' -- UNIQUE
- ',h_commitment BYTEA NOT NULL CHECK (LENGTH(h_commitment)=64)'
- ',freshcoin_index INT4 NOT NULL'
- ',denominations_serial INT8 NOT NULL'
- ',coin_ev BYTEA NOT NULL'
- ',h_coin_ev BYTEA CHECK (LENGTH(h_coin_ev)=64)'
- ',ev_sig BYTEA NOT NULL'
- ',ewv BYTEA NOT NULL'
- ') %s ;'
- ,table_name
- ,'PARTITION BY HASH (h_commitment)'
- ,partition_suffix
- );
- PERFORM comment_partitioned_table(
- 'Reveal of proofs of the correct age restriction after the commitment when withdrawing coins with age restriction'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Foreign key reference to the corresponding commitment'
- ,'h_commitment'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Index of the coin in the withdraw-age request, which is implicitly a batch request'
- ,'freshcoin_index'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Foreign key reference to the denominations'
- ,'denominations_serial'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Envelope of the new coin to be signed'
- ,'coin_ev'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Hash of the envelope of the new coin to be signed (for lookups)'
- ,'h_coin_ev'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Exchange signature over the envelope'
- ,'ev_sig'
- ,table_name
- ,partition_suffix
- );
- PERFORM comment_partitioned_column(
- 'Exchange contributed values in the creation of the fresh coin (see /csr)'
- ,'ewv'
- ,table_name
- ,partition_suffix
- );
-END
-$$;
-
-CREATE FUNCTION constrain_table_withdraw_age_revealed_coins(
- IN partition_suffix VARCHAR
-)
-RETURNS void
-LANGUAGE plpgsql
-AS $$
-DECLARE
- table_name VARCHAR DEFAULT 'withdraw_age_revealed_coins';
-BEGIN
- table_name = concat_ws('_', table_name, partition_suffix);
-
- EXECUTE FORMAT (
- 'ALTER TABLE ' || table_name ||
- ' ADD CONSTRAINT ' || table_name || '_withdraw_age_revealed_coins_id_key'
- ' UNIQUE (withdraw_age_revealed_coins_id);'
- );
- EXECUTE FORMAT (
- 'ALTER TABLE ' || table_name ||
- ' ADD CONSTRAINT ' || table_name || '_freshcoin_index_and_h_commitment_uniqueness'
- ' UNIQUE (freshcoin_index, h_commitment);'
- );
-END
-$$;
-
-CREATE FUNCTION foreign_table_withdraw_age_revealed_coins()
-RETURNS void
-LANGUAGE plpgsql
-AS $$
-DECLARE
- table_name VARCHAR DEFAULT 'withdraw_age_revealed_coins';
-BEGIN
- EXECUTE FORMAT (
- 'ALTER TABLE ' || table_name ||
- ' ADD CONSTRAINT ' || table_name || '_foreign_h_commitment'
- ' FOREIGN KEY (h_commitment)'
- ' REFERENCES withdraw_age_commitments (h_commitment) ON DELETE CASCADE;'
- );
- EXECUTE FORMAT (
- 'ALTER TABLE ' || table_name ||
- ' ADD CONSTRAINT ' || table_name || '_foreign_denominations_serial'
- ' FOREIGN KEY (denominations_serial) '
- ' REFERENCES denominations (denominations_serial) ON DELETE CASCADE;'
- );
-END
-$$;
-
-
-INSERT INTO exchange_tables
- (name
- ,version
- ,action
- ,partitioned
- ,by_range)
- VALUES
- ('withdraw_age_revealed_coins'
- ,'exchange-0003'
- ,'create'
- ,TRUE
- ,FALSE),
- ('withdraw_age_revealed_coins'
- ,'exchange-0003'
- ,'constrain'
- ,TRUE
- ,FALSE),
- ('withdraw_age_revealed_coins'
- ,'exchange-0003'
- ,'foreign'
- ,TRUE
- ,FALSE);
diff --git a/src/exchangedb/exchange-0003.sql.in b/src/exchangedb/exchange-0003.sql.in
@@ -25,6 +25,8 @@ SET search_path TO exchange;
#include "0003-aml_status.sql"
#include "0003-aml_staff.sql"
#include "0003-aml_history.sql"
+#include "0003-age_withdraw_commitments.sql"
+#include "0003-age_withdraw_reveals.sql"
COMMIT;
diff --git a/src/exchangedb/pg_get_age_withdraw_info.c b/src/exchangedb/pg_get_age_withdraw_info.c
@@ -69,7 +69,7 @@ TEH_PG_get_age_withdraw_info (
",amount_with_fee_val"
",amount_with_fee_frac"
",noreveal_index"
- " FROM withdraw_age_commitments"
+ " FROM age_withdraw_commitments"
" WHERE reserve_pub=$1 and h_commitment=$2;");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"get_age_withdraw_info",
diff --git a/src/exchangedb/pg_insert_age_withdraw_reveal.c b/src/exchangedb/pg_insert_age_withdraw_reveal.c
@@ -42,8 +42,8 @@ TEH_PG_insert_age_withdraw_reveal (
/* TODO */
#if 0
PREPARE (pg,
- "insert_withdraw_age_revealed_coin",
- "INSERT INTO withdraw_age_reveals "
+ "insert_age_withdraw_revealed_coin",
+ "INSERT INTO age_withdraw_reveals "
"(h_commitment "
",freshcoin_index "
",denominations_serial "
diff --git a/src/exchangedb/pg_insert_records_by_table.c b/src/exchangedb/pg_insert_records_by_table.c
@@ -2062,39 +2062,39 @@ irbt_cb_table_purse_deletion (struct PostgresClosure *pg,
/**
- * Function called with withdraw_age_commitments records to insert into table.
+ * Function called with age_withdraw_commitments records to insert into table.
*
* @param pg plugin context
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
-irbt_cb_table_withdraw_age_commitments (struct PostgresClosure *pg,
+irbt_cb_table_age_withdraw_commitments (struct PostgresClosure *pg,
const struct
TALER_EXCHANGEDB_TableData *td)
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (
- &td->details.withdraw_age_commitments.h_commitment),
+ &td->details.age_withdraw_commitments.h_commitment),
TALER_PQ_query_param_amount (
- &td->details.withdraw_age_commitments.amount_with_fee),
+ &td->details.age_withdraw_commitments.amount_with_fee),
GNUNET_PQ_query_param_uint16 (
- &td->details.withdraw_age_commitments.max_age),
+ &td->details.age_withdraw_commitments.max_age),
GNUNET_PQ_query_param_auto_from_type (
- &td->details.withdraw_age_commitments.reserve_pub),
+ &td->details.age_withdraw_commitments.reserve_pub),
GNUNET_PQ_query_param_auto_from_type (
- &td->details.withdraw_age_commitments.reserve_sig),
+ &td->details.age_withdraw_commitments.reserve_sig),
GNUNET_PQ_query_param_uint32 (
- &td->details.withdraw_age_commitments.noreveal_index),
+ &td->details.age_withdraw_commitments.noreveal_index),
GNUNET_PQ_query_param_absolute_time (
- &td->details.withdraw_age_commitments.timestamp),
+ &td->details.age_withdraw_commitments.timestamp),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
- "insert_into_table_withdraw_age_commitments",
- "INSERT INTO withdraw_age_commitments"
- "(withdraw_age_commitment_id"
+ "insert_into_table_age_withdraw_commitments",
+ "INSERT INTO age_withdraw_commitments"
+ "(age_withdraw_commitment_id"
",h_commitment"
",amount_with_fee_val"
",amount_with_fee_frac"
@@ -2106,19 +2106,19 @@ irbt_cb_table_withdraw_age_commitments (struct PostgresClosure *pg,
") VALUES "
"($1, $2, $3, $4, $5, $6, $7, $8, $9);");
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "insert_into_table_withdraw_age_commitments",
+ "insert_into_table_age_withdraw_commitments",
params);
}
/**
- * Function called with withdraw_age_revealed_coins records to insert into table.
+ * Function called with age_withdraw_revealed_coins records to insert into table.
*
* @param pg plugin context
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
-irbt_cb_table_withdraw_age_revealed_coins (struct PostgresClosure *pg,
+irbt_cb_table_age_withdraw_revealed_coins (struct PostgresClosure *pg,
const struct
TALER_EXCHANGEDB_TableData *td)
{
@@ -2126,26 +2126,26 @@ irbt_cb_table_withdraw_age_revealed_coins (struct PostgresClosure *pg,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (
- &td->details.withdraw_age_revealed_coins.h_commitment),
+ &td->details.age_withdraw_revealed_coins.h_commitment),
GNUNET_PQ_query_param_uint32 (
- &td->details.withdraw_age_revealed_coins.freshcoin_index),
+ &td->details.age_withdraw_revealed_coins.freshcoin_index),
GNUNET_PQ_query_param_uint64 (
- &td->details.withdraw_age_revealed_coins.denominations_serial),
+ &td->details.age_withdraw_revealed_coins.denominations_serial),
GNUNET_PQ_query_param_fixed_size (
- td->details.withdraw_age_revealed_coins.coin_ev,
- td->details.withdraw_age_revealed_coins.coin_ev_size),
+ td->details.age_withdraw_revealed_coins.coin_ev,
+ td->details.age_withdraw_revealed_coins.coin_ev_size),
GNUNET_PQ_query_param_auto_from_type (&h_coin_ev),
TALER_PQ_query_param_blinded_denom_sig (
- &td->details.withdraw_age_revealed_coins.ev_sig),
+ &td->details.age_withdraw_revealed_coins.ev_sig),
TALER_PQ_query_param_exchange_withdraw_values (
- &td->details.withdraw_age_revealed_coins.ewv),
+ &td->details.age_withdraw_revealed_coins.ewv),
GNUNET_PQ_query_param_end
};
PREPARE (pg,
- "insert_into_table_withdraw_age_revealed_coins",
- "INSERT INTO withdraw_age_revealed_coins"
- "(withdraw_age_revealed_coins_id"
+ "insert_into_table_age_withdraw_revealed_coins",
+ "INSERT INTO age_withdraw_revealed_coins"
+ "(age_withdraw_revealed_coins_id"
",h_commitment"
",freshcoin_index"
",denominations_serial"
@@ -2156,12 +2156,12 @@ irbt_cb_table_withdraw_age_revealed_coins (struct PostgresClosure *pg,
") VALUES "
"($1, $2, $3, $4, $5, $6, $7, $8);");
- GNUNET_CRYPTO_hash (td->details.withdraw_age_revealed_coins.coin_ev,
- td->details.withdraw_age_revealed_coins.coin_ev_size,
+ GNUNET_CRYPTO_hash (td->details.age_withdraw_revealed_coins.coin_ev,
+ td->details.age_withdraw_revealed_coins.coin_ev_size,
&h_coin_ev);
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "insert_into_table_withdraw_age_revealed_coins",
+ "insert_into_table_age_withdraw_revealed_coins",
params);
}
@@ -2314,10 +2314,10 @@ TEH_PG_insert_records_by_table (void *cls,
rh = &irbt_cb_table_purse_deletion;
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS:
- rh = &irbt_cb_table_withdraw_age_commitments;
+ rh = &irbt_cb_table_age_withdraw_commitments;
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS:
- rh = &irbt_cb_table_withdraw_age_revealed_coins;
+ rh = &irbt_cb_table_age_withdraw_revealed_coins;
break;
}
if (NULL == rh)
diff --git a/src/exchangedb/pg_lookup_records_by_table.c b/src/exchangedb/pg_lookup_records_by_table.c
@@ -2767,14 +2767,14 @@ lrbt_cb_table_purse_deletion (void *cls,
/**
- * Function called with withdraw_age_commitments table entries.
+ * Function called with age_withdraw_commitments table entries.
*
* @param cls closure
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
-lrbt_cb_table_withdraw_age_commitments (void *cls,
+lrbt_cb_table_age_withdraw_commitments (void *cls,
PGresult *result,
unsigned int num_results)
{
@@ -2788,26 +2788,26 @@ lrbt_cb_table_withdraw_age_commitments (void *cls,
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 (
- "withdraw_age_commitment_id",
+ "age_withdraw_commitment_id",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type (
"h_commitment",
- &td.details.withdraw_age_commitments.h_commitment),
+ &td.details.age_withdraw_commitments.h_commitment),
GNUNET_PQ_result_spec_uint16 (
"max_age",
- &td.details.withdraw_age_commitments.max_age),
+ &td.details.age_withdraw_commitments.max_age),
TALER_PQ_RESULT_SPEC_AMOUNT (
"amount_with_fee",
- &td.details.withdraw_age_commitments.amount_with_fee),
+ &td.details.age_withdraw_commitments.amount_with_fee),
GNUNET_PQ_result_spec_auto_from_type (
"reserve_pub",
- &td.details.withdraw_age_commitments.reserve_pub),
+ &td.details.age_withdraw_commitments.reserve_pub),
GNUNET_PQ_result_spec_auto_from_type (
"reserve_sig",
- &td.details.withdraw_age_commitments.reserve_sig),
+ &td.details.age_withdraw_commitments.reserve_sig),
GNUNET_PQ_result_spec_uint32 (
"noreveal_index",
- &td.details.withdraw_age_commitments.noreveal_index),
+ &td.details.age_withdraw_commitments.noreveal_index),
GNUNET_PQ_result_spec_end
};
@@ -2828,14 +2828,14 @@ lrbt_cb_table_withdraw_age_commitments (void *cls,
/**
- * Function called with withdraw_age_revealed_coins table entries.
+ * Function called with age_withdraw_revealed_coins table entries.
*
* @param cls closure
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
-lrbt_cb_table_withdraw_age_revealed_coins (void *cls,
+lrbt_cb_table_age_withdraw_revealed_coins (void *cls,
PGresult *result,
unsigned int num_results)
{
@@ -2848,22 +2848,22 @@ lrbt_cb_table_withdraw_age_revealed_coins (void *cls,
{
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 (
- "withdraw_age_revealed_coins_id",
+ "age_withdraw_revealed_coins_id",
&td.serial),
GNUNET_PQ_result_spec_auto_from_type (
"h_commitment",
- &td.details.withdraw_age_revealed_coins.h_commitment),
+ &td.details.age_withdraw_revealed_coins.h_commitment),
GNUNET_PQ_result_spec_uint32 (
"freshcoin_index",
- &td.details.withdraw_age_revealed_coins.freshcoin_index),
+ &td.details.age_withdraw_revealed_coins.freshcoin_index),
GNUNET_PQ_result_spec_uint64 (
"denominations_serial",
- &td.details.withdraw_age_revealed_coins.denominations_serial),
+ &td.details.age_withdraw_revealed_coins.denominations_serial),
/* Note: h_coin_ev is recalculated */
GNUNET_PQ_result_spec_variable_size (
"coin_ev",
- (void **) &td.details.withdraw_age_revealed_coins.coin_ev,
- &td.details.withdraw_age_revealed_coins.coin_ev_size),
+ (void **) &td.details.age_withdraw_revealed_coins.coin_ev,
+ &td.details.age_withdraw_revealed_coins.coin_ev_size),
TALER_PQ_result_spec_blinded_denom_sig (
"ev_sig",
&td.details.refresh_revealed_coins.ev_sig),
@@ -3598,9 +3598,9 @@ TEH_PG_lookup_records_by_table (void *cls,
rh = &lrbt_cb_table_purse_deletion;
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS:
- XPREPARE ("select_above_serial_by_table_withdraw_age_commitments",
+ XPREPARE ("select_above_serial_by_table_age_withdraw_commitments",
"SELECT"
- " withdraw_age_commitment_id"
+ " age_withdraw_commitment_id"
",h_commitment"
",amount_with_fee_val"
",amount_with_fee_frac"
@@ -3608,15 +3608,15 @@ TEH_PG_lookup_records_by_table (void *cls,
",reserve_pub"
",reserve_sig"
",noreveal_index"
- " FROM withdraw_age_commitments"
- " WHERE withdraw_age_commitment_id > $1"
- " ORDER BY withdraw_age_commitment_id ASC;");
- rh = &lrbt_cb_table_withdraw_age_commitments;
+ " FROM age_withdraw_commitments"
+ " WHERE age_withdraw_commitment_id > $1"
+ " ORDER BY age_withdraw_commitment_id ASC;");
+ rh = &lrbt_cb_table_age_withdraw_commitments;
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS:
- XPREPARE ("select_above_serial_by_table_withdraw_age_revealed_coins",
+ XPREPARE ("select_above_serial_by_table_age_withdraw_revealed_coins",
"SELECT"
- " withdraw_age_revealed_coins_serial_id"
+ " age_withdraw_revealed_coins_serial_id"
",h_commitment"
",freshcoin_index"
",denominations_serial"
@@ -3624,10 +3624,10 @@ TEH_PG_lookup_records_by_table (void *cls,
",h_coin_ev"
",ev_sig"
",ewv"
- " FROM withdraw_age_revealed_coins"
- " WHERE withdraw_age_revealed_coins_serial_id > $1"
- " ORDER BY withdraw_age_revealed_coins_serial_id ASC;");
- rh = &lrbt_cb_table_withdraw_age_revealed_coins;
+ " FROM age_withdraw_revealed_coins"
+ " WHERE age_withdraw_revealed_coins_serial_id > $1"
+ " ORDER BY age_withdraw_revealed_coins_serial_id ASC;");
+ rh = &lrbt_cb_table_age_withdraw_revealed_coins;
break;
}
if (NULL == rh)
diff --git a/src/exchangedb/pg_lookup_serial_by_table.c b/src/exchangedb/pg_lookup_serial_by_table.c
@@ -427,22 +427,22 @@ TEH_PG_lookup_serial_by_table (void *cls,
statement = "select_serial_by_table_purse_deletion";
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS:
- XPREPARE ("select_serial_by_table_withdraw_age_commitments",
+ XPREPARE ("select_serial_by_table_age_withdraw_commitments",
"SELECT"
- " withdraw_age_commitment_id AS serial"
- " FROM withdraw_age_commitments"
- " ORDER BY withdraw_age_commitment_id DESC"
+ " age_withdraw_commitment_id AS serial"
+ " FROM age_withdraw_commitments"
+ " ORDER BY age_withdraw_commitment_id DESC"
" LIMIT 1;");
- statement = "select_serial_by_table_withdraw_age_commitments";
+ statement = "select_serial_by_table_age_withdraw_commitments";
break;
case TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS:
- XPREPARE ("select_serial_by_table_withdraw_age_revealed_coins",
+ XPREPARE ("select_serial_by_table_age_withdraw_revealed_coins",
"SELECT"
- " withdraw_age_revealed_coins_id AS serial"
- " FROM withdraw_age_revealed_coins"
- " ORDER BY withdraw_age_revealed_coins_id DESC"
+ " age_withdraw_revealed_coins_id AS serial"
+ " FROM age_withdraw_revealed_coins"
+ " ORDER BY age_withdraw_revealed_coins_id DESC"
" LIMIT 1;");
- statement = "select_serial_by_table_withdraw_age_revealed_coins";
+ statement = "select_serial_by_table_age_withdraw_revealed_coins";
break;
}
if (NULL == statement)
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
@@ -760,7 +760,7 @@ struct TALER_EXCHANGEDB_TableData
struct TALER_ReserveSignatureP reserve_sig;
uint32_t noreveal_index;
struct GNUNET_TIME_Absolute timestamp;
- } withdraw_age_commitments;
+ } age_withdraw_commitments;
struct
{
@@ -772,7 +772,7 @@ struct TALER_EXCHANGEDB_TableData
struct TALER_ExchangeWithdrawValues ewv;
// h_coin_ev omitted, to be recomputed!
struct TALER_BlindedDenominationSignature ev_sig;
- } withdraw_age_revealed_coins;
+ } age_withdraw_revealed_coins;
} details;
@@ -1200,8 +1200,9 @@ struct TALER_EXCHANGEDB_AgeWithdrawCommitment
struct TALER_ReservePublicKeyP reserve_pub;
/**
- * Signature confirming the age withdrawal, matching @e reserve_pub, @e
- * maximum_age_group and @e h_commitment and @e total_amount_with_fee.
+ * Signature confirming the age withdrawal commitment, matching @e
+ * reserve_pub, @e maximum_age_group and @e h_commitment and @e
+ * total_amount_with_fee.
*/
struct TALER_ReserveSignatureP reserve_sig;
@@ -2737,6 +2738,28 @@ struct TALER_EXCHANGEDB_CsRevealFreshCoinData
uint32_t coin_off;
};
+/**
+ * Information about a coin that was revealed to the exchange
+ * during reveal.
+ */
+struct TALER_EXCHANGEDB_AgeWithdrawRevealedCoin
+{
+ /**
+ * Hash of the public denomination key of the coin.
+ */
+ struct TALER_DenominationHashP h_denom_pub;
+
+ /**
+ * Signature generated by the exchange over the coin (in blinded format).
+ */
+ struct TALER_BlindedDenominationSignature coin_sig;
+
+ /**
+ * Blinded hash of the new coin
+ */
+ struct TALER_BlindedCoinHashP h_coin_ev;
+};
+
/**
* Generic KYC status for some operation.
@@ -3810,19 +3833,18 @@ struct TALER_EXCHANGEDB_Plugin
* age restriction enabled in a given age-withdraw operation and the relevant
* information we learned or created in the reveal steop
*
- * @param cls the `struct PostgresClosure` with the plugin-specific state
- * @param h_commitment The hash of the original age-withdraw commitment, which is a key into the withdraw_age_commitments table
- * @param num_coins number of coins to generate, size of the @a coin_evs array
- * TODO: oec
+ * @param cls The `struct PostgresClosure` with the plugin-specific state
+ * @param h_commitment The hash of the original age-withdraw commitment, which is a key into the age_withdraw_commitments table
+ * @param num_awrcs Number of coins to generate, size of the @a coin_evs array
+ * @param awrcs Array of @a num_awrcs information about coins to be created
* @return query execution status
*/
enum GNUNET_DB_QueryStatus
(*insert_age_withdraw_reveal)(
void *cls,
- uint64_t h_commitment,
- uint32_t num_coins
- /* TODO: oec */
- );
+ const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
+ uint32_t num_awrcs,
+ const struct TALER_EXCHANGEDB_AgeWithdrawRevealedCoin *awrcs);
/**
* Lookup in the database for the fresh coins with age-restriction that