gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: add signing/verifying functions


From: gnunet
Subject: [taler-exchange] branch master updated: add signing/verifying functions for global fees
Date: Sat, 05 Mar 2022 12:04:16 +0100

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 43f8ab6b add signing/verifying functions for global fees
43f8ab6b is described below

commit 43f8ab6b48d6a51988c85fdc1bcd4f9d4f1a7a01
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Mar 5 12:04:13 2022 +0100

    add signing/verifying functions for global fees
---
 src/include/taler_crypto_lib.h | 37 ++++++++++++++++++++++++++++++++
 src/include/taler_signatures.h | 36 +++++++++++++++++++++++++++++++
 src/util/offline_signatures.c  | 48 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)

diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index d81f5a71..1beada69 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -3270,6 +3270,43 @@ TALER_exchange_offline_wire_fee_verify (
   const struct TALER_MasterSignatureP *master_sig);
 
 
+/**
+ * Create global fees signature.
+ *
+ * @param start_time when do the fees start to apply
+ * @param end_time when do the fees start to apply
+ * @param fees the global fees
+ * @param master_priv private key to sign with
+ * @param[out] master_sig where to write the signature
+ */
+void
+TALER_exchange_offline_global_fee_sign (
+  struct GNUNET_TIME_Timestamp start_time,
+  struct GNUNET_TIME_Timestamp end_time,
+  const struct TALER_GlobalFeeSet *fees,
+  const struct TALER_MasterPrivateKeyP *master_priv,
+  struct TALER_MasterSignatureP *master_sig);
+
+
+/**
+ * Verify global fees signature.
+ *
+ * @param start_time when do the fees start to apply
+ * @param end_time when do the fees start to apply
+ * @param fees the global fees
+ * @param master_pub public key to verify against
+ * @param master_sig the signature the signature
+ * @return #GNUNET_OK if the signature is valid
+ */
+enum GNUNET_GenericReturnValue
+TALER_exchange_offline_global_fee_verify (
+  struct GNUNET_TIME_Timestamp start_time,
+  struct GNUNET_TIME_Timestamp end_time,
+  const struct TALER_GlobalFeeSet *fees,
+  const struct TALER_MasterPublicKeyP *master_pub,
+  const struct TALER_MasterSignatureP *master_sig);
+
+
 /**
  * Create wire account addition signature.
  *
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 3758792a..ed985938 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -56,6 +56,12 @@
  */
 #define TALER_SIGNATURE_MASTER_ADD_WIRE 1021
 
+/**
+ * Signature over global set of fees charged by the
+ * exchange.
+ */
+#define TALER_SIGNATURE_MASTER_GLOBAL_FEES 1022
+
 /**
  * Remove payto URI from the list of our wire methods.
  */
@@ -1250,6 +1256,36 @@ struct TALER_MasterWireFeePS
 };
 
 
+/**
+ * Global fees charged by the exchange independent of
+ * denomination or wire method.
+ */
+struct TALER_MasterGlobalFeePS
+{
+
+  /**
+   * Purpose is #TALER_SIGNATURE_MASTER_GLOBAL_FEES.
+   */
+  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+  /**
+   * Start date when the fee goes into effect.
+   */
+  struct GNUNET_TIME_TimestampNBO start_date;
+
+  /**
+   * End date when the fee stops being in effect (exclusive)
+   */
+  struct GNUNET_TIME_TimestampNBO end_date;
+
+  /**
+   * Fee charged to the merchant per wire transfer.
+   */
+  struct TALER_GlobalFeeSetNBOP fees;
+
+};
+
+
 /**
  * @brief Message confirming that a denomination key was revoked.
  */
diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c
index bc162599..5aef4ac3 100644
--- a/src/util/offline_signatures.c
+++ b/src/util/offline_signatures.c
@@ -472,6 +472,54 @@ TALER_exchange_offline_wire_fee_verify (
 }
 
 
+void
+TALER_exchange_offline_global_fee_sign (
+  struct GNUNET_TIME_Timestamp start_time,
+  struct GNUNET_TIME_Timestamp end_time,
+  const struct TALER_GlobalFeeSet *fees,
+  const struct TALER_MasterPrivateKeyP *master_priv,
+  struct TALER_MasterSignatureP *master_sig)
+{
+  struct TALER_MasterGlobalFeePS kv = {
+    .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_GLOBAL_FEES),
+    .purpose.size = htonl (sizeof (kv)),
+    .start_date = GNUNET_TIME_timestamp_hton (start_time),
+    .end_date = GNUNET_TIME_timestamp_hton (end_time),
+  };
+
+  TALER_global_fee_set_hton (&kv.fees,
+                             fees);
+  GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
+                            &kv,
+                            &master_sig->eddsa_signature);
+}
+
+
+enum GNUNET_GenericReturnValue
+TALER_exchange_offline_global_fee_verify (
+  struct GNUNET_TIME_Timestamp start_time,
+  struct GNUNET_TIME_Timestamp end_time,
+  const struct TALER_GlobalFeeSet *fees,
+  const struct TALER_MasterPublicKeyP *master_pub,
+  const struct TALER_MasterSignatureP *master_sig)
+{
+  struct TALER_MasterGlobalFeePS wf = {
+    .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_GLOBAL_FEES),
+    .purpose.size = htonl (sizeof (wf)),
+    .start_date = GNUNET_TIME_timestamp_hton (start_time),
+    .end_date = GNUNET_TIME_timestamp_hton (end_time)
+  };
+
+  TALER_global_fee_set_hton (&wf.fees,
+                             fees);
+  return
+    GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_GLOBAL_FEES,
+                                &wf,
+                                &master_sig->eddsa_signature,
+                                &master_pub->eddsa_pub);
+}
+
+
 void
 TALER_exchange_offline_extension_config_hash_sign (
   const struct TALER_ExtensionConfigHashP *h_config,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]