gnunet-svn
[Top][All Lists]
Advanced

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

[taler-donau] branch master updated (9839b09 -> 4611663)


From: gnunet
Subject: [taler-donau] branch master updated (9839b09 -> 4611663)
Date: Sun, 07 Jan 2024 18:14:33 +0100

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

lukas-matyja pushed a change to branch master
in repository donau.

    from 9839b09  fixed httpd errors added metrics
     new 3693283  [lib] decode keys implementation
     new dc30ef2  [lib] work on API Keys implementation
     new 76fa632  [lib] implementation key api roughly completed
     new 31c610a  merge and add some json helpers
     new 4611663  remove error

The 5 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:
 src/include/donau_crypto_lib.h |   43 ++
 src/include/donau_json_lib.h   |   43 ++
 src/include/donau_service.h    |   19 +-
 src/json/donau_json.c          |  138 ++++++
 src/lib/donau_api_handle.c     | 1023 ++++++----------------------------------
 src/util/donau_crypto.c        |   69 ++-
 6 files changed, 459 insertions(+), 876 deletions(-)
 create mode 100644 src/include/donau_json_lib.h
 create mode 100644 src/json/donau_json.c

diff --git a/src/include/donau_crypto_lib.h b/src/include/donau_crypto_lib.h
index 468d218..3fc644f 100644
--- a/src/include/donau_crypto_lib.h
+++ b/src/include/donau_crypto_lib.h
@@ -118,6 +118,37 @@ struct DONAU_DonationUnitHashP
   struct GNUNET_HashCode hash;
 };
 
+/**
+<<<<<<< HEAD
+ * Compare two donation unit public keys.
+ *
+ * @param donation_unit1 first key
+ * @param donation_unit2 second key
+ * @return 0 if the keys are equal, otherwise -1 or 1
+ */
+int
+DONAU_donation_unit_pub_cmp (const struct DONAU_DonationUnitPublicKey 
*donation_unit1,
+                     const struct DONAU_DonationUnitPublicKey *donation_unit2);
+
+/**
+ * Make a (deep) copy of the given @a donation_unit_src to
+ * @a donation_unit_dst.
+ *
+ * @param[out] donation_unit_dst target to copy to
+ * @param donation_unit_src public key to copy
+ */
+void
+DONAU_donation_unit_pub_deep_copy (struct DONAU_DonationUnitPublicKey 
*donation_unit_dst,
+                             const struct DONAU_DonationUnitPublicKey 
*donation_unit_src);
+
+/**
+ * Free internals of @a donation_unit_pub, but not @a donation_unit_pub itself.
+ *
+ * @param[in] donation_unit_pub key to free
+ */
+void
+DONAU_donation_unit_pub_free (struct DONAU_DonationUnitPublicKey 
*donation_unit_pub);
+
 /**
  * Hash used to represent a Donation Receipt
  */
@@ -129,6 +160,7 @@ struct DONAU_DonationReceiptHashP
   struct GNUNET_HashCode hash;
 };
 
+
 /**
   * Donor's hashed and salted unique donation identifier.
   */
@@ -315,6 +347,17 @@ struct DONAU_DonationUnitGroup
 
 };
 
+/**
+ * Compute a unique key for the meta data of a donation unit group.
+ *
+ * @param dg donation unit group to evaluate
+ * @param[out] key key to set
+ */
+void
+DONAU_donation_unit_group_get_key (
+  const struct DONAU_DonationUnitGroup *dg,
+  struct GNUNET_HashCode *key);
+
 /**
  * @brief Inputs needed from the donau for blind signing.
  */
diff --git a/src/include/donau_json_lib.h b/src/include/donau_json_lib.h
new file mode 100644
index 0000000..9dcafe6
--- /dev/null
+++ b/src/include/donau_json_lib.h
@@ -0,0 +1,43 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2024 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify it under the
+  terms of the GNU General Public License as published by the Free Software
+  Foundation; either version 3, or (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License along with
+  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file include/donau_json_lib.h
+ * @brief helper functions for JSON processing using libjansson
+ * @author Lukas Matyja
+ */
+#ifndef TALER_JSON_LIB_H_
+#define TALER_JSON_LIB_H_
+
+#include <jansson.h>
+#include <gnunet/gnunet_json_lib.h>
+#include <gnunet/gnunet_curl_lib.h>
+#include "taler/taler_util.h"
+#include "taler/taler_error_codes.h"
+
+/**
+ * Generate a parser specification for a donation unit public key of a given
+ * cipher.
+ *
+ * @param field name of the field
+ * @param cipher which cipher type to parse for
+ * @param[out] pk key to fill
+ * @return corresponding field spec
+ */
+struct GNUNET_JSON_Specification
+DONAU_JSON_spec_donation_unit_pub_cipher (
+  const char *field,
+  enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher,
+  struct DONAU_DonationUnitPublicKey *pk);
\ No newline at end of file
diff --git a/src/include/donau_service.h b/src/include/donau_service.h
index 086dd1c..9853241 100644
--- a/src/include/donau_service.h
+++ b/src/include/donau_service.h
@@ -64,7 +64,7 @@ struct DONAU_DonationUnitInformation
   /**
    * amount of the donation
    */
-  struct TALER_Amount donation_unit;
+  struct TALER_Amount value;
 
   /**
    * Year of validity
@@ -129,6 +129,11 @@ struct DONAU_Keys
    */
   unsigned int num_donation_unit_keys;
 
+    /**
+   * Actual length of the @e donation_unit_keys array (size of allocation).
+   */
+  unsigned int donation_unit_keys_size;
+
   /**
    * Reference counter for this structure.
    * Freed when it reaches 0.
@@ -368,18 +373,18 @@ DONAU_keys_decref (struct DONAU_Keys *keys);
 
 /**
  * Test if the given @a pub is a current signing key from the donau
- * according to @a keys.
+ * according to @a keys. (->  // always current, revocation not yet supported)
  *
  * @param keys the donau's key set
  * @param pub claimed online signing key for the donau
  * @param year given year
  * @return #GNUNET_OK if @a pub is (according to /keys and @a year) the 
corresponding signing key
  */
-enum GNUNET_GenericReturnValue
-DONAU_test_signing_key (
-  const struct DONAU_Keys *keys,
-  const unsigned int year,
-  const struct DONAU_DonauPublicKeyP *pub);
+// enum GNUNET_GenericReturnValue
+// DONAU_test_signing_key (
+//   const struct DONAU_Keys *keys,
+//   const unsigned int year,
+//   const struct DONAU_DonauPublicKeyP *pub);
 
 
 /**
diff --git a/src/json/donau_json.c b/src/json/donau_json.c
new file mode 100644
index 0000000..e14f707
--- /dev/null
+++ b/src/json/donau_json.c
@@ -0,0 +1,138 @@
+/*
+  This file is part of TALER
+  Copyright (C) 2024 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify it under the
+  terms of the GNU General Public License as published by the Free Software
+  Foundation; either version 3, or (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License along with
+  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file json/donau_json.c
+ * @brief helper functions for JSON processing using libjansson
+ * @author Lukas Matyja
+ */
+#include "taler/platform.h"
+#include <gnunet/gnunet_util_lib.h>
+#include "taler/taler_util.h"
+#include "taler/taler_json_lib.h"
+#include <unistr.h>
+#include "donau_json_lib.h"
+#include "donau_util.h"
+
+/**
+ * Parse given JSON object partially into a donation unit public key.
+ *
+ * Depending on the cipher in cls, it parses the corresponding public key type.
+ *
+ * @param cls closure, enum GNUNET_CRYPTO_BlindSignatureAlgorithm
+ * @param root the json object representing data
+ * @param[out] spec where to write the data
+ * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
+ */
+static enum GNUNET_GenericReturnValue
+parse_donation_unit_pub_cipher (void *cls,
+                        json_t *root,
+                        struct GNUNET_JSON_Specification *spec)
+{
+  struct DONAU_DonationUnitPublicKey *donation_unit_pub = spec->ptr;
+  enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher =
+    (enum GNUNET_CRYPTO_BlindSignatureAlgorithm) (long) cls;
+  struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub;
+  const char *emsg;
+  unsigned int eline;
+
+  bsign_pub = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPublicKey);
+  bsign_pub->cipher = cipher;
+  bsign_pub->rc = 1;
+  switch (cipher)
+  {
+  case GNUNET_CRYPTO_BSA_INVALID:
+    break;
+  case GNUNET_CRYPTO_BSA_RSA:
+    {
+      struct GNUNET_JSON_Specification ispec[] = {
+        GNUNET_JSON_spec_rsa_public_key (
+          "rsa_pub",
+          &bsign_pub->details.rsa_public_key),
+        GNUNET_JSON_spec_end ()
+      };
+
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (root,
+                             ispec,
+                             &emsg,
+                             &eline))
+      {
+        GNUNET_break_op (0);
+        GNUNET_free (bsign_pub);
+        return GNUNET_SYSERR;
+      }
+      donation_unit_pub->bsign_pub_key = bsign_pub;
+      return GNUNET_OK;
+    }
+  case GNUNET_CRYPTO_BSA_CS:
+    {
+      struct GNUNET_JSON_Specification ispec[] = {
+        GNUNET_JSON_spec_fixed ("cs_pub",
+                                &bsign_pub->details.cs_public_key,
+                                sizeof (bsign_pub->details.cs_public_key)),
+        GNUNET_JSON_spec_end ()
+      };
+
+      if (GNUNET_OK !=
+          GNUNET_JSON_parse (root,
+                             ispec,
+                             &emsg,
+                             &eline))
+      {
+        GNUNET_break_op (0);
+        GNUNET_free (bsign_pub);
+        return GNUNET_SYSERR;
+      }
+      donation_unit_pub->bsign_pub_key = bsign_pub;
+      return GNUNET_OK;
+    }
+  }
+  GNUNET_break_op (0);
+  GNUNET_free (bsign_pub);
+  return GNUNET_SYSERR;
+}
+
+/**
+ * Cleanup data left from parsing donation unit public key.
+ *
+ * @param cls closure, NULL
+ * @param[out] spec where to free the data
+ */
+static void
+clean_donation_unit_pub (void *cls,
+                 struct GNUNET_JSON_Specification *spec)
+{
+  struct DONAU_DonationUnitPublicKey *donation_unit_pub = spec->ptr;
+
+  (void) cls;
+  DONAU_donation_unit_pub_free (donation_unit_pub);
+}
+
+struct GNUNET_JSON_Specification
+DONAU_JSON_spec_donation_unit_pub_cipher (const char *field,
+                                          enum 
GNUNET_CRYPTO_BlindSignatureAlgorithm cipher,
+                                          struct DONAU_DonationUnitPublicKey 
*pk)
+{
+  struct GNUNET_JSON_Specification ret = {
+    .parser = &parse_donation_unit_pub_cipher,
+    .cleaner = &clean_donation_unit_pub,
+    .field = field,
+    .cls = (void *) cipher,
+    .ptr = pk
+  };
+
+  return ret;
+}
\ No newline at end of file
diff --git a/src/lib/donau_api_handle.c b/src/lib/donau_api_handle.c
index ae563bd..cd6ef60 100644
--- a/src/lib/donau_api_handle.c
+++ b/src/lib/donau_api_handle.c
@@ -37,7 +37,7 @@
 #include <gnunet/gnunet_crypto_lib.h>
 
 /**
- * Which version of the Taler protocol is implemented
+ * Which version of the Donau protocol is implemented
  * by this library?  Used to determine compatibility.
  */
 #define DONAU_PROTOCOL_CURRENT 0
