LCOV - code coverage report
Current view: top level - util - offline_signatures.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 13 237 5.5 %
Date: 2022-08-25 06:15:09 Functions: 2 28 7.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2020-2022 Taler Systems SA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify it under the
       6             :   terms of the GNU General Public License as published by the Free Software
       7             :   Foundation; either version 3, or (at your option) any later version.
       8             : 
       9             :   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10             :   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11             :   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      12             : 
      13             :   You should have received a copy of the GNU General Public License along with
      14             :   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15             : */
      16             : /**
      17             :  * @file offline_signatures.c
      18             :  * @brief Utility functions for Taler exchange offline signatures
      19             :  * @author Christian Grothoff
      20             :  */
      21             : #include "platform.h"
      22             : #include "taler_util.h"
      23             : #include "taler_signatures.h"
      24             : 
      25             : 
      26             : GNUNET_NETWORK_STRUCT_BEGIN
      27             : 
      28             : /**
      29             :  * @brief Signature made by the exchange offline key over the information of
      30             :  * an auditor to be added to the exchange's set of auditors.
      31             :  */
      32             : struct TALER_MasterAddAuditorPS
      33             : {
      34             : 
      35             :   /**
      36             :    * Purpose is #TALER_SIGNATURE_MASTER_ADD_AUDITOR.   Signed
      37             :    * by a `struct TALER_MasterPublicKeyP` using EdDSA.
      38             :    */
      39             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
      40             : 
      41             :   /**
      42             :    * Time of the change.
      43             :    */
      44             :   struct GNUNET_TIME_TimestampNBO start_date;
      45             : 
      46             :   /**
      47             :    * Public key of the auditor.
      48             :    */
      49             :   struct TALER_AuditorPublicKeyP auditor_pub;
      50             : 
      51             :   /**
      52             :    * Hash over the auditor's URL.
      53             :    */
      54             :   struct GNUNET_HashCode h_auditor_url GNUNET_PACKED;
      55             : };
      56             : GNUNET_NETWORK_STRUCT_END
      57             : 
      58             : 
      59             : void
      60           0 : TALER_exchange_offline_auditor_add_sign (
      61             :   const struct TALER_AuditorPublicKeyP *auditor_pub,
      62             :   const char *auditor_url,
      63             :   struct GNUNET_TIME_Timestamp start_date,
      64             :   const struct TALER_MasterPrivateKeyP *master_priv,
      65             :   struct TALER_MasterSignatureP *master_sig)
      66             : {
      67           0 :   struct TALER_MasterAddAuditorPS kv = {
      68           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_AUDITOR),
      69           0 :     .purpose.size = htonl (sizeof (kv)),
      70           0 :     .start_date = GNUNET_TIME_timestamp_hton (start_date),
      71             :     .auditor_pub = *auditor_pub,
      72             :   };
      73             : 
      74           0 :   GNUNET_CRYPTO_hash (auditor_url,
      75           0 :                       strlen (auditor_url) + 1,
      76             :                       &kv.h_auditor_url);
      77           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
      78             :                             &kv,
      79             :                             &master_sig->eddsa_signature);
      80           0 : }
      81             : 
      82             : 
      83             : enum GNUNET_GenericReturnValue
      84           0 : TALER_exchange_offline_auditor_add_verify (
      85             :   const struct TALER_AuditorPublicKeyP *auditor_pub,
      86             :   const char *auditor_url,
      87             :   struct GNUNET_TIME_Timestamp start_date,
      88             :   const struct TALER_MasterPublicKeyP *master_pub,
      89             :   const struct TALER_MasterSignatureP *master_sig)
      90             : {
      91           0 :   struct TALER_MasterAddAuditorPS aa = {
      92           0 :     .purpose.purpose = htonl (
      93             :       TALER_SIGNATURE_MASTER_ADD_AUDITOR),
      94           0 :     .purpose.size = htonl (sizeof (aa)),
      95           0 :     .start_date = GNUNET_TIME_timestamp_hton (start_date),
      96             :     .auditor_pub = *auditor_pub
      97             :   };
      98             : 
      99           0 :   GNUNET_CRYPTO_hash (auditor_url,
     100           0 :                       strlen (auditor_url) + 1,
     101             :                       &aa.h_auditor_url);
     102           0 :   return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_ADD_AUDITOR,
     103             :                                      &aa,
     104             :                                      &master_sig->eddsa_signature,
     105             :                                      &master_pub->eddsa_pub);
     106             : }
     107             : 
     108             : 
     109             : GNUNET_NETWORK_STRUCT_BEGIN
     110             : 
     111             : /**
     112             :  * @brief Signature made by the exchange offline key over the information of
     113             :  * an auditor to be removed from the exchange's set of auditors.
     114             :  */
     115             : struct TALER_MasterDelAuditorPS
     116             : {
     117             : 
     118             :   /**
     119             :    * Purpose is #TALER_SIGNATURE_MASTER_DEL_AUDITOR.   Signed
     120             :    * by a `struct TALER_MasterPublicKeyP` using EdDSA.
     121             :    */
     122             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     123             : 
     124             :   /**
     125             :    * Time of the change.
     126             :    */
     127             :   struct GNUNET_TIME_TimestampNBO end_date;
     128             : 
     129             :   /**
     130             :    * Public key of the auditor.
     131             :    */
     132             :   struct TALER_AuditorPublicKeyP auditor_pub;
     133             : 
     134             : };
     135             : GNUNET_NETWORK_STRUCT_END
     136             : 
     137             : 
     138             : void
     139           0 : TALER_exchange_offline_auditor_del_sign (
     140             :   const struct TALER_AuditorPublicKeyP *auditor_pub,
     141             :   struct GNUNET_TIME_Timestamp end_date,
     142             :   const struct TALER_MasterPrivateKeyP *master_priv,
     143             :   struct TALER_MasterSignatureP *master_sig)
     144             : {
     145           0 :   struct TALER_MasterDelAuditorPS kv = {
     146           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DEL_AUDITOR),
     147           0 :     .purpose.size = htonl (sizeof (kv)),
     148           0 :     .end_date = GNUNET_TIME_timestamp_hton (end_date),
     149             :     .auditor_pub = *auditor_pub,
     150             :   };
     151             : 
     152           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     153             :                             &kv,
     154             :                             &master_sig->eddsa_signature);
     155           0 : }
     156             : 
     157             : 
     158             : enum GNUNET_GenericReturnValue
     159           0 : TALER_exchange_offline_auditor_del_verify (
     160             :   const struct TALER_AuditorPublicKeyP *auditor_pub,
     161             :   struct GNUNET_TIME_Timestamp end_date,
     162             :   const struct TALER_MasterPublicKeyP *master_pub,
     163             :   const struct TALER_MasterSignatureP *master_sig)
     164             : {
     165           0 :   struct TALER_MasterDelAuditorPS da = {
     166           0 :     .purpose.purpose = htonl (
     167             :       TALER_SIGNATURE_MASTER_DEL_AUDITOR),
     168           0 :     .purpose.size = htonl (sizeof (da)),
     169           0 :     .end_date = GNUNET_TIME_timestamp_hton (end_date),
     170             :     .auditor_pub = *auditor_pub
     171             :   };
     172             : 
     173           0 :   return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DEL_AUDITOR,
     174             :                                      &da,
     175             :                                      &master_sig->eddsa_signature,
     176             :                                      &master_pub->eddsa_pub);
     177             : }
     178             : 
     179             : 
     180             : GNUNET_NETWORK_STRUCT_BEGIN
     181             : 
     182             : /**
     183             :  * @brief Message confirming that a denomination key was revoked.
     184             :  */
     185             : struct TALER_MasterDenominationKeyRevocationPS
     186             : {
     187             :   /**
     188             :    * Purpose is #TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED.
     189             :    */
     190             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     191             : 
     192             :   /**
     193             :    * Hash of the denomination key.
     194             :    */
     195             :   struct TALER_DenominationHashP h_denom_pub;
     196             : 
     197             : };
     198             : 
     199             : GNUNET_NETWORK_STRUCT_END
     200             : 
     201             : 
     202             : void
     203           0 : TALER_exchange_offline_denomination_revoke_sign (
     204             :   const struct TALER_DenominationHashP *h_denom_pub,
     205             :   const struct TALER_MasterPrivateKeyP *master_priv,
     206             :   struct TALER_MasterSignatureP *master_sig)
     207             : {
     208           0 :   struct TALER_MasterDenominationKeyRevocationPS rm = {
     209           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED),
     210           0 :     .purpose.size = htonl (sizeof (rm)),
     211             :     .h_denom_pub = *h_denom_pub
     212             :   };
     213             : 
     214           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     215             :                             &rm,
     216             :                             &master_sig->eddsa_signature);
     217           0 : }
     218             : 
     219             : 
     220             : enum GNUNET_GenericReturnValue
     221           0 : TALER_exchange_offline_denomination_revoke_verify (
     222             :   const struct TALER_DenominationHashP *h_denom_pub,
     223             :   const struct TALER_MasterPublicKeyP *master_pub,
     224             :   const struct TALER_MasterSignatureP *master_sig)
     225             : {
     226           0 :   struct TALER_MasterDenominationKeyRevocationPS kr = {
     227           0 :     .purpose.purpose = htonl (
     228             :       TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED),
     229           0 :     .purpose.size = htonl (sizeof (kr)),
     230             :     .h_denom_pub = *h_denom_pub
     231             :   };
     232             : 
     233           0 :   return GNUNET_CRYPTO_eddsa_verify (
     234             :     TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED,
     235             :     &kr,
     236             :     &master_sig->eddsa_signature,
     237             :     &master_pub->eddsa_pub);
     238             : }
     239             : 
     240             : 
     241             : GNUNET_NETWORK_STRUCT_BEGIN
     242             : 
     243             : /**
     244             :  * @brief Message confirming that an exchange online signing key was revoked.
     245             :  */
     246             : struct TALER_MasterSigningKeyRevocationPS
     247             : {
     248             :   /**
     249             :    * Purpose is #TALER_SIGNATURE_MASTER_SIGNING_KEY_REVOKED.
     250             :    */
     251             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     252             : 
     253             :   /**
     254             :    * The exchange's public key.
     255             :    */
     256             :   struct TALER_ExchangePublicKeyP exchange_pub;
     257             : 
     258             : };
     259             : 
     260             : GNUNET_NETWORK_STRUCT_END
     261             : 
     262             : 
     263             : void
     264           0 : TALER_exchange_offline_signkey_revoke_sign (
     265             :   const struct TALER_ExchangePublicKeyP *exchange_pub,
     266             :   const struct TALER_MasterPrivateKeyP *master_priv,
     267             :   struct TALER_MasterSignatureP *master_sig)
     268             : {
     269           0 :   struct TALER_MasterSigningKeyRevocationPS kv = {
     270           0 :     .purpose.purpose = htonl (
     271             :       TALER_SIGNATURE_MASTER_SIGNING_KEY_REVOKED),
     272           0 :     .purpose.size = htonl (sizeof (kv)),
     273             :     .exchange_pub = *exchange_pub
     274             :   };
     275             : 
     276           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     277             :                             &kv,
     278             :                             &master_sig->eddsa_signature);
     279           0 : }
     280             : 
     281             : 
     282             : enum GNUNET_GenericReturnValue
     283           0 : TALER_exchange_offline_signkey_revoke_verify (
     284             :   const struct TALER_ExchangePublicKeyP *exchange_pub,
     285             :   const struct TALER_MasterPublicKeyP *master_pub,
     286             :   const struct TALER_MasterSignatureP *master_sig)
     287             : {
     288           0 :   struct TALER_MasterSigningKeyRevocationPS rm = {
     289           0 :     .purpose.purpose = htonl (
     290             :       TALER_SIGNATURE_MASTER_SIGNING_KEY_REVOKED),
     291           0 :     .purpose.size = htonl (sizeof (rm)),
     292             :     .exchange_pub = *exchange_pub
     293             :   };
     294             : 
     295           0 :   return GNUNET_CRYPTO_eddsa_verify (
     296             :     TALER_SIGNATURE_MASTER_SIGNING_KEY_REVOKED,
     297             :     &rm,
     298             :     &master_sig->eddsa_signature,
     299             :     &master_pub->eddsa_pub);
     300             : }
     301             : 
     302             : 
     303             : GNUNET_NETWORK_STRUCT_BEGIN
     304             : 
     305             : /**
     306             :  * @brief Information about a signing key of the exchange.  Signing keys are used
     307             :  * to sign exchange messages other than coins, i.e. to confirm that a
     308             :  * deposit was successful or that a refresh was accepted.
     309             :  */
     310             : struct TALER_ExchangeSigningKeyValidityPS
     311             : {
     312             : 
     313             :   /**
     314             :    * Purpose is #TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY.
     315             :    */
     316             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     317             : 
     318             :   /**
     319             :    * When does this signing key begin to be valid?
     320             :    */
     321             :   struct GNUNET_TIME_TimestampNBO start;
     322             : 
     323             :   /**
     324             :    * When does this signing key expire? Note: This is currently when
     325             :    * the Exchange will definitively stop using it.  Signatures made with
     326             :    * the key remain valid until @e end.  When checking validity periods,
     327             :    * clients should allow for some overlap between keys and tolerate
     328             :    * the use of either key during the overlap time (due to the
     329             :    * possibility of clock skew).
     330             :    */
     331             :   struct GNUNET_TIME_TimestampNBO expire;
     332             : 
     333             :   /**
     334             :    * When do signatures with this signing key become invalid?  After
     335             :    * this point, these signatures cannot be used in (legal) disputes
     336             :    * anymore, as the Exchange is then allowed to destroy its side of the
     337             :    * evidence.  @e end is expected to be significantly larger than @e
     338             :    * expire (by a year or more).
     339             :    */
     340             :   struct GNUNET_TIME_TimestampNBO end;
     341             : 
     342             :   /**
     343             :    * The public online signing key that the exchange will use
     344             :    * between @e start and @e expire.
     345             :    */
     346             :   struct TALER_ExchangePublicKeyP signkey_pub;
     347             : };
     348             : 
     349             : GNUNET_NETWORK_STRUCT_END
     350             : 
     351             : 
     352             : void
     353           0 : TALER_exchange_offline_signkey_validity_sign (
     354             :   const struct TALER_ExchangePublicKeyP *exchange_pub,
     355             :   struct GNUNET_TIME_Timestamp start_sign,
     356             :   struct GNUNET_TIME_Timestamp end_sign,
     357             :   struct GNUNET_TIME_Timestamp end_legal,
     358             :   const struct TALER_MasterPrivateKeyP *master_priv,
     359             :   struct TALER_MasterSignatureP *master_sig)
     360             : {
     361           0 :   struct TALER_ExchangeSigningKeyValidityPS skv = {
     362           0 :     .purpose.purpose = htonl (
     363             :       TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY),
     364           0 :     .purpose.size = htonl (sizeof (skv)),
     365           0 :     .start = GNUNET_TIME_timestamp_hton (start_sign),
     366           0 :     .expire = GNUNET_TIME_timestamp_hton (end_sign),
     367           0 :     .end = GNUNET_TIME_timestamp_hton (end_legal),
     368             :     .signkey_pub = *exchange_pub
     369             :   };
     370             : 
     371           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     372             :                             &skv,
     373             :                             &master_sig->eddsa_signature);
     374           0 : }
     375             : 
     376             : 
     377             : enum GNUNET_GenericReturnValue
     378           0 : TALER_exchange_offline_signkey_validity_verify (
     379             :   const struct TALER_ExchangePublicKeyP *exchange_pub,
     380             :   struct GNUNET_TIME_Timestamp start_sign,
     381             :   struct GNUNET_TIME_Timestamp end_sign,
     382             :   struct GNUNET_TIME_Timestamp end_legal,
     383             :   const struct TALER_MasterPublicKeyP *master_pub,
     384             :   const struct TALER_MasterSignatureP *master_sig)
     385             : {
     386           0 :   struct TALER_ExchangeSigningKeyValidityPS skv = {
     387           0 :     .purpose.purpose = htonl (
     388             :       TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY),
     389           0 :     .purpose.size = htonl (sizeof (skv)),
     390           0 :     .start = GNUNET_TIME_timestamp_hton (start_sign),
     391           0 :     .expire = GNUNET_TIME_timestamp_hton (end_sign),
     392           0 :     .end = GNUNET_TIME_timestamp_hton (end_legal),
     393             :     .signkey_pub = *exchange_pub
     394             :   };
     395             : 
     396             :   return
     397           0 :     GNUNET_CRYPTO_eddsa_verify (
     398             :     TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY,
     399             :     &skv,
     400             :     &master_sig->eddsa_signature,
     401             :     &master_pub->eddsa_pub);
     402             : }
     403             : 
     404             : 
     405             : GNUNET_NETWORK_STRUCT_BEGIN
     406             : 
     407             : /**
     408             :  * @brief Information about a denomination key. Denomination keys
     409             :  * are used to sign coins of a certain value into existence.
     410             :  */
     411             : struct TALER_DenominationKeyValidityPS
     412             : {
     413             : 
     414             :   /**
     415             :    * Purpose is #TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY.
     416             :    */
     417             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     418             : 
     419             :   /**
     420             :    * The long-term offline master key of the exchange that was
     421             :    * used to create @e signature.
     422             :    *
     423             :    * Note: This member is not strictly required, but here for
     424             :    * backwards-compatibility. If we ever again badly break
     425             :    * compatibility, we might want to remove it.
     426             :    */
     427             :   struct TALER_MasterPublicKeyP master;
     428             : 
     429             :   /**
     430             :    * Start time of the validity period for this key.
     431             :    */
     432             :   struct GNUNET_TIME_TimestampNBO start;
     433             : 
     434             :   /**
     435             :    * The exchange will sign fresh coins between @e start and this time.
     436             :    * @e expire_withdraw will be somewhat larger than @e start to
     437             :    * ensure a sufficiently large anonymity set, while also allowing
     438             :    * the Exchange to limit the financial damage in case of a key being
     439             :    * compromised.  Thus, exchanges with low volume are expected to have a
     440             :    * longer withdraw period (@e expire_withdraw - @e start) than exchanges
     441             :    * with high transaction volume.  The period may also differ between
     442             :    * types of coins.  A exchange may also have a few denomination keys
     443             :    * with the same value with overlapping validity periods, to address
     444             :    * issues such as clock skew.
     445             :    */
     446             :   struct GNUNET_TIME_TimestampNBO expire_withdraw;
     447             : 
     448             :   /**
     449             :    * Coins signed with the denomination key must be spent or refreshed
     450             :    * between @e start and this expiration time.  After this time, the
     451             :    * exchange will refuse transactions involving this key as it will
     452             :    * "drop" the table with double-spending information (shortly after)
     453             :    * this time.  Note that wallets should refresh coins significantly
     454             :    * before this time to be on the safe side.  @e expire_deposit must be
     455             :    * significantly larger than @e expire_withdraw (by months or even
     456             :    * years).
     457             :    */
     458             :   struct GNUNET_TIME_TimestampNBO expire_deposit;
     459             : 
     460             :   /**
     461             :    * When do signatures with this denomination key become invalid?
     462             :    * After this point, these signatures cannot be used in (legal)
     463             :    * disputes anymore, as the Exchange is then allowed to destroy its side
     464             :    * of the evidence.  @e expire_legal is expected to be significantly
     465             :    * larger than @e expire_deposit (by a year or more).
     466             :    */
     467             :   struct GNUNET_TIME_TimestampNBO expire_legal;
     468             : 
     469             :   /**
     470             :    * The value of the coins signed with this denomination key.
     471             :    */
     472             :   struct TALER_AmountNBO value;
     473             : 
     474             :   /**
     475             :    * Fees for the coin.
     476             :    */
     477             :   struct TALER_DenomFeeSetNBOP fees;
     478             : 
     479             :   /**
     480             :    * Hash code of the denomination public key. (Used to avoid having
     481             :    * the variable-size RSA key in this struct.)
     482             :    */
     483             :   struct TALER_DenominationHashP denom_hash GNUNET_PACKED;
     484             : 
     485             : };
     486             : 
     487             : GNUNET_NETWORK_STRUCT_END
     488             : 
     489             : 
     490             : void
     491           0 : TALER_exchange_offline_denom_validity_sign (
     492             :   const struct TALER_DenominationHashP *h_denom_pub,
     493             :   struct GNUNET_TIME_Timestamp stamp_start,
     494             :   struct GNUNET_TIME_Timestamp stamp_expire_withdraw,
     495             :   struct GNUNET_TIME_Timestamp stamp_expire_deposit,
     496             :   struct GNUNET_TIME_Timestamp stamp_expire_legal,
     497             :   const struct TALER_Amount *coin_value,
     498             :   const struct TALER_DenomFeeSet *fees,
     499             :   const struct TALER_MasterPrivateKeyP *master_priv,
     500             :   struct TALER_MasterSignatureP *master_sig)
     501             : {
     502           0 :   struct TALER_DenominationKeyValidityPS issue = {
     503             :     .purpose.purpose
     504           0 :       = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY),
     505             :     .purpose.size
     506           0 :       = htonl (sizeof (issue)),
     507           0 :     .start = GNUNET_TIME_timestamp_hton (stamp_start),
     508           0 :     .expire_withdraw = GNUNET_TIME_timestamp_hton (stamp_expire_withdraw),
     509           0 :     .expire_deposit = GNUNET_TIME_timestamp_hton (stamp_expire_deposit),
     510           0 :     .expire_legal = GNUNET_TIME_timestamp_hton (stamp_expire_legal),
     511             :     .denom_hash = *h_denom_pub
     512             :   };
     513             : 
     514           0 :   GNUNET_CRYPTO_eddsa_key_get_public (&master_priv->eddsa_priv,
     515             :                                       &issue.master.eddsa_pub);
     516           0 :   TALER_amount_hton (&issue.value,
     517             :                      coin_value);
     518           0 :   TALER_denom_fee_set_hton (&issue.fees,
     519             :                             fees);
     520           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     521             :                             &issue,
     522             :                             &master_sig->eddsa_signature);
     523           0 : }
     524             : 
     525             : 
     526             : enum GNUNET_GenericReturnValue
     527           0 : TALER_exchange_offline_denom_validity_verify (
     528             :   const struct TALER_DenominationHashP *h_denom_pub,
     529             :   struct GNUNET_TIME_Timestamp stamp_start,
     530             :   struct GNUNET_TIME_Timestamp stamp_expire_withdraw,
     531             :   struct GNUNET_TIME_Timestamp stamp_expire_deposit,
     532             :   struct GNUNET_TIME_Timestamp stamp_expire_legal,
     533             :   const struct TALER_Amount *coin_value,
     534             :   const struct TALER_DenomFeeSet *fees,
     535             :   const struct TALER_MasterPublicKeyP *master_pub,
     536             :   const struct TALER_MasterSignatureP *master_sig)
     537             : {
     538           0 :   struct TALER_DenominationKeyValidityPS dkv = {
     539           0 :     .purpose.purpose = htonl (
     540             :       TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY),
     541           0 :     .purpose.size = htonl (sizeof (dkv)),
     542             :     .master = *master_pub,
     543           0 :     .start = GNUNET_TIME_timestamp_hton (stamp_start),
     544           0 :     .expire_withdraw = GNUNET_TIME_timestamp_hton (stamp_expire_withdraw),
     545           0 :     .expire_deposit = GNUNET_TIME_timestamp_hton (stamp_expire_deposit),
     546           0 :     .expire_legal = GNUNET_TIME_timestamp_hton (stamp_expire_legal),
     547             :     .denom_hash = *h_denom_pub
     548             :   };
     549             : 
     550           0 :   TALER_amount_hton (&dkv.value,
     551             :                      coin_value);
     552           0 :   TALER_denom_fee_set_hton (&dkv.fees,
     553             :                             fees);
     554             :   return
     555           0 :     GNUNET_CRYPTO_eddsa_verify (
     556             :     TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY,
     557             :     &dkv,
     558             :     &master_sig->eddsa_signature,
     559             :     &master_pub->eddsa_pub);
     560             : }
     561             : 
     562             : 
     563             : GNUNET_NETWORK_STRUCT_BEGIN
     564             : 
     565             : /**
     566             :  * @brief Signature made by the exchange offline key over the information of
     567             :  * a payto:// URI to be added to the exchange's set of active wire accounts.
     568             :  */
     569             : struct TALER_MasterAddWirePS
     570             : {
     571             : 
     572             :   /**
     573             :    * Purpose is #TALER_SIGNATURE_MASTER_ADD_WIRE.   Signed
     574             :    * by a `struct TALER_MasterPublicKeyP` using EdDSA.
     575             :    */
     576             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     577             : 
     578             :   /**
     579             :    * Time of the change.
     580             :    */
     581             :   struct GNUNET_TIME_TimestampNBO start_date;
     582             : 
     583             :   /**
     584             :    * Hash over the exchange's payto URI.
     585             :    */
     586             :   struct TALER_PaytoHashP h_payto GNUNET_PACKED;
     587             : };
     588             : 
     589             : GNUNET_NETWORK_STRUCT_END
     590             : 
     591             : 
     592             : void
     593           0 : TALER_exchange_offline_wire_add_sign (
     594             :   const char *payto_uri,
     595             :   struct GNUNET_TIME_Timestamp now,
     596             :   const struct TALER_MasterPrivateKeyP *master_priv,
     597             :   struct TALER_MasterSignatureP *master_sig)
     598             : {
     599           0 :   struct TALER_MasterAddWirePS kv = {
     600           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_WIRE),
     601           0 :     .purpose.size = htonl (sizeof (kv)),
     602           0 :     .start_date = GNUNET_TIME_timestamp_hton (now),
     603             :   };
     604             : 
     605           0 :   TALER_payto_hash (payto_uri,
     606             :                     &kv.h_payto);
     607           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     608             :                             &kv,
     609             :                             &master_sig->eddsa_signature);
     610           0 : }
     611             : 
     612             : 
     613             : enum GNUNET_GenericReturnValue
     614           0 : TALER_exchange_offline_wire_add_verify (
     615             :   const char *payto_uri,
     616             :   struct GNUNET_TIME_Timestamp sign_time,
     617             :   const struct TALER_MasterPublicKeyP *master_pub,
     618             :   const struct TALER_MasterSignatureP *master_sig)
     619             : {
     620           0 :   struct TALER_MasterAddWirePS aw = {
     621           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_ADD_WIRE),
     622           0 :     .purpose.size = htonl (sizeof (aw)),
     623           0 :     .start_date = GNUNET_TIME_timestamp_hton (sign_time),
     624             :   };
     625             : 
     626           0 :   TALER_payto_hash (payto_uri,
     627             :                     &aw.h_payto);
     628             :   return
     629           0 :     GNUNET_CRYPTO_eddsa_verify (
     630             :     TALER_SIGNATURE_MASTER_ADD_WIRE,
     631             :     &aw,
     632             :     &master_sig->eddsa_signature,
     633             :     &master_pub->eddsa_pub);
     634             : }
     635             : 
     636             : 
     637             : GNUNET_NETWORK_STRUCT_BEGIN
     638             : 
     639             : /**
     640             :  * @brief Signature made by the exchange offline key over the information of
     641             :  * a  wire method to be removed to the exchange's set of active accounts.
     642             :  */
     643             : struct TALER_MasterDelWirePS
     644             : {
     645             : 
     646             :   /**
     647             :    * Purpose is #TALER_SIGNATURE_MASTER_DEL_WIRE.   Signed
     648             :    * by a `struct TALER_MasterPublicKeyP` using EdDSA.
     649             :    */
     650             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     651             : 
     652             :   /**
     653             :    * Time of the change.
     654             :    */
     655             :   struct GNUNET_TIME_TimestampNBO end_date;
     656             : 
     657             :   /**
     658             :    * Hash over the exchange's payto URI.
     659             :    */
     660             :   struct TALER_PaytoHashP h_payto GNUNET_PACKED;
     661             : 
     662             : };
     663             : 
     664             : GNUNET_NETWORK_STRUCT_END
     665             : 
     666             : 
     667             : void
     668           0 : TALER_exchange_offline_wire_del_sign (
     669             :   const char *payto_uri,
     670             :   struct GNUNET_TIME_Timestamp now,
     671             :   const struct TALER_MasterPrivateKeyP *master_priv,
     672             :   struct TALER_MasterSignatureP *master_sig)
     673             : {
     674           0 :   struct TALER_MasterDelWirePS kv = {
     675           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DEL_WIRE),
     676           0 :     .purpose.size = htonl (sizeof (kv)),
     677           0 :     .end_date = GNUNET_TIME_timestamp_hton (now),
     678             :   };
     679             : 
     680           0 :   TALER_payto_hash (payto_uri,
     681             :                     &kv.h_payto);
     682           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     683             :                             &kv,
     684             :                             &master_sig->eddsa_signature);
     685           0 : }
     686             : 
     687             : 
     688             : enum GNUNET_GenericReturnValue
     689           0 : TALER_exchange_offline_wire_del_verify (
     690             :   const char *payto_uri,
     691             :   struct GNUNET_TIME_Timestamp sign_time,
     692             :   const struct TALER_MasterPublicKeyP *master_pub,
     693             :   const struct TALER_MasterSignatureP *master_sig)
     694             : {
     695           0 :   struct TALER_MasterDelWirePS aw = {
     696           0 :     .purpose.purpose = htonl (
     697             :       TALER_SIGNATURE_MASTER_DEL_WIRE),
     698           0 :     .purpose.size = htonl (sizeof (aw)),
     699           0 :     .end_date = GNUNET_TIME_timestamp_hton (sign_time),
     700             :   };
     701             : 
     702           0 :   TALER_payto_hash (payto_uri,
     703             :                     &aw.h_payto);
     704           0 :   return GNUNET_CRYPTO_eddsa_verify (
     705             :     TALER_SIGNATURE_MASTER_DEL_WIRE,
     706             :     &aw,
     707             :     &master_sig->eddsa_signature,
     708             :     &master_pub->eddsa_pub);
     709             : }
     710             : 
     711             : 
     712             : GNUNET_NETWORK_STRUCT_BEGIN
     713             : 
     714             : /**
     715             :  * @brief Information signed by the exchange's master
     716             :  * key stating the wire fee to be paid per wire transfer.
     717             :  */
     718             : struct TALER_MasterWireFeePS
     719             : {
     720             : 
     721             :   /**
     722             :    * Purpose is #TALER_SIGNATURE_MASTER_WIRE_FEES.
     723             :    */
     724             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     725             : 
     726             :   /**
     727             :    * Hash over the wire method (yes, H("x-taler-bank") or H("iban")), in lower
     728             :    * case, including 0-terminator.  Used to uniquely identify which
     729             :    * wire method these fees apply to.
     730             :    */
     731             :   struct GNUNET_HashCode h_wire_method;
     732             : 
     733             :   /**
     734             :    * Start date when the fee goes into effect.
     735             :    */
     736             :   struct GNUNET_TIME_TimestampNBO start_date;
     737             : 
     738             :   /**
     739             :    * End date when the fee stops being in effect (exclusive)
     740             :    */
     741             :   struct GNUNET_TIME_TimestampNBO end_date;
     742             : 
     743             :   /**
     744             :    * Fees charged for wire transfers using the
     745             :    * given wire method.
     746             :    */
     747             :   struct TALER_WireFeeSetNBOP fees;
     748             : 
     749             : };
     750             : 
     751             : GNUNET_NETWORK_STRUCT_END
     752             : 
     753             : 
     754             : void
     755           0 : TALER_exchange_offline_wire_fee_sign (
     756             :   const char *payment_method,
     757             :   struct GNUNET_TIME_Timestamp start_time,
     758             :   struct GNUNET_TIME_Timestamp end_time,
     759             :   const struct TALER_WireFeeSet *fees,
     760             :   const struct TALER_MasterPrivateKeyP *master_priv,
     761             :   struct TALER_MasterSignatureP *master_sig)
     762             : {
     763           0 :   struct TALER_MasterWireFeePS kv = {
     764           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES),
     765           0 :     .purpose.size = htonl (sizeof (kv)),
     766           0 :     .start_date = GNUNET_TIME_timestamp_hton (start_time),
     767           0 :     .end_date = GNUNET_TIME_timestamp_hton (end_time),
     768             :   };
     769             : 
     770           0 :   GNUNET_CRYPTO_hash (payment_method,
     771           0 :                       strlen (payment_method) + 1,
     772             :                       &kv.h_wire_method);
     773           0 :   TALER_wire_fee_set_hton (&kv.fees,
     774             :                            fees);
     775           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     776             :                             &kv,
     777             :                             &master_sig->eddsa_signature);
     778           0 : }
     779             : 
     780             : 
     781             : enum GNUNET_GenericReturnValue
     782           0 : TALER_exchange_offline_wire_fee_verify (
     783             :   const char *payment_method,
     784             :   struct GNUNET_TIME_Timestamp start_time,
     785             :   struct GNUNET_TIME_Timestamp end_time,
     786             :   const struct TALER_WireFeeSet *fees,
     787             :   const struct TALER_MasterPublicKeyP *master_pub,
     788             :   const struct TALER_MasterSignatureP *master_sig)
     789             : {
     790           0 :   struct TALER_MasterWireFeePS wf = {
     791           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES),
     792           0 :     .purpose.size = htonl (sizeof (wf)),
     793           0 :     .start_date = GNUNET_TIME_timestamp_hton (start_time),
     794           0 :     .end_date = GNUNET_TIME_timestamp_hton (end_time)
     795             :   };
     796             : 
     797           0 :   GNUNET_CRYPTO_hash (payment_method,
     798           0 :                       strlen (payment_method) + 1,
     799             :                       &wf.h_wire_method);
     800           0 :   TALER_wire_fee_set_hton (&wf.fees,
     801             :                            fees);
     802             :   return
     803           0 :     GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_WIRE_FEES,
     804             :                                 &wf,
     805             :                                 &master_sig->eddsa_signature,
     806             :                                 &master_pub->eddsa_pub);
     807             : }
     808             : 
     809             : 
     810             : GNUNET_NETWORK_STRUCT_BEGIN
     811             : 
     812             : /**
     813             :  * Global fees charged by the exchange independent of
     814             :  * denomination or wire method.
     815             :  */
     816             : struct TALER_MasterGlobalFeePS
     817             : {
     818             : 
     819             :   /**
     820             :    * Purpose is #TALER_SIGNATURE_MASTER_GLOBAL_FEES.
     821             :    */
     822             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     823             : 
     824             :   /**
     825             :    * Start date when the fee goes into effect.
     826             :    */
     827             :   struct GNUNET_TIME_TimestampNBO start_date;
     828             : 
     829             :   /**
     830             :    * End date when the fee stops being in effect (exclusive)
     831             :    */
     832             :   struct GNUNET_TIME_TimestampNBO end_date;
     833             : 
     834             :   /**
     835             :    * How long does an exchange keep a purse around after a purse
     836             :    * has expired (or been successfully merged)?  A 'GET' request
     837             :    * for a purse will succeed until the purse expiration time
     838             :    * plus this value.
     839             :    */
     840             :   struct GNUNET_TIME_RelativeNBO purse_timeout;
     841             : 
     842             :   /**
     843             :    * How long does the exchange promise to keep funds
     844             :    * an account for which the KYC has never happened
     845             :    * after a purse was merged into an account? Basically,
     846             :    * after this time funds in an account without KYC are
     847             :    * forfeit.
     848             :    */
     849             :   struct GNUNET_TIME_RelativeNBO kyc_timeout;
     850             : 
     851             :   /**
     852             :    * How long will the exchange preserve the account history?  After an
     853             :    * account was deleted/closed, the exchange will retain the account history
     854             :    * for legal reasons until this time.
     855             :    */
     856             :   struct GNUNET_TIME_RelativeNBO history_expiration;
     857             : 
     858             :   /**
     859             :    * Fee charged to the merchant per wire transfer.
     860             :    */
     861             :   struct TALER_GlobalFeeSetNBOP fees;
     862             : 
     863             :   /**
     864             :    * Number of concurrent purses that any
     865             :    * account holder is allowed to create without having
     866             :    * to pay the @e purse_fee. Here given in NBO.
     867             :    */
     868             :   uint32_t purse_account_limit;
     869             : 
     870             : };
     871             : 
     872             : GNUNET_NETWORK_STRUCT_END
     873             : 
     874             : 
     875             : void
     876           0 : TALER_exchange_offline_global_fee_sign (
     877             :   struct GNUNET_TIME_Timestamp start_time,
     878             :   struct GNUNET_TIME_Timestamp end_time,
     879             :   const struct TALER_GlobalFeeSet *fees,
     880             :   struct GNUNET_TIME_Relative purse_timeout,
     881             :   struct GNUNET_TIME_Relative kyc_timeout,
     882             :   struct GNUNET_TIME_Relative history_expiration,
     883             :   uint32_t purse_account_limit,
     884             :   const struct TALER_MasterPrivateKeyP *master_priv,
     885             :   struct TALER_MasterSignatureP *master_sig)
     886             : {
     887           0 :   struct TALER_MasterGlobalFeePS kv = {
     888           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_GLOBAL_FEES),
     889           0 :     .purpose.size = htonl (sizeof (kv)),
     890           0 :     .start_date = GNUNET_TIME_timestamp_hton (start_time),
     891           0 :     .end_date = GNUNET_TIME_timestamp_hton (end_time),
     892           0 :     .purse_timeout = GNUNET_TIME_relative_hton (purse_timeout),
     893           0 :     .kyc_timeout = GNUNET_TIME_relative_hton (kyc_timeout),
     894           0 :     .history_expiration = GNUNET_TIME_relative_hton (history_expiration),
     895           0 :     .purse_account_limit = htonl (purse_account_limit)
     896             :   };
     897             : 
     898           0 :   TALER_global_fee_set_hton (&kv.fees,
     899             :                              fees);
     900           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     901             :                             &kv,
     902             :                             &master_sig->eddsa_signature);
     903           0 : }
     904             : 
     905             : 
     906             : enum GNUNET_GenericReturnValue
     907           0 : TALER_exchange_offline_global_fee_verify (
     908             :   struct GNUNET_TIME_Timestamp start_time,
     909             :   struct GNUNET_TIME_Timestamp end_time,
     910             :   const struct TALER_GlobalFeeSet *fees,
     911             :   struct GNUNET_TIME_Relative purse_timeout,
     912             :   struct GNUNET_TIME_Relative kyc_timeout,
     913             :   struct GNUNET_TIME_Relative history_expiration,
     914             :   uint32_t purse_account_limit,
     915             :   const struct TALER_MasterPublicKeyP *master_pub,
     916             :   const struct TALER_MasterSignatureP *master_sig)
     917             : {
     918           0 :   struct TALER_MasterGlobalFeePS wf = {
     919           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_GLOBAL_FEES),
     920           0 :     .purpose.size = htonl (sizeof (wf)),
     921           0 :     .start_date = GNUNET_TIME_timestamp_hton (start_time),
     922           0 :     .end_date = GNUNET_TIME_timestamp_hton (end_time),
     923           0 :     .purse_timeout = GNUNET_TIME_relative_hton (purse_timeout),
     924           0 :     .kyc_timeout = GNUNET_TIME_relative_hton (kyc_timeout),
     925           0 :     .history_expiration = GNUNET_TIME_relative_hton (history_expiration),
     926           0 :     .purse_account_limit = htonl (purse_account_limit)
     927             :   };
     928             : 
     929           0 :   TALER_global_fee_set_hton (&wf.fees,
     930             :                              fees);
     931             :   return
     932           0 :     GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_GLOBAL_FEES,
     933             :                                 &wf,
     934             :                                 &master_sig->eddsa_signature,
     935             :                                 &master_pub->eddsa_pub);
     936             : }
     937             : 
     938             : 
     939             : GNUNET_NETWORK_STRUCT_BEGIN
     940             : 
     941             : /**
     942             :  * @brief Signature made by the exchange offline key over the
     943             :  * configuration of an extension.
     944             :  */
     945             : struct TALER_MasterExtensionConfigurationPS
     946             : {
     947             :   /**
     948             :    * Purpose is #TALER_SIGNATURE_MASTER_EXTENSION.   Signed
     949             :    * by a `struct TALER_MasterPublicKeyP` using EdDSA.
     950             :    */
     951             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
     952             : 
     953             :   /**
     954             :    * Hash of the JSON object that represents the configuration of an extension.
     955             :    */
     956             :   struct TALER_ExtensionConfigHashP h_config GNUNET_PACKED;
     957             : };
     958             : 
     959             : GNUNET_NETWORK_STRUCT_END
     960             : 
     961             : 
     962             : void
     963           0 : TALER_exchange_offline_extension_config_hash_sign (
     964             :   const struct TALER_ExtensionConfigHashP *h_config,
     965             :   const struct TALER_MasterPrivateKeyP *master_priv,
     966             :   struct TALER_MasterSignatureP *master_sig)
     967             : {
     968           0 :   struct TALER_MasterExtensionConfigurationPS ec = {
     969           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION),
     970           0 :     .purpose.size = htonl (sizeof(ec)),
     971             :     .h_config = *h_config
     972             :   };
     973           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
     974             :                             &ec,
     975             :                             &master_sig->eddsa_signature);
     976           0 : }
     977             : 
     978             : 
     979             : enum GNUNET_GenericReturnValue
     980           0 : TALER_exchange_offline_extension_config_hash_verify (
     981             :   const struct TALER_ExtensionConfigHashP *h_config,
     982             :   const struct TALER_MasterPublicKeyP *master_pub,
     983             :   const struct TALER_MasterSignatureP *master_sig
     984             :   )
     985             : {
     986           0 :   struct TALER_MasterExtensionConfigurationPS ec = {
     987           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION),
     988           0 :     .purpose.size = htonl (sizeof(ec)),
     989             :     .h_config = *h_config
     990             :   };
     991             : 
     992           0 :   return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_EXTENSION,
     993             :                                      &ec,
     994             :                                      &master_sig->eddsa_signature,
     995             :                                      &master_pub->eddsa_pub);
     996             : }
     997             : 
     998             : 
     999             : GNUNET_NETWORK_STRUCT_BEGIN
    1000             : 
    1001             : /**
    1002             :  * @brief Information signed by the exchange's master
    1003             :  * key affirming the IBAN details for the exchange.
    1004             :  */
    1005             : struct TALER_MasterWireDetailsPS
    1006             : {
    1007             : 
    1008             :   /**
    1009             :    * Purpose is #TALER_SIGNATURE_MASTER_WIRE_DETAILS.
    1010             :    */
    1011             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    1012             : 
    1013             :   /**
    1014             :    * Hash over the account holder's payto:// URL.
    1015             :    */
    1016             :   struct TALER_PaytoHashP h_wire_details GNUNET_PACKED;
    1017             : 
    1018             : };
    1019             : 
    1020             : GNUNET_NETWORK_STRUCT_END
    1021             : 
    1022             : 
    1023             : enum GNUNET_GenericReturnValue
    1024           4 : TALER_exchange_wire_signature_check (
    1025             :   const char *payto_uri,
    1026             :   const struct TALER_MasterPublicKeyP *master_pub,
    1027             :   const struct TALER_MasterSignatureP *master_sig)
    1028             : {
    1029           4 :   struct TALER_MasterWireDetailsPS wd = {
    1030           4 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_DETAILS),
    1031           4 :     .purpose.size = htonl (sizeof (wd))
    1032             :   };
    1033             : 
    1034           4 :   TALER_payto_hash (payto_uri,
    1035             :                     &wd.h_wire_details);
    1036           4 :   return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_WIRE_DETAILS,
    1037             :                                      &wd,
    1038             :                                      &master_sig->eddsa_signature,
    1039             :                                      &master_pub->eddsa_pub);
    1040             : }
    1041             : 
    1042             : 
    1043             : void
    1044           3 : TALER_exchange_wire_signature_make (
    1045             :   const char *payto_uri,
    1046             :   const struct TALER_MasterPrivateKeyP *master_priv,
    1047             :   struct TALER_MasterSignatureP *master_sig)
    1048             : {
    1049           3 :   struct TALER_MasterWireDetailsPS wd = {
    1050           3 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_DETAILS),
    1051           3 :     .purpose.size = htonl (sizeof (wd))
    1052             :   };
    1053             : 
    1054           3 :   TALER_payto_hash (payto_uri,
    1055             :                     &wd.h_wire_details);
    1056           3 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
    1057             :                             &wd,
    1058             :                             &master_sig->eddsa_signature);
    1059           3 : }
    1060             : 
    1061             : 
    1062             : GNUNET_NETWORK_STRUCT_BEGIN
    1063             : 
    1064             : /**
    1065             :  * Message signed by account to merge a purse into a reserve.
    1066             :  */
    1067             : struct TALER_PartnerConfigurationPS
    1068             : {
    1069             : 
    1070             :   /**
    1071             :    * Purpose is #TALER_SIGNATURE_MASTER_PARNTER_DETAILS
    1072             :    */
    1073             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    1074             :   struct TALER_MasterPublicKeyP partner_pub;
    1075             :   struct GNUNET_TIME_TimestampNBO start_date;
    1076             :   struct GNUNET_TIME_TimestampNBO end_date;
    1077             :   struct GNUNET_TIME_RelativeNBO wad_frequency;
    1078             :   struct TALER_AmountNBO wad_fee;
    1079             :   struct GNUNET_HashCode h_url;
    1080             : };
    1081             : 
    1082             : GNUNET_NETWORK_STRUCT_END
    1083             : 
    1084             : 
    1085             : void
    1086           0 : TALER_exchange_offline_partner_details_sign (
    1087             :   const struct TALER_MasterPublicKeyP *partner_pub,
    1088             :   struct GNUNET_TIME_Timestamp start_date,
    1089             :   struct GNUNET_TIME_Timestamp end_date,
    1090             :   struct GNUNET_TIME_Relative wad_frequency,
    1091             :   const struct TALER_Amount *wad_fee,
    1092             :   const char *partner_base_url,
    1093             :   const struct TALER_MasterPrivateKeyP *master_priv,
    1094             :   struct TALER_MasterSignatureP *master_sig)
    1095             : {
    1096           0 :   struct TALER_PartnerConfigurationPS wd = {
    1097           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_PARTNER_DETAILS),
    1098           0 :     .purpose.size = htonl (sizeof (wd)),
    1099             :     .partner_pub = *partner_pub,
    1100           0 :     .start_date = GNUNET_TIME_timestamp_hton (start_date),
    1101           0 :     .end_date = GNUNET_TIME_timestamp_hton (end_date),
    1102           0 :     .wad_frequency = GNUNET_TIME_relative_hton (wad_frequency),
    1103             :   };
    1104             : 
    1105           0 :   GNUNET_CRYPTO_hash (partner_base_url,
    1106           0 :                       strlen (partner_base_url) + 1,
    1107             :                       &wd.h_url);
    1108           0 :   TALER_amount_hton (&wd.wad_fee,
    1109             :                      wad_fee);
    1110           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
    1111             :                             &wd,
    1112             :                             &master_sig->eddsa_signature);
    1113           0 : }
    1114             : 
    1115             : 
    1116             : enum GNUNET_GenericReturnValue
    1117           0 : TALER_exchange_offline_partner_details_verify (
    1118             :   const struct TALER_MasterPublicKeyP *partner_pub,
    1119             :   struct GNUNET_TIME_Timestamp start_date,
    1120             :   struct GNUNET_TIME_Timestamp end_date,
    1121             :   struct GNUNET_TIME_Relative wad_frequency,
    1122             :   const struct TALER_Amount *wad_fee,
    1123             :   const char *partner_base_url,
    1124             :   const struct TALER_MasterPublicKeyP *master_pub,
    1125             :   const struct TALER_MasterSignatureP *master_sig)
    1126             : {
    1127           0 :   struct TALER_PartnerConfigurationPS wd = {
    1128           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_PARTNER_DETAILS),
    1129           0 :     .purpose.size = htonl (sizeof (wd)),
    1130             :     .partner_pub = *partner_pub,
    1131           0 :     .start_date = GNUNET_TIME_timestamp_hton (start_date),
    1132           0 :     .end_date = GNUNET_TIME_timestamp_hton (end_date),
    1133           0 :     .wad_frequency = GNUNET_TIME_relative_hton (wad_frequency),
    1134             :   };
    1135             : 
    1136           0 :   GNUNET_CRYPTO_hash (partner_base_url,
    1137           0 :                       strlen (partner_base_url) + 1,
    1138             :                       &wd.h_url);
    1139           0 :   TALER_amount_hton (&wd.wad_fee,
    1140             :                      wad_fee);
    1141           0 :   return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_PARTNER_DETAILS,
    1142             :                                      &wd,
    1143             :                                      &master_sig->eddsa_signature,
    1144             :                                      &master_pub->eddsa_pub);
    1145             : }
    1146             : 
    1147             : 
    1148             : GNUNET_NETWORK_STRUCT_BEGIN
    1149             : 
    1150             : /**
    1151             :  * Message signed by account to drain profits
    1152             :  * from the escrow account of the exchange.
    1153             :  */
    1154             : struct TALER_DrainProfitPS
    1155             : {
    1156             : 
    1157             :   /**
    1158             :    * Purpose is #TALER_SIGNATURE_MASTER_DRAIN_PROFITS
    1159             :    */
    1160             :   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
    1161             :   struct TALER_WireTransferIdentifierRawP wtid;
    1162             :   struct GNUNET_TIME_TimestampNBO date;
    1163             :   struct TALER_AmountNBO amount;
    1164             :   struct GNUNET_HashCode h_section;
    1165             :   struct TALER_PaytoHashP h_payto;
    1166             : };
    1167             : 
    1168             : GNUNET_NETWORK_STRUCT_END
    1169             : 
    1170             : 
    1171             : void
    1172           0 : TALER_exchange_offline_profit_drain_sign (
    1173             :   const struct TALER_WireTransferIdentifierRawP *wtid,
    1174             :   struct GNUNET_TIME_Timestamp date,
    1175             :   const struct TALER_Amount *amount,
    1176             :   const char *account_section,
    1177             :   const char *payto_uri,
    1178             :   const struct TALER_MasterPrivateKeyP *master_priv,
    1179             :   struct TALER_MasterSignatureP *master_sig)
    1180             : {
    1181           0 :   struct TALER_DrainProfitPS wd = {
    1182           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DRAIN_PROFIT),
    1183           0 :     .purpose.size = htonl (sizeof (wd)),
    1184             :     .wtid = *wtid,
    1185           0 :     .date = GNUNET_TIME_timestamp_hton (date),
    1186             :   };
    1187             : 
    1188           0 :   GNUNET_CRYPTO_hash (account_section,
    1189           0 :                       strlen (account_section) + 1,
    1190             :                       &wd.h_section);
    1191           0 :   TALER_payto_hash (payto_uri,
    1192             :                     &wd.h_payto);
    1193           0 :   TALER_amount_hton (&wd.amount,
    1194             :                      amount);
    1195           0 :   GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv,
    1196             :                             &wd,
    1197             :                             &master_sig->eddsa_signature);
    1198           0 : }
    1199             : 
    1200             : 
    1201             : enum GNUNET_GenericReturnValue
    1202           0 : TALER_exchange_offline_profit_drain_verify (
    1203             :   const struct TALER_WireTransferIdentifierRawP *wtid,
    1204             :   struct GNUNET_TIME_Timestamp date,
    1205             :   const struct TALER_Amount *amount,
    1206             :   const char *account_section,
    1207             :   const char *payto_uri,
    1208             :   const struct TALER_MasterPublicKeyP *master_pub,
    1209             :   const struct TALER_MasterSignatureP *master_sig)
    1210             : {
    1211           0 :   struct TALER_DrainProfitPS wd = {
    1212           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DRAIN_PROFIT),
    1213           0 :     .purpose.size = htonl (sizeof (wd)),
    1214             :     .wtid = *wtid,
    1215           0 :     .date = GNUNET_TIME_timestamp_hton (date),
    1216             :   };
    1217             : 
    1218           0 :   GNUNET_CRYPTO_hash (account_section,
    1219           0 :                       strlen (account_section) + 1,
    1220             :                       &wd.h_section);
    1221           0 :   TALER_payto_hash (payto_uri,
    1222             :                     &wd.h_payto);
    1223           0 :   TALER_amount_hton (&wd.amount,
    1224             :                      amount);
    1225           0 :   return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DRAIN_PROFIT,
    1226             :                                      &wd,
    1227             :                                      &master_sig->eddsa_signature,
    1228             :                                      &master_pub->eddsa_pub);
    1229             : }
    1230             : 
    1231             : 
    1232             : /* end of offline_signatures.c */

Generated by: LCOV version 1.14