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;
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++)
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],
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) *
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),
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,
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);
}
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;
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);
(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,
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));
GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
©_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),
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)
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))
{
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,