@@ -96,7 +96,7 @@ struct DONAU_GetKeysHandle
   /**
    * Previous /keys response, NULL for none.
    */
-  struct DONAU_Keys *prev_keys;
+  struct DONAU_Keys *prev_keys; // not used, as keys are always completely 
reloaded
 
   /**
    * Entry for this request with the `struct GNUNET_CURL_Context`.
@@ -107,7 +107,7 @@ struct DONAU_GetKeysHandle
    * Expiration time according to "Expire:" header.
    * 0 if not provided by the server.
    */
-  struct GNUNET_TIME_Timestamp expire;
+  struct GNUNET_TIME_Timestamp expire; // not used -> no expiration, always 0
 
   /**
    * Function to call with the donau's certification data,
@@ -144,7 +144,7 @@ parse_json_signkey (struct 
DONAU_SigningPublicKeyAndValidity *sign_key,
     GNUNET_JSON_spec_fixed_auto ("key",
                                  &sign_key->key),
     GNUNET_JSON_spec_varsize ("year_of_validity",
-                                &sign_key->year)
+                                &sign_key->year),
     GNUNET_JSON_spec_end ()
   };
 
@@ -159,6 +159,36 @@ parse_json_signkey (struct 
DONAU_SigningPublicKeyAndValidity *sign_key,
   return GNUNET_OK;
 }
 
+/**
+ * Compare two donation unit keys.
+ *
+ * @param donation_unit1 first donation unit key
+ * @param donation_unit2 second donation unit key
+ * @return 0 if the two keys are equal (not necessarily
+ *  the same object), 1 otherwise.
+ */
+static unsigned int
+donation_units_cmp (const struct DONAU_DonationUnitInformation *donation_unit1,
+                    const struct DONAU_DonationUnitInformation *donation_unit2)
+{
+  struct DONAU_DonationUnitInformation tmp1;
+  struct DONAU_DonationUnitInformation tmp2;
+
+  if (0 !=
+      DONAU_donation_unit_pub_cmp (&donation_unit1->key,
+                                   &donation_unit2->key))
+    return 1;
+  tmp1 = *donation_unit1;
+  tmp2 = *donation_unit2;
+  memset (&tmp1.key,
+          0,
+          sizeof (tmp1.key));
+  memset (&tmp2.key,
+          0,
+          sizeof (tmp2.key));
+  return GNUNET_memcmp (&tmp1,
+                        &tmp2);
+}
 
 /**
  * Decode the JSON in @a resp_obj from the /keys response
@@ -175,8 +205,8 @@ decode_keys_json (const json_t *resp_obj,
                   struct DONAU_Keys *key_data,
                   enum DONAU_VersionCompatibility *vc)
 {
-  struct DONAU_DonauPublicKeyP pub;
-  //const json_t *sign_keys_array;
+  //struct DONAU_SigningPublicKeyAndValidity donau_pub;
+  const json_t *sign_keys_array;
   const json_t *donation_units_by_group;
 
   if (JSON_OBJECT != json_typeof (resp_obj))
@@ -220,92 +250,37 @@ decode_keys_json (const json_t *resp_obj,
       GNUNET_break_op (0);
       return GNUNET_SYSERR;
     }
-    *vc = DONAU_VC_MATCH;
+    *vc = DONAU_VC_MATCH; // 0
     if (DONAU_PROTOCOL_CURRENT < current)
     {
-      *vc |= DONAU_VC_NEWER;
+      *vc |= DONAU_VC_NEWER; // 4
       if (DONAU_PROTOCOL_CURRENT < current - age)
-        *vc |= DONAU_VC_INCOMPATIBLE;
+        *vc |= DONAU_VC_INCOMPATIBLE; // 1
     }
     if (DONAU_PROTOCOL_CURRENT > current)
     {
-      *vc |= DONAU_VC_OLDER;
+      *vc |= DONAU_VC_OLDER; // 2
       if (DONAU_PROTOCOL_CURRENT - DONAU_PROTOCOL_AGE > current)
-        *vc |= DONAU_VC_INCOMPATIBLE;
+        *vc |= DONAU_VC_INCOMPATIBLE; // 1
     }
     key_data->version = GNUNET_strdup (ver);
   }
 
   {
     const char *currency;
-    const char *asset_type;
     struct GNUNET_JSON_Specification mspec[] = {
-      GNUNET_JSON_spec_fixed_auto (
-        "donation_units_sig",
-        &donation_units_sig),
-      GNUNET_JSON_spec_fixed_auto (
-        "eddsa_pub",
-        &pub),
-      GNUNET_JSON_spec_fixed_auto (
-        "master_public_key",
-        &key_data->master_pub),
-      GNUNET_JSON_spec_array_const ("accounts",
-                                    &accounts),
-      GNUNET_JSON_spec_object_const ("wire_fees",
-                                     &fees),
-      GNUNET_JSON_spec_array_const ("wads",
-                                    &wads),
-      GNUNET_JSON_spec_timestamp (
-        "list_issue_date",
-        &key_data->list_issue_date),
-      GNUNET_JSON_spec_relative_time (
-        "reserve_closing_delay",
-        &key_data->reserve_closing_delay),
-      GNUNET_JSON_spec_string (
-        "currency",
-        &currency),
-      GNUNET_JSON_spec_uint32 (
-        "currency_fraction_digits",
-        &key_data->currency_fraction_digits),
-      GNUNET_JSON_spec_string (
-        "asset_type",
-        &asset_type),
-      GNUNET_JSON_spec_array_const (
-        "global_fees",
-        &global_fees),
+      // GNUNET_JSON_spec_fixed_auto ( // already in signkeys?
+      //   "donau_pub",
+      //   &donau_pub),
       GNUNET_JSON_spec_array_const (
-        "signkeys",
+        "signkeys", // naming convention?
         &sign_keys_array),
+      GNUNET_JSON_spec_string (
+        "currency",
+        &currency), //&key_data->currency instead?
       GNUNET_JSON_spec_array_const (
         "donation_units",
         &donation_units_by_group),
-      GNUNET_JSON_spec_mark_optional (
-        GNUNET_JSON_spec_array_const (
-          "recoup",
-          &recoup_array),
-        NULL),
-      GNUNET_JSON_spec_array_const (
-        "auditors",
-        &auditors_array),
-      GNUNET_JSON_spec_mark_optional (
-        GNUNET_JSON_spec_bool (
-          "rewards_allowed",
-          &key_data->rewards_allowed),
-        NULL),
-      GNUNET_JSON_spec_mark_optional (
-        GNUNET_JSON_spec_object_const ("extensions",
-                                       &manifests),
-        &no_extensions),
-      GNUNET_JSON_spec_mark_optional (
-        GNUNET_JSON_spec_fixed_auto (
-          "extensions_sig",
-          &key_data->extensions_sig),
-        &no_signature),
-      GNUNET_JSON_spec_mark_optional (
-        GNUNET_JSON_spec_array_const (
-          "wallet_balance_limit_without_kyc",
-          &wblwk),
-        NULL),
       GNUNET_JSON_spec_end ()
     };
     const char *emsg;
@@ -313,7 +288,7 @@ decode_keys_json (const json_t *resp_obj,
 
     if (GNUNET_OK !=
         GNUNET_JSON_parse (resp_obj,
-                           (check_sig) ? mspec : &mspec[2],
+                           mspec,
                            &emsg,
                            &eline))
     {
@@ -324,19 +299,11 @@ decode_keys_json (const json_t *resp_obj,
       EXITIF (1);
     }
     {
-      struct GNUNET_JSON_Specification sspec[] = {
-        TALER_JSON_spec_amount (
-          "stefan_abs",
-          currency,
-          &key_data->stefan_abs),
-        TALER_JSON_spec_amount (
-          "stefan_log",
+      struct GNUNET_JSON_Specification sspec[] = { // why separate sspec and 
mspec?
+        TALER_JSON_spec_currency_specification (
+          "currency_specification",
           currency,
-          &key_data->stefan_log),
-        TALER_JSON_spec_amount (
-          "stefan_lin",
-          currency,
-          &key_data->stefan_lin),
+          &key_data->currency_specification),
         GNUNET_JSON_spec_end ()
       };
 
@@ -347,9 +314,6 @@ decode_keys_json (const json_t *resp_obj,
     }
 
     key_data->currency = GNUNET_strdup (currency);
-    key_data->asset_type = GNUNET_strdup (asset_type);
-    if (! no_extensions)
-      key_data->extensions = json_incref ((json_t *) manifests);
   }
 
   /* parse the signing keys */
