-fix withdraw logic

This commit is contained in:
Christian Grothoff 2022-02-09 16:43:36 +01:00
parent d05c561e4f
commit 1777db292e
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
5 changed files with 23 additions and 14 deletions

View File

@ -602,6 +602,7 @@ csr_cb (void *cls,
struct TALER_EXCHANGE_MeltHandle *mh = cls; struct TALER_EXCHANGE_MeltHandle *mh = cls;
unsigned int nks_off = 0; unsigned int nks_off = 0;
mh->csr = NULL;
for (unsigned int i = 0; i<mh->rd->fresh_pks_len; i++) for (unsigned int i = 0; i<mh->rd->fresh_pks_len; i++)
{ {
const struct TALER_EXCHANGE_DenomPublicKey *fresh_pk = const struct TALER_EXCHANGE_DenomPublicKey *fresh_pk =

View File

@ -214,6 +214,8 @@ withdraw_cs_stage_two_callback (void *cls,
TALER_planchet_blinding_secret_create (&wh->ps, TALER_planchet_blinding_secret_create (&wh->ps,
&wh->alg_values, &wh->alg_values,
&wh->bks); &wh->bks);
/* This initializes the 2nd half of the
wh->pd.blinded_planchet! */
if (GNUNET_OK != if (GNUNET_OK !=
TALER_planchet_prepare (&wh->pk.key, TALER_planchet_prepare (&wh->pk.key,
&wh->alg_values, &wh->alg_values,
@ -297,9 +299,13 @@ TALER_EXCHANGE_withdraw (
.pk = pk, .pk = pk,
}; };
wh->pd.blinded_planchet.cipher = TALER_DENOMINATION_CS;
TALER_cs_withdraw_nonce_derive (ps, TALER_cs_withdraw_nonce_derive (ps,
&nk.nonce); &nk.nonce);
/* Note that we only initialize the first half
of the blinded_planchet here; the other part
will be done after the /csr request! */
wh->pd.blinded_planchet.cipher = TALER_DENOMINATION_CS;
wh->pd.blinded_planchet.details.cs_blinded_planchet.nonce = nk.nonce;
wh->csrh = TALER_EXCHANGE_csr (exchange, wh->csrh = TALER_EXCHANGE_csr (exchange,
1, /* "array" length */ 1, /* "array" length */
&nk, &nk,
@ -312,7 +318,6 @@ TALER_EXCHANGE_withdraw (
GNUNET_free (wh); GNUNET_free (wh);
return NULL; return NULL;
} }
TALER_blinded_planchet_free (&wh->pd.blinded_planchet);
return wh; return wh;
} }
@ -320,6 +325,7 @@ TALER_EXCHANGE_withdraw (
void void
TALER_EXCHANGE_withdraw_cancel (struct TALER_EXCHANGE_WithdrawHandle *wh) TALER_EXCHANGE_withdraw_cancel (struct TALER_EXCHANGE_WithdrawHandle *wh)
{ {
TALER_blinded_planchet_free (&wh->pd.blinded_planchet);
if (NULL != wh->csrh) if (NULL != wh->csrh)
{ {
TALER_EXCHANGE_csr_cancel (wh->csrh); TALER_EXCHANGE_csr_cancel (wh->csrh);

View File

@ -438,9 +438,10 @@ TALER_EXCHANGE_withdraw2 (
TALER_amount_hton (&req.amount_with_fee, TALER_amount_hton (&req.amount_with_fee,
&wh->requested_amount); &wh->requested_amount);
if (GNUNET_OK != TALER_coin_ev_hash (&pd->blinded_planchet, if (GNUNET_OK !=
&pd->denom_pub_hash, TALER_coin_ev_hash (&pd->blinded_planchet,
&req.h_coin_envelope)) &pd->denom_pub_hash,
&req.h_coin_envelope))
{ {
GNUNET_break (0); GNUNET_break (0);
GNUNET_free (wh); GNUNET_free (wh);

View File

@ -633,13 +633,14 @@ TALER_CRYPTO_helper_cs_r_derive (struct TALER_CRYPTO_CsDenominationHelper *dh,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Requesting R\n"); "Requesting R\n");
{ {
struct TALER_CRYPTO_CsRDeriveRequest rdr; struct TALER_CRYPTO_CsRDeriveRequest rdr = {
.header.size = htons (sizeof (rdr)),
.header.type = htons (TALER_HELPER_CS_MT_REQ_RDERIVE),
.reserved = htonl (0),
.h_cs = *h_cs,
.nonce = *nonce
};
rdr.header.size = htons (sizeof (rdr));
rdr.header.type = htons (TALER_HELPER_CS_MT_REQ_RDERIVE);
rdr.reserved = htonl (0);
rdr.h_cs = *h_cs;
rdr.nonce = *nonce;
if (GNUNET_OK != if (GNUNET_OK !=
TALER_crypto_helper_send_all (dh->sock, TALER_crypto_helper_send_all (dh->sock,
&rdr, &rdr,

View File

@ -364,15 +364,15 @@ TALER_denom_blind (
struct TALER_DenominationCSPublicRPairP blinded_r_pub; struct TALER_DenominationCSPublicRPairP blinded_r_pub;
struct GNUNET_CRYPTO_CsBlindingSecret bs[2]; struct GNUNET_CRYPTO_CsBlindingSecret bs[2];
blinded_planchet->cipher = dk->cipher; blinded_planchet->cipher = TALER_DENOMINATION_CS;
GNUNET_CRYPTO_cs_blinding_secrets_derive (&coin_bks->nonce, GNUNET_CRYPTO_cs_blinding_secrets_derive (&coin_bks->nonce,
bs); bs);
GNUNET_CRYPTO_cs_calc_blinded_c ( GNUNET_CRYPTO_cs_calc_blinded_c (
bs, bs,
alg_values->details.cs_values.r_pub_pair.r_pub, alg_values->details.cs_values.r_pub_pair.r_pub,
&dk->details.cs_public_key, &dk->details.cs_public_key,
&c_hash->hash, c_hash,
sizeof(struct GNUNET_HashCode), sizeof(*c_hash),
blinded_planchet->details.cs_blinded_planchet.c, blinded_planchet->details.cs_blinded_planchet.c,
blinded_r_pub.r_pub); blinded_r_pub.r_pub);
return GNUNET_OK; return GNUNET_OK;