refactor TALER_coin_ev_hash

This commit is contained in:
Gian Demarmels 2022-01-17 19:36:19 +01:00
parent 2213012866
commit 086cf05794
No known key found for this signature in database
GPG Key ID: 030CEDDCCC92D778
6 changed files with 36 additions and 33 deletions

View File

@ -266,7 +266,7 @@ verify_and_execute_recoup (
NULL); NULL);
} }
if (GNUNET_OK != TALER_coin_ev_hash (&blinded_planchet, if (GNUNET_OK != TALER_coin_ev_hash (&blinded_planchet,
&dk->denom_pub, &coin->denom_pub_hash,
&pc.h_blind)) &pc.h_blind))
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -503,7 +503,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,
wc.wsrd.h_denomination_pub wc.wsrd.h_denomination_pub
= wc.collectable.denom_pub_hash; = wc.collectable.denom_pub_hash;
if (GNUNET_OK != TALER_coin_ev_hash (&wc.blinded_planchet, if (GNUNET_OK != TALER_coin_ev_hash (&wc.blinded_planchet,
&dk->denom_pub, &wc.collectable.denom_pub_hash,
&wc.wsrd.h_coin_envelope)) &wc.wsrd.h_coin_envelope))
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -1732,7 +1732,7 @@ run (void *cls)
&c_hash, &c_hash,
&pd.blinded_planchet)); &pd.blinded_planchet));
GNUNET_assert (GNUNET_OK == TALER_coin_ev_hash (&pd.blinded_planchet, GNUNET_assert (GNUNET_OK == TALER_coin_ev_hash (&pd.blinded_planchet,
&dkp->pub, &cbc.denom_pub_hash,
&cbc.h_coin_envelope)); &cbc.h_coin_envelope));
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_denom_sign_blinded (&cbc.sig, TALER_denom_sign_blinded (&cbc.sig,

View File

@ -1264,7 +1264,7 @@ TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info,
*/ */
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet, TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet,
const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_DenominationHash *denom_hash,
struct TALER_BlindedCoinHash *bch); struct TALER_BlindedCoinHash *bch);

View File

@ -438,7 +438,7 @@ 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 != TALER_coin_ev_hash (&pd->blinded_planchet,
&dk->key, &pd->denom_pub_hash,
&req.h_coin_envelope)) &req.h_coin_envelope))
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -502,43 +502,46 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc,
enum GNUNET_GenericReturnValue enum GNUNET_GenericReturnValue
TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet, TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet,
const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_DenominationHash *denom_hash,
struct TALER_BlindedCoinHash *bch) struct TALER_BlindedCoinHash *bch)
{ {
switch (blinded_planchet->cipher) switch (blinded_planchet->cipher)
{ {
case TALER_DENOMINATION_RSA: case TALER_DENOMINATION_RSA:
// FIXME: Include denom_pub into hash
GNUNET_CRYPTO_hash (
blinded_planchet->details.rsa_blinded_planchet.blinded_msg,
blinded_planchet->details.rsa_blinded_planchet.blinded_msg_size,
&bch->hash);
return GNUNET_OK;
case TALER_DENOMINATION_CS:
{ {
char delim = ':'; struct GNUNET_HashContext *hash_context;
size_t buf_len = sizeof(denom_pub->details.cs_public_key) hash_context = GNUNET_CRYPTO_hash_context_start ();
+ sizeof (blinded_planchet->details.cs_blinded_planchet.
nonce) // // FIXME: Include denom_pub into hash
+ sizeof(delim); // GNUNET_CRYPTO_hash_context_read (hash_context,
void*buf = GNUNET_malloc (buf_len); // &denom_hash->hash,
memcpy (buf, // sizeof(denom_hash->hash));
&denom_pub->details.cs_public_key, GNUNET_CRYPTO_hash_context_read (hash_context,
sizeof(denom_pub->details.cs_public_key)); blinded_planchet->details.
memcpy (buf + sizeof(denom_pub->details.cs_public_key), rsa_blinded_planchet.blinded_msg,
&delim, blinded_planchet->details.
sizeof(delim)); rsa_blinded_planchet.blinded_msg_size);
memcpy (buf + sizeof(denom_pub->details.cs_public_key) + sizeof(delim), GNUNET_CRYPTO_hash_context_finish (hash_context,
&blinded_planchet->details.cs_blinded_planchet.nonce,
sizeof (blinded_planchet->details.cs_blinded_planchet.nonce));
GNUNET_CRYPTO_hash (
buf,
buf_len,
&bch->hash); &bch->hash);
GNUNET_free (buf);
return GNUNET_OK; return GNUNET_OK;
} }
case TALER_DENOMINATION_CS:
{
struct GNUNET_HashContext *hash_context;
hash_context = GNUNET_CRYPTO_hash_context_start ();
GNUNET_CRYPTO_hash_context_read (hash_context,
&denom_hash->hash,
sizeof(denom_hash->hash));
GNUNET_CRYPTO_hash_context_read (hash_context,
&blinded_planchet->details.
cs_blinded_planchet.nonce,
sizeof (blinded_planchet->details.
cs_blinded_planchet.nonce));
GNUNET_CRYPTO_hash_context_finish (hash_context,
&bch->hash);
return GNUNET_OK;
}
default: default:
GNUNET_break (0); GNUNET_break (0);
return GNUNET_SYSERR; return GNUNET_SYSERR;