diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/auditor_api_deposit_confirmation.c | 23 | ||||
| -rw-r--r-- | src/lib/exchange_api_common.c | 169 | ||||
| -rw-r--r-- | src/lib/exchange_api_deposit.c | 23 | ||||
| -rw-r--r-- | src/lib/exchange_api_deposits_get.c | 66 | ||||
| -rw-r--r-- | src/lib/exchange_api_handle.c | 18 | ||||
| -rw-r--r-- | src/lib/exchange_api_kyc_check.c | 18 | ||||
| -rw-r--r-- | src/lib/exchange_api_melt.c | 2 | ||||
| -rw-r--r-- | src/lib/exchange_api_refund.c | 107 | ||||
| -rw-r--r-- | src/lib/exchange_api_transfers_get.c | 61 | 
9 files changed, 235 insertions, 252 deletions
| diff --git a/src/lib/auditor_api_deposit_confirmation.c b/src/lib/auditor_api_deposit_confirmation.c index 2c5bd2b4..be981eb9 100644 --- a/src/lib/auditor_api_deposit_confirmation.c +++ b/src/lib/auditor_api_deposit_confirmation.c @@ -188,17 +188,18 @@ verify_signatures (const struct TALER_MerchantWireHashP *h_wire,                     const struct TALER_MasterSignatureP *master_sig)  {    if (GNUNET_OK != -      TALER_exchange_deposit_confirm_verify (h_contract_terms, -                                             h_wire, -                                             h_extensions, -                                             exchange_timestamp, -                                             wire_deadline, -                                             refund_deadline, -                                             amount_without_fee, -                                             coin_pub, -                                             merchant_pub, -                                             exchange_pub, -                                             exchange_sig)) +      TALER_exchange_online_deposit_confirmation_verify ( +        h_contract_terms, +        h_wire, +        h_extensions, +        exchange_timestamp, +        wire_deadline, +        refund_deadline, +        amount_without_fee, +        coin_pub, +        merchant_pub, +        exchange_pub, +        exchange_sig))    {      GNUNET_break_op (0);      TALER_LOG_WARNING ( diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c index 1da36fe8..df1c43e4 100644 --- a/src/lib/exchange_api_common.c +++ b/src/lib/exchange_api_common.c @@ -219,18 +219,16 @@ TALER_EXCHANGE_parse_reserve_history (      else if (0 == strcasecmp (type,                                "RECOUP"))      { -      struct TALER_RecoupConfirmationPS pc; -      struct GNUNET_TIME_Timestamp timestamp;        const struct TALER_EXCHANGE_Keys *key_state;        struct GNUNET_JSON_Specification recoup_spec[] = {          GNUNET_JSON_spec_fixed_auto ("coin_pub", -                                     &pc.coin_pub), +                                     &rh->details.recoup_details.coin_pub),          GNUNET_JSON_spec_fixed_auto ("exchange_sig",                                       &rh->details.recoup_details.exchange_sig),          GNUNET_JSON_spec_fixed_auto ("exchange_pub",                                       &rh->details.recoup_details.exchange_pub), -        GNUNET_JSON_spec_timestamp_nbo ("timestamp", -                                        &pc.timestamp), +        GNUNET_JSON_spec_timestamp ("timestamp", +                                    &rh->details.recoup_details.timestamp),          GNUNET_JSON_spec_end ()        }; @@ -244,15 +242,6 @@ TALER_EXCHANGE_parse_reserve_history (          GNUNET_break_op (0);          return GNUNET_SYSERR;        } -      rh->details.recoup_details.coin_pub = pc.coin_pub; -      TALER_amount_hton (&pc.recoup_amount, -                         &amount); -      pc.purpose.size = htonl (sizeof (pc)); -      pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP); -      pc.reserve_pub = *reserve_pub; -      timestamp = GNUNET_TIME_timestamp_ntoh (pc.timestamp); -      rh->details.recoup_details.timestamp = timestamp; -        key_state = TALER_EXCHANGE_get_keys (exchange);        if (GNUNET_OK !=            TALER_EXCHANGE_test_signing_key (key_state, @@ -263,11 +252,13 @@ TALER_EXCHANGE_parse_reserve_history (          return GNUNET_SYSERR;        }        if (GNUNET_OK != -          GNUNET_CRYPTO_eddsa_verify ( -            TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP, -            &pc, -            &rh->details.recoup_details.exchange_sig.eddsa_signature, -            &rh->details.recoup_details.exchange_pub.eddsa_pub)) +          TALER_exchange_online_confirm_recoup_verify ( +            rh->details.recoup_details.timestamp, +            &amount, +            &rh->details.recoup_details.coin_pub, +            reserve_pub, +            &rh->details.recoup_details.exchange_pub, +            &rh->details.recoup_details.exchange_sig))        {          GNUNET_break_op (0);          return GNUNET_SYSERR; @@ -287,8 +278,6 @@ TALER_EXCHANGE_parse_reserve_history (                                "CLOSING"))      {        const struct TALER_EXCHANGE_Keys *key_state; -      struct TALER_ReserveCloseConfirmationPS rcc; -      struct GNUNET_TIME_Timestamp timestamp;        struct GNUNET_JSON_Specification closing_spec[] = {          GNUNET_JSON_spec_string (            "receiver_account_details", @@ -299,10 +288,10 @@ TALER_EXCHANGE_parse_reserve_history (                                       &rh->details.close_details.exchange_sig),          GNUNET_JSON_spec_fixed_auto ("exchange_pub",                                       &rh->details.close_details.exchange_pub), -        TALER_JSON_spec_amount_any_nbo ("closing_fee", -                                        &rcc.closing_fee), -        GNUNET_JSON_spec_timestamp_nbo ("timestamp", -                                        &rcc.timestamp), +        TALER_JSON_spec_amount_any ("closing_fee", +                                    &rh->details.close_details.fee), +        GNUNET_JSON_spec_timestamp ("timestamp", +                                    &rh->details.close_details.timestamp),          GNUNET_JSON_spec_end ()        }; @@ -316,33 +305,26 @@ TALER_EXCHANGE_parse_reserve_history (          GNUNET_break_op (0);          return GNUNET_SYSERR;        } -      TALER_amount_hton (&rcc.closing_amount, -                         &amount); -      TALER_payto_hash (rh->details.close_details.receiver_account_details, -                        &rcc.h_payto); -      rcc.wtid = rh->details.close_details.wtid; -      rcc.purpose.size = htonl (sizeof (rcc)); -      rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED); -      rcc.reserve_pub = *reserve_pub; -      timestamp = GNUNET_TIME_timestamp_ntoh (rcc.timestamp); -      rh->details.close_details.timestamp = timestamp; -      TALER_amount_ntoh (&rh->details.close_details.fee, -                         &rcc.closing_fee); +        key_state = TALER_EXCHANGE_get_keys (exchange);        if (GNUNET_OK != -          TALER_EXCHANGE_test_signing_key (key_state, -                                           &rh->details.close_details. -                                           exchange_pub)) +          TALER_EXCHANGE_test_signing_key ( +            key_state, +            &rh->details.close_details.exchange_pub))        {          GNUNET_break_op (0);          return GNUNET_SYSERR;        }        if (GNUNET_OK != -          GNUNET_CRYPTO_eddsa_verify ( -            TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED, -            &rcc, -            &rh->details.close_details.exchange_sig.eddsa_signature, -            &rh->details.close_details.exchange_pub.eddsa_pub)) +          TALER_exchange_online_reserve_closed_verify ( +            rh->details.close_details.timestamp, +            &amount, +            &rh->details.close_details.fee, +            rh->details.close_details.receiver_account_details, +            &rh->details.close_details.wtid, +            reserve_pub, +            &rh->details.close_details.exchange_pub, +            &rh->details.close_details.exchange_sig))        {          GNUNET_break_op (0);          return GNUNET_SYSERR; @@ -671,35 +653,29 @@ TALER_EXCHANGE_verify_coin_history (      else if (0 == strcasecmp (type,                                "RECOUP"))      { -      struct TALER_RecoupConfirmationPS pc = { -        .purpose.size = htonl (sizeof (pc)), -        .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP), -        .coin_pub = *coin_pub -      }; +      struct TALER_ReservePublicKeyP reserve_pub; +      struct GNUNET_TIME_Timestamp timestamp;        union TALER_DenominationBlindingKeyP coin_bks; -      struct TALER_Amount recoup_amount;        struct TALER_ExchangePublicKeyP exchange_pub;        struct TALER_ExchangeSignatureP exchange_sig;        struct TALER_CoinSpendSignatureP coin_sig;        struct GNUNET_JSON_Specification spec[] = { -        TALER_JSON_spec_amount_any_nbo ("amount", -                                        &pc.recoup_amount),          TALER_JSON_spec_amount_any ("amount", -                                    &recoup_amount), +                                    &amount),          GNUNET_JSON_spec_fixed_auto ("exchange_sig",                                       &exchange_sig),          GNUNET_JSON_spec_fixed_auto ("exchange_pub",                                       &exchange_pub),          GNUNET_JSON_spec_fixed_auto ("reserve_pub", -                                     &pc.reserve_pub), +                                     &reserve_pub),          GNUNET_JSON_spec_fixed_auto ("coin_sig",                                       &coin_sig),          GNUNET_JSON_spec_fixed_auto ("coin_blind",                                       &coin_bks),          GNUNET_JSON_spec_fixed_auto ("h_denom_pub",                                       h_denom_pub), -        GNUNET_JSON_spec_timestamp_nbo ("timestamp", -                                        &pc.timestamp), +        GNUNET_JSON_spec_timestamp ("timestamp", +                                    ×tamp),          GNUNET_JSON_spec_end ()        }; @@ -711,13 +687,14 @@ TALER_EXCHANGE_verify_coin_history (          GNUNET_break_op (0);          return GNUNET_SYSERR;        } -      TALER_amount_hton (&pc.recoup_amount, -                         &amount);        if (GNUNET_OK != -          GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP, -                                      &pc, -                                      &exchange_sig.eddsa_signature, -                                      &exchange_pub.eddsa_pub)) +          TALER_exchange_online_confirm_recoup_verify ( +            timestamp, +            &amount, +            coin_pub, +            &reserve_pub, +            &exchange_pub, +            &exchange_sig))        {          GNUNET_break_op (0);          return GNUNET_SYSERR; @@ -738,22 +715,16 @@ TALER_EXCHANGE_verify_coin_history (      {        /* This is the coin that was subjected to a recoup,           the value being credited to the old coin. */ -      struct TALER_RecoupRefreshConfirmationPS pc = { -        .purpose.size = htonl (sizeof (pc)), -        .purpose.purpose = htonl ( -          TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH), -        .coin_pub = *coin_pub -      }; +      struct TALER_CoinSpendPublicKeyP old_coin_pub;        union TALER_DenominationBlindingKeyP coin_bks; -      struct TALER_Amount recoup_amount; +      struct TALER_Amount amount; +      struct GNUNET_TIME_Timestamp timestamp;        struct TALER_ExchangePublicKeyP exchange_pub;        struct TALER_ExchangeSignatureP exchange_sig;        struct TALER_CoinSpendSignatureP coin_sig;        struct GNUNET_JSON_Specification spec[] = { -        TALER_JSON_spec_amount_any_nbo ("amount", -                                        &pc.recoup_amount),          TALER_JSON_spec_amount_any ("amount", -                                    &recoup_amount), +                                    &amount),          GNUNET_JSON_spec_fixed_auto ("exchange_sig",                                       &exchange_sig),          GNUNET_JSON_spec_fixed_auto ("exchange_pub", @@ -761,13 +732,13 @@ TALER_EXCHANGE_verify_coin_history (          GNUNET_JSON_spec_fixed_auto ("coin_sig",                                       &coin_sig),          GNUNET_JSON_spec_fixed_auto ("old_coin_pub", -                                     &pc.old_coin_pub), +                                     &old_coin_pub),          GNUNET_JSON_spec_fixed_auto ("coin_blind",                                       &coin_bks),          GNUNET_JSON_spec_fixed_auto ("h_denom_pub",                                       h_denom_pub), -        GNUNET_JSON_spec_timestamp_nbo ("timestamp", -                                        &pc.timestamp), +        GNUNET_JSON_spec_timestamp ("timestamp", +                                    ×tamp),          GNUNET_JSON_spec_end ()        }; @@ -779,14 +750,14 @@ TALER_EXCHANGE_verify_coin_history (          GNUNET_break_op (0);          return GNUNET_SYSERR;        } -      TALER_amount_hton (&pc.recoup_amount, -                         &amount);        if (GNUNET_OK != -          GNUNET_CRYPTO_eddsa_verify ( -            TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH, -            &pc, -            &exchange_sig.eddsa_signature, -            &exchange_pub.eddsa_pub)) +          TALER_exchange_online_confirm_recoup_refresh_verify ( +            timestamp, +            &amount, +            coin_pub, +            &old_coin_pub, +            &exchange_pub, +            &exchange_sig))        {          GNUNET_break_op (0);          return GNUNET_SYSERR; @@ -807,25 +778,21 @@ TALER_EXCHANGE_verify_coin_history (      {        /* This is the coin that was credited in a recoup,           the value being credited to the this coin. */ -      struct TALER_RecoupRefreshConfirmationPS pc = { -        .purpose.size = htonl (sizeof (pc)), -        .purpose.purpose = htonl ( -          TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH), -        .old_coin_pub = *coin_pub -      };        struct TALER_ExchangePublicKeyP exchange_pub;        struct TALER_ExchangeSignatureP exchange_sig; +      struct TALER_CoinSpendPublicKeyP new_coin_pub; +      struct GNUNET_TIME_Timestamp timestamp;        struct GNUNET_JSON_Specification spec[] = { -        TALER_JSON_spec_amount_any_nbo ("amount", -                                        &pc.recoup_amount), +        TALER_JSON_spec_amount_any ("amount", +                                    &amount),          GNUNET_JSON_spec_fixed_auto ("exchange_sig",                                       &exchange_sig),          GNUNET_JSON_spec_fixed_auto ("exchange_pub",                                       &exchange_pub),          GNUNET_JSON_spec_fixed_auto ("coin_pub", -                                     &pc.coin_pub), -        GNUNET_JSON_spec_timestamp_nbo ("timestamp", -                                        &pc.timestamp), +                                     &new_coin_pub), +        GNUNET_JSON_spec_timestamp ("timestamp", +                                    ×tamp),          GNUNET_JSON_spec_end ()        }; @@ -837,14 +804,14 @@ TALER_EXCHANGE_verify_coin_history (          GNUNET_break_op (0);          return GNUNET_SYSERR;        } -      TALER_amount_hton (&pc.recoup_amount, -                         &amount);        if (GNUNET_OK != -          GNUNET_CRYPTO_eddsa_verify ( -            TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH, -            &pc, -            &exchange_sig.eddsa_signature, -            &exchange_pub.eddsa_pub)) +          TALER_exchange_online_confirm_recoup_refresh_verify ( +            timestamp, +            &amount, +            &new_coin_pub, +            coin_pub, +            &exchange_pub, +            &exchange_sig))        {          GNUNET_break_op (0);          return GNUNET_SYSERR; diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c index a08a6f42..947a4256 100644 --- a/src/lib/exchange_api_deposit.c +++ b/src/lib/exchange_api_deposit.c @@ -361,17 +361,18 @@ handle_deposit_finished (void *cls,        }        if (GNUNET_OK != -          TALER_exchange_deposit_confirm_verify (&dh->h_contract_terms, -                                                 &dh->h_wire, -                                                 &dh->h_extensions, -                                                 dh->exchange_timestamp, -                                                 dh->wire_deadline, -                                                 dh->refund_deadline, -                                                 &dh->amount_without_fee, -                                                 &dh->coin_pub, -                                                 &dh->merchant_pub, -                                                 &dh->exchange_pub, -                                                 &dh->exchange_sig)) +          TALER_exchange_online_deposit_confirmation_verify ( +            &dh->h_contract_terms, +            &dh->h_wire, +            &dh->h_extensions, +            dh->exchange_timestamp, +            dh->wire_deadline, +            dh->refund_deadline, +            &dh->amount_without_fee, +            &dh->coin_pub, +            &dh->merchant_pub, +            &dh->exchange_pub, +            &dh->exchange_sig))        {          GNUNET_break_op (0);          dr.hr.http_status = 0; diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c index 5d069d5c..32c60f1f 100644 --- a/src/lib/exchange_api_deposits_get.c +++ b/src/lib/exchange_api_deposits_get.c @@ -70,10 +70,38 @@ struct TALER_EXCHANGE_DepositGetHandle    void *cb_cls;    /** -   * Information the exchange should sign in response. -   * (with pre-filled fields from the request). +   * Hash over the wiring information of the merchant.     */ -  struct TALER_ConfirmWirePS depconf; +  struct TALER_MerchantWireHashP h_wire; + +  /** +   * Hash over the contract for which this deposit is made. +   */ +  struct TALER_PrivateContractHashP h_contract_terms; + +  /** +   * Raw value (binary encoding) of the wire transfer subject. +   */ +  struct TALER_WireTransferIdentifierRawP wtid; + +  /** +   * The coin's public key.  This is the value that must have been +   * signed (blindly) by the Exchange. +   */ +  struct TALER_CoinSpendPublicKeyP coin_pub; + +  /** +   * When did the exchange execute this transfer? Note that the +   * timestamp may not be exactly the same on the wire, i.e. +   * because the wire has a different timezone or resolution. +   */ +  struct GNUNET_TIME_Timestamp execution_time; + +  /** +   * The contribution of @e coin_pub to the total transfer volume. +   * This is the value of the deposit minus the fee. +   */ +  struct TALER_Amount coin_contribution;  }; @@ -87,6 +115,7 @@ struct TALER_EXCHANGE_DepositGetHandle   * @param exchange_sig the exchange's signature   * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not   */ +// FIXME: inline...  static enum GNUNET_GenericReturnValue  verify_deposit_wtid_signature_ok (    const struct TALER_EXCHANGE_DepositGetHandle *dwh, @@ -104,10 +133,15 @@ verify_deposit_wtid_signature_ok (      return GNUNET_SYSERR;    }    if (GNUNET_OK != -      GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE, -                                  &dwh->depconf, -                                  &exchange_sig->eddsa_signature, -                                  &exchange_pub->eddsa_pub)) +      TALER_exchange_online_confirm_wire_verify ( +        &dwh->h_wire, +        &dwh->h_contract_terms, +        &dwh->wtid, +        &dwh->coin_pub, +        dwh->execution_time, +        &dwh->coin_contribution, +        exchange_pub, +        exchange_sig))    {      GNUNET_break_op (0);      return GNUNET_SYSERR; @@ -168,11 +202,10 @@ handle_deposit_wtid_finished (void *cls,          dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;          break;        } -      dwh->depconf.execution_time = GNUNET_TIME_timestamp_hton ( -        dr.details.success.execution_time); -      dwh->depconf.wtid = dr.details.success.wtid; -      TALER_amount_hton (&dwh->depconf.coin_contribution, -                         &dr.details.success.coin_contribution); +      // FIXME: remove once we inline function below... +      dwh->execution_time = dr.details.success.execution_time; +      dwh->wtid = dr.details.success.wtid; +      dwh->coin_contribution = dr.details.success.coin_contribution;        if (GNUNET_OK !=            verify_deposit_wtid_signature_ok (dwh,                                              &dr.details.success.exchange_pub, @@ -285,6 +318,7 @@ TALER_EXCHANGE_deposits_get (      GNUNET_break (0);      return NULL;    } +  // FIXME: move to helper!    dtp.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION);    dtp.purpose.size = htonl (sizeof (dtp));    dtp.h_contract_terms = *h_contract_terms; @@ -351,11 +385,9 @@ TALER_EXCHANGE_deposits_get (      GNUNET_free (dwh);      return NULL;    } -  dwh->depconf.purpose.size = htonl (sizeof (struct TALER_ConfirmWirePS)); -  dwh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE); -  dwh->depconf.h_wire = *h_wire; -  dwh->depconf.h_contract_terms = *h_contract_terms; -  dwh->depconf.coin_pub = *coin_pub; +  dwh->h_wire = *h_wire; +  dwh->h_contract_terms = *h_contract_terms; +  dwh->coin_pub = *coin_pub;    eh = TALER_EXCHANGE_curl_easy_get_ (dwh->url);    if (NULL == eh) diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index e0fcd2b9..feab4ac4 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -1136,11 +1136,7 @@ decode_keys_json (const json_t *resp_obj,    if (check_sig)    { -    struct TALER_ExchangeKeySetPS ks = { -      .purpose.size = htonl (sizeof (ks)), -      .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_KEY_SET), -      .list_issue_date = GNUNET_TIME_timestamp_hton (key_data->list_issue_date) -    }; +    struct GNUNET_HashCode hc;      /* If we had any age restricted denominations, add their hash to the end of       * the normal denominations. */ @@ -1160,16 +1156,18 @@ decode_keys_json (const json_t *resp_obj,      }      GNUNET_CRYPTO_hash_context_finish (hash_context, -                                       &ks.hc); +                                       &hc);      hash_context = NULL;      EXITIF (GNUNET_OK !=              TALER_EXCHANGE_test_signing_key (key_data,                                               &pub)); +      EXITIF (GNUNET_OK != -            GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_KEY_SET, -                                        &ks, -                                        &sig.eddsa_signature, -                                        &pub.eddsa_pub)); +            TALER_exchange_online_key_set_verify ( +              key_data->list_issue_date, +              &hc, +              &pub, +              &sig));    }    return GNUNET_OK;  EXITIF_exit: diff --git a/src/lib/exchange_api_kyc_check.c b/src/lib/exchange_api_kyc_check.c index 303368ea..1f9f3b16 100644 --- a/src/lib/exchange_api_kyc_check.c +++ b/src/lib/exchange_api_kyc_check.c @@ -105,12 +105,6 @@ handle_kyc_check_finished (void *cls,          GNUNET_JSON_spec_end ()        };        const struct TALER_EXCHANGE_Keys *key_state; -      struct TALER_ExchangeAccountSetupSuccessPS kyc_purpose = { -        .purpose.size = htonl (sizeof (kyc_purpose)), -        .purpose.purpose = htonl ( -          TALER_SIGNATURE_EXCHANGE_ACCOUNT_SETUP_SUCCESS), -        .h_payto = kch->h_payto -      };        if (GNUNET_OK !=            GNUNET_JSON_parse (j, @@ -122,8 +116,6 @@ handle_kyc_check_finished (void *cls,          ks.ec = TALER_EC_GENERIC_INVALID_RESPONSE;          break;        } -      kyc_purpose.timestamp = GNUNET_TIME_timestamp_hton ( -        ks.details.kyc_ok.timestamp);        key_state = TALER_EXCHANGE_get_keys (kch->exchange);        if (GNUNET_OK !=            TALER_EXCHANGE_test_signing_key (key_state, @@ -137,11 +129,11 @@ handle_kyc_check_finished (void *cls,        }        if (GNUNET_OK != -          GNUNET_CRYPTO_eddsa_verify ( -            TALER_SIGNATURE_EXCHANGE_ACCOUNT_SETUP_SUCCESS, -            &kyc_purpose, -            &ks.details.kyc_ok.exchange_sig.eddsa_signature, -            &ks.details.kyc_ok.exchange_pub.eddsa_pub)) +          TALER_exchange_online_account_setup_success_verify ( +            &kch->h_payto, +            ks.details.kyc_ok.timestamp, +            &ks.details.kyc_ok.exchange_pub, +            &ks.details.kyc_ok.exchange_sig))        {          GNUNET_break_op (0);          ks.http_status = 0; diff --git a/src/lib/exchange_api_melt.c b/src/lib/exchange_api_melt.c index 96e8c8e2..80c75970 100644 --- a/src/lib/exchange_api_melt.c +++ b/src/lib/exchange_api_melt.c @@ -170,7 +170,7 @@ verify_melt_signature_ok (struct TALER_EXCHANGE_MeltHandle *mh,    }    if (GNUNET_OK != -      TALER_exchange_melt_confirmation_verify ( +      TALER_exchange_online_melt_confirmation_verify (          &mh->md.rc,          mh->noreveal_index,          exchange_pub, diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 9ae907dc..6369a5bd 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -70,9 +70,33 @@ struct TALER_EXCHANGE_RefundHandle    void *cb_cls;    /** -   * Information the exchange should sign in response. +   * Hash over the proposal data to identify the contract +   * which is being refunded.     */ -  struct TALER_RefundConfirmationPS depconf; +  struct TALER_PrivateContractHashP h_contract_terms; + +  /** +   * The coin's public key.  This is the value that must have been +   * signed (blindly) by the Exchange. +   */ +  struct TALER_CoinSpendPublicKeyP coin_pub; + +  /** +   * The Merchant's public key.  Allows the merchant to later refund +   * the transaction or to inquire about the wire transfer identifier. +   */ +  struct TALER_MerchantPublicKeyP merchant; + +  /** +   * Merchant-generated transaction ID for the refund. +   */ +  uint64_t rtransaction_id; + +  /** +   * Amount to be refunded, including refund fee charged by the +   * exchange to the customer. +   */ +  struct TALER_Amount refund_amount;  }; @@ -119,10 +143,14 @@ verify_refund_signature_ok (struct TALER_EXCHANGE_RefundHandle *rh,      return GNUNET_SYSERR;    }    if (GNUNET_OK != -      GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND, -                                  &rh->depconf, -                                  &exchange_sig->eddsa_signature, -                                  &exchange_pub->eddsa_pub)) +      TALER_exchange_online_refund_confirmation_verify ( +        &rh->h_contract_terms, +        &rh->coin_pub, +        &rh->merchant, +        rh->rtransaction_id, +        &rh->refund_amount, +        exchange_pub, +        exchange_sig))    {      GNUNET_break_op (0);      return GNUNET_SYSERR; @@ -253,16 +281,16 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,                                         wallet_timestamp,                                         &merchant_pub,                                         refund_deadline, -                                       &rh->depconf.coin_pub, +                                       &rh->coin_pub,                                         &sig))        {          GNUNET_break_op (0);          GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        } -      if ( (0 != GNUNET_memcmp (&rh->depconf.h_contract_terms, +      if ( (0 != GNUNET_memcmp (&rh->h_contract_terms,                                  &h_contract_terms)) || -           (0 != GNUNET_memcmp (&rh->depconf.merchant, +           (0 != GNUNET_memcmp (&rh->merchant,                                  &merchant_pub)) )        {          /* deposit information is about a different merchant/contract */ @@ -334,7 +362,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,          return GNUNET_SYSERR;        }        if (GNUNET_OK != -          TALER_merchant_refund_verify (&rh->depconf.coin_pub, +          TALER_merchant_refund_verify (&rh->coin_pub,                                          &h_contract_terms,                                          rtransaction_id,                                          &sig_amount, @@ -345,9 +373,9 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,          GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        } -      if ( (0 != GNUNET_memcmp (&rh->depconf.h_contract_terms, +      if ( (0 != GNUNET_memcmp (&rh->h_contract_terms,                                  &h_contract_terms)) || -           (0 != GNUNET_memcmp (&rh->depconf.merchant, +           (0 != GNUNET_memcmp (&rh->merchant,                                  &merchant_pub)) )        {          /* refund is about a different merchant/contract */ @@ -355,7 +383,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,          GNUNET_JSON_parse_free (spec);          return GNUNET_SYSERR;        } -      if (rtransaction_id == rh->depconf.rtransaction_id) +      if (rtransaction_id == rh->rtransaction_id)        {          /* Eh, this shows either a dependency failure or idempotency,             but must not happen in a conflict reply. Fail! */ @@ -398,16 +426,12 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,    }    { -    struct TALER_Amount amount; - -    TALER_amount_ntoh (&amount, -                       &rh->depconf.refund_amount);      if (have_refund)      {        if (0 >            TALER_amount_add (&rtotal,                              &rtotal, -                            &amount)) +                            &rh->refund_amount))        {          GNUNET_break (0);          GNUNET_JSON_parse_free (spec); @@ -416,7 +440,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,      }      else      { -      rtotal = amount; +      rtotal = rh->refund_amount;      }    }    if (-1 == TALER_amount_cmp (&dtotal, @@ -472,7 +496,6 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,    e = json_array_get (h, 0);    {      struct TALER_Amount amount; -    struct TALER_Amount depconf_amount;      const char *type;      struct TALER_MerchantSignatureP sig;      struct TALER_Amount refund_fee; @@ -507,7 +530,7 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,        return GNUNET_SYSERR;      }      if (GNUNET_OK != -        TALER_merchant_refund_verify (&rh->depconf.coin_pub, +        TALER_merchant_refund_verify (&rh->coin_pub,                                        &h_contract_terms,                                        rtransaction_id,                                        &amount, @@ -518,14 +541,12 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,        GNUNET_JSON_parse_free (spec);        return GNUNET_SYSERR;      } -    TALER_amount_ntoh (&depconf_amount, -                       &rh->depconf.refund_amount); -    if ( (rtransaction_id != rh->depconf.rtransaction_id) || -         (0 != GNUNET_memcmp (&rh->depconf.h_contract_terms, +    if ( (rtransaction_id != rh->rtransaction_id) || +         (0 != GNUNET_memcmp (&rh->h_contract_terms,                                &h_contract_terms)) || -         (0 != GNUNET_memcmp (&rh->depconf.merchant, +         (0 != GNUNET_memcmp (&rh->merchant,                                &merchant_pub)) || -         (0 == TALER_amount_cmp (&depconf_amount, +         (0 == TALER_amount_cmp (&rh->refund_amount,                                   &amount)) )      {        GNUNET_break_op (0); @@ -669,15 +690,15 @@ handle_refund_finished (void *cls,  struct TALER_EXCHANGE_RefundHandle * -TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, -                       const struct TALER_Amount *amount, -                       const struct -                       TALER_PrivateContractHashP *h_contract_terms, -                       const struct TALER_CoinSpendPublicKeyP *coin_pub, -                       uint64_t rtransaction_id, -                       const struct TALER_MerchantPrivateKeyP *merchant_priv, -                       TALER_EXCHANGE_RefundCallback cb, -                       void *cb_cls) +TALER_EXCHANGE_refund ( +  struct TALER_EXCHANGE_Handle *exchange, +  const struct TALER_Amount *amount, +  const struct TALER_PrivateContractHashP *h_contract_terms, +  const struct TALER_CoinSpendPublicKeyP *coin_pub, +  uint64_t rtransaction_id, +  const struct TALER_MerchantPrivateKeyP *merchant_priv, +  TALER_EXCHANGE_RefundCallback cb, +  void *cb_cls)  {    struct TALER_MerchantPublicKeyP merchant_pub;    struct TALER_MerchantSignatureP merchant_sig; @@ -735,15 +756,11 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange,      GNUNET_free (rh);      return NULL;    } -  rh->depconf.purpose.size = htonl (sizeof (struct TALER_RefundConfirmationPS)); -  rh->depconf.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND); -  rh->depconf.h_contract_terms = *h_contract_terms; -  rh->depconf.coin_pub = *coin_pub; -  rh->depconf.merchant = merchant_pub; -  rh->depconf.rtransaction_id = GNUNET_htonll (rtransaction_id); -  TALER_amount_hton (&rh->depconf.refund_amount, -                     amount); - +  rh->h_contract_terms = *h_contract_terms; +  rh->coin_pub = *coin_pub; +  rh->merchant = merchant_pub; +  rh->rtransaction_id = rtransaction_id; +  rh->refund_amount = *amount;    eh = TALER_EXCHANGE_curl_easy_get_ (rh->url);    if ( (NULL == eh) ||         (GNUNET_OK != diff --git a/src/lib/exchange_api_transfers_get.c b/src/lib/exchange_api_transfers_get.c index b9a9db94..23a0ee76 100644 --- a/src/lib/exchange_api_transfers_get.c +++ b/src/lib/exchange_api_transfers_get.c @@ -177,43 +177,29 @@ check_transfers_get_response_ok (          return GNUNET_SYSERR;        }        /* build up big hash for signature checking later */ -      { -        struct TALER_WireDepositDetailP dd; - -        dd.h_contract_terms = detail->h_contract_terms; -        dd.execution_time = GNUNET_TIME_timestamp_hton (td.execution_time); -        dd.coin_pub = detail->coin_pub; -        TALER_amount_hton (&dd.deposit_value, -                           &detail->coin_value); -        TALER_amount_hton (&dd.deposit_fee, -                           &detail->coin_fee); -        GNUNET_CRYPTO_hash_context_read (hash_context, -                                         &dd, -                                         sizeof (dd)); -      } +      TALER_exchange_online_wire_deposit_append ( +        hash_context, +        &detail->h_contract_terms, +        td.execution_time, +        &detail->coin_pub, +        &detail->coin_value, +        &detail->coin_fee);      }      /* Check signature */      { -      struct TALER_WireDepositDataPS wdp = { -        .purpose.purpose = htonl ( -          TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT), -        .purpose.size = htonl (sizeof (wdp)), -        .merchant_pub = merchant_pub, -        .h_payto = td.h_payto -      }; +      struct GNUNET_HashCode h_details; -      TALER_amount_hton (&wdp.total, -                         &td.total_amount); -      TALER_amount_hton (&wdp.wire_fee, -                         &td.wire_fee);        GNUNET_CRYPTO_hash_context_finish (hash_context, -                                         &wdp.h_details); +                                         &h_details);        if (GNUNET_OK != -          GNUNET_CRYPTO_eddsa_verify ( -            TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT, -            &wdp, -            &td.exchange_sig.eddsa_signature, -            &td.exchange_pub.eddsa_pub)) +          TALER_exchange_online_wire_deposit_verify ( +            &td.total_amount, +            &td.wire_fee, +            &merchant_pub, +            &td.h_payto, +            &h_details, +            &td.exchange_pub, +            &td.exchange_sig))        {          GNUNET_break_op (0);          GNUNET_JSON_parse_free (spec); @@ -330,16 +316,6 @@ handle_transfers_get_finished (void *cls,  } -/** - * Query the exchange about which transactions were combined - * to create a wire transfer. - * - * @param exchange exchange to query - * @param wtid raw wire transfer identifier to get information about - * @param cb callback to call - * @param cb_cls closure for @a cb - * @return handle to cancel operation - */  struct TALER_EXCHANGE_TransfersGetHandle *  TALER_EXCHANGE_transfers_get (    struct TALER_EXCHANGE_Handle *exchange, @@ -369,8 +345,7 @@ TALER_EXCHANGE_transfers_get (      char *end;      end = GNUNET_STRINGS_data_to_string (wtid, -                                         sizeof (struct -                                                 TALER_WireTransferIdentifierRawP), +                                         sizeof (wtid),                                           wtid_str,                                           sizeof (wtid_str));      *end = '\0'; | 
