gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: implemented truth store


From: gnunet
Subject: [taler-anastasis] branch master updated: implemented truth store
Date: Fri, 17 Jan 2020 13:59:47 +0100

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 d235037  implemented truth store
d235037 is described below

commit d235037eef5f7b037bb07f9136b4a66872a6fe95
Author: Dominik Meister <address@hidden>
AuthorDate: Fri Jan 17 13:59:30 2020 +0100

    implemented truth store
---
 src/include/anastasis_service.h     |   4 +-
 src/lib/anastasis_api_truth_store.c | 112 +++++++-----------------------------
 2 files changed, 24 insertions(+), 92 deletions(-)

diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 8460544..4a27cbf 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -436,8 +436,8 @@ ANASTASIS_truth_lookup (struct GNUNET_CURL_Context *ctx,
  * @param tlo cancel the truth lookup operation
  */
 void
-ANASTASIS_policy_lookup_cancel (struct
-                                ANASTASIS_TruthLookupOperation *tlo);
+ANASTASIS_truth_lookup_cancel (struct
+                               ANASTASIS_TruthLookupOperation *tlo);
 
 /**
  * Handle for a POST /truth operation.
diff --git a/src/lib/anastasis_api_truth_store.c 
b/src/lib/anastasis_api_truth_store.c
index f887377..8dee103 100644
--- a/src/lib/anastasis_api_truth_store.c
+++ b/src/lib/anastasis_api_truth_store.c
@@ -65,11 +65,6 @@ struct ANASTASIS_TruthStoreOperation
    */
   void *cb_cls;
 
-  /**
-   * Payment URI we received from the service, or NULL.
-   */
-  char *pay_uri;
-
   /**
    * Hash of the data we are uploading.
    */
@@ -90,12 +85,10 @@ ANASTASIS_truth_store_cancel (struct
     GNUNET_CURL_job_cancel (tso->job);
     tso->job = NULL;
   }
-  GNUNET_free_non_null (tso->pay_uri);
   GNUNET_free (tso->url);
   GNUNET_free (tso);
 }
 