@@ -362,88 +326,12 @@ decode_keys_json (const json_t *resp_obj,
 
     key_data->sign_keys
       = GNUNET_new_array (key_data->num_sign_keys,
-                          struct DONAU_SigningPublicKey);
+                          struct DONAU_SigningPublicKeyAndValidity);
     json_array_foreach (sign_keys_array, index, sign_key_obj) {
       EXITIF (GNUNET_SYSERR ==
               parse_json_signkey (&key_data->sign_keys[index],
-                                  check_sig,
-                                  sign_key_obj,
-                                  &key_data->master_pub));
-    }
-  }
-
-  /* Parse balance limits */
-  if (NULL != wblwk)
-  {
-    key_data->wblwk_length = json_array_size (wblwk);
-    key_data->wallet_balance_limit_without_kyc
-      = GNUNET_new_array (key_data->wblwk_length,
-                          struct TALER_Amount);
-    for (unsigned int i = 0; i<key_data->wblwk_length; i++)
-    {
-      struct TALER_Amount *a = &key_data->wallet_balance_limit_without_kyc[i];
-      const json_t *aj = json_array_get (wblwk,
-                                         i);
-      struct GNUNET_JSON_Specification spec[] = {
-        TALER_JSON_spec_amount (NULL,
-                                key_data->currency,
-                                a),
-        GNUNET_JSON_spec_end ()
-      };
-
-      EXITIF (GNUNET_OK !=
-              GNUNET_JSON_parse (aj,
-                                 spec,
-                                 NULL, NULL));
-    }
-  }
-
-  /* Parse wire accounts */
-  key_data->fees = parse_fees (&key_data->master_pub,
-                               key_data->currency,
-                               fees,
-                               &key_data->fees_len);
-  EXITIF (NULL == key_data->fees);
-  /* parse accounts */
-  GNUNET_array_grow (key_data->accounts,
-                     key_data->accounts_len,
-                     json_array_size (accounts));
-  EXITIF (GNUNET_OK !=
-          DONAU_parse_accounts (&key_data->master_pub,
-                                accounts,
-                                key_data->accounts_len,
-                                key_data->accounts));
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Parsed %u wire accounts from JSON\n",
-              (unsigned int) json_array_size (accounts));
-
-
-  /* Parse the supported extension(s): age-restriction. */
-  /* TODO: maybe lift all this into a FP in TALER_Extension ? */
-  if (! no_extensions)
-  {
-    if (no_signature)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "found extensions without signature\n");
+                                  sign_key_obj));
     }
