add new reserve status/history signatures

This commit is contained in:
Christian Grothoff 2022-03-20 02:39:28 +01:00
parent c83892ba29
commit 1bb5a77c8d
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 201 additions and 2 deletions

View File

@ -2778,7 +2778,7 @@ TALER_wallet_recoup_verify (
* @param h_denom_pub hash of the denomiantion public key of the coin
* @param coin_bks blinding factor used when withdrawing the coin
* @param coin_priv coin key of the coin to be recouped
* @param coin_sig resulting signature
* @param[out] coin_sig resulting signature
*/
void
TALER_wallet_recoup_sign (
@ -2811,7 +2811,7 @@ TALER_wallet_recoup_refresh_verify (
* @param h_denom_pub hash of the denomiantion public key of the coin
* @param coin_bks blinding factor used when withdrawing the coin
* @param coin_priv coin key of the coin to be recouped
* @param coin_sig resulting signature
* @param[out] coin_sig resulting signature
*/
void
TALER_wallet_recoup_refresh_sign (
@ -2821,6 +2821,68 @@ TALER_wallet_recoup_refresh_sign (
struct TALER_CoinSpendSignatureP *coin_sig);
/**
* Verify reserve history request signature.
*
* @param ts timestamp used
* @param history_fee how much did the wallet say it would pay
* @param reserve_pub reserve the history request was for
* @param reserve_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_history_verify (
const struct GNUNET_TIME_Timestamp ts,
const struct TALER_Amount *history_fee,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Create reserve history request signature.
*
* @param ts timestamp used
* @param history_fee how much do we expect to pay
* @param reserve_pub reserve the history request is for
* @param[out] reserve_sig resulting signature
*/
void
TALER_wallet_reserve_history_sign (
const struct GNUNET_TIME_Timestamp ts,
const struct TALER_Amount *history_fee,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
/**
* Verify reserve status request signature.
*
* @param ts timestamp used
* @param reserve_pub reserve the status request was for
* @param reserve_sig resulting signature
* @return #GNUNET_OK if the signature is valid
*/
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_status_verify (
const struct GNUNET_TIME_Timestamp ts,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
/**
* Create reserve status request signature.
*
* @param ts timestamp used
* @param reserve_pub reserve the status request is for
* @param[out] reserve_sig resulting signature
*/
void
TALER_wallet_reserve_status_sign (
const struct GNUNET_TIME_Timestamp ts,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
/* ********************* merchant signing ************************** */

View File

@ -283,6 +283,16 @@
*/
#define TALER_SIGNATURE_WALLET_AGE_ATTESTATION 1207
/**
* Request full reserve history and pay for it.
*/
#define TALER_SIGNATURE_WALLET_RESERVE_HISTORY 1208
/**
* Request detailed account status (for free).
*/
#define TALER_SIGNATURE_WALLET_RESERVE_STATUS 1209
/******************************/
/* Security module signatures */
@ -443,6 +453,51 @@ struct TALER_LinkDataPS
};
/**
* Response by which a wallet requests an account status.
*/
struct TALER_ReserveStatusRequestPS
{
/**
* Purpose is #TALER_SIGNATURE_WALLET_RESERVE_STATUS
*/
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
* When did the wallet make the requst.
*/
struct GNUNET_TIME_TimestampNBO request_timestamp;
};
/**
* Response by which a wallet requests a full
* reserve history and indicates it is willing
* to pay for it.
*/
struct TALER_ReserveHistoryRequestPS
{
/**
* Purpose is #TALER_SIGNATURE_WALLET_RESERVE_HISTORY
*/
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
* When did the wallet make the requst.
*/
struct GNUNET_TIME_TimestampNBO request_timestamp;
/**
* How much does the exchange charge for the history?
*/
struct TALER_AmountNBO history_fee;
};
/**
* @brief Format used for to generate the signature on a request to withdraw
* coins from a reserve.

View File

@ -373,4 +373,86 @@ TALER_wallet_account_setup_sign (
}
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_history_verify (
const struct GNUNET_TIME_Timestamp ts,
const struct TALER_Amount *history_fee,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig)
{
struct TALER_ReserveHistoryRequestPS rhr = {
.purpose.size = htonl (sizeof (rhr)),
.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_HISTORY),
.request_timestamp = GNUNET_TIME_timestamp_hton (ts)
};
TALER_amount_hton (&rhr.history_fee,
history_fee);
return GNUNET_CRYPTO_eddsa_verify (
TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW,
&rhr,
&reserve_sig->eddsa_signature,
&reserve_pub->eddsa_pub);
}
void
TALER_wallet_reserve_history_sign (
const struct GNUNET_TIME_Timestamp ts,
const struct TALER_Amount *history_fee,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig)
{
struct TALER_ReserveHistoryRequestPS rhr = {
.purpose.size = htonl (sizeof (rhr)),
.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_HISTORY),
.request_timestamp = GNUNET_TIME_timestamp_hton (ts)
};
TALER_amount_hton (&rhr.history_fee,
history_fee);
GNUNET_CRYPTO_eddsa_sign (&reserve_priv->eddsa_priv,
&rhr,
&reserve_sig->eddsa_signature);
}
enum GNUNET_GenericReturnValue
TALER_wallet_reserve_status_verify (
const struct GNUNET_TIME_Timestamp ts,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig)
{
struct TALER_ReserveStatusRequestPS rsr = {
.purpose.size = htonl (sizeof (rsr)),
.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_STATUS),
.request_timestamp = GNUNET_TIME_timestamp_hton (ts)
};
return GNUNET_CRYPTO_eddsa_verify (
TALER_SIGNATURE_WALLET_RESERVE_STATUS,
&rsr,
&reserve_sig->eddsa_signature,
&reserve_pub->eddsa_pub);
}
void
TALER_wallet_reserve_status_sign (
const struct GNUNET_TIME_Timestamp ts,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig)
{
struct TALER_ReserveStatusRequestPS rsr = {
.purpose.size = htonl (sizeof (rsr)),
.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_STATUS),
.request_timestamp = GNUNET_TIME_timestamp_hton (ts)
};
GNUNET_CRYPTO_eddsa_sign (&reserve_priv->eddsa_priv,
&rsr,
&reserve_sig->eddsa_signature);
}
/* end of wallet_signatures.c */