summaryrefslogtreecommitdiff
path: root/src/scalarproduct/gnunet-service-scalarproduct_alice.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scalarproduct/gnunet-service-scalarproduct_alice.c')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_alice.c1134
1 files changed, 568 insertions, 566 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c
index 6e823dca4..66b01c89e 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c
@@ -37,12 +37,13 @@
37#include "gnunet-service-scalarproduct.h" 37#include "gnunet-service-scalarproduct.h"
38 38
39#define LOG(kind, ...) \ 39#define LOG(kind, ...) \
40 GNUNET_log_from(kind, "scalarproduct-alice", __VA_ARGS__) 40 GNUNET_log_from (kind, "scalarproduct-alice", __VA_ARGS__)
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{
46 /** 47 /**
47 * Key used to identify matching pairs of values to multiply. 48 * Key used to identify matching pairs of values to multiply.
48 * Points into an existing data structure, to avoid copying 49 * Points into an existing data structure, to avoid copying
@@ -61,7 +62,8 @@ struct MpiElement {
61 * A scalarproduct session which tracks 62 * A scalarproduct session which tracks
62 * a request form the client to our final response. 63 * a request form the client to our final response.
63 */ 64 */
64struct AliceServiceSession { 65struct AliceServiceSession
66{
65 /** 67 /**
66 * (hopefully) unique transaction ID 68 * (hopefully) unique transaction ID
67 */ 69 */
@@ -221,11 +223,11 @@ static struct GNUNET_CADET_Handle *my_cadet;
221 * @return #GNUNET_OK (continue to iterate) 223 * @return #GNUNET_OK (continue to iterate)
222 */ 224 */
223static int 225static int
224free_element_cb(void *cls, const struct GNUNET_HashCode *key, void *value) 226free_element_cb (void *cls, const struct GNUNET_HashCode *key, void *value)
225{ 227{
226 struct GNUNET_SCALARPRODUCT_Element *e = value; 228 struct GNUNET_SCALARPRODUCT_Element *e = value;
227 229
228 GNUNET_free(e); 230 GNUNET_free (e);
229 return GNUNET_OK; 231 return GNUNET_OK;
230} 232}
231 233
@@ -236,69 +238,69 @@ free_element_cb(void *cls, const struct GNUNET_HashCode *key, void *value)
236 * @param s the session to free elements from 238 * @param s the session to free elements from
237 */ 239 */
238static void 240static void
239destroy_service_session(struct AliceServiceSession *s) 241destroy_service_session (struct AliceServiceSession *s)
240{ 242{
241 if (GNUNET_YES == s->in_destroy) 243 if (GNUNET_YES == s->in_destroy)
242 return; 244 return;
243 s->in_destroy = GNUNET_YES; 245 s->in_destroy = GNUNET_YES;
244 if (NULL != s->client) 246 if (NULL != s->client)
245 { 247 {
246 struct GNUNET_SERVICE_Client *c = s->client; 248 struct GNUNET_SERVICE_Client *c = s->client;
247 249
248 s->client = NULL; 250 s->client = NULL;
249 GNUNET_SERVICE_client_drop(c); 251 GNUNET_SERVICE_client_drop (c);
250 } 252 }
251 if (NULL != s->channel) 253 if (NULL != s->channel)
252 { 254 {
253 GNUNET_CADET_channel_destroy(s->channel); 255 GNUNET_CADET_channel_destroy (s->channel);
254 s->channel = NULL; 256 s->channel = NULL;
255 } 257 }
256 if (NULL != s->intersected_elements) 258 if (NULL != s->intersected_elements)
257 { 259 {
258 GNUNET_CONTAINER_multihashmap_iterate(s->intersected_elements, 260 GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
259 &free_element_cb, 261 &free_element_cb,
260 s); 262 s);
261 GNUNET_CONTAINER_multihashmap_destroy(s->intersected_elements); 263 GNUNET_CONTAINER_multihashmap_destroy (s->intersected_elements);
262 s->intersected_elements = NULL; 264 s->intersected_elements = NULL;
263 } 265 }
264 if (NULL != s->intersection_listen) 266 if (NULL != s->intersection_listen)
265 { 267 {
266 GNUNET_SET_listen_cancel(s->intersection_listen); 268 GNUNET_SET_listen_cancel (s->intersection_listen);
267 s->intersection_listen = NULL; 269 s->intersection_listen = NULL;
268 } 270 }
269 if (NULL != s->intersection_op) 271 if (NULL != s->intersection_op)
270 { 272 {
271 GNUNET_SET_operation_cancel(s->intersection_op); 273 GNUNET_SET_operation_cancel (s->intersection_op);
272 s->intersection_op = NULL; 274 s->intersection_op = NULL;
273 } 275 }
274 if (NULL != s->intersection_set) 276 if (NULL != s->intersection_set)
275 { 277 {
276 GNUNET_SET_destroy(s->intersection_set); 278 GNUNET_SET_destroy (s->intersection_set);
277 s->intersection_set = NULL; 279 s->intersection_set = NULL;
278 } 280 }
279 if (NULL != s->sorted_elements) 281 if (NULL != s->sorted_elements)
280 { 282 {
281 for (unsigned int i = 0; i < s->used_element_count; i++) 283 for (unsigned int i = 0; i < s->used_element_count; i++)
282 gcry_mpi_release(s->sorted_elements[i].value); 284 gcry_mpi_release (s->sorted_elements[i].value);
283 GNUNET_free(s->sorted_elements); 285 GNUNET_free (s->sorted_elements);
284 s->sorted_elements = NULL; 286 s->sorted_elements = NULL;
285 } 287 }
286 if (NULL != s->r) 288 if (NULL != s->r)
287 { 289 {
288 GNUNET_free(s->r); 290 GNUNET_free (s->r);
289 s->r = NULL; 291 s->r = NULL;
290 } 292 }
291 if (NULL != s->r_prime) 293 if (NULL != s->r_prime)
292 { 294 {
293 GNUNET_free(s->r_prime); 295 GNUNET_free (s->r_prime);
294 s->r_prime = NULL; 296 s->r_prime = NULL;
295 } 297 }
296 if (NULL != s->product) 298 if (NULL != s->product)
297 { 299 {
298 gcry_mpi_release(s->product); 300 gcry_mpi_release (s->product);
299 s->product = NULL; 301 s->product = NULL;
300 } 302 }
301 GNUNET_free(s); 303 GNUNET_free (s);
302} 304}
303 305
304 306
@@ -309,22 +311,22 @@ destroy_service_session(struct AliceServiceSession *s)
309 * @param session the associated client session to fail or succeed 311 * @param session the associated client session to fail or succeed
310 */ 312 */
311static void 313static void
312prepare_client_end_notification(struct AliceServiceSession *session) 314prepare_client_end_notification (struct AliceServiceSession *session)
313{ 315{
314 struct ClientResponseMessage *msg; 316 struct ClientResponseMessage *msg;
315 struct GNUNET_MQ_Envelope *e; 317 struct GNUNET_MQ_Envelope *e;
316 318
317 if (NULL == session->client_mq) 319 if (NULL == session->client_mq)
318 return; /* no client left to be notified */ 320 return; /* no client left to be notified */
319 GNUNET_log( 321 GNUNET_log (
320 GNUNET_ERROR_TYPE_DEBUG, 322 GNUNET_ERROR_TYPE_DEBUG,
321 "Sending session-end notification with status %d to client for session %s\n", 323 "Sending session-end notification with status %d to client for session %s\n",
322 session->status, 324 session->status,
323 GNUNET_h2s(&session->session_id)); 325 GNUNET_h2s (&session->session_id));
324 e = GNUNET_MQ_msg(msg, GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT); 326 e = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT);
325 msg->product_length = htonl(0); 327 msg->product_length = htonl (0);
326 msg->status = htonl(session->status); 328 msg->status = htonl (session->status);
327 GNUNET_MQ_send(session->client_mq, e); 329 GNUNET_MQ_send (session->client_mq, e);
328} 330}
329 331
330 332
@@ -335,7 +337,7 @@ prepare_client_end_notification(struct AliceServiceSession *session)
335 * @param s the session associated with our client. 337 * @param s the session associated with our client.
336 */ 338 */
337static void 339static void
338transmit_client_response(struct AliceServiceSession *s) 340transmit_client_response (struct AliceServiceSession *s)
339{ 341{
340 struct ClientResponseMessage *msg; 342 struct ClientResponseMessage *msg;
341 struct GNUNET_MQ_Envelope *e; 343 struct GNUNET_MQ_Envelope *e;
@@ -347,56 +349,56 @@ transmit_client_response(struct AliceServiceSession *s)
347 gcry_mpi_t value; 349 gcry_mpi_t value;
348 350
349 if (NULL == s->product) 351 if (NULL == s->product)
350 { 352 {
351 GNUNET_break(0); 353 GNUNET_break (0);
352 prepare_client_end_notification(s); 354 prepare_client_end_notification (s);
353 return; 355 return;
354 } 356 }
355 value = gcry_mpi_new(0); 357 value = gcry_mpi_new (0);
356 sign = gcry_mpi_cmp_ui(s->product, 0); 358 sign = gcry_mpi_cmp_ui (s->product, 0);
357 if (0 > sign) 359 if (0 > sign)
358 { 360 {
359 range = -1; 361 range = -1;
360 gcry_mpi_sub(value, value, s->product); 362 gcry_mpi_sub (value, value, s->product);
361 } 363 }
362 else if (0 < sign) 364 else if (0 < sign)
363 { 365 {
364 range = 1; 366 range = 1;
365 gcry_mpi_add(value, value, s->product); 367 gcry_mpi_add (value, value, s->product);
366 } 368 }
367 else 369 else
368 { 370 {
369 /* result is exactly zero */ 371 /* result is exactly zero */
370 range = 0; 372 range = 0;
371 } 373 }
372 gcry_mpi_release(s->product); 374 gcry_mpi_release (s->product);
373 s->product = NULL; 375 s->product = NULL;
374 376
375 if ((0 != range) && (0 != (rc = gcry_mpi_aprint(GCRYMPI_FMT_STD, 377 if ((0 != range) && (0 != (rc = gcry_mpi_aprint (GCRYMPI_FMT_STD,
376 &product_exported, 378 &product_exported,
377 &product_length, 379 &product_length,
378 value)))) 380 value))))
379 { 381 {
380 LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); 382 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
381 prepare_client_end_notification(s); 383 prepare_client_end_notification (s);
382 return; 384 return;
383 } 385 }
384 gcry_mpi_release(value); 386 gcry_mpi_release (value);
385 e = GNUNET_MQ_msg_extra(msg, 387 e = GNUNET_MQ_msg_extra (msg,
386 product_length, 388 product_length,
387 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT); 389 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT);
388 msg->status = htonl(GNUNET_SCALARPRODUCT_STATUS_SUCCESS); 390 msg->status = htonl (GNUNET_SCALARPRODUCT_STATUS_SUCCESS);
389 msg->range = htonl(range); 391 msg->range = htonl (range);
390 msg->product_length = htonl(product_length); 392 msg->product_length = htonl (product_length);
391 if (NULL != product_exported) 393 if (NULL != product_exported)
392 { 394 {
393 GNUNET_memcpy(&msg[1], product_exported, product_length); 395 GNUNET_memcpy (&msg[1], product_exported, product_length);
394 GNUNET_free(product_exported); 396 GNUNET_free (product_exported);
395 } 397 }
396 GNUNET_MQ_send(s->client_mq, e); 398 GNUNET_MQ_send (s->client_mq, e);
397 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
398 "Sent result to client, session %s has ended!\n", 400 "Sent result to client, session %s has ended!\n",
399 GNUNET_h2s(&s->session_id)); 401 GNUNET_h2s (&s->session_id));
400} 402}
401 403
402 404
@@ -410,20 +412,20 @@ transmit_client_response(struct AliceServiceSession *s)
410 * @param channel connection to the other end (henceforth invalid) 412 * @param channel connection to the other end (henceforth invalid)
411 */ 413 */
412static void 414static void
413cb_channel_destruction(void *cls, const struct GNUNET_CADET_Channel *channel) 415cb_channel_destruction (void *cls, const struct GNUNET_CADET_Channel *channel)
414{ 416{
415 struct AliceServiceSession *s = cls; 417 struct AliceServiceSession *s = cls;
416 418
417 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
418 "Peer disconnected, terminating session %s with peer %s\n", 420 "Peer disconnected, terminating session %s with peer %s\n",
419 GNUNET_h2s(&s->session_id), 421 GNUNET_h2s (&s->session_id),
420 GNUNET_i2s(&s->peer)); 422 GNUNET_i2s (&s->peer));
421 if (GNUNET_SCALARPRODUCT_STATUS_ACTIVE == s->status) 423 if (GNUNET_SCALARPRODUCT_STATUS_ACTIVE == s->status)
422 { 424 {
423 /* We didn't get an answer yet, fail with error */ 425 /* We didn't get an answer yet, fail with error */
424 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; 426 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
425 prepare_client_end_notification(s); 427 prepare_client_end_notification (s);
426 } 428 }
427 s->channel = NULL; 429 s->channel = NULL;
428} 430}
429 431
@@ -436,21 +438,21 @@ cb_channel_destruction(void *cls, const struct GNUNET_CADET_Channel *channel)
436 * @return an MPI value containing the calculated sum, never NULL 438 * @return an MPI value containing the calculated sum, never NULL
437 */ 439 */
438static gcry_mpi_t 440static gcry_mpi_t
439compute_square_sum_mpi_elements(const struct MpiElement *vector, 441compute_square_sum_mpi_elements (const struct MpiElement *vector,
440 uint32_t length) 442 uint32_t length)
441{ 443{
442 gcry_mpi_t elem; 444 gcry_mpi_t elem;
443 gcry_mpi_t sum; 445 gcry_mpi_t sum;
444 uint32_t i; 446 uint32_t i;
445 447
446 GNUNET_assert(NULL != (sum = gcry_mpi_new(0))); 448 GNUNET_assert (NULL != (sum = gcry_mpi_new (0)));
447 GNUNET_assert(NULL != (elem = gcry_mpi_new(0))); 449 GNUNET_assert (NULL != (elem = gcry_mpi_new (0)));
448 for (i = 0; i < length; i++) 450 for (i = 0; i < length; i++)
449 { 451 {
450 gcry_mpi_mul(elem, vector[i].value, vector[i].value); 452 gcry_mpi_mul (elem, vector[i].value, vector[i].value);
451 gcry_mpi_add(sum, sum, elem); 453 gcry_mpi_add (sum, sum, elem);
452 } 454 }
453 gcry_mpi_release(elem); 455 gcry_mpi_release (elem);
454 return sum; 456 return sum;
455} 457}
456 458
@@ -463,20 +465,20 @@ compute_square_sum_mpi_elements(const struct MpiElement *vector,
463 * @return an MPI value containing the calculated sum, never NULL 465 * @return an MPI value containing the calculated sum, never NULL
464 */ 466 */
465static gcry_mpi_t 467static gcry_mpi_t
466compute_square_sum(const gcry_mpi_t *vector, uint32_t length) 468compute_square_sum (const gcry_mpi_t *vector, uint32_t length)
467{ 469{
468 gcry_mpi_t elem; 470 gcry_mpi_t elem;
469 gcry_mpi_t sum; 471 gcry_mpi_t sum;
470 uint32_t i; 472 uint32_t i;
471 473
472 GNUNET_assert(NULL != (sum = gcry_mpi_new(0))); 474 GNUNET_assert (NULL != (sum = gcry_mpi_new (0)));
473 GNUNET_assert(NULL != (elem = gcry_mpi_new(0))); 475 GNUNET_assert (NULL != (elem = gcry_mpi_new (0)));
474 for (i = 0; i < length; i++) 476 for (i = 0; i < length; i++)
475 { 477 {
476 gcry_mpi_mul(elem, vector[i], vector[i]); 478 gcry_mpi_mul (elem, vector[i], vector[i]);
477 gcry_mpi_add(sum, sum, elem); 479 gcry_mpi_add (sum, sum, elem);
478 } 480 }
479 gcry_mpi_release(elem); 481 gcry_mpi_release (elem);
480 return sum; 482 return sum;
481} 483}
482 484
@@ -488,7 +490,7 @@ compute_square_sum(const gcry_mpi_t *vector, uint32_t length)
488 * @return product as MPI, never NULL 490 * @return product as MPI, never NULL
489 */ 491 */
490static gcry_mpi_t 492static gcry_mpi_t
491compute_scalar_product(struct AliceServiceSession *session) 493compute_scalar_product (struct AliceServiceSession *session)
492{ 494{
493 uint32_t count; 495 uint32_t count;
494 gcry_mpi_t t; 496 gcry_mpi_t t;
@@ -508,80 +510,80 @@ compute_scalar_product(struct AliceServiceSession *session)
508 // from the E(a_pi)(+)E(-b_pi-r_pi) and E(a_qi)(+)E(-r_qi) twice each, 510 // from the E(a_pi)(+)E(-b_pi-r_pi) and E(a_qi)(+)E(-r_qi) twice each,
509 // the result is E((S + a_pi) + (S -b_pi-r_pi)) and E(S + a_qi + S - r_qi) 511 // the result is E((S + a_pi) + (S -b_pi-r_pi)) and E(S + a_qi + S - r_qi)
510 for (i = 0; i < count; i++) 512 for (i = 0; i < count; i++)
511 { 513 {
512 r[i] = gcry_mpi_new(0); 514 r[i] = gcry_mpi_new (0);
513 GNUNET_CRYPTO_paillier_decrypt(&my_privkey, 515 GNUNET_CRYPTO_paillier_decrypt (&my_privkey,
514 &my_pubkey, 516 &my_pubkey,
515 &session->r[i], 517 &session->r[i],
516 r[i]); 518 r[i]);
517 gcry_mpi_sub(r[i], r[i], my_offset); 519 gcry_mpi_sub (r[i], r[i], my_offset);
518 gcry_mpi_sub(r[i], r[i], my_offset); 520 gcry_mpi_sub (r[i], r[i], my_offset);
519 r_prime[i] = gcry_mpi_new(0); 521 r_prime[i] = gcry_mpi_new (0);
520 GNUNET_CRYPTO_paillier_decrypt(&my_privkey, 522 GNUNET_CRYPTO_paillier_decrypt (&my_privkey,
521 &my_pubkey, 523 &my_pubkey,
522 &session->r_prime[i], 524 &session->r_prime[i],
523 r_prime[i]); 525 r_prime[i]);
524 gcry_mpi_sub(r_prime[i], r_prime[i], my_offset); 526 gcry_mpi_sub (r_prime[i], r_prime[i], my_offset);
525 gcry_mpi_sub(r_prime[i], r_prime[i], my_offset); 527 gcry_mpi_sub (r_prime[i], r_prime[i], my_offset);
526 } 528 }
527 529
528 // calculate t = sum(ai) 530 // calculate t = sum(ai)
529 t = compute_square_sum_mpi_elements(session->sorted_elements, count); 531 t = compute_square_sum_mpi_elements (session->sorted_elements, count);
530 // calculate U 532 // calculate U
531 u = gcry_mpi_new(0); 533 u = gcry_mpi_new (0);
532 tmp = compute_square_sum(r, count); 534 tmp = compute_square_sum (r, count);
533 gcry_mpi_sub(u, u, tmp); 535 gcry_mpi_sub (u, u, tmp);
534 gcry_mpi_release(tmp); 536 gcry_mpi_release (tmp);
535 537
536 //calculate U' 538 // calculate U'
537 u_prime = gcry_mpi_new(0); 539 u_prime = gcry_mpi_new (0);
538 tmp = compute_square_sum(r_prime, count); 540 tmp = compute_square_sum (r_prime, count);
539 gcry_mpi_sub(u_prime, u_prime, tmp); 541 gcry_mpi_sub (u_prime, u_prime, tmp);
540 542
541 GNUNET_assert(p = gcry_mpi_new(0)); 543 GNUNET_assert (p = gcry_mpi_new (0));
542 GNUNET_assert(p_prime = gcry_mpi_new(0)); 544 GNUNET_assert (p_prime = gcry_mpi_new (0));
543 GNUNET_assert(s = gcry_mpi_new(0)); 545 GNUNET_assert (s = gcry_mpi_new (0));
544 GNUNET_assert(s_prime = gcry_mpi_new(0)); 546 GNUNET_assert (s_prime = gcry_mpi_new (0));
545 547
546 // compute P 548 // compute P
547 GNUNET_CRYPTO_paillier_decrypt(&my_privkey, &my_pubkey, &session->s, s); 549 GNUNET_CRYPTO_paillier_decrypt (&my_privkey, &my_pubkey, &session->s, s);
548 GNUNET_CRYPTO_paillier_decrypt(&my_privkey, 550 GNUNET_CRYPTO_paillier_decrypt (&my_privkey,
549 &my_pubkey, 551 &my_pubkey,
550 &session->s_prime, 552 &session->s_prime,
551 s_prime); 553 s_prime);
552 554
553 // compute P 555 // compute P
554 gcry_mpi_add(p, s, t); 556 gcry_mpi_add (p, s, t);
555 gcry_mpi_add(p, p, u); 557 gcry_mpi_add (p, p, u);
556 558
557 // compute P' 559 // compute P'
558 gcry_mpi_add(p_prime, s_prime, t); 560 gcry_mpi_add (p_prime, s_prime, t);
559 gcry_mpi_add(p_prime, p_prime, u_prime); 561 gcry_mpi_add (p_prime, p_prime, u_prime);
560 562
561 gcry_mpi_release(t); 563 gcry_mpi_release (t);
562 gcry_mpi_release(u); 564 gcry_mpi_release (u);
563 gcry_mpi_release(u_prime); 565 gcry_mpi_release (u_prime);
564 gcry_mpi_release(s); 566 gcry_mpi_release (s);
565 gcry_mpi_release(s_prime); 567 gcry_mpi_release (s_prime);
566 568
567 // compute product 569 // compute product
568 gcry_mpi_sub(p, p, p_prime); 570 gcry_mpi_sub (p, p, p_prime);
569 gcry_mpi_release(p_prime); 571 gcry_mpi_release (p_prime);
570 tmp = gcry_mpi_set_ui(tmp, 2); 572 tmp = gcry_mpi_set_ui (tmp, 2);
571 gcry_mpi_div(p, NULL, p, tmp, 0); 573 gcry_mpi_div (p, NULL, p, tmp, 0);
572 574
573 gcry_mpi_release(tmp); 575 gcry_mpi_release (tmp);
574 for (i = 0; i < count; i++) 576 for (i = 0; i < count; i++)
575 { 577 {
576 gcry_mpi_release(session->sorted_elements[i].value); 578 gcry_mpi_release (session->sorted_elements[i].value);
577 gcry_mpi_release(r[i]); 579 gcry_mpi_release (r[i]);
578 gcry_mpi_release(r_prime[i]); 580 gcry_mpi_release (r_prime[i]);
579 } 581 }
580 GNUNET_free(session->sorted_elements); 582 GNUNET_free (session->sorted_elements);
581 session->sorted_elements = NULL; 583 session->sorted_elements = NULL;
582 GNUNET_free(session->r); 584 GNUNET_free (session->r);
583 session->r = NULL; 585 session->r = NULL;
584 GNUNET_free(session->r_prime); 586 GNUNET_free (session->r_prime);
585 session->r_prime = NULL; 587 session->r_prime = NULL;
586 588
587 return p; 589 return p;
@@ -598,7 +600,7 @@ compute_scalar_product(struct AliceServiceSession *session)
598 * #GNUNET_SYSERR to close it (signal serious error) 600 * #GNUNET_SYSERR to close it (signal serious error)
599 */ 601 */
600static int 602static int
601check_bobs_cryptodata_multipart( 603check_bobs_cryptodata_multipart (
602 void *cls, 604 void *cls,
603 const struct BobCryptodataMultipartMessage *msg) 605 const struct BobCryptodataMultipartMessage *msg)
604{ 606{
@@ -607,17 +609,17 @@ check_bobs_cryptodata_multipart(
607 size_t msg_size; 609 size_t msg_size;
608 size_t required_size; 610 size_t required_size;
609 611
610 msg_size = ntohs(msg->header.size); 612 msg_size = ntohs (msg->header.size);
611 contained = ntohl(msg->contained_element_count); 613 contained = ntohl (msg->contained_element_count);
612 required_size = 614 required_size =
613 sizeof(struct BobCryptodataMultipartMessage) + 615 sizeof(struct BobCryptodataMultipartMessage)
614 2 * contained * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext); 616 + 2 * contained * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext);
615 if ((required_size != msg_size) || 617 if ((required_size != msg_size) ||
616 (s->cadet_received_element_count + contained > s->used_element_count)) 618 (s->cadet_received_element_count + contained > s->used_element_count))
617 { 619 {
618 GNUNET_break(0); 620 GNUNET_break (0);
619 return GNUNET_SYSERR; 621 return GNUNET_SYSERR;
620 } 622 }
621 return GNUNET_OK; 623 return GNUNET_OK;
622} 624}
623 625
@@ -629,7 +631,7 @@ check_bobs_cryptodata_multipart(
629 * @param msg the actual message 631 * @param msg the actual message
630 */ 632 */
631static void 633static void
632handle_bobs_cryptodata_multipart( 634handle_bobs_cryptodata_multipart (
633 void *cls, 635 void *cls,
634 const struct BobCryptodataMultipartMessage *msg) 636 const struct BobCryptodataMultipartMessage *msg)
635{ 637{
@@ -638,29 +640,29 @@ handle_bobs_cryptodata_multipart(
638 size_t i; 640 size_t i;
639 uint32_t contained; 641 uint32_t contained;
640 642
641 contained = ntohl(msg->contained_element_count); 643 contained = ntohl (msg->contained_element_count);
642 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 644 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
643 "Received %u additional crypto values from Bob\n", 645 "Received %u additional crypto values from Bob\n",
644 (unsigned int)contained); 646 (unsigned int) contained);
645 647
646 payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *)&msg[1]; 648 payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
647 /* Convert each k[][perm] to its MPI_value */ 649 /* Convert each k[][perm] to its MPI_value */
648 for (i = 0; i < contained; i++) 650 for (i = 0; i < contained; i++)
649 { 651 {
650 GNUNET_memcpy(&s->r[s->cadet_received_element_count + i], 652 GNUNET_memcpy (&s->r[s->cadet_received_element_count + i],
651 &payload[2 * i], 653 &payload[2 * i],
652 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext)); 654 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
653 GNUNET_memcpy(&s->r_prime[s->cadet_received_element_count + i], 655 GNUNET_memcpy (&s->r_prime[s->cadet_received_element_count + i],
654 &payload[2 * i], 656 &payload[2 * i],
655 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext)); 657 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
656 } 658 }
657 s->cadet_received_element_count += contained; 659 s->cadet_received_element_count += contained;
658 GNUNET_CADET_receive_done(s->channel); 660 GNUNET_CADET_receive_done (s->channel);
659 if (s->cadet_received_element_count != s->used_element_count) 661 if (s->cadet_received_element_count != s->used_element_count)
660 return; /* more to come */ 662 return; /* more to come */
661 663
662 s->product = compute_scalar_product(s); 664 s->product = compute_scalar_product (s);
663 transmit_client_response(s); 665 transmit_client_response (s);
664} 666}
665 667
666 668
@@ -674,38 +676,38 @@ handle_bobs_cryptodata_multipart(
674 * #GNUNET_SYSERR to close it (we are done) 676 * #GNUNET_SYSERR to close it (we are done)
675 */ 677 */
676static int 678static int
677check_bobs_cryptodata_message(void *cls, 679check_bobs_cryptodata_message (void *cls,
678 const struct BobCryptodataMessage *msg) 680 const struct BobCryptodataMessage *msg)
679{ 681{
680 struct AliceServiceSession *s = cls; 682 struct AliceServiceSession *s = cls;
681 uint32_t contained; 683 uint32_t contained;
682 uint16_t msg_size; 684 uint16_t msg_size;
683 size_t required_size; 685 size_t required_size;
684 686
685 msg_size = ntohs(msg->header.size); 687 msg_size = ntohs (msg->header.size);
686 contained = ntohl(msg->contained_element_count); 688 contained = ntohl (msg->contained_element_count);
687 required_size = 689 required_size =
688 sizeof(struct BobCryptodataMessage) + 690 sizeof(struct BobCryptodataMessage)
689 2 * contained * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext) + 691 + 2 * contained * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext)
690 2 * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext); 692 + 2 * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext);
691 if ((msg_size != required_size) || (contained > UINT16_MAX) || 693 if ((msg_size != required_size) || (contained > UINT16_MAX) ||
692 (s->used_element_count < contained)) 694 (s->used_element_count < contained))
693 { 695 {
694 GNUNET_break_op(0); 696 GNUNET_break_op (0);
695 return GNUNET_SYSERR; 697 return GNUNET_SYSERR;
696 } 698 }
697 if (NULL == s->sorted_elements) 699 if (NULL == s->sorted_elements)
698 { 700 {
699 /* we're not ready yet, how can Bob be? */ 701 /* we're not ready yet, how can Bob be? */
700 GNUNET_break_op(0); 702 GNUNET_break_op (0);
701 return GNUNET_SYSERR; 703 return GNUNET_SYSERR;
702 } 704 }
703 if (s->total != s->client_received_element_count) 705 if (s->total != s->client_received_element_count)
704 { 706 {
705 /* we're not ready yet, how can Bob be? */ 707 /* we're not ready yet, how can Bob be? */
706 GNUNET_break_op(0); 708 GNUNET_break_op (0);
707 return GNUNET_SYSERR; 709 return GNUNET_SYSERR;
708 } 710 }
709 return GNUNET_OK; 711 return GNUNET_OK;
710} 712}
711 713
@@ -718,50 +720,50 @@ check_bobs_cryptodata_message(void *cls,
718 * @param msg the actual message 720 * @param msg the actual message
719 */ 721 */
720static void 722static void
721handle_bobs_cryptodata_message(void *cls, 723handle_bobs_cryptodata_message (void *cls,
722 const struct BobCryptodataMessage *msg) 724 const struct BobCryptodataMessage *msg)
723{ 725{
724 struct AliceServiceSession *s = cls; 726 struct AliceServiceSession *s = cls;
725 const struct GNUNET_CRYPTO_PaillierCiphertext *payload; 727 const struct GNUNET_CRYPTO_PaillierCiphertext *payload;
726 uint32_t i; 728 uint32_t i;
727 uint32_t contained; 729 uint32_t contained;
728 730
729 contained = ntohl(msg->contained_element_count); 731 contained = ntohl (msg->contained_element_count);
730 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 732 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
731 "Received %u crypto values from Bob\n", 733 "Received %u crypto values from Bob\n",
732 (unsigned int)contained); 734 (unsigned int) contained);
733 payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *)&msg[1]; 735 payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
734 GNUNET_memcpy(&s->s, 736 GNUNET_memcpy (&s->s,
735 &payload[0], 737 &payload[0],
736 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext)); 738 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
737 GNUNET_memcpy(&s->s_prime, 739 GNUNET_memcpy (&s->s_prime,
738 &payload[1], 740 &payload[1],
739 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext)); 741 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
740 payload = &payload[2]; 742 payload = &payload[2];
741 743
742 s->r = GNUNET_new_array(s->used_element_count, 744 s->r = GNUNET_new_array (s->used_element_count,
743 struct GNUNET_CRYPTO_PaillierCiphertext); 745 struct GNUNET_CRYPTO_PaillierCiphertext);
744 s->r_prime = GNUNET_new_array(s->used_element_count, 746 s->r_prime = GNUNET_new_array (s->used_element_count,
745 struct GNUNET_CRYPTO_PaillierCiphertext); 747 struct GNUNET_CRYPTO_PaillierCiphertext);
746 for (i = 0; i < contained; i++) 748 for (i = 0; i < contained; i++)
747 { 749 {
748 GNUNET_memcpy(&s->r[i], 750 GNUNET_memcpy (&s->r[i],
749 &payload[2 * i], 751 &payload[2 * i],
750 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext)); 752 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
751 GNUNET_memcpy(&s->r_prime[i], 753 GNUNET_memcpy (&s->r_prime[i],
752 &payload[2 * i + 1], 754 &payload[2 * i + 1],
753 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext)); 755 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext));
754 } 756 }
755 s->cadet_received_element_count = contained; 757 s->cadet_received_element_count = contained;
756 GNUNET_CADET_receive_done(s->channel); 758 GNUNET_CADET_receive_done (s->channel);
757 759
758 if (s->cadet_received_element_count != s->used_element_count) 760 if (s->cadet_received_element_count != s->used_element_count)
759 { 761 {
760 /* More to come */ 762 /* More to come */
761 return; 763 return;
762 } 764 }
763 s->product = compute_scalar_product(s); 765 s->product = compute_scalar_product (s);
764 transmit_client_response(s); 766 transmit_client_response (s);
765} 767}
766 768
767 769
@@ -774,19 +776,19 @@ handle_bobs_cryptodata_message(void *cls,
774 * @param value the `struct GNUNET_SCALARPRODUCT_Element *` 776 * @param value the `struct GNUNET_SCALARPRODUCT_Element *`
775 */ 777 */
776static int 778static int
777copy_element_cb(void *cls, const struct GNUNET_HashCode *key, void *value) 779copy_element_cb (void *cls, const struct GNUNET_HashCode *key, void *value)
778{ 780{
779 struct AliceServiceSession *s = cls; 781 struct AliceServiceSession *s = cls;
780 struct GNUNET_SCALARPRODUCT_Element *e = value; 782 struct GNUNET_SCALARPRODUCT_Element *e = value;
781 gcry_mpi_t mval; 783 gcry_mpi_t mval;
782 int64_t val; 784 int64_t val;
783 785
784 mval = gcry_mpi_new(0); 786 mval = gcry_mpi_new (0);
785 val = (int64_t)GNUNET_ntohll(e->value); 787 val = (int64_t) GNUNET_ntohll (e->value);
786 if (0 > val) 788 if (0 > val)
787 gcry_mpi_sub_ui(mval, mval, -val); 789 gcry_mpi_sub_ui (mval, mval, -val);
788 else 790 else
789 gcry_mpi_add_ui(mval, mval, val); 791 gcry_mpi_add_ui (mval, mval, val);
790 s->sorted_elements[s->used_element_count].value = mval; 792 s->sorted_elements[s->used_element_count].value = mval;
791 s->sorted_elements[s->used_element_count].key = &e->key; 793 s->sorted_elements[s->used_element_count].key = &e->key;
792 s->used_element_count++; 794 s->used_element_count++;
@@ -802,12 +804,12 @@ copy_element_cb(void *cls, const struct GNUNET_HashCode *key, void *value)
802 * @return -1 for a < b, 0 for a=b, 1 for a > b. 804 * @return -1 for a < b, 0 for a=b, 1 for a > b.
803 */ 805 */
804static int 806static int
805element_cmp(const void *a, const void *b) 807element_cmp (const void *a, const void *b)
806{ 808{
807 const struct MpiElement *ma = a; 809 const struct MpiElement *ma = a;
808 const struct MpiElement *mb = b; 810 const struct MpiElement *mb = b;
809 811
810 return GNUNET_CRYPTO_hash_cmp(ma->key, mb->key); 812 return GNUNET_CRYPTO_hash_cmp (ma->key, mb->key);
811} 813}
812 814
813 815
@@ -816,9 +818,9 @@ element_cmp(const void *a, const void *b)
816 * message 818 * message
817 */ 819 */
818#define ELEMENT_CAPACITY \ 820#define ELEMENT_CAPACITY \
819 ((GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE - 1 - \ 821 ((GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE - 1 \
820 sizeof(struct AliceCryptodataMessage)) / \ 822 - sizeof(struct AliceCryptodataMessage)) \
821 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext)) 823 / sizeof(struct GNUNET_CRYPTO_PaillierCiphertext))
822 824
823 825
824/** 826/**
@@ -828,7 +830,7 @@ element_cmp(const void *a, const void *b)
828 * @param s the associated service session 830 * @param s the associated service session
829 */ 831 */
830static void 832static void
831send_alices_cryptodata_message(struct AliceServiceSession *s) 833send_alices_cryptodata_message (struct AliceServiceSession *s)
832{ 834{
833 struct AliceCryptodataMessage *msg; 835 struct AliceCryptodataMessage *msg;
834 struct GNUNET_MQ_Envelope *e; 836 struct GNUNET_MQ_Envelope *e;
@@ -838,50 +840,50 @@ send_alices_cryptodata_message(struct AliceServiceSession *s)
838 gcry_mpi_t a; 840 gcry_mpi_t a;
839 uint32_t off; 841 uint32_t off;
840 842
841 s->sorted_elements = GNUNET_malloc( 843 s->sorted_elements = GNUNET_malloc (
842 GNUNET_CONTAINER_multihashmap_size(s->intersected_elements) * 844 GNUNET_CONTAINER_multihashmap_size (s->intersected_elements)
843 sizeof(struct MpiElement)); 845 * sizeof(struct MpiElement));
844 s->used_element_count = 0; 846 s->used_element_count = 0;
845 GNUNET_CONTAINER_multihashmap_iterate(s->intersected_elements, 847 GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
846 &copy_element_cb, 848 &copy_element_cb,
847 s); 849 s);
848 LOG(GNUNET_ERROR_TYPE_DEBUG, 850 LOG (GNUNET_ERROR_TYPE_DEBUG,
849 "Finished intersection, %d items remain\n", 851 "Finished intersection, %d items remain\n",
850 s->used_element_count); 852 s->used_element_count);
851 qsort(s->sorted_elements, 853 qsort (s->sorted_elements,
852 s->used_element_count, 854 s->used_element_count,
853 sizeof(struct MpiElement), 855 sizeof(struct MpiElement),
854 &element_cmp); 856 &element_cmp);
855 off = 0; 857 off = 0;
856 while (off < s->used_element_count) 858 while (off < s->used_element_count)
859 {
860 todo_count = s->used_element_count - off;
861 if (todo_count > ELEMENT_CAPACITY)
862 todo_count = ELEMENT_CAPACITY;
863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
864 "Sending %u/%u crypto values to Bob\n",
865 (unsigned int) todo_count,
866 (unsigned int) s->used_element_count);
867
868 e =
869 GNUNET_MQ_msg_extra (msg,
870 todo_count
871 * sizeof(struct GNUNET_CRYPTO_PaillierCiphertext),
872 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_CRYPTODATA);
873 msg->contained_element_count = htonl (todo_count);
874 payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1];
875 a = gcry_mpi_new (0);
876 for (i = off; i < off + todo_count; i++)
857 { 877 {
858 todo_count = s->used_element_count - off; 878 gcry_mpi_add (a, s->sorted_elements[i].value, my_offset);
859 if (todo_count > ELEMENT_CAPACITY) 879 GNUNET_assert (
860 todo_count = ELEMENT_CAPACITY; 880 3 ==
861 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 881 GNUNET_CRYPTO_paillier_encrypt (&my_pubkey, a, 3, &payload[i - off]));
862 "Sending %u/%u crypto values to Bob\n",
863 (unsigned int)todo_count,
864 (unsigned int)s->used_element_count);
865
866 e =
867 GNUNET_MQ_msg_extra(msg,
868 todo_count *
869 sizeof(struct GNUNET_CRYPTO_PaillierCiphertext),
870 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_CRYPTODATA);
871 msg->contained_element_count = htonl(todo_count);
872 payload = (struct GNUNET_CRYPTO_PaillierCiphertext *)&msg[1];
873 a = gcry_mpi_new(0);
874 for (i = off; i < off + todo_count; i++)
875 {
876 gcry_mpi_add(a, s->sorted_elements[i].value, my_offset);
877 GNUNET_assert(
878 3 ==
879 GNUNET_CRYPTO_paillier_encrypt(&my_pubkey, a, 3, &payload[i - off]));
880 }
881 gcry_mpi_release(a);
882 off += todo_count;
883 GNUNET_MQ_send(s->cadet_mq, e);
884 } 882 }
883 gcry_mpi_release (a);
884 off += todo_count;
885 GNUNET_MQ_send (s->cadet_mq, e);
886 }
885} 887}
886 888
887 889
@@ -896,70 +898,70 @@ send_alices_cryptodata_message(struct AliceServiceSession *s)
896 * @param status what has happened with the set intersection? 898 * @param status what has happened with the set intersection?
897 */ 899 */
898static void 900static void
899cb_intersection_element_removed(void *cls, 901cb_intersection_element_removed (void *cls,
900 const struct GNUNET_SET_Element *element, 902 const struct GNUNET_SET_Element *element,
901 uint64_t current_size, 903 uint64_t current_size,
902 enum GNUNET_SET_Status status) 904 enum GNUNET_SET_Status status)
903{ 905{
904 struct AliceServiceSession *s = cls; 906 struct AliceServiceSession *s = cls;
905 struct GNUNET_SCALARPRODUCT_Element *se; 907 struct GNUNET_SCALARPRODUCT_Element *se;
906 908
907 switch (status) 909 switch (status)
910 {
911 case GNUNET_SET_STATUS_OK:
912 /* this element has been removed from the set */
913 se = GNUNET_CONTAINER_multihashmap_get (s->intersected_elements,
914 element->data);
915 GNUNET_assert (NULL != se);
916 LOG (GNUNET_ERROR_TYPE_DEBUG,
917 "Intersection removed element with key %s and value %lld\n",
918 GNUNET_h2s (&se->key),
919 (long long) GNUNET_ntohll (se->value));
920 GNUNET_assert (
921 GNUNET_YES ==
922 GNUNET_CONTAINER_multihashmap_remove (s->intersected_elements,
923 element->data,
924 se));
925 GNUNET_free (se);
926 return;
927
928 case GNUNET_SET_STATUS_DONE:
929 s->intersection_op = NULL;
930 if (NULL != s->intersection_set)
908 { 931 {
909 case GNUNET_SET_STATUS_OK: 932 GNUNET_SET_destroy (s->intersection_set);
910 /* this element has been removed from the set */ 933 s->intersection_set = NULL;
911 se = GNUNET_CONTAINER_multihashmap_get(s->intersected_elements,
912 element->data);
913 GNUNET_assert(NULL != se);
914 LOG(GNUNET_ERROR_TYPE_DEBUG,
915 "Intersection removed element with key %s and value %lld\n",
916 GNUNET_h2s(&se->key),
917 (long long)GNUNET_ntohll(se->value));
918 GNUNET_assert(
919 GNUNET_YES ==
920 GNUNET_CONTAINER_multihashmap_remove(s->intersected_elements,
921 element->data,
922 se));
923 GNUNET_free(se);
924 return;
925
926 case GNUNET_SET_STATUS_DONE:
927 s->intersection_op = NULL;
928 if (NULL != s->intersection_set)
929 {
930 GNUNET_SET_destroy(s->intersection_set);
931 s->intersection_set = NULL;
932 }
933 send_alices_cryptodata_message(s);
934 return;
935
936 case GNUNET_SET_STATUS_HALF_DONE:
937 /* unexpected for intersection */
938 GNUNET_break(0);
939 return;
940
941 case GNUNET_SET_STATUS_FAILURE:
942 /* unhandled status code */
943 LOG(GNUNET_ERROR_TYPE_DEBUG, "Set intersection failed!\n");
944 if (NULL != s->intersection_listen)
945 {
946 GNUNET_SET_listen_cancel(s->intersection_listen);
947 s->intersection_listen = NULL;
948 }
949 s->intersection_op = NULL;
950 if (NULL != s->intersection_set)
951 {
952 GNUNET_SET_destroy(s->intersection_set);
953 s->intersection_set = NULL;
954 }
955 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
956 prepare_client_end_notification(s);
957 return;
958
959 default:
960 GNUNET_break(0);
961 return;
962 } 934 }
935 send_alices_cryptodata_message (s);
936 return;
937
938 case GNUNET_SET_STATUS_HALF_DONE:
939 /* unexpected for intersection */
940 GNUNET_break (0);
941 return;
942
943 case GNUNET_SET_STATUS_FAILURE:
944 /* unhandled status code */
945 LOG (GNUNET_ERROR_TYPE_DEBUG, "Set intersection failed!\n");
946 if (NULL != s->intersection_listen)
947 {
948 GNUNET_SET_listen_cancel (s->intersection_listen);
949 s->intersection_listen = NULL;
950 }
951 s->intersection_op = NULL;
952 if (NULL != s->intersection_set)
953 {
954 GNUNET_SET_destroy (s->intersection_set);
955 s->intersection_set = NULL;
956 }
957 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
958 prepare_client_end_notification (s);
959 return;
960
961 default:
962 GNUNET_break (0);
963 return;
964 }
963} 965}
964 966
965 967
@@ -979,37 +981,37 @@ cb_intersection_element_removed(void *cls,
979 * message. It's necessary to specify the timeout. 981 * message. It's necessary to specify the timeout.
980 */ 982 */
981static void 983static void
982cb_intersection_request_alice(void *cls, 984cb_intersection_request_alice (void *cls,
983 const struct GNUNET_PeerIdentity *other_peer, 985 const struct GNUNET_PeerIdentity *other_peer,
984 const struct GNUNET_MessageHeader *context_msg, 986 const struct GNUNET_MessageHeader *context_msg,
985 struct GNUNET_SET_Request *request) 987 struct GNUNET_SET_Request *request)
986{ 988{
987 struct AliceServiceSession *s = cls; 989 struct AliceServiceSession *s = cls;
988 990
989 if (0 != GNUNET_memcmp(other_peer, &s->peer)) 991 if (0 != GNUNET_memcmp (other_peer, &s->peer))
990 { 992 {
991 GNUNET_break_op(0); 993 GNUNET_break_op (0);
992 return; 994 return;
993 } 995 }
994 s->intersection_op = GNUNET_SET_accept(request, 996 s->intersection_op = GNUNET_SET_accept (request,
995 GNUNET_SET_RESULT_REMOVED, 997 GNUNET_SET_RESULT_REMOVED,
996 (struct GNUNET_SET_Option[]){ { 0 } }, 998 (struct GNUNET_SET_Option[]){ { 0 } },
997 &cb_intersection_element_removed, 999 &cb_intersection_element_removed,
998 s); 1000 s);
999 if (NULL == s->intersection_op) 1001 if (NULL == s->intersection_op)
1000 { 1002 {
1001 GNUNET_break(0); 1003 GNUNET_break (0);
1002 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; 1004 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
1003 prepare_client_end_notification(s); 1005 prepare_client_end_notification (s);
1004 return; 1006 return;
1005 } 1007 }
1006 if (GNUNET_OK != GNUNET_SET_commit(s->intersection_op, s->intersection_set)) 1008 if (GNUNET_OK != GNUNET_SET_commit (s->intersection_op, s->intersection_set))
1007 { 1009 {
1008 GNUNET_break(0); 1010 GNUNET_break (0);
1009 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; 1011 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
1010 prepare_client_end_notification(s); 1012 prepare_client_end_notification (s);
1011 return; 1013 return;
1012 } 1014 }
1013} 1015}
1014 1016
1015 1017
@@ -1019,58 +1021,58 @@ cb_intersection_request_alice(void *cls,
1019 * @param session the service session context 1021 * @param session the service session context
1020 */ 1022 */
1021static void 1023static void
1022client_request_complete_alice(struct AliceServiceSession *s) 1024client_request_complete_alice (struct AliceServiceSession *s)
1023{ 1025{
1024 struct GNUNET_MQ_MessageHandler cadet_handlers[] = 1026 struct GNUNET_MQ_MessageHandler cadet_handlers[] =
1025 { GNUNET_MQ_hd_var_size(bobs_cryptodata_message, 1027 { GNUNET_MQ_hd_var_size (bobs_cryptodata_message,
1026 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA, 1028 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA,
1027 struct BobCryptodataMessage, 1029 struct BobCryptodataMessage,
1028 s), 1030 s),
1029 GNUNET_MQ_hd_var_size( 1031 GNUNET_MQ_hd_var_size (
1030 bobs_cryptodata_multipart, 1032 bobs_cryptodata_multipart,
1031 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART, 1033 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_CRYPTODATA_MULTIPART,
1032 struct BobCryptodataMultipartMessage, 1034 struct BobCryptodataMultipartMessage,
1033 s), 1035 s),
1034 GNUNET_MQ_handler_end() }; 1036 GNUNET_MQ_handler_end () };
1035 struct ServiceRequestMessage *msg; 1037 struct ServiceRequestMessage *msg;
1036 struct GNUNET_MQ_Envelope *e; 1038 struct GNUNET_MQ_Envelope *e;
1037 1039
1038 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1040 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1039 "Creating new channel for session with key %s.\n", 1041 "Creating new channel for session with key %s.\n",
1040 GNUNET_h2s(&s->session_id)); 1042 GNUNET_h2s (&s->session_id));
1041 s->channel = GNUNET_CADET_channel_create(my_cadet, 1043 s->channel = GNUNET_CADET_channel_create (my_cadet,
1042 s, 1044 s,
1043 &s->peer, 1045 &s->peer,
1044 &s->session_id, 1046 &s->session_id,
1045 NULL, 1047 NULL,
1046 &cb_channel_destruction, 1048 &cb_channel_destruction,
1047 cadet_handlers); 1049 cadet_handlers);
1048 if (NULL == s->channel) 1050 if (NULL == s->channel)
1049 { 1051 {
1050 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; 1052 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
1051 prepare_client_end_notification(s); 1053 prepare_client_end_notification (s);
1052 return; 1054 return;
1053 } 1055 }
1054 s->cadet_mq = GNUNET_CADET_get_mq(s->channel); 1056 s->cadet_mq = GNUNET_CADET_get_mq (s->channel);
1055 s->intersection_listen = GNUNET_SET_listen(cfg, 1057 s->intersection_listen = GNUNET_SET_listen (cfg,
1056 GNUNET_SET_OPERATION_INTERSECTION, 1058 GNUNET_SET_OPERATION_INTERSECTION,
1057 &s->session_id, 1059 &s->session_id,
1058 &cb_intersection_request_alice, 1060 &cb_intersection_request_alice,
1059 s); 1061 s);
1060 if (NULL == s->intersection_listen) 1062 if (NULL == s->intersection_listen)
1061 { 1063 {
1062 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE; 1064 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
1063 GNUNET_CADET_channel_destroy(s->channel); 1065 GNUNET_CADET_channel_destroy (s->channel);
1064 s->channel = NULL; 1066 s->channel = NULL;
1065 prepare_client_end_notification(s); 1067 prepare_client_end_notification (s);
1066 return; 1068 return;
1067 } 1069 }
1068 1070
1069 e = GNUNET_MQ_msg(msg, 1071 e = GNUNET_MQ_msg (msg,
1070 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_SESSION_INITIALIZATION); 1072 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_SESSION_INITIALIZATION);
1071 msg->session_id = s->session_id; 1073 msg->session_id = s->session_id;
1072 msg->public_key = my_pubkey; 1074 msg->public_key = my_pubkey;
1073 GNUNET_MQ_send(s->cadet_mq, e); 1075 GNUNET_MQ_send (s->cadet_mq, e);
1074} 1076}
1075 1077
1076 1078
@@ -1083,7 +1085,7 @@ client_request_complete_alice(struct AliceServiceSession *s)
1083 * @return #GNUNET_OK if @a msg is well-formed 1085 * @return #GNUNET_OK if @a msg is well-formed
1084 */ 1086 */
1085static int 1087static int
1086check_alice_client_message_multipart( 1088check_alice_client_message_multipart (
1087 void *cls, 1089 void *cls,
1088 const struct ComputationBobCryptodataMultipartMessage *msg) 1090 const struct ComputationBobCryptodataMultipartMessage *msg)
1089{ 1091{
@@ -1091,18 +1093,18 @@ check_alice_client_message_multipart(
1091 uint32_t contained_count; 1093 uint32_t contained_count;
1092 uint16_t msize; 1094 uint16_t msize;
1093 1095
1094 msize = ntohs(msg->header.size); 1096 msize = ntohs (msg->header.size);
1095 contained_count = ntohl(msg->element_count_contained); 1097 contained_count = ntohl (msg->element_count_contained);
1096 if ((msize != 1098 if ((msize !=
1097 (sizeof(struct ComputationBobCryptodataMultipartMessage) + 1099 (sizeof(struct ComputationBobCryptodataMultipartMessage)
1098 contained_count * sizeof(struct GNUNET_SCALARPRODUCT_Element))) || 1100 + contained_count * sizeof(struct GNUNET_SCALARPRODUCT_Element))) ||
1099 (0 == contained_count) || 1101 (0 == contained_count) ||
1100 (s->total == s->client_received_element_count) || 1102 (s->total == s->client_received_element_count) ||
1101 (s->total < s->client_received_element_count + contained_count)) 1103 (s->total < s->client_received_element_count + contained_count))
1102 { 1104 {
1103 GNUNET_break_op(0); 1105 GNUNET_break_op (0);
1104 return GNUNET_SYSERR; 1106 return GNUNET_SYSERR;
1105 } 1107 }
1106 return GNUNET_OK; 1108 return GNUNET_OK;
1107} 1109}
1108 1110
@@ -1115,7 +1117,7 @@ check_alice_client_message_multipart(
1115 * @param msg the actual message 1117 * @param msg the actual message
1116 */ 1118 */
1117static void 1119static void
1118handle_alice_client_message_multipart( 1120handle_alice_client_message_multipart (
1119 void *cls, 1121 void *cls,
1120 const struct ComputationBobCryptodataMultipartMessage *msg) 1122 const struct ComputationBobCryptodataMultipartMessage *msg)
1121{ 1123{
@@ -1125,38 +1127,38 @@ handle_alice_client_message_multipart(
1125 struct GNUNET_SET_Element set_elem; 1127 struct GNUNET_SET_Element set_elem;
1126 struct GNUNET_SCALARPRODUCT_Element *elem; 1128 struct GNUNET_SCALARPRODUCT_Element *elem;
1127 1129
1128 contained_count = ntohl(msg->element_count_contained); 1130 contained_count = ntohl (msg->element_count_contained);
1129 s->client_received_element_count += contained_count; 1131 s->client_received_element_count += contained_count;
1130 elements = (const struct GNUNET_SCALARPRODUCT_Element *)&msg[1]; 1132 elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1];
1131 for (uint32_t i = 0; i < contained_count; i++) 1133 for (uint32_t i = 0; i < contained_count; i++)
1134 {
1135 elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element);
1136 GNUNET_memcpy (elem,
1137 &elements[i],
1138 sizeof(struct GNUNET_SCALARPRODUCT_Element));
1139 if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put (
1140 s->intersected_elements,
1141 &elem->key,
1142 elem,
1143 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1132 { 1144 {
1133 elem = GNUNET_new(struct GNUNET_SCALARPRODUCT_Element); 1145 GNUNET_break (0);
1134 GNUNET_memcpy(elem, 1146 GNUNET_free (elem);
1135 &elements[i], 1147 continue;
1136 sizeof(struct GNUNET_SCALARPRODUCT_Element));
1137 if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put(
1138 s->intersected_elements,
1139 &elem->key,
1140 elem,
1141 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1142 {
1143 GNUNET_break(0);
1144 GNUNET_free(elem);
1145 continue;
1146 }
1147 set_elem.data = &elem->key;
1148 set_elem.size = sizeof(elem->key);
1149 set_elem.element_type = 0;
1150 GNUNET_SET_add_element(s->intersection_set, &set_elem, NULL, NULL);
1151 s->used_element_count++;
1152 } 1148 }
1153 GNUNET_SERVICE_client_continue(s->client); 1149 set_elem.data = &elem->key;
1150 set_elem.size = sizeof(elem->key);
1151 set_elem.element_type = 0;
1152 GNUNET_SET_add_element (s->intersection_set, &set_elem, NULL, NULL);
1153 s->used_element_count++;
1154 }
1155 GNUNET_SERVICE_client_continue (s->client);
1154 if (s->total != s->client_received_element_count) 1156 if (s->total != s->client_received_element_count)
1155 { 1157 {
1156 /* more to come */ 1158 /* more to come */
1157 return; 1159 return;
1158 } 1160 }
1159 client_request_complete_alice(s); 1161 client_request_complete_alice (s);
1160} 1162}
1161 1163
1162 1164
@@ -1169,8 +1171,8 @@ handle_alice_client_message_multipart(
1169 * @return #GNUNET_OK if @a msg is well-formed 1171 * @return #GNUNET_OK if @a msg is well-formed
1170 */ 1172 */
1171static int 1173static int
1172check_alice_client_message(void *cls, 1174check_alice_client_message (void *cls,
1173 const struct AliceComputationMessage *msg) 1175 const struct AliceComputationMessage *msg)
1174{ 1176{
1175 struct AliceServiceSession *s = cls; 1177 struct AliceServiceSession *s = cls;
1176 uint16_t msize; 1178 uint16_t msize;
@@ -1178,23 +1180,23 @@ check_alice_client_message(void *cls,
1178 uint32_t contained_count; 1180 uint32_t contained_count;
1179 1181
1180 if (NULL != s->intersected_elements) 1182 if (NULL != s->intersected_elements)
1181 { 1183 {
1182 /* only one concurrent session per client connection allowed, 1184 /* only one concurrent session per client connection allowed,
1183 simplifies logic a lot... */ 1185 simplifies logic a lot... */
1184 GNUNET_break(0); 1186 GNUNET_break (0);
1185 return GNUNET_SYSERR; 1187 return GNUNET_SYSERR;
1186 } 1188 }
1187 msize = ntohs(msg->header.size); 1189 msize = ntohs (msg->header.size);
1188 total_count = ntohl(msg->element_count_total); 1190 total_count = ntohl (msg->element_count_total);
1189 contained_count = ntohl(msg->element_count_contained); 1191 contained_count = ntohl (msg->element_count_contained);
1190 if ((0 == total_count) || (0 == contained_count) || 1192 if ((0 == total_count) || (0 == contained_count) ||
1191 (msize != 1193 (msize !=
1192 (sizeof(struct AliceComputationMessage) + 1194 (sizeof(struct AliceComputationMessage)
1193 contained_count * sizeof(struct GNUNET_SCALARPRODUCT_Element)))) 1195 + contained_count * sizeof(struct GNUNET_SCALARPRODUCT_Element))))
1194 { 1196 {
1195 GNUNET_break_op(0); 1197 GNUNET_break_op (0);
1196 return GNUNET_SYSERR; 1198 return GNUNET_SYSERR;
1197 } 1199 }
1198 return GNUNET_OK; 1200 return GNUNET_OK;
1199} 1201}
1200 1202
@@ -1207,8 +1209,8 @@ check_alice_client_message(void *cls,
1207 * @param msg the actual message 1209 * @param msg the actual message
1208 */ 1210 */
1209static void 1211static void
1210handle_alice_client_message(void *cls, 1212handle_alice_client_message (void *cls,
1211 const struct AliceComputationMessage *msg) 1213 const struct AliceComputationMessage *msg)
1212{ 1214{
1213 struct AliceServiceSession *s = cls; 1215 struct AliceServiceSession *s = cls;
1214 uint32_t contained_count; 1216 uint32_t contained_count;
@@ -1217,51 +1219,51 @@ handle_alice_client_message(void *cls,
1217 struct GNUNET_SET_Element set_elem; 1219 struct GNUNET_SET_Element set_elem;
1218 struct GNUNET_SCALARPRODUCT_Element *elem; 1220 struct GNUNET_SCALARPRODUCT_Element *elem;
1219 1221
1220 total_count = ntohl(msg->element_count_total); 1222 total_count = ntohl (msg->element_count_total);
1221 contained_count = ntohl(msg->element_count_contained); 1223 contained_count = ntohl (msg->element_count_contained);
1222 s->peer = msg->peer; 1224 s->peer = msg->peer;
1223 s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE; 1225 s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE;
1224 s->total = total_count; 1226 s->total = total_count;
1225 s->client_received_element_count = contained_count; 1227 s->client_received_element_count = contained_count;
1226 s->session_id = msg->session_key; 1228 s->session_id = msg->session_key;
1227 elements = (const struct GNUNET_SCALARPRODUCT_Element *)&msg[1]; 1229 elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1];
1228 s->intersected_elements = 1230 s->intersected_elements =
1229 GNUNET_CONTAINER_multihashmap_create(s->total, GNUNET_YES); 1231 GNUNET_CONTAINER_multihashmap_create (s->total, GNUNET_YES);
1230 s->intersection_set = 1232 s->intersection_set =
1231 GNUNET_SET_create(cfg, GNUNET_SET_OPERATION_INTERSECTION); 1233 GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_INTERSECTION);
1232 1234
1233 for (uint32_t i = 0; i < contained_count; i++) 1235 for (uint32_t i = 0; i < contained_count; i++)
1236 {
1237 if (0 == GNUNET_ntohll (elements[i].value))
1238 continue;
1239 elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element);
1240 GNUNET_memcpy (elem,
1241 &elements[i],
1242 sizeof(struct GNUNET_SCALARPRODUCT_Element));
1243 if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put (
1244 s->intersected_elements,
1245 &elem->key,
1246 elem,
1247 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1234 { 1248 {
1235 if (0 == GNUNET_ntohll(elements[i].value)) 1249 /* element with same key encountered twice! */
1236 continue; 1250 GNUNET_break (0);
1237 elem = GNUNET_new(struct GNUNET_SCALARPRODUCT_Element); 1251 GNUNET_free (elem);
1238 GNUNET_memcpy(elem, 1252 continue;
1239 &elements[i],
1240 sizeof(struct GNUNET_SCALARPRODUCT_Element));
1241 if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put(
1242 s->intersected_elements,
1243 &elem->key,
1244 elem,
1245 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1246 {
1247 /* element with same key encountered twice! */
1248 GNUNET_break(0);
1249 GNUNET_free(elem);
1250 continue;
1251 }
1252 set_elem.data = &elem->key;
1253 set_elem.size = sizeof(elem->key);
1254 set_elem.element_type = 0;
1255 GNUNET_SET_add_element(s->intersection_set, &set_elem, NULL, NULL);
1256 s->used_element_count++;
1257 } 1253 }
1258 GNUNET_SERVICE_client_continue(s->client); 1254 set_elem.data = &elem->key;
1255 set_elem.size = sizeof(elem->key);
1256 set_elem.element_type = 0;
1257 GNUNET_SET_add_element (s->intersection_set, &set_elem, NULL, NULL);
1258 s->used_element_count++;
1259 }
1260 GNUNET_SERVICE_client_continue (s->client);
1259 if (s->total != s->client_received_element_count) 1261 if (s->total != s->client_received_element_count)
1260 { 1262 {
1261 /* wait for multipart msg */ 1263 /* wait for multipart msg */
1262 return; 1264 return;
1263 } 1265 }
1264 client_request_complete_alice(s); 1266 client_request_complete_alice (s);
1265} 1267}
1266 1268
1267 1269
@@ -1271,15 +1273,15 @@ handle_alice_client_message(void *cls,
1271 * @param cls unused 1273 * @param cls unused
1272 */ 1274 */
1273static void 1275static void
1274shutdown_task(void *cls) 1276shutdown_task (void *cls)
1275{ 1277{
1276 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Shutting down, initiating cleanup.\n"); 1278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down, initiating cleanup.\n");
1277 // FIXME: we have to cut our connections to CADET first! 1279 // FIXME: we have to cut our connections to CADET first!
1278 if (NULL != my_cadet) 1280 if (NULL != my_cadet)
1279 { 1281 {
1280 GNUNET_CADET_disconnect(my_cadet); 1282 GNUNET_CADET_disconnect (my_cadet);
1281 my_cadet = NULL; 1283 my_cadet = NULL;
1282 } 1284 }
1283} 1285}
1284 1286
1285 1287
@@ -1294,13 +1296,13 @@ shutdown_task(void *cls)
1294 * @return our `struct AliceServiceSession` 1296 * @return our `struct AliceServiceSession`
1295 */ 1297 */
1296static void * 1298static void *
1297client_connect_cb(void *cls, 1299client_connect_cb (void *cls,
1298 struct GNUNET_SERVICE_Client *client, 1300 struct GNUNET_SERVICE_Client *client,
1299 struct GNUNET_MQ_Handle *mq) 1301 struct GNUNET_MQ_Handle *mq)
1300{ 1302{
1301 struct AliceServiceSession *s; 1303 struct AliceServiceSession *s;
1302 1304
1303 s = GNUNET_new(struct AliceServiceSession); 1305 s = GNUNET_new (struct AliceServiceSession);
1304 s->client = client; 1306 s->client = client;
1305 s->client_mq = mq; 1307 s->client_mq = mq;
1306 return s; 1308 return s;
@@ -1318,18 +1320,18 @@ client_connect_cb(void *cls,
1318 * @param app_cls our `struct AliceServiceSession` 1320 * @param app_cls our `struct AliceServiceSession`
1319 */ 1321 */
1320static void 1322static void
1321client_disconnect_cb(void *cls, 1323client_disconnect_cb (void *cls,
1322 struct GNUNET_SERVICE_Client *client, 1324 struct GNUNET_SERVICE_Client *client,
1323 void *app_cls) 1325 void *app_cls)
1324{ 1326{
1325 struct AliceServiceSession *s = app_cls; 1327 struct AliceServiceSession *s = app_cls;
1326 1328
1327 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1329 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1328 "Client %p disconnected from us.\n", 1330 "Client %p disconnected from us.\n",
1329 client); 1331 client);
1330 s->client = NULL; 1332 s->client = NULL;
1331 s->client_mq = NULL; 1333 s->client_mq = NULL;
1332 destroy_service_session(s); 1334 destroy_service_session (s);
1333} 1335}
1334 1336
1335 1337
@@ -1341,49 +1343,49 @@ client_disconnect_cb(void *cls,
1341 * @param service the initialized service 1343 * @param service the initialized service
1342 */ 1344 */
1343static void 1345static void
1344run(void *cls, 1346run (void *cls,
1345 const struct GNUNET_CONFIGURATION_Handle *c, 1347 const struct GNUNET_CONFIGURATION_Handle *c,
1346 struct GNUNET_SERVICE_Handle *service) 1348 struct GNUNET_SERVICE_Handle *service)
1347{ 1349{
1348 cfg = c; 1350 cfg = c;
1349 /* 1351 /*
1350 offset has to be sufficiently small to allow computation of: 1352 offset has to be sufficiently small to allow computation of:
1351 m1+m2 mod n == (S + a) + (S + b) mod n, 1353 m1+m2 mod n == (S + a) + (S + b) mod n,
1352 if we have more complex operations, this factor needs to be lowered */ 1354 if we have more complex operations, this factor needs to be lowered */
1353 my_offset = gcry_mpi_new(GNUNET_CRYPTO_PAILLIER_BITS / 3); 1355 my_offset = gcry_mpi_new (GNUNET_CRYPTO_PAILLIER_BITS / 3);
1354 gcry_mpi_set_bit(my_offset, GNUNET_CRYPTO_PAILLIER_BITS / 3); 1356 gcry_mpi_set_bit (my_offset, GNUNET_CRYPTO_PAILLIER_BITS / 3);
1355 GNUNET_CRYPTO_paillier_create(&my_pubkey, &my_privkey); 1357 GNUNET_CRYPTO_paillier_create (&my_pubkey, &my_privkey);
1356 my_cadet = GNUNET_CADET_connect(cfg); 1358 my_cadet = GNUNET_CADET_connect (cfg);
1357 GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL); 1359 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
1358 if (NULL == my_cadet) 1360 if (NULL == my_cadet)
1359 { 1361 {
1360 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Connect to CADET failed\n")); 1362 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Connect to CADET failed\n"));
1361 GNUNET_SCHEDULER_shutdown(); 1363 GNUNET_SCHEDULER_shutdown ();
1362 return; 1364 return;
1363 } 1365 }
1364} 1366}
1365 1367
1366 1368
1367/** 1369/**
1368 * Define "main" method using service macro. 1370 * Define "main" method using service macro.
1369 */ 1371 */
1370GNUNET_SERVICE_MAIN( 1372GNUNET_SERVICE_MAIN (
1371 "scalarproduct-alice", 1373 "scalarproduct-alice",
1372 GNUNET_SERVICE_OPTION_NONE, 1374 GNUNET_SERVICE_OPTION_NONE,
1373 &run, 1375 &run,
1374 &client_connect_cb, 1376 &client_connect_cb,
1375 &client_disconnect_cb, 1377 &client_disconnect_cb,
1376 NULL, 1378 NULL,
1377 GNUNET_MQ_hd_var_size(alice_client_message, 1379 GNUNET_MQ_hd_var_size (alice_client_message,
1378 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE, 1380 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE,
1379 struct AliceComputationMessage, 1381 struct AliceComputationMessage,
1380 NULL), 1382 NULL),
1381 GNUNET_MQ_hd_var_size( 1383 GNUNET_MQ_hd_var_size (
1382 alice_client_message_multipart, 1384 alice_client_message_multipart,
1383 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_ALICE, 1385 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_MULTIPART_ALICE,
1384 struct ComputationBobCryptodataMultipartMessage, 1386 struct ComputationBobCryptodataMultipartMessage,
1385 NULL), 1387 NULL),
1386 GNUNET_MQ_handler_end()); 1388 GNUNET_MQ_handler_end ());
1387 1389
1388 1390
1389/* end of gnunet-service-scalarproduct_alice.c */ 1391/* end of gnunet-service-scalarproduct_alice.c */