gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-donau] 01/02: [donau] batch blind signing


From: gnunet
Subject: [taler-donau] 01/02: [donau] batch blind signing
Date: Thu, 18 Apr 2024 00:25:28 +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 064e297362fc9ae14b886aad99def74a0b4878b4
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
AuthorDate: Thu Apr 18 00:18:12 2024 +0200

    [donau] batch  blind signing
---
 src/donau/donau-httpd_batch-issue.c                |   8 +-
 src/donau/donau-httpd_keys.c                       | 277 ++++++++++-----------
 src/donau/donau-httpd_keys.h                       |  10 +-
 .../donau_do_save_issue_receipts_request.sql       |   2 +-
 src/testing/.test-suite.log.swp                    | Bin 0 -> 16384 bytes
 5 files changed, 149 insertions(+), 148 deletions(-)

diff --git a/src/donau/donau-httpd_batch-issue.c 
b/src/donau/donau-httpd_batch-issue.c
index bc2f21c..a240d81 100644
--- a/src/donau/donau-httpd_batch-issue.c
+++ b/src/donau/donau-httpd_batch-issue.c
@@ -345,12 +345,14 @@ start:
     bkps_sign_data[i].h_donation_unit_pub = &bkps[i].h_donation_unit_pub;
     bkps_sign_data[i].budi = &bkps[i].blinded_udi;
   }
