exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 192e361811c93327c80af69b0f5280b30ceae682
parent 47397c55f764ccd5a00a2626199d2a6772fb7db9
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 27 Oct 2023 23:54:55 +0200

fixes with respect to new blinding API

Diffstat:
Msrc/exchangedb/pg_get_known_coin.c | 4----
Msrc/include/taler_crypto_lib.h | 37+++++++++++++++++++------------------
Msrc/include/taler_exchange_service.h | 1+
Msrc/lib/exchange_api_batch_withdraw.c | 20+++++++++++++++-----
Msrc/lib/exchange_api_refresh_common.c | 5+++--
Msrc/pq/pq_result_helper.c | 2+-
6 files changed, 39 insertions(+), 30 deletions(-)

diff --git a/src/exchangedb/pg_get_known_coin.c b/src/exchangedb/pg_get_known_coin.c @@ -51,9 +51,6 @@ TEH_PG_get_known_coin (void *cls, "Getting known coin data for coin %s\n", TALER_B2S (coin_pub)); coin_info->coin_pub = *coin_pub; - /* Used in #postgres_get_known_coin() to fetch - the denomination public key and signature for - a coin known to the exchange. */ PREPARE (pg, "get_known_coin", "SELECT" @@ -63,7 +60,6 @@ TEH_PG_get_known_coin (void *cls, " FROM known_coins" " JOIN denominations USING (denominations_serial)" " WHERE coin_pub=$1;"); - return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "get_known_coin", params, diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h @@ -1133,16 +1133,6 @@ TALER_rsa_pub_hash (const struct GNUNET_CRYPTO_RsaPublicKey *rsa, /** - * Return the alg value singleton for creation of - * blinding secrets for RSA. - * - * @return singleton to use for RSA blinding - */ -const struct TALER_ExchangeWithdrawValues * -TALER_denom_ewv_rsa_singleton (void); - - -/** * Hash @a cs. * * @param cs key to hash @@ -1352,6 +1342,16 @@ struct TALER_ExchangeWithdrawValues /** + * Return the alg value singleton for creation of + * blinding secrets for RSA. + * + * @return singleton to use for RSA blinding + */ +const struct TALER_ExchangeWithdrawValues * +TALER_denom_ewv_rsa_singleton (void); + + +/** * Create private key for a Taler coin. * @param ps planchet secret to derive coin priv key * @param alg_values includes algorithm specific values @@ -1946,14 +1946,15 @@ TALER_planchet_blinding_secret_create ( * @return #GNUNET_OK on success */ enum GNUNET_GenericReturnValue -TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, - const struct TALER_ExchangeWithdrawValues *alg_values, - const union GNUNET_CRYPTO_BlindingSecretP *bks, - const union GNUNET_CRYPTO_BlindSessionNonce *nonce, - const struct TALER_CoinSpendPrivateKeyP *coin_priv, - const struct TALER_AgeCommitmentHash *ach, - struct TALER_CoinPubHashP *c_hash, - struct TALER_PlanchetDetail *pd); +TALER_planchet_prepare ( + const struct TALER_DenominationPublicKey *dk, + const struct TALER_ExchangeWithdrawValues *alg_values, + const union GNUNET_CRYPTO_BlindingSecretP *bks, + const union GNUNET_CRYPTO_BlindSessionNonce *nonce, + const struct TALER_CoinSpendPrivateKeyP *coin_priv, + const struct TALER_AgeCommitmentHash *ach, + struct TALER_CoinPubHashP *c_hash, + struct TALER_PlanchetDetail *pd); /** diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h @@ -1513,6 +1513,7 @@ struct TALER_EXCHANGE_CsRWithdrawResponse * respective coin's withdraw operation. */ struct TALER_ExchangeWithdrawValues alg_values; + } ok; /** diff --git a/src/lib/exchange_api_batch_withdraw.c b/src/lib/exchange_api_batch_withdraw.c @@ -116,7 +116,6 @@ struct TALER_EXCHANGE_BatchWithdrawHandle */ const struct TALER_EXCHANGE_Keys *keys; - /** * Handle for the actual (internal) batch withdraw operation. */ @@ -305,7 +304,9 @@ withdraw_cs_stage_two_callback ( switch (csrr->hr.http_status) { case MHD_HTTP_OK: - cd->alg_values = csrr->details.ok.alg_values; + cd->alg_values.blinding_inputs + = GNUNET_CRYPTO_blinding_input_values_incref ( + csrr->details.ok.alg_values.blinding_inputs); TALER_planchet_setup_coin_priv (&cd->ps, &cd->alg_values, &cd->priv); @@ -376,15 +377,18 @@ TALER_EXCHANGE_batch_withdraw ( { case GNUNET_CRYPTO_BSA_RSA: { + const struct TALER_ExchangeWithdrawValues *alg_values + = TALER_denom_ewv_rsa_singleton (); + TALER_planchet_setup_coin_priv (&cd->ps, - &cd->alg_values, + alg_values, &cd->priv); TALER_planchet_blinding_secret_create (&cd->ps, - &cd->alg_values, + alg_values, &cd->bks); if (GNUNET_OK != TALER_planchet_prepare (&cd->pk.key, - NULL, + alg_values, &cd->bks, NULL, &cd->priv, @@ -444,6 +448,12 @@ TALER_EXCHANGE_batch_withdraw_cancel ( TALER_EXCHANGE_csr_withdraw_cancel (cd->csrh); cd->csrh = NULL; } + if (NULL != cd->alg_values.blinding_inputs) + { + GNUNET_CRYPTO_blinding_input_values_decref ( + cd->alg_values.blinding_inputs); + cd->alg_values.blinding_inputs = NULL; + } TALER_blinded_planchet_free (&cd->pd.blinded_planchet); TALER_denom_pub_free (&cd->pk.key); } diff --git a/src/lib/exchange_api_refresh_common.c b/src/lib/exchange_api_refresh_common.c @@ -99,6 +99,9 @@ TALER_EXCHANGE_get_melt_data_ ( { struct FreshCoinData *fcd = &md->fcds[j]; + TALER_denom_pub_deep_copy (&fcd->fresh_pk, + &rd->fresh_pks[j].key); + GNUNET_assert (NULL != fcd->fresh_pk.bsign_pub_key); switch (fcd->fresh_pk.bsign_pub_key->cipher) { case GNUNET_CRYPTO_BSA_INVALID: @@ -121,8 +124,6 @@ TALER_EXCHANGE_get_melt_data_ ( &nonces[j].cs_nonce); break; } - TALER_denom_pub_deep_copy (&fcd->fresh_pk, - &rd->fresh_pks[j].key); if ( (0 > TALER_amount_add (&total, &total, diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c @@ -623,13 +623,13 @@ extract_denom_sig (void *cls, if (sizeof (ubs->details.cs_signature) != len) { GNUNET_break (0); + GNUNET_free (ubs); return GNUNET_SYSERR; } GNUNET_memcpy (&ubs->details.cs_signature, res, len); sig->unblinded_sig = ubs; - GNUNET_free (ubs); return GNUNET_OK; } GNUNET_break (0);