gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34492 - in gnunet/src: include scalarproduct


From: gnunet
Subject: [GNUnet-SVN] r34492 - in gnunet/src: include scalarproduct
Date: Sun, 7 Dec 2014 02:07:07 +0100

Author: grothoff
Date: 2014-12-07 02:07:07 +0100 (Sun, 07 Dec 2014)
New Revision: 34492

Modified:
   gnunet/src/include/gnunet_scalarproduct_service.h
   gnunet/src/scalarproduct/gnunet-scalarproduct.c
   gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
   gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c
   gnunet/src/scalarproduct/test_scalarproduct.sh
Log:
-more SP fixes and todos

Modified: gnunet/src/include/gnunet_scalarproduct_service.h
===================================================================
--- gnunet/src/include/gnunet_scalarproduct_service.h   2014-12-07 00:54:55 UTC 
(rev 34491)
+++ gnunet/src/include/gnunet_scalarproduct_service.h   2014-12-07 01:07:07 UTC 
(rev 34492)
@@ -87,7 +87,7 @@
   struct GNUNET_HashCode key;
 
   /**
-   * Value to multiply in scalar product.
+   * Value to multiply in scalar product, in NBO.
    */
   int64_t value GNUNET_PACKED;
 };

Modified: gnunet/src/scalarproduct/gnunet-scalarproduct.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-scalarproduct.c     2014-12-07 00:54:55 UTC 
(rev 34491)
+++ gnunet/src/scalarproduct/gnunet-scalarproduct.c     2014-12-07 01:07:07 UTC 
(rev 34492)
@@ -289,9 +289,10 @@
       LOG (GNUNET_ERROR_TYPE_ERROR,
            _("Could not convert `%s' to int64_t.\n"),
            begin);
-      GNUNET_free(elements);
+      GNUNET_free (elements);
       return;
     }
+    element.value = GNUNET_htonll (element.value);
     elements[i] = element;
     begin = end + 1;
   }

Modified: gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c       
2014-12-07 00:54:55 UTC (rev 34491)
+++ gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c       
2014-12-07 01:07:07 UTC (rev 34492)
@@ -148,18 +148,21 @@
   gcry_mpi_t product;
 
   /**
-   * how many elements we were supplied with from the client
+   * How many elements we were supplied with from the client (total
+   * count before intersection).
    */
   uint32_t total;
 
   /**
-   * how many elements actually are used for the scalar product.
-   * Size of the arrays in @e r and @e r_prime.
+   * How many elements actually are used for the scalar product.
+   * Size of the arrays in @e r and @e r_prime.  Sometimes also
+   * reset to 0 and used as a counter!
    */
   uint32_t used_element_count;
 
   /**
-   * already transferred elements (sent/received) for multipart messages, less 
or equal than @e used_element_count for
+   * Already transferred elements from client to us.
+   * Less or equal than @e total.
    */
   uint32_t transferred_element_count;
 
@@ -665,6 +668,11 @@
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received %u additional crypto values from Bob\n",
+              (unsigned int) contained);
+
   payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
   /* Convert each k[][perm] to its MPI_value */
   for (i = 0; i < contained; i++)
@@ -741,6 +749,11 @@
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
   }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received %u crypto values from Bob\n",
