gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: uuid


From: gnunet
Subject: [taler-anastasis] branch master updated: uuid
Date: Mon, 06 Jul 2020 18:58:37 +0200

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

ds-meister pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 84d9970  uuid
84d9970 is described below

commit 84d9970dab4a96398787eefa4d11ae5ac973667f
Author: Dominik Meister <dominiksamuel.meister@students.bfh.ch>
AuthorDate: Mon Jul 6 18:58:30 2020 +0200

    uuid
---
 src/include/anastasis.h            |  17 ++-
 src/include/anastasis_crypto_lib.h |  26 +++++
 src/lib/anastasis.c                | 206 +++++++++++++++++++------------------
 src/util/anastasis_crypto.c        |  35 +++++++
 4 files changed, 177 insertions(+), 107 deletions(-)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 6819cd3..6a382d0 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -23,7 +23,6 @@
 #include "platform.h"
 #include <taler/taler_json_lib.h>
 #include <gnunet/gnunet_util_lib.h>
-#include <uuid/uuid.h>
 #include "anastasis_service.h"
 #include <stdbool.h>
 
@@ -53,13 +52,13 @@ struct ANASTASIS_PaymentDetails
 struct ANASTASIS_DecryptionPolicy
 {
   /**
-   * Set of escrow methods identfied by their uuids
+   * Set of escrow methods identfied by unique public keys
    */
-  uuid_t *escrow_uuids;
+  struct ANASTASIS_CRYPTO_NonceP *nonces;
   /**
    * length of the methods in this policy
    */
-  uint32_t uuids_length;
+  uint32_t nonces_length;
   /**
    * encrypted masterkey ( encrypted with the policy key)
    */
@@ -102,7 +101,7 @@ typedef void
                                 size_t secret_size);
 
 /**
- * Challenge struct contains the UUID's needed for the recovery process and a 
reference to
+ * Challenge struct contains the public key's needed for the recovery process 
and a reference to
  * ANASTASIS_Recovery.
  */
 struct ANASTASIS_Challenge;
@@ -145,7 +144,7 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
  * @param instructions defines which steps need to be done e.g. ( please look 
for the pin for recovery #1234)
  * @param cost Cost to solve this challenge
  * @param solved 1 if solved, else 0
- * @param uuid Uuid of the challenge
+ * @param truth_public_key Identifier of the challenge
  * @param currency Currency of the cost
  */
 struct ANASTASIS_ChallengeInformation
@@ -155,7 +154,7 @@ struct ANASTASIS_ChallengeInformation
   const char *instructions;
   struct TALER_Amount *cost;
   const unsigned int *solved;
-  const uuid_t *uuid;
+  const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key;
   char *currency;
   struct ANASTASIS_Challenge *challenge;
 };
@@ -269,7 +268,7 @@ ANASTASIS_recovery_abort (struct ANASTASIS_Recovery *r);
 struct ANASTASIS_TruthUpload;
 
 /**
-* provider_url + UUID
+* provider_url + truth public key
 */
 struct ANASTASIS_Truth;
 
@@ -290,7 +289,7 @@ typedef void
 * caller MUST free 't' using ANASTASIS_truth_free()
 *
 * @param cls closure for callback
-* @param t Truth object (contains provider url and uuid)
+* @param t Truth object (contains provider url and truth public key)
 */
 typedef void
 (*ANASTASIS_TruthCallback)(void *cls,
diff --git a/src/include/anastasis_crypto_lib.h 
b/src/include/anastasis_crypto_lib.h
index 9906402..ee3651c 100644
--- a/src/include/anastasis_crypto_lib.h
+++ b/src/include/anastasis_crypto_lib.h
@@ -44,6 +44,21 @@ struct ANASTASIS_CRYPTO_AccountPrivateKeyP
   struct GNUNET_CRYPTO_EddsaPrivateKey priv;
 };
 
