merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit ce731ccc4d9bfae7178f6f993757940de4ac022d
parent 3e0645c3f86a44112802603e5ab1afd8f247f229
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Mon, 14 Apr 2025 15:35:06 +0200

adding some missing part of process of receiving the BUDIs key pairs

Diffstat:
Msrc/testing/testing_api_cmd_pay_order.c | 127+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 122 insertions(+), 5 deletions(-)

diff --git a/src/testing/testing_api_cmd_pay_order.c b/src/testing/testing_api_cmd_pay_order.c @@ -41,6 +41,29 @@ #endif /* HAVE_DONAU_DONAU_SERVICE_H */ #ifdef HAVE_DONAU_DONAU_SERVICE_H +struct CSR_Data +{ + /** + * Handle to the "batch issue receipt status" operation. + */ + struct DONAU_CsRBatchIssueHandle *csr_handle; + + /** + * CS-Nonce + */ + union GNUNET_CRYPTO_BlindSessionNonce nonce; + + /** + * batch issue receipt status state + */ + struct StatusState *ss; + + /** + * array position in batch issue receipt request (first position is zero) + */ + size_t position; +}; + struct MerchantDonauPayData { /** @@ -71,7 +94,7 @@ struct MerchantDonauPayData /** * Number of BUDIs to create or fetch. Example only. */ - size_t num_budis; + size_t num_bkps; /** * Year of the donation @@ -81,7 +104,7 @@ struct MerchantDonauPayData /** * BUDI keypairs used in the payment (blinded_udi + pubkey). */ - struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkp; + struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkps; /** * Blinding secrets, if needed for each BUDI (CS vs. RSA). @@ -89,11 +112,26 @@ struct MerchantDonauPayData union GNUNET_CRYPTO_BlindingSecretP *blinding_secrets; /** + * Blinding values. Cs-nonces, cipher. + */ + const struct DONAU_BatchIssueValues **alg_values; + + /** * Hash of the salted donor tax id, if relevant. */ struct DONAU_HashDonorTaxId h_donor_tax_id; /** + * Array of donation receipts; + */ + struct DONAU_DonationReceipt *receipts; + + /** + * Array of hashed udis. + */ + struct DONAU_UniqueDonorIdentifierHashP *h_udis; + + /** * If using the CS approach, we might track how many * asynchronous calls are still pending, etc. */ @@ -101,8 +139,7 @@ struct MerchantDonauPayData }; -//FIXME: Here I need a command which will parse the data from this system, and donau system -// and will prepare all necessary data for the donau pay order +//FIXME: One thing left is to receive the BUDIsKP static enum GNUNET_GenericReturnValue prepare_donau_data(struct TALER_TESTING_Interpreter *is, struct MerchantDonauPayData *ss){ @@ -150,6 +187,86 @@ prepare_donau_data(struct TALER_TESTING_Interpreter *is, /* Get BUDIsKP */ { //FIXME: Define me pleeeease + ss->bkps = + GNUNET_new_array (ss->num_bkps, struct + DONAU_BlindedUniqueDonorIdentifierKeyPair); + ss->blinding_secrets = + GNUNET_new_array (ss->num_bkps, union GNUNET_CRYPTO_BlindingSecretP); + ss->receipts = + GNUNET_new_array (ss->num_bkps, struct DONAU_DonationReceipt); + ss->alg_values = + GNUNET_new_array (ss->num_bkps, const struct DONAU_BatchIssueValues *); + ss->h_udis = + GNUNET_new_array (ss->num_bkps, struct DONAU_UniqueDonorIdentifierHashP); + + + for (size_t cnt = 0; cnt < ss->num_bkps; cnt++) + { + DONAU_donation_unit_pub_hash (&ss->keys->donation_unit_keys[0].key, + &ss->bkps[cnt].h_donation_unit_pub); + + ss->receipts[cnt].h_donation_unit_pub = ss->bkps[cnt].h_donation_unit_pub; + struct DONAU_UniqueDonorIdentifierNonce *udi_nonce = + &ss->receipts[cnt].nonce; + struct DONAU_BudiMasterSecretP ps; + const struct DONAU_BatchIssueValues *alg_values; + struct DONAU_BlindedUniqueDonorIdentifier *blinded_udi = + &ss->bkps[cnt].blinded_udi; + struct DONAU_UniqueDonorIdentifierHashP *udi_hash = &ss->h_udis[cnt]; + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, + &ps, + sizeof (ps)); + GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, + udi_nonce, + sizeof (*udi_nonce)); + switch (ss->keys->donation_unit_keys[0].key.bsign_pub_key->cipher) + { + case GNUNET_CRYPTO_BSA_RSA: + alg_values = DONAU_donation_unit_ewv_rsa_singleton (); + DONAU_budi_secret_create (&ps, + alg_values, + &ss->blinding_secrets[cnt]); + GNUNET_assert (GNUNET_OK == + DONAU_donation_unit_blind ( + &ss->keys->donation_unit_keys[0].key, + &ss->blinding_secrets[cnt], + NULL, /* no cs-nonce needed for rsa */ + udi_nonce, + &ss->h_donor_tax_id, + alg_values, + udi_hash, + blinded_udi)); + ss->alg_values[cnt] = alg_values; + break; + case GNUNET_CRYPTO_BSA_CS: + //FUCK THIS CS CASE +// struct CSR_Data *csr_data = GNUNET_new (struct CSR_Data); +// TALER_cs_withdraw_nonce_derive ( // FIXME: write new method +// (struct TALER_PlanchetMasterSecretP *) &ps, +// &csr_data->nonce.cs_nonce); +// csr_data->ss = is; +// csr_data->position = cnt; +// +// csr_data->csr_handle = DONAU_csr_issue ( +// TALER_TESTING_interpreter_get_context (is), +// TALER_TESTING_get_donau_url (is), +// &ss->keys->donation_unit_keys[0].key, +// &csr_data->nonce.cs_nonce, +// &cs_stage_two_callback, +// csr_data); +// if (NULL == csr_data->csr_handle) +// { +// GNUNET_break (0); +// } +// ss->cs_pending++; + break; + default: + GNUNET_break (0); + } + } + //What to do with the next thing from donau + //if (0 == ss->cs_pending) + // phase_two (ss); } return GNUNET_OK; @@ -1308,7 +1425,7 @@ TALER_TESTING_cmd_merchant_pay_order_choices (const char *label, mdpd = GNUNET_new (struct MerchantDonauPayData); mdpd->year = year; - mdpd->num_budis = 3; + mdpd->num_bkps = 3; mdpd->charity_reference = charity_reference; /* Here we generate the h_donor_tax_id*/