[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: add function for purse status si
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: add function for purse status signing |
Date: |
Sat, 07 May 2022 23:28:01 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 2d84d7f6 add function for purse status signing
2d84d7f6 is described below
commit 2d84d7f6ddce69b5c1d4d44a16a9aa0663fd4eba
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat May 7 23:27:56 2022 +0200
add function for purse status signing
---
src/include/taler_crypto_lib.h | 19 +++++++++
src/include/taler_signatures.h | 8 +++-
src/util/exchange_signatures.c | 89 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 115 insertions(+), 1 deletion(-)
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 1ee080ab..cf160c68 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -3976,6 +3976,25 @@ TALER_exchange_online_purse_merged_verify (
const struct TALER_ExchangeSignatureP *sig);
+enum TALER_ErrorCode
+TALER_exchange_purse_status_sign (
+ TALER_ExchangeSignCallback scb,
+ struct GNUNET_TIME_Timestamp merge_timestamp,
+ struct GNUNET_TIME_Timestamp deposit_timestamp,
+ const struct TALER_Amount *balance,
+ struct TALER_ExchangePublicKeyP *pub,
+ struct TALER_ExchangeSignatureP *sig);
+
+
+enum GNUNET_GenericReturnValue
+TALER_exchange_purse_status_verify (
+ struct GNUNET_TIME_Timestamp merge_timestamp,
+ struct GNUNET_TIME_Timestamp deposit_timestamp,
+ const struct TALER_Amount *balance,
+ const struct TALER_ExchangePublicKeyP *exchange_pub,
+ const struct TALER_ExchangeSignatureP *exchange_sig);
+
+
/* ********************* offline signing ************************** */
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 9897082d..57c84b50 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -189,6 +189,13 @@
*/
#define TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_MERGED 1046
+/**
+ * Purpose for the state of a purse, signed by the exchange's signing
+ * key.
+ */
+#define TALER_SIGNATURE_EXCHANGE_PURSE_STATUS 1047
+
+
/**********************/
/* Auditor signatures */
/**********************/
@@ -383,5 +390,4 @@
#define TALER_SIGNATURE_SYNC_BACKUP_UPLOAD 1450
-
#endif
diff --git a/src/util/exchange_signatures.c b/src/util/exchange_signatures.c
index d6214ab3..41f2b61a 100644
--- a/src/util/exchange_signatures.c
+++ b/src/util/exchange_signatures.c
@@ -1505,4 +1505,93 @@ TALER_exchange_online_purse_merged_verify (
}
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * @brief Format used to generate the signature on a purse status
+ * from the exchange.
+ */
+struct TALER_PurseStatusPS
+{
+ /**
+ * Purpose must be #TALER_SIGNATURE_EXCHANGE_PURSE_STATUS. Signed
+ * by a `struct TALER_ExchangePublicKeyP` using EdDSA.
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+ /**
+ * Time when the purse was merged, possibly 'never'.
+ */
+ struct GNUNET_TIME_TimestampNBO merge_timestamp;
+
+ /**
+ * Time when the purse was deposited last, possibly 'never'.
+ */
+ struct GNUNET_TIME_TimestampNBO deposit_timestamp;
+
+ /**
+ * Amount deposited in total in the purse without fees.
+ * May be possibly less than the target amount.
+ */
+ struct TALER_AmountNBO balance;
+
+};
+
+GNUNET_NETWORK_STRUCT_END
+
+
+enum TALER_ErrorCode
+TALER_exchange_purse_status_sign (
+ TALER_ExchangeSignCallback scb,
+ struct GNUNET_TIME_Timestamp merge_timestamp,
+ struct GNUNET_TIME_Timestamp deposit_timestamp,
+ const struct TALER_Amount *balance,
+ struct TALER_ExchangePublicKeyP *pub,
+ struct TALER_ExchangeSignatureP *sig)
+{
+ struct TALER_PurseStatusPS dcs = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_PURSE_STATUS),
+ .purpose.size = htonl (sizeof (dcs)),
+ .merge_timestamp = GNUNET_TIME_timestamp_hton (merge_timestamp),
+ .deposit_timestamp = GNUNET_TIME_timestamp_hton (deposit_timestamp)
+ };
+
+ TALER_amount_hton (&dcs.balance,
+ balance);
+ return scb (&dcs.purpose,
+ pub,
+ sig);
+}
+
+
+enum GNUNET_GenericReturnValue
+TALER_exchange_online_purse_status_verify (
+ struct GNUNET_TIME_Timestamp merge_timestamp,
+ struct GNUNET_TIME_Timestamp deposit_timestamp,
+ const struct TALER_Amount *balance,
+ const struct TALER_ExchangePublicKeyP *exchange_pub,
+ const struct TALER_ExchangeSignatureP *exchange_sig)
+{
+ struct TALER_PurseStatusPS dcs = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_PURSE_STATUS),
+ .purpose.size = htonl (sizeof (dcs)),
+ .merge_timestamp = GNUNET_TIME_timestamp_hton (merge_timestamp),
+ .deposit_timestamp = GNUNET_TIME_timestamp_hton (deposit_timestamp)
+ };
+
+ TALER_amount_hton (&dcs.balance,
+ balance);
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_PURSE_STATUS,
+ &dcs,
+ &exchange_sig->eddsa_signature,
+ &exchange_pub->eddsa_pub))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
/* end of exchange_signatures.c */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: add function for purse status signing,
gnunet <=