+/**
+ * An EdDSA private key that is used to identify a truth object
+ */
+struct ANASTASIS_CRYPTO_TruthPrivateKeyP
+{
+  struct GNUNET_CRYPTO_EddsaPrivateKey priv;
+};
+
+/**
+ * An EdDSA public key that is used to identify a truth object
+ */
+struct ANASTASIS_CRYPTO_TruthPublicKeyP
+{
+  struct GNUNET_CRYPTO_EddsaPublicKey pub;
+};
 
 /**
  * Specifies a TruthKey which is used to decrypt the Truth stored by the user.
@@ -172,6 +187,17 @@ ANASTASIS_CRYPTO_user_identifier_derive (
   const struct ANASTASIS_CRYPTO_SaltP *server_salt,
   struct ANASTASIS_CRYPTO_UserIdentifierP *id);
 
+/**
+ * Generates the eddsa public Key and private key which are the identfier of 
the truth object.
+ * The private key is used to sign the upload.
+ * @param nonce is the seed to create and recreate the private key
+ * @param pub_key[out] handle for the generated pub key
+ * @param priv_key[out] handle for the generated priv key
+ */
+void
+ANASTASIS_CRYPTO_truth_public_key_derive (
+  const struct ANASTASIS_CRYPTO_NonceP *nonce,
+  struct ANASTASIS_CRYPTO_TruthPublicKeyP *pub_key);
 
 /**
  * Generates the eddsa public Key used as the account identifier on the 
providers
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index da47dc0..e1eade3 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -105,7 +105,7 @@ struct ANASTASIS_Recovery
 };
 
 /**
- * Challenge struct contains the UUID's needed for the recovery process and a 
reference to
+ * Challenge struct contains the nonce and public key's needed for the 
recovery process and a reference to
  * ANASTASIS_Recovery.
  */
 struct ANASTASIS_Challenge
@@ -141,9 +141,14 @@ struct ANASTASIS_Challenge
   const char *url;
 
   /**
-   * uuid which defines this challenge
+   * truth public key which identifies this challenge
    */
