aboutsummaryrefslogtreecommitdiff
path: root/src/util/exchange_signatures.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/exchange_signatures.c')
-rw-r--r--src/util/exchange_signatures.c165
1 files changed, 165 insertions, 0 deletions
diff --git a/src/util/exchange_signatures.c b/src/util/exchange_signatures.c
index 4890ca20..eeec0d61 100644
--- a/src/util/exchange_signatures.c
+++ b/src/util/exchange_signatures.c
@@ -23,6 +23,8 @@
#include "taler_signatures.h"
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* @brief Format used to generate the signature on a confirmation
* from the exchange that a deposit request succeeded.
@@ -91,6 +93,8 @@ struct TALER_DepositConfirmationPS
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_deposit_confirmation_sign (
@@ -172,6 +176,8 @@ TALER_exchange_online_deposit_confirmation_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* @brief Format used to generate the signature on a request to refund
* a coin into the account of the customer.
@@ -213,6 +219,8 @@ struct TALER_RefundConfirmationPS
struct TALER_AmountNBO refund_amount;
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_refund_confirmation_sign (
@@ -276,6 +284,8 @@ TALER_exchange_online_refund_confirmation_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* @brief Format of the block signed by the Exchange in response to a successful
* "/refresh/melt" request. Hereby the exchange affirms that all of the
@@ -303,6 +313,8 @@ struct TALER_RefreshMeltConfirmationPS
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_melt_confirmation_sign (
@@ -347,6 +359,8 @@ TALER_exchange_online_melt_confirmation_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* @brief Signature made by the exchange over the full set of keys, used
* to detect cheating exchanges that give out different sets to
@@ -372,6 +386,8 @@ struct TALER_ExchangeKeySetPS
struct GNUNET_HashCode hc GNUNET_PACKED;
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_key_set_sign (
@@ -418,6 +434,8 @@ TALER_exchange_online_key_set_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* @brief Signature by which an exchange affirms that an account
* successfully passed the KYC checks.
@@ -442,6 +460,8 @@ struct TALER_ExchangeAccountSetupSuccessPS
struct GNUNET_TIME_TimestampNBO timestamp;
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_account_setup_success_sign (
@@ -490,6 +510,8 @@ TALER_exchange_online_account_setup_success_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* @brief Format internally used for packing the detailed information
* to generate the signature for /track/transfer signatures.
@@ -524,6 +546,8 @@ struct TALER_WireDepositDetailP
};
+GNUNET_NETWORK_STRUCT_END
+
void
TALER_exchange_online_wire_deposit_append (
@@ -549,6 +573,8 @@ TALER_exchange_online_wire_deposit_append (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* @brief Format used to generate the signature for /wire/deposit
* replies.
@@ -589,6 +615,8 @@ struct TALER_WireDepositDataPS
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_wire_deposit_sign (
@@ -650,6 +678,8 @@ TALER_exchange_online_wire_deposit_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Details affirmed by the exchange about a wire transfer the exchange
* claims to have done with respect to a deposit operation.
@@ -698,6 +728,8 @@ struct TALER_ConfirmWirePS
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_confirm_wire_sign (
@@ -761,6 +793,8 @@ TALER_exchange_online_confirm_wire_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Response by which the exchange affirms that it will
* refund a coin as part of the emergency /recoup
@@ -799,6 +833,8 @@ struct TALER_RecoupConfirmationPS
struct TALER_ReservePublicKeyP reserve_pub;
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_confirm_recoup_sign (
@@ -851,6 +887,8 @@ TALER_exchange_online_confirm_recoup_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Response by which the exchange affirms that it will refund a refreshed coin
* as part of the emergency /recoup protocol. The recoup will go back to the
@@ -888,6 +926,8 @@ struct TALER_RecoupRefreshConfirmationPS
struct TALER_CoinSpendPublicKeyP old_coin_pub;
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_confirm_recoup_refresh_sign (
@@ -945,6 +985,8 @@ TALER_exchange_online_confirm_recoup_refresh_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Response by which the exchange affirms that it does not
* currently know a denomination by the given hash.
@@ -968,6 +1010,8 @@ struct TALER_DenominationUnknownAffirmationPS
struct TALER_DenominationHashP h_denom_pub;
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_denomination_unknown_sign (
@@ -1012,6 +1056,8 @@ TALER_exchange_online_denomination_unknown_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Response by which the exchange affirms that it does not
* currently consider the given denomination to be valid
@@ -1042,6 +1088,8 @@ struct TALER_DenominationExpiredAffirmationPS
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_denomination_expired_sign (
@@ -1100,6 +1148,8 @@ TALER_exchange_online_denomination_expired_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Response by which the exchange affirms that it has
* closed a reserve and send back the funds.
@@ -1143,6 +1193,8 @@ struct TALER_ReserveCloseConfirmationPS
struct TALER_WireTransferIdentifierRawP wtid;
};
+GNUNET_NETWORK_STRUCT_END
+
enum TALER_ErrorCode
TALER_exchange_online_reserve_closed_sign (
@@ -1209,4 +1261,117 @@ TALER_exchange_online_reserve_closed_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Response by which the exchange affirms that it has
+ * received funds deposited into a purse.
+ */
+struct TALER_PurseCreateDepositConfirmationPS
+{
+
+ /**
+ * Purpose is #TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_CREATION
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+ /**
+ * When did the exchange receive the deposits.
+ */
+ struct GNUNET_TIME_TimestampNBO exchange_time;
+
+ /**
+ * When will the purse expire?
+ */
+ struct GNUNET_TIME_TimestampNBO purse_expiration;
+
+ /**
+ * How much should the purse ultimately contain.
+ */
+ struct TALER_AmountNBO amount_without_fee;
+
+ /**
+ * How much was deposited so far.
+ */
+ struct TALER_AmountNBO total_deposited;
+
+ /**
+ * Public key of the purse.
+ */
+ struct TALER_PurseContractPublicKeyP purse_pub;
+
+ /**
+ * Public key of the merge capability.
+ */
+ struct TALER_PurseMergePublicKeyP merge_pub;
+
+ /**
+ * Hash of the contract of the purse.
+ */
+ struct TALER_PrivateContractHashP h_contract_terms;
+
+};
+
+GNUNET_NETWORK_STRUCT_END
+
+
+enum TALER_ErrorCode
+TALER_exchange_online_purse_created_sign (
+ TALER_ExchangeSignCallback scb,
+ struct GNUNET_TIME_Timestamp exchange_time,
+ struct GNUNET_TIME_Timestamp purse_expiration,
+ const struct TALER_Amount *amount_without_fee,
+ const struct TALER_Amount *total_deposited,
+ const struct TALER_PurseContractPublicKeyP *purse_pub,
+ const struct TALER_PurseMergePublicKeyP *merge_pub,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ struct TALER_ExchangePublicKeyP *pub,
+ struct TALER_ExchangeSignatureP *sig)
+{
+ struct TALER_PurseCreateDepositConfirmationPS dc = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_CREATION),
+ .purpose.size = htonl (sizeof (dc)),
+ .h_contract_terms = *h_contract_terms,
+ .purse_pub = *purse_pub,
+ .merge_pub = *merge_pub,
+ .purse_expiration = GNUNET_TIME_timestamp_hton (purse_expiration),
+ .exchange_time = GNUNET_TIME_timestamp_hton (exchange_time)
+ };
+
+ return scb (&dc.purpose,
+ pub,
+ sig);
+}
+
+
+enum GNUNET_GenericReturnValue
+TALER_exchange_online_purse_created_verify (
+ struct GNUNET_TIME_Timestamp exchange_time,
+ struct GNUNET_TIME_Timestamp purse_expiration,
+ const struct TALER_Amount *amount_without_fee,
+ const struct TALER_Amount *total_deposited,
+ const struct TALER_PurseContractPublicKeyP *purse_pub,
+ const struct TALER_PurseMergePublicKeyP *merge_pub,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_ExchangePublicKeyP *pub,
+ const struct TALER_ExchangeSignatureP *sig)
+{
+ struct TALER_PurseCreateDepositConfirmationPS dc = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_CREATION),
+ .purpose.size = htonl (sizeof (dc)),
+ .h_contract_terms = *h_contract_terms,
+ .purse_pub = *purse_pub,
+ .merge_pub = *merge_pub,
+ .purse_expiration = GNUNET_TIME_timestamp_hton (purse_expiration),
+ .exchange_time = GNUNET_TIME_timestamp_hton (exchange_time)
+ };
+
+ return
+ GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_CREATION,
+ &dc,
+ &sig->eddsa_signature,
+ &pub->eddsa_pub);
+}
+
+
/* end of exchange_signatures.c */