summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-07-29 09:21:38 +0200
committerChristian Grothoff <christian@grothoff.org>2022-07-29 09:21:38 +0200
commitc1b43de5b4b5a1b4512c6e1a6f87b830df240fc9 (patch)
tree07a3f553454ebe8496c911274ca6a672b5b640f7 /src/util
parentdc26b2db4cecbca155f5df2678f60aadf13c3bd4 (diff)
downloadexchange-c1b43de5b4b5a1b4512c6e1a6f87b830df240fc9.tar.gz
exchange-c1b43de5b4b5a1b4512c6e1a6f87b830df240fc9.tar.bz2
exchange-c1b43de5b4b5a1b4512c6e1a6f87b830df240fc9.zip
add offline signature to drain profits (#4960)
Diffstat (limited to 'src/util')
-rw-r--r--src/util/offline_signatures.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c
index 54da2b114..108c665ef 100644
--- a/src/util/offline_signatures.c
+++ b/src/util/offline_signatures.c
@@ -1145,4 +1145,88 @@ TALER_exchange_offline_partner_details_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Message signed by account to drain profits
+ * from the escrow account of the exchange.
+ */
+struct TALER_DrainProfitPS
+{
+
+ /**
+ * Purpose is #TALER_SIGNATURE_MASTER_DRAIN_PROFITS
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+ struct TALER_WireTransferIdentifierRawP wtid;
+ struct GNUNET_TIME_TimestampNBO date;
+ struct TALER_AmountNBO amount;
+ struct GNUNET_HashCode h_section;
+ struct TALER_PaytoHashP h_payto;
+};
+
+GNUNET_NETWORK_STRUCT_END
+
+
+void
+TALER_exchange_offline_profit_drain_sign (
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ struct GNUNET_TIME_Timestamp date,
+ const struct TALER_Amount *amount,
+ const char *account_section,
+ const char *payto_uri,
+ const struct TALER_MasterPrivateKeyP *master_priv,
+ struct TALER_MasterSignatureP *master_sig)
+{
+ struct TALER_DrainProfitPS wd = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DRAIN_PROFIT),
+ .purpose.size = htonl (sizeof (wd)),
+ .wtid = *wtid,
+ .date = GNUNET_TIME_timestamp_hton (date),
+ };
+
+ GNUNET_CRYPTO_hash (account_section,
+ strlen (account_section) + 1,
+ &wd.h_section);
+ TALER_payto_hash (payto_uri,
+ &wd.h_payto);
+ TALER_amount_hton (&wd.amount,
+ amount);
+ GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
+ &wd,
+ &master_sig->eddsa_signature);
+}
+
+
+enum GNUNET_GenericReturnValue
+TALER_exchange_offline_profit_drain_verify (
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ struct GNUNET_TIME_Timestamp date,
+ const struct TALER_Amount *amount,
+ const char *account_section,
+ const char *payto_uri,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct TALER_MasterSignatureP *master_sig)
+{
+ struct TALER_DrainProfitPS wd = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DRAIN_PROFIT),
+ .purpose.size = htonl (sizeof (wd)),
+ .wtid = *wtid,
+ .date = GNUNET_TIME_timestamp_hton (date),
+ };
+
+ GNUNET_CRYPTO_hash (account_section,
+ strlen (account_section) + 1,
+ &wd.h_section);
+ TALER_payto_hash (payto_uri,
+ &wd.h_payto);
+ TALER_amount_hton (&wd.amount,
+ amount);
+ return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DRAIN_PROFIT,
+ &wd,
+ &master_sig->eddsa_signature,
+ &master_pub->eddsa_pub);
+}
+
+
/* end of offline_signatures.c */