commit 05360b030ac3c2b4333da6b1c6b5602c41dbc264
parent f46e805fa3652f88e92bb5584c7f00837f2c1673
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date: Sun, 28 Apr 2024 09:52:20 +0200
fix du receipt sig
Diffstat:
5 files changed, 58 insertions(+), 16 deletions(-)
diff --git a/src/donau/donau-httpd_batch-submit.c b/src/donau/donau-httpd_batch-submit.c
@@ -60,8 +60,8 @@ parse_json_dr (struct DONAU_DonationReceipt *dr,
&dr->h_donation_unit_pub),
GNUNET_JSON_spec_fixed_auto ("nonce",
&dr->nonce),
- GNUNET_JSON_spec_fixed_auto ("donau_sig",
- &dr->donau_sig),
+ GNUNET_JSON_spec_fixed_auto ("donation_unit_sig",
+ &dr->donation_unit_sig),
GNUNET_JSON_spec_end ()
};
@@ -144,9 +144,37 @@ 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
+ // /* verify charity signature */
+ // if (GNUNET_OK !=
+ // DONAU_ (num_bkps,
+ // bkps,
+ // &charity_meta.charity_pub,
+ // &charity_sig))
+ // {
+ // GNUNET_break_op (0);
+ // return TALER_MHD_reply_with_error (
+ // rc->connection,
+ // MHD_HTTP_FORBIDDEN,
+ // TALER_EC_DONAU_CHARITY_SIGNATURE_INVALID,
+ // NULL);
+ // }
}
enum GNUNET_DB_QueryStatus qs;
diff --git a/src/donaudb/0002-donau_receipts_submitted.sql b/src/donaudb/0002-donau_receipts_submitted.sql
@@ -19,7 +19,7 @@ CREATE TABLE receipts_submitted
,h_tax_number BYTEA NOT NULL
,nonce BYTEA NOT NULL UNIQUE CHECK (LENGTH(nonce)=32)
,donation_unit_pub BYTEA NOT NULL REFERENCES donation_units (donation_unit_pub)
- ,donau_sig BYTEA NOT NULL UNIQUE
+ ,donation_unit_sig BYTEA NOT NULL UNIQUE
,donation_year INT8 NOT NULL
);
COMMENT ON TABLE receipts_submitted
diff --git a/src/donaudb/pg_insert_submitted_receipts.c b/src/donaudb/pg_insert_submitted_receipts.c
@@ -38,7 +38,8 @@ DH_PG_insert_submitted_receipts (
const struct DONAU_DonationUnitHashP *h_donation_unit_pubs[GNUNET_NZL (num_dr)
];
const struct DONAU_UniqueDonorIdentifierNonce *nonces[GNUNET_NZL (num_dr)];
- const struct DONAU_DonauSignatureP *donau_sigs[GNUNET_NZL (num_dr)];
+ const struct DONAU_DonationUnitSignature *donation_unit_sigs[GNUNET_NZL (
+ num_dr)];
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (h_tax_number),
GNUNET_PQ_query_param_array_ptrs_auto_from_type (num_dr,
@@ -48,7 +49,7 @@ DH_PG_insert_submitted_receipts (
nonces,
pg->conn),
GNUNET_PQ_query_param_array_ptrs_auto_from_type (num_dr,
- donau_sigs,
+ donation_unit_sigs,
pg->conn),
GNUNET_PQ_query_param_uint64 (&donation_year),
GNUNET_PQ_query_param_end
@@ -61,7 +62,7 @@ DH_PG_insert_submitted_receipts (
h_donation_unit_pubs[i] = &dr->h_donation_unit_pub;
nonces[i] = &dr->nonce;
- donau_sigs[i] = &dr->donau_sig;
+ donation_unit_sigs[i] = &dr->donation_unit_sig;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Do insert submitted receipt\n");
diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h
@@ -210,7 +210,7 @@ struct DONAU_BlindedDonationUnitSignature
/**
- * @brief Type of (unblinded) donation receipts signatures for Taler.
+ * @brief Type of (unblinded) donation receipts signatures for Donau.
*/
struct DONAU_DonationUnitSignature
{
@@ -303,7 +303,7 @@ struct DONAU_DonationReceipt
/**
* Unblinded donation unit signature from the donau.
*/
- struct DONAU_DonauSignatureP donau_sig;
+ struct DONAU_DonationUnitSignature donation_unit_sig;
};
@@ -416,6 +416,19 @@ DONAU_donation_statement_verify (
const struct DONAU_DonauSignatureP *statement_sig);
+/**
+ * Verify donation receipt.
+ *
+ * @param donation_unit_priv private key of the donation_unit
+ * @param donation_unit_sig signature to verify
+ * @return #GNUNET_OK if the signature is valid
+ */
+enum GNUNET_GenericReturnValue
+DONAU_donation_receipt_verify (
+ const struct DONAU_DonationReceipt *donation_receipt,
+ const struct DONAU_DonationUnitSignature *donation_unit_sig);
+
+
///* ********************* donau blind signing ************************** */
@@ -438,12 +451,12 @@ DONAU_blinded_donation_unit_sig_free (
* @param budi_hash hash over the budi
* @return #GNUNET_OK if the signature is valid
*/
-enum GNUNET_GenericReturnValue
-TALER_donation_unit_pub_verify (const struct
- DONAU_DonationUnitPublicKey *du_pub,
- const struct
- DONAU_DonationUnitSignature *du_sig,
- const struct DONAU_BudiHashP *budi_hash);
+// enum GNUNET_GenericReturnValue
+// TALER_donation_unit_pub_verify (
+// const struct DONAU_DonationUnitPublicKey *du_pub,
+// const struct
+// DONAU_DonationUnitSignature *du_sig,
+// const struct DONAU_BudiHashP *budi_hash);
// FIXME: Copied from taler_crypto_lib.h, is anything of this necessary?
diff --git a/src/lib/donau_api_batch_submit_receipts.c b/src/lib/donau_api_batch_submit_receipts.c
@@ -98,8 +98,8 @@ submit_request_body_to_json (const size_t num_drs,
&drs[i].h_donation_unit_pub),
GNUNET_JSON_pack_data_auto ("nonce",
&drs[i].nonce),
- GNUNET_JSON_pack_data_auto ("donau_sig",
- &drs[i].donau_sig));
+ GNUNET_JSON_pack_data_auto ("donation_unit_sig",
+ &drs[i].donation_unit_sig));
GNUNET_assert (0 ==
json_array_append_new (donation_receipts,
receipt));