-    else
-    {
-      /* We have an extensions object. Verify its signature. */
-      EXITIF (GNUNET_OK !=
-              TALER_extensions_verify_manifests_signature (
-                manifests,
-                &key_data->extensions_sig,
-                &key_data->master_pub));
-
-      /* Parse and set the the configuration of the extensions accordingly */
-      EXITIF (GNUNET_OK !=
-              TALER_extensions_load_manifests (manifests));
-    }
-
-    /* Assuming we might have now a new value for age_mask, set it in key_data 
*/
-    key_data->age_mask = TALER_extensions_get_age_restriction_mask ();
   }
 
   /*
@@ -451,32 +339,28 @@ decode_keys_json (const json_t *resp_obj,
    * possibly EXISTING array as required (/keys cherry picking).
    *
    * The donation units are grouped by common values of
-   *    {cipher, value, fee, age_mask}.
+   *    {cipher, value}.
    */
   {
     json_t *group_obj;
     unsigned int group_idx;
 
-    json_array_foreach (donation_units_by_group, group_idx, group_obj)
+    json_array_foreach (donation_units_by_group, 
+                        group_idx, group_obj)
     {
-      /* Running XOR of each SHA512 hash of the donation units' public key in
-         this group.  Used to compare against group.hash after all keys have
-         been parsed. */
-      struct GNUNET_HashCode group_hash_xor = {0};
-
-      /* First, parse { cipher, fees, value, age_mask, hash } of the current
+      /* First, parse { cipher, value, hash } of the current
          group. */
-      struct TALER_DenominationGroup group = {0};
-      const json_t *denom_keys_array;
+      struct DONAU_DonationUnitGroup group = {0}; // what must be given to be 
a part of a group?
+      const json_t *donation_unit_keys_array;
       struct GNUNET_JSON_Specification group_spec[] = {
-        TALER_JSON_spec_donation_unit_group (NULL,
+        TALER_JSON_spec_denomination_group (NULL,  // TODO: write method
                                             key_data->currency,
                                             &group),
-        GNUNET_JSON_spec_array_const ("denoms",
-                                      &denom_keys_array),
+        GNUNET_JSON_spec_array_const ("donation_units",
+                                      &donation_unit_keys_array),
         GNUNET_JSON_spec_end ()
       };
-      json_t *denom_key_obj;
+      json_t *donation_unit_key_obj;
       unsigned int index;
 
       EXITIF (GNUNET_SYSERR ==
@@ -486,37 +370,41 @@ decode_keys_json (const json_t *resp_obj,
                                  NULL));
 
       /* Now, parse the individual donation units */
-      json_array_foreach (denom_keys_array, index, denom_key_obj)
+      json_array_foreach (donation_unit_keys_array, 
+                                index, 
+                                donation_unit_key_obj)
       {
         /* Set the common fields from the group for this particular
            donation unit.  Required to make the validity check inside
            parse_json_denomkey_partially pass */
-        struct DONAU_DenomPublicKey dk = {
-          .key.cipher = group.cipher,
+        struct DONAU_DonationUnitInformation dk = {
           .value = group.value,
-          .fees = group.fees,
-          .key.age_mask = group.age_mask
+          .year = group.year
         };
         bool found = false;
 
-        EXITIF (GNUNET_SYSERR == //was partially
-                parse_json_donation_unit_key (&dk,
-                                               group.cipher,
-                                               check_sig,
-                                               denom_key_obj,
-                                               &key_data->master_pub,
-                                               check_sig ? &hash_xor : NULL));
-
-        /* Build the running xor of the SHA512-hash of the public keys for the 
group */
-        GNUNET_CRYPTO_hash_xor (&dk.h_key.hash,
-                                &group_hash_xor,
-                                &group_hash_xor);
+        struct GNUNET_JSON_Specification kspec[] = {
+          DONAU_JSON_spec_donation_unit_pub_cipher (NULL,
+                                                    group.cipher,
+                                                    &dk->key),
+          GNUNET_JSON_spec_end ()
+        };
+
+        if (GNUNET_OK !=
+            GNUNET_JSON_parse (donation_unit_key_obj,
+                              kspec,
+                              NULL, NULL))
+        {
+          GNUNET_break_op (0);
+          EXITIF(1);
+        }
+
         for (unsigned int j = 0;
-             j<key_data->num_denom_keys;
+             j<key_data->num_donation_unit_keys;
              j++)
         {
-          if (0 == GNUNET_CRYPTO_bsign_pub_cmp (&dk,
-                                                &key_data->denom_keys[j]))
+          if (0 == donation_units_cmp (&dk.key,
+                                                
&key_data->donation_unit_keys[j]))
           {
             found = true;
             break;
@@ -527,149 +415,25 @@ decode_keys_json (const json_t *resp_obj,
         {
           /* 0:0:0 did not support /keys cherry picking */
           TALER_LOG_DEBUG ("Skipping donation unit key: already know it\n");
-          TALER_denom_pub_free (&dk.key);
+          DONAU_donation_unit_pub_free (&dk.key);
           continue;
         }
 
-        if (key_data->denom_keys_size == key_data->num_denom_keys)
-          GNUNET_array_grow (key_data->denom_keys,
-                             key_data->denom_keys_size,
-                             key_data->denom_keys_size * 2 + 2);
-        key_data->denom_keys[key_data->num_denom_keys++] = dk;
+        if (key_data->donation_unit_keys_size == 
key_data->num_donation_unit_keys)
+          GNUNET_array_grow (key_data->donation_unit_keys,
+                             key_data->donation_unit_keys_size,
+                             key_data->donation_unit_keys_size * 2 + 2);
+        key_data->donation_unit_keys[key_data->num_donation_unit_keys++] = dk;
 
         /* Update "last_denom_issue_date" */
-        TALER_LOG_DEBUG ("Adding donation unit key that is valid_until %s\n",
-                         GNUNET_TIME_timestamp2s (dk.valid_from));
-        key_data->last_denom_issue_date
-          = GNUNET_TIME_timestamp_max (key_data->last_denom_issue_date,
-                                       dk.valid_from);
-      };   /* end of json_array_foreach over donation units */
+        TALER_LOG_DEBUG ("Adding donation unit key that is valid for the year 
%d\n",
+                         dk.year);
 
-      /* The calculated group_hash_xor must be the same as group.hash from
-         the JSON. */
-      EXITIF (0 !=
-              GNUNET_CRYPTO_hash_cmp (&group_hash_xor,
-                                      &group.hash));
+      };   /* end of json_array_foreach over donation units */
 
     } /* end of json_array_foreach over groups of donation units */
   } /* end of scope for group_ojb/group_idx */
 
-  /* parse the auditor information */
-  {
-    json_t *auditor_info;
-    unsigned int index;
-
-    /* Merge with the existing auditor information we have (/keys cherry 
picking) */
-    json_array_foreach (auditors_array, index, auditor_info)
-    {
-      struct DONAU_AuditorInformation ai;
-      bool found = false;
-
-      memset (&ai,
-              0,
-              sizeof (ai));
-      EXITIF (GNUNET_SYSERR ==
-              parse_json_auditor (&ai,
-                                  check_sig,
-                                  auditor_info,
-                                  key_data));
-      for (unsigned int j = 0; j<key_data->num_auditors; j++)
-      {
-        struct DONAU_AuditorInformation *aix = &key_data->auditors[j];
-
-        if (0 == GNUNET_memcmp (&ai.auditor_pub,
-                                &aix->auditor_pub))
-        {
-          found = true;
-          /* Merge donation unit key signatures of downloaded /keys into 
existing
-             auditor information 'aix'. */
-          TALER_LOG_DEBUG (
-            "Merging %u new audited keys with %u known audited keys\n",
-            aix->num_denom_keys,
-            ai.num_denom_keys);
-          for (unsigned int i = 0; i<ai.num_denom_keys; i++)
-          {
-            bool kfound = false;
-
-            for (unsigned int k = 0; k<aix->num_denom_keys; k++)
-            {
-              if (aix->denom_keys[k].denom_key_offset ==
-                  ai.denom_keys[i].denom_key_offset)
-              {
-                kfound = true;
-                break;
-              }
-            }
-            if (! kfound)
-              GNUNET_array_append (aix->denom_keys,
-                                   aix->num_denom_keys,
-                                   ai.denom_keys[i]);
-          }
-          break;
-        }
-      }
-      if (found)
-      {
-        GNUNET_array_grow (ai.denom_keys,
-                           ai.num_denom_keys,
-                           0);
-        GNUNET_free (ai.auditor_url);
-        continue; /* we are done */
-      }
-      if (key_data->auditors_size == key_data->num_auditors)
-        GNUNET_array_grow (key_data->auditors,
-                           key_data->auditors_size,
-                           key_data->auditors_size * 2 + 2);
-      GNUNET_assert (NULL != ai.auditor_url);
-      key_data->auditors[key_data->num_auditors++] = ai;
-    };
-  }
-
-  /* parse the revocation/recoup information */
-  if (NULL != recoup_array)
-  {
-    json_t *recoup_info;
-    unsigned int index;
-
-    json_array_foreach (recoup_array, index, recoup_info)
-    {
-      struct TALER_DenominationHashP h_denom_pub;
-      struct GNUNET_JSON_Specification spec[] = {
-        GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
-                                     &h_denom_pub),
-        GNUNET_JSON_spec_end ()
-      };
-
-      EXITIF (GNUNET_OK !=
-              GNUNET_JSON_parse (recoup_info,
-                                 spec,
-                                 NULL, NULL));
-      for (unsigned int j = 0;
-           j<key_data->num_denom_keys;
-           j++)
-      {
-        if (0 == GNUNET_memcmp (&h_denom_pub,
-                                &key_data->denom_keys[j].h_key))
-        {
-          key_data->denom_keys[j].revoked = true;
-          break;
-        }
-      }
-    }
-  }
-
-  if (check_sig)
-  {
-    EXITIF (GNUNET_OK !=
-            DONAU_test_signing_key (key_data,
-                                    &pub));
-    EXITIF (GNUNET_OK !=
-            TALER_donau_online_key_set_verify (
-              key_data->list_issue_date,
-              &hash_xor,
-              &pub,
-              &donation_units_sig));
-  }
   return GNUNET_OK;
 
 EXITIF_exit:
@@ -702,20 +466,9 @@ keys_completed_cb (void *cls,
 
   gkh->job = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Received keys from URL `%s' with status %ld and expiration 
%s.\n",
+              "Received keys from URL `%s' with status %ld.\n",
               gkh->url,
-              response_code,
-              GNUNET_TIME_timestamp2s (gkh->expire));
-  if (GNUNET_TIME_absolute_is_past (gkh->expire.abs_time))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Donau failed to give expiration time, assuming in %s\n",
-                GNUNET_TIME_relative2s (DEFAULT_EXPIRATION,
-                                        true));
-    gkh->expire
-      = GNUNET_TIME_absolute_to_timestamp (
-          GNUNET_TIME_relative_to_absolute (DEFAULT_EXPIRATION));
-  }
+              response_code);
   switch (response_code)
   {
   case 0:
@@ -732,50 +485,7 @@ keys_completed_cb (void *cls,
     }
     kd = GNUNET_new (struct DONAU_Keys);
     kd->donau_url = GNUNET_strdup (gkh->donau_url);
-    if (NULL != gkh->prev_keys)
-    {
-      const struct DONAU_Keys *kd_old = gkh->prev_keys;
-
-      /* We keep the donation unit keys and auditor signatures from the
-         previous iteration (/keys cherry picking) */
-      kd->num_denom_keys
-        = kd_old->num_denom_keys;
-      kd->last_denom_issue_date
-        = kd_old->last_denom_issue_date;
-      GNUNET_array_grow (kd->denom_keys,
-                         kd->denom_keys_size,
-                         kd->num_denom_keys);
-      /* First make a shallow copy, we then need another pass for the RSA 
key... */
-      GNUNET_memcpy (kd->denom_keys,
-                     kd_old->denom_keys,
-                     kd_old->num_denom_keys
-                     * sizeof (struct DONAU_DenomPublicKey));
-      for (unsigned int i = 0; i<kd_old->num_denom_keys; i++)
-        TALER_denom_pub_deep_copy (&kd->denom_keys[i].key,
-                                   &kd_old->denom_keys[i].key);
-      kd->num_auditors = kd_old->num_auditors;
-      kd->auditors = GNUNET_new_array (kd->num_auditors,
-                                       struct DONAU_AuditorInformation);
-      /* Now the necessary deep copy... */
-      for (unsigned int i = 0; i<kd_old->num_auditors; i++)
-      {
-        const struct DONAU_AuditorInformation *aold =
-          &kd_old->auditors[i];
-        struct DONAU_AuditorInformation *anew = &kd->auditors[i];
-
-        anew->auditor_pub = aold->auditor_pub;
-        anew->auditor_url = GNUNET_strdup (aold->auditor_url);
-        GNUNET_array_grow (anew->denom_keys,
-                           anew->num_denom_keys,
-                           aold->num_denom_keys);
-        GNUNET_memcpy (
-          anew->denom_keys,
-          aold->denom_keys,
-          aold->num_denom_keys
-          * sizeof (struct DONAU_AuditorDenominationInfo));
-      }
-    }
-    /* Now decode fresh /keys response */
+
     if (GNUNET_OK !=
         decode_keys_json (j,
                           true,
@@ -791,19 +501,6 @@ keys_completed_cb (void *cls,
       break;
     }
     kd->rc = 1;
-    kd->key_data_expiration = gkh->expire;
-    if (GNUNET_TIME_relative_cmp (
-          GNUNET_TIME_absolute_get_remaining (gkh->expire.abs_time),
-          <,
-          MINIMUM_EXPIRATION))
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Donau returned keys with expiration time below %s. 
Compensating.\n",
-                  GNUNET_TIME_relative2s (MINIMUM_EXPIRATION,
-                                          true));
-      kd->key_data_expiration
-        = GNUNET_TIME_relative_to_timestamp (MINIMUM_EXPIRATION);
-    }
 
     kresp.details.ok.keys = kd;
     break;
@@ -846,108 +543,6 @@ keys_completed_cb (void *cls,
 }
 
 
-/**
- * Define a max length for the HTTP "Expire:" header
- */
-#define MAX_DATE_LINE_LEN 32
-
-
-/**
- * Parse HTTP timestamp.
- *
- * @param dateline header to parse header
- * @param[out] at where to write the result
- * @return #GNUNET_OK on success
- */
-static enum GNUNET_GenericReturnValue
-parse_date_string (const char *dateline,
-                   struct GNUNET_TIME_Timestamp *at)
-{
-  static const char *MONTHS[] =
-  { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
-    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL };
-  int year;
-  int mon;
-  int day;
-  int hour;
-  int min;
-  int sec;
-  char month[4];
-  struct tm tm;
-  time_t t;
-
-  /* We recognize the three formats in RFC2616, section 3.3.1.  Month
-     names are always in English.  The formats are:
-      Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
-      Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
-      Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
-     Note that the first is preferred.
-   */
-
-  if (strlen (dateline) > MAX_DATE_LINE_LEN)
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
-  while (*dateline == ' ')
-    ++dateline;
-  while (*dateline && *dateline != ' ')
-    ++dateline;
-  while (*dateline == ' ')
-    ++dateline;
-  /* We just skipped over the day of the week. Now we have:*/
-  if ( (sscanf (dateline,
-                "%d %3s %d %d:%d:%d",
-                &day, month, &year, &hour, &min, &sec) != 6) &&
-       (sscanf (dateline,
-                "%d-%3s-%d %d:%d:%d",
-                &day, month, &year, &hour, &min, &sec) != 6) &&
-       (sscanf (dateline,
-                "%3s %d %d:%d:%d %d",
-                month, &day, &hour, &min, &sec, &year) != 6) )
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
-  /* Two digit dates are defined to be relative to 1900; all other dates
-   * are supposed to be represented as four digits. */
-  if (year < 100)
-    year += 1900;
-
-  for (mon = 0; ; mon++)
-  {
-    if (! MONTHS[mon])
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-    if (0 == strcasecmp (month,
-                         MONTHS[mon]))
-      break;
-  }
-
-  memset (&tm, 0, sizeof(tm));
-  tm.tm_year = year - 1900;
-  tm.tm_mon = mon;
-  tm.tm_mday = day;
-  tm.tm_hour = hour;
-  tm.tm_min = min;
-  tm.tm_sec = sec;
-
-  t = mktime (&tm);
-  if (((time_t) -1) == t)
-  {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
-                         "mktime");
-    return GNUNET_SYSERR;
-  }
-  if (t < 0)
-    t = 0; /* can happen due to timezone issues if date was 1.1.1970 */
-  *at = GNUNET_TIME_timestamp_from_s (t);
-  return GNUNET_OK;
-}
-
-
 /**
  * Function called for each header in the HTTP /keys response.
  * Finds the "Expire:" header and parses it, storing the result
@@ -981,16 +576,16 @@ header_cb (char *buffer,
               "Found %s header `%s'\n",
               MHD_HTTP_HEADER_EXPIRES,
               val);
-  if (GNUNET_OK !=
-      parse_date_string (val,
-                         &kr->expire))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Failed to parse %s-header `%s'\n",
-                MHD_HTTP_HEADER_EXPIRES,
-                val);
-    kr->expire = GNUNET_TIME_UNIT_ZERO_TS;
-  }
+  // if (GNUNET_OK !=
+  //     parse_date_string (val,
+  //                        &kr->expire))
+  // {
+  //   GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+  //               "Failed to parse %s-header `%s'\n",
+  //               MHD_HTTP_HEADER_EXPIRES,
+  //               val);
+  //   kr->expire = GNUNET_TIME_UNIT_ZERO_TS;
+  // }
   GNUNET_free (val);
   return total;
 }
@@ -1035,10 +630,10 @@ DONAU_get_keys (
                 curl_easy_setopt (eh,
                                   CURLOPT_TIMEOUT,
                                   120 /* seconds */));
