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);
}
if (GNUNET_OK != TALER_coin_ev_hash (&blinded_planchet,
&dk->denom_pub,
&coin->denom_pub_hash,
&pc.h_blind))
{
GNUNET_break (0);

View File

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

View File

@ -1732,7 +1732,7 @@ run (void *cls)
&c_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));
GNUNET_assert (GNUNET_OK ==
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
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);

View File

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

View File

@ -502,43 +502,46 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc,
enum GNUNET_GenericReturnValue
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)
{
switch (blinded_planchet->cipher)
{
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 = ':';
size_t buf_len = sizeof(denom_pub->details.cs_public_key)
+ sizeof (blinded_planchet->details.cs_blinded_planchet.
nonce)
+ sizeof(delim);
void*buf = GNUNET_malloc (buf_len);
memcpy (buf,
&denom_pub->details.cs_public_key,
sizeof(denom_pub->details.cs_public_key));
memcpy (buf + sizeof(denom_pub->details.cs_public_key),
&delim,
sizeof(delim));
memcpy (buf + sizeof(denom_pub->details.cs_public_key) + sizeof(delim),
&blinded_planchet->details.cs_blinded_planchet.nonce,
sizeof (blinded_planchet->details.cs_blinded_planchet.nonce));
GNUNET_CRYPTO_hash (
buf,
buf_len,
&bch->hash);
GNUNET_free (buf);
struct GNUNET_HashContext *hash_context;
hash_context = GNUNET_CRYPTO_hash_context_start ();
// // FIXME: Include denom_pub into hash
// GNUNET_CRYPTO_hash_context_read (hash_context,
// &denom_hash->hash,
// sizeof(denom_hash->hash));
GNUNET_CRYPTO_hash_context_read (hash_context,
blinded_planchet->details.
rsa_blinded_planchet.blinded_msg,
blinded_planchet->details.
rsa_blinded_planchet.blinded_msg_size);
GNUNET_CRYPTO_hash_context_finish (hash_context,
&bch->hash);
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:
GNUNET_break (0);
return GNUNET_SYSERR;