[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34498 - gnunet/src/scalarproduct
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34498 - gnunet/src/scalarproduct |
Date: |
Sun, 7 Dec 2014 22:50:13 +0100 |
Author: grothoff
Date: 2014-12-07 22:50:13 +0100 (Sun, 07 Dec 2014)
New Revision: 34498
Modified:
gnunet/src/scalarproduct/gnunet-service-scalarproduct.h
gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c
Log:
-fix FIXMEs
Modified: gnunet/src/scalarproduct/gnunet-service-scalarproduct.h
===================================================================
--- gnunet/src/scalarproduct/gnunet-service-scalarproduct.h 2014-12-07
21:30:34 UTC (rev 34497)
+++ gnunet/src/scalarproduct/gnunet-service-scalarproduct.h 2014-12-07
21:50:13 UTC (rev 34498)
@@ -101,15 +101,14 @@
struct GNUNET_MessageHeader header;
/**
- * How many elements the session input had (in NBO).
+ * For alignment, always zero.
*/
- uint32_t total_element_count GNUNET_PACKED;
+ uint32_t reserved GNUNET_PACKED;
/**
- * How many elements were included after the mask was applied
- * including all multipart msgs (in NBO).
+ * How many elements the Bob has in the intersection (in NBO).
*/
- uint32_t used_element_count GNUNET_PACKED;
+ uint32_t intersection_element_count GNUNET_PACKED;
/**
* How many elements this individual message delivers (in NBO).
Modified: gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
2014-12-07 21:30:34 UTC (rev 34497)
+++ gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
2014-12-07 21:50:13 UTC (rev 34498)
@@ -731,6 +731,13 @@
return GNUNET_SYSERR;
}
msg = (const struct ServiceResponseMessage *) message;
+ GNUNET_break_op (0 == ntohl (msg->reserved));
+ if (s->used_element_count != ntohl (msg->intersection_element_count))
+ {
+ /* Alice and Bob disagree on intersection set size, bad news! */
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
contained = ntohl (msg->contained_element_count);
required_size = sizeof (struct ServiceResponseMessage)
+ 2 * contained * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)
Modified: gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c 2014-12-07
21:30:34 UTC (rev 34497)
+++ gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c 2014-12-07
21:50:13 UTC (rev 34498)
@@ -145,25 +145,36 @@
gcry_mpi_t product;
/**
- * How many elements we were supplied with from the client
+ * How many elements will be supplied in total from the client.
*/
uint32_t total;
/**
- * how many elements actually are used for the scalar product.
- * Size of the arrays in @e r and @e r_prime.
+ * Already transferred elements (received) for multipart
+ * messages from client. Always less than @e total.
*/
+ uint32_t client_received_element_count;
+
+ /**
+ * How many elements actually are used for the scalar product.
+ * Size of the arrays in @e r and @e r_prime. Also sometimes
+ * used as an index into the arrays during construction.
+ */
uint32_t used_element_count;
/**
- * 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.
+ * Counts the number of values received from Alice by us.
+ * Always less than @e used_element_count.
*/
- uint32_t transferred_element_count;
+ uint32_t cadet_received_element_count;
/**
+ * Counts the number of values transmitted from us to Alice.
+ * Always less than @e used_element_count.
+ */
+ uint32_t cadet_transmitted_element_count;
+
+ /**
* Is this session active (#GNUNET_YES), Concluded (#GNUNET_NO), or had an
error (#GNUNET_SYSERR)
*/
int32_t active;
@@ -262,14 +273,8 @@
*/
static struct GNUNET_CADET_Handle *my_cadet;
-/**
- * Certain events (callbacks for server & cadet operations) must not
- * be queued after shutdown.
- */
-static int do_shutdown;
-
/**
* Finds a not terminated client session in the respective map based on
* session key.
@@ -527,9 +532,9 @@
unsigned int j;
uint32_t todo_count;
- while (s->transferred_element_count != s->used_element_count)
+ while (s->cadet_transmitted_element_count != s->used_element_count)
{
- todo_count = s->used_element_count - s->transferred_element_count;
+ todo_count = s->used_element_count - s->cadet_transmitted_element_count;
if (todo_count > ELEMENT_CAPACITY / 2)
todo_count = ELEMENT_CAPACITY / 2;
@@ -541,7 +546,7 @@
GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART);
msg->contained_element_count = htonl (todo_count);
payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
- for (i = s->transferred_element_count, j = 0; i <
s->transferred_element_count + todo_count; i++)
+ for (i = s->cadet_transmitted_element_count, j = 0; i <
s->cadet_transmitted_element_count + todo_count; i++)
{
//r[i][p] and r[i][q]
memcpy (&payload[j++],
@@ -551,8 +556,8 @@
&s->r_prime[i],
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
}
- s->transferred_element_count += todo_count;
- if (s->transferred_element_count == s->used_element_count)
+ s->cadet_transmitted_element_count += todo_count;
+ if (s->cadet_transmitted_element_count == s->used_element_count)
GNUNET_MQ_notify_sent (e,
&bob_cadet_done_cb,
s);
@@ -581,25 +586,24 @@
struct GNUNET_CRYPTO_PaillierCiphertext *payload;
unsigned int i;
- s->transferred_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof
(struct ServiceResponseMessage)) /
+ s->cadet_transmitted_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 -
sizeof (struct ServiceResponseMessage)) /
(sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * 2) - 2;
- if (s->transferred_element_count > s->used_element_count)
- s->transferred_element_count = s->used_element_count;
+ if (s->cadet_transmitted_element_count > s->used_element_count)
+ s->cadet_transmitted_element_count = s->used_element_count;
e = GNUNET_MQ_msg_extra (msg,
- (2 + s->transferred_element_count * 2)
+ (2 + s->cadet_transmitted_element_count * 2)
* sizeof (struct GNUNET_CRYPTO_PaillierCiphertext),
GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA);
- // 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->reserved = htonl (0);
+ msg->intersection_element_count = htonl (s->used_element_count);
+ msg->contained_element_count = htonl (s->cadet_transmitted_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);
+ "Sending %u/%u crypto values to Alice\n",
+ (unsigned int) s->cadet_transmitted_element_count,
+ (unsigned int) s->used_element_count);
payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
memcpy (&payload[0],
@@ -611,7 +615,7 @@
payload = &payload[2];
// convert k[][]
- for (i = 0; i < s->transferred_element_count; i++)
+ for (i = 0; i < s->cadet_transmitted_element_count; i++)
{
//k[i][p] and k[i][q]
memcpy (&payload[i * 2],
@@ -621,7 +625,7 @@
&s->r_prime[i],
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
}
- if (s->transferred_element_count == s->used_element_count)
+ if (s->cadet_transmitted_element_count == s->used_element_count)
GNUNET_MQ_notify_sent (e,
&bob_cadet_done_cb,
s);
@@ -917,7 +921,7 @@
if ( (msize != msg_length) ||
(0 == contained_elements) ||
(contained_elements > UINT16_MAX) ||
- (max < contained_elements + s->transferred_element_count) )
+ (max < contained_elements + s->cadet_received_element_count) )
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -930,12 +934,12 @@
if (NULL == s->e_a)
s->e_a = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) *
max);
- memcpy (&s->e_a[s->transferred_element_count],
+ memcpy (&s->e_a[s->cadet_received_element_count],
payload,
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) *
contained_elements);
- s->transferred_element_count += contained_elements;
+ s->cadet_received_element_count += contained_elements;
- if ( (s->transferred_element_count == max) &&
+ if ( (s->cadet_received_element_count == max) &&
(NULL == s->intersection_op) )
{
/* intersection has finished also on our side, and
@@ -986,7 +990,7 @@
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Finished intersection, %d items remain\n",
GNUNET_CONTAINER_multihashmap_size (s->intersected_elements));
- if (s->transferred_element_count ==
+ if (s->client_received_element_count ==
GNUNET_CONTAINER_multihashmap_size (s->intersected_elements))
{
/* CADET transmission from Alice is also already done,
@@ -1026,7 +1030,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got session with key %s and %u elements, starting
intersection.\n",
GNUNET_h2s (&s->session_id),
- (unsigned int) s->transferred_element_count);
+ (unsigned int) s->total);
s->intersection_op
= GNUNET_SET_prepare (&s->cadet->peer,
@@ -1094,7 +1098,7 @@
/* pair them up */
in->s = s;
s->cadet = in;
- if (s->transferred_element_count == s->total)
+ if (s->client_received_element_count == s->total)
start_intersection (s);
return GNUNET_OK;
}
@@ -1178,8 +1182,8 @@
contained_count * sizeof (struct
GNUNET_SCALARPRODUCT_Element))) ||
(0 == contained_count) ||
(UINT16_MAX < contained_count) ||
- (s->total == s->transferred_element_count) ||
- (s->total < s->transferred_element_count + contained_count) )
+ (s->total == s->client_received_element_count) ||
+ (s->total < s->client_received_element_count + contained_count) )
{
GNUNET_break_op (0);
GNUNET_SERVER_receive_done (client,
@@ -1212,10 +1216,10 @@
&set_elem,
NULL, NULL);
}
- s->transferred_element_count += contained_count;
+ s->client_received_element_count += contained_count;
GNUNET_SERVER_receive_done (client,
GNUNET_OK);
- if (s->total != s->transferred_element_count)
+ if (s->total != s->client_received_element_count)
{
/* more to come */
return;
@@ -1300,7 +1304,7 @@
s->client = client;
s->client_mq = GNUNET_MQ_queue_for_server_client (client);
s->total = total_count;
- s->transferred_element_count = contained_count;
+ s->client_received_element_count = contained_count;
s->session_id = msg->session_key;
GNUNET_break (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (client_sessions,
@@ -1342,7 +1346,7 @@
s);
GNUNET_SERVER_receive_done (client,
GNUNET_YES);
- if (s->total != s->transferred_element_count)
+ if (s->total != s->client_received_element_count)
{
/* multipart msg */
return;
@@ -1373,8 +1377,7 @@
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Shutting down, initiating cleanup.\n");
- do_shutdown = GNUNET_YES;
- // FIXME: is there a need to shutdown active sessions?
+ // FIXME: do we have to cut our connections to CADET first?
if (NULL != my_cadet)
{
GNUNET_CADET_disconnect (my_cadet);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34498 - gnunet/src/scalarproduct,
gnunet <=