exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

exchange_api_common.h (6429B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2015-2022 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
     15   <http://www.gnu.org/licenses/>
     16 */
     17 /**
     18  * @file lib/exchange_api_common.h
     19  * @brief common functions for the exchange API
     20  * @author Christian Grothoff
     21  */
     22 #ifndef EXCHANGE_API_COMMON_H
     23 #define EXCHANGE_API_COMMON_H
     24 
     25 #include "taler/taler_json_lib.h"
     26 #include "taler/taler_exchange_service.h"
     27 
     28 
     29 /**
     30  * Check proof of a purse creation conflict.
     31  *
     32  * @param cpurse_sig conflicting signature (must
     33  *        not match the signature from the proof)
     34  * @param purse_pub the public key (must match
     35  *        the signature from the proof)
     36  * @param proof the proof to check
     37  * @return #GNUNET_OK if the @a proof is OK for @a purse_pub and conflicts with @a cpurse_sig
     38  */
     39 enum GNUNET_GenericReturnValue
     40 TALER_EXCHANGE_check_purse_create_conflict_ (
     41   const struct TALER_PurseContractSignatureP *cpurse_sig,
     42   const struct TALER_PurseContractPublicKeyP *purse_pub,
     43   const json_t *proof);
     44 
     45 
     46 /**
     47  * Check proof of a purse merge conflict.
     48  *
     49  * @param cmerge_sig conflicting signature (must
     50  *        not match the signature from the proof)
     51  * @param merge_pub the public key (must match
     52  *        the signature from the proof)
     53  * @param purse_pub the public key of the purse
     54  * @param exchange_url the base URL of this exchange
     55  * @param proof the proof to check
     56  * @return #GNUNET_OK if the @a proof is OK for @a purse_pub and @a merge_pub and conflicts with @a cmerge_sig
     57  */
     58 enum GNUNET_GenericReturnValue
     59 TALER_EXCHANGE_check_purse_merge_conflict_ (
     60   const struct TALER_PurseMergeSignatureP *cmerge_sig,
     61   const struct TALER_PurseMergePublicKeyP *merge_pub,
     62   const struct TALER_PurseContractPublicKeyP *purse_pub,
     63   const char *exchange_url,
     64   const json_t *proof);
     65 
     66 
     67 /**
     68  * Check @a proof that claims this coin was spend
     69  * differently on the same purse already. Note that
     70  * the caller must still check that @a coin_pub is
     71  * in the list of coins that were used, and that
     72  * @a coin_sig is different from the signature the
     73  * caller used.
     74  *
     75  * @param purse_pub the public key of the purse
     76  * @param exchange_url base URL of our exchange
     77  * @param proof the proof to check
     78  * @param[out] h_denom_pub hash of the coin's denomination
     79  * @param[out] phac age commitment hash of the coin
     80  * @param[out] coin_pub set to the conflicting coin
     81  * @param[out] coin_sig set to the conflicting signature
     82  * @return #GNUNET_OK if the @a proof is OK for @a purse_pub and showing that @a coin_pub was spent using @a coin_sig.
     83  */
     84 enum GNUNET_GenericReturnValue
     85 TALER_EXCHANGE_check_purse_coin_conflict_ (
     86   const struct TALER_PurseContractPublicKeyP *purse_pub,
     87   const char *exchange_url,
     88   const json_t *proof,
     89   struct TALER_DenominationHashP *h_denom_pub,
     90   struct TALER_AgeCommitmentHashP *phac,
     91   struct TALER_CoinSpendPublicKeyP *coin_pub,
     92   struct TALER_CoinSpendSignatureP *coin_sig);
     93 
     94 
     95 /**
     96  * Check proof of a contract conflict.
     97  *
     98  * @param ccontract_sig conflicting signature (must
     99  *        not match the signature from the proof)
    100  * @param purse_pub public key of the purse
    101  * @param proof the proof to check
    102  * @return #GNUNET_OK if the @a proof is OK for @a purse_pub and conflicts with @a ccontract_sig
    103  */
    104 enum GNUNET_GenericReturnValue
    105 TALER_EXCHANGE_check_purse_econtract_conflict_ (
    106   const struct TALER_PurseContractSignatureP *ccontract_sig,
    107   const struct TALER_PurseContractPublicKeyP *purse_pub,
    108   const json_t *proof);
    109 
    110 
    111 /**
    112  * Check proof of a coin spend value conflict.
    113  *
    114  * @param keys exchange /keys structure
    115  * @param proof the proof to check
    116  * @param[out] coin_pub set to the public key of the
    117  *        coin that is claimed to have an insufficient
    118  *        balance
    119  * @param[out] remaining set to the remaining balance
    120  *        of the coin as provided by the proof
    121  * @return #GNUNET_OK if the @a proof is OK for @a purse_pub demonstrating that @a coin_pub has only @a remaining balance.
    122  */
    123 enum GNUNET_GenericReturnValue
    124 TALER_EXCHANGE_check_coin_amount_conflict_ (
    125   const struct TALER_EXCHANGE_Keys *keys,
    126   const json_t *proof,
    127   struct TALER_CoinSpendPublicKeyP *coin_pub,
    128   struct TALER_Amount *remaining);
    129 
    130 
    131 /**
    132  * Verify that @a proof contains a coin history that demonstrates that @a
    133  * coin_pub was previously used with a denomination key that is different from
    134  * @a ch_denom_pub.  Note that the coin history MUST have been checked before
    135  * using #TALER_EXCHANGE_check_coin_amount_conflict_().
    136  *
    137  * @param proof a proof to check
    138  * @param ch_denom_pub hash of the conflicting denomination
    139  * @return #GNUNET_OK if @a ch_denom_pub differs from the
    140  *         denomination hash given by the history of the coin
    141  */
    142 enum GNUNET_GenericReturnValue
    143 TALER_EXCHANGE_check_coin_denomination_conflict_ (
    144   const json_t *proof,
    145   const struct TALER_DenominationHashP *ch_denom_pub);
    146 
    147 
    148 /**
    149  * Find the smallest denomination amount in @e keys.
    150  *
    151  * @param keys keys to search
    152  * @param[out] min set to the smallest amount
    153  * @return #GNUNET_SYSERR if there are no denominations in @a keys
    154  */
    155 enum GNUNET_GenericReturnValue
    156 TALER_EXCHANGE_get_min_denomination_ (
    157   const struct TALER_EXCHANGE_Keys *keys,
    158   struct TALER_Amount *min);
    159 
    160 
    161 /**
    162  * Verify signature information about the deposit.
    163  *
    164  * @param dcd contract details
    165  * @param ech hashed policy (passed to avoid recomputation)
    166  * @param h_wire hashed wire details (passed to avoid recomputation)
    167  * @param cdd coin-specific details
    168  * @param dki denomination of the coin
    169  * @return #GNUNET_OK if signatures are OK, #GNUNET_SYSERR if not
    170  */
    171 enum GNUNET_GenericReturnValue
    172 TALER_EXCHANGE_verify_deposit_signature_ (
    173   const struct TALER_EXCHANGE_DepositContractDetail *dcd,
    174   const struct TALER_ExtensionPolicyHashP *ech,
    175   const struct TALER_MerchantWireHashP *h_wire,
    176   const struct TALER_EXCHANGE_CoinDepositDetail *cdd,
    177   const struct TALER_EXCHANGE_DenomPublicKey *dki);
    178 
    179 
    180 #endif