donau

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

commit 411384d5ce179fd17e6bfdf2630c95a2ba3eccb6
parent a1db20bd9e9415bb1817cbfd9867b49cb930e3d1
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date:   Sun, 28 Apr 2024 15:38:31 +0200

work in donau-httpd_batch-submit

Diffstat:
Msrc/donau/donau-httpd_batch-submit.c | 54+++++++++++++++++++++++++++++++++++-------------------
Msrc/include/donau_crypto_lib.h | 18+++++++++++++++---
Msrc/util/donau_crypto.c | 28+++++++++++++++++++++++++---
3 files changed, 75 insertions(+), 25 deletions(-)

diff --git a/src/donau/donau-httpd_batch-submit.c b/src/donau/donau-httpd_batch-submit.c @@ -29,8 +29,7 @@ #include "taler/taler_signatures.h" #include "donaudb_plugin.h" #include "donau-httpd_batch-submit.h" -#include "donau-httpd_db.h" -#include "donau-httpd_metrics.h" +#include "donau-httpd_keys.h" /** @@ -144,26 +143,45 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc, } } - // du_iter_qs = DH_plugin->iterate_donation_units (DH_plugin->cls, - // &donation_unit_info_cb, - // NULL); -// -// if (du_iter_qs < 0) -// { -// GNUNET_break (0); -// // FIXME change error message -// return TALER_MHD_reply_with_error (rc->connection, -// MHD_HTTP_INTERNAL_SERVER_ERROR, -// TALER_EC_GENERIC_DB_FETCH_FAILED, -// "donation_units"); -// } - for (size_t i = 0; i < num_dr; i++) { - // FIXME Check sigs, Donation unit hashes, nonce + // FIXME Check nonce + struct DONAU_UniqueDonorIdentifierHashP udi_hash; + struct DH_DonationUnitKey *dk; + + if (NULL == (dk = DH_keys_donation_unit_by_hash ( + &irc.donation_receipts[i].h_donation_unit_pub))) + { + return TALER_MHD_reply_with_error (rc->connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_DONAU_GENERIC_KEYS_MISSING, + NULL); + } + + DONAU_unique_donor_id_hash ( + irc.h_donor_tax_id, + &irc.donation_receipts[i].nonce, + &udi_hash); + + /* Check signature*/ + if (GNUNET_OK != DONAU_donation_receipt_verify ( + &dk->donation_unit_pub, + &udi_hash, + &irc.donation_receipts[i].donation_unit_sig)) + { + // FIXME change error message + return TALER_MHD_reply_with_error (rc->connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_DONAU_GENERIC_KEYS_MISSING, + NULL); + } } + // FIXME + // Fetch donation receipts and join with donation units to get amount + // then create donation statement + enum GNUNET_DB_QueryStatus qs; qs = DH_plugin->insert_submitted_receipts ( @@ -184,8 +202,6 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc, } // FIXME - // Fetch donation receipts and join with donation units to get amount - // then create donation statement // Send back DS return MHD_HTTP_OK; diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h @@ -425,6 +425,8 @@ DONAU_donation_statement_verify ( const struct DONAU_DonauSignatureP *statement_sig); +///* ********************* donau blind signing ************************** */ + /** * Verify donation receipt. * @@ -440,9 +442,6 @@ DONAU_donation_receipt_verify ( const struct DONAU_DonationUnitSignature *donation_unit_sig); -///* ********************* donau blind signing ************************** */ - - /** * Free internals of @a donation_unit_sig, but not @a donation_unit_sig itself. * @@ -627,5 +626,18 @@ struct TALER_DonauBatchIssueValues struct GNUNET_CRYPTO_BlindingInputValues *blinding_inputs; }; +/** + * Compute the hash of a Unique Donor Identifier. + * + * @param h_donor_tax_id hash of the tax id + * @param nonce that makes the Donor Identifier unique + * @param[out] h_udi where to write the hash + */ +void +DONAU_unique_donor_id_hash (const struct DONAU_HashDonorTaxId *h_donor_tax_id, + const struct DONAU_UniqueDonorIdentifierNonce *nonce + , + struct DONAU_UniqueDonorIdentifierHashP *h_udi); + #endif diff --git a/src/util/donau_crypto.c b/src/util/donau_crypto.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA + Copyright (C) 2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -138,6 +138,29 @@ DONAU_donation_unit_pub_hash ( } +void +DONAU_unique_donor_id_hash (const struct DONAU_HashDonorTaxId *h_donor_tax_id, + const struct DONAU_UniqueDonorIdentifierNonce *nonce + , + struct DONAU_UniqueDonorIdentifierHashP *h_udi) +{ + struct GNUNET_HashContext *hash_context; + hash_context = GNUNET_CRYPTO_hash_context_start (); + + GNUNET_CRYPTO_hash_context_read ( + hash_context, + h_donor_tax_id, + sizeof(struct DONAU_HashDonorTaxId)); + GNUNET_CRYPTO_hash_context_read ( + hash_context, + nonce, + sizeof(struct DONAU_UniqueDonorIdentifierNonce)); + GNUNET_CRYPTO_hash_context_finish ( + hash_context, + &h_udi->hash); +} + + enum GNUNET_GenericReturnValue DONAU_donation_receipt_verify ( const struct DONAU_DonationUnitPublicKey *donation_unit_pub, @@ -148,4 +171,4 @@ DONAU_donation_receipt_verify ( donation_unit_sig->unblinded_sig, h_udi, sizeof (*h_udi)); -} -\ No newline at end of file +}