aboutsummaryrefslogtreecommitdiff
path: root/src/util/wallet_signatures.c
diff options
context:
space:
mode:
authorChristian Blättler <blatc2@bfh.ch>2024-04-25 10:25:25 +0200
committerChristian Blättler <blatc2@bfh.ch>2024-04-25 10:25:25 +0200
commit8fb9b71939248c9323962e06f03768b34f8fa108 (patch)
treee5c09b8d895f020fcb7624bca6d0f5cda5dca600 /src/util/wallet_signatures.c
parent8b159830567006f8faad263bd3084acacd2d72cd (diff)
downloadexchange-8fb9b71939248c9323962e06f03768b34f8fa108.tar.xz
add token use signature functions
Diffstat (limited to 'src/util/wallet_signatures.c')
-rw-r--r--src/util/wallet_signatures.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c
index 0b6ab5432..7b1a539ef 100644
--- a/src/util/wallet_signatures.c
+++ b/src/util/wallet_signatures.c
@@ -23,6 +23,7 @@
#include "taler_util.h"
#include "taler_signatures.h"
#include <gnunet/gnunet_common.h>
+#include <stdint.h>
GNUNET_NETWORK_STRUCT_BEGIN
@@ -1827,4 +1828,73 @@ TALER_wallet_econtract_upload_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Message signed by wallet to confirm usage of a coin for a transaction.
+ */
+struct TALER_TokenUseRequestPS
+{
+
+ /**
+ * Purpose is #TALER_SIGNATURE_WALLET_TOKEN_USE
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+ /**
+ * Hash over the contract for which this token is used.
+ */
+ struct TALER_PrivateContractHashP h_contract_terms GNUNET_PACKED;
+
+ /**
+ * Hash over a JSON containing data provided by the
+ * wallet to complete the contract upon payment.
+ */
+ struct GNUNET_HashCode wallet_data_hash;
+
+};
+
+GNUNET_NETWORK_STRUCT_END
+
+
+void
+TALER_wallet_token_use_sign (
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct GNUNET_HashCode *wallet_data_hash,
+ const struct TALER_TokenUsePrivateKeyP *token_use_priv,
+ struct TALER_TokenUseSignatureP *token_sig)
+{
+ struct TALER_TokenUseRequestPS tur = {
+ .purpose.size = htonl (sizeof (tur)),
+ .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_TOKEN_USE),
+ .h_contract_terms = *h_contract_terms,
+ .wallet_data_hash = *wallet_data_hash
+ };
+
+ GNUNET_CRYPTO_eddsa_sign (&token_use_priv->private_key,
+ &tur,
+ &token_sig->signature);
+}
+
+
+enum GNUNET_GenericReturnValue
+TALER_wallet_token_use_verify (
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct GNUNET_HashCode *wallet_data_hash,
+ const struct TALER_TokenUsePublicKeyP *token_use_pub,
+ const struct TALER_TokenUseSignatureP *token_sig)
+{
+ struct TALER_TokenUseRequestPS tur = {
+ .purpose.size = htonl (sizeof (tur)),
+ .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_TOKEN_USE),
+ .h_contract_terms = *h_contract_terms,
+ .wallet_data_hash = *wallet_data_hash
+ };
+
+ return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_TOKEN_USE,
+ &tur,
+ &token_sig->signature,
+ &token_use_pub->public_key);
+}
+
/* end of wallet_signatures.c */