summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-12-06 13:02:54 +0100
committerChristian Grothoff <christian@grothoff.org>2022-12-06 13:02:54 +0100
commit21959eebd2256a3fb72173488cf366868179ee13 (patch)
tree3804cebf03db618cce5c8bb25d631fb05527e5c3 /src/util
parent9e4ac84b6eed7cc622d041c396bc460ce7e1bf07 (diff)
downloadexchange-21959eebd2256a3fb72173488cf366868179ee13.tar.gz
exchange-21959eebd2256a3fb72173488cf366868179ee13.tar.bz2
exchange-21959eebd2256a3fb72173488cf366868179ee13.zip
fix FIXME: sign also over balance during account-setup
Diffstat (limited to 'src/util')
-rw-r--r--src/util/wallet_signatures.c57
1 files changed, 45 insertions, 12 deletions
diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c
index 5efcc5d64..6866ca19b 100644
--- a/src/util/wallet_signatures.c
+++ b/src/util/wallet_signatures.c
@@ -604,36 +604,68 @@ TALER_wallet_withdraw_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
+
+/**
+ * @brief Format used for to generate the signature on a request to withdraw
+ * coins from a reserve.
+ */
+struct TALER_AccountSetupRequestSignaturePS
+{
+
+ /**
+ * Purpose must be #TALER_SIGNATURE_WALLET_ACCOUNT_SETUP.
+ * Used with an EdDSA signature of a `struct TALER_ReservePublicKeyP`.
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+ /**
+ * Balance threshold the wallet is about to cross.
+ */
+ struct TALER_AmountNBO threshold;
+
+};
+
+
+GNUNET_NETWORK_STRUCT_END
+
+
void
TALER_wallet_account_setup_sign (
const struct TALER_ReservePrivateKeyP *reserve_priv,
+ const struct TALER_Amount *balance_threshold,
struct TALER_ReserveSignatureP *reserve_sig)
{
- struct GNUNET_CRYPTO_EccSignaturePurpose purpose = {
- .size = htonl (sizeof (purpose)),
- .purpose = htonl (TALER_SIGNATURE_WALLET_ACCOUNT_SETUP)
+ struct TALER_AccountSetupRequestSignaturePS asap = {
+ .purpose.size = htonl (sizeof (asap)),
+ .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_ACCOUNT_SETUP)
};
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign_ (&reserve_priv->eddsa_priv,
- &purpose,
- &reserve_sig->eddsa_signature));
+ TALER_amount_hton (&asap.threshold,
+ balance_threshold);
+ GNUNET_CRYPTO_eddsa_sign (&reserve_priv->eddsa_priv,
+ &asap,
+ &reserve_sig->eddsa_signature);
}
enum GNUNET_GenericReturnValue
TALER_wallet_account_setup_verify (
const struct TALER_ReservePublicKeyP *reserve_pub,
+ const struct TALER_Amount *balance_threshold,
const struct TALER_ReserveSignatureP *reserve_sig)
{
- struct GNUNET_CRYPTO_EccSignaturePurpose purpose = {
- .size = htonl (sizeof (purpose)),
- .purpose = htonl (TALER_SIGNATURE_WALLET_ACCOUNT_SETUP)
+ struct TALER_AccountSetupRequestSignaturePS asap = {
+ .purpose.size = htonl (sizeof (asap)),
+ .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_ACCOUNT_SETUP)
};
- return GNUNET_CRYPTO_eddsa_verify_ (
+ TALER_amount_hton (&asap.threshold,
+ balance_threshold);
+ return GNUNET_CRYPTO_eddsa_verify (
TALER_SIGNATURE_WALLET_ACCOUNT_SETUP,
- &purpose,
+ &asap,
&reserve_sig->eddsa_signature,
&reserve_pub->eddsa_pub);
}
@@ -641,6 +673,7 @@ TALER_wallet_account_setup_verify (
GNUNET_NETWORK_STRUCT_BEGIN
+
/**
* Response by which a wallet requests a full
* reserve history and indicates it is willing