-  uuid_t challenge_uuid;
+  struct ANASTASIS_CRYPTO_TruthPublicKeyP truth_public_key;
+
+  /**
+   * nonce which identifies the challenge
+   */
+  struct ANASTASIS_CRYPTO_NonceP nonce;
 
   /**
    * Key used to encrypt the truth passed to the server
@@ -241,7 +246,7 @@ keyshare_lookup_cb (void *cls,
          http_status);
 
   /**
-   * 0 equals the uuid was not solved 1 it was solved
+   * 0 equals the challenge was not solved 1 it was solved
    */
   bool missing = true;
   /**
@@ -251,13 +256,14 @@ keyshare_lookup_cb (void *cls,
 
   for (unsigned int i = 0; i < c->recovery->ri->dps_len; i++)
   {
-    for (unsigned int j = 0; j < c->recovery->ri->dps[i].uuids_length; j++)
+    for (unsigned int j = 0; j < c->recovery->ri->dps[i].nonces_length; j++)
     {
       missing = true;
       for (unsigned int k = 0; k < c->recovery->solved_challenge_pos; k++)
       {
-        if (0 == uuid_compare (c->recovery->ri->dps[i].escrow_uuids[j],
-                               
c->recovery->solved_challenges[k].challenge_uuid))
+        if (0 == memcmp (&c->recovery->ri->dps[i].nonces[j],
+                         &c->recovery->solved_challenges[k].nonce,
+                         sizeof(struct ANASTASIS_CRYPTO_NonceP)))
         {
           missing = false;
           break;
@@ -282,15 +288,16 @@ keyshare_lookup_cb (void *cls,
     void *core_secret;
     size_t core_secret_size;
     struct ANASTASIS_CRYPTO_KeyShareP
-      key_shares[c->recovery->ri->dps[success].uuids_length];
+      key_shares[c->recovery->ri->dps[success].nonces_length];
     struct ANASTASIS_CRYPTO_PolicyKeyP policy_key;
-    for (unsigned int l = 0; l < c->recovery->ri->dps[success].uuids_length;
+    for (unsigned int l = 0; l < c->recovery->ri->dps[success].nonces_length;
          l++)
     {
       for (unsigned int m = 0; m < c->recovery->solved_challenge_pos; m++)
       {
-        if (0 == uuid_compare (c->recovery->ri->dps[success].escrow_uuids[l],
-                               
c->recovery->solved_challenges[m].challenge_uuid))
+        if (0 == memcmp (&c->recovery->ri->dps[success].nonces[l],
+                         &c->recovery->solved_challenges[m].nonce,
+                         sizeof(struct ANASTASIS_CRYPTO_NonceP)))
         {
           key_shares[l] = *c->recovery->solved_challenges[m].key_share;
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -305,7 +312,7 @@ keyshare_lookup_cb (void *cls,
     }
     ANASTASIS_CRYPTO_policy_key_derive (key_shares,
                                         c->recovery->ri->dps[success].
-                                        uuids_length,
+                                        nonces_length,
                                         &c->recovery->ri->dps[success].salt,
                                         &policy_key);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -369,8 +376,8 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d challenge %s-%llu is solved with url %s \n", __FILE__,
               __LINE__,
-              TALER_B2S (&c->challenge_uuid),
-              (unsigned long long) sizeof (c->challenge_uuid),
+              TALER_B2S (&c->truth_public_key),
+              (unsigned long long) sizeof (c->truth_public_key),
               c->url);
 
   struct GNUNET_HashCode hashed_answer;
@@ -385,7 +392,7 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
   c->http_status = MHD_HTTP_OK;
   c->kslo = ANASTASIS_keyshare_lookup (c->ctx,
                                        c->url,
-                                       &c->challenge_uuid,
+                                       &c->truth_public_key,
                                        &c->truth_key,
                                        &hashed_answer,
                                        &keyshare_lookup_cb,
@@ -408,7 +415,7 @@ ANASTASIS_get_challenge (struct ANASTASIS_Challenge 
*challenge,
   struct ANASTASIS_ChallengeInformation *ci;
   ci = GNUNET_new (struct ANASTASIS_ChallengeInformation);
   challenge->cc = cc;
-  ci->uuid = &challenge->challenge_uuid;
+  ci->truth_public_key = &challenge->truth_public_key;
   ci->method = challenge->escrow_method;
   ci->url = challenge->url;
   ci->instructions = challenge->instructions;
@@ -555,12 +562,11 @@ policy_lookup_cb (void *cls,
 
   for (unsigned int i = 0; i < r->ri->cs_len; i++)
   {
-    const char *uuid;
     cs[i] = GNUNET_new (struct ANASTASIS_Challenge);
 
     struct GNUNET_JSON_Specification spec[] = {
-      GNUNET_JSON_spec_string ("uuid",
-                               &uuid),
+      GNUNET_JSON_spec_fixed_auto ("nonce",
+                                   &cs[i]->nonce),
       GNUNET_JSON_spec_string ("url",
                                &cs[i]->url),
       GNUNET_JSON_spec_string ("instructions",
@@ -584,15 +590,15 @@ policy_lookup_cb (void *cls,
       return;
     }
 
-    GNUNET_assert (0 ==
-                   uuid_parse (uuid,
-                               cs[i]->challenge_uuid));
+    ANASTASIS_CRYPTO_truth_public_key_derive (&cs[i]->nonce,
+                                              &cs[i]->truth_public_key);
     cs[i]->recovery = r;
 
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d challenge_uuid is %s-%llu b\n", __FILE__, __LINE__,
-                TALER_B2S (&cs[i]->challenge_uuid),
-                (unsigned long long) sizeof (cs[i]->challenge_uuid));
+                "At %s:%d challenge public key is %s-%llu b\n", __FILE__,
+                __LINE__,
+                TALER_B2S (&cs[i]->truth_public_key),
+                (unsigned long long) sizeof (cs[i]->truth_public_key));
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "At %s:%d url is %s\n", __FILE__, __LINE__,
                 cs[i]->url);
@@ -611,17 +617,17 @@ policy_lookup_cb (void *cls,
 
   for (unsigned int j = 0; j < r->ri->dps_len; j++)
   {
-    const char *uuids;
+    const char *nonces;
 
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_fixed_auto ("master_key",
                                    &r->ri->dps[j].emk),
-      GNUNET_JSON_spec_string ("uuids",
-                               &uuids),
+      GNUNET_JSON_spec_string ("nonces",
+                               &nonces),
       GNUNET_JSON_spec_fixed_auto ("salt",
                                    &r->ri->dps[j].salt),
-      GNUNET_JSON_spec_uint32 ("uuids_length",
-                               &r->ri->dps[j].uuids_length),
+      GNUNET_JSON_spec_uint32 ("nonces_length",
+                               &r->ri->dps[j].nonces_length),
       GNUNET_JSON_spec_end ()
     };
 
@@ -635,25 +641,25 @@ policy_lookup_cb (void *cls,
       return;
     }
 
-    r->ri->dps[j].escrow_uuids = GNUNET_new_array (r->ri->dps[j].uuids_length,
-                                                   uuid_t);
+    r->ri->dps[j].nonces = GNUNET_new_array (r->ri->dps[j].nonces_length,
+                                             struct ANASTASIS_CRYPTO_NonceP);
 
-    for (int a = 0; a < r->ri->dps[j].uuids_length; a++)
+    for (int a = 0; a < r->ri->dps[j].nonces_length; a++)
     {
-      char buf[37];
-      strncpy (buf,uuids + a * 36,36);
-      buf[36] = '\0';
+      char buf[33];
+      strncpy (buf,nonces + a * 33,33);
+      buf[32] = '\0';
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "At %s:%d buf is %s\n", __FILE__, __LINE__,
                   buf);
-      GNUNET_assert (0 ==
-                     uuid_parse (buf,
-                                 r->ri->dps[j].escrow_uuids[a]));
-
+      GNUNET_STRINGS_string_to_data (buf,
+                                     sizeof(buf),
+                                     &r->ri->dps[j].nonces[a],
+                                     sizeof(struct ANASTASIS_CRYPTO_NonceP));
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "At %s:%d escrow uuid is %s-%llu b\n", __FILE__, __LINE__,
-                  TALER_B2S (&r->ri->dps[j].escrow_uuids[a]),
-                  (unsigned long long) sizeof (r->ri->dps[j].escrow_uuids[a]));
+                  "At %s:%d escrow nonce is %s-%llu b\n", __FILE__, __LINE__,
+                  TALER_B2S (&r->ri->dps[j].nonces[a]),
+                  (unsigned long long) sizeof (r->ri->dps[j].nonces[a]));
     }
 
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -771,7 +777,7 @@ ANASTASIS_recovery_abort (struct ANASTASIS_Recovery *r)
 /* Upload api
 ----------------------------------------------------------------- */
 /**
-* provider_url + UUID
+* provider_url + nonce
 */
 struct ANASTASIS_Truth
 {
@@ -783,7 +789,7 @@ struct ANASTASIS_Truth
   /**
    * identification of the truth
    */
-  uuid_t uuid;
+  struct ANASTASIS_CRYPTO_NonceP nonce;
 
   /**
    * method used for this truth
@@ -980,6 +986,7 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
   struct ANASTASIS_Truth *t;
   // struct SaltState *ss; FIXME unused
   struct ANASTASIS_CRYPTO_EncryptedKeyShareP *encrypted_key_share;
+  struct ANASTASIS_CRYPTO_TruthPublicKeyP pub_key;
   void *encrypted_truth;
   size_t encrypted_truth_size;
   json_t *truth;
@@ -1001,12 +1008,13 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
   t->mime_type = mime_type;
   t->salt = salt;
 
-  uuid_generate (t->uuid);
-  GNUNET_assert (0 == uuid_is_null (t->uuid));
+  GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
+                              &t->nonce,
+                              sizeof (struct ANASTASIS_CRYPTO_NonceP));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "At %s:%d uuid is %s-%llu b\n", __FILE__, __LINE__,
-              TALER_B2S (&t->uuid),
-              (unsigned long long) sizeof (t->uuid));
+              "At %s:%d nonce is %s-%llu b\n", __FILE__, __LINE__,
+              TALER_B2S (&t->nonce),
+              (unsigned long long) sizeof (t->nonce));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d server salt is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (salt),
@@ -1062,9 +1070,12 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
     GNUNET_break (0);
     return tu;
   }
+
+  ANASTASIS_CRYPTO_truth_public_key_derive (&t->nonce,
+                                            &pub_key);
   tu->tso = ANASTASIS_truth_store (tu->ctx,
                                    t->url,
-                                   &t->uuid,
+                                   &pub_key,
                                    truth,
                                    tu->payment_requested,
                                    tu->paid_order_id,
@@ -1131,12 +1142,12 @@ struct ANASTASIS_Policy
   /**
    * set of truths inside this policy
    */
-  uuid_t *uuids;
+  struct ANASTASIS_CRYPTO_NonceP *nonces;
 
   /**
    * length of methods used
    */
-  uint32_t uuids_length;
+  uint32_t nonces_length;
 
   /**
    * array of truths
@@ -1157,7 +1168,7 @@ ANASTASIS_policy_create (const struct ANASTASIS_Truth 
*truths[],
   struct ANASTASIS_Policy *p;
   const struct ANASTASIS_Truth *truth;
   struct ANASTASIS_CRYPTO_KeyShareP key_shares[truths_len];
-  uuid_t uuids[truths_len];
+  struct ANASTASIS_CRYPTO_NonceP nonces[truths_len];
 
   p = GNUNET_new (struct ANASTASIS_Policy);
 
@@ -1178,19 +1189,18 @@ ANASTASIS_policy_create (const struct ANASTASIS_Truth 
*truths[],
     GNUNET_memcpy (&key_shares[i],
                    &truth->key_share,
                    sizeof (struct ANASTASIS_CRYPTO_KeyShareP));
-    // key_shares[i] = truth->key_share;
     GNUNET_assert (NULL != &key_shares[i]);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "At %s:%d keyshare is %s-%llu b\n", __FILE__, __LINE__,
                 TALER_B2S (&key_shares[i]),
                 (unsigned long long) sizeof (key_shares[i]));
-    // uuids[i] = truth->uuid;
-    uuid_copy (uuids[i], truth->uuid);
-    GNUNET_assert (0 == uuid_is_null (uuids[i]));
+    GNUNET_memcpy (&nonces[i],
+                   &truth->nonce,
+                   sizeof(struct ANASTASIS_CRYPTO_NonceP));
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d uuid is %s-%llu b\n", __FILE__, __LINE__,
-                TALER_B2S (&uuids[i]),
-                (unsigned long long) sizeof (uuids[i]));
+                "At %s:%d nocne is %s-%llu b\n", __FILE__, __LINE__,
+                TALER_B2S (&nonces[i]),
+                (unsigned long long) sizeof (nonces[i]));
   }
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
                               &p->salt,
@@ -1210,14 +1220,13 @@ ANASTASIS_policy_create (const struct ANASTASIS_Truth 
*truths[],
   GNUNET_memcpy (p->truths,
                  truths,
                  truths_len * sizeof (struct ANASTASIS_Truth *));
-  p->uuids = GNUNET_malloc (truths_len * sizeof (uuid_t));
-  GNUNET_memcpy (p->uuids,
-                 uuids,
-                 truths_len * sizeof (uuid_t));
-  p->uuids_length = truths_len;
-
-  GNUNET_assert (NULL != p->uuids);
-  GNUNET_assert (p->uuids_length == truths_len);
+  p->nonces = GNUNET_malloc (truths_len * sizeof (struct
+                                                  ANASTASIS_CRYPTO_NonceP));
+  GNUNET_memcpy (p->nonces,
+                 nonces,
+                 truths_len * sizeof (struct ANASTASIS_CRYPTO_NonceP));
+  p->nonces_length = truths_len;
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
               TALER_B2S (p),
@@ -1492,7 +1501,7 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
 
   for (unsigned int i = 0; i < policies_len; i++)
   {
-    len += policies[i]->uuids_length;
+    len += policies[i]->nonces_length;
   }
 
   {
@@ -1505,7 +1514,7 @@ ANASTASIS_get_num_urls (const struct ANASTASIS_Policy 
*policies[],
                   TALER_B2S (policies[l]),
                   (unsigned long long) sizeof (struct ANASTASIS_Policy));
 
-      for (unsigned int j = 0; j < policies[l]->uuids_length; j++)
+      for (unsigned int j = 0; j < policies[l]->nonces_length; j++)
       {
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
@@ -1677,34 +1686,37 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                 TALER_B2S (policies[k]),
                 (unsigned long long) sizeof (struct ANASTASIS_Policy));
 
-    char uuids[36 * policies[k]->uuids_length + 1];
-    for (unsigned int a = 0; a < policies[k]->uuids_length; a++)
+    char nonces[33 * policies[k]->nonces_length + 1];
+    for (unsigned int a = 0; a < policies[k]->nonces_length; a++)
     {
-      char buf[36];
-      uuid_unparse (policies[k]->uuids[a], buf);
-      strncpy (uuids + a * strlen (buf), buf, strlen (buf));
+      char buf[33];
+      GNUNET_STRINGS_data_to_string (&policies[k]->nonces[a],
+                                     sizeof(struct ANASTASIS_CRYPTO_NonceP),
+                                     buf,
+                                     strlen (buf));
+      strncpy (nonces + a * strlen (buf), buf, strlen (buf));
     }
-    uuids[36 * policies[k]->uuids_length] = '\0';
+    nonces[33 * policies[k]->nonces_length] = '\0';
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "At %s:%d uuids are %s b\n", __FILE__, __LINE__,
-                uuids);
+                "At %s:%d nonces are %s b\n", __FILE__, __LINE__,
+                nonces);
     if (0 !=
         json_array_append_new (
           dec_policies,
           json_pack ("{s:o,"   /* encrypted master key */
-                     " s:s,"   /* policy uuids  */
+                     " s:s,"   /* policy nonces  */
                      " s:o,"   /* policy salt  */
-                     " s:i}",  /* policy uuids length */
+                     " s:i}",  /* policy nonces length */
                      "master_key",
                      GNUNET_JSON_from_data_auto (
                        &encrypted_master_keys[k]),
-                     "uuids",
-                     uuids,
+                     "nonces",
+                     nonces,
                      "salt",
                      GNUNET_JSON_from_data_auto (
                        &policies[k]->salt),
-                     "uuids_length",
-                     (int) policies[k]->uuids_length)))
+                     "nonces_length",
+                     (int) policies[k]->nonces_length)))
     {
       GNUNET_break (0);
       json_decref (dec_policies);
@@ -1717,7 +1729,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                 json_dumps (dec_policies, JSON_COMPACT));
 
     // FIXME CHALLENGE
