gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated (28116298 -> ad09066a)


From: gnunet
Subject: [taler-exchange] branch master updated (28116298 -> ad09066a)
Date: Fri, 22 Dec 2023 16:29:22 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository exchange.

    from 28116298 -cleanup
     new 4bfdee10 first draft of token crypto structs
     new 92c3189b ignore .DS_Store files
     new 247e96cf Merge branch 'master' into feature/tokens
     new 15d64a09 Merge branch 'master' into feature/tokens
     new da3bc6a9 use new gnunet bling sign structs
     new 14dae4fd Merge branch 'master' into feature/tokens
     new 6500ab37 Merge branch 'master' into feature/tokens
     new 9b27ee9c add query param functions for blind sign private and public 
keys
     new f9926292 Merge branch 'master' into feature/tokens
     new 62448125 Merge branch 'master' into feature/tokens
     new 9fb19a98 Merge branch 'master' into feature/tokens
     new 219dfe1f Merge branch 'feature/tokens' of 
git+ssh://git.taler.net/exchange
     new ad09066a -minor code cleanup

The 13 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                     |   3 +-
 src/include/taler_crypto_lib.h |  54 +++++++++++
 src/include/taler_pq_lib.h     |  50 +++++++++++
 src/json/json_helper.c         |  17 ++--
 src/lib/exchange_api_handle.c  |  16 +++-
 src/pq/pq_query_helper.c       | 199 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 323 insertions(+), 16 deletions(-)

diff --git a/.gitignore b/.gitignore
index a029ccda..e710cab6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,7 @@ GPATH
 GRTAGS
 GTAGS
 *.swp
+.DS_Store
 src/include/taler_error_codes.h
 src/testing/test_exchange_api_rsa
 src/testing/test_exchange_api_cs
@@ -167,4 +168,4 @@ src/kyclogic/taler-exchange-kyc-tester
 src/auditor/exchange-httpd-drain.err
 src/templating/libmustach.a
 contrib/tos/conf.py
-contrib/pp/conf.py
+contrib/pp/conf.py
\ No newline at end of file
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index f74575d7..fb9e32a2 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -5886,4 +5886,58 @@ TALER_denomination_group_get_key (
   struct GNUNET_HashCode *key);
 
 
+/**
+ * Token family public key.
+ */
+struct TALER_TokenFamilyPublicKey
+{
+  /**
+   * Type of the signature.
+   */
+  struct GNUNET_CRYPTO_BlindSignPublicKey public_key;
+};
+
+/**
+ * Hash of a public key of a token family.
+ */
+struct TALER_TokenFamilyPublicKeyHash
+{
+  /**
+   * Hash of the token public key.
+   */
+  struct GNUNET_HashCode hash;
+};
+
+/**
+ * Token family private key.
+ */
+struct TALER_TokenFamilyPrivateKey
+{
+  struct GNUNET_CRYPTO_BlindSignPrivateKey private_key;
+};
+
+/**
+ * Token public key.
+ */
+struct TALER_TokenPublicKey
+{
+  struct GNUNET_CRYPTO_EddsaPublicKey public_key;
+};
+
+/**
+ * Signature made using a token private key.
+ */
+struct TALER_TokenSignature
+{
+  struct GNUNET_CRYPTO_EddsaSignature signature;
+};
+
+/**
+ * Blind signature for a token (signed by merchant).
+ */
+struct TALER_TokenBlindSignature
+{
+  struct GNUNET_CRYPTO_BlindedSignature signature;
+};
+
 #endif
diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h
index d9c23e35..a529b430 100644
--- a/src/include/taler_pq_lib.h
+++ b/src/include/taler_pq_lib.h
@@ -149,6 +149,7 @@ TALER_PQ_query_param_array_blinded_denom_sig (
   struct GNUNET_PQ_Context *db
   );
 
