diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index d81f5a71d..1beada699 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 3758792ae..ed985938b 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 bc1625992..5aef4ac3e 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,