diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-07 11:41:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-07 11:41:53 +0100 |
commit | cd8d4bede16e62850235b4e83cc29c2ca498013e (patch) | |
tree | c28d6f587c8125c67f0334446f034c1185654074 /src/util/exchange_signatures.c | |
parent | fadfc735fadb0a718989fae6e4c436718e581783 (diff) | |
download | exchange-cd8d4bede16e62850235b4e83cc29c2ca498013e.tar.xz |
add missing file
Diffstat (limited to 'src/util/exchange_signatures.c')
-rw-r--r-- | src/util/exchange_signatures.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/util/exchange_signatures.c b/src/util/exchange_signatures.c new file mode 100644 index 000000000..2e71a33c1 --- /dev/null +++ b/src/util/exchange_signatures.c @@ -0,0 +1,69 @@ +/* + This file is part of TALER + Copyright (C) 2021 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file exchange_signatures.c + * @brief Utility functions for Taler security module signatures + * @author Christian Grothoff + */ +#include "platform.h" +#include "taler_util.h" +#include "taler_signatures.h" + + +enum GNUNET_GenericReturnValue +TALER_exchange_deposit_confirm_verify ( + const struct TALER_PrivateContractHash *h_contract_terms, + const struct TALER_MerchantWireHash *h_wire, + const struct TALER_ExtensionContractHash *h_extensions, + struct GNUNET_TIME_Absolute exchange_timestamp, + struct GNUNET_TIME_Absolute wire_deadline, + struct GNUNET_TIME_Absolute refund_deadline, + const struct TALER_Amount *amount_without_fee, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_ExchangePublicKeyP *exchange_pub, + const struct TALER_ExchangeSignatureP *exchange_sig) +{ + struct TALER_DepositConfirmationPS dcs = { + .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT), + .purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS)), + .h_contract_terms = *h_contract_terms, + .h_wire = *h_wire, + .exchange_timestamp = GNUNET_TIME_absolute_hton (exchange_timestamp), + .wire_deadline = GNUNET_TIME_absolute_hton (wire_deadline), + .refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline), + .coin_pub = *coin_pub, + .merchant_pub = *merchant_pub + }; + + if (NULL != h_extensions) + dcs.h_extensions = *h_extensions; + TALER_amount_hton (&dcs.amount_without_fee, + amount_without_fee); + if (GNUNET_OK != + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT, + &dcs, + &exchange_sig->eddsa_signature, + &exchange_pub->eddsa_pub)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + + +/* end of exchange_signatures.c */ |