donau

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

commit e0070070910767c856452884b106cfd2fc5fbf0d
parent 23a2e824c765f239f542a9aec43e0d279871f897
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Mon,  8 Apr 2024 16:40:35 +0200

[donau][testing] work on issue receipts

Diffstat:
Msrc/donau/donau-httpd_post-batch-issue.c | 2+-
Msrc/include/donau_crypto_lib.h | 6++----
Msrc/include/donau_service.h | 5++---
Msrc/json/donau_json.c | 30+++++++++++++++---------------
Msrc/lib/donau_api_batch_issue_receipts.c | 14++++++--------
Msrc/testing/test_donau_api.c | 10+++++-----
Msrc/testing/testing_api_cmd_issue_receipts.c | 28++++++++++++++++++++++++++--
Msrc/util/charity_signatures.c | 4++--
8 files changed, 59 insertions(+), 40 deletions(-)

diff --git a/src/donau/donau-httpd_post-batch-issue.c b/src/donau/donau-httpd_post-batch-issue.c @@ -235,7 +235,7 @@ DH_handler_issue_receipts_post (struct DH_RequestContext *rc, "got charity from db!"); /* verify charity signature */ if (GNUNET_OK != - DONAU_charity_budi_key_pair_verify (num_bkp, &irc.bkp, + DONAU_charity_budi_key_pair_verify (num_bkp, irc.bkp, &charity_meta.charity_pub, &irc.charity_sig)) { diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h @@ -303,8 +303,7 @@ struct DONAU_BudiHashP void DONAU_charity_budi_key_pair_sign ( const unsigned int num_bkp, - const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp[static - num_bkp], + const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, const struct DONAU_CharityPrivateKeyP *charity_priv, struct DONAU_CharitySignatureP *charity_sig); @@ -321,8 +320,7 @@ DONAU_charity_budi_key_pair_sign ( enum GNUNET_GenericReturnValue DONAU_charity_budi_key_pair_verify ( const unsigned int num_bkp, - const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp[static - num_bkp], + const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, const struct DONAU_CharityPublicKeyP *charity_pub, const struct DONAU_CharitySignatureP *charity_sig); diff --git a/src/include/donau_service.h b/src/include/donau_service.h @@ -537,9 +537,8 @@ DONAU_charity_issue_receipt ( const struct DONAU_CharityPrivateKeyP *charity_priv, const uint64_t charity_id, const uint64_t year, - const unsigned int num_bkp, - const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp[static - num_bkp], + const size_t num_bkp, + const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, DONAU_BatchIssueReceiptsCallback cb, void *cb_cls); diff --git a/src/json/donau_json.c b/src/json/donau_json.c @@ -233,7 +233,7 @@ DONAU_JSON_spec_donation_unit_pub (const char *field, /** - * Parse given JSON object to blinded planchet. + * Parse given JSON object to blinded unique donation identifier. * * @param cls closure, NULL * @param root the json object representing data @@ -241,11 +241,11 @@ DONAU_JSON_spec_donation_unit_pub (const char *field, * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ static enum GNUNET_GenericReturnValue -parse_blinded_planchet (void *cls, - json_t *root, - struct GNUNET_JSON_Specification *spec) +parse_blinded_donation_identifier (void *cls, + json_t *root, + struct GNUNET_JSON_Specification *spec) { - struct TALER_BlindedPlanchet *blinded_planchet = spec->ptr; + struct DONAU_BlindedUniqueDonationIdentifier *blinded_udi = spec->ptr; struct GNUNET_CRYPTO_BlindedMessage *blinded_message; const char *cipher; struct GNUNET_JSON_Specification dspec[] = { @@ -277,7 +277,7 @@ parse_blinded_planchet (void *cls, { struct GNUNET_JSON_Specification ispec[] = { GNUNET_JSON_spec_varsize ( - "rsa_blinded_planchet", + "rsa_blinded_identifier", &blinded_message->details.rsa_blinded_message.blinded_msg, &blinded_message->details.rsa_blinded_message.blinded_msg_size), GNUNET_JSON_spec_end () @@ -293,7 +293,7 @@ parse_blinded_planchet (void *cls, GNUNET_free (blinded_message); return GNUNET_SYSERR; } - blinded_planchet->blinded_message = blinded_message; + blinded_udi->blinded_message = blinded_message; return GNUNET_OK; } case GNUNET_CRYPTO_BSA_CS: @@ -321,7 +321,7 @@ parse_blinded_planchet (void *cls, GNUNET_free (blinded_message); return GNUNET_SYSERR; } - blinded_planchet->blinded_message = blinded_message; + blinded_udi->blinded_message = blinded_message; return GNUNET_OK; } } @@ -332,19 +332,19 @@ parse_blinded_planchet (void *cls, /** - * Cleanup data left from parsing blinded planchet. + * Cleanup data left from parsing blinded unique donation identifier. * * @param cls closure, NULL * @param[out] spec where to free the data */ static void -clean_blinded_planchet (void *cls, - struct GNUNET_JSON_Specification *spec) +clean_blinded_donation_identifier (void *cls, + struct GNUNET_JSON_Specification *spec) { - struct TALER_BlindedPlanchet *blinded_planchet = spec->ptr; + struct TALER_BlindedPlanchet *blinded_udi = spec->ptr; (void) cls; - TALER_blinded_planchet_free (blinded_planchet); + TALER_blinded_planchet_free (blinded_udi); } @@ -356,8 +356,8 @@ DONAU_JSON_spec_blinded_donation_identifier (const char *field, blinded_udi) { struct GNUNET_JSON_Specification ret = { - .parser = &parse_blinded_planchet, - .cleaner = &clean_blinded_planchet, + .parser = &parse_blinded_donation_identifier, + .cleaner = &clean_blinded_donation_identifier, .field = field, .ptr = blinded_udi }; diff --git a/src/lib/donau_api_batch_issue_receipts.c b/src/lib/donau_api_batch_issue_receipts.c @@ -84,8 +84,7 @@ struct DONAU_BatchIssueReceiptHandle json_t * issue_receipt_body_to_json (const unsigned int num_bkp, const struct - DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp[ - static num_bkp], + DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, const uint64_t year, const struct DONAU_CharitySignatureP *charity_sig) { @@ -96,9 +95,9 @@ issue_receipt_body_to_json (const unsigned int num_bkp, { json_t *budikeypair = GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("h_du_pub", - &bkp[i]->h_donation_unit_pub)); -// DONAU_JSON_pack_blinded_donation_identifier ("blinded_udi", -// &bkp[i]->blinded_udi)); + &bkp[i].h_donation_unit_pub.hash), + DONAU_JSON_pack_blinded_donation_identifier ("blinded_udi", + &bkp[i].blinded_udi)); GNUNET_assert (0 == json_array_append_new (budikeypairs, budikeypair)); @@ -184,9 +183,8 @@ DONAU_charity_issue_receipt ( const struct DONAU_CharityPrivateKeyP *charity_priv, const uint64_t charity_id, const uint64_t year, - const unsigned int num_bkp, - const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp[static - num_bkp], + const size_t num_bkp, + const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, DONAU_BatchIssueReceiptsCallback cb, void *cb_cls) { diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c @@ -91,11 +91,11 @@ run (void *cls, TALER_TESTING_cmd_charities_get ("get-charities", &bearer, MHD_HTTP_OK), -// TALER_TESTING_cmd_issue_receipts ("issue-receipts", -// "post-charity", -// 2024, -// 3, // number of budi key pairs -// MHD_HTTP_CREATED), + TALER_TESTING_cmd_issue_receipts ("issue-receipts", + "post-charity", + 2024, + 3, // number of budi key pairs + MHD_HTTP_CREATED), TALER_TESTING_cmd_charity_delete ("delete-charity", "post-charity", // cmd trait reference &bearer, diff --git a/src/testing/testing_api_cmd_issue_receipts.c b/src/testing/testing_api_cmd_issue_receipts.c @@ -78,6 +78,11 @@ struct StatusState */ struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkps; + /** + * donau keys + */ + struct DONAU_Keys *keys; + }; @@ -152,6 +157,24 @@ status_run (void *cls, ss->charity_priv = *(charity_priv); } + /* Get donau keys from trait */ + { + const struct TALER_TESTING_Command *keys_cmd; + struct DONAU_Keys *keys; + + keys_cmd = TALER_TESTING_interpreter_lookup_command (is, + "get-donau"); + + if (GNUNET_OK != + TALER_TESTING_get_trait_donau_keys (keys_cmd, &keys)) + { + GNUNET_break (0); + TALER_TESTING_interpreter_fail (is); + return; + } + ss->keys = keys; + } + // TODO: build bkps with traits from /keys request, use the public sign key from the // DONAU to verify the signatures ss->bkps @@ -161,7 +184,8 @@ status_run (void *cls, { struct GNUNET_CRYPTO_RsaBlindedMessage *rp; struct DONAU_BlindedUniqueDonationIdentifier *bp; - // &ss->bkps[cnt].h_donation_unit_pub.hash = + DONAU_donation_unit_pub_hash (&ss->keys->donation_unit_keys[0].key, + &ss->bkps[cnt].h_donation_unit_pub); bp = &ss->bkps[cnt].blinded_udi; bp->blinded_message = GNUNET_new (struct GNUNET_CRYPTO_BlindedMessage); bp->blinded_message->cipher = GNUNET_CRYPTO_BSA_RSA; @@ -184,7 +208,7 @@ status_run (void *cls, ss->charity_id, ss->year, ss->num_bkp, - &bkps, + bkps, &issue_receipts_status_cb, ss); diff --git a/src/util/charity_signatures.c b/src/util/charity_signatures.c @@ -59,7 +59,7 @@ GNUNET_NETWORK_STRUCT_END void DONAU_charity_budi_key_pair_sign ( const unsigned int num_bkp, - const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp[num_bkp], + const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, const struct DONAU_CharityPrivateKeyP *charity_priv, struct DONAU_CharitySignatureP *charity_sig) { @@ -82,7 +82,7 @@ DONAU_charity_budi_key_pair_sign ( enum GNUNET_GenericReturnValue DONAU_charity_budi_key_pair_verify ( const unsigned int num_bkp, - const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp[num_bkp], + const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *bkp, const struct DONAU_CharityPublicKeyP *charity_pub, const struct DONAU_CharitySignatureP *charity_sig) {