-  GNUNET_assert (CURLE_OK ==
-                 curl_easy_setopt (eh,
-                                   CURLOPT_HEADERFUNCTION,
-                                   &header_cb));
+  // GNUNET_assert (CURLE_OK ==
+  //                curl_easy_setopt (eh,
+  //                                  CURLOPT_HEADERFUNCTION,
+  //                                  &header_cb));
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_HEADERDATA,
@@ -1067,59 +662,29 @@ DONAU_get_keys_cancel (
 }
 
 
-enum GNUNET_GenericReturnValue
-DONAU_test_signing_key (
-  const struct DONAU_Keys *keys,
-  const struct DONAU_DonauPublicKeyP *pub)
-{
-  struct GNUNET_TIME_Absolute now;
-
-  /* we will check using a tolerance of 1h for the time */
-  now = GNUNET_TIME_absolute_get ();
-  for (unsigned int i = 0; i<keys->num_sign_keys; i++)
-    if ( (GNUNET_TIME_absolute_cmp (
-            keys->sign_keys[i].valid_from.abs_time,
-            <=,
-            GNUNET_TIME_absolute_add (now,
-                                      LIFETIME_TOLERANCE))) &&
-         (GNUNET_TIME_absolute_cmp (
-            keys->sign_keys[i].valid_until.abs_time,
-            >,
-            GNUNET_TIME_absolute_subtract (now,
-                                           LIFETIME_TOLERANCE))) &&
-         (0 == GNUNET_memcmp (pub,
-                              &keys->sign_keys[i].key)) )
-      return GNUNET_OK;
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              "Signing key not valid at time %s\n",
-              GNUNET_TIME_absolute2s (now));
-  return GNUNET_SYSERR;
-}
-
-
-const struct DONAU_DenomPublicKey *
+const struct DONAU_DonationUnitInformation *
 DONAU_get_donation_unit_key (
   const struct DONAU_Keys *keys,
-  const struct TALER_DenominationPublicKey *pk)
+  const struct DONAU_DonationUnitPublicKey *pk)
 {
-  for (unsigned int i = 0; i<keys->num_denom_keys; i++)
+  for (unsigned int i = 0; i<keys->num_donation_unit_keys; i++)
     if (0 ==
-        TALER_denom_pub_cmp (pk,
-                             &keys->denom_keys[i].key))
-      return &keys->denom_keys[i];
+        DONAU_donation_unit_pub_cmp (pk,
+                             &keys->donation_unit_keys[i].key))
+      return &keys->donation_unit_keys[i];
   return NULL;
 }
 
 
