donau

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

commit 13f59581eeb47ad73883c29bd2b82c081b585b5a
parent 39e2d0252c1f78cbaf29891e68ee8613fd039b6c
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Wed,  8 Nov 2023 00:35:22 +0100

[util] verify and sign for charity

Diffstat:
Msrc/include/donau_crypto_lib.h | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/include/donau_service.h | 2+-
Msrc/util/charity_signatures.c | 164+++++++++++++++++--------------------------------------------------------------
Msrc/util/donau_signatures.c | 547-------------------------------------------------------------------------------
4 files changed, 84 insertions(+), 678 deletions(-)

diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h @@ -62,7 +62,17 @@ struct DONAU_CharityPublicKeyP }; +/** + * Signing key for whole batches of BUDI-key-pairs. Used by a Charity. + */ +struct DONAU_CharityPrivateKeyP +{ + /** + * Donau uses EdDSA for BUDI-key-pair signing + */ + struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; +}; /** * Hash of a donation unit public key @@ -92,6 +102,7 @@ struct TALER_BlindedDonationUnitSignature }; + /** * @brief Type of signature used by the donau for non-blind signatures. */ @@ -124,4 +135,42 @@ struct TALER_DONAU_BearerToken */ struct GNUNET_Uuid token; }; + + +/* ********************* charity signing ************************** */ + + +/** + * Create charity signature approving to issue a donation part. + * + * @param num_bkp number of bkps + * @param bkp to be signed + * @param charity_priv private key of the charity + * @param[out] charity_sig where to write the signature + */ +void +TALER_charity_blinded_unique_donation_identifier_key_pair_sign ( + const unsigned int num_bkp, + const struct TALER_BlindedUniqueDonationIdentifierKeyPair *bkp[static num_bkp], + const struct TALER_DONAU_CharityPrivateKeyP *charity_priv, + struct TALER_CharitySignatureP *charity_sig); + + +/** + * Verify charity signature approving to issue a donation part. + * + * @param num_bkp number of bkps + * @param bkp array to verify + * @param charity_pub public key of the charity + * @param charity_sig where to write the signature + * @return #GNUNET_OK if the signature is valid + */ +enum GNUNET_GenericReturnValue +TALER_charity_blinded_unique_donation_identifier_key_pair_verify ( + const unsigned int num_bkp, + const struct TALER_BlindedUniqueDonationIdentifierKeyPair *bkp[static num_bkp], + const struct TALER_DONAU_CharityPublicKeyP *charity_pub, + struct TALER_CharitySignatureP *charity_sig); + + #endif diff --git a/src/include/donau_service.h b/src/include/donau_service.h @@ -597,7 +597,7 @@ struct TALER_DONAU_BatchIssueReceiptHandle * TALER_DONAU_charity_issue_receipt ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_DONAU_CharityPrivateKey *charity_priv, + const struct TALER_DONAU_CharityPrivateKeyP *charity_priv, unsigned int num_bkp, const struct TALER_BlindedUniqueDonationIdentifierKeyPair bkp[static num_bkp], TALER_DONAU_BatchIssueReceiptsCallback cb, diff --git a/src/util/charity_signatures.c b/src/util/charity_signatures.c @@ -18,10 +18,28 @@ * @brief Utility functions for Taler charity signatures * @author Christian Grothoff */ -#include <taler/taler_util.h> +#include "donau_util.h" #include <taler/taler_signatures.h> +void +TALER_charity_blinded_unique_donation_identifier_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 (bk[0])* num_bkp), + .purpose.purpose = htonl (TALER_SIGNATURE_CHARITY_TRACK_TRANSACTION), + .bkp = *bkp, + }; + + GNUNET_CRYPTO_eddsa_sign (&charity_priv->eddsa_priv, + &tps, + &charity_sig->eddsa_sig); +} + GNUNET_NETWORK_STRUCT_BEGIN /** @@ -36,154 +54,40 @@ struct TALER_DepositTrackPS struct GNUNET_CRYPTO_EccSignaturePurpose purpose; /** - * Hash over the proposal data of the contract for which this deposit is made. - */ - // struct TALER_PrivateContractHashP h_contract_terms GNUNET_PACKED; - - /** - * Hash over the wiring information of the charity. + * num of bkps */ - // struct TALER_CharityWireHashP h_wire GNUNET_PACKED; + unsigned int num_bkp; /** - * The coin's public key. This is the value that must have been + * The BUDI-Key-Pair. It contains the BUDI value that must have been * signed (blindly) by the Donau. */ - struct TALER_CoinSpendPublicKeyP coin_pub; + struct TALER_BlindedUniqueDonationIdentifierKeyPair *bkp[static num_bkp]; }; GNUNET_NETWORK_STRUCT_END -/* -void -TALER_charity_deposit_sign ( - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_CharityWireHashP *h_wire, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CharityPrivateKeyP *charity_priv, - struct TALER_CharitySignatureP *charity_sig) -{ - struct TALER_DepositTrackPS dtp = { - .purpose.purpose = htonl (TALER_SIGNATURE_CHARITY_TRACK_TRANSACTION), - .purpose.size = htonl (sizeof (dtp)), - .h_contract_terms = *h_contract_terms, - .h_wire = *h_wire, - .coin_pub = *coin_pub - }; - - GNUNET_CRYPTO_eddsa_sign (&charity_priv->eddsa_priv, - &dtp, - &charity_sig->eddsa_sig); -}*/ - -/* enum GNUNET_GenericReturnValue -TALER_charity_deposit_verify ( - const struct TALER_CharityPublicKeyP *charity, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_CharityWireHashP *h_wire, - const struct TALER_CharitySignatureP *charity_sig) +TALER_charity_blinded_unique_donation_identifier_key_pair_verify ( + const unsigned int num_bkp, + const struct TALER_BlindedUniqueDonationIdentifierKeyPair *bkp[static num_bkp], + const struct TALER_DONAU_CharityPublicKeyP *charity_pub, + struct TALER_CharitySignatureP *charity_sig) { - struct TALER_DepositTrackPS tps = { - .purpose.size = htonl (sizeof (tps)), - .purpose.purpose = htonl (TALER_SIGNATURE_CHARITY_TRACK_TRANSACTION), - .coin_pub = *coin_pub, - .h_contract_terms = *h_contract_terms, - .h_wire = *h_wire + struct TALER_BudiKeyPairTrackPS tps = { + .purpose.size = htonl (sizeof (bk[0])* num_bkp), + .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION), + .num_bkp = num_bkp, + .bkp = *bkp }; return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_CHARITY_TRACK_TRANSACTION, &tps, &charity_sig->eddsa_sig, - &charity->eddsa_pub); -}*/ - -/* -enum GNUNET_GenericReturnValue -TALER_charity_refund_verify ( - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_PrivateContractHashP *h_contract_terms, - uint64_t rtransaction_id, - const struct TALER_Amount *amount, - const struct TALER_CharityPublicKeyP *charity_pub, - const struct TALER_CharitySignatureP *charity_sig) -{ - struct TALER_RefundRequestPS rr = { - .purpose.purpose = htonl (TALER_SIGNATURE_CHARITY_REFUND), - .purpose.size = htonl (sizeof (rr)), - .h_contract_terms = *h_contract_terms, - .coin_pub = *coin_pub, - .rtransaction_id = GNUNET_htonll (rtransaction_id) - }; - - TALER_amount_hton (&rr.refund_amount, - amount); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_CHARITY_REFUND, - &rr, - &charity_sig->eddsa_sig, &charity_pub->eddsa_pub); -}*/ - -/** - * Used by charities to return signed responses to /pay requests. - * Currently only used to return 200 OK signed responses. - */ - -// struct TALER_PaymentResponsePS -// { - /** - * Set to #TALER_SIGNATURE_CHARITY_PAYMENT_OK. Note that - * unsuccessful payments are usually proven by some donau's signature. - */ - // struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Hash of the proposal data associated with this confirmation - */ - // struct TALER_PrivateContractHashP h_contract_terms; -// }; - -// void -// TALER_charity_pay_sign ( - // const struct TALER_PrivateContractHashP *h_contract_terms, - // const struct TALER_CharityPrivateKeyP *merch_priv, - // struct GNUNET_CRYPTO_EddsaSignature *merch_sig) -// { - // struct TALER_PaymentResponsePS mr = { - // .purpose.purpose = htonl (TALER_SIGNATURE_CHARITY_PAYMENT_OK), - // .purpose.size = htonl (sizeof (mr)), - // .h_contract_terms = *h_contract_terms - // }; - - // GNUNET_CRYPTO_eddsa_sign (&merch_priv->eddsa_priv, - // &mr, - // merch_sig); -// } - - -// enum GNUNET_GenericReturnValue -// TALER_charity_pay_verify ( -// const struct TALER_PrivateContractHashP *h_contract_terms, -// const struct TALER_CharityPublicKeyP *charity_pub, -// const struct TALER_CharitySignatureP *charity_sig) -// { -// struct TALER_PaymentResponsePS pr = { -// .purpose.purpose = htonl (TALER_SIGNATURE_CHARITY_PAYMENT_OK), -// .purpose.size = htonl (sizeof (pr)), -// .h_contract_terms = *h_contract_terms -// }; -// -// return -// GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_CHARITY_PAYMENT_OK, -// &pr, -// &charity_sig->eddsa_sig, -// &charity_pub->eddsa_pub); -// } - +} /* end of charity_signatures.c */ diff --git a/src/util/donau_signatures.c b/src/util/donau_signatures.c @@ -179,274 +179,6 @@ TALER_donau_online_deposit_confirmation_verify ( GNUNET_NETWORK_STRUCT_BEGIN /** - * @brief Format used to generate the signature on a request to refund - * a coin into the account of the donor. - */ -struct TALER_RefundConfirmationPS -{ - /** - * Purpose must be #TALER_SIGNATURE_DONAU_CONFIRM_REFUND. - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Hash over the proposal data to identify the contract - * which is being refunded. - */ - struct TALER_PrivateContractHashP h_contract_terms GNUNET_PACKED; - - /** - * The coin's public key. This is the value that must have been - * signed (blindly) by the Donau. - */ - 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 TALER_CharityPublicKeyP charity; - - /** - * Charity-generated transaction ID for the refund. - */ - uint64_t rtransaction_id GNUNET_PACKED; - - /** - * Amount to be refunded, including refund fee charged by the - * donau to the donor. - */ - struct TALER_AmountNBO refund_amount; -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_refund_confirmation_sign ( - TALER_DonauSignCallback scb, - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CharityPublicKeyP *charity, - uint64_t rtransaction_id, - const struct TALER_Amount *refund_amount, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_RefundConfirmationPS rc = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_REFUND), - .purpose.size = htonl (sizeof (rc)), - .h_contract_terms = *h_contract_terms, - .coin_pub = *coin_pub, - .charity = *charity, - .rtransaction_id = GNUNET_htonll (rtransaction_id) - }; - - TALER_amount_hton (&rc.refund_amount, - refund_amount); - return scb (&rc.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_refund_confirmation_verify ( - const struct TALER_PrivateContractHashP *h_contract_terms, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CharityPublicKeyP *charity, - uint64_t rtransaction_id, - const struct TALER_Amount *refund_amount, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_RefundConfirmationPS rc = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_REFUND), - .purpose.size = htonl (sizeof (rc)), - .h_contract_terms = *h_contract_terms, - .coin_pub = *coin_pub, - .charity = *charity, - .rtransaction_id = GNUNET_htonll (rtransaction_id) - }; - - TALER_amount_hton (&rc.refund_amount, - refund_amount); - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_REFUND, - &rc, - &sig->eddsa_signature, - &pub->eddsa_pub)) - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief Format of the block signed by the Donau in response to a successful - * "/refresh/melt" request. Hereby the donau affirms that all of the - * coins were successfully melted. This also commits the donau to a - * particular index to not be revealed during the refresh. - */ -struct TALER_RefreshMeltConfirmationPS -{ - /** - * Purpose is #TALER_SIGNATURE_DONAU_CONFIRM_MELT. Signed - * by a `struct TALER_DonauPublicKeyP` using EdDSA. - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Commitment made in the /refresh/melt. - */ - struct TALER_RefreshCommitmentP rc GNUNET_PACKED; - - /** - * Index that the client will not have to reveal, in NBO. - * Must be smaller than #TALER_CNC_KAPPA. - */ - uint32_t noreveal_index GNUNET_PACKED; - -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_melt_confirmation_sign ( - TALER_DonauSignCallback scb, - const struct TALER_RefreshCommitmentP *rc, - uint32_t noreveal_index, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_RefreshMeltConfirmationPS confirm = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_MELT), - .purpose.size = htonl (sizeof (confirm)), - .rc = *rc, - .noreveal_index = htonl (noreveal_index) - }; - - return scb (&confirm.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_melt_confirmation_verify ( - const struct TALER_RefreshCommitmentP *rc, - uint32_t noreveal_index, - const struct TALER_DonauPublicKeyP *donau_pub, - const struct TALER_DonauSignatureP *donau_sig) -{ - struct TALER_RefreshMeltConfirmationPS confirm = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_MELT), - .purpose.size = htonl (sizeof (confirm)), - .rc = *rc, - .noreveal_index = htonl (noreveal_index) - }; - - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_MELT, - &confirm, - &donau_sig->eddsa_signature, - &donau_pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief Format of the block signed by the Donau in response to a - * successful "/reserves/$RESERVE_PUB/age-withdraw" request. Hereby the - * donau affirms that the commitment along with the maximum age group and - * the amount were accepted. This also commits the donau to a particular - * index to not be revealed during the reveal. - */ -struct TALER_AgeWithdrawConfirmationPS -{ - /** - * Purpose is #TALER_SIGNATURE_DONAU_CONFIRM_AGE_WITHDRAW. Signed by a - * `struct TALER_DonauPublicKeyP` using EdDSA. - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Commitment made in the /reserves/$RESERVE_PUB/age-withdraw. - */ - struct TALER_AgeWithdrawCommitmentHashP h_commitment GNUNET_PACKED; - - /** - * Index that the client will not have to reveal, in NBO. - * Must be smaller than #TALER_CNC_KAPPA. - */ - uint32_t noreveal_index GNUNET_PACKED; - -}; - -GNUNET_NETWORK_STRUCT_END - -enum TALER_ErrorCode -TALER_donau_online_age_withdraw_confirmation_sign ( - TALER_DonauSignCallback scb, - const struct TALER_AgeWithdrawCommitmentHashP *h_commitment, - uint32_t noreveal_index, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - - struct TALER_AgeWithdrawConfirmationPS confirm = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_AGE_WITHDRAW), - .purpose.size = htonl (sizeof (confirm)), - .h_commitment = *h_commitment, - .noreveal_index = htonl (noreveal_index) - }; - - return scb (&confirm.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_age_withdraw_confirmation_verify ( - const struct TALER_AgeWithdrawCommitmentHashP *h_commitment, - uint32_t noreveal_index, - const struct TALER_DonauPublicKeyP *donau_pub, - const struct TALER_DonauSignatureP *donau_sig) -{ - struct TALER_AgeWithdrawConfirmationPS confirm = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_AGE_WITHDRAW), - .purpose.size = htonl (sizeof (confirm)), - .h_commitment = *h_commitment, - .noreveal_index = htonl (noreveal_index) - }; - - if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify ( - TALER_SIGNATURE_DONAU_CONFIRM_AGE_WITHDRAW, - &confirm, - &donau_sig->eddsa_signature, - &donau_pub->eddsa_pub)) - { - GNUNET_break_op (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -/* TODO:oec: add signature for age-withdraw, age-reveal */ - - -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. @@ -473,7 +205,6 @@ struct TALER_DonauKeySetPS GNUNET_NETWORK_STRUCT_END - enum TALER_ErrorCode TALER_donau_online_key_set_sign ( TALER_DonauSignCallback2 scb, @@ -886,201 +617,6 @@ TALER_donau_online_confirm_wire_verify ( &pub->eddsa_pub); } - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Response by which the donau affirms that it will - * refund a coin as part of the emergency /recoup - * protocol. The recoup will go back to the bank - * account that created the reserve. - */ -struct TALER_RecoupConfirmationPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_CONFIRM_RECOUP - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * When did the donau receive the recoup request? - * Indirectly determines when the wire transfer is (likely) - * to happen. - */ - struct GNUNET_TIME_TimestampNBO timestamp; - - /** - * How much of the coin's value will the donau transfer? - * (Needed in case the coin was partially spent.) - */ - struct TALER_AmountNBO recoup_amount; - - /** - * Public key of the coin. - */ - struct TALER_CoinSpendPublicKeyP coin_pub; - - /** - * Public key of the reserve that will receive the recoup. - */ - struct TALER_ReservePublicKeyP reserve_pub; -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_confirm_recoup_sign ( - TALER_DonauSignCallback scb, - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_Amount *recoup_amount, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_ReservePublicKeyP *reserve_pub, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_RecoupConfirmationPS pc = { - .purpose.size = htonl (sizeof (pc)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_RECOUP), - .timestamp = GNUNET_TIME_timestamp_hton (timestamp), - .coin_pub = *coin_pub, - .reserve_pub = *reserve_pub - }; - - TALER_amount_hton (&pc.recoup_amount, - recoup_amount); - return scb (&pc.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_confirm_recoup_verify ( - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_Amount *recoup_amount, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_RecoupConfirmationPS pc = { - .purpose.size = htonl (sizeof (pc)), - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_RECOUP), - .timestamp = GNUNET_TIME_timestamp_hton (timestamp), - .coin_pub = *coin_pub, - .reserve_pub = *reserve_pub - }; - - TALER_amount_hton (&pc.recoup_amount, - recoup_amount); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_RECOUP, - &pc, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * Response by which the donau affirms that it will refund a refreshed coin - * as part of the emergency /recoup protocol. The recoup will go back to the - * old coin's balance. - */ -struct TALER_RecoupRefreshConfirmationPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_CONFIRM_RECOUP_REFRESH - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * When did the donau receive the recoup request? - * Indirectly determines when the wire transfer is (likely) - * to happen. - */ - struct GNUNET_TIME_TimestampNBO timestamp; - - /** - * How much of the coin's value will the donau transfer? - * (Needed in case the coin was partially spent.) - */ - struct TALER_AmountNBO recoup_amount; - - /** - * Public key of the refreshed coin. - */ - struct TALER_CoinSpendPublicKeyP coin_pub; - - /** - * Public key of the old coin that will receive the recoup. - */ - struct TALER_CoinSpendPublicKeyP old_coin_pub; -}; - -GNUNET_NETWORK_STRUCT_END - - -enum TALER_ErrorCode -TALER_donau_online_confirm_recoup_refresh_sign ( - TALER_DonauSignCallback scb, - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_Amount *recoup_amount, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CoinSpendPublicKeyP *old_coin_pub, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_RecoupRefreshConfirmationPS pc = { - .purpose.purpose = htonl ( - TALER_SIGNATURE_DONAU_CONFIRM_RECOUP_REFRESH), - .purpose.size = htonl (sizeof (pc)), - .timestamp = GNUNET_TIME_timestamp_hton (timestamp), - .coin_pub = *coin_pub, - .old_coin_pub = *old_coin_pub - }; - - TALER_amount_hton (&pc.recoup_amount, - recoup_amount); - return scb (&pc.purpose, - pub, - sig); -} - - -enum GNUNET_GenericReturnValue -TALER_donau_online_confirm_recoup_refresh_verify ( - struct GNUNET_TIME_Timestamp timestamp, - const struct TALER_Amount *recoup_amount, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CoinSpendPublicKeyP *old_coin_pub, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_RecoupRefreshConfirmationPS pc = { - .purpose.purpose = htonl ( - TALER_SIGNATURE_DONAU_CONFIRM_RECOUP_REFRESH), - .purpose.size = htonl (sizeof (pc)), - .timestamp = GNUNET_TIME_timestamp_hton (timestamp), - .coin_pub = *coin_pub, - .old_coin_pub = *old_coin_pub - }; - - TALER_amount_hton (&pc.recoup_amount, - recoup_amount); - - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_RECOUP_REFRESH, - &pc, - &sig->eddsa_signature, - &pub->eddsa_pub); -} - - GNUNET_NETWORK_STRUCT_BEGIN /** @@ -1471,96 +1007,13 @@ TALER_donau_online_purse_created_verify ( GNUNET_NETWORK_STRUCT_BEGIN -/** - * Response by which the donau affirms that it has - * received funds deposited into a purse. - */ -struct TALER_CoinPurseRefundConfirmationPS -{ - - /** - * Purpose is #TALER_SIGNATURE_DONAU_CONFIRM_PURSE_REFUND - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Public key of the purse. - */ - struct TALER_PurseContractPublicKeyP purse_pub; - - /** - * Public key of the coin. - */ - struct TALER_CoinSpendPublicKeyP coin_pub; - - /** - * How much will be refunded to the purse. - */ - struct TALER_AmountNBO refunded_amount; - /** - * How much was the refund fee. - */ - struct TALER_AmountNBO refund_fee; - -}; GNUNET_NETWORK_STRUCT_END -enum TALER_ErrorCode -TALER_donau_online_purse_refund_sign ( - TALER_DonauSignCallback scb, - const struct TALER_Amount *amount_without_fee, - const struct TALER_Amount *refund_fee, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_PurseContractPublicKeyP *purse_pub, - struct TALER_DonauPublicKeyP *pub, - struct TALER_DonauSignatureP *sig) -{ - struct TALER_CoinPurseRefundConfirmationPS dc = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_PURSE_REFUND), - .purpose.size = htonl (sizeof (dc)), - .coin_pub = *coin_pub, - .purse_pub = *purse_pub, - }; - - TALER_amount_hton (&dc.refunded_amount, - amount_without_fee); - TALER_amount_hton (&dc.refund_fee, - refund_fee); - return scb (&dc.purpose, - pub, - sig); -} - -enum GNUNET_GenericReturnValue -TALER_donau_online_purse_refund_verify ( - const struct TALER_Amount *amount_without_fee, - const struct TALER_Amount *refund_fee, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_PurseContractPublicKeyP *purse_pub, - const struct TALER_DonauPublicKeyP *pub, - const struct TALER_DonauSignatureP *sig) -{ - struct TALER_CoinPurseRefundConfirmationPS dc = { - .purpose.purpose = htonl (TALER_SIGNATURE_DONAU_CONFIRM_PURSE_REFUND), - .purpose.size = htonl (sizeof (dc)), - .coin_pub = *coin_pub, - .purse_pub = *purse_pub, - }; - TALER_amount_hton (&dc.refunded_amount, - amount_without_fee); - TALER_amount_hton (&dc.refund_fee, - refund_fee); - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_DONAU_CONFIRM_PURSE_REFUND, - &dc, - &sig->eddsa_signature, - &pub->eddsa_pub); -} GNUNET_NETWORK_STRUCT_BEGIN