summaryrefslogtreecommitdiff
path: root/src/scalarproduct/gnunet-service-scalarproduct_bob.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scalarproduct/gnunet-service-scalarproduct_bob.c')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_bob.c1140
1 files changed, 570 insertions, 570 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_bob.c b/src/scalarproduct/gnunet-service-scalarproduct_bob.c
index 0b95f3a00..f787cdd2e 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct_bob.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct_bob.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -36,14 +36,13 @@
36#include "scalarproduct.h" 36#include "scalarproduct.h"
37#include "gnunet-service-scalarproduct.h" 37#include "gnunet-service-scalarproduct.h"
38 38
39#define LOG(kind,...) GNUNET_log_from (kind, "scalarproduct-bob", __VA_ARGS__) 39#define LOG(kind, ...) GNUNET_log_from(kind, "scalarproduct-bob", __VA_ARGS__)
40 40
41 41
42/** 42/**
43 * An encrypted element key-value pair. 43 * An encrypted element key-value pair.
44 */ 44 */
45struct MpiElement 45struct MpiElement {
46{
47 /** 46 /**
48 * Key used to identify matching pairs of values to multiply. 47 * Key used to identify matching pairs of values to multiply.
49 * Points into an existing data structure, to avoid copying 48 * Points into an existing data structure, to avoid copying
@@ -62,9 +61,7 @@ struct MpiElement
62 * A scalarproduct session which tracks an offer for a 61 * A scalarproduct session which tracks an offer for a
63 * multiplication service by a local client. 62 * multiplication service by a local client.
64 */ 63 */
65struct BobServiceSession 64struct BobServiceSession {
66{
67
68 /** 65 /**
69 * (hopefully) unique transaction ID 66 * (hopefully) unique transaction ID
70 */ 67 */
@@ -200,7 +197,6 @@ struct BobServiceSession
200 * The message queue for this channel. 197 * The message queue for this channel.
201 */ 198 */
202 struct GNUNET_MQ_Handle *cadet_mq; 199 struct GNUNET_MQ_Handle *cadet_mq;
203
204}; 200};
205 201
206 202
@@ -239,13 +235,13 @@ static struct GNUNET_CADET_Handle *my_cadet;
239 * @param value the value to free 235 * @param value the value to free
240 */ 236 */
241static int 237static int
242free_element_cb (void *cls, 238free_element_cb(void *cls,
243 const struct GNUNET_HashCode *key, 239 const struct GNUNET_HashCode *key,
244 void *value) 240 void *value)
245{ 241{
246 struct GNUNET_SCALARPRODUCT_Element *element = value; 242 struct GNUNET_SCALARPRODUCT_Element *element = value;
247 243
248 GNUNET_free (element); 244 GNUNET_free(element);
249 return GNUNET_OK; 245 return GNUNET_OK;
250} 246}
251 247
@@ -256,7 +252,7 @@ free_element_cb (void *cls,
256 * @param session the session to free elements from 252 * @param session the session to free elements from
257 */ 253 */
258static void 254static void
259destroy_service_session (struct BobServiceSession *s) 255destroy_service_session(struct BobServiceSession *s)
260{ 256{
261 unsigned int i; 257 unsigned int i;
262 258
@@ -264,63 +260,63 @@ destroy_service_session (struct BobServiceSession *s)
264 return; 260 return;
265 s->in_destroy = GNUNET_YES; 261 s->in_destroy = GNUNET_YES;
266 if (NULL != s->client) 262 if (NULL != s->client)
267 { 263 {
268 struct GNUNET_SERVICE_Client *c = s->client; 264 struct GNUNET_SERVICE_Client *c = s->client;
269 265
270 s->client = NULL; 266 s->client = NULL;
271 GNUNET_SERVICE_client_drop (c); 267 GNUNET_SERVICE_client_drop(c);
272 } 268 }
273 if (NULL != s->intersected_elements) 269 if (NULL != s->intersected_elements)
274 { 270 {
275 GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements, 271 GNUNET_CONTAINER_multihashmap_iterate(s->intersected_elements,
276 &free_element_cb, 272 &free_element_cb,
277 NULL); 273 NULL);
278 GNUNET_CONTAINER_multihashmap_destroy (s->intersected_elements); 274 GNUNET_CONTAINER_multihashmap_destroy(s->intersected_elements);
279 s->intersected_elements = NULL; 275 s->intersected_elements = NULL;
280 } 276 }
281 if (NULL != s->intersection_op) 277 if (NULL != s->intersection_op)
282 { 278 {
283 GNUNET_SET_operation_cancel (s->intersection_op); 279 GNUNET_SET_operation_cancel(s->intersection_op);
284 s->intersection_op = NULL; 280 s->intersection_op = NULL;
285 } 281 }
286 if (NULL != s->intersection_set) 282 if (NULL != s->intersection_set)
287 { 283 {
288 GNUNET_SET_destroy (s->intersection_set); 284 GNUNET_SET_destroy(s->intersection_set);
289 s->intersection_set = NULL; 285 s->intersection_set = NULL;
290 } 286 }
291 if (NULL != s->e_a) 287 if (NULL != s->e_a)
292 { 288 {
293 GNUNET_free (s->e_a); 289 GNUNET_free(s->e_a);
294 s->e_a = NULL; 290 s->e_a = NULL;
295 } 291 }
296 if (NULL != s->sorted_elements) 292 if (NULL != s->sorted_elements)
297 { 293 {
298 for (i=0;i<s->used_element_count;i++) 294 for (i = 0; i < s->used_element_count; i++)
299 gcry_mpi_release (s->sorted_elements[i].value); 295 gcry_mpi_release(s->sorted_elements[i].value);
300 GNUNET_free (s->sorted_elements); 296 GNUNET_free(s->sorted_elements);
301 s->sorted_elements = NULL; 297 s->sorted_elements = NULL;
302 } 298 }
303 if (NULL != s->r) 299 if (NULL != s->r)
304 { 300 {
305 GNUNET_free (s->r); 301 GNUNET_free(s->r);
306 s->r = NULL; 302 s->r = NULL;
307 } 303 }
308 if (NULL != s->r_prime) 304 if (NULL != s->r_prime)
309 { 305 {
310 GNUNET_free (s->r_prime); 306 GNUNET_free(s->r_prime);
311 s->r_prime = NULL; 307 s->r_prime = NULL;
312 } 308 }
313 if (NULL != s->port) 309 if (NULL != s->port)
314 { 310 {
315 GNUNET_CADET_close_port (s->port); 311 GNUNET_CADET_close_port(s->port);
316 s->port = NULL; 312 s->port = NULL;
317 } 313 }
318 if (NULL != s->channel) 314 if (NULL != s->channel)
319 { 315 {
320 GNUNET_CADET_channel_destroy (s->channel); 316 GNUNET_CADET_channel_destroy(s->channel);
321 s->channel = NULL; 317 s->channel = NULL;
322 } 318 }
323 GNUNET_free (s); 319 GNUNET_free(s);
324} 320}
325 321
326 322
@@ -332,24 +328,24 @@ destroy_service_session (struct BobServiceSession *s)
332 * @param session the associated client session to fail or succeed 328 * @param session the associated client session to fail or succeed
333 */ 329 */
334static void 330static void
335prepare_client_end_notification (struct BobServiceSession *session) 331prepare_client_end_notification(struct BobServiceSession *session)
336{ 332{
337 struct ClientResponseMessage *msg; 333 struct ClientResponseMessage *msg;
338 struct GNUNET_MQ_Envelope *e; 334 struct GNUNET_MQ_Envelope *e;
339 335
340 if (NULL == session->client_mq) 336 if (NULL == session->client_mq)
341 return; /* no client left to be notified */ 337 return; /* no client left to be notified */
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 338 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
343 "Sending session-end notification with status %d to client for session %s\n", 339 "Sending session-end notification with status %d to client for session %s\n",
344 session->status, 340 session->status,
345 GNUNET_h2s (&session->session_id)); 341 GNUNET_h2s(&session->session_id));
346 e = GNUNET_MQ_msg (msg, 342 e = GNUNET_MQ_msg(msg,
347 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT); 343 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT);
348 msg->range = 0; 344 msg->range = 0;
349 msg->product_length = htonl (0); 345 msg->product_length = htonl(0);
350 msg->status = htonl (session->status); 346 msg->status = htonl(session->status);
351 GNUNET_MQ_send (session->client_mq, 347 GNUNET_MQ_send(session->client_mq,
352 e); 348 e);
353} 349}
354 350
355 351
@@ -363,22 +359,22 @@ prepare_client_end_notification (struct BobServiceSession *session)
363 * @param channel connection to the other end (henceforth invalid) 359 * @param channel connection to the other end (henceforth invalid)
364 */ 360 */
365static void 361static void
366cb_channel_destruction (void *cls, 362cb_channel_destruction(void *cls,
367 const struct GNUNET_CADET_Channel *channel) 363 const struct GNUNET_CADET_Channel *channel)
368{ 364{
369 struct BobServiceSession *s = cls; 365 struct BobServiceSession *s = cls;
370 366
371 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 367 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
372 "Peer disconnected, terminating session %s with peer %s\n", 368 "Peer disconnected, terminating session %s with peer %s\n",
373 GNUNET_h2s (&s->session_id), 369 GNUNET_h2s(&s->session_id),
374 GNUNET_i2s (&s->peer)); 370 GNUNET_i2s(&s->peer));
375 if (GNUNET_SCALARPRODUCT_STATUS_ACTIVE == s->status) 371 if (GNUNET_SCALARPRODUCT_STATUS_ACTIVE == s->status)
376 { 372 {
377 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; 373 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
378 prepare_client_end_notification (s); 374 prepare_client_end_notification(s);
379 } 375 }
380 s->channel = NULL; 376 s->channel = NULL;
381 destroy_service_session (s); 377 destroy_service_session(s);
382} 378}
383 379
384 380
@@ -387,19 +383,19 @@ cb_channel_destruction (void *cls,
387 * the client that we are finished. 383 * the client that we are finished.
388 */ 384 */
389static void 385static void
390bob_cadet_done_cb (void *cls) 386bob_cadet_done_cb(void *cls)
391{ 387{
392 struct BobServiceSession *session = cls; 388 struct BobServiceSession *session = cls;
393 389
394 session->status = GNUNET_SCALARPRODUCT_STATUS_SUCCESS; 390 session->status = GNUNET_SCALARPRODUCT_STATUS_SUCCESS;
395 prepare_client_end_notification (session); 391 prepare_client_end_notification(session);
396} 392}
397 393
398 394
399/** 395/**
400 * Maximum count of elements we can put into a multipart message 396 * Maximum count of elements we can put into a multipart message
401 */ 397 */
402#define ELEMENT_CAPACITY ((GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE - 1 - sizeof (struct BobCryptodataMultipartMessage)) / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)) 398#define ELEMENT_CAPACITY ((GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE - 1 - sizeof(struct BobCryptodataMultipartMessage)) / sizeof(struct GNUNET_CRYPTO_PaillierCiphertext))
403 399
404 400
405/** 401/**
@@ -409,7 +405,7 @@ bob_cadet_done_cb (void *cls)
409 * @param s the associated service session 405 * @param s the associated service session
410 */ 406 */
411static void 407static void
412transmit_bobs_cryptodata_message_multipart (struct BobServiceSession *s) 408transmit_bobs_cryptodata_message_multipart(struct BobServiceSession *s)
413{ 409{
414 struct GNUNET_CRYPTO_PaillierCiphertext *payload; 410 struct GNUNET_CRYPTO_PaillierCiphertext *payload;
415 struct BobCryptodataMultipartMessage *msg; 411 struct BobCryptodataMultipartMessage *msg;
@@ -419,39 +415,39 @@ transmit_bobs_cryptodata_message_multipart (struct BobServiceSession *s)
419 uint32_t todo_count; 415 uint32_t todo_count;
420 416
421 while (s->cadet_transmitted_element_count != s->used_element_count) 417 while (s->cadet_transmitted_element_count != s->used_element_count)
422 {
423 todo_count = s->used_element_count - s->cadet_transmitted_element_count;
424 if (todo_count > ELEMENT_CAPACITY / 2)
425 todo_count = ELEMENT_CAPACITY / 2;
426
427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
428 "Sending %u additional crypto values to Alice\n",
429 (unsigned int) todo_count);
430 e = GNUNET_MQ_msg_extra (msg,
431 todo_count * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * 2,
432 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART);
433 msg->contained_element_count = htonl (todo_count);
434 payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
435 for (i = s->cadet_transmitted_element_count, j = 0; i < s->cadet_transmitted_element_count + todo_count; i++)
436 { 418 {
437 //r[i][p] and r[i][q] 419 todo_count = s->used_element_count - s->cadet_transmitted_element_count;
438 GNUNET_memcpy (&payload[j++], 420 if (todo_count > ELEMENT_CAPACITY / 2)
439 &s->r[i], 421 todo_count = ELEMENT_CAPACITY / 2;
440 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); 422
441 GNUNET_memcpy (&payload[j++], 423 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
442 &s->r_prime[i], 424 "Sending %u additional crypto values to Alice\n",
443 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); 425 (unsigned int)todo_count);
426 e = GNUNET_MQ_msg_extra(msg,
427 todo_count * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext) * 2,
428 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART);
429 msg->contained_element_count = htonl(todo_count);
430 payload = (struct GNUNET_CRYPTO_PaillierCiphertext *)&msg[1];
431 for (i = s->cadet_transmitted_element_count, j = 0; i < s->cadet_transmitted_element_count + todo_count; i++)
432 {
433 //r[i][p] and r[i][q]
434 GNUNET_memcpy(&payload[j++],
435 &s->r[i],
436 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
437 GNUNET_memcpy(&payload[j++],
438 &s->r_prime[i],
439 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
440 }
441 s->cadet_transmitted_element_count += todo_count;
442 if (s->cadet_transmitted_element_count == s->used_element_count)
443 GNUNET_MQ_notify_sent(e,
444 &bob_cadet_done_cb,
445 s);
446 GNUNET_MQ_send(s->cadet_mq,
447 e);
444 } 448 }
445 s->cadet_transmitted_element_count += todo_count; 449 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
446 if (s->cadet_transmitted_element_count == s->used_element_count) 450 "All values queued for Alice, Bob is done\n");
447 GNUNET_MQ_notify_sent (e,
448 &bob_cadet_done_cb,
449 s);
450 GNUNET_MQ_send (s->cadet_mq,
451 e);
452 }
453 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
454 "All values queued for Alice, Bob is done\n");
455} 451}
456 452
457 453
@@ -467,7 +463,7 @@ transmit_bobs_cryptodata_message_multipart (struct BobServiceSession *s)
467 * @param s the associated requesting session with Alice 463 * @param s the associated requesting session with Alice
468 */ 464 */
469static void 465static void
470transmit_bobs_cryptodata_message (struct BobServiceSession *s) 466transmit_bobs_cryptodata_message(struct BobServiceSession *s)
471{ 467{
472 struct BobCryptodataMessage *msg; 468 struct BobCryptodataMessage *msg;
473 struct GNUNET_MQ_Envelope *e; 469 struct GNUNET_MQ_Envelope *e;
@@ -475,49 +471,49 @@ transmit_bobs_cryptodata_message (struct BobServiceSession *s)
475 unsigned int i; 471 unsigned int i;
476 472
477 s->cadet_transmitted_element_count 473 s->cadet_transmitted_element_count
478 = ((GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE - 1 - sizeof (struct BobCryptodataMessage)) 474 = ((GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE - 1 - sizeof(struct BobCryptodataMessage))
479 / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) / 2) - 1; 475 / sizeof(struct GNUNET_CRYPTO_PaillierCiphertext) / 2) - 1;
480 if (s->cadet_transmitted_element_count > s->used_element_count) 476 if (s->cadet_transmitted_element_count > s->used_element_count)
481 s->cadet_transmitted_element_count = s->used_element_count; 477 s->cadet_transmitted_element_count = s->used_element_count;
482 478
483 e = GNUNET_MQ_msg_extra (msg, 479 e = GNUNET_MQ_msg_extra(msg,
484 (2 + s->cadet_transmitted_element_count * 2) 480 (2 + s->cadet_transmitted_element_count * 2)
485 * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext), 481 * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext),
486 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA); 482 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA);
487 msg->contained_element_count = htonl (s->cadet_transmitted_element_count); 483 msg->contained_element_count = htonl(s->cadet_transmitted_element_count);
488 484
489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 485 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
490 "Sending %u/%u crypto values to Alice\n", 486 "Sending %u/%u crypto values to Alice\n",
491 (unsigned int) s->cadet_transmitted_element_count, 487 (unsigned int)s->cadet_transmitted_element_count,
492 (unsigned int) s->used_element_count); 488 (unsigned int)s->used_element_count);
493 489
494 payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; 490 payload = (struct GNUNET_CRYPTO_PaillierCiphertext *)&msg[1];
495 GNUNET_memcpy (&payload[0], 491 GNUNET_memcpy(&payload[0],
496 &s->s, 492 &s->s,
497 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); 493 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
498 GNUNET_memcpy (&payload[1], 494 GNUNET_memcpy(&payload[1],
499 &s->s_prime, 495 &s->s_prime,
500 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); 496 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
501 497
502 payload = &payload[2]; 498 payload = &payload[2];
503 // convert k[][] 499 // convert k[][]
504 for (i = 0; i < s->cadet_transmitted_element_count; i++) 500 for (i = 0; i < s->cadet_transmitted_element_count; i++)
505 { 501 {
506 //k[i][p] and k[i][q] 502 //k[i][p] and k[i][q]
507 GNUNET_memcpy (&payload[i * 2], 503 GNUNET_memcpy(&payload[i * 2],
508 &s->r[i], 504 &s->r[i],
509 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); 505 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
510 GNUNET_memcpy (&payload[i * 2 + 1], 506 GNUNET_memcpy(&payload[i * 2 + 1],
511 &s->r_prime[i], 507 &s->r_prime[i],
512 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); 508 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
513 } 509 }
514 if (s->cadet_transmitted_element_count == s->used_element_count) 510 if (s->cadet_transmitted_element_count == s->used_element_count)
515 GNUNET_MQ_notify_sent (e, 511 GNUNET_MQ_notify_sent(e,
516 &bob_cadet_done_cb, 512 &bob_cadet_done_cb,
517 s); 513 s);
518 GNUNET_MQ_send (s->cadet_mq, 514 GNUNET_MQ_send(s->cadet_mq,
519 e); 515 e);
520 transmit_bobs_cryptodata_message_multipart (s); 516 transmit_bobs_cryptodata_message_multipart(s);
521} 517}
522#undef ELEMENT_CAPACITY 518#undef ELEMENT_CAPACITY
523 519
@@ -531,21 +527,21 @@ transmit_bobs_cryptodata_message (struct BobServiceSession *s)
531 * TODO: code duplication with Alice! 527 * TODO: code duplication with Alice!
532 */ 528 */
533static gcry_mpi_t 529static gcry_mpi_t
534compute_square_sum (const gcry_mpi_t *vector, 530compute_square_sum(const gcry_mpi_t *vector,
535 uint32_t length) 531 uint32_t length)
536{ 532{
537 gcry_mpi_t elem; 533 gcry_mpi_t elem;
538 gcry_mpi_t sum; 534 gcry_mpi_t sum;
539 uint32_t i; 535 uint32_t i;
540 536
541 GNUNET_assert (NULL != (sum = gcry_mpi_new (0))); 537 GNUNET_assert(NULL != (sum = gcry_mpi_new(0)));
542 GNUNET_assert (NULL != (elem = gcry_mpi_new (0))); 538 GNUNET_assert(NULL != (elem = gcry_mpi_new(0)));
543 for (i = 0; i < length; i++) 539 for (i = 0; i < length; i++)
544 { 540 {
545 gcry_mpi_mul (elem, vector[i], vector[i]); 541 gcry_mpi_mul(elem, vector[i], vector[i]);
546 gcry_mpi_add (sum, sum, elem); 542 gcry_mpi_add(sum, sum, elem);
547 } 543 }
548 gcry_mpi_release (elem); 544 gcry_mpi_release(elem);
549 return sum; 545 return sum;
550} 546}
551 547
@@ -561,7 +557,7 @@ compute_square_sum (const gcry_mpi_t *vector,
561 * @return #GNUNET_OK on success 557 * @return #GNUNET_OK on success
562 */ 558 */
563static int 559static int
564compute_service_response (struct BobServiceSession *session) 560compute_service_response(struct BobServiceSession *session)
565{ 561{
566 uint32_t i; 562 uint32_t i;
567 unsigned int *p; 563 unsigned int *p;
@@ -577,125 +573,125 @@ compute_service_response (struct BobServiceSession *session)
577 count = session->used_element_count; 573 count = session->used_element_count;
578 a = session->e_a; 574 a = session->e_a;
579 b = session->sorted_elements; 575 b = session->sorted_elements;
580 q = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, 576 q = GNUNET_CRYPTO_random_permute(GNUNET_CRYPTO_QUALITY_WEAK,
581 count); 577 count);
582 p = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, 578 p = GNUNET_CRYPTO_random_permute(GNUNET_CRYPTO_QUALITY_WEAK,
583 count); 579 count);
584 rand = GNUNET_malloc (sizeof (gcry_mpi_t) * count); 580 rand = GNUNET_malloc(sizeof(gcry_mpi_t) * count);
585 for (i = 0; i < count; i++) 581 for (i = 0; i < count; i++)
586 GNUNET_assert (NULL != (rand[i] = gcry_mpi_new (0))); 582 GNUNET_assert(NULL != (rand[i] = gcry_mpi_new(0)));
587 r = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * count); 583 r = GNUNET_malloc(sizeof(struct GNUNET_CRYPTO_PaillierCiphertext) * count);
588 r_prime = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * count); 584 r_prime = GNUNET_malloc(sizeof(struct GNUNET_CRYPTO_PaillierCiphertext) * count);
589 585
590 for (i = 0; i < count; i++) 586 for (i = 0; i < count; i++)
591 { 587 {
592 int32_t svalue; 588 int32_t svalue;
593 589
594 svalue = (int32_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 590 svalue = (int32_t)GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK,
595 UINT32_MAX); 591 UINT32_MAX);
596 // long to gcry_mpi_t 592 // long to gcry_mpi_t
597 if (svalue < 0) 593 if (svalue < 0)
598 gcry_mpi_sub_ui (rand[i], 594 gcry_mpi_sub_ui(rand[i],
599 rand[i], 595 rand[i],
600 - svalue); 596 -svalue);
601 else 597 else
602 rand[i] = gcry_mpi_set_ui (rand[i], svalue); 598 rand[i] = gcry_mpi_set_ui(rand[i], svalue);
603 } 599 }
604 600
605 tmp = gcry_mpi_new (0); 601 tmp = gcry_mpi_new(0);
606 // encrypt the element 602 // encrypt the element
607 // for the sake of readability I decided to have dedicated permutation 603 // for the sake of readability I decided to have dedicated permutation
608 // vectors, which get rid of all the lookups in p/q. 604 // vectors, which get rid of all the lookups in p/q.
609 // however, ap/aq are not absolutely necessary but are just abstraction 605 // however, ap/aq are not absolutely necessary but are just abstraction
610 // Calculate Kp = E(S + a_pi) (+) E(S - r_pi - b_pi) 606 // Calculate Kp = E(S + a_pi) (+) E(S - r_pi - b_pi)
611 for (i = 0; i < count; i++) 607 for (i = 0; i < count; i++)
612 { 608 {
613 // E(S - r_pi - b_pi) 609 // E(S - r_pi - b_pi)
614 gcry_mpi_sub (tmp, my_offset, rand[p[i]]); 610 gcry_mpi_sub(tmp, my_offset, rand[p[i]]);
615 gcry_mpi_sub (tmp, tmp, b[p[i]].value); 611 gcry_mpi_sub(tmp, tmp, b[p[i]].value);
616 GNUNET_assert (2 == 612 GNUNET_assert(2 ==
617 GNUNET_CRYPTO_paillier_encrypt (&session->remote_pubkey, 613 GNUNET_CRYPTO_paillier_encrypt(&session->remote_pubkey,
618 tmp, 614 tmp,
619 2, 615 2,
620 &r[i])); 616 &r[i]));
621 617
622 // E(S - r_pi - b_pi) * E(S + a_pi) == E(2*S + a - r - b) 618 // E(S - r_pi - b_pi) * E(S + a_pi) == E(2*S + a - r - b)
623 if (GNUNET_OK != 619 if (GNUNET_OK !=
624 GNUNET_CRYPTO_paillier_hom_add (&session->remote_pubkey, 620 GNUNET_CRYPTO_paillier_hom_add(&session->remote_pubkey,
625 &r[i], 621 &r[i],
626 &a[p[i]], 622 &a[p[i]],
627 &r[i])) 623 &r[i]))
628 { 624 {
629 GNUNET_break_op (0); 625 GNUNET_break_op(0);
630 goto error_cleanup; 626 goto error_cleanup;
627 }
631 } 628 }
632 }
633 629
634 // Calculate Kq = E(S + a_qi) (+) E(S - r_qi) 630 // Calculate Kq = E(S + a_qi) (+) E(S - r_qi)
635 for (i = 0; i < count; i++) 631 for (i = 0; i < count; i++)
636 { 632 {
637 // E(S - r_qi) 633 // E(S - r_qi)
638 gcry_mpi_sub (tmp, my_offset, rand[q[i]]); 634 gcry_mpi_sub(tmp, my_offset, rand[q[i]]);
639 GNUNET_assert (2 == 635 GNUNET_assert(2 ==
640 GNUNET_CRYPTO_paillier_encrypt (&session->remote_pubkey, 636 GNUNET_CRYPTO_paillier_encrypt(&session->remote_pubkey,
641 tmp, 637 tmp,
642 2, 638 2,
643 &r_prime[i])); 639 &r_prime[i]));
644 640
645 // E(S - r_qi) * E(S + a_qi) == E(2*S + a_qi - r_qi) 641 // E(S - r_qi) * E(S + a_qi) == E(2*S + a_qi - r_qi)
646 if (GNUNET_OK != 642 if (GNUNET_OK !=
647 GNUNET_CRYPTO_paillier_hom_add (&session->remote_pubkey, 643 GNUNET_CRYPTO_paillier_hom_add(&session->remote_pubkey,
648 &r_prime[i], 644 &r_prime[i],
649 &a[q[i]], 645 &a[q[i]],
650 &r_prime[i])) 646 &r_prime[i]))
651 { 647 {
652 GNUNET_break_op (0); 648 GNUNET_break_op(0);
653 goto error_cleanup; 649 goto error_cleanup;
650 }
654 } 651 }
655 } 652 gcry_mpi_release(tmp);
656 gcry_mpi_release (tmp);
657 653
658 // Calculate S' = E(SUM( r_i^2 )) 654 // Calculate S' = E(SUM( r_i^2 ))
659 tmp = compute_square_sum (rand, count); 655 tmp = compute_square_sum(rand, count);
660 GNUNET_assert (1 == 656 GNUNET_assert(1 ==
661 GNUNET_CRYPTO_paillier_encrypt (&session->remote_pubkey, 657 GNUNET_CRYPTO_paillier_encrypt(&session->remote_pubkey,
662 tmp, 658 tmp,
663 1, 659 1,
664 &session->s_prime)); 660 &session->s_prime));
665 gcry_mpi_release (tmp); 661 gcry_mpi_release(tmp);
666 662
667 // Calculate S = E(SUM( (r_i + b_i)^2 )) 663 // Calculate S = E(SUM( (r_i + b_i)^2 ))
668 for (i = 0; i < count; i++) 664 for (i = 0; i < count; i++)
669 gcry_mpi_add (rand[i], rand[i], b[i].value); 665 gcry_mpi_add(rand[i], rand[i], b[i].value);
670 tmp = compute_square_sum (rand, count); 666 tmp = compute_square_sum(rand, count);
671 GNUNET_assert (1 == 667 GNUNET_assert(1 ==
672 GNUNET_CRYPTO_paillier_encrypt (&session->remote_pubkey, 668 GNUNET_CRYPTO_paillier_encrypt(&session->remote_pubkey,
673 tmp, 669 tmp,
674 1, 670 1,
675 &session->s)); 671 &session->s));
676 gcry_mpi_release (tmp); 672 gcry_mpi_release(tmp);
677 673
678 session->r = r; 674 session->r = r;
679 session->r_prime = r_prime; 675 session->r_prime = r_prime;
680 676
681 for (i = 0; i < count; i++) 677 for (i = 0; i < count; i++)
682 gcry_mpi_release (rand[i]); 678 gcry_mpi_release(rand[i]);
683 GNUNET_free (session->e_a); 679 GNUNET_free(session->e_a);
684 session->e_a = NULL; 680 session->e_a = NULL;
685 GNUNET_free (p); 681 GNUNET_free(p);
686 GNUNET_free (q); 682 GNUNET_free(q);
687 GNUNET_free (rand); 683 GNUNET_free(rand);
688 return GNUNET_OK; 684 return GNUNET_OK;
689 685
690 error_cleanup: 686error_cleanup:
691 GNUNET_free (r); 687 GNUNET_free(r);
692 GNUNET_free (r_prime); 688 GNUNET_free(r_prime);
693 gcry_mpi_release (tmp); 689 gcry_mpi_release(tmp);
694 GNUNET_free (p); 690 GNUNET_free(p);
695 GNUNET_free (q); 691 GNUNET_free(q);
696 for (i = 0; i < count; i++) 692 for (i = 0; i < count; i++)
697 gcry_mpi_release (rand[i]); 693 gcry_mpi_release(rand[i]);
698 GNUNET_free (rand); 694 GNUNET_free(rand);
699 return GNUNET_SYSERR; 695 return GNUNET_SYSERR;
700} 696}
701 697
@@ -710,21 +706,21 @@ compute_service_response (struct BobServiceSession *session)
710 * TODO: code duplication with Alice! 706 * TODO: code duplication with Alice!
711 */ 707 */
712static int 708static int
713copy_element_cb (void *cls, 709copy_element_cb(void *cls,
714 const struct GNUNET_HashCode *key, 710 const struct GNUNET_HashCode *key,
715 void *value) 711 void *value)
716{ 712{
717 struct BobServiceSession *s = cls; 713 struct BobServiceSession *s = cls;
718 struct GNUNET_SCALARPRODUCT_Element *e = value; 714 struct GNUNET_SCALARPRODUCT_Element *e = value;
719 gcry_mpi_t mval; 715 gcry_mpi_t mval;
720 int64_t val; 716 int64_t val;
721 717
722 mval = gcry_mpi_new (0); 718 mval = gcry_mpi_new(0);
723 val = (int64_t) GNUNET_ntohll (e->value); 719 val = (int64_t)GNUNET_ntohll(e->value);
724 if (0 > val) 720 if (0 > val)
725 gcry_mpi_sub_ui (mval, mval, -val); 721 gcry_mpi_sub_ui(mval, mval, -val);
726 else 722 else
727 gcry_mpi_add_ui (mval, mval, val); 723 gcry_mpi_add_ui(mval, mval, val);
728 s->sorted_elements [s->used_element_count].value = mval; 724 s->sorted_elements [s->used_element_count].value = mval;
729 s->sorted_elements [s->used_element_count].key = &e->key; 725 s->sorted_elements [s->used_element_count].key = &e->key;
730 s->used_element_count++; 726 s->used_element_count++;
@@ -741,14 +737,14 @@ copy_element_cb (void *cls,
741 * TODO: code duplication with Alice! 737 * TODO: code duplication with Alice!
742 */ 738 */
743static int 739static int
744element_cmp (const void *a, 740element_cmp(const void *a,
745 const void *b) 741 const void *b)
746{ 742{
747 const struct MpiElement *ma = a; 743 const struct MpiElement *ma = a;
748 const struct MpiElement *mb = b; 744 const struct MpiElement *mb = b;
749 745
750 return GNUNET_CRYPTO_hash_cmp (ma->key, 746 return GNUNET_CRYPTO_hash_cmp(ma->key,
751 mb->key); 747 mb->key);
752} 748}
753 749
754 750
@@ -760,33 +756,33 @@ element_cmp (const void *a,
760 * @param s session to transmit reply for. 756 * @param s session to transmit reply for.
761 */ 757 */
762static void 758static void
763transmit_cryptographic_reply (struct BobServiceSession *s) 759transmit_cryptographic_reply(struct BobServiceSession *s)
764{ 760{
765 struct GNUNET_CADET_Channel *channel; 761 struct GNUNET_CADET_Channel *channel;
766 762
767 /* TODO: code duplication with Alice! */ 763 /* TODO: code duplication with Alice! */
768 LOG (GNUNET_ERROR_TYPE_DEBUG, 764 LOG(GNUNET_ERROR_TYPE_DEBUG,
769 "Received everything, building reply for Alice\n"); 765 "Received everything, building reply for Alice\n");
770 s->sorted_elements 766 s->sorted_elements
771 = GNUNET_malloc (GNUNET_CONTAINER_multihashmap_size (s->intersected_elements) * 767 = GNUNET_malloc(GNUNET_CONTAINER_multihashmap_size(s->intersected_elements) *
772 sizeof (struct MpiElement)); 768 sizeof(struct MpiElement));
773 s->used_element_count = 0; 769 s->used_element_count = 0;
774 GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements, 770 GNUNET_CONTAINER_multihashmap_iterate(s->intersected_elements,
775 &copy_element_cb, 771 &copy_element_cb,
776 s); 772 s);
777 qsort (s->sorted_elements, 773 qsort(s->sorted_elements,
778 s->used_element_count, 774 s->used_element_count,
779 sizeof (struct MpiElement), 775 sizeof(struct MpiElement),
780 &element_cmp); 776 &element_cmp);
781 if (GNUNET_OK != 777 if (GNUNET_OK !=
782 compute_service_response (s)) 778 compute_service_response(s))
783 { 779 {
784 channel = s->channel; 780 channel = s->channel;
785 s->channel = NULL; 781 s->channel = NULL;
786 GNUNET_CADET_channel_destroy (channel); 782 GNUNET_CADET_channel_destroy(channel);
787 return; 783 return;
788 } 784 }
789 transmit_bobs_cryptodata_message (s); 785 transmit_bobs_cryptodata_message(s);
790} 786}
791 787
792 788
@@ -800,8 +796,8 @@ transmit_cryptographic_reply (struct BobServiceSession *s)
800 * #GNUNET_SYSERR to close it (signal serious error) 796 * #GNUNET_SYSERR to close it (signal serious error)
801 */ 797 */
802static int 798static int
803check_alices_cryptodata_message (void *cls, 799check_alices_cryptodata_message(void *cls,
804 const struct AliceCryptodataMessage *msg) 800 const struct AliceCryptodataMessage *msg)
805{ 801{
806 struct BobServiceSession *s = cls; 802 struct BobServiceSession *s = cls;
807 uint32_t contained_elements; 803 uint32_t contained_elements;
@@ -809,21 +805,21 @@ check_alices_cryptodata_message (void *cls,
809 uint16_t msize; 805 uint16_t msize;
810 unsigned int max; 806 unsigned int max;
811 807
812 msize = ntohs (msg->header.size); 808 msize = ntohs(msg->header.size);
813 contained_elements = ntohl (msg->contained_element_count); 809 contained_elements = ntohl(msg->contained_element_count);
814 /* Our intersection may still be ongoing, but this is nevertheless 810 /* Our intersection may still be ongoing, but this is nevertheless
815 an upper bound on the required array size */ 811 an upper bound on the required array size */
816 max = GNUNET_CONTAINER_multihashmap_size (s->intersected_elements); 812 max = GNUNET_CONTAINER_multihashmap_size(s->intersected_elements);
817 msg_length = sizeof (struct AliceCryptodataMessage) 813 msg_length = sizeof(struct AliceCryptodataMessage)
818 + contained_elements * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext); 814 + contained_elements * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext);
819 if ( (msize != msg_length) || 815 if ((msize != msg_length) ||
820 (0 == contained_elements) || 816 (0 == contained_elements) ||
821 (contained_elements > UINT16_MAX) || 817 (contained_elements > UINT16_MAX) ||
822 (max < contained_elements + s->cadet_received_element_count) ) 818 (max < contained_elements + s->cadet_received_element_count))
823 { 819 {
824 GNUNET_break_op (0); 820 GNUNET_break_op(0);
825 return GNUNET_SYSERR; 821 return GNUNET_SYSERR;
826 } 822 }
827 return GNUNET_OK; 823 return GNUNET_OK;
828} 824}
829 825
@@ -836,40 +832,40 @@ check_alices_cryptodata_message (void *cls,
836 * @param msg the actual message 832 * @param msg the actual message
837 */ 833 */
838static void 834static void
839handle_alices_cryptodata_message (void *cls, 835handle_alices_cryptodata_message(void *cls,
840 const struct AliceCryptodataMessage *msg) 836 const struct AliceCryptodataMessage *msg)
841{ 837{
842 struct BobServiceSession *s = cls; 838 struct BobServiceSession *s = cls;
843 const struct GNUNET_CRYPTO_PaillierCiphertext *payload; 839 const struct GNUNET_CRYPTO_PaillierCiphertext *payload;
844 uint32_t contained_elements; 840 uint32_t contained_elements;
845 unsigned int max; 841 unsigned int max;
846 842
847 contained_elements = ntohl (msg->contained_element_count); 843 contained_elements = ntohl(msg->contained_element_count);
848 /* Our intersection may still be ongoing, but this is nevertheless 844 /* Our intersection may still be ongoing, but this is nevertheless
849 an upper bound on the required array size */ 845 an upper bound on the required array size */
850 max = GNUNET_CONTAINER_multihashmap_size (s->intersected_elements); 846 max = GNUNET_CONTAINER_multihashmap_size(s->intersected_elements);
851 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 847 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
852 "Received %u crypto values from Alice\n", 848 "Received %u crypto values from Alice\n",
853 (unsigned int) contained_elements); 849 (unsigned int)contained_elements);
854 850
855 payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; 851 payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *)&msg[1];
856 if (NULL == s->e_a) 852 if (NULL == s->e_a)
857 s->e_a = GNUNET_new_array (max, 853 s->e_a = GNUNET_new_array(max,
858 struct GNUNET_CRYPTO_PaillierCiphertext); 854 struct GNUNET_CRYPTO_PaillierCiphertext);
859 GNUNET_memcpy (&s->e_a[s->cadet_received_element_count], 855 GNUNET_memcpy(&s->e_a[s->cadet_received_element_count],
860 payload, 856 payload,
861 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext) * contained_elements); 857 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext) * contained_elements);
862 s->cadet_received_element_count += contained_elements; 858 s->cadet_received_element_count += contained_elements;
863 859
864 if ( (s->cadet_received_element_count == max) && 860 if ((s->cadet_received_element_count == max) &&
865 (NULL == s->intersection_op) ) 861 (NULL == s->intersection_op))
866 { 862 {
867 /* intersection has finished also on our side, and 863 /* intersection has finished also on our side, and
868 we got the full set, so we can proceed with the 864 we got the full set, so we can proceed with the
869 CADET response(s) */ 865 CADET response(s) */
870 transmit_cryptographic_reply (s); 866 transmit_cryptographic_reply(s);
871 } 867 }
872 GNUNET_CADET_receive_done (s->channel); 868 GNUNET_CADET_receive_done(s->channel);
873} 869}
874 870
875 871
@@ -883,67 +879,71 @@ handle_alices_cryptodata_message (void *cls,
883 * @param status what has happened with the set intersection? 879 * @param status what has happened with the set intersection?
884 */ 880 */
885static void 881static void
886cb_intersection_element_removed (void *cls, 882cb_intersection_element_removed(void *cls,
887 const struct GNUNET_SET_Element *element, 883 const struct GNUNET_SET_Element *element,
888 uint64_t current_size, 884 uint64_t current_size,
889 enum GNUNET_SET_Status status) 885 enum GNUNET_SET_Status status)
890{ 886{
891 struct BobServiceSession *s = cls; 887 struct BobServiceSession *s = cls;
892 struct GNUNET_SCALARPRODUCT_Element *se; 888 struct GNUNET_SCALARPRODUCT_Element *se;
893 889
894 switch (status) 890 switch (status)
895 { 891 {
896 case GNUNET_SET_STATUS_OK: 892 case GNUNET_SET_STATUS_OK:
897 /* this element has been removed from the set */ 893 /* this element has been removed from the set */
898 se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements, 894 se = GNUNET_CONTAINER_multihashmap_get(s->intersected_elements,
899 element->data); 895 element->data);
900 GNUNET_assert (NULL != se); 896 GNUNET_assert(NULL != se);
901 LOG (GNUNET_ERROR_TYPE_DEBUG, 897 LOG(GNUNET_ERROR_TYPE_DEBUG,
902 "Removed element with key %s and value %lld\n", 898 "Removed element with key %s and value %lld\n",
903 GNUNET_h2s (&se->key), 899 GNUNET_h2s(&se->key),
904 (long long) GNUNET_ntohll (se->value)); 900 (long long)GNUNET_ntohll(se->value));
905 GNUNET_assert (GNUNET_YES == 901 GNUNET_assert(GNUNET_YES ==
906 GNUNET_CONTAINER_multihashmap_remove (s->intersected_elements, 902 GNUNET_CONTAINER_multihashmap_remove(s->intersected_elements,
907 element->data, 903 element->data,
908 se)); 904 se));
909 GNUNET_free (se); 905 GNUNET_free(se);
910 return; 906 return;
911 case GNUNET_SET_STATUS_DONE: 907
912 s->intersection_op = NULL; 908 case GNUNET_SET_STATUS_DONE:
913 GNUNET_break (NULL == s->intersection_set); 909 s->intersection_op = NULL;
914 GNUNET_CADET_receive_done (s->channel); 910 GNUNET_break(NULL == s->intersection_set);
915 LOG (GNUNET_ERROR_TYPE_DEBUG, 911 GNUNET_CADET_receive_done(s->channel);
916 "Finished intersection, %d items remain\n", 912 LOG(GNUNET_ERROR_TYPE_DEBUG,
917 GNUNET_CONTAINER_multihashmap_size (s->intersected_elements)); 913 "Finished intersection, %d items remain\n",
918 if (s->client_received_element_count == 914 GNUNET_CONTAINER_multihashmap_size(s->intersected_elements));
919 GNUNET_CONTAINER_multihashmap_size (s->intersected_elements)) 915 if (s->client_received_element_count ==
920 { 916 GNUNET_CONTAINER_multihashmap_size(s->intersected_elements))
921 /* CADET transmission from Alice is also already done, 917 {
922 start with our own reply */ 918 /* CADET transmission from Alice is also already done,
923 transmit_cryptographic_reply (s); 919 start with our own reply */
920 transmit_cryptographic_reply(s);
921 }
922 return;
923
924 case GNUNET_SET_STATUS_HALF_DONE:
925 /* unexpected for intersection */
926 GNUNET_break(0);
927 return;
928
929 case GNUNET_SET_STATUS_FAILURE:
930 /* unhandled status code */
931 LOG(GNUNET_ERROR_TYPE_DEBUG,
932 "Set intersection failed!\n");
933 s->intersection_op = NULL;
934 if (NULL != s->intersection_set)
935 {
936 GNUNET_SET_destroy(s->intersection_set);
937 s->intersection_set = NULL;
938 }
939 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
940 prepare_client_end_notification(s);
941 return;
942
943 default:
944 GNUNET_break(0);
945 return;
924 } 946 }
925 return;
926 case GNUNET_SET_STATUS_HALF_DONE:
927 /* unexpected for intersection */
928 GNUNET_break (0);
929 return;
930 case GNUNET_SET_STATUS_FAILURE:
931 /* unhandled status code */
932 LOG (GNUNET_ERROR_TYPE_DEBUG,
933 "Set intersection failed!\n");
934 s->intersection_op = NULL;
935 if (NULL != s->intersection_set)
936 {
937 GNUNET_SET_destroy (s->intersection_set);
938 s->intersection_set = NULL;
939 }
940 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
941 prepare_client_end_notification (s);
942 return;
943 default:
944 GNUNET_break (0);
945 return;
946 }
947} 947}
948 948
949 949
@@ -954,31 +954,31 @@ cb_intersection_element_removed (void *cls,
954 * @param s client session to start intersection for 954 * @param s client session to start intersection for
955 */ 955 */
956static void 956static void
957start_intersection (struct BobServiceSession *s) 957start_intersection(struct BobServiceSession *s)
958{ 958{
959 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 959 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
960 "Got session with key %s and %u elements, starting intersection.\n", 960 "Got session with key %s and %u elements, starting intersection.\n",
961 GNUNET_h2s (&s->session_id), 961 GNUNET_h2s(&s->session_id),
962 (unsigned int) s->total); 962 (unsigned int)s->total);
963 963
964 s->intersection_op 964 s->intersection_op
965 = GNUNET_SET_prepare (&s->peer, 965 = GNUNET_SET_prepare(&s->peer,
966 &s->session_id, 966 &s->session_id,
967 NULL, 967 NULL,
968 GNUNET_SET_RESULT_REMOVED, 968 GNUNET_SET_RESULT_REMOVED,
969 (struct GNUNET_SET_Option[]) {{ 0 }}, 969 (struct GNUNET_SET_Option[]) { { 0 } },
970 &cb_intersection_element_removed, 970 &cb_intersection_element_removed,
971 s); 971 s);
972 if (GNUNET_OK != 972 if (GNUNET_OK !=
973 GNUNET_SET_commit (s->intersection_op, 973 GNUNET_SET_commit(s->intersection_op,
974 s->intersection_set)) 974 s->intersection_set))
975 { 975 {
976 GNUNET_break (0); 976 GNUNET_break(0);
977 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; 977 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
978 prepare_client_end_notification (s); 978 prepare_client_end_notification(s);
979 return; 979 return;
980 } 980 }
981 GNUNET_SET_destroy (s->intersection_set); 981 GNUNET_SET_destroy(s->intersection_set);
982 s->intersection_set = NULL; 982 s->intersection_set = NULL;
983} 983}
984 984
@@ -990,15 +990,15 @@ start_intersection (struct BobServiceSession *s)
990 * @param msg the actual message 990 * @param msg the actual message
991 */ 991 */
992static void 992static void
993handle_alices_computation_request (void *cls, 993handle_alices_computation_request(void *cls,
994 const struct ServiceRequestMessage *msg) 994 const struct ServiceRequestMessage *msg)
995{ 995{
996 struct BobServiceSession *s = cls; 996 struct BobServiceSession *s = cls;
997 997
998 s->session_id = msg->session_id; // ?? 998 s->session_id = msg->session_id; // ??
999 s->remote_pubkey = msg->public_key; 999 s->remote_pubkey = msg->public_key;
1000 if (s->client_received_element_count == s->total) 1000 if (s->client_received_element_count == s->total)
1001 start_intersection (s); 1001 start_intersection(s);
1002} 1002}
1003 1003
1004 1004
@@ -1013,20 +1013,20 @@ handle_alices_computation_request (void *cls,
1013 * @return session associated with the channel 1013 * @return session associated with the channel
1014 */ 1014 */
1015static void * 1015static void *
1016cb_channel_incoming (void *cls, 1016cb_channel_incoming(void *cls,
1017 struct GNUNET_CADET_Channel *channel, 1017 struct GNUNET_CADET_Channel *channel,
1018 const struct GNUNET_PeerIdentity *initiator) 1018 const struct GNUNET_PeerIdentity *initiator)
1019{ 1019{
1020 struct BobServiceSession *s = cls; 1020 struct BobServiceSession *s = cls;
1021 1021
1022 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1022 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1023 "New incoming channel from peer %s.\n", 1023 "New incoming channel from peer %s.\n",
1024 GNUNET_i2s (initiator)); 1024 GNUNET_i2s(initiator));
1025 GNUNET_CADET_close_port (s->port); 1025 GNUNET_CADET_close_port(s->port);
1026 s->port = NULL; 1026 s->port = NULL;
1027 s->channel = channel; 1027 s->channel = channel;
1028 s->peer = *initiator; 1028 s->peer = *initiator;
1029 s->cadet_mq = GNUNET_CADET_get_mq (s->channel); 1029 s->cadet_mq = GNUNET_CADET_get_mq(s->channel);
1030 return s; 1030 return s;
1031} 1031}
1032 1032
@@ -1039,25 +1039,25 @@ cb_channel_incoming (void *cls,
1039 * @return #GNUNET_OK if @a msg is well-formed 1039 * @return #GNUNET_OK if @a msg is well-formed
1040 */ 1040 */
1041static int 1041static int
1042check_bob_client_message_multipart (void *cls, 1042check_bob_client_message_multipart(void *cls,
1043 const struct ComputationBobCryptodataMultipartMessage *msg) 1043 const struct ComputationBobCryptodataMultipartMessage *msg)
1044{ 1044{
1045 struct BobServiceSession *s = cls; 1045 struct BobServiceSession *s = cls;
1046 uint32_t contained_count; 1046 uint32_t contained_count;
1047 uint16_t msize; 1047 uint16_t msize;
1048 1048
1049 msize = ntohs (msg->header.size); 1049 msize = ntohs(msg->header.size);
1050 contained_count = ntohl (msg->element_count_contained); 1050 contained_count = ntohl(msg->element_count_contained);
1051 if ( (msize != (sizeof (struct ComputationBobCryptodataMultipartMessage) + 1051 if ((msize != (sizeof(struct ComputationBobCryptodataMultipartMessage) +
1052 contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) || 1052 contained_count * sizeof(struct GNUNET_SCALARPRODUCT_Element))) ||
1053 (0 == contained_count) || 1053 (0 == contained_count) ||
1054 (UINT16_MAX < contained_count) || 1054 (UINT16_MAX < contained_count) ||
1055 (s->total == s->client_received_element_count) || 1055 (s->total == s->client_received_element_count) ||
1056 (s->total < s->client_received_element_count + contained_count) ) 1056 (s->total < s->client_received_element_count + contained_count))
1057 { 1057 {
1058 GNUNET_break (0); 1058 GNUNET_break(0);
1059 return GNUNET_SYSERR; 1059 return GNUNET_SYSERR;
1060 } 1060 }
1061 return GNUNET_OK; 1061 return GNUNET_OK;
1062} 1062}
1063 1063
@@ -1070,8 +1070,8 @@ check_bob_client_message_multipart (void *cls,
1070 * @param msg the actual message 1070 * @param msg the actual message
1071 */ 1071 */
1072static void 1072static void
1073handle_bob_client_message_multipart (void *cls, 1073handle_bob_client_message_multipart(void *cls,
1074 const struct ComputationBobCryptodataMultipartMessage *msg) 1074 const struct ComputationBobCryptodataMultipartMessage *msg)
1075{ 1075{
1076 struct BobServiceSession *s = cls; 1076 struct BobServiceSession *s = cls;
1077 uint32_t contained_count; 1077 uint32_t contained_count;
@@ -1079,44 +1079,44 @@ handle_bob_client_message_multipart (void *cls,
1079 struct GNUNET_SET_Element set_elem; 1079 struct GNUNET_SET_Element set_elem;
1080 struct GNUNET_SCALARPRODUCT_Element *elem; 1080 struct GNUNET_SCALARPRODUCT_Element *elem;
1081 1081
1082 contained_count = ntohl (msg->element_count_contained); 1082 contained_count = ntohl(msg->element_count_contained);
1083 elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1]; 1083 elements = (const struct GNUNET_SCALARPRODUCT_Element *)&msg[1];
1084 for (uint32_t i = 0; i < contained_count; i++) 1084 for (uint32_t i = 0; i < contained_count; i++)
1085 {
1086 elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element);
1087 GNUNET_memcpy (elem,
1088 &elements[i],
1089 sizeof (struct GNUNET_SCALARPRODUCT_Element));
1090 if (GNUNET_SYSERR ==
1091 GNUNET_CONTAINER_multihashmap_put (s->intersected_elements,
1092 &elem->key,
1093 elem,
1094 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1095 { 1085 {
1096 GNUNET_break (0); 1086 elem = GNUNET_new(struct GNUNET_SCALARPRODUCT_Element);
1097 GNUNET_free (elem); 1087 GNUNET_memcpy(elem,
1098 continue; 1088 &elements[i],
1089 sizeof(struct GNUNET_SCALARPRODUCT_Element));
1090 if (GNUNET_SYSERR ==
1091 GNUNET_CONTAINER_multihashmap_put(s->intersected_elements,
1092 &elem->key,
1093 elem,
1094 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1095 {
1096 GNUNET_break(0);
1097 GNUNET_free(elem);
1098 continue;
1099 }
1100 set_elem.data = &elem->key;
1101 set_elem.size = sizeof(elem->key);
1102 set_elem.element_type = 0;
1103 GNUNET_SET_add_element(s->intersection_set,
1104 &set_elem,
1105 NULL, NULL);
1099 } 1106 }
1100 set_elem.data = &elem->key;
1101 set_elem.size = sizeof (elem->key);
1102 set_elem.element_type = 0;
1103 GNUNET_SET_add_element (s->intersection_set,
1104 &set_elem,
1105 NULL, NULL);
1106 }
1107 s->client_received_element_count += contained_count; 1107 s->client_received_element_count += contained_count;
1108 GNUNET_SERVICE_client_continue (s->client); 1108 GNUNET_SERVICE_client_continue(s->client);
1109 if (s->total != s->client_received_element_count) 1109 if (s->total != s->client_received_element_count)
1110 { 1110 {
1111 /* more to come */ 1111 /* more to come */
1112 return; 1112 return;
1113 } 1113 }
1114 if (NULL == s->channel) 1114 if (NULL == s->channel)
1115 { 1115 {
1116 /* no Alice waiting for this request, wait for Alice */ 1116 /* no Alice waiting for this request, wait for Alice */
1117 return; 1117 return;
1118 } 1118 }
1119 start_intersection (s); 1119 start_intersection(s);
1120} 1120}
1121 1121
1122 1122
@@ -1129,8 +1129,8 @@ handle_bob_client_message_multipart (void *cls,
1129 * @return #GNUNET_OK if @a msg is well-formed 1129 * @return #GNUNET_OK if @a msg is well-formed
1130 */ 1130 */
1131static int 1131static int
1132check_bob_client_message (void *cls, 1132check_bob_client_message(void *cls,
1133 const struct BobComputationMessage *msg) 1133 const struct BobComputationMessage *msg)
1134{ 1134{
1135 struct BobServiceSession *s = cls; 1135 struct BobServiceSession *s = cls;
1136 uint32_t contained_count; 1136 uint32_t contained_count;
@@ -1138,22 +1138,22 @@ check_bob_client_message (void *cls,
1138 uint16_t msize; 1138 uint16_t msize;
1139 1139
1140 if (GNUNET_SCALARPRODUCT_STATUS_INIT != s->status) 1140 if (GNUNET_SCALARPRODUCT_STATUS_INIT != s->status)
1141 { 1141 {
1142 GNUNET_break (0); 1142 GNUNET_break(0);
1143 return GNUNET_SYSERR; 1143 return GNUNET_SYSERR;
1144 } 1144 }
1145 msize = ntohs (msg->header.size); 1145 msize = ntohs(msg->header.size);
1146 total_count = ntohl (msg->element_count_total); 1146 total_count = ntohl(msg->element_count_total);
1147 contained_count = ntohl (msg->element_count_contained); 1147 contained_count = ntohl(msg->element_count_contained);
1148 if ( (0 == total_count) || 1148 if ((0 == total_count) ||
1149 (0 == contained_count) || 1149 (0 == contained_count) ||
1150 (UINT16_MAX < contained_count) || 1150 (UINT16_MAX < contained_count) ||
1151 (msize != (sizeof (struct BobComputationMessage) + 1151 (msize != (sizeof(struct BobComputationMessage) +
1152 contained_count * sizeof (struct GNUNET_SCALARPRODUCT_Element))) ) 1152 contained_count * sizeof(struct GNUNET_SCALARPRODUCT_Element))))
1153 { 1153 {
1154 GNUNET_break_op (0); 1154 GNUNET_break_op(0);
1155 return GNUNET_SYSERR; 1155 return GNUNET_SYSERR;
1156 } 1156 }
1157 return GNUNET_OK; 1157 return GNUNET_OK;
1158} 1158}
1159 1159
@@ -1167,20 +1167,20 @@ check_bob_client_message (void *cls,
1167 * @param msg the actual message 1167 * @param msg the actual message
1168 */ 1168 */
1169static void 1169static void
1170handle_bob_client_message (void *cls, 1170handle_bob_client_message(void *cls,
1171 const struct BobComputationMessage *msg) 1171 const struct BobComputationMessage *msg)
1172{ 1172{
1173 struct BobServiceSession *s = cls; 1173 struct BobServiceSession *s = cls;
1174 struct GNUNET_MQ_MessageHandler cadet_handlers[] = { 1174 struct GNUNET_MQ_MessageHandler cadet_handlers[] = {
1175 GNUNET_MQ_hd_fixed_size (alices_computation_request, 1175 GNUNET_MQ_hd_fixed_size(alices_computation_request,
1176 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_SESSION_INITIALIZATION, 1176 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_SESSION_INITIALIZATION,
1177 struct ServiceRequestMessage, 1177 struct ServiceRequestMessage,
1178 NULL), 1178 NULL),
1179 GNUNET_MQ_hd_var_size (alices_cryptodata_message, 1179 GNUNET_MQ_hd_var_size(alices_cryptodata_message,
1180 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_CRYPTODATA, 1180 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_CRYPTODATA,
1181 struct AliceCryptodataMessage, 1181 struct AliceCryptodataMessage,
1182 NULL), 1182 NULL),
1183 GNUNET_MQ_handler_end () 1183 GNUNET_MQ_handler_end()
1184 }; 1184 };
1185 uint32_t contained_count; 1185 uint32_t contained_count;
1186 uint32_t total_count; 1186 uint32_t total_count;
@@ -1188,61 +1188,61 @@ handle_bob_client_message (void *cls,
1188 struct GNUNET_SET_Element set_elem; 1188 struct GNUNET_SET_Element set_elem;
1189 struct GNUNET_SCALARPRODUCT_Element *elem; 1189 struct GNUNET_SCALARPRODUCT_Element *elem;
1190 1190
1191 total_count = ntohl (msg->element_count_total); 1191 total_count = ntohl(msg->element_count_total);
1192 contained_count = ntohl (msg->element_count_contained); 1192 contained_count = ntohl(msg->element_count_contained);
1193 1193
1194 s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE; 1194 s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE;
1195 s->total = total_count; 1195 s->total = total_count;
1196 s->client_received_element_count = contained_count; 1196 s->client_received_element_count = contained_count;
1197 s->session_id = msg->session_key; 1197 s->session_id = msg->session_key;
1198 elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1]; 1198 elements = (const struct GNUNET_SCALARPRODUCT_Element *)&msg[1];
1199 s->intersected_elements 1199 s->intersected_elements
1200 = GNUNET_CONTAINER_multihashmap_create (s->total, 1200 = GNUNET_CONTAINER_multihashmap_create(s->total,
1201 GNUNET_YES); 1201 GNUNET_YES);
1202 s->intersection_set 1202 s->intersection_set
1203 = GNUNET_SET_create (cfg, 1203 = GNUNET_SET_create(cfg,
1204 GNUNET_SET_OPERATION_INTERSECTION); 1204 GNUNET_SET_OPERATION_INTERSECTION);
1205 for (uint32_t i = 0; i < contained_count; i++) 1205 for (uint32_t i = 0; i < contained_count; i++)
1206 {
1207 if (0 == GNUNET_ntohll (elements[i].value))
1208 continue;
1209 elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element);
1210 GNUNET_memcpy (elem,
1211 &elements[i],
1212 sizeof (struct GNUNET_SCALARPRODUCT_Element));
1213 if (GNUNET_SYSERR ==
1214 GNUNET_CONTAINER_multihashmap_put (s->intersected_elements,
1215 &elem->key,
1216 elem,
1217 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1218 { 1206 {
1219 GNUNET_break (0); 1207 if (0 == GNUNET_ntohll(elements[i].value))
1220 GNUNET_free (elem); 1208 continue;
1221 continue; 1209 elem = GNUNET_new(struct GNUNET_SCALARPRODUCT_Element);
1210 GNUNET_memcpy(elem,
1211 &elements[i],
1212 sizeof(struct GNUNET_SCALARPRODUCT_Element));
1213 if (GNUNET_SYSERR ==
1214 GNUNET_CONTAINER_multihashmap_put(s->intersected_elements,
1215 &elem->key,
1216 elem,
1217 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1218 {
1219 GNUNET_break(0);
1220 GNUNET_free(elem);
1221 continue;
1222 }
1223 set_elem.data = &elem->key;
1224 set_elem.size = sizeof(elem->key);
1225 set_elem.element_type = 0;
1226 GNUNET_SET_add_element(s->intersection_set,
1227 &set_elem,
1228 NULL, NULL);
1229 s->used_element_count++;
1222 } 1230 }
1223 set_elem.data = &elem->key; 1231 GNUNET_SERVICE_client_continue(s->client);
1224 set_elem.size = sizeof (elem->key);
1225 set_elem.element_type = 0;
1226 GNUNET_SET_add_element (s->intersection_set,
1227 &set_elem,
1228 NULL, NULL);
1229 s->used_element_count++;
1230 }
1231 GNUNET_SERVICE_client_continue (s->client);
1232 /* We're ready, open the port */ 1232 /* We're ready, open the port */
1233 s->port = GNUNET_CADET_open_port (my_cadet, 1233 s->port = GNUNET_CADET_open_port(my_cadet,
1234 &msg->session_key, 1234 &msg->session_key,
1235 &cb_channel_incoming, 1235 &cb_channel_incoming,
1236 s, 1236 s,
1237 NULL, 1237 NULL,
1238 &cb_channel_destruction, 1238 &cb_channel_destruction,
1239 cadet_handlers); 1239 cadet_handlers);
1240 if (NULL == s->port) 1240 if (NULL == s->port)
1241 { 1241 {
1242 GNUNET_break (0); 1242 GNUNET_break(0);
1243 GNUNET_SERVICE_client_drop (s->client); 1243 GNUNET_SERVICE_client_drop(s->client);
1244 return; 1244 return;
1245 } 1245 }
1246} 1246}
1247 1247
1248 1248
@@ -1252,16 +1252,16 @@ handle_bob_client_message (void *cls,
1252 * @param cls unused 1252 * @param cls unused
1253 */ 1253 */
1254static void 1254static void
1255shutdown_task (void *cls) 1255shutdown_task(void *cls)
1256{ 1256{
1257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1257 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1258 "Shutting down, initiating cleanup.\n"); 1258 "Shutting down, initiating cleanup.\n");
1259 // FIXME: we have to cut our connections to CADET first! 1259 // FIXME: we have to cut our connections to CADET first!
1260 if (NULL != my_cadet) 1260 if (NULL != my_cadet)
1261 { 1261 {
1262 GNUNET_CADET_disconnect (my_cadet); 1262 GNUNET_CADET_disconnect(my_cadet);
1263 my_cadet = NULL; 1263 my_cadet = NULL;
1264 } 1264 }
1265} 1265}
1266 1266
1267 1267
@@ -1276,13 +1276,13 @@ shutdown_task (void *cls)
1276 * @return our `struct BobServiceSession` 1276 * @return our `struct BobServiceSession`
1277 */ 1277 */
1278static void * 1278static void *
1279client_connect_cb (void *cls, 1279client_connect_cb(void *cls,
1280 struct GNUNET_SERVICE_Client *client, 1280 struct GNUNET_SERVICE_Client *client,
1281 struct GNUNET_MQ_Handle *mq) 1281 struct GNUNET_MQ_Handle *mq)
1282{ 1282{
1283 struct BobServiceSession *s; 1283 struct BobServiceSession *s;
1284 1284
1285 s = GNUNET_new (struct BobServiceSession); 1285 s = GNUNET_new(struct BobServiceSession);
1286 s->client = client; 1286 s->client = client;
1287 s->client_mq = mq; 1287 s->client_mq = mq;
1288 return s; 1288 return s;
@@ -1300,16 +1300,16 @@ client_connect_cb (void *cls,
1300 * @param app_cls our `struct BobServiceSession` 1300 * @param app_cls our `struct BobServiceSession`
1301 */ 1301 */
1302static void 1302static void
1303client_disconnect_cb (void *cls, 1303client_disconnect_cb(void *cls,
1304 struct GNUNET_SERVICE_Client *client, 1304 struct GNUNET_SERVICE_Client *client,
1305 void *app_cls) 1305 void *app_cls)
1306{ 1306{
1307 struct BobServiceSession *s = app_cls; 1307 struct BobServiceSession *s = app_cls;
1308 1308
1309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1309 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1310 "Client disconnected from us.\n"); 1310 "Client disconnected from us.\n");
1311 s->client = NULL; 1311 s->client = NULL;
1312 destroy_service_session (s); 1312 destroy_service_session(s);
1313} 1313}
1314 1314
1315 1315
@@ -1321,31 +1321,31 @@ client_disconnect_cb (void *cls,
1321 * @param service the initialized service 1321 * @param service the initialized service
1322 */ 1322 */
1323static void 1323static void
1324run (void *cls, 1324run(void *cls,
1325 const struct GNUNET_CONFIGURATION_Handle *c, 1325 const struct GNUNET_CONFIGURATION_Handle *c,
1326 struct GNUNET_SERVICE_Handle *service) 1326 struct GNUNET_SERVICE_Handle *service)
1327{ 1327{
1328 cfg = c; 1328 cfg = c;
1329 /* 1329 /*
1330 offset has to be sufficiently small to allow computation of: 1330 offset has to be sufficiently small to allow computation of:
1331 m1+m2 mod n == (S + a) + (S + b) mod n, 1331 m1+m2 mod n == (S + a) + (S + b) mod n,
1332 if we have more complex operations, this factor needs to be lowered */ 1332 if we have more complex operations, this factor needs to be lowered */
1333 my_offset = gcry_mpi_new (GNUNET_CRYPTO_PAILLIER_BITS / 3); 1333 my_offset = gcry_mpi_new(GNUNET_CRYPTO_PAILLIER_BITS / 3);
1334 gcry_mpi_set_bit (my_offset, 1334 gcry_mpi_set_bit(my_offset,
1335 GNUNET_CRYPTO_PAILLIER_BITS / 3); 1335 GNUNET_CRYPTO_PAILLIER_BITS / 3);
1336 1336
1337 GNUNET_CRYPTO_paillier_create (&my_pubkey, 1337 GNUNET_CRYPTO_paillier_create(&my_pubkey,
1338 &my_privkey); 1338 &my_privkey);
1339 my_cadet = GNUNET_CADET_connect (cfg); 1339 my_cadet = GNUNET_CADET_connect(cfg);
1340 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 1340 GNUNET_SCHEDULER_add_shutdown(&shutdown_task,
1341 NULL); 1341 NULL);
1342 if (NULL == my_cadet) 1342 if (NULL == my_cadet)
1343 { 1343 {
1344 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1344 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1345 _("Connect to CADET failed\n")); 1345 _("Connect to CADET failed\n"));
1346 GNUNET_SCHEDULER_shutdown (); 1346 GNUNET_SCHEDULER_shutdown();
1347 return; 1347 return;
1348 } 1348 }
1349} 1349}
1350 1350
1351 1351
@@ -1353,21 +1353,21 @@ run (void *cls,
1353 * Define "main" method using service macro. 1353 * Define "main" method using service macro.
1354 */ 1354 */
1355GNUNET_SERVICE_MAIN 1355GNUNET_SERVICE_MAIN
1356("scalarproduct-bob", 1356 ("scalarproduct-bob",
1357 GNUNET_SERVICE_OPTION_NONE, 1357 GNUNET_SERVICE_OPTION_NONE,
1358 &run, 1358 &run,
1359 &client_connect_cb, 1359 &client_connect_cb,
1360 &client_disconnect_cb, 1360 &client_disconnect_cb,
1361 NULL, 1361 NULL,
1362 GNUNET_MQ_hd_var_size (bob_client_message, 1362 GNUNET_MQ_hd_var_size(bob_client_message,
1363 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB, 1363 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB,
1364 struct BobComputationMessage, 1364 struct BobComputationMessage,
1365 NULL), 1365 NULL),
1366GNUNET_MQ_hd_var_size (bob_client_message_multipart, 1366 GNUNET_MQ_hd_var_size(bob_client_message_multipart,
1367 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_BOB, 1367 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_BOB,
1368 struct ComputationBobCryptodataMultipartMessage, 1368 struct ComputationBobCryptodataMultipartMessage,
1369 NULL), 1369 NULL),
1370 GNUNET_MQ_handler_end ()); 1370 GNUNET_MQ_handler_end());
1371 1371
1372 1372
1373/* end of gnunet-service-scalarproduct_bob.c */ 1373/* end of gnunet-service-scalarproduct_bob.c */