[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-donau] 02/03: work on issue receipts
From: |
gnunet |
Subject: |
[taler-donau] 02/03: work on issue receipts |
Date: |
Tue, 09 Apr 2024 00:19:05 +0200 |
This is an automated email from the git hooks/post-receive script.
lukas-matyja pushed a commit to branch master
in repository donau.
commit f0426eae184cea17d8076bc5f2cd9160123f2046
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
AuthorDate: Tue Apr 9 00:19:16 2024 +0200
work on issue receipts
---
src/donau/donau-httpd_post-batch-issue.c | 20 ++++++++++----------
src/include/donau_service.h | 1 +
src/lib/donau_api_batch_issue_receipts.c | 14 +++++++++++++-
src/pq/pq_query_helper.c | 20 ++++++++++----------
src/testing/testing_api_cmd_issue_receipts.c | 7 ++++++-
src/util/charity_signatures.c | 2 +-
6 files changed, 41 insertions(+), 23 deletions(-)
diff --git a/src/donau/donau-httpd_post-batch-issue.c
b/src/donau/donau-httpd_post-batch-issue.c
index 8eb89c5..d5088ca 100644
--- a/src/donau/donau-httpd_post-batch-issue.c
+++ b/src/donau/donau-httpd_post-batch-issue.c
@@ -167,7 +167,7 @@ DH_handler_issue_receipts_post (struct DH_RequestContext
*rc,
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "parse some values!");
+ "parse some values!\n");
/* parse the budikeypairs array */
const size_t num_bkp
= json_array_size (budikeypairs);
@@ -195,7 +195,7 @@ DH_handler_issue_receipts_post (struct DH_RequestContext
*rc,
else
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "empty array of budi key pairs!");
+ "empty array of budi key pairs!\n");
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
@@ -203,7 +203,7 @@ DH_handler_issue_receipts_post (struct DH_RequestContext
*rc,
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "budi key pairs array is parsed!");
+ "budi key pairs array is parsed!\n");
// Get charity pub
struct DONAUDB_CharityMetaData charity_meta;
enum GNUNET_DB_QueryStatus qs_charity;
@@ -232,7 +232,7 @@ DH_handler_issue_receipts_post (struct DH_RequestContext
*rc,
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "got charity from db!");
+ "got charity from db!\n");
/* verify charity signature */
if (GNUNET_OK !=
DONAU_charity_budi_key_pair_verify (num_bkp, irc.bkp,
@@ -248,7 +248,7 @@ DH_handler_issue_receipts_post (struct DH_RequestContext
*rc,
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "charity signature valid!");
+ "charity signature valid!\n");
/* request already made? -> idempotent */
enum GNUNET_DB_QueryStatus qs_check_receipts;
struct DONAUDB_IssuedReceiptsMetaData check_receipts_meta;
@@ -289,11 +289,11 @@ start:
NULL);
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "request have not been made yet (first time)!");
+ "request have not been made yet (first time)!\n");
break; // it's the first request from the charity, we can proceed
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "request have been made already!");
+ "request have been made already!\n");
signatures_to_JSON (num_bkp, check_receipts_meta.blinded_sig,
blind_signatures);
return TALER_MHD_REPLY_JSON_PACK (
@@ -328,7 +328,7 @@ start:
TALER_EC_GENERIC_PARAMETER_MALFORMED,//
TODO: other EC
"budikeypairs");
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "calculated the new receipts to date amount");
+ "calculated the new receipts to date amount\n");
/* sign budis and send the signatures back */
struct DONAU_BlindedDonationUnitSignature *du_sigs = {0};
@@ -352,7 +352,7 @@ start:
}
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "made blind signatures!");
+ "made blind signatures!\n");
}
/* save new receipts to date and save receipts Request (blinded signatures,
* charity id, amount, hash over bkps) to make it idempotent*/
@@ -382,7 +382,7 @@ start:
break;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "issue receipts request is saved! (idempotent)");
+ "issue receipts request is saved! (idempotent)\n");
signatures_to_JSON (num_bkp, du_sigs, blind_signatures);
return TALER_MHD_REPLY_JSON_PACK (
diff --git a/src/include/donau_service.h b/src/include/donau_service.h
index ea35eb9..353ee87 100644
--- a/src/include/donau_service.h
+++ b/src/include/donau_service.h
@@ -535,6 +535,7 @@ DONAU_charity_issue_receipt (
struct GNUNET_CURL_Context *ctx,
const char *url,
const struct DONAU_CharityPrivateKeyP *charity_priv,
+ const struct DONAU_CharityPublicKeyP *charity_pub,
const uint64_t charity_id,
const uint64_t year,
const size_t num_bkp,
diff --git a/src/lib/donau_api_batch_issue_receipts.c
b/src/lib/donau_api_batch_issue_receipts.c
index be9c8b5..abc419c 100644
--- a/src/lib/donau_api_batch_issue_receipts.c
+++ b/src/lib/donau_api_batch_issue_receipts.c
@@ -181,6 +181,7 @@ DONAU_charity_issue_receipt (
struct GNUNET_CURL_Context *ctx,
const char *url,
const struct DONAU_CharityPrivateKeyP *charity_priv,
+ const struct DONAU_CharityPublicKeyP *charity_pub,
const uint64_t charity_id,
const uint64_t year,
const size_t num_bkp,
@@ -196,7 +197,18 @@ DONAU_charity_issue_receipt (
// make signature over budi-key-pair
DONAU_charity_budi_key_pair_sign (num_bkp, bkp, charity_priv,
&birh->charity_sig);
-
+ /* FIXME temporary test */
+ if (GNUNET_OK !=
+ DONAU_charity_budi_key_pair_verify (num_bkp, bkp,
+ charity_pub,
+ &birh->charity_sig))
+ {
+ GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "signature or verification function(s) not ok\n");
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "signature and verification functions ok\n");
TALER_LOG_DEBUG ("Connecting to the donau (%s)\n",
url);
birh->url = GNUNET_strdup (url);
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c
index 0b01edd..871d2ef 100644
--- a/src/pq/pq_query_helper.c
+++ b/src/pq/pq_query_helper.c
@@ -225,16 +225,16 @@ DONAU_PQ_query_param_donation_unit_pub (
// GNUNET_assert (NULL != dst);
// *((void **) dst) = NULL;
-
-// #define FAIL_IF(cond) \
-// do { \
-// if ((cond)) \
-// { \
-// GNUNET_break (! (cond)); \
-// goto FAIL; \
-// } \
-// } while (0)
-
+/**
+ #define FAIL_IF(cond) \
+ do { \
+ if ((cond)) \
+ { \
+ GNUNET_break (! (cond)); \
+ goto FAIL; \
+ } \
+ } while (0)
+**/
// col_num = PQfnumber (result, fname);
// FAIL_IF (0 > col_num);
diff --git a/src/testing/testing_api_cmd_issue_receipts.c
b/src/testing/testing_api_cmd_issue_receipts.c
index bee57e0..df23d2d 100644
--- a/src/testing/testing_api_cmd_issue_receipts.c
+++ b/src/testing/testing_api_cmd_issue_receipts.c
@@ -135,11 +135,13 @@ status_run (void *cls,
ss->is = is;
/* Get charity id and the charity private key from trait */
+ const struct DONAU_CharityPublicKeyP *charity_pub;
{
const struct TALER_TESTING_Command *charity_post_cmd;
const unsigned long long *charity_id;
const struct DONAU_CharityPrivateKeyP *charity_priv;
+
charity_post_cmd = TALER_TESTING_interpreter_lookup_command (is,
ss->
charity_reference);
@@ -147,7 +149,9 @@ status_run (void *cls,
if (GNUNET_OK !=
TALER_TESTING_get_trait_charity_id (charity_post_cmd, &charity_id) ||
GNUNET_OK != TALER_TESTING_get_trait_charity_priv (charity_post_cmd,
- &charity_priv))
+ &charity_priv) ||
+ GNUNET_OK != TALER_TESTING_get_trait_charity_pub (charity_post_cmd,
+ &charity_pub))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
@@ -205,6 +209,7 @@ status_run (void *cls,
TALER_TESTING_interpreter_get_context (is),
TALER_TESTING_get_donau_url (is),
&ss->charity_priv,
+ charity_pub,
ss->charity_id,
ss->year,
ss->num_bkp,
diff --git a/src/util/charity_signatures.c b/src/util/charity_signatures.c
index 29ddb29..1924501 100644
--- a/src/util/charity_signatures.c
+++ b/src/util/charity_signatures.c
@@ -87,8 +87,8 @@ DONAU_charity_budi_key_pair_verify (
const struct DONAU_CharitySignatureP *charity_sig)
{
struct DONAU_BudiKeyPairTrackPS tps = {
- .purpose.size = htonl (sizeof (bkp[0]) * num_bkp),
.purpose.purpose = htonl (DONAU_SIGNATURE_CHARITY_DONATION_CONFIRMATION),
+ .purpose.size = htonl (sizeof (tps)),
.num_bkp = htonl (num_bkp)
};
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.