-    for (unsigned int l = 0; l < policies[k]->uuids_length; l++)
+    for (unsigned int l = 0; l < policies[k]->nonces_length; l++)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
@@ -1736,31 +1748,30 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
                   (unsigned long
                    long) sizeof (policies[k]->truths[l]->truth_key));
 
-      char uuid[37];
-      uuid_unparse (policies[k]->truths[l]->uuid, uuid);
-
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "At %s:%d uuid is %s b\n", __FILE__, __LINE__,
-                  uuid);
+                  "At %s:%d nonce is %s-%llu b\n", __FILE__, __LINE__,
+                  TALER_B2S (&policies[k]->truths[l]->nonce),
+                  (unsigned long long) sizeof (policies[k]->truths[l]->nonce));
 
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "At %s:%d server salt is %s-%llu b\n", __FILE__, __LINE__,
                   TALER_B2S (policies[k]->truths[l]->salt),
                   (unsigned long long) sizeof (*policies[k]->truths[l]->salt));
 
-      // FIXME: JUST APPEND UNIQUE UUIDS!!!
+      // FIXME: JUST APPEND UNIQUE NONCES!!!
       // creates a json array for saving
       if (0 !=
           json_array_append_new (
             esc_methods,
-            json_pack ("{s:s," /* truth uuid */
+            json_pack ("{s:o," /* truth nonce */
                        " s:s," /* provider url */
                        " s:s," /* instructions */
                        " s:o," /* truth key */
                        " s:o," /* truth salt */
                        " s:s}", /* escrow method */
-                       "uuid",
-                       &uuid,
+                       "nonce",
+                       GNUNET_JSON_from_data_auto (
+                         &policies[k]->truths[l]->nonce),
                        "url",
                        policies[k]->truths[l]->url,
                        "instructions",
@@ -1820,8 +1831,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
         index_pss++;
       }
     }
-    /* FIXME free uuids and truths
-    GNUNET_free (policy->uuids);
+    /* FIXME free NONCES and truths
     GNUNET_free (policy->truths);
     */
   }
@@ -1893,7 +1903,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
     // ecs[l] = ss->pss[l]->ec;
   }
 