-struct DONAU_DenomPublicKey *
+struct DONAU_DonationUnitInformation *
 DONAU_copy_donation_unit_key (
-  const struct DONAU_DenomPublicKey *key)
+  const struct DONAU_DonationUnitInformation *key)
 {
-  struct DONAU_DenomPublicKey *copy;
+  struct DONAU_DonationUnitInformation *copy;
 
-  copy = GNUNET_new (struct DONAU_DenomPublicKey);
+  copy = GNUNET_new (struct DONAU_DonationUnitInformation);
   *copy = *key;
-  TALER_denom_pub_deep_copy (&copy->key,
+  DONAU_donation_unit_pub_deep_copy (&copy->key, // only increments rc, still 
same pointer
                              &key->key);
   return copy;
 }
@@ -1127,22 +692,23 @@ DONAU_copy_donation_unit_key (
 
 void
 DONAU_destroy_donation_unit_key (
-  struct DONAU_DenomPublicKey *key)
+  struct DONAU_DonationUnitInformation *key)
 {
-  TALER_denom_pub_free (&key->key);
+  DONAU_donation_unit_pub_free (&key->key);
   GNUNET_free (key);
 }
 
 
-const struct DONAU_DenomPublicKey *
+const struct DONAU_DonationUnitInformation *
 DONAU_get_donation_unit_key_by_hash (
   const struct DONAU_Keys *keys,
-  const struct TALER_DenominationHashP *hc)
+  const struct DONAU_DonationUnitHashP *hc)
 {
-  for (unsigned int i = 0; i<keys->num_denom_keys; i++)
-    if (0 == GNUNET_memcmp (hc,
-                            &keys->denom_keys[i].h_key))
-      return &keys->denom_keys[i];
+  for (unsigned int i = 0; i<keys->num_donation_unit_keys; i++)
+    // memcmp needs two pointer of the same type
+    if (0 == GNUNET_memcmp (&hc->hash,
+                            
&keys->donation_unit_keys[i].key.bsign_pub_key.pub_key_hash))
+      return &keys->donation_unit_keys[i];
   return NULL;
 }
 
@@ -1168,35 +734,14 @@ DONAU_keys_decref (struct DONAU_Keys *keys)
   GNUNET_array_grow (keys->sign_keys,
                      keys->num_sign_keys,
                      0);
-  for (unsigned int i = 0; i<keys->num_denom_keys; i++)
-    TALER_denom_pub_free (&keys->denom_keys[i].key);
+  for (unsigned int i = 0; i<keys->num_donation_unit_keys; i++)
+    DONAU_donation_unit_pub_free (&keys->donation_unit_keys[i].key);
 
-  GNUNET_array_grow (keys->denom_keys,
-                     keys->denom_keys_size,
-                     0);
-  for (unsigned int i = 0; i<keys->num_auditors; i++)
-  {
-    GNUNET_array_grow (keys->auditors[i].denom_keys,
-                       keys->auditors[i].num_denom_keys,
-                       0);
-    GNUNET_free (keys->auditors[i].auditor_url);
-  }
-  GNUNET_array_grow (keys->auditors,
-                     keys->auditors_size,
-                     0);
-  DONAU_free_accounts (keys->accounts_len,
-                       keys->accounts);
-  GNUNET_array_grow (keys->accounts,
-                     keys->accounts_len,
+  GNUNET_array_grow (keys->donation_unit_keys,
+                     keys->donation_unit_keys_size,
                      0);
-  free_fees (keys->fees,
-             keys->fees_len);
-  json_decref (keys->extensions);
-  GNUNET_free (keys->wallet_balance_limit_without_kyc);
   GNUNET_free (keys->version);
   GNUNET_free (keys->currency);
-  GNUNET_free (keys->asset_type);
-  GNUNET_free (keys->global_fees);
   GNUNET_free (keys->donau_url);
   GNUNET_free (keys);
 }
@@ -1208,8 +753,6 @@ DONAU_keys_from_json (const json_t *j)
   const json_t *jkeys;
   const char *url;
   uint32_t version;
-  struct GNUNET_TIME_Timestamp expire
-    = GNUNET_TIME_UNIT_ZERO_TS;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_uint32 ("version",
                              &version),
@@ -1217,10 +760,6 @@ DONAU_keys_from_json (const json_t *j)
                                    &jkeys),
     GNUNET_JSON_spec_string ("donau_url",
                              &url),
-    GNUNET_JSON_spec_mark_optional (
-      GNUNET_JSON_spec_timestamp ("expire",
-                                  &expire),
-      NULL),
     GNUNET_JSON_spec_end ()
   };
   struct DONAU_Keys *keys;
@@ -1251,7 +790,6 @@ DONAU_keys_from_json (const json_t *j)
     return NULL;
   }
   keys->rc = 1;
-  keys->key_data_expiration = expire;
   keys->donau_url = GNUNET_strdup (url);
   return keys;
 }