-  if (TALER_EC_NONE != DH_keys_donation_unit_batch_sign (num_bkps,
+  enum TALER_ErrorCode batch_sign_ec;
+  batch_sign_ec = DH_keys_donation_unit_batch_sign (num_bkps,
                                                          bkps_sign_data,
-                                                         du_sigs))
+                                                         du_sigs);
+  if (TALER_EC_NONE != batch_sign_ec)
     return TALER_MHD_reply_with_error (rc->connection,
                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
-                                       TALER_EC_GENERIC_DB_FETCH_FAILED,   // 
TODO:other EC
+                                       batch_sign_ec,   // TODO:other EC
                                        NULL);
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "made blind signatures!\n");
diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c
index 2106f8d..bca8637 100644
--- a/src/donau/donau-httpd_keys.c
+++ b/src/donau/donau-httpd_keys.c
@@ -1289,147 +1289,146 @@ DH_keys_donau_sign_ (
 
 enum TALER_ErrorCode
 DH_keys_donation_unit_batch_sign (
-  unsigned int budis_length,
-  const struct DONAU_BkpSignData bkps[budis_length],
-  struct DONAU_BlindedDonationUnitSignature du_sigs[budis_length])
+  unsigned int num_bkps,
+  const struct DONAU_BkpSignData bkps[num_bkps],
+  struct DONAU_BlindedDonationUnitSignature du_sigs[num_bkps])
 {
+  struct DH_KeyStateHandle *ksh;
+  struct DH_DonationUnitKey *du;
+  struct TALER_CRYPTO_RsaSignRequest rsrs[num_bkps];
+  struct TALER_CRYPTO_CsSignRequest csrs[num_bkps];
+  struct TALER_BlindedDenominationSignature rs[num_bkps];
+  struct TALER_BlindedDenominationSignature cs[num_bkps];
+  unsigned int rsrs_pos = 0;
+  unsigned int csrs_pos = 0;
+  enum TALER_ErrorCode ec;
+
+  ksh = DH_keys_get_state ();
+  if (NULL == ksh)
+    // FIXME change error code
+    return TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING;
+  for (unsigned int i = 0; i<num_bkps; i++)
+  {
+    const struct DONAU_DonationUnitHashP *h_du_pub = 
bkps[i].h_donation_unit_pub;
+    const struct DONAU_BlindedUniqueDonorIdentifier *budi = bkps[i].budi;
+
+    du = GNUNET_CONTAINER_multihashmap_get (du_keys,
+                                            &h_du_pub->hash);
+    if (NULL == du)
+      // FIXME change error code
+      return TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN;
+    if (budi->blinded_message->cipher !=
+        du->donation_unit_pub.bsign_pub_key->cipher)
+      return TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE;
+    switch (du->donation_unit_pub.bsign_pub_key->cipher)
+    {
+    case GNUNET_CRYPTO_BSA_RSA:
+      /* See DONAU_donation_unit_pub_hash: we guarantee that these
+   hashes are equivalent! */
+      rsrs[rsrs_pos].h_rsa
+        = (const struct TALER_RsaPubHashP *) &du->h_donation_unit_pub;
+      rsrs[rsrs_pos].msg
+        = budi->blinded_message->details.rsa_blinded_message.blinded_msg;
+      rsrs[rsrs_pos].msg_size
+        = budi->blinded_message->details.rsa_blinded_message.blinded_msg_size;
+      rsrs_pos++;
+      break;
+    case GNUNET_CRYPTO_BSA_CS:
+      /* See DONAU_donation_unit_pub_hash: we guarantee that these
+   hashes are equivalent! */
+      csrs[csrs_pos].h_cs
+        = (const struct TALER_CsPubHashP *) &du->h_donation_unit_pub;
+      csrs[csrs_pos].blinded_planchet
+        = &budi->blinded_message->details.cs_blinded_message;
+      csrs_pos++;
+      break;
+    default:
+      return TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE;
+    }
+  }
+
+  if ( (0 != csrs_pos) &&
+       (0 != rsrs_pos) )
+  {
+    memset (rs,
+            0,
+            sizeof (rs));
+    memset (cs,
+            0,
+            sizeof (cs));
+  }
+  ec = TALER_EC_NONE;
+  if (0 != csrs_pos)
+  {
+    ec = TALER_CRYPTO_helper_cs_batch_sign (
+      csdh,
+      csrs_pos,
+      csrs,
+      false, // for_melt
+      cs);
+    if (TALER_EC_NONE != ec)
+    {
+      for (unsigned int i = 0; i<csrs_pos; i++)
+      {
+        if (NULL != cs[i].blinded_sig)
+        {
+          GNUNET_CRYPTO_blinded_sig_decref (cs[i].blinded_sig);
+          cs[i].blinded_sig = NULL;
+        }
+      }
+      return ec;
+    }
+    // TEH_METRICS_num_signatures[TEH_MT_SIGNATURE_CS] += csrs_pos;
+  }
+  if (0 != rsrs_pos)
+  {
+    ec = TALER_CRYPTO_helper_rsa_batch_sign (
+      rsadh,
+      rsrs_pos,
+      rsrs,
+      rs);
+    if (TALER_EC_NONE != ec)
+    {
+      for (unsigned int i = 0; i<csrs_pos; i++)
+      {
+        if (NULL != cs[i].blinded_sig)
+        {
+          GNUNET_CRYPTO_blinded_sig_decref (cs[i].blinded_sig);
+          cs[i].blinded_sig = NULL;
+        }
+      }
+      for (unsigned int i = 0; i<rsrs_pos; i++)
+      {
+        if (NULL != rs[i].blinded_sig)
+        {
+          GNUNET_CRYPTO_blinded_sig_decref (rs[i].blinded_sig);
+          rs[i].blinded_sig = NULL;
+        }
+      }
+      return ec;
+    }
+    // TEH_METRICS_num_signatures[TEH_MT_SIGNATURE_RSA] += rsrs_pos;
+  }
+
+  rsrs_pos = 0;
+  csrs_pos = 0;
+  for (unsigned int i = 0; i<num_bkps; i++)
+  {
+    const struct DONAU_BlindedUniqueDonorIdentifier *budi = bkps[i].budi;
+
+    switch (budi->blinded_message->cipher)
+    {
+    case GNUNET_CRYPTO_BSA_RSA:
+      du_sigs[i].blinded_sig = rs[rsrs_pos++].blinded_sig;
+      break;
+    case GNUNET_CRYPTO_BSA_CS:
+      du_sigs[i].blinded_sig = cs[csrs_pos++].blinded_sig;
+      break;
+    default:
+      GNUNET_assert (0);
+    }
+  }
   return TALER_EC_NONE;
-  // struct DH_KeyStateHandle *ksh;
-  // struct DH_DonationUnitKey *du;
-  // struct TALER_CRYPTO_RsaSignRequest rsrs[csds_length];
-  // struct TALER_CRYPTO_CsSignRequest csrs[csds_length];
-  // struct TALER_BlindedDenominationSignature rs[csds_length];
-  // struct TALER_BlindedDenominationSignature cs[csds_length];
-  // unsigned int rsrs_pos = 0;
-  // unsigned int csrs_pos = 0;
-  // enum TALER_ErrorCode ec;
-
-  // ksh = DH_keys_get_state ();
-  // if (NULL == ksh)
-  //   // FIXME change error code
-  //   return TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING;
-  // for (unsigned int i = 0; i<csds_length; i++)
-  // {
-  //   const struct DONAU_DonationUnitHashP *h_du_pub = csds[i].h_du_pub;
-  //   const struct DONAU_BlindedUniqueDonorIdentifier *budi = csds[i].budi;
-
-  //   du = GNUNET_CONTAINER_multihashmap_get (du_keys,
-  //                                           &h_du_pub->hash);
-  //   if (NULL == du)
-  //     // FIXME change error code
-  //     return TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN;
-  //   if (budi->blinded_message->cipher !=
-  //       du->donation_unit_pub.bsign_pub_key->cipher)
-  //     return TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE;
-  //   switch (du->donation_unit_pub.bsign_pub_key->cipher)
-  //   {
-  //   case GNUNET_CRYPTO_BSA_RSA:
-  //     /* See DONAU_donation_unit_pub_hash: we guarantee that these
-  //  hashes are equivalent! */
-  //     rsrs[rsrs_pos].h_rsa
-  //       = (const struct TALER_RsaPubHashP *) &du->h_donation_unit_pub;
-  //     rsrs[rsrs_pos].msg
-  //       = budi->blinded_message->details.rsa_blinded_message.blinded_msg;
-  //     rsrs[rsrs_pos].msg_size
-  //       = 
budi->blinded_message->details.rsa_blinded_message.blinded_msg_size;
-  //     rsrs_pos++;
-  //     break;
-  //   case GNUNET_CRYPTO_BSA_CS:
-  //     /* See DONAU_donation_unit_pub_hash: we guarantee that these
-  //  hashes are equivalent! */
-  //     csrs[csrs_pos].h_cs
-  //       = (const struct TALER_CsPubHashP *) &du->h_donation_unit_pub;
-  //     csrs[csrs_pos].blinded_planchet
-  //       = &budi->blinded_message->details.cs_blinded_message;
-  //     csrs_pos++;
-  //     break;
-  //   default:
-  //     return TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE;
-  //   }
-  // }
-
-  // if ( (0 != csrs_pos) &&
-  //      (0 != rsrs_pos) )
-  // {
-  //   memset (rs,
-  //           0,
-  //           sizeof (rs));
-  //   memset (cs,
-  //           0,
-  //           sizeof (cs));
-  // }
-  // ec = TALER_EC_NONE;
-  // if (0 != csrs_pos)
-  // {
-  //   ec = TALER_CRYPTO_helper_cs_batch_sign (
-  //     csdh,
-  //     csrs_pos,
-  //     csrs,
-  //     false, // for_melt
-  //     cs);
-  //   if (TALER_EC_NONE != ec)
-  //   {
-  //     for (unsigned int i = 0; i<csrs_pos; i++)
-  //     {
-  //       if (NULL != cs[i].blinded_sig)
-  //       {
-  //         GNUNET_CRYPTO_blinded_sig_decref (cs[i].blinded_sig);
-  //         cs[i].blinded_sig = NULL;
-  //       }
-  //     }
-  //     return ec;
-  //   }
-  //   // TEH_METRICS_num_signatures[TEH_MT_SIGNATURE_CS] += csrs_pos;
-  // }
-  // if (0 != rsrs_pos)
-  // {
-  //   ec = TALER_CRYPTO_helper_rsa_batch_sign (
-  //     rsadh,
-  //     rsrs_pos,
-  //     rsrs,
-  //     rs);
-  //   if (TALER_EC_NONE != ec)
-  //   {
-  //     for (unsigned int i = 0; i<csrs_pos; i++)
-  //     {
-  //       if (NULL != cs[i].blinded_sig)
-  //       {
-  //         GNUNET_CRYPTO_blinded_sig_decref (cs[i].blinded_sig);
-  //         cs[i].blinded_sig = NULL;
-  //       }
-  //     }
-  //     for (unsigned int i = 0; i<rsrs_pos; i++)
-  //     {
-  //       if (NULL != rs[i].blinded_sig)
-  //       {
-  //         GNUNET_CRYPTO_blinded_sig_decref (rs[i].blinded_sig);
-  //         rs[i].blinded_sig = NULL;
-  //       }
-  //     }
-  //     return ec;
-  //   }
-  //   // TEH_METRICS_num_signatures[TEH_MT_SIGNATURE_RSA] += rsrs_pos;
-  // }
-
-  // rsrs_pos = 0;
-  // csrs_pos = 0;
-  // for (unsigned int i = 0; i<csds_length; i++)
-  // {
-  //   const struct DONAU_BlindedUniqueDonorIdentifier *budi = csds[i].budi;
-
-  //   switch (budi->blinded_message->cipher)
-  //   {
-  //   case GNUNET_CRYPTO_BSA_RSA:
-  //     bss[i].blinded_sig = rs[rsrs_pos++].blinded_sig;
-  //     break;
-  //   case GNUNET_CRYPTO_BSA_CS:
-  //     bss[i].blinded_sig = cs[csrs_pos++].blinded_sig;
-  //     break;
-  //   default:
-  //     GNUNET_assert (0);
-  //   }
-  // }
-  // return TALER_EC_NONE;
 }
 
 