-  // FIXME: clean up PSS, UUIDS, TRUTHS etc. !!!
+  // FIXME: clean up PSS, TRUTHS etc. !!!
   // SETUP SHARE RESULT CALLBACK
   return ss;
 }
diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index 7626987..69a464d 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -516,6 +516,41 @@ ANASTASIS_CRYPTO_keyshare_decrypt (
   }
 }
 
+/**
+ * Generates the eddsa public Key  which is the identfier of the truth object.
+ * The private key is used to sign the upload.
+ * @param nonce is the seed to create and recreate the private key
+ * @param pub_key[out] handle for the generated pub key
+ */
+void
+ANASTASIS_CRYPTO_truth_public_key_derive (
+  const struct ANASTASIS_CRYPTO_NonceP *nonce,
+  struct ANASTASIS_CRYPTO_TruthPublicKeyP *pub_key)
+{
+  struct ANASTASIS_CRYPTO_TruthPrivateKeyP priv_key;
+  /* priv_key = ver_secret */
+  if (GNUNET_YES !=
+      GNUNET_CRYPTO_hkdf (&priv_key.priv,
+                          sizeof (priv_key.priv),
+                          GCRY_MD_SHA512,
+                          GCRY_MD_SHA256,
+                          nonce,
+                          sizeof (struct ANASTASIS_CRYPTO_NonceP),
+                          "ver",
+                          strlen ("ver"),
+                          NULL,
+                          0))
+  {
+    GNUNET_break (0);
+    return;
+  }
+  /* go from ver_secret to proper private key (eddsa_d_to_a() in spec) */
+  priv_key.priv.d[0] = (priv_key.priv.d[0] & 0x7f) | 0x40;
+  priv_key.priv.d[31] &= 0xf8;
+
+  GNUNET_CRYPTO_eddsa_key_get_public (&priv_key.priv,
+                                      &pub_key->pub);
+}
 
 /**
  * Encrypts the truth data which contains the hashed answer or the phone 
number..

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