diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-02-12 00:52:19 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-12 00:52:19 +0100 |
commit | 94a5359494bcc24916c9f7f8323ace4643bc0065 (patch) | |
tree | 2d012532facb3d805487ad5bd9c07ebde2e1deb6 /src/lib | |
parent | 3b1e742dde4c386b38fc77147127b4bf6119d9e5 (diff) |
-address misc. fixmes
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/exchange_api_common.c | 35 | ||||
-rw-r--r-- | src/lib/exchange_api_refreshes_reveal.c | 9 | ||||
-rw-r--r-- | src/lib/exchange_api_withdraw2.c | 36 |
3 files changed, 34 insertions, 46 deletions
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 399eb280a..53a75a934 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -124,7 +124,8 @@ TALER_EXCHANGE_parse_reserve_history ( "WITHDRAW")) { struct TALER_ReserveSignatureP sig; - struct TALER_WithdrawRequestPS withdraw_purpose; + struct TALER_DenominationHash h_denom_pub; + struct TALER_BlindedCoinHash bch; struct TALER_Amount withdraw_fee; struct GNUNET_JSON_Specification withdraw_spec[] = { GNUNET_JSON_spec_fixed_auto ("reserve_sig", @@ -132,9 +133,9 @@ TALER_EXCHANGE_parse_reserve_history ( TALER_JSON_spec_amount_any ("withdraw_fee", &withdraw_fee), GNUNET_JSON_spec_fixed_auto ("h_denom_pub", - &withdraw_purpose.h_denomination_pub), + &h_denom_pub), GNUNET_JSON_spec_fixed_auto ("h_coin_envelope", - &withdraw_purpose.h_coin_envelope), + &bch), GNUNET_JSON_spec_end () }; @@ -147,19 +148,14 @@ TALER_EXCHANGE_parse_reserve_history ( GNUNET_break_op (0); return GNUNET_SYSERR; } - withdraw_purpose.purpose.size - = htonl (sizeof (withdraw_purpose)); - withdraw_purpose.purpose.purpose - = htonl (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW); - withdraw_purpose.reserve_pub = *reserve_pub; - TALER_amount_hton (&withdraw_purpose.amount_with_fee, - &amount); + /* Check that the signature is a valid withdraw request */ if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW, - &withdraw_purpose, - &sig.eddsa_signature, - &reserve_pub->eddsa_pub)) + TALER_wallet_withdraw_verify (&h_denom_pub, + &amount, + &bch, + reserve_pub, + &sig)) { GNUNET_break_op (0); GNUNET_JSON_parse_free (withdraw_spec); @@ -172,8 +168,7 @@ TALER_EXCHANGE_parse_reserve_history ( key_state = TALER_EXCHANGE_get_keys (exchange); dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state, - &withdraw_purpose. - h_denomination_pub); + &h_denom_pub); if ( (GNUNET_YES != TALER_amount_cmp_currency (&withdraw_fee, &dki->fee_withdraw)) || @@ -193,10 +188,10 @@ TALER_EXCHANGE_parse_reserve_history ( /* Check check that the same withdraw transaction isn't listed twice by the exchange. We use the "uuid" array to remember the hashes of all - purposes, and compare the hashes to find - duplicates. */// - GNUNET_CRYPTO_hash (&withdraw_purpose, - ntohl (withdraw_purpose.purpose.size), + signatures, and compare the hashes to find + duplicates. */ + GNUNET_CRYPTO_hash (&sig, + sizeof (sig), &uuid[uuid_off]); for (unsigned int i = 0; i<uuid_off; i++) { diff --git a/src/lib/exchange_api_refreshes_reveal.c b/src/lib/exchange_api_refreshes_reveal.c index ca49f7782..2fc02d330 100644 --- a/src/lib/exchange_api_refreshes_reveal.c +++ b/src/lib/exchange_api_refreshes_reveal.c @@ -399,10 +399,11 @@ TALER_EXCHANGE_refreshes_reveal ( TALER_planchet_blinding_secret_create (&coin_ps, &alg_values[i], &bks); - TALER_cs_refresh_nonce_derive ( - rms, - i, - &pd.blinded_planchet.details.cs_blinded_planchet.nonce); + if (TALER_DENOMINATION_CS == alg_values[i].cipher) + TALER_cs_refresh_nonce_derive ( + rms, + i, + &pd.blinded_planchet.details.cs_blinded_planchet.nonce); if (GNUNET_OK != TALER_planchet_prepare (&md.fresh_pks[i], &alg_values[i], diff --git a/src/lib/exchange_api_withdraw2.c b/src/lib/exchange_api_withdraw2.c index d354946e1..c0643b9af 100644 --- a/src/lib/exchange_api_withdraw2.c +++ b/src/lib/exchange_api_withdraw2.c @@ -380,6 +380,7 @@ TALER_EXCHANGE_withdraw2 ( const struct TALER_EXCHANGE_DenomPublicKey *dk; struct TALER_ReserveSignatureP reserve_sig; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; + struct TALER_BlindedCoinHash bch; keys = TALER_EXCHANGE_get_keys (exchange); if (NULL == keys) @@ -428,31 +429,22 @@ TALER_EXCHANGE_withdraw2 ( "/reserves/%s/withdraw", pub_str); } - // FIXME: move this to libtalerutil! + + if (GNUNET_OK != + TALER_coin_ev_hash (&pd->blinded_planchet, + &pd->denom_pub_hash, + &bch)) { - struct TALER_WithdrawRequestPS req = { - .purpose.size = htonl (sizeof (req)), - .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW), - .reserve_pub = wh->reserve_pub, - .h_denomination_pub = pd->denom_pub_hash - }; - - TALER_amount_hton (&req.amount_with_fee, - &wh->requested_amount); - if (GNUNET_OK != - TALER_coin_ev_hash (&pd->blinded_planchet, - &pd->denom_pub_hash, - &req.h_coin_envelope)) - { - GNUNET_break (0); - GNUNET_free (wh); - return NULL; - } - GNUNET_CRYPTO_eddsa_sign (&reserve_priv->eddsa_priv, - &req, - &reserve_sig.eddsa_signature); + GNUNET_break (0); + GNUNET_free (wh); + return NULL; } + TALER_wallet_withdraw_sign (&pd->denom_pub_hash, + &wh->requested_amount, + &bch, + reserve_priv, + &reserve_sig); { json_t *withdraw_obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("denom_pub_hash", |