From 2c14d338704f4574055c4b5c51d8a79dd2e22345 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 21 Dec 2021 16:16:10 +0100 Subject: deduplicate melt signing logic, remove coin_pub from data being signed over --- src/util/wallet_signatures.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/util/wallet_signatures.c') diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c index 81ce9cc5f..f686b765c 100644 --- a/src/util/wallet_signatures.c +++ b/src/util/wallet_signatures.c @@ -202,4 +202,58 @@ TALER_wallet_recoup_sign ( } +void +TALER_wallet_melt_sign ( + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *melt_fee, + const struct TALER_RefreshCommitmentP *rc, + const struct TALER_DenominationHash *h_denom_pub, + const struct TALER_CoinSpendPrivateKeyP *coin_priv, + struct TALER_CoinSpendSignatureP *coin_sig) +{ + struct TALER_RefreshMeltCoinAffirmationPS melt = { + .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT), + .purpose.size = htonl (sizeof (melt)), + .rc = *rc, + .h_denom_pub = *h_denom_pub + }; + + TALER_amount_hton (&melt.amount_with_fee, + amount_with_fee); + TALER_amount_hton (&melt.melt_fee, + melt_fee); + GNUNET_CRYPTO_eddsa_sign (&coin_priv->eddsa_priv, + &melt, + &coin_sig->eddsa_signature); +} + + +enum GNUNET_GenericReturnValue +TALER_wallet_melt_verify ( + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *melt_fee, + const struct TALER_RefreshCommitmentP *rc, + const struct TALER_DenominationHash *h_denom_pub, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_CoinSpendSignatureP *coin_sig) +{ + struct TALER_RefreshMeltCoinAffirmationPS melt = { + .purpose.size = htonl (sizeof (melt)), + .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT), + .rc = *rc, + .h_denom_pub = *h_denom_pub + }; + + TALER_amount_hton (&melt.amount_with_fee, + amount_with_fee); + TALER_amount_hton (&melt.melt_fee, + melt_fee); + return GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_WALLET_COIN_MELT, + &melt, + &coin_sig->eddsa_signature, + &coin_pub->eddsa_pub); +} + + /* end of wallet_signatures.c */ -- cgit v1.2.3