summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatyja Lukas Adam <lukas.matyja@students.bfh.ch>2024-05-01 01:49:05 +0200
committerMatyja Lukas Adam <lukas.matyja@students.bfh.ch>2024-05-01 01:49:05 +0200
commitfbf92c7f418d8da3088352b5856998778243ef3f (patch)
tree8d3d80cfcc53ff3a6a2d4f2617cb3494b68e9465
parent1c471ae8086bc768349b83fb62d6d59600c392a1 (diff)
downloaddonau-fbf92c7f418d8da3088352b5856998778243ef3f.tar.gz
donau-fbf92c7f418d8da3088352b5856998778243ef3f.tar.bz2
donau-fbf92c7f418d8da3088352b5856998778243ef3f.zip
[testing] issue receipts add blind and unblind
-rw-r--r--src/donau/donau-httpd_batch-submit.c2
-rw-r--r--src/include/donau_crypto_lib.h146
-rw-r--r--src/include/donau_service.h2
-rw-r--r--src/include/donau_testing_lib.h15
-rw-r--r--src/lib/donau_api_batch_submit_receipts.c14
-rw-r--r--src/testing/test_donau_api.c12
-rw-r--r--src/testing/testing_api_cmd_issue_receipts.c114
-rw-r--r--src/testing/testing_api_cmd_submit_receipts.c17
-rw-r--r--src/util/donau_crypto.c114
9 files changed, 352 insertions, 84 deletions
diff --git a/src/donau/donau-httpd_batch-submit.c b/src/donau/donau-httpd_batch-submit.c
index 41bf396..c908c86 100644
--- a/src/donau/donau-httpd_batch-submit.c
+++ b/src/donau/donau-httpd_batch-submit.c
@@ -208,4 +208,4 @@ DH_handler_submit_receipts_post (struct DH_RequestContext *rc,
}
-/* end of donau-httpd_post-submit-receipts.c */
+/* end of donau-httpd_post-submit-receipts.c */ \ No newline at end of file
diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h
index 8181611..9bf2ea5 100644
--- 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 Donau.
+ * @brief Type of (unblinded) donation receipts signatures for Taler.
*/
struct DONAU_DonationUnitSignature
{
@@ -326,14 +326,6 @@ struct DONAU_BkpSignData
/** USED?
* Hash of a budikeypair array
*/
-// struct DONAU_BudiKeyPairsHashP
-// {
-// struct GNUNET_HashCode hash;
-// };
-
-/** USED?
- * Hash of a budikeypair array
- */
// struct DONAU_BudiHashP
// {
// struct GNUNET_HashCode hash;
@@ -347,6 +339,38 @@ struct DONAU_UniqueDonorIdentifierHashP
struct GNUNET_HashCode hash;
};
+/**
+ * Hash of a budikeypair array
+ */
+struct DONAU_BudiHashP
+{
+ struct GNUNET_HashCode hash;
+};
+
+/**
+ * @brief Inputs needed from the donau for blind signing.
+ */
+struct DONAU_BatchIssueValues
+{
+ /**
+ * Input values.
+ */
+ struct GNUNET_CRYPTO_BlindingInputValues *blinding_inputs;
+};
+
+/**
+ * Master key material for the deriviation of
+ * blinding factors during issuing receipts.
+ */
+struct DONAU_BudiMasterSecretP
+{
+
+ /**
+ * Key material.
+ */
+ uint32_t key_data[8];
+
+};
/* ********************* charity eddsa signing ************************** */
@@ -425,7 +449,7 @@ DONAU_donation_statement_verify (
const struct DONAU_DonauSignatureP *statement_sig);
-///* ********************* donau blind signing ************************** */
+/* ********************* donau blind signing ************************** */
/**
* Verify donation receipt.
@@ -446,7 +470,7 @@ DONAU_donation_receipt_verify (
* Free internals of @a donation_unit_sig, but not @a donation_unit_sig itself.
*
* @param[in] donation_unit_sig signature to free
-// */
+ */
void
DONAU_blinded_donation_unit_sig_free (
struct DONAU_BlindedDonationUnitSignature *donation_unit_sig);
@@ -461,12 +485,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?
@@ -583,6 +607,82 @@ DONAU_blinded_donation_unit_sig_free (
// const struct DONAU_ *c_hash);
//
+/* ********************* client blind/unblind ************************** */
+
+/**
+ * Create a blinding secret @a bks given the client's @a ps and the alg_values
+ * from the exchange.
+ *
+ * @param ps secret to derive blindings from
+ * @param alg_values containing cipher and additional CS values
+ * @param[out] bks blinding secrets
+ */
+void
+DONAU_budi_secret_create (
+ const struct DONAU_BudiMasterSecretP *ps,
+ const struct DONAU_BatchIssueValues *alg_values,
+ union GNUNET_CRYPTO_BlindingSecretP *bks);
+
+
+/**
+ * Return the alg value singleton for creation of
+ * blinding secrets for RSA.
+ *
+ * @return singleton to use for RSA blinding
+ */
+const struct DONAU_BatchIssueValues *
+DONAU_donation_unit_ewv_rsa_singleton (void);
+
+
+/**
+ * Blind udi for blind signing with @a du_pub using blinding secret @a budi_secret.
+ *
+ * NOTE: As a particular oddity, the @a budi is only partially
+ * initialized by this function in the case of CS donation units. Here, the
+ * 'nonce' must be initialized separately!
+ *
+ * @param du_pub donation unit public key to blind for
+ * @param budi_secret blinding secret to use
+ * @param cs_nonce nonce used to derive session values,
+ * could be NULL for ciphers that do not use it
+ * @param udi_nonce guarantees uniqueness, part of the message to blind
+ * @param h_tax_id hashed and salted tax id, part of the message to blind
+ * @param alg_values algorithm specific values to blind the udi
+ * @param[out] udi_hash resulting hashed @a h_tax_id with @a udi_nonce
+ * @param[out] budi blinded udi data to initialize
+ * @return #GNUNET_OK on success
+ */
+enum GNUNET_GenericReturnValue
+DONAU_donation_unit_blind (
+ const struct DONAU_DonationUnitPublicKey *du_pub,
+ const union GNUNET_CRYPTO_BlindingSecretP *budi_secret,
+ const union GNUNET_CRYPTO_BlindSessionNonce *cs_nonce,
+ const struct DONAU_UniqueDonorIdentifierNonce *udi_nonce,//message
+ const struct DONAU_HashDonorTaxId *h_tax_id, //message
+ const struct DONAU_BatchIssueValues *alg_values,
+ struct DONAU_UniqueDonorIdentifierHashP *udi_hash,
+ struct DONAU_BlindedUniqueDonorIdentifier *budi);
+
+
+/**
+ * Unblind blinded signature.
+ *
+ * @param[out] du_sig where to write the unblinded signature
+ * @param blind_du_sig the blinded signature
+ * @param budi_secret blinding secret to use
+ * @param udi_hash hash of udi for verification of the signature
+ * @param alg_values algorithm specific values
+ * @param du_pub public key used for signing
+ * @return #GNUNET_OK on success
+ */
+enum GNUNET_GenericReturnValue
+DONAU_donation_unit_sig_unblind (
+ struct DONAU_DonationUnitSignature *du_sig,
+ const struct DONAU_BlindedDonationUnitSignature *blind_du_sig,
+ const union GNUNET_CRYPTO_BlindingSecretP *budi_secret,
+ const struct DONAU_UniqueDonorIdentifierHashP *udi_hash,
+ const struct DONAU_BatchIssueValues *alg_values,
+ const struct DONAU_DonationUnitPublicKey *du_pub);
/*********************** helpers ************************************************/
/**
@@ -616,17 +716,6 @@ DONAU_donation_unit_group_get_key (
struct GNUNET_HashCode *key);
/**
- * @brief Inputs needed from the donau for blind signing.
- */
-struct TALER_DonauBatchIssueValues
-{
- /**
- * Input values.
- */
- struct GNUNET_CRYPTO_BlindingInputValues *blinding_inputs;
-};
-
-/**
* Compute the hash of a Unique Donor Identifier.
*
* @param h_donor_tax_id hash of the tax id
@@ -639,5 +728,4 @@ DONAU_unique_donor_id_hash (const struct DONAU_HashDonorTaxId *h_donor_tax_id,
,
struct DONAU_UniqueDonorIdentifierHashP *h_udi);
-
#endif
diff --git a/src/include/donau_service.h b/src/include/donau_service.h
index 0654db9..722f321 100644
--- a/src/include/donau_service.h
+++ b/src/include/donau_service.h
@@ -708,7 +708,7 @@ struct DONAU_CsRBatchIssueResponse
* Values contributed by the donau for the
* respective donation receipts's batch-issue operation.
*/
- struct TALER_DonauBatchIssueValues alg_values;
+ struct DONAU_BatchIssueValues alg_values;
} ok;
diff --git a/src/include/donau_testing_lib.h b/src/include/donau_testing_lib.h
index 2a64ed4..1e2bd17 100644
--- a/src/include/donau_testing_lib.h
+++ b/src/include/donau_testing_lib.h
@@ -118,7 +118,8 @@ TALER_TESTING_cmd_charities_get (const char *label,
* @param label the command label.
* @param charity_reference reference for traits
* @param year current year (mostly)
- * @param num_bkps number of budi key pairs
+ * @param donor_tax_id tax id of the donor
+ * @param salt for tax id hash
* @param expected_response_code expected HTTP response code.
* @return the command.
*/
@@ -126,7 +127,8 @@ struct TALER_TESTING_Command
TALER_TESTING_cmd_issue_receipts (const char *label,
const char *charity_reference,
const uint64_t year,
- const size_t num_bkp,
+ const char *donor_tax_id,
+ const char *salt,
unsigned int expected_response_code);
@@ -134,17 +136,15 @@ TALER_TESTING_cmd_issue_receipts (const char *label,
* Create a POST "batch-issue" command.
*
* @param label the command label.
+ * @param issue_receipt_reference reference for traits
* @param year current or past year (mostly)
- * @param donor_tax_id current year (mostly)
- * @param salt current year (mostly)
* @param expected_response_code expected HTTP response code.
* @return the command.
*/
struct TALER_TESTING_Command
TALER_TESTING_cmd_submit_receipts (const char *label,
+ const char *issue_receipt_reference,
const uint64_t year,
- const char *donor_tax_id,
- const char *salt,
unsigned int expected_response_code);
@@ -190,7 +190,8 @@ TALER_TESTING_get_donau_url (
op (charity_pub, const struct DONAU_CharityPublicKeyP) \
op (charity_id, const unsigned long long) \
op (donau_url, const char) \
- op (donau_keys, struct DONAU_Keys)
+ op (donau_keys, struct DONAU_Keys) \
+ op (salted_tax_id_hash, struct DONAU_HashDonorTaxId)
/**
diff --git a/src/lib/donau_api_batch_submit_receipts.c b/src/lib/donau_api_batch_submit_receipts.c
index 4c53313..d0ddfe3 100644
--- a/src/lib/donau_api_batch_submit_receipts.c
+++ b/src/lib/donau_api_batch_submit_receipts.c
@@ -74,14 +74,14 @@ struct DONAU_DonorReceiptsToStatementHandle
* @param num_drs number of donation receipts in @drs
* @param drs donation receipts array
* @param year corresponding year
- * @param h_donor_tax_id salted and hashed tax id
+ * @param h_tax_id salted and hashed tax id
*/
json_t *
submit_request_body_to_json (const size_t num_drs,
const struct
DONAU_DonationReceipt drs[num_drs],
const uint64_t year,
- const struct DONAU_HashDonorTaxId *h_donor_tax_id)
+ const struct DONAU_HashDonorTaxId *h_tax_id)
{
json_t *donation_receipts = json_array ();
GNUNET_assert (NULL != donation_receipts);
@@ -93,7 +93,7 @@ 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),
- DONAU_JSON_pack_donation_unit_sig ("donation_unit_sig",
+ DONAU_JSON_pack_donation_unit_sig ("donau_sig",
&drs[i].donation_unit_sig));
GNUNET_assert (0 ==
json_array_append_new (donation_receipts,
@@ -102,8 +102,8 @@ submit_request_body_to_json (const size_t num_drs,
return GNUNET_JSON_PACK (
GNUNET_JSON_pack_array_steal ("donation_receipts",
donation_receipts),
- GNUNET_JSON_pack_data_auto ("h_donor_tax_id",
- h_donor_tax_id),
+ GNUNET_JSON_pack_data_auto ("h_tax_number",
+ h_tax_id),
GNUNET_JSON_pack_uint64 ("donation_year",
year));
}
@@ -187,7 +187,7 @@ DONAU_donor_receipts_to_statement (
const size_t num_drs,
const struct DONAU_DonationReceipt drs[num_drs],
const uint64_t year,
- const struct DONAU_HashDonorTaxId *h_donor_tax_id,
+ const struct DONAU_HashDonorTaxId *h_tax_id,
DONAU_DonorReceiptsToStatementResultCallback cb,
void *cls)
{
@@ -215,7 +215,7 @@ DONAU_donor_receipts_to_statement (
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"submit_receipts_with_URL `%s'.\n",
birh->url);
- body = submit_request_body_to_json (num_drs, drs, year, h_donor_tax_id);
+ body = submit_request_body_to_json (num_drs, drs, year, h_tax_id);
eh = DONAU_curl_easy_get_ (birh->url);
if ( (NULL == eh) ||
(GNUNET_OK !=
diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c
index 98f1695..a0e9eca 100644
--- a/src/testing/test_donau_api.c
+++ b/src/testing/test_donau_api.c
@@ -95,13 +95,13 @@ run (void *cls,
TALER_TESTING_cmd_issue_receipts ("issue-receipts",
"post-charity",
2024,
- 3, // number of budi key pairs
+ "7560001010000", // tax id
+ "1234", //salt for tax id hash
MHD_HTTP_CREATED),
-// TALER_TESTING_cmd_submit_receipts ("submit-receipts",
-// 2024,
-// "7560001010000", // tax id
-// "1234", //salt
-// MHD_HTTP_OK),
+ TALER_TESTING_cmd_submit_receipts ("submit-receipts",
+ "issue-receipts", // cmd trait reference
+ 2024,
+ MHD_HTTP_OK),
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
index bea1be2..12062ed 100644
--- a/src/testing/testing_api_cmd_issue_receipts.c
+++ b/src/testing/testing_api_cmd_issue_receipts.c
@@ -83,6 +83,16 @@ struct StatusState
*/
struct DONAU_Keys *keys;
+ /**
+ * Hashed and salted tax id of the donor.
+ */
+ struct DONAU_HashDonorTaxId *h_donor_tax_id;
+
+ /**
+ * Array of generated nonces for the udis.
+ */
+ struct DONAU_UniqueDonorIdentifierNonce *udi_nonces;
+
};
@@ -181,24 +191,50 @@ status_run (void *cls,
ss->bkps
= GNUNET_new_array (ss->num_bkp,
struct DONAU_BlindedUniqueDonorIdentifierKeyPair);
+ union GNUNET_CRYPTO_BlindingSecretP blinded_secrets[ss->num_bkp];
for (size_t cnt = 0; cnt < ss->num_bkp; cnt++)
{
- struct GNUNET_CRYPTO_RsaBlindedMessage *rp;
- struct DONAU_BlindedUniqueDonorIdentifier *bp = {0};
+ struct DONAU_UniqueDonorIdentifierNonce udi_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;
+ alg_values = DONAU_donation_unit_ewv_rsa_singleton ();
+
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
+ &ps,
+ sizeof (ps));
+ DONAU_budi_secret_create (&ps,
+ alg_values,
+ &blinded_secrets[cnt]);
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
+ &udi_nonce,
+ sizeof (udi_nonce));
+ GNUNET_assert (GNUNET_OK ==
+ DONAU_donation_unit_blind (&ss->keys->donation_unit_keys[0].key,
+ &blinded_secrets[cnt],
+ NULL, /* no cs-nonce needed for rsa */
+ &udi_nonce,
+ ss->h_donor_tax_id,
+ alg_values,
+ &udi_hash,
+ blinded_udi));
+
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;
- bp->blinded_message->rc = 1;
- rp = &bp->blinded_message->details.rsa_blinded_message;
- rp->blinded_msg_size = 1 + (size_t) GNUNET_CRYPTO_random_u64 (
- GNUNET_CRYPTO_QUALITY_WEAK,
- (1024 / 8) - 1); // 1024 is the RSA key size
- rp->blinded_msg = GNUNET_malloc (rp->blinded_msg_size);
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
- rp->blinded_msg,
- rp->blinded_msg_size);
+ // struct GNUNET_CRYPTO_RsaBlindedMessage *rp;
+ // bp = &ss->bkps[cnt].blinded_udi;
+ // bp->blinded_message = GNUNET_new (struct GNUNET_CRYPTO_BlindedMessage);
+ // bp->blinded_message->cipher = GNUNET_CRYPTO_BSA_RSA;
+ // bp->blinded_message->rc = 1;
+ // rp = &bp->blinded_message->details.rsa_blinded_message;
+ // rp->blinded_msg_size = 1 + (size_t) GNUNET_CRYPTO_random_u64 (
+ // GNUNET_CRYPTO_QUALITY_WEAK,
+ // (1024 / 8) - 1); // 1024 is the RSA key size
+ // rp->blinded_msg = GNUNET_malloc (rp->blinded_msg_size);
+ // GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+ // rp->blinded_msg,
+ // rp->blinded_msg_size);
}
const struct DONAU_BlindedUniqueDonorIdentifierKeyPair *bkps = ss->bkps;
@@ -252,11 +288,40 @@ cleanup (void *cls,
}
+/**
+ * Offer internal data from a "deposit" CMD, to other commands.
+ *
+ * @param cls closure.
+ * @param[out] ret result.
+ * @param trait name of the trait.
+ * @param index index number of the object to offer.
+ * @return #GNUNET_OK on success.
+ */
+static enum GNUNET_GenericReturnValue
+issue_receipts_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ struct StatusState *ss = cls;
+ struct TALER_TESTING_Trait traits[] = {
+ TALER_TESTING_make_trait_salted_tax_id_hash (ss->h_donor_tax_id),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+}
+
+
struct TALER_TESTING_Command
TALER_TESTING_cmd_issue_receipts (const char *label,
const char *charity_reference,
const uint64_t year,
- const size_t num_bkp,
+ const char *donor_tax_id,
+ const char *salt,
unsigned int expected_response_code)
{
struct StatusState *ss;
@@ -266,14 +331,27 @@ TALER_TESTING_cmd_issue_receipts (const char *label,
ss->year = year;
ss->charity_reference = charity_reference;
ss->expected_response_code = expected_response_code;
- ss->num_bkp = num_bkp;
-
+ ss->num_bkp = 3;
+ struct DONAU_HashDonorTaxId h_donor_tax_id;
+ struct GNUNET_HashContext *hash_context;
+ hash_context = GNUNET_CRYPTO_hash_context_start ();
+
+ GNUNET_CRYPTO_hash_context_read (hash_context,
+ donor_tax_id,
+ sizeof((*donor_tax_id))),
+ GNUNET_CRYPTO_hash_context_read (hash_context,
+ salt,
+ sizeof((*salt)));
+ GNUNET_CRYPTO_hash_context_finish (hash_context,
+ &h_donor_tax_id.hash);
+ ss->h_donor_tax_id = &h_donor_tax_id;
{
struct TALER_TESTING_Command cmd = {
.cls = ss,
.label = label,
.run = &status_run,
- .cleanup = &cleanup
+ .cleanup = &cleanup,
+ .traits = &issue_receipts_traits
};
return cmd;
diff --git a/src/testing/testing_api_cmd_submit_receipts.c b/src/testing/testing_api_cmd_submit_receipts.c
index 7957152..8b5f5b0 100644
--- a/src/testing/testing_api_cmd_submit_receipts.c
+++ b/src/testing/testing_api_cmd_submit_receipts.c
@@ -195,9 +195,8 @@ cleanup (void *cls,
struct TALER_TESTING_Command
TALER_TESTING_cmd_submit_receipts (const char *label,
+ const char *issue_receipt_reference,
const uint64_t year,
- const char *donor_tax_id,
- const char *salt,
unsigned int expected_response_code)
{
struct StatusState *ss;
@@ -206,19 +205,7 @@ TALER_TESTING_cmd_submit_receipts (const char *label,
ss->year = year;
ss->expected_response_code = expected_response_code;
- struct DONAU_HashDonorTaxId h_donor_tax_id;
- struct GNUNET_HashContext *hash_context;
- hash_context = GNUNET_CRYPTO_hash_context_start ();
-
- GNUNET_CRYPTO_hash_context_read (hash_context,
- donor_tax_id,
- sizeof((*donor_tax_id))),
- GNUNET_CRYPTO_hash_context_read (hash_context,
- salt,
- sizeof((*salt)));
- GNUNET_CRYPTO_hash_context_finish (hash_context,
- &h_donor_tax_id.hash);
- ss->h_donor_tax_id = &h_donor_tax_id;
+ // ss->h_donor_tax_id = &h_donor_tax_id;
{
struct TALER_TESTING_Command cmd = {
.cls = ss,
diff --git a/src/util/donau_crypto.c b/src/util/donau_crypto.c
index 6d86466..ffe7b53 100644
--- a/src/util/donau_crypto.c
+++ b/src/util/donau_crypto.c
@@ -172,3 +172,117 @@ DONAU_donation_receipt_verify (
h_udi,
sizeof (*h_udi));
}
+
+enum GNUNET_GenericReturnValue
+DONAU_donation_unit_blind (
+ const struct DONAU_DonationUnitPublicKey *du_pub,
+ const union GNUNET_CRYPTO_BlindingSecretP *budi_secret,
+ const union GNUNET_CRYPTO_BlindSessionNonce *cs_nonce,
+ const struct DONAU_UniqueDonorIdentifierNonce *udi_nonce,//message
+ const struct DONAU_HashDonorTaxId *h_tax_id, //message
+ const struct DONAU_BatchIssueValues *alg_values,
+ struct DONAU_UniqueDonorIdentifierHashP *udi_hash,
+ struct DONAU_BlindedUniqueDonorIdentifier *budi)
+{
+ struct GNUNET_HashContext *hash_context;
+ hash_context = GNUNET_CRYPTO_hash_context_start ();
+
+ GNUNET_CRYPTO_hash_context_read (hash_context,
+ udi_nonce,
+ sizeof((*udi_nonce))),
+ GNUNET_CRYPTO_hash_context_read (hash_context,
+ h_tax_id,
+ sizeof((*h_tax_id)));
+ GNUNET_CRYPTO_hash_context_finish (hash_context,
+ &udi_hash->hash);
+
+ budi->blinded_message
+ = GNUNET_CRYPTO_message_blind_to_sign (du_pub->bsign_pub_key,
+ budi_secret,
+ cs_nonce,
+ udi_hash,
+ sizeof (*udi_hash),
+ alg_values->blinding_inputs);
+ if (NULL == budi->blinded_message)
+ return GNUNET_SYSERR;
+ return GNUNET_OK;
+}
+
+enum GNUNET_GenericReturnValue
+DONAU_donation_unit_sig_unblind (
+ struct DONAU_DonationUnitSignature *du_sig,
+ const struct DONAU_BlindedDonationUnitSignature *blind_du_sig,
+ const union GNUNET_CRYPTO_BlindingSecretP *budi_secret,
+ const struct DONAU_UniqueDonorIdentifierHashP *udi_hash,
+ const struct DONAU_BatchIssueValues *alg_values,
+ const struct DONAU_DonationUnitPublicKey *du_pub)
+{
+ du_sig->unblinded_sig
+ = GNUNET_CRYPTO_blind_sig_unblind (blind_du_sig->blinded_sig,
+ budi_secret,
+ udi_hash,
+ sizeof (*udi_hash),
+ alg_values->blinding_inputs,
+ du_pub->bsign_pub_key);
+ if (NULL == du_sig->unblinded_sig)
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+void
+DONAU_budi_secret_create (
+ const struct DONAU_BudiMasterSecretP *ps,
+ const struct DONAU_BatchIssueValues *alg_values,
+ union GNUNET_CRYPTO_BlindingSecretP *bks)
+{
+ const struct GNUNET_CRYPTO_BlindingInputValues *bi =
+ alg_values->blinding_inputs;
+
+ switch (bi->cipher)
+ {
+ case GNUNET_CRYPTO_BSA_INVALID:
+ GNUNET_break (0);
+ return;
+ case GNUNET_CRYPTO_BSA_RSA:
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CRYPTO_kdf (&bks->rsa_bks,
+ sizeof (bks->rsa_bks),
+ "bks",
+ strlen ("bks"),
+ ps,
+ sizeof(*ps),
+ NULL,
+ 0));
+ return;
+ case GNUNET_CRYPTO_BSA_CS:
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CRYPTO_kdf (&bks->nonce,
+ sizeof (bks->nonce),
+ "bseed",
+ strlen ("bseed"),
+ ps,
+ sizeof(*ps),
+ &bi->details.cs_values,
+ sizeof(bi->details.cs_values),
+ NULL,
+ 0));
+ return;
+ }
+ GNUNET_assert (0);
+}
+
+
+const struct DONAU_BatchIssueValues *
+DONAU_donation_unit_ewv_rsa_singleton ()
+{
+ static struct GNUNET_CRYPTO_BlindingInputValues bi = {
+ .cipher = GNUNET_CRYPTO_BSA_RSA
+ };
+ static struct DONAU_BatchIssueValues alg_values = {
+ .blinding_inputs = &bi
+ };
+ return &alg_values;
+} \ No newline at end of file