+              (unsigned int) contained);
+
   payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
   memcpy (&s->s,
           &payload[0],
@@ -847,6 +860,7 @@
   unsigned int i;
   uint32_t todo_count;
   gcry_mpi_t a;
+  uint32_t off;
 
   s->sorted_elements
     = GNUNET_malloc (GNUNET_CONTAINER_multihashmap_size 
(s->intersected_elements) *
@@ -862,12 +876,15 @@
          s->used_element_count,
          sizeof (struct MpiElement),
          &element_cmp);
-
-  while (s->transferred_element_count < s->used_element_count)
+  off = 0;
+  while (off < s->used_element_count)
   {
-    todo_count = s->used_element_count - s->transferred_element_count;
+    todo_count = s->used_element_count - off;
     if (todo_count > ELEMENT_CAPACITY)
       todo_count = ELEMENT_CAPACITY;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Sending %u crypto values to Bob\n",
+                (unsigned int) todo_count);
 
     e = GNUNET_MQ_msg_extra (msg,
                              todo_count * sizeof (struct 
GNUNET_CRYPTO_PaillierCiphertext),
@@ -875,7 +892,7 @@
     msg->contained_element_count = htonl (todo_count);
     payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
     a = gcry_mpi_new (0);
-    for (i = s->transferred_element_count; i < todo_count; i++)
+    for (i = off; i < todo_count; i++)
     {
       gcry_mpi_add (a,
                     s->sorted_elements[i].value,
@@ -883,10 +900,10 @@
       GNUNET_CRYPTO_paillier_encrypt (&my_pubkey,
                                       a,
                                       3,
-                                      &payload[i - 
s->transferred_element_count]);
+                                      &payload[i - off]);
     }
     gcry_mpi_release (a);
-    s->transferred_element_count += todo_count;
+    off += todo_count;
     GNUNET_MQ_send (s->cadet_mq,
                     e);
   }

Modified: gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c 2014-12-07 
00:54:55 UTC (rev 34491)
+++ gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c 2014-12-07 
01:07:07 UTC (rev 34492)
@@ -156,7 +156,10 @@
   uint32_t used_element_count;
 
   /**
-   * already transferred elements (sent/received) for multipart messages, less 
or equal than @e used_element_count for
+   * Already transferred elements (sent/received) for multipart
+   * messages.  First used to count values received from client (less
+   * than @e total), then used to count values transmitted from Alice
+   * (less than @e used_element_count)!  FIXME: maybe separate this.
    */
   uint32_t transferred_element_count;
 
@@ -530,6 +533,9 @@
     if (todo_count > ELEMENT_CAPACITY / 2)
       todo_count = ELEMENT_CAPACITY / 2;
 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Sending %u additional crypto values to Alice\n",
+                (unsigned int) todo_count);
     e = GNUNET_MQ_msg_extra (msg,
                              todo_count * sizeof (struct 
GNUNET_CRYPTO_PaillierCiphertext) * 2,
                              
GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART);
@@ -584,11 +590,17 @@
                            (2 + s->transferred_element_count * 2)
                            * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext),
                            GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA);
-  msg->total_element_count = htonl (s->total);
-  msg->used_element_count = htonl (s->used_element_count);
+  // FIXME: 'total' maybe confusing here, and should already be known to Alice
+  msg->total_element_count = htonl (s->used_element_count);
+  // FIXME: redundant!
+  msg->used_element_count = htonl (s->transferred_element_count);
   msg->contained_element_count = htonl (s->transferred_element_count);
   msg->key = s->session_id;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Sending %u crypto values to Alice\n",
+              (unsigned int) s->transferred_element_count);
+
   payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
   memcpy (&payload[0],
           &s->s,
@@ -834,6 +846,8 @@
 transmit_cryptographic_reply (struct BobServiceSession *s)
 {
   /* TODO: code duplication with Alice! */
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Received everything, building reply for Alice\n");
   s->sorted_elements
     = GNUNET_malloc (GNUNET_CONTAINER_multihashmap_size 
(s->intersected_elements) *
                      sizeof (struct MpiElement));
@@ -841,9 +855,6 @@
   GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
                                          &copy_element_cb,
                                          s);
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Finished intersection, %d items remain\n",
-       s->used_element_count);
   qsort (s->sorted_elements,
          s->used_element_count,
          sizeof (struct MpiElement),
@@ -911,6 +922,9 @@
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
   }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received %u crypto values from Alice\n",
+              (unsigned int) contained_elements);
 
   payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
   if (NULL == s->e_a)
@@ -969,6 +983,9 @@
   case GNUNET_SET_STATUS_DONE:
     s->intersection_op = NULL;
     s->intersection_set = NULL;
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Finished intersection, %d items remain\n",
+         GNUNET_CONTAINER_multihashmap_size (s->intersected_elements));
     if (s->transferred_element_count ==
         GNUNET_CONTAINER_multihashmap_size (s->intersected_elements))
     {
@@ -1007,8 +1024,9 @@
 start_intersection (struct BobServiceSession *s)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Got session with key %s and a matching element set, 
processing.\n",
-              GNUNET_h2s (&s->session_id));
+              "Got session with key %s and %u elements, starting 
intersection.\n",
+              GNUNET_h2s (&s->session_id),
+              (unsigned int) s->transferred_element_count);
 
   s->intersection_op
     = GNUNET_SET_prepare (&s->cadet->peer,

Modified: gnunet/src/scalarproduct/test_scalarproduct.sh
===================================================================
--- gnunet/src/scalarproduct/test_scalarproduct.sh      2014-12-07 00:54:55 UTC 
(rev 34491)
+++ gnunet/src/scalarproduct/test_scalarproduct.sh      2014-12-07 01:07:07 UTC 
(rev 34492)
@@ -17,7 +17,7 @@
 # interactive mode would terminate the test immediately
 # because the rest of the script is already in stdin,
 # thus redirecting stdin does not suffice)
-GNUNET_LOG='scalarproduct*;;;;DEBUG'
+GNUNET_FORCE_LOG='scalarproduct*;;;;DEBUG'
 GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c 
test_scalarproduct.conf -p 2 &
 PID=$!
 # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe




reply via email to

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