diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-12-21 16:16:10 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-12-25 13:56:40 +0100 |
commit | 2c14d338704f4574055c4b5c51d8a79dd2e22345 (patch) | |
tree | b90afcabc65e7f27b531098a8bf3ce48a5362593 /src/util/wallet_signatures.c | |
parent | 1b23857f2cb56f4aa95a07d7c52bd48abc20b73b (diff) | |
download | exchange-2c14d338704f4574055c4b5c51d8a79dd2e22345.tar.xz |
deduplicate melt signing logic, remove coin_pub from data being signed over
Diffstat (limited to 'src/util/wallet_signatures.c')
-rw-r--r-- | src/util/wallet_signatures.c | 54 |
1 files changed, 54 insertions, 0 deletions
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 */ |