commit 1c550f2a985fb1e9c52c2606fe87f2857433e203
parent 11f9a80ba8b8abc12205ee5a72f7e9e27f244f93
Author: Özgür Kesim <oec@codeblau.de>
Date: Sun, 8 Nov 2026 13:15:21 +0100
[exchange] v46: MELT history has noreveal_index, transfer_pubs, ev_sigs (#11916)
ev_sigs only after the reveal.
Diffstat:
6 files changed, 130 insertions(+), 7 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_get-coins-COIN_PUB-history.c b/src/exchange/taler-exchange-httpd_get-coins-COIN_PUB-history.c
@@ -171,6 +171,8 @@ compile_transaction_history (
pos->details.melt;
const struct TALER_AgeCommitmentHashP *phac;
const struct TALER_BlindingMasterSeedP *pbs;
+ json_t *transfer_pubs = NULL;
+ json_t *ev_sigs = NULL;
#if ENABLE_SANITY_CHECKS
TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++;
@@ -195,6 +197,31 @@ compile_transaction_history (
pbs = melt->no_blinding_seed
? NULL
: &melt->blinding_seed;
+ if (NULL != melt->transfer_pubs)
+ {
+ transfer_pubs = json_array ();
+ GNUNET_assert (NULL != transfer_pubs);
+ for (size_t i = 0; i < melt->num_coins; i++)
+ GNUNET_assert (0 ==
+ json_array_append_new (
+ transfer_pubs,
+ GNUNET_JSON_from_data_auto (
+ &melt->transfer_pubs[i])));
+ }
+ /* only set after a successful reveal, see get_coin_transactions() */
+ if (NULL != melt->ev_sigs)
+ {
+ ev_sigs = json_array ();
+ GNUNET_assert (NULL != ev_sigs);
+ for (size_t i = 0; i < melt->num_coins; i++)
+ GNUNET_assert (0 ==
+ json_array_append_new (
+ ev_sigs,
+ GNUNET_JSON_PACK (
+ TALER_JSON_pack_blinded_denom_sig (
+ NULL,
+ &melt->ev_sigs[i]))));
+ }
if (0 !=
json_array_append_new (
history,
@@ -218,6 +245,14 @@ compile_transaction_history (
melt->num_coins,
melt->denom_pub_hashes,
sizeof(melt->denom_pub_hashes[0])),
+ GNUNET_JSON_pack_uint64 ("noreveal_index",
+ melt->noreveal_index),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_array_steal ("transfer_pubs",
+ transfer_pubs)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_array_steal ("ev_sigs",
+ ev_sigs)),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_data_auto ("blinding_seed",
pbs)),
diff --git a/src/exchange/taler-exchange-httpd_get-config.h b/src/exchange/taler-exchange-httpd_get-config.h
@@ -41,7 +41,7 @@
*
* Returned via both /config and /keys endpoints.
*/
-#define EXCHANGE_PROTOCOL_VERSION "45:0:11"
+#define EXCHANGE_PROTOCOL_VERSION "46:0:12"
/**
diff --git a/src/exchangedb/free_coin_transaction_list.c b/src/exchangedb/free_coin_transaction_list.c
@@ -40,9 +40,20 @@ TALER_EXCHANGEDB_free_coin_transaction_list (
break;
}
case TALER_EXCHANGEDB_TT_MELT:
- GNUNET_free (tl->details.melt->denom_pub_hashes);
- GNUNET_free (tl->details.melt);
- break;
+ {
+ struct TALER_EXCHANGEDB_MeltListEntry *melt = tl->details.melt;
+
+ if (NULL != melt->ev_sigs)
+ {
+ for (size_t i = 0; i < melt->num_coins; i++)
+ TALER_blinded_denom_sig_free (&melt->ev_sigs[i]);
+ GNUNET_free (melt->ev_sigs);
+ }
+ GNUNET_free (melt->transfer_pubs);
+ GNUNET_free (melt->denom_pub_hashes);
+ GNUNET_free (melt);
+ break;
+ }
case TALER_EXCHANGEDB_TT_RECOUP_REFRESH_RECEIVER:
{
struct TALER_EXCHANGEDB_RecoupRefreshListEntry *rr;
diff --git a/src/exchangedb/get_coin_transactions.c b/src/exchangedb/get_coin_transactions.c
@@ -259,6 +259,12 @@ add_coin_melt (void *cls,
melt = GNUNET_new (struct TALER_EXCHANGEDB_MeltListEntry);
{
struct TALER_DenominationHashP *denom_pub_hashes = NULL;
+ struct TALER_TransferPublicKeyP *transfer_pubs = NULL;
+ struct TALER_BlindedDenominationSignature *ev_sigs = NULL;
+ size_t num_transfer_pubs = 0;
+ size_t num_ev_sigs = 0;
+ bool no_transfer_pubs;
+ bool no_ev_sigs;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("rc",
&melt->rc),
@@ -287,6 +293,21 @@ add_coin_melt (void *cls,
&melt->no_age_commitment),
GNUNET_PQ_result_spec_uint64 ("refresh_id",
&serial_id),
+ GNUNET_PQ_result_spec_uint32 ("noreveal_index",
+ &melt->noreveal_index),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_array_fixed_size (pg->conn,
+ "transfer_pubs",
+ sizeof (*transfer_pubs),
+ &num_transfer_pubs,
+ (void **) &transfer_pubs),
+ &no_transfer_pubs),
+ GNUNET_PQ_result_spec_allow_null (
+ TALER_PQ_result_spec_array_blinded_denom_sig (pg->conn,
+ "ev_sigs",
+ &num_ev_sigs,
+ &ev_sigs),
+ &no_ev_sigs),
GNUNET_PQ_result_spec_end
};
@@ -301,8 +322,29 @@ add_coin_melt (void *cls,
chc->failed = true;
return;
}
+ if ( ( (! no_transfer_pubs) &&
+ (num_transfer_pubs != melt->num_coins) ) ||
+ ( (! no_ev_sigs) &&
+ (num_ev_sigs != melt->num_coins) ) )
+ {
+ GNUNET_break (0);
+ GNUNET_PQ_cleanup_result (rs);
+ GNUNET_free (melt);
+ chc->failed = true;
+ return;
+ }
melt->denom_pub_hashes = denom_pub_hashes;
denom_pub_hashes = NULL;
+ if (! no_transfer_pubs)
+ {
+ melt->transfer_pubs = transfer_pubs;
+ transfer_pubs = NULL;
+ }
+ if (! no_ev_sigs)
+ {
+ melt->ev_sigs = ev_sigs;
+ ev_sigs = NULL;
+ }
GNUNET_PQ_cleanup_result (rs);
}
tl = GNUNET_new (struct TALER_EXCHANGEDB_TransactionList);
@@ -951,6 +993,9 @@ TALER_EXCHANGEDB_get_coin_transactions (
",denoms.fee_refresh"
",kc.age_commitment_hash"
",refresh_id"
+ ",noreveal_index"
+ ",transfer_pubs"
+ ",CASE WHEN revealed THEN denom_sigs END AS ev_sigs"
",ARRAY("
" SELECT fresh_denoms.denom_pub_hash"
" FROM unnest(refresh.denom_serials) WITH ORDINALITY"
diff --git a/src/exchangedb/test_coin_history.c b/src/exchangedb/test_coin_history.c
@@ -40,6 +40,11 @@
#include "exchange-database/insert_reserve_open_deposit.h"
#include "exchange-database/update_to_refresh_revealed.h"
+/**
+ * Number of fresh coins of the melt in check_other_spends().
+ */
+#define NUM_FRESH_COINS 3
+
/**
* Account the checks fund their reserves from.
@@ -475,6 +480,7 @@ check_other_spends (struct TALER_EXCHANGEDB_PostgresContext *pg)
bool nonce_reuse;
bool melt_balance_ok;
uint32_t noreveal_index;
+ struct TALER_TransferPublicKeyP transfer_pubs[NUM_FRESH_COINS];
enum GNUNET_DB_QueryStatus qs;
memset (&rf,
@@ -499,7 +505,7 @@ check_other_spends (struct TALER_EXCHANGEDB_PostgresContext *pg)
"0.1",
"0.01",
&fresh_denom);
- rf.num_coins = 3;
+ rf.num_coins = NUM_FRESH_COINS;
rf.denom_serials = GNUNET_new_array (rf.num_coins,
uint64_t);
/* Deliberately neither sorted nor distinct. */
@@ -512,8 +518,12 @@ check_other_spends (struct TALER_EXCHANGEDB_PostgresContext *pg)
for (unsigned int i = 0; i < rf.num_coins; i++)
TDB_blinded_denom_sig (43 + i,
&rf.denom_sigs[i]);
+ for (unsigned int i = 0; i < rf.num_coins; i++)
+ TDB_FILL (transfer_pubs[i],
+ 50 + i);
+ rf.transfer_pubs = transfer_pubs;
rf.noreveal_index = 1;
- rf.rc_version = TALER_REFRESH_COMMITMENT_VERSION_LEGACY_V27;
+ rf.rc_version = TALER_REFRESH_COMMITMENT_VERSION_CURRENT;
rf.no_blinding_seed = true;
qs = TALER_EXCHANGEDB_do_refresh (pg,
&rf,
@@ -556,7 +566,7 @@ check_other_spends (struct TALER_EXCHANGEDB_PostgresContext *pg)
continue;
found_melt = true;
melt = pos->details.melt;
- FAILIF_C (3 != melt->num_coins,
+ FAILIF_C (NUM_FRESH_COINS != melt->num_coins,
TALER_EXCHANGEDB_free_coin_transaction_list (tl));
FAILIF_C (0 != GNUNET_memcmp (&melt->denom_pub_hashes[0],
&fresh_denom.h_denom_pub),
@@ -567,6 +577,16 @@ check_other_spends (struct TALER_EXCHANGEDB_PostgresContext *pg)
FAILIF_C (0 != GNUNET_memcmp (&melt->denom_pub_hashes[2],
&fresh_denom.h_denom_pub),
TALER_EXCHANGEDB_free_coin_transaction_list (tl));
+ FAILIF_C (noreveal_index != melt->noreveal_index,
+ TALER_EXCHANGEDB_free_coin_transaction_list (tl));
+ FAILIF_C ( (NULL == melt->transfer_pubs) ||
+ (0 != memcmp (melt->transfer_pubs,
+ transfer_pubs,
+ sizeof (transfer_pubs))),
+ TALER_EXCHANGEDB_free_coin_transaction_list (tl));
+ /* the signatures over the fresh coins only after the reveal */
+ FAILIF_C ((NULL != melt->ev_sigs) != (0 != revealed),
+ TALER_EXCHANGEDB_free_coin_transaction_list (tl));
}
TALER_EXCHANGEDB_free_coin_transaction_list (tl);
tl = NULL;
diff --git a/src/include/exchange-database/free_coin_transaction_list.h b/src/include/exchange-database/free_coin_transaction_list.h
@@ -326,6 +326,18 @@ struct TALER_EXCHANGEDB_MeltListEntry
*/
struct TALER_BlindingMasterSeedP blinding_seed;
+ /**
+ * The @e num_coins transfer public keys of the batch at
+ * @e noreveal_index, NULL if the melt request had none.
+ */
+ struct TALER_TransferPublicKeyP *transfer_pubs;
+
+ /**
+ * The @e num_coins blinded signatures over the fresh coins of the batch
+ * at @e noreveal_index, NULL if the reveal was not (yet) performed.
+ */
+ struct TALER_BlindedDenominationSignature *ev_sigs;
+
};