diff --git a/src/donau/donau-httpd_keys.h b/src/donau/donau-httpd_keys.h
index 6bf59ce..27d6109 100644
--- a/src/donau/donau-httpd_keys.h
+++ b/src/donau/donau-httpd_keys.h
@@ -179,16 +179,16 @@ DH_keys_finished (void);
 /**
  * Request to sign @a budis.
  *
- * @param budis_length length of @a budis array
+ * @param num_bkps length of @a budis array
  * @param bkps array with data to blindly sign (and keys to sign with)
- * @param[out] du_sigs array set to the blind signature on success; must be of 
length @a budis_length
+ * @param[out] du_sigs array set to the blind signature on success; must be of 
length @a num_bkps
  * @return #TALER_EC_NONE on success
  */
 enum TALER_ErrorCode
 DH_keys_donation_unit_batch_sign (
-  unsigned int budis_length,
-  const struct DONAU_BkpSignData bkps[budis_length],
-  struct DONAU_BlindedDonationUnitSignature du_sigs[budis_length]);
+  unsigned int num_bkps,
+  const struct DONAU_BkpSignData bkps[num_bkps],
+  struct DONAU_BlindedDonationUnitSignature du_sigs[num_bkps]);
 
 
 #endif
diff --git a/src/donaudb/donau_do_save_issue_receipts_request.sql 
b/src/donaudb/donau_do_save_issue_receipts_request.sql
index ea07da3..74fff7c 100644
--- a/src/donaudb/donau_do_save_issue_receipts_request.sql
+++ b/src/donaudb/donau_do_save_issue_receipts_request.sql
@@ -29,7 +29,7 @@ BEGIN
 UPDATE charities SET receipts_to_date = in_new_total_amount;
 -- Insert into the table receipts_issued
 INSERT INTO receipts_issued (/*blinded_sig,*/ charity_id, receipt_hash, 
amount) 
-VALUES (/*in_blinded_sig,*/ in_charity_id, in_receipt_hash, in_amount) 
RETURNING receipt_id INTO out_receipt_id;
+VALUES (/*in_blinded_sig,*/ in_charity_id, in_receipt_hash, in_amount); 
--RETURNING receipt_id INTO out_receipt_id;
 -- Get the receipts id
 -- SELECT receipt_id INTO out_receipt_id SELECT WHERE 
receipt_hash=in_receipts_hash FROM receipts_issued ;
 -- Commit the transaction if everything is successful
diff --git a/src/testing/.test-suite.log.swp b/src/testing/.test-suite.log.swp
new file mode 100644
index 0000000..8c907f6
Binary files /dev/null and b/src/testing/.test-suite.log.swp differ

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]