LCOV - code coverage report
Current view: top level - util - wallet_signatures.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 13 13 100.0 %
Date: 2021-08-30 06:43:37 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2020 Taler Systems SA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify it under the
       6             :   terms of the GNU General Public License as published by the Free Software
       7             :   Foundation; either version 3, or (at your option) any later version.
       8             : 
       9             :   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10             :   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11             :   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12             : 
      13             :   You should have received a copy of the GNU General Public License along with
      14             :   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15             : */
      16             : /**
      17             :  * @file secmod_signatures.c
      18             :  * @brief Utility functions for Taler security module signatures
      19             :  * @author Christian Grothoff
      20             :  */
      21             : #include "platform.h"
      22             : #include "taler_util.h"
      23             : #include "taler_signatures.h"
      24             : 
      25             : 
      26             : void
      27          23 : TALER_wallet_link_sign (const struct GNUNET_HashCode *h_denom_pub,
      28             :                         const struct TALER_TransferPublicKeyP *transfer_pub,
      29             :                         const void *coin_ev,
      30             :                         size_t coin_ev_size,
      31             :                         const struct TALER_CoinSpendPrivateKeyP *old_coin_priv,
      32             :                         struct TALER_CoinSpendSignatureP *coin_sig)
      33             : {
      34          23 :   struct TALER_LinkDataPS ldp = {
      35          23 :     .purpose.size = htonl (sizeof (ldp)),
      36          23 :     .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_LINK),
      37             :     .h_denom_pub = *h_denom_pub,
      38             :     .transfer_pub = *transfer_pub
      39             :   };
      40             : 
      41          23 :   GNUNET_CRYPTO_hash (coin_ev,
      42             :                       coin_ev_size,
      43             :                       &ldp.coin_envelope_hash);
      44          23 :   GNUNET_CRYPTO_eddsa_sign (&old_coin_priv->eddsa_priv,
      45             :                             &ldp,
      46             :                             &coin_sig->eddsa_signature);
      47          23 : }
      48             : 
      49             : 
      50             : enum GNUNET_GenericReturnValue
      51          27 : TALER_wallet_link_verify (
      52             :   const struct GNUNET_HashCode *h_denom_pub,
      53             :   const struct TALER_TransferPublicKeyP *transfer_pub,
      54             :   const void *coin_ev,
      55             :   size_t coin_ev_size,
      56             :   const struct TALER_CoinSpendPublicKeyP *old_coin_pub,
      57             :   const struct TALER_CoinSpendSignatureP *coin_sig)
      58             : {
      59          27 :   struct TALER_LinkDataPS ldp = {
      60          27 :     .purpose.size = htonl (sizeof (ldp)),
      61          27 :     .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_LINK),
      62             :     .h_denom_pub = *h_denom_pub,
      63             :     .transfer_pub = *transfer_pub
      64             :   };
      65             : 
      66          27 :   GNUNET_CRYPTO_hash (coin_ev,
      67             :                       coin_ev_size,
      68             :                       &ldp.coin_envelope_hash);
      69             :   return
      70          27 :     GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_LINK,
      71             :                                 &ldp,
      72             :                                 &coin_sig->eddsa_signature,
      73             :                                 &old_coin_pub->eddsa_pub);
      74             : }
      75             : 
      76             : 
      77             : /* end of wallet_signatures.c */

Generated by: LCOV version 1.14