-
 /**
  * Callback to process POST /truth response
  *
@@ -241,17 +234,13 @@ handle_header (char *buffer,
 
 
 /**
- * Store policies, does a POST /truth/$AccountPub
+ * Store Truth, does a POST /policy/$UUID
  *
  * @param ctx the CURL context used to connect to the backend
  * @param backend_url backend's base URL, including final "/"
- * @param anastasis_pub public key of the user's account
- * @param anastasis_priv private key of the user's account
- * @param prev_truth_data_hash hash of the previous uploaded truth document
- * @param truth_data truth data to be stored
- * @param truth_data_size number of bytes in @a truth_data
- * @param payment_requested #GNUNET_YES if the client wants to pay more for 
the account now
- * @param paymentSecretP payment identifier of last payment
+ * @param truth_uuid Identfication of the Truth Upload
+ * @param prev_truth_data_hash hash of the previous truth upload, NULL for the 
first upload ever
+ * @param truth_data contains the data which is stored on the Server in JSON 
Format
  * @param cb callback processing the response from /truth
  * @param cb_cls closure for cb
  * @return handle for the operation
@@ -260,39 +249,19 @@ struct ANASTASIS_TruthStoreOperation *
 ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
                        const char *backend_url,
                        const struct
-                       ANASTASIS_AccountPrivP *anastasis_priv,
+                       ANASTASIS_UuidP *truth_uuid,
                        const struct
                        GNUNET_HashCode *prev_truth_data_hash,
-                       const void *truth_data,
-                       size_t truth_data_size,
-                       int payment_requested,
-                       const struct
-                       ANASTASIS_PaymentSecretP *paymentSecretP,
+                       json_t *truth_data,
                        ANASTASIS_TruthStoreCallback cb,
                        void *cb_cls)
 {
   struct ANASTASIS_TruthStoreOperation *tso;
-  struct ANASTASIS_AccountSignatureP account_sig;
-  struct ANASTASIS_UploadSignaturePS usp;
   CURL *eh;
   struct curl_slist *job_headers;
+  struct GNUNET_HashCode old_truth_data_hash;
+  struct GNUNET_HashCode new_truth_data_hash;
 
-  memset (&usp, 0, sizeof (usp));
-  usp.purpose.purpose = htonl (TALER_SIGNATURE_ANASTASIS_TRUTH_UPLOAD);
-  usp.purpose.size = htonl (sizeof (usp));
-  if (NULL != prev_truth_data_hash)
-    usp.old_truth_data_hash = *prev_truth_data_hash;
-  GNUNET_CRYPTO_hash (truth_data,
-                      truth_data_size,
-                      &usp.new_truth_data_hash);
-  if (GNUNET_OK !=
-      GNUNET_CRYPTO_eddsa_sign (&anastasis_priv->priv,
-                                &usp.purpose,
-                                &account_sig.eddsa_sig))
-  {
-    GNUNET_break (0);
-    return NULL;
-  }
   /* setup our HTTP headers */
   job_headers = NULL;
   {
@@ -300,26 +269,14 @@ ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
     char *val;
     char *hdr;
 
-    /* Set Anastasis-Policy-Signature header */
-    val = GNUNET_STRINGS_data_to_string_alloc (&account_sig,
-                                               sizeof (account_sig));
-    GNUNET_asprintf (&hdr,
-                     "Anastasis-Truth-Signature: %s",
-                     val);
-    GNUNET_free (val);
-    ext = curl_slist_append (job_headers,
-                             hdr);
-    GNUNET_free (hdr);
-    if (NULL == ext)
-    {
-      GNUNET_break (0);
-      curl_slist_free_all (job_headers);
-      return NULL;
-    }
-    job_headers = ext;
+    if (NULL != prev_truth_data_hash)
+        old_truth_data_hash = *prev_truth_data_hash;
+    GNUNET_CRYPTO_hash (truth_data,
+                        sizeof(truth_data),
+                        &new_truth_data_hash);
 
     /* set Etag header */
-    val = GNUNET_STRINGS_data_to_string_alloc (&usp.new_truth_data_hash,
+    val = GNUNET_STRINGS_data_to_string_alloc (&new_truth_data_hash,
                                                sizeof (struct 
GNUNET_HashCode));
     GNUNET_asprintf (&hdr,
                      "Etag: %s",
@@ -339,7 +296,7 @@ ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
     /* Setup If-Match header */
     if (NULL != prev_truth_data_hash)
     {
-      val = GNUNET_STRINGS_data_to_string_alloc (&usp.old_truth_data_hash,
+      val = GNUNET_STRINGS_data_to_string_alloc (&old_truth_data_hash,
                                                  sizeof (struct
                                                          GNUNET_HashCode));
       GNUNET_asprintf (&hdr,
@@ -357,46 +314,21 @@ ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
       }
       job_headers = ext;
     }
-
-    /* Setup Payment-Identifier header */
-    if (NULL != paymentSecretP)
-    {
-      val = GNUNET_STRINGS_data_to_string_alloc (&paymentSecretP,
-                                                 sizeof (paymentSecretP));
-      GNUNET_asprintf (&hdr,
-                       "Payment-Identifier: %s",
-                       val);
-      GNUNET_free (val);
-      ext = curl_slist_append (job_headers,
-                               hdr);
-      GNUNET_free (hdr);
-      if (NULL == ext)
-      {
-        GNUNET_break (0);
-        curl_slist_free_all (job_headers);
-        return NULL;
-      }
-      job_headers = ext;
-    }
   }
   /* Finished setting up headers */
 
   tso = GNUNET_new (struct ANASTASIS_TruthStoreOperation);
-  tso->new_truth_data_hash = usp.new_truth_data_hash;
+  tso->new_truth_data_hash = new_truth_data_hash;
   {
-    char *acc_pub_str;
+    char *uuid_str;
     char *path;
-    struct ANASTASIS_AccountPubP pub;
-
-    GNUNET_CRYPTO_eddsa_key_get_public (&anastasis_priv->priv,
-                                        &pub.pub);
 
-    acc_pub_str = GNUNET_STRINGS_data_to_string_alloc (&pub,
-                                                       sizeof (pub));
+    uuid_str = GNUNET_STRINGS_data_to_string_alloc (&truth_uuid,
+                                                    sizeof (truth_uuid));
     GNUNET_asprintf (&path,
                      "truth/%s",
-                     acc_pub_str);
-    GNUNET_free (acc_pub_str);
+                     uuid_str);
+    GNUNET_free (uuid_str);
     tso->url = TALER_url_join (backend_url,
                                path);
     GNUNET_free (path);
@@ -412,7 +344,7 @@ ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_POSTFIELDSIZE,
-                                   (long) truth_data_size));
+                                   sizeof(truth_data)));
   GNUNET_assert (CURLE_OK ==
                  curl_easy_setopt (eh,
                                    CURLOPT_HEADERFUNCTION,

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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