@@ -1298,21 +836,19 @@ add_grp (void *cls,
   switch (gd->meta.cipher)
   {
   case GNUNET_CRYPTO_BSA_RSA:
-    cipher = age_restricted ? "RSA+age_restricted" : "RSA";
+    cipher = "RSA";
     break;
   case GNUNET_CRYPTO_BSA_CS:
-    cipher = age_restricted ? "CS+age_restricted" : "CS";
+    cipher = "CS";
     break;
   default:
     GNUNET_assert (false);
   }
 
   ge = GNUNET_JSON_PACK (
-    GNUNET_JSON_pack_data_auto ("hash",
-                                &gd->meta.hash),
     GNUNET_JSON_pack_string ("cipher",
                              cipher),
-    GNUNET_JSON_pack_array_steal ("denoms",
+    GNUNET_JSON_pack_array_steal ("donation_units",
                                   gd->json),
     TALER_JSON_pack_amount ("value",
                             &gd->meta.value));
@@ -1324,80 +860,18 @@ add_grp (void *cls,
 }
 
 
-/**
- * Convert array of account restrictions @a ars to JSON.
- *
- * @param ar_len length of @a ars
- * @param ars account restrictions to convert
- * @return JSON representation
- */
-static json_t *
-ar_to_json (unsigned int ar_len,
-            const struct TALER_DONAU_AccountRestriction ars[static ar_len])
-{
-  json_t *rval;
-
-  rval = json_array ();
-  GNUNET_assert (NULL != rval);
-  for (unsigned int i = 0; i<ar_len; i++)
-  {
-    const struct TALER_DONAU_AccountRestriction *ar = &ars[i];
-
-    switch (ar->type)
-    {
-    case TALER_DONAU_AR_INVALID:
-      GNUNET_break (0);
-      json_decref (rval);
-      return NULL;
-    case TALER_DONAU_AR_DENY:
-      GNUNET_assert (
-        0 ==
-        json_array_append_new (
-          rval,
-          GNUNET_JSON_PACK (
-            GNUNET_JSON_pack_string ("type",
-                                     "deny"))));
-      break;
-    case TALER_DONAU_AR_REGEX:
-      GNUNET_assert (
-        0 ==
-        json_array_append_new (
-          rval,
-          GNUNET_JSON_PACK (
-            GNUNET_JSON_pack_string (
-              "type",
-              "regex"),
-            GNUNET_JSON_pack_string (
-              "regex",
-              ar->details.regex.posix_egrep),
-            GNUNET_JSON_pack_string (
-              "human_hint",
-              ar->details.regex.human_hint),
-            GNUNET_JSON_pack_object_incref (
-              "human_hint_i18n",
-              (json_t *) ar->details.regex.human_hint_i18n)
-            )));
-      break;
-    }
-  }
-  return rval;
-}
-
-
 json_t *
 DONAU_keys_to_json (const struct DONAU_Keys *kd)
 {
   json_t *keys;
   json_t *signkeys;
   json_t *donation_units;
-  json_t *accounts;
 
-  now = GNUNET_TIME_timestamp_get ();
   signkeys = json_array ();
   GNUNET_assert (NULL != signkeys);
   for (unsigned int i = 0; i<kd->num_sign_keys; i++)
   {
-    const struct TALER_DONAU_SigningPublicKey *sk = &kd->sign_keys[i];
+    const struct DONAU_SigningPublicKeyAndValidity *sk = &kd->sign_keys[i];
     json_t *signkey;
 
     signkey = GNUNET_JSON_PACK (
@@ -1416,24 +890,22 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd)
   {
     struct GNUNET_CONTAINER_MultiHashMap *dbg;
 
-    dbg = GNUNET_CONTAINER_multihashmap_create (128,
+    dbg = GNUNET_CONTAINER_multihashmap_create (128, // why 128 and why do we 
need a multihashmap (remove doubles?), why are the timestamps not included?
                                                 false);
     for (unsigned int i = 0; i<kd->num_donation_unit_keys; i++)
     {
-      const struct TALER_DONAU_DenomPublicKey *dk = &kd->denom_keys[i];
-      struct TALER_DenominationGroup meta = {
-        .cipher = dk->key.cipher,
-        .value = dk->value,
-        .year = dk->year
+      const struct DONAU_DonationUnitInformation *dk = 
&kd->donation_unit_keys[i];
+      struct DONAU_DonationUnitGroup meta = {
+        .cipher = dk->key.bsign_pub_key->cipher,
+        .value = dk->value
+        //.year = dk->year ??
       };
       struct GNUNET_HashCode key;
       struct GroupData *gd;
       json_t *donation_unit;
       struct GNUNET_JSON_PackSpec key_spec;
 
-      //TODO: check year
-
-      TALER_donation_unit_group_get_key (&meta,
+      DONAU_donation_unit_group_get_key (&meta,
                                         &key);
       gd = GNUNET_CONTAINER_multihashmap_get (dbg,
                                               &key);
@@ -1471,16 +943,8 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd)
         GNUNET_assert (false);
       }
       donation_unit = GNUNET_JSON_PACK (
-        GNUNET_JSON_pack_timestamp ("stamp_expire_deposit",
-                                    dk->expire_deposit),
-        GNUNET_JSON_pack_timestamp ("stamp_expire_withdraw",
-                                    dk->withdraw_valid_until),
-        GNUNET_JSON_pack_timestamp ("stamp_start",
-                                    dk->valid_from),
-        GNUNET_JSON_pack_timestamp ("stamp_expire_legal",
-                                    dk->expire_legal),
-        GNUNET_JSON_pack_data_auto ("master_sig",
-                                    &dk->master_sig),
+        GNUNET_JSON_pack_data_varsize ("year",
+                                       dk->year),
         key_spec
         );
       GNUNET_assert (0 ==
@@ -1493,191 +957,14 @@ DONAU_keys_to_json (const struct DONAU_Keys *kd)
     GNUNET_CONTAINER_multihashmap_destroy (dbg);
   }
 
-  auditors = json_array ();
-  GNUNET_assert (NULL != auditors);
-  for (unsigned int i = 0; i<kd->num_auditors; i++)
-  {
-    const struct TALER_DONAU_AuditorInformation *ai = &kd->auditors[i];
-    json_t *a;
-    json_t *adenoms;
-
-    adenoms = json_array ();
-    GNUNET_assert (NULL != adenoms);
-    for (unsigned int j = 0; j<ai->num_denom_keys; j++)
-    {
-      const struct TALER_DONAU_AuditorDenominationInfo *adi =
-        &ai->denom_keys[j];
-      const struct TALER_DONAU_DenomPublicKey *dk =
-        &kd->denom_keys[adi->denom_key_offset];
-      json_t *k;
-
-      GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys);
-      if (GNUNET_TIME_timestamp_cmp (now,
-                                     >,
-                                     dk->expire_deposit))
-        continue; /* skip auditor signatures for donation unit keys that have 
expired */
-      GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys);
-      k = GNUNET_JSON_PACK (
-        GNUNET_JSON_pack_data_auto ("denom_pub_h",
-                                    &dk->h_key),
-        GNUNET_JSON_pack_data_auto ("auditor_sig",
-                                    &adi->auditor_sig));
-      GNUNET_assert (0 ==
-                     json_array_append_new (adenoms,
-                                            k));
-    }
-
-    a = GNUNET_JSON_PACK (
-      GNUNET_JSON_pack_data_auto ("auditor_pub",
-                                  &ai->auditor_pub),
-      GNUNET_JSON_pack_string ("auditor_url",
-                               ai->auditor_url),
-      GNUNET_JSON_pack_array_steal ("donation_unit_keys",
-                                    adenoms));
-    GNUNET_assert (0 ==
-                   json_array_append_new (auditors,
-                                          a));
-  }
-
-  global_fees = json_array ();
-  GNUNET_assert (NULL != global_fees);
-  for (unsigned int i = 0; i<kd->num_global_fees; i++)
-  {
-    const struct TALER_DONAU_GlobalFee *gf
-      = &kd->global_fees[i];
-
-    if (GNUNET_TIME_absolute_is_past (gf->end_date.abs_time))
-      continue;
-    GNUNET_assert (
-      0 ==
-      json_array_append_new (
-        global_fees,
-        GNUNET_JSON_PACK (
-          GNUNET_JSON_pack_timestamp ("start_date",
-                                      gf->start_date),
-          GNUNET_JSON_pack_timestamp ("end_date",
-                                      gf->end_date),
-          TALER_JSON_PACK_GLOBAL_FEES (&gf->fees),
-          GNUNET_JSON_pack_time_rel ("history_expiration",
-                                     gf->history_expiration),
-          GNUNET_JSON_pack_time_rel ("purse_timeout",
-                                     gf->purse_timeout),
-          GNUNET_JSON_pack_uint64 ("purse_account_limit",
-                                   gf->purse_account_limit),
-          GNUNET_JSON_pack_data_auto ("master_sig",
-                                      &gf->master_sig))));
-  }
-
-  accounts = json_array ();
-  GNUNET_assert (NULL != accounts);
-  for (unsigned int i = 0; i<kd->accounts_len; i++)
-  {
-    const struct TALER_DONAU_WireAccount *acc
-      = &kd->accounts[i];
-    json_t *credit_restrictions;
-    json_t *debit_restrictions;
-
-    credit_restrictions
-      = ar_to_json (acc->credit_restrictions_length,
-                    acc->credit_restrictions);
-    GNUNET_assert (NULL != credit_restrictions);
-    debit_restrictions
-      = ar_to_json (acc->debit_restrictions_length,
-                    acc->debit_restrictions);
-    GNUNET_assert (NULL != debit_restrictions);
-    GNUNET_assert (
-      0 ==
-      json_array_append_new (
-        accounts,
-        GNUNET_JSON_PACK (
-          GNUNET_JSON_pack_string ("payto_uri",
-                                   acc->payto_uri),
-          GNUNET_JSON_pack_allow_null (
-            GNUNET_JSON_pack_string ("conversion_url",
-                                     acc->conversion_url)),
-          GNUNET_JSON_pack_array_steal ("debit_restrictions",
-                                        debit_restrictions),
-          GNUNET_JSON_pack_array_steal ("credit_restrictions",
-                                        credit_restrictions),
-          GNUNET_JSON_pack_data_auto ("master_sig",
-                                      &acc->master_sig))));
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Serialized %u/%u wire accounts to JSON\n",
-              (unsigned int) json_array_size (accounts),
-              kd->accounts_len);
-
-  wire_fees = json_object ();
-  GNUNET_assert (NULL != wire_fees);
-  for (unsigned int i = 0; i<kd->fees_len; i++)
-  {
-    const struct TALER_DONAU_WireFeesByMethod *fbw
-      = &kd->fees[i];
-    json_t *wf;
-
-    wf = json_array ();
-    GNUNET_assert (NULL != wf);
-    for (struct TALER_DONAU_WireAggregateFees *p = fbw->fees_head;
-         NULL != p;
-         p = p->next)
-    {
-      GNUNET_assert (
-        0 ==
-        json_array_append_new (
-          wf,
-          GNUNET_JSON_PACK (
-            TALER_JSON_pack_amount ("wire_fee",
-                                    &p->fees.wire),
-            TALER_JSON_pack_amount ("closing_fee",
-                                    &p->fees.closing),
-            GNUNET_JSON_pack_timestamp ("start_date",
-                                        p->start_date),
-            GNUNET_JSON_pack_timestamp ("end_date",
-                                        p->end_date),
-            GNUNET_JSON_pack_data_auto ("sig",
-                                        &p->master_sig))));
-    }
-    GNUNET_assert (0 ==
-                   json_object_set_new (wire_fees,
-                                        fbw->method,
-                                        wf));
-  }
-
-  recoup = json_array ();
-  GNUNET_assert (NULL != recoup);
-  for (unsigned int i = 0; i<kd->num_denom_keys; i++)
-  {
-    const struct TALER_DONAU_DenomPublicKey *dk
-      = &kd->denom_keys[i];
-    if (! dk->revoked)
-      continue;
-    GNUNET_assert (0 ==
-                   json_array_append_new (
-                     recoup,
-                     GNUNET_JSON_PACK (
-                       GNUNET_JSON_pack_data_auto ("h_denom_pub",
-                                                   &dk->h_key))));
-  }
-
-  wblwk = json_array ();
-  GNUNET_assert (NULL != wblwk);
-  for (unsigned int i = 0; i<kd->wblwk_length; i++)
-  {
-    const struct TALER_Amount *a = &kd->wallet_balance_limit_without_kyc[i];
-
-    GNUNET_assert (0 ==
-                   json_array_append_new (
-                     wblwk,
-                     TALER_JSON_from_amount (a)));
-  }
-
   keys = GNUNET_JSON_PACK (
     GNUNET_JSON_pack_string ("version",
                              kd->version),
     GNUNET_JSON_pack_string ("currency",
                              kd->currency),
-    GNUNET_JSON_pack_uint64 ("currency_fraction_digits",
-                             kd->currency_fraction_digits),
+    GNUNET_JSON_pack_object_steal ("currency_specification",
+                                   TALER_CONFIG_currency_specs_to_json (
+                                     &kd->currency_specification)),
     GNUNET_JSON_pack_array_steal ("signkeys",
                                   signkeys),
     GNUNET_JSON_pack_array_steal ("donation_units",
diff --git a/src/util/donau_crypto.c b/src/util/donau_crypto.c
index 1097cae..8afd373 100644
--- a/src/util/donau_crypto.c
+++ b/src/util/donau_crypto.c
@@ -31,7 +31,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
 struct DonationUnitGroupP
 {
   /**
-   * Value of coins in this denomination group.
+   * Value of coins in this donation unit group.
    */
   struct TALER_AmountNBO value;
 
@@ -60,3 +60,70 @@ TALER_donation_unit_group_get_key (
                       key);
 }
 
+int
+DONAU_donation_unit_pub_cmp (const struct DONAU_DonationUnitPublicKey 
*donation_unit1,
+                     const struct DONAU_DonationUnitPublicKey *donation_unit2)
+{
+  if (donation_unit1->bsign_pub_key->cipher !=
+      donation_unit2->bsign_pub_key->cipher)
+    return (donation_unit1->bsign_pub_key->cipher >
+            donation_unit2->bsign_pub_key->cipher) ? 1 : -1;
+  if (donation_unit1->age_mask.bits != donation_unit2->age_mask.bits)
+    return (donation_unit1->age_mask.bits > donation_unit2->age_mask.bits) ? 1 
: -1;
+  return GNUNET_CRYPTO_bsign_pub_cmp (donation_unit1->bsign_pub_key,
+                                      donation_unit2->bsign_pub_key);
+}
+
+void
+DONAU_donation_unit_pub_deep_copy (struct DONAU_DonationUnitPublicKey 
*donation_unit_dst,
+                             const struct DONAU_DonationUnitPublicKey 
*donation_unit_src)
+{
+  donation_unit_dst->bsign_pub_key
+    = GNUNET_CRYPTO_bsign_pub_incref (donation_unit_src->bsign_pub_key);
+}
+
+void
+DONAU_donation_unit_pub_free (struct DONAU_DonationUnitPublicKey 
*donation_unit_pub)
+{
+  if (NULL != donation_unit_pub->bsign_pub_key)
+  {
+    GNUNET_CRYPTO_blind_sign_pub_decref (donation_unit_pub->bsign_pub_key);
+    donation_unit_pub->bsign_pub_key = NULL;
+  }
+}
+
+
+GNUNET_NETWORK_STRUCT_BEGIN
+/**
+ * Structure we hash to compute the group key for
+ * a donation unit group.
+ */
+struct DonationUnitGroupP
+{
+  /**
+   * Value of coins in this donation unit group.
+   */
+  struct TALER_AmountNBO value;
+
+  /**
+   * Cipher used for the denomination, in NBO.
+   */
+  uint32_t cipher GNUNET_PACKED;
+};
+GNUNET_NETWORK_STRUCT_END
+
+void
+DONAU_donatin_unit_group_get_key (
+  const struct DONAU_DonationUnitGroup *dg,
+  struct GNUNET_HashCode *key)
+{
+  struct DonationUnitGroupP dgp = {
+    .cipher = htonl (dg->cipher)
+  };
+
+  TALER_amount_hton (&dgp.value,
+                     &dg->value);
+  GNUNET_CRYPTO_hash (&dgp,
+                      sizeof (dgp),
+                      key);
+}
\ No newline at end of file

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