From 1acc851deb38c52e4212823100eec8a00d5f385a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 16 Dec 2021 20:18:44 +0100 Subject: -fix recoup ugliness --- src/util/wallet_signatures.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/util/wallet_signatures.c') diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c index b895de14b..81ce9cc5f 100644 --- a/src/util/wallet_signatures.c +++ b/src/util/wallet_signatures.c @@ -155,4 +155,51 @@ TALER_wallet_link_verify ( } +enum GNUNET_GenericReturnValue +TALER_wallet_recoup_verify ( + const struct TALER_DenominationHash *h_denom_pub, + const union TALER_DenominationBlindingKeyP *coin_bks, + const struct TALER_Amount *requested_amount, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_CoinSpendSignatureP *coin_sig) +{ + struct TALER_RecoupRequestPS pr = { + .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_RECOUP), + .purpose.size = htonl (sizeof (pr)), + .h_denom_pub = *h_denom_pub, + .coin_blind = *coin_bks + }; + + TALER_amount_hton (&pr.recoup_amount, + requested_amount); + return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_RECOUP, + &pr, + &coin_sig->eddsa_signature, + &coin_pub->eddsa_pub); +} + + +void +TALER_wallet_recoup_sign ( + const struct TALER_DenominationHash *h_denom_pub, + const union TALER_DenominationBlindingKeyP *coin_bks, + const struct TALER_Amount *requested_amount, + const struct TALER_CoinSpendPrivateKeyP *coin_priv, + struct TALER_CoinSpendSignatureP *coin_sig) +{ + struct TALER_RecoupRequestPS pr = { + .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_RECOUP), + .purpose.size = htonl (sizeof (struct TALER_RecoupRequestPS)), + .h_denom_pub = *h_denom_pub, + .coin_blind = *coin_bks + }; + + TALER_amount_hton (&pr.recoup_amount, + requested_amount); + GNUNET_CRYPTO_eddsa_sign (&coin_priv->eddsa_priv, + &pr, + &coin_sig->eddsa_signature); +} + + /* end of wallet_signatures.c */ -- cgit v1.2.3