donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit acb897dd97da52174f5c407549f65841b048a47a
parent e1ccd6adc5107e3186a5ef45a2a3c7095d94c873
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Mon, 13 Nov 2023 08:35:22 +0100

[util] donau eddsa signatures

Diffstat:
Msrc/include/donau_crypto_lib.h | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Msrc/util/charity_signatures.c | 59+++++++++++++++++++++++++++++++++--------------------------
Msrc/util/donau_signatures.c | 1312+++----------------------------------------------------------------------------
3 files changed, 137 insertions(+), 1300 deletions(-)

diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h @@ -43,13 +43,26 @@ struct TALER_DONAU_EddsaPublicKeyP { /** - * Donau uses EdDSA for online signing. + * Donau uses EdDSA for non-blind signing. */ struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; }; /** + * @brief Private key used by the donau to + * sign messages. + */ +struct TALER_DONAU_PrivateKeyP +{ + /** + * Donau uses EdDSA for non-blind signing. + */ + struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; +}; + + +/** * Signing key for whole batches of BUDI-key-pairs. Used by a Charity. */ struct DONAU_CharityPublicKeyP @@ -136,11 +149,11 @@ struct TALER_DONAU_BearerToken }; -/* ********************* charity signing ************************** */ +/* ********************* charity eddsa signing ************************** */ /** - * Create charity signature approving to issue a donation part. + * Create charity eddsa signature approving to issue a donation part. * * @param num_bkp number of bkps * @param bkp to be signed @@ -148,7 +161,7 @@ struct TALER_DONAU_BearerToken * @param[out] charity_sig where to write the signature */ void -TALER_charity_budi_key_pair_sign ( +DONAU_charity_budi_key_pair_sign ( const unsigned int num_bkp, const struct TALER_BlindedUniqueDonationIdentifierKeyPair *bkp[static num_bkp], const struct TALER_DONAU_CharityPrivateKeyP *charity_priv, @@ -156,7 +169,7 @@ TALER_charity_budi_key_pair_sign ( /** - * Verify charity signature approving to issue a donation part. + * Verify charity eddsa signature approving to issue a donation part. * * @param num_bkp number of bkps * @param bkp array to verify @@ -165,11 +178,52 @@ TALER_charity_budi_key_pair_sign ( * @return #GNUNET_OK if the signature is valid */ enum GNUNET_GenericReturnValue -TALER_charity_budi_key_pair_verify ( +DONAU_charity_budi_key_pair_verify ( const unsigned int num_bkp, const struct TALER_BlindedUniqueDonationIdentifierKeyPair *bkp[static num_bkp], const struct TALER_DONAU_CharityPublicKeyP *charity_pub, const struct TALER_CharitySignatureP *charity_sig); +/* ********************* donau eddsa signing ************************** */ + + +/** + * Create donau eddsa signature. Another name for this + * is the donation statement. + * + * @param amount_tot total donated amount of @a year + * @param year + * @param i hash value, the identifier of the donor + * @param donau_priv private key of the donau + * @param[out] statement_sig where to write the signature + */ +void +DONAU_donation_statement_sign ( + const struct TALER_Amount *amount_tot, + const unsigned int year, + const struct TALER_DONAU_HashDonorTaxId *i, + const struct TALER_DONAU_PrivateKeyP *donau_priv, + struct TALER_DonauSignatureP *statement_sig); + + +/** + * Verify donau eddsa signature/donation statement. + * + * @param amount_tot total donated amount of @a year + * @param year + * @param i hash value, the identifier of the donor + * @param donau_priv private key of the donau + * @param statement_sig signature to verify + * @return #GNUNET_OK if the signature is valid + */ +enum GNUNET_GenericReturnValue +DONAU_donation_statement_verify ( + const struct TALER_Amount *amount_tot, + const unsigned int year, + const struct TALER_DONAU_HashDonorTaxId *i, + const struct TALER_DONAU_PublicKeyP *donau_pub, + const TALER_DonauSignatureP *statement_sig); + + #endif diff --git a/src/util/charity_signatures.c b/src/util/charity_signatures.c @@ -19,39 +19,26 @@ * @author Christian Grothoff * @author Lukas Matyja */ +#include "taler/platform.h" +#include "taler/taler_util.h" #include "donau_util.h" +#include <gnunet/gnunet_common.h> #include <taler/taler_signatures.h> -void -TALER_charity_budi_key_pair_sign ( - const unsigned int num_bkp, - const struct TALER_BlindedUniqueDonationIdentifierKeyPair *bkp[num_bkp], - const struct TALER_DONAU_CharityPrivateKeyP *charity_priv, - struct TALER_CharitySignatureP *charity_sig) -{ - struct TALER_BudiKeyPairTrackPS tps = { - .purpose.size = htonl (sizeof (bkp[0])* num_bkp), - .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION), - .num_bkp = num_bkp, - .bkp = *bkp - }; - - GNUNET_CRYPTO_eddsa_sign (&charity_priv->eddsa_priv, - &tps, - &charity_sig->eddsa_sig); -} - +GNUNET_NETWORK_STRUCT_BEGIN /** - * @brief Format used to generate the signature on a request to obtain - * the wire transfer identifier associated with a donation. + * @brief Format used to generate the charity signature on all blinded + * identifiers and key pairs as a agreement of the charity with the + * donation request from the donor. */ struct TALER_BudiKeyPairTrackPS { /** - * Purpose must be #TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION. + * Purpose must be #TALER_SIGNATURE_DONAU_CHARITY_DONATION_CONFIRMATION. Signed + * by a `struct TALER_CharityPublicKeyP` using EdDSA. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -67,25 +54,45 @@ struct TALER_BudiKeyPairTrackPS struct TALER_BlindedUniqueDonationIdentifierKeyPair bkp; }; +GNUNET_NETWORK_STRUCT_END + +void +DONAU_charity_budi_key_pair_sign ( + const unsigned int num_bkp, + const struct TALER_BlindedUniqueDonationIdentifierKeyPair *bkp[num_bkp], + const struct TALER_DONAU_CharityPrivateKeyP *charity_priv, + struct TALER_CharitySignatureP *charity_sig) +{ + struct TALER_BudiKeyPairTrackPS tps = { + .purpose.size = htonl (sizeof (bkp[0])* num_bkp), + .purpose.purpose = htonl (DONAU_SIGNATURE_CHARITY_DONATION_CONFIRMATION), + .num_bkp = num_bkp, + .bkp = *bkp + }; + + GNUNET_CRYPTO_eddsa_sign (&charity_priv->eddsa_priv, + &tps, + &charity_sig->eddsa_sig); +} enum GNUNET_GenericReturnValue -TALER_charity_budi_key_pair_verify ( +DONAU_charity_budi_key_pair_verify ( const unsigned int num_bkp, - const struct TALER_BlindedUniqueDonationIdentifierKeyPair *bkp[static num_bkp], + const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp[static num_bkp], const struct TALER_DONAU_CharityPublicKeyP *charity_pub, const struct TALER_CharitySignatureP *charity_sig) { struct TALER_BudiKeyPairTrackPS tps = { .purpose.size = htonl (sizeof (bkp[0])* num_bkp), - .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION), + .purpose.purpose = htonl (DONAU_SIGNATURE_CHARITY_DONATION_CONFIRMATION), .num_bkp = num_bkp, .bkp = *bkp }; return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION, + GNUNET_CRYPTO_eddsa_verify (DONAU_SIGNATURE_CHARITY_DONATION_CONFIRMATION, &tps, &charity_sig->eddsa_sig, &charity_pub->eddsa_pub); diff --git a/src/util/donau_signatures.c b/src/util/donau_signatures.c @@ -15,8 +15,9 @@ */ /** * @file donau_signatures.c - * @brief Utility functions for Taler security module signatures + * @brief Utility functions for Taler donau security module signatures * @author Christian Grothoff + * @author Lukas Matyja */ #include "taler/platform.h" #include "taler/taler_util.h" @@ -26,348 +27,31 @@ GNUNET_NETWORK_STRUCT_BEGIN /** - * @brief Format used to generate the signature on a confirmation - * from the donau that a deposit request succeeded. + * @brief Format used to generate the signature/donation statement + * over the total amount and a donor identifier of a year. */ -struct TALER_DepositConfirmationPS +struct TALER_DonationStatementConfirmationPS { /** - * Purpose must be #TALER_SIGNATURE_DONAU_CONFIRM_DEPOSIT. Signed - * by a `struct TALER_DonauPublicKeyP` using EdDSA. + * Purpose must be #DONAU_SIGNATURE_DONAU_DONATION_STATEMENT. Signed + * by a `struct TALER_DONAU_EddsaPublicKeyP` using EdDSA. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; /** - * Hash over the contract for which this deposit is made. + * Total amount donated of a specific @a year. */ - struct TALER_PrivateContractHashP h_contract_terms GNUNET_PACKED; + struct TALER_AmountNBO amount_tot; /** - * Hash over the wiring information of the charity. + * The corresponding year. */ - // struct TALER_CharityWireHashP h_wire GNUNET_PACKED; + unsigned int year; /** - * Hash over the optional policy extension of the deposit, 0 if there - * was no policy. + * The hash of the identifier of the donor. */ - struct TALER_ExtensionPolicyHashP h_policy GNUNET_PACKED; - - /** - * Time when this confirmation was generated / when the donau received - * the deposit request. - */ - struct GNUNET_TIME_TimestampNBO donau_timestamp; - - /** - * By when does the donau expect to pay the charity - * (as per the charity's request). - */ - struct GNUNET_TIME_TimestampNBO wire_deadline; - - /** - * How much time does the @e charity have to issue a refund - * request? Zero if refunds are not allowed. After this time, the - * coin cannot be refunded. Note that the wire transfer will not be - * performed by the donau until the refund deadline. This value - * is taken from the original deposit request. - */ - struct GNUNET_TIME_TimestampNBO refund_deadline; - - /** - * Amount to be deposited, excluding fee. Calculated from the - * amount with fee and the fee from the deposit request. - */ - struct TALER_AmountNBO amount_without_fee; - - /** - * The public key of the coin that was deposited. - */ - struct TALER_CoinSpendPublicKeyP coin_pub; - - /** - * The Charity's public key. Allows the charity to later refund - * the transaction or to inquire about the wire transfer identifier. - */ - struct DONAU_CharityPublicKeyP charity_pub; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_deposit_confirmation_sign ( - TALER_DonauSignCallback scb, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_CharityWireHashP *h_wire, - const struct TALER_ExtensionPolicyHashP *h_policy, - struct GNUNET_TIME_Timestamp donau_timestamp, - struct GNUNET_TIME_Timestamp wire_deadline, - struct GNUNET_TIME_Timestamp refund_deadline, - const struct TALER_Amount *amount_without_fee, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CharityPublicKeyP *charity_pub, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_DepositConfirmationPS dcs = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_DEPOSIT), - .purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS)), - .h_contract_terms = *h_contract_terms, - .h_wire = *h_wire, - .donau_timestamp = GNUNET_TIME_timestamp_hton (donau_timestamp), - .wire_deadline = GNUNET_TIME_timestamp_hton (wire_deadline), - .refund_deadline = GNUNET_TIME_timestamp_hton (refund_deadline), - .coin_pub = *coin_pub, - .charity_pub = *charity_pub - }; - - if (NULL != h_policy) - dcs.h_policy = *h_policy; - TALER_amount_hton (&dcs.amount_without_fee, - amount_without_fee); - return scb (&dcs.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_deposit_confirmation_verify ( - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_CharityWireHashP *h_wire, - const struct TALER_ExtensionPolicyHashP *h_policy, - struct GNUNET_TIME_Timestamp donau_timestamp, - struct GNUNET_TIME_Timestamp wire_deadline, - struct GNUNET_TIME_Timestamp refund_deadline, - const struct TALER_Amount *amount_without_fee, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CharityPublicKeyP *charity_pub, - const struct TALER_DonauPublicKeyP *donau_pub, - const struct TALER_DonauSignatureP *donau_sig) -{ - struct TALER_DepositConfirmationPS dcs = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_DEPOSIT), - .purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS)), - .h_contract_terms = *h_contract_terms, - .h_wire = *h_wire, - .donau_timestamp = GNUNET_TIME_timestamp_hton (donau_timestamp), - .wire_deadline = GNUNET_TIME_timestamp_hton (wire_deadline), - .refund_deadline = GNUNET_TIME_timestamp_hton (refund_deadline), - .coin_pub = *coin_pub, - .charity_pub = *charity_pub - }; - - if (NULL != h_policy) - dcs.h_policy = *h_policy; - TALER_amount_hton (&dcs.amount_without_fee, - amount_without_fee); - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_DEPOSIT, - &dcs, - &donau_sig->eddsa_signature, - &donau_pub->eddsa_pub)) - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief Signature made by the donau over the full set of keys, used - * to detect cheating donaus that give out different sets to - * different users. - */ -struct TALER_DonauKeySetPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_KEY_SET. Signed - * by a `struct TALER_DonauPublicKeyP` using EdDSA. - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Time of the key set issue. - */ - struct GNUNET_TIME_TimestampNBO list_issue_date; - - /** - * Hash over the various denomination signing keys returned. - */ - struct GNUNET_HashCode hc GNUNET_PACKED; -}; - -GNUNET_NETWORK_STRUCT_END - -enum TALER_ErrorCode -TALER_donau_online_key_set_sign ( - TALER_DonauSignCallback2 scb, - void *cls, - struct GNUNET_TIME_Timestamp timestamp, - const struct GNUNET_HashCode *hc, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_DonauKeySetPS ks = { - .purpose.size = htonl (sizeof (ks)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_KEY_SET), - .list_issue_date = GNUNET_TIME_timestamp_hton (timestamp), - .hc = *hc - }; - - return scb (cls, - &ks.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_key_set_verify ( - struct GNUNET_TIME_Timestamp timestamp, - const struct GNUNET_HashCode *hc, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_DonauKeySetPS ks = { - .purpose.size = htonl (sizeof (ks)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_KEY_SET), - .list_issue_date = GNUNET_TIME_timestamp_hton (timestamp), - .hc = *hc - }; - - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_KEY_SET, - &ks, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief Signature by which an donau affirms that an account - * successfully passed the KYC checks. - */ -struct TALER_DonauAccountSetupSuccessPS -{ - /** - * Purpose is #TALER_SIGNATURE_DONAU_ACCOUNT_SETUP_SUCCESS. Signed by a - * `struct TALER_DonauPublicKeyP` using EdDSA. - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Hash over the payto for which the signature was made. - */ - struct TALER_PaytoHashP h_payto; - - /** - * Hash over details on *which* KYC obligations were discharged! - */ - struct GNUNET_HashCode h_kyc; - - /** - * When was the signature made. - */ - struct GNUNET_TIME_TimestampNBO timestamp; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_account_setup_success_sign ( - TALER_DonauSignCallback scb, - const struct TALER_PaytoHashP *h_payto, - const json_t *kyc, - struct GNUNET_TIME_Timestamp timestamp, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_DonauAccountSetupSuccessPS kyc_purpose = { - .purpose.size = htonl (sizeof (kyc_purpose)), - .purpose.purpose = htonl ( - TALER_SIGNATURE_DONAU_ACCOUNT_SETUP_SUCCESS), - .h_payto = *h_payto, - .timestamp = GNUNET_TIME_timestamp_hton (timestamp) - }; - - TALER_json_hash (kyc, - &kyc_purpose.h_kyc); - return scb (&kyc_purpose.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_account_setup_success_verify ( - const struct TALER_PaytoHashP *h_payto, - const json_t *kyc, - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_DonauAccountSetupSuccessPS kyc_purpose = { - .purpose.size = htonl (sizeof (kyc_purpose)), - .purpose.purpose = htonl ( - TALER_SIGNATURE_DONAU_ACCOUNT_SETUP_SUCCESS), - .h_payto = *h_payto, - .timestamp = GNUNET_TIME_timestamp_hton (timestamp) - }; - - TALER_json_hash (kyc, - &kyc_purpose.h_kyc); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_ACCOUNT_SETUP_SUCCESS, - &kyc_purpose, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief Format internally used for packing the detailed information - * to generate the signature for /track/transfer signatures. - */ -struct TALER_WireDepositDetailP -{ - - /** - * Hash of the contract - */ - struct TALER_PrivateContractHashP h_contract_terms; - - /** - * Time when the wire transfer was performed by the donau. - */ - struct GNUNET_TIME_TimestampNBO execution_time; - - /** - * Coin's public key. - */ - struct TALER_CoinSpendPublicKeyP coin_pub; - - /** - * Total value of the coin. - */ - struct TALER_AmountNBO deposit_value; - - /** - * Fees charged by the donau for the deposit. - */ - struct TALER_AmountNBO deposit_fee; + struct TALER_DONAU_HashDonorTaxId i; }; @@ -375,956 +59,48 @@ GNUNET_NETWORK_STRUCT_END void -TALER_donau_online_wire_deposit_append ( - struct GNUNET_HashContext *hash_context, - const struct TALER_PrivateContractHashP *h_contract_terms, - struct GNUNET_TIME_Timestamp execution_time, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_Amount *deposit_value, - const struct TALER_Amount *deposit_fee) -{ - struct TALER_WireDepositDetailP dd = { - .h_contract_terms = *h_contract_terms, - .execution_time = GNUNET_TIME_timestamp_hton (execution_time), - .coin_pub = *coin_pub - }; - TALER_amount_hton (&dd.deposit_value, - deposit_value); - TALER_amount_hton (&dd.deposit_fee, - deposit_fee); - GNUNET_CRYPTO_hash_context_read (hash_context, - &dd, - sizeof (dd)); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief Format used to generate the signature for /wire/deposit - * replies. - */ -struct TALER_WireDepositDataPS -{ - /** - * Purpose header for the signature over the contract with - * purpose #TALER_SIGNATURE_DONAU_CONFIRM_WIRE_DEPOSIT. - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Total amount that was transferred. - */ - struct TALER_AmountNBO total; - - /** - * Wire fee that was charged. - */ - struct TALER_AmountNBO wire_fee; - - /** - * Public key of the charity (for all aggregated transactions). - */ - struct TALER_CharityPublicKeyP charity_pub; - - /** - * Hash of bank account of the charity. - */ - struct TALER_PaytoHashP h_payto; - - /** - * Hash of the individual deposits that were aggregated, - * each in the format of a `struct TALER_WireDepositDetailP`. - */ - struct GNUNET_HashCode h_details; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_wire_deposit_sign ( - TALER_DonauSignCallback scb, - const struct TALER_Amount *total, - const struct TALER_Amount *wire_fee, - const struct TALER_CharityPublicKeyP *charity_pub, - const char *payto, - const struct GNUNET_HashCode *h_details, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_WireDepositDataPS wdp = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_WIRE_DEPOSIT), - .purpose.size = htonl (sizeof (wdp)), - .charity_pub = *charity_pub, - .h_details = *h_details - }; - - TALER_amount_hton (&wdp.total, - total); - TALER_amount_hton (&wdp.wire_fee, - wire_fee); - TALER_payto_hash (payto, - &wdp.h_payto); - return scb (&wdp.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_wire_deposit_verify ( - const struct TALER_Amount *total, - const struct TALER_Amount *wire_fee, - const struct TALER_CharityPublicKeyP *charity_pub, - const struct TALER_PaytoHashP *h_payto, - const struct GNUNET_HashCode *h_details, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_WireDepositDataPS wdp = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_WIRE_DEPOSIT), - .purpose.size = htonl (sizeof (wdp)), - .charity_pub = *charity_pub, - .h_details = *h_details, - .h_payto = *h_payto - }; - - TALER_amount_hton (&wdp.total, - total); - TALER_amount_hton (&wdp.wire_fee, - wire_fee); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_WIRE_DEPOSIT, - &wdp, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Details affirmed by the donau about a wire transfer the donau - * claims to have done with respect to a deposit operation. - */ -struct TALER_ConfirmWirePS -{ - /** - * Purpose header for the signature over the contract with - * purpose #TALER_SIGNATURE_DONAU_CONFIRM_WIRE. - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Hash over the wiring information of the charity. - */ - struct TALER_CharityWireHashP h_wire GNUNET_PACKED; - - /** - * Hash over the contract for which this deposit is made. - */ - struct TALER_PrivateContractHashP h_contract_terms GNUNET_PACKED; - - /** - * Raw value (binary encoding) of the wire transfer subject. - */ - struct TALER_WireTransferIdentifierRawP wtid; - - /** - * The coin's public key. This is the value that must have been - * signed (blindly) by the Donau. - */ - struct TALER_CoinSpendPublicKeyP coin_pub; - - /** - * When did the donau execute this transfer? Note that the - * timestamp may not be exactly the same on the wire, i.e. - * because the wire has a different timezone or resolution. - */ - struct GNUNET_TIME_TimestampNBO execution_time; - - /** - * The contribution of @e coin_pub to the total transfer volume. - * This is the value of the deposit minus the fee. - */ - struct TALER_AmountNBO coin_contribution; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_confirm_wire_sign ( - TALER_DonauSignCallback scb, - const struct TALER_CharityWireHashP *h_wire, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - struct GNUNET_TIME_Timestamp execution_time, - const struct TALER_Amount *coin_contribution, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) - -{ - struct TALER_ConfirmWirePS cw = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_WIRE), - .purpose.size = htonl (sizeof (cw)), - .h_wire = *h_wire, - .h_contract_terms = *h_contract_terms, - .wtid = *wtid, - .coin_pub = *coin_pub, - .execution_time = GNUNET_TIME_timestamp_hton (execution_time) - }; - - TALER_amount_hton (&cw.coin_contribution, - coin_contribution); - return scb (&cw.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_confirm_wire_verify ( - const struct TALER_CharityWireHashP *h_wire, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - struct GNUNET_TIME_Timestamp execution_time, - const struct TALER_Amount *coin_contribution, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_ConfirmWirePS cw = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_WIRE), - .purpose.size = htonl (sizeof (cw)), - .h_wire = *h_wire, - .h_contract_terms = *h_contract_terms, - .wtid = *wtid, - .coin_pub = *coin_pub, - .execution_time = GNUNET_TIME_timestamp_hton (execution_time) - }; - - TALER_amount_hton (&cw.coin_contribution, - coin_contribution); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_WIRE, - &cw, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Response by which the donau affirms that it does not - * currently know a denomination by the given hash. - */ -struct TALER_DenominationUnknownAffirmationPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_AFFIRM_DENOM_UNKNOWN - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * When did the donau sign this message. - */ - struct GNUNET_TIME_TimestampNBO timestamp; - - /** - * Hash of the public denomination key we do not know. - */ - struct TALER_DenominationHashP h_denom_pub; -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_denomination_unknown_sign ( - TALER_DonauSignCallback scb, - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_DenominationHashP *h_denom_pub, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_DenominationUnknownAffirmationPS dua = { - .purpose.size = htonl (sizeof (dua)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_AFFIRM_DENOM_UNKNOWN), - .timestamp = GNUNET_TIME_timestamp_hton (timestamp), - .h_denom_pub = *h_denom_pub, - }; - - return scb (&dua.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_denomination_unknown_verify ( - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_DenominationHashP *h_denom_pub, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_DenominationUnknownAffirmationPS dua = { - .purpose.size = htonl (sizeof (dua)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_AFFIRM_DENOM_UNKNOWN), - .timestamp = GNUNET_TIME_timestamp_hton (timestamp), - .h_denom_pub = *h_denom_pub, - }; - - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_AFFIRM_DENOM_UNKNOWN, - &dua, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Response by which the donau affirms that it does not - * currently consider the given denomination to be valid - * for the requested operation. - */ -struct TALER_DenominationExpiredAffirmationPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_AFFIRM_DENOM_EXPIRED - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * When did the donau sign this message. - */ - struct GNUNET_TIME_TimestampNBO timestamp; - - /** - * Name of the operation that is not allowed at this time. Might NOT be 0-terminated, but is padded with 0s. - */ - char operation[8]; - - /** - * Hash of the public denomination key we do not know. - */ - struct TALER_DenominationHashP h_denom_pub; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_denomination_expired_sign ( - TALER_DonauSignCallback scb, - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_DenominationHashP *h_denom_pub, - const char *op, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_DenominationExpiredAffirmationPS dua = { - .purpose.size = htonl (sizeof (dua)), - .purpose.purpose = htonl ( - TALER_SIGNATURE_DONAU_AFFIRM_DENOM_EXPIRED), - .timestamp = GNUNET_TIME_timestamp_hton (timestamp), - .h_denom_pub = *h_denom_pub, - }; - - /* strncpy would create a compiler warning */ - GNUNET_memcpy (dua.operation, - op, - GNUNET_MIN (sizeof (dua.operation), - strlen (op))); - return scb (&dua.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_denomination_expired_verify ( - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_DenominationHashP *h_denom_pub, - const char *op, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_DenominationExpiredAffirmationPS dua = { - .purpose.size = htonl (sizeof (dua)), - .purpose.purpose = htonl ( - TALER_SIGNATURE_DONAU_AFFIRM_DENOM_EXPIRED), - .timestamp = GNUNET_TIME_timestamp_hton (timestamp), - .h_denom_pub = *h_denom_pub, - }; - - /* strncpy would create a compiler warning */ - GNUNET_memcpy (dua.operation, - op, - GNUNET_MIN (sizeof (dua.operation), - strlen (op))); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_AFFIRM_DENOM_EXPIRED, - &dua, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Response by which the donau affirms that it has - * closed a reserve and send back the funds. - */ -struct TALER_ReserveCloseConfirmationPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_RESERVE_CLOSED - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * When did the donau initiate the wire transfer. - */ - struct GNUNET_TIME_TimestampNBO timestamp; - - /** - * How much did the donau send? - */ - struct TALER_AmountNBO closing_amount; - - /** - * How much did the donau charge for closing the reserve? - */ - struct TALER_AmountNBO closing_fee; - - /** - * Public key of the reserve that was closed. - */ - struct TALER_ReservePublicKeyP reserve_pub; - - /** - * Hash of the receiver's bank account. - */ - struct TALER_PaytoHashP h_payto; - - /** - * Wire transfer subject. - */ - struct TALER_WireTransferIdentifierRawP wtid; -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_reserve_closed_sign ( - TALER_DonauSignCallback scb, - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_Amount *closing_amount, - const struct TALER_Amount *closing_fee, - const char *payto, - const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_ReservePublicKeyP *reserve_pub, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_ReserveCloseConfirmationPS rcc = { - .purpose.size = htonl (sizeof (rcc)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_RESERVE_CLOSED), - .wtid = *wtid, - .reserve_pub = *reserve_pub, - .timestamp = GNUNET_TIME_timestamp_hton (timestamp) - }; - - TALER_amount_hton (&rcc.closing_amount, - closing_amount); - TALER_amount_hton (&rcc.closing_fee, - closing_fee); - TALER_payto_hash (payto, - &rcc.h_payto); - return scb (&rcc.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_reserve_closed_verify ( - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_Amount *closing_amount, - const struct TALER_Amount *closing_fee, - const char *payto, - const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_ReserveCloseConfirmationPS rcc = { - .purpose.size = htonl (sizeof (rcc)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_RESERVE_CLOSED), - .wtid = *wtid, - .reserve_pub = *reserve_pub, - .timestamp = GNUNET_TIME_timestamp_hton (timestamp) - }; - - TALER_amount_hton (&rcc.closing_amount, - closing_amount); - TALER_amount_hton (&rcc.closing_fee, - closing_fee); - TALER_payto_hash (payto, - &rcc.h_payto); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_RESERVE_CLOSED, - &rcc, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Response by which the donau affirms that it has - * received funds deposited into a purse. - */ -struct TALER_PurseCreateDepositConfirmationPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_CONFIRM_PURSE_CREATION - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * When did the donau receive the deposits. - */ - struct GNUNET_TIME_TimestampNBO donau_time; - - /** - * When will the purse expire? - */ - struct GNUNET_TIME_TimestampNBO purse_expiration; - - /** - * How much should the purse ultimately contain. - */ - struct TALER_AmountNBO amount_without_fee; - - /** - * How much was deposited so far. - */ - struct TALER_AmountNBO total_deposited; - - /** - * Public key of the purse. - */ - struct TALER_PurseContractPublicKeyP purse_pub; - - /** - * Hash of the contract of the purse. - */ - struct TALER_PrivateContractHashP h_contract_terms; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_purse_created_sign ( - TALER_DonauSignCallback scb, - struct GNUNET_TIME_Timestamp donau_time, - struct GNUNET_TIME_Timestamp purse_expiration, - const struct TALER_Amount *amount_without_fee, - const struct TALER_Amount *total_deposited, - const struct TALER_PurseContractPublicKeyP *purse_pub, - const struct TALER_PrivateContractHashP *h_contract_terms, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) +DONAU_donation_statement_sign ( + const struct TALER_Amount *amount_tot, + const unsigned int year, + const struct TALER_DONAU_HashDonorTaxId *i, + const struct TALER_DONAU_PrivateKeyP *donau_priv, + struct TALER_DonauSignatureP *statement_sig) { - struct TALER_PurseCreateDepositConfirmationPS dc = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_PURSE_CREATION), - .purpose.size = htonl (sizeof (dc)), - .h_contract_terms = *h_contract_terms, - .purse_pub = *purse_pub, - .purse_expiration = GNUNET_TIME_timestamp_hton (purse_expiration), - .donau_time = GNUNET_TIME_timestamp_hton (donau_time) + struct TALER_DonationStatementConfirmationPS tps = { + .purpose.size = htonl (sizeof (struct TALER_DonationStatementConfirmationPS)), + .purpose.purpose = htonl (DONAU_SIGNATURE_DONAU_DONATION_STATEMENT), + .amount_tot = *amount_tot, + .year = year, + .i = *i }; - TALER_amount_hton (&dc.amount_without_fee, - amount_without_fee); - TALER_amount_hton (&dc.total_deposited, - total_deposited); - return scb (&dc.purpose, - pub, - sig); + GNUNET_CRYPTO_eddsa_sign (&donau_priv->eddsa_priv, + &tps, + &statement_sig->eddsa_sig); } enum GNUNET_GenericReturnValue -TALER_donau_online_purse_created_verify ( - struct GNUNET_TIME_Timestamp donau_time, - struct GNUNET_TIME_Timestamp purse_expiration, - const struct TALER_Amount *amount_without_fee, - const struct TALER_Amount *total_deposited, - const struct TALER_PurseContractPublicKeyP *purse_pub, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) +DONAU_donation_statement_verify ( + const struct TALER_Amount *amount_tot, + const unsigned int year, + const struct TALER_DONAU_HashDonorTaxId *i, + const struct TALER_DONAU_PublicKeyP *donau_pub, + const TALER_DonauSignatureP *statement_sig) { - struct TALER_PurseCreateDepositConfirmationPS dc = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_PURSE_CREATION), - .purpose.size = htonl (sizeof (dc)), - .h_contract_terms = *h_contract_terms, - .purse_pub = *purse_pub, - .purse_expiration = GNUNET_TIME_timestamp_hton (purse_expiration), - .donau_time = GNUNET_TIME_timestamp_hton (donau_time) + struct TALER_DonationStatementConfirmationPS tps = { + .purpose.size = htonl (sizeof (struct TALER_DonationStatementConfirmationPS)), + .purpose.purpose = htonl (DONAU_SIGNATURE_DONAU_DONATION_STATEMENT), + .amount_tot = *amount_tot, + .year = year, + .i = *i }; - TALER_amount_hton (&dc.amount_without_fee, - amount_without_fee); - TALER_amount_hton (&dc.total_deposited, - total_deposited); return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_PURSE_CREATION, - &dc, - &sig->eddsa_signature, - &pub->eddsa_pub); + GNUNET_CRYPTO_eddsa_verify (DONAU_SIGNATURE_DONAU_DONATION_STATEMENT, + &tps, + &statement_sig->eddsa_sig, + &donau_pub->eddsa_pub); } - -GNUNET_NETWORK_STRUCT_BEGIN - - - -GNUNET_NETWORK_STRUCT_END - - - - - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Response by which the donau affirms that it has - * merged a purse into a reserve. - */ -struct TALER_PurseMergedConfirmationPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_CONFIRM_PURSE_MERGED - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * When did the donau receive the deposits. - */ - struct GNUNET_TIME_TimestampNBO donau_time; - - /** - * When will the purse expire? - */ - struct GNUNET_TIME_TimestampNBO purse_expiration; - - /** - * How much should the purse ultimately contain. - */ - struct TALER_AmountNBO amount_without_fee; - - /** - * Public key of the purse. - */ - struct TALER_PurseContractPublicKeyP purse_pub; - - /** - * Public key of the reserve. - */ - struct TALER_ReservePublicKeyP reserve_pub; - - /** - * Hash of the contract of the purse. - */ - struct TALER_PrivateContractHashP h_contract_terms; - - /** - * Hash of the provider URL hosting the reserve. - */ - struct GNUNET_HashCode h_provider_url; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_purse_merged_sign ( - TALER_DonauSignCallback scb, - struct GNUNET_TIME_Timestamp donau_time, - struct GNUNET_TIME_Timestamp purse_expiration, - const struct TALER_Amount *amount_without_fee, - const struct TALER_PurseContractPublicKeyP *purse_pub, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_ReservePublicKeyP *reserve_pub, - const char *donau_url, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_PurseMergedConfirmationPS dc = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_PURSE_MERGED), - .purpose.size = htonl (sizeof (dc)), - .h_contract_terms = *h_contract_terms, - .purse_pub = *purse_pub, - .reserve_pub = *reserve_pub, - .purse_expiration = GNUNET_TIME_timestamp_hton (purse_expiration), - .donau_time = GNUNET_TIME_timestamp_hton (donau_time) - }; - - TALER_amount_hton (&dc.amount_without_fee, - amount_without_fee); - GNUNET_CRYPTO_hash (donau_url, - strlen (donau_url) + 1, - &dc.h_provider_url); - return scb (&dc.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_purse_merged_verify ( - struct GNUNET_TIME_Timestamp donau_time, - struct GNUNET_TIME_Timestamp purse_expiration, - const struct TALER_Amount *amount_without_fee, - const struct TALER_PurseContractPublicKeyP *purse_pub, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_ReservePublicKeyP *reserve_pub, - const char *donau_url, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_PurseMergedConfirmationPS dc = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_PURSE_MERGED), - .purpose.size = htonl (sizeof (dc)), - .h_contract_terms = *h_contract_terms, - .purse_pub = *purse_pub, - .reserve_pub = *reserve_pub, - .purse_expiration = GNUNET_TIME_timestamp_hton (purse_expiration), - .donau_time = GNUNET_TIME_timestamp_hton (donau_time) - }; - - TALER_amount_hton (&dc.amount_without_fee, - amount_without_fee); - GNUNET_CRYPTO_hash (donau_url, - strlen (donau_url) + 1, - &dc.h_provider_url); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_PURSE_MERGED, - &dc, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief Format used to generate the signature on a purse status - * from the donau. - */ -struct TALER_PurseStatusPS -{ - /** - * Purpose must be #TALER_SIGNATURE_DONAU_PURSE_STATUS. Signed - * by a `struct TALER_DonauPublicKeyP` 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_donau_online_purse_status_sign ( - TALER_DonauSignCallback scb, - struct GNUNET_TIME_Timestamp merge_timestamp, - struct GNUNET_TIME_Timestamp deposit_timestamp, - const struct TALER_Amount *balance, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_PurseStatusPS dcs = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_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_donau_online_purse_status_verify ( - struct GNUNET_TIME_Timestamp merge_timestamp, - struct GNUNET_TIME_Timestamp deposit_timestamp, - const struct TALER_Amount *balance, - const struct TALER_DonauPublicKeyP *donau_pub, - const struct TALER_DonauSignatureP *donau_sig) -{ - struct TALER_PurseStatusPS dcs = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_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_DONAU_PURSE_STATUS, - &dcs, - &donau_sig->eddsa_signature, - &donau_pub->eddsa_pub)) - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Message signed by the donau to affirm that the - * owner of a reserve has certain attributes. - */ -struct TALER_DonauAttestPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_RESERVE_ATTEST_DETAILS - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Time when the attestation was made. - */ - struct GNUNET_TIME_TimestampNBO attest_timestamp; - - /** - * Time when the attestation expires. - */ - struct GNUNET_TIME_TimestampNBO expiration_time; - - /** - * Public key of the reserve for which the attributes - * are attested. - */ - struct TALER_ReservePublicKeyP reserve_pub; - - /** - * Hash over the attributes. - */ - struct GNUNET_HashCode h_attributes; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_reserve_attest_details_sign ( - TALER_DonauSignCallback scb, - struct GNUNET_TIME_Timestamp attest_timestamp, - struct GNUNET_TIME_Timestamp expiration_time, - const struct TALER_ReservePublicKeyP *reserve_pub, - const json_t *attributes, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_DonauAttestPS rap = { - .purpose.size = htonl (sizeof (rap)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_RESERVE_ATTEST_DETAILS), - .attest_timestamp = GNUNET_TIME_timestamp_hton (attest_timestamp), - .expiration_time = GNUNET_TIME_timestamp_hton (expiration_time), - .reserve_pub = *reserve_pub - }; - - TALER_json_hash (attributes, - &rap.h_attributes); - return scb (&rap.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_reserve_attest_details_verify ( - struct GNUNET_TIME_Timestamp attest_timestamp, - struct GNUNET_TIME_Timestamp expiration_time, - const struct TALER_ReservePublicKeyP *reserve_pub, - const json_t *attributes, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_DonauAttestPS rap = { - .purpose.size = htonl (sizeof (rap)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_RESERVE_ATTEST_DETAILS), - .attest_timestamp = GNUNET_TIME_timestamp_hton (attest_timestamp), - .expiration_time = GNUNET_TIME_timestamp_hton (expiration_time), - .reserve_pub = *reserve_pub - }; - - TALER_json_hash (attributes, - &rap.h_attributes); - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify ( - TALER_SIGNATURE_DONAU_RESERVE_ATTEST_DETAILS, - &rap, - &sig->eddsa_signature, - &pub->eddsa_pub)) - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - /* end of donau_signatures.c */