+
 /**
  * Generate query parameter for an array of blinded hashes of coin envelopes
  *
@@ -162,6 +163,7 @@ TALER_PQ_query_param_array_blinded_coin_hash (
   const struct TALER_BlindedCoinHashP *coin_evs,
   struct GNUNET_PQ_Context *db);
 
+
 /**
  * Generate query parameter for an array of GNUNET_HashCode
  *
@@ -189,6 +191,26 @@ TALER_PQ_query_param_array_amount (
   struct GNUNET_PQ_Context *db);
 
 
+/**
+ * Generate query parameter for a blind sign public key of variable size.
+ *
+ * @param public_key pointer to the query parameter to pass
+ */
+struct GNUNET_PQ_QueryParam
+TALER_PQ_query_param_blind_sign_pub (
+  const struct GNUNET_CRYPTO_BlindSignPublicKey *public_key);
+
+
+/**
+ * Generate query parameter for a blind sign private key of variable size.
+ *
+ * @param private_key pointer to the query parameter to pass
+ */
+struct GNUNET_PQ_QueryParam
+TALER_PQ_query_param_blind_sign_priv (
+  const struct GNUNET_CRYPTO_BlindSignPrivateKey *private_key);
+
+
 /**
  * Currency amount expected, from a record-field of (DB)
  * taler_amount_with_currency type. The currency must be stored in the
@@ -311,6 +333,7 @@ TALER_PQ_result_spec_array_blinded_denom_sig (
   size_t *num,
   struct TALER_BlindedDenominationSignature **denom_sigs);
 
+
 /**
  * Array of blinded hashes of coin envelopes
  *
@@ -327,6 +350,7 @@ TALER_PQ_result_spec_array_blinded_coin_hash (
   size_t *num,
   struct TALER_BlindedCoinHashP **h_coin_evs);
 
+
 /**
  * Array of hashes of denominations
  *
@@ -343,6 +367,7 @@ TALER_PQ_result_spec_array_denom_hash (
   size_t *num,
   struct TALER_DenominationHashP **denom_hs);
 
+
 /**
  * Array of GNUNET_HashCode
  *
@@ -378,6 +403,31 @@ TALER_PQ_result_spec_array_amount (
   struct TALER_Amount **amounts);
 
 
+/**
+ * Blind sign public key expected.
+ *
+ * @param name name of the field in the table
+ * @param[out] public_key where to store the denomination signature
+ * @return array entry for the result specification to use
+ */
+struct GNUNET_PQ_ResultSpec
+TALER_PQ_result_spec_blind_sign_pub (
+  const char *name,
+  struct GNUNET_CRYPTO_BlindSignPublicKey *public_key);
+
+
+/**
+ * Blind sign private key expected.
+ *
+ * @param name name of the field in the table
+ * @param[out] private_key where to store the denomination signature
+ * @return array entry for the result specification to use
+ */
+struct GNUNET_PQ_ResultSpec
+TALER_PQ_result_spec_blind_sign_priv (
+  const char *name,
+  struct GNUNET_CRYPTO_BlindSignPrivateKey *private_key);
+
 #endif  /* TALER_PQ_LIB_H_ */
 
 /* end of include/taler_pq_lib.h */
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index b339ff68..9f57c56f 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -267,6 +267,9 @@ TALER_JSON_spec_currency_specification (
     .size_ptr = NULL
   };
 
+  memset (r_cspec,
+          0,
+          sizeof (*r_cspec));
   return ret;
 }
 
@@ -345,11 +348,9 @@ TALER_JSON_spec_denomination_group (const char *name,
   struct GNUNET_JSON_Specification ret = {
     .cls = (void *) currency,
     .parser = &parse_denomination_group,
-    .cleaner = NULL,
     .field = name,
     .ptr = group,
-    .ptr_size = sizeof(*group),
-    .size_ptr = NULL,
+    .ptr_size = sizeof(*group)
   };
 
   return ret;
@@ -421,11 +422,8 @@ TALER_JSON_spec_econtract (const char *name,
   struct GNUNET_JSON_Specification ret = {
     .parser = &parse_econtract,
     .cleaner = &clean_econtract,
-    .cls = NULL,
     .field = name,
-    .ptr = econtract,
-    .ptr_size = 0,
-    .size_ptr = NULL
+    .ptr = econtract
   };
 
   return ret;
@@ -526,11 +524,8 @@ TALER_JSON_spec_age_commitment (const char *name,
   struct GNUNET_JSON_Specification ret = {
     .parser = &parse_age_commitment,
     .cleaner = &clean_age_commitment,
-    .cls = NULL,
     .field = name,
-    .ptr = age_commitment,
-    .ptr_size = 0,
-    .size_ptr = NULL
+    .ptr = age_commitment
   };
 
   return ret;
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index ed491c8b..27ce8506 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -928,10 +928,18 @@ decode_keys_json (const json_t *resp_obj,
         GNUNET_JSON_spec_end ()
       };
 
-      EXITIF (GNUNET_OK !=
-              GNUNET_JSON_parse (resp_obj,
-                                 sspec,
-                                 NULL, NULL));
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (resp_obj,
+                             sspec,
+                             &emsg,
+                             &eline))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                    "Parsing /keys failed for `%s' (%u)\n",
+                    emsg,
+                    eline);
+        EXITIF (1);
+      }
     }
 
     key_data->currency = GNUNET_strdup (currency);
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c
index 24bf054d..d8655db0 100644
--- a/src/pq/pq_query_helper.c
+++ b/src/pq/pq_query_helper.c
@@ -1220,4 +1220,203 @@ TALER_PQ_query_param_array_amount (
 }
 
 
+/**
+ * Function called to convert input argument into SQL parameters.
+ *
+ * @param cls closure
+ * @param data pointer to input argument
+ * @param data_len number of bytes in @a data (if applicable)
+ * @param[out] param_values SQL data to set
+ * @param[out] param_lengths SQL length data to set
+ * @param[out] param_formats SQL format data to set
+ * @param param_length number of entries available in the @a param_values, @a 
param_lengths and @a param_formats arrays
+ * @param[out] scratch buffer for dynamic allocations (to be done via 
#GNUNET_malloc()
+ * @param scratch_length number of entries left in @a scratch
+ * @return -1 on error, number of offsets used in @a scratch otherwise
+ */
+static int
+qconv_blind_sign_pub (void *cls,
+                      const void *data,
+                      size_t data_len,
+                      void *param_values[],
+                      int param_lengths[],
+                      int param_formats[],
+                      unsigned int param_length,
+                      void *scratch[],
+                      unsigned int scratch_length)
+{
+  const struct GNUNET_CRYPTO_BlindSignPublicKey *public_key = data;
+  size_t tlen;
+  size_t len;
+  uint32_t be;
+  char *buf;
+  void *tbuf;
+
+  (void) cls;
+  (void) data_len;
+  GNUNET_assert (1 == param_length);
+  GNUNET_assert (scratch_length > 0);
+  GNUNET_break (NULL == cls);
+  be = htonl ((uint32_t) public_key->cipher);
+  switch (public_key->cipher)
+  {
+  case GNUNET_CRYPTO_BSA_RSA:
+    tlen = GNUNET_CRYPTO_rsa_public_key_encode (
+      public_key->details.rsa_public_key,
+      &tbuf);
+    break;
+  case GNUNET_CRYPTO_BSA_CS:
+    tlen = sizeof (public_key->details.cs_public_key);
+    break;
+  default:
+    GNUNET_assert (0);
+  }
+  len = tlen + sizeof (be);
+  buf = GNUNET_malloc (len);
+  GNUNET_memcpy (buf,
+                 &be,
+                 sizeof (be));
+  switch (public_key->cipher)
+  {
+  case GNUNET_CRYPTO_BSA_RSA:
+    GNUNET_memcpy (&buf[sizeof (be)],
+                   tbuf,
+                   tlen);
+    GNUNET_free (tbuf);
+    break;
+  case GNUNET_CRYPTO_BSA_CS:
+    GNUNET_memcpy (&buf[sizeof (be)],
+                   &public_key->details.cs_public_key,
+                   tlen);
+    break;
+  default:
+    GNUNET_assert (0);
+  }
+
+  scratch[0] = buf;
+  param_values[0] = (void *) buf;
+  param_lengths[0] = len;
+  param_formats[0] = 1;
+  return 1;
+}
+
+/**
+ * Generate query parameter for a blind sign public key of variable size.
+ *
+ * @param public_key pointer to the query parameter to pass
+ */
+struct GNUNET_PQ_QueryParam
+TALER_PQ_query_param_blind_sign_pub (
+  const struct GNUNET_CRYPTO_BlindSignPublicKey *public_key)
+{
+  struct GNUNET_PQ_QueryParam res = {
+    .conv = &qconv_blind_sign_pub,
+    .data = public_key,
+    .num_params = 1
+  };
+
+  return res;
+}
+
+
+/**
+ * Function called to convert input argument into SQL parameters.
+ *
+ * @param cls closure
+ * @param data pointer to input argument
+ * @param data_len number of bytes in @a data (if applicable)
+ * @param[out] param_values SQL data to set
+ * @param[out] param_lengths SQL length data to set
+ * @param[out] param_formats SQL format data to set
+ * @param param_length number of entries available in the @a param_values, @a 
param_lengths and @a param_formats arrays
+ * @param[out] scratch buffer for dynamic allocations (to be done via 
#GNUNET_malloc()
+ * @param scratch_length number of entries left in @a scratch
+ * @return -1 on error, number of offsets used in @a scratch otherwise
+ */
+static int
+qconv_blind_sign_priv (void *cls,
+                       const void *data,
+                       size_t data_len,
+                       void *param_values[],
+                       int param_lengths[],
+                       int param_formats[],
+                       unsigned int param_length,
+                       void *scratch[],
+                       unsigned int scratch_length)
+{
+  const struct GNUNET_CRYPTO_BlindSignPrivateKey *private_key = data;
+  size_t tlen;
+  size_t len;
+  uint32_t be;
+  char *buf;
+  void *tbuf;
+
+  (void) cls;
+  (void) data_len;
+  GNUNET_assert (1 == param_length);
+  GNUNET_assert (scratch_length > 0);
+  GNUNET_break (NULL == cls);
+  be = htonl ((uint32_t) private_key->cipher);
+  switch (private_key->cipher)
+  {
+  case GNUNET_CRYPTO_BSA_RSA:
+    tlen = GNUNET_CRYPTO_rsa_private_key_encode (
+      private_key->details.rsa_private_key,
+      &tbuf);
+    break;
+  case GNUNET_CRYPTO_BSA_CS:
+    tlen = sizeof (private_key->details.cs_private_key);
+    break;
+  default:
+    GNUNET_assert (0);
+  }
+  len = tlen + sizeof (be);
+  buf = GNUNET_malloc (len);
+  GNUNET_memcpy (buf,
+                 &be,
+                 sizeof (be));
+  switch (private_key->cipher)
+  {
+  case GNUNET_CRYPTO_BSA_RSA:
+    GNUNET_memcpy (&buf[sizeof (be)],
+                   tbuf,
+                   tlen);
+    GNUNET_free (tbuf);
+    break;
+  case GNUNET_CRYPTO_BSA_CS:
+    GNUNET_memcpy (&buf[sizeof (be)],
+                   &private_key->details.cs_private_key,
+                   tlen);
+    break;
+  default:
+    GNUNET_assert (0);
+  }
+
+  scratch[0] = buf;
+  param_values[0] = (void *) buf;
+  param_lengths[0] = len;
+  param_formats[0] = 1;
+  return 1;
+}
+
+
+/**
+ * Generate query parameter for a blind sign private key of variable size.
+ *
+ * @param private_key pointer to the query parameter to pass
+ */
+struct GNUNET_PQ_QueryParam
+TALER_PQ_query_param_blind_sign_priv (
+  const struct GNUNET_CRYPTO_BlindSignPrivateKey *private_key)
+{
+  struct GNUNET_PQ_QueryParam res = {
+    .conv = &qconv_blind_sign_priv,
+    .data = private_key,
+    .num_params = 1
+  };
+
+  return res;
+}
+
+
 /* end of pq/pq_query_helper.c */

-- 
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]