aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-06 20:55:28 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-06 20:55:28 +0000
commit61c39c60565b386e0e12ea669556b030e8cd7180 (patch)
tree59109aeab8297bdc996faca8c4e38ec7426c36cf /src/scalarproduct
parent780eb09dd8040ecf8649d40ddf8314464e0fc48e (diff)
downloadgnunet-61c39c60565b386e0e12ea669556b030e8cd7180.tar.gz
gnunet-61c39c60565b386e0e12ea669556b030e8cd7180.zip
-remove trailing whitespace
Diffstat (limited to 'src/scalarproduct')
-rw-r--r--src/scalarproduct/gnunet-scalarproduct.c14
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.c122
-rw-r--r--src/scalarproduct/scalarproduct.h18
-rw-r--r--src/scalarproduct/scalarproduct_api.c34
-rw-r--r--src/scalarproduct/scalarproduct_testing.h22
-rw-r--r--src/scalarproduct/test_scalarproduct_api.c38
6 files changed, 124 insertions, 124 deletions
diff --git a/src/scalarproduct/gnunet-scalarproduct.c b/src/scalarproduct/gnunet-scalarproduct.c
index 5e95742e6..32ed95268 100644
--- a/src/scalarproduct/gnunet-scalarproduct.c
+++ b/src/scalarproduct/gnunet-scalarproduct.c
@@ -77,9 +77,9 @@ static int ret = -1;
77 77
78/** 78/**
79 * Callback called if we are initiating a new computation session 79 * Callback called if we are initiating a new computation session
80 * 80 *
81 * @param cls unused 81 * @param cls unused
82 * @param status if our job was successfully processed 82 * @param status if our job was successfully processed
83 */ 83 */
84static void 84static void
85responder_callback (void *cls, 85responder_callback (void *cls,
@@ -110,14 +110,14 @@ responder_callback (void *cls,
110 110
111/** 111/**
112 * Callback called if we are initiating a new computation session 112 * Callback called if we are initiating a new computation session
113 * 113 *
114 * @param cls unused 114 * @param cls unused
115 * @param key unused 115 * @param key unused
116 * @param peer unused 116 * @param peer unused
117 * @param status if our job was successfully processed 117 * @param status if our job was successfully processed
118 * @param size size of the msg returned 118 * @param size size of the msg returned
119 * @param msg the response we got. 119 * @param msg the response we got.
120 * @param type of the message received 120 * @param type of the message received
121 */ 121 */
122static void 122static void
123requester_callback (void *cls, 123requester_callback (void *cls,
@@ -247,7 +247,7 @@ run (void *cls,
247 LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Need elements to compute the vectorproduct, got none.\n")); 247 LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Need elements to compute the vectorproduct, got none.\n"));
248 return; 248 return;
249 } 249 }
250 250
251 begin = input_elements; 251 begin = input_elements;
252 elements = GNUNET_malloc (sizeof (int32_t) * element_count); 252 elements = GNUNET_malloc (sizeof (int32_t) * element_count);
253 element_count = 0; 253 element_count = 0;
@@ -328,7 +328,7 @@ run (void *cls,
328 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 328 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
329 &shutdown_task, 329 &shutdown_task,
330 NULL); 330 NULL);
331 331
332 ret = 0; 332 ret = 0;
333} 333}
334 334
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c
index e17a3a4d1..b2a84fdb6 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct.c
@@ -66,7 +66,7 @@ enum PeerRole
66 66
67/** 67/**
68 * A scalarproduct session which tracks: 68 * A scalarproduct session which tracks:
69 * 69 *
70 * a request form the client to our final response. 70 * a request form the client to our final response.
71 * or 71 * or
72 * a request from a service to us(service). 72 * a request from a service to us(service).
@@ -93,7 +93,7 @@ struct ServiceSession
93 */ 93 */
94 struct GNUNET_HashCode key; 94 struct GNUNET_HashCode key;
95 95
96 /** 96 /**
97 * state of the session 97 * state of the session
98 */ 98 */
99 enum SessionState state; 99 enum SessionState state;
@@ -127,9 +127,9 @@ struct ServiceSession
127 * already transferred elements (sent/received) for multipart messages, less or equal than used_element_count for 127 * already transferred elements (sent/received) for multipart messages, less or equal than used_element_count for
128 */ 128 */
129 uint32_t transferred_element_count; 129 uint32_t transferred_element_count;
130 130
131 /** 131 /**
132 * how many bytes the mask is long. 132 * how many bytes the mask is long.
133 * just for convenience so we don't have to re-re-re calculate it each time 133 * just for convenience so we don't have to re-re-re calculate it each time
134 */ 134 */
135 uint32_t mask_length; 135 uint32_t mask_length;
@@ -158,14 +158,14 @@ struct ServiceSession
158 * Bob's permutation p of R 158 * Bob's permutation p of R
159 */ 159 */
160 gcry_mpi_t * r; 160 gcry_mpi_t * r;
161 161
162 /** 162 /**
163 * Bob's permutation q of R 163 * Bob's permutation q of R
164 */ 164 */
165 gcry_mpi_t * r_prime; 165 gcry_mpi_t * r_prime;
166 166
167 /** 167 /**
168 * The computed scalar 168 * The computed scalar
169 */ 169 */
170 gcry_mpi_t product; 170 gcry_mpi_t product;
171 171
@@ -245,27 +245,27 @@ static gcry_mpi_t my_lambda;
245static gcry_mpi_t my_offset; 245static gcry_mpi_t my_offset;
246 246
247/** 247/**
248 * Head of our double linked list for client-requests sent to us. 248 * Head of our double linked list for client-requests sent to us.
249 * for all of these elements we calculate a scalar product with a remote peer 249 * for all of these elements we calculate a scalar product with a remote peer
250 * split between service->service and client->service for simplicity 250 * split between service->service and client->service for simplicity
251 */ 251 */
252static struct ServiceSession * from_client_head; 252static struct ServiceSession * from_client_head;
253/** 253/**
254 * Tail of our double linked list for client-requests sent to us. 254 * Tail of our double linked list for client-requests sent to us.
255 * for all of these elements we calculate a scalar product with a remote peer 255 * for all of these elements we calculate a scalar product with a remote peer
256 * split between service->service and client->service for simplicity 256 * split between service->service and client->service for simplicity
257 */ 257 */
258static struct ServiceSession * from_client_tail; 258static struct ServiceSession * from_client_tail;
259 259
260/** 260/**
261 * Head of our double linked list for service-requests sent to us. 261 * Head of our double linked list for service-requests sent to us.
262 * for all of these elements we help the requesting service in calculating a scalar product 262 * for all of these elements we help the requesting service in calculating a scalar product
263 * split between service->service and client->service for simplicity 263 * split between service->service and client->service for simplicity
264 */ 264 */
265static struct ServiceSession * from_service_head; 265static struct ServiceSession * from_service_head;
266 266
267/** 267/**
268 * Tail of our double linked list for service-requests sent to us. 268 * Tail of our double linked list for service-requests sent to us.
269 * for all of these elements we help the requesting service in calculating a scalar product 269 * for all of these elements we help the requesting service in calculating a scalar product
270 * split between service->service and client->service for simplicity 270 * split between service->service and client->service for simplicity
271 */ 271 */
@@ -306,7 +306,7 @@ generate_keyset ()
306 GNUNET_assert (0 == gcry_pk_genkey (&key, gen_params)); 306 GNUNET_assert (0 == gcry_pk_genkey (&key, gen_params));
307 gcry_sexp_release (gen_params); 307 gcry_sexp_release (gen_params);
308 308
309 // get n and d of our publickey as MPI 309 // get n and d of our publickey as MPI
310 tmp_sexp = gcry_sexp_find_token (key, "n", 0); 310 tmp_sexp = gcry_sexp_find_token (key, "n", 0);
311 GNUNET_assert (tmp_sexp); 311 GNUNET_assert (tmp_sexp);
312 my_n = gcry_sexp_nth_mpi (tmp_sexp, 1, GCRYMPI_FMT_USG); 312 my_n = gcry_sexp_nth_mpi (tmp_sexp, 1, GCRYMPI_FMT_USG);
@@ -389,7 +389,7 @@ generate_keyset ()
389 gcry_sexp_release (key); 389 gcry_sexp_release (key);
390 390
391 // offset has to be sufficiently small to allow computation of: 391 // offset has to be sufficiently small to allow computation of:
392 // m1+m2 mod n == (S + a) + (S + b) mod n, 392 // m1+m2 mod n == (S + a) + (S + b) mod n,
393 // if we have more complex operations, this factor needs to be lowered 393 // if we have more complex operations, this factor needs to be lowered
394 my_offset = gcry_mpi_new (KEYBITS / 3); 394 my_offset = gcry_mpi_new (KEYBITS / 3);
395 gcry_mpi_set_bit (my_offset, KEYBITS / 3); 395 gcry_mpi_set_bit (my_offset, KEYBITS / 3);
@@ -420,7 +420,7 @@ adjust (unsigned char *buf, size_t size, size_t target)
420 420
421/** 421/**
422 * encrypts an element using the paillier crypto system 422 * encrypts an element using the paillier crypto system
423 * 423 *
424 * @param c ciphertext (output) 424 * @param c ciphertext (output)
425 * @param m plaintext 425 * @param m plaintext
426 * @param g the public base 426 * @param g the public base
@@ -450,7 +450,7 @@ encrypt_element (gcry_mpi_t c, gcry_mpi_t m, gcry_mpi_t g, gcry_mpi_t n, gcry_mp
450 450
451/** 451/**
452 * decrypts an element using the paillier crypto system 452 * decrypts an element using the paillier crypto system
453 * 453 *
454 * @param m plaintext (output) 454 * @param m plaintext (output)
455 * @param c the ciphertext 455 * @param c the ciphertext
456 * @param mu the modifier to correct encryption 456 * @param mu the modifier to correct encryption
@@ -470,7 +470,7 @@ decrypt_element (gcry_mpi_t m, gcry_mpi_t c, gcry_mpi_t mu, gcry_mpi_t lambda, g
470 470
471/** 471/**
472 * computes the square sum over a vector of a given length. 472 * computes the square sum over a vector of a given length.
473 * 473 *
474 * @param vector the vector to encrypt 474 * @param vector the vector to encrypt
475 * @param length the length of the vector 475 * @param length the length of the vector
476 * @return an MPI value containing the calculated sum, never NULL 476 * @return an MPI value containing the calculated sum, never NULL
@@ -501,7 +501,7 @@ compute_square_sum (gcry_mpi_t * vector, uint32_t length)
501 * Primitive callback for copying over a message, as they 501 * Primitive callback for copying over a message, as they
502 * usually are too complex to be handled in the callback itself. 502 * usually are too complex to be handled in the callback itself.
503 * clears a session-callback, if a session was handed over and the transmit handle was stored 503 * clears a session-callback, if a session was handed over and the transmit handle was stored
504 * 504 *
505 * @param cls the message object 505 * @param cls the message object
506 * @param size the size of the buffer we got 506 * @param size the size of the buffer we got
507 * @param buf the buffer to copy the message to 507 * @param buf the buffer to copy the message to
@@ -559,7 +559,7 @@ do_send_message (void *cls, size_t size, void *buf)
559 559
560/** 560/**
561 * initializes a new vector with fresh MPI values (=0) of a given length 561 * initializes a new vector with fresh MPI values (=0) of a given length
562 * 562 *
563 * @param length of the vector to create 563 * @param length of the vector to create
564 * @return the initialized vector, never NULL 564 * @return the initialized vector, never NULL
565 */ 565 */
@@ -577,7 +577,7 @@ initialize_mpi_vector (uint32_t length)
577 577
578/** 578/**
579 * permutes an MPI vector according to the given permutation vector 579 * permutes an MPI vector according to the given permutation vector
580 * 580 *
581 * @param vector the vector to permuted 581 * @param vector the vector to permuted
582 * @param perm the permutation to use 582 * @param perm the permutation to use
583 * @param length the length of the vectors 583 * @param length the length of the vectors
@@ -596,7 +596,7 @@ permute_vector (gcry_mpi_t * vector,
596 // backup old layout 596 // backup old layout
597 memcpy (tmp, vector, length * sizeof (gcry_mpi_t)); 597 memcpy (tmp, vector, length * sizeof (gcry_mpi_t));
598 598
599 // permute vector according to given 599 // permute vector according to given
600 for (i = 0; i < length; i++) 600 for (i = 0; i < length; i++)
601 vector[i] = tmp[perm[i]]; 601 vector[i] = tmp[perm[i]];
602 602
@@ -605,8 +605,8 @@ permute_vector (gcry_mpi_t * vector,
605 605
606 606
607/** 607/**
608 * Populate a vector with random integer values and convert them to 608 * Populate a vector with random integer values and convert them to
609 * 609 *
610 * @param length the length of the vector we must generate 610 * @param length the length of the vector we must generate
611 * @return an array of MPI values with random values 611 * @return an array of MPI values with random values
612 */ 612 */
@@ -636,12 +636,12 @@ generate_random_vector (uint32_t length)
636 636
637 637
638/** 638/**
639 * Finds a not terminated client/service session in the 639 * Finds a not terminated client/service session in the
640 * given DLL based on session key, element count and state. 640 * given DLL based on session key, element count and state.
641 * 641 *
642 * @param tail - the tail of the DLL 642 * @param tail - the tail of the DLL
643 * @param my - the session to compare it to 643 * @param my - the session to compare it to
644 * @return a pointer to a matching session, 644 * @return a pointer to a matching session,
645 * else NULL 645 * else NULL
646 */ 646 */
647static struct ServiceSession * 647static struct ServiceSession *
@@ -702,9 +702,9 @@ free_session (struct ServiceSession * session)
702 702
703 703
704/** 704/**
705 * A client disconnected. 705 * A client disconnected.
706 * 706 *
707 * Remove the associated session(s), release datastructures 707 * Remove the associated session(s), release datastructures
708 * and cancel pending outgoing transmissions to the client. 708 * and cancel pending outgoing transmissions to the client.
709 * if the session has not yet completed, we also cancel Alice's request to Bob. 709 * if the session has not yet completed, we also cancel Alice's request to Bob.
710 * 710 *
@@ -755,10 +755,10 @@ handle_client_disconnect (void *cls,
755 755
756/** 756/**
757 * Notify the client that the session has succeeded or failed completely. 757 * Notify the client that the session has succeeded or failed completely.
758 * This message gets sent to 758 * This message gets sent to
759 * * alice's client if bob disconnected or to 759 * * alice's client if bob disconnected or to
760 * * bob's client if the operation completed or alice disconnected 760 * * bob's client if the operation completed or alice disconnected
761 * 761 *
762 * @param client_session the associated client session 762 * @param client_session the associated client session
763 * @return GNUNET_NO, if we could not notify the client 763 * @return GNUNET_NO, if we could not notify the client
764 * GNUNET_YES if we notified it. 764 * GNUNET_YES if we notified it.
@@ -777,7 +777,7 @@ prepare_client_end_notification (void * cls,
777 memcpy (&msg->key, &session->key, sizeof (struct GNUNET_HashCode)); 777 memcpy (&msg->key, &session->key, sizeof (struct GNUNET_HashCode));
778 memcpy (&msg->peer, &session->peer, sizeof ( struct GNUNET_PeerIdentity)); 778 memcpy (&msg->peer, &session->peer, sizeof ( struct GNUNET_PeerIdentity));
779 msg->header.size = htons (sizeof (struct GNUNET_SCALARPRODUCT_client_response)); 779 msg->header.size = htons (sizeof (struct GNUNET_SCALARPRODUCT_client_response));
780 // signal error if not signalized, positive result-range field but zero length. 780 // signal error if not signalized, positive result-range field but zero length.
781 msg->product_length = htonl (0); 781 msg->product_length = htonl (0);
782 msg->range = (session->state == FINALIZED) ? 0 : -1; 782 msg->range = (session->state == FINALIZED) ? 0 : -1;
783 783
@@ -807,13 +807,13 @@ prepare_client_end_notification (void * cls,
807 807
808/** 808/**
809 * Bob executes: 809 * Bob executes:
810 * generates the response message to be sent to alice after computing 810 * generates the response message to be sent to alice after computing
811 * the values (1), (2), S and S' 811 * the values (1), (2), S and S'
812 * (1)[]: $E_A(a_{pi(i)}) times E_A(- r_{pi(i)} - b_{pi(i)}) &= E_A(a_{pi(i)} - r_{pi(i)} - b_{pi(i)})$ 812 * (1)[]: $E_A(a_{pi(i)}) times E_A(- r_{pi(i)} - b_{pi(i)}) &= E_A(a_{pi(i)} - r_{pi(i)} - b_{pi(i)})$
813 * (2)[]: $E_A(a_{pi'(i)}) times E_A(- r_{pi'(i)}) &= E_A(a_{pi'(i)} - r_{pi'(i)})$ 813 * (2)[]: $E_A(a_{pi'(i)}) times E_A(- r_{pi'(i)}) &= E_A(a_{pi'(i)} - r_{pi'(i)})$
814 * S: $S := E_A(sum (r_i + b_i)^2)$ 814 * S: $S := E_A(sum (r_i + b_i)^2)$
815 * S': $S' := E_A(sum r_i^2)$ 815 * S': $S' := E_A(sum r_i^2)$
816 * 816 *
817 * @param r (1)[]: $E_A(a_{pi(i)}) times E_A(- r_{pi(i)} - b_{pi(i)}) &= E_A(a_{pi(i)} - r_{pi(i)} - b_{pi(i)})$ 817 * @param r (1)[]: $E_A(a_{pi(i)}) times E_A(- r_{pi(i)} - b_{pi(i)}) &= E_A(a_{pi(i)} - r_{pi(i)} - b_{pi(i)})$
818 * @param r_prime (2)[]: $E_A(a_{pi'(i)}) times E_A(- r_{pi'(i)}) &= E_A(a_{pi'(i)} - r_{pi'(i)})$ 818 * @param r_prime (2)[]: $E_A(a_{pi'(i)}) times E_A(- r_{pi'(i)}) &= E_A(a_{pi'(i)} - r_{pi'(i)})$
819 * @param s S: $S := E_A(sum (r_i + b_i)^2)$ 819 * @param s S: $S := E_A(sum (r_i + b_i)^2)$
@@ -847,7 +847,7 @@ prepare_service_response (gcry_mpi_t s,
847 else { 847 else {
848 request->transferred_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - msg_length) / (PAILLIER_ELEMENT_LENGTH * 2); 848 request->transferred_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - msg_length) / (PAILLIER_ELEMENT_LENGTH * 2);
849 } 849 }
850 850
851 msg = GNUNET_malloc (msg_length); 851 msg = GNUNET_malloc (msg_length);
852 852
853 msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE); 853 msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE);
@@ -861,7 +861,7 @@ prepare_service_response (gcry_mpi_t s,
861 element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH); 861 element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH);
862 // 4 times the same logics with slight variations. 862 // 4 times the same logics with slight variations.
863 // doesn't really justify having 2 functions for that 863 // doesn't really justify having 2 functions for that
864 // so i put it into blocks to enhance readability 864 // so i put it into blocks to enhance readability
865 // convert s 865 // convert s
866 memset (element_exported, 0, PAILLIER_ELEMENT_LENGTH); 866 memset (element_exported, 0, PAILLIER_ELEMENT_LENGTH);
867 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, 867 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG,
@@ -907,7 +907,7 @@ prepare_service_response (gcry_mpi_t s,
907 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH); 907 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH);
908 current += PAILLIER_ELEMENT_LENGTH; 908 current += PAILLIER_ELEMENT_LENGTH;
909 } 909 }
910 910
911 GNUNET_free (element_exported); 911 GNUNET_free (element_exported);
912 for (i = 0; i < request->transferred_element_count; i++) 912 for (i = 0; i < request->transferred_element_count; i++)
913 { 913 {
@@ -916,7 +916,7 @@ prepare_service_response (gcry_mpi_t s,
916 } 916 }
917 gcry_mpi_release (s); 917 gcry_mpi_release (s);
918 gcry_mpi_release (s_prime); 918 gcry_mpi_release (s_prime);
919 919
920 request->msg = (struct GNUNET_MessageHeader *) msg; 920 request->msg = (struct GNUNET_MessageHeader *) msg;
921 request->service_transmit_handle = 921 request->service_transmit_handle =
922 GNUNET_MESH_notify_transmit_ready (request->tunnel, 922 GNUNET_MESH_notify_transmit_ready (request->tunnel,
@@ -942,19 +942,19 @@ prepare_service_response (gcry_mpi_t s,
942 else 942 else
943 //singlepart 943 //singlepart
944 request->state = FINALIZED; 944 request->state = FINALIZED;
945 945
946 return GNUNET_OK; 946 return GNUNET_OK;
947} 947}
948 948
949 949
950/** 950/**
951 * executed by bob: 951 * executed by bob:
952 * compute the values 952 * compute the values
953 * (1)[]: $E_A(a_{\pi(i)}) \otimes E_A(- r_{\pi(i)} - b_{\pi(i)}) &= E_A(a_{\pi(i)} - r_{\pi(i)} - b_{\pi(i)})$ 953 * (1)[]: $E_A(a_{\pi(i)}) \otimes E_A(- r_{\pi(i)} - b_{\pi(i)}) &= E_A(a_{\pi(i)} - r_{\pi(i)} - b_{\pi(i)})$
954 * (2)[]: $E_A(a_{\pi'(i)}) \otimes E_A(- r_{\pi'(i)}) &= E_A(a_{\pi'(i)} - r_{\pi'(i)})$ 954 * (2)[]: $E_A(a_{\pi'(i)}) \otimes E_A(- r_{\pi'(i)}) &= E_A(a_{\pi'(i)} - r_{\pi'(i)})$
955 * S: $S := E_A(\sum (r_i + b_i)^2)$ 955 * S: $S := E_A(\sum (r_i + b_i)^2)$
956 * S': $S' := E_A(\sum r_i^2)$ 956 * S': $S' := E_A(\sum r_i^2)$
957 * 957 *
958 * @param request the requesting session + bob's requesting peer 958 * @param request the requesting session + bob's requesting peer
959 * @param response the responding session + bob's client handle 959 * @param response the responding session + bob's client handle
960 * @return GNUNET_SYSERR if the computation failed 960 * @return GNUNET_SYSERR if the computation failed
@@ -1063,7 +1063,7 @@ compute_service_response (struct ServiceSession * request,
1063 r = initialize_mpi_vector (count); 1063 r = initialize_mpi_vector (count);
1064 r_prime = initialize_mpi_vector (count); 1064 r_prime = initialize_mpi_vector (count);
1065 1065
1066 // copy the REFERNCES of a, b and r into aq and bq. we will not change 1066 // copy the REFERNCES of a, b and r into aq and bq. we will not change
1067 // those values, thus we can work with the references 1067 // those values, thus we can work with the references
1068 memcpy (a_pi, request->a, sizeof (gcry_mpi_t) * count); 1068 memcpy (a_pi, request->a, sizeof (gcry_mpi_t) * count);
1069 memcpy (a_pi_prime, request->a, sizeof (gcry_mpi_t) * count); 1069 memcpy (a_pi_prime, request->a, sizeof (gcry_mpi_t) * count);
@@ -1080,7 +1080,7 @@ compute_service_response (struct ServiceSession * request,
1080 1080
1081 // encrypt the element 1081 // encrypt the element
1082 // for the sake of readability I decided to have dedicated permutation 1082 // for the sake of readability I decided to have dedicated permutation
1083 // vectors, which get rid of all the lookups in p/q. 1083 // vectors, which get rid of all the lookups in p/q.
1084 // however, ap/aq are not absolutely necessary but are just abstraction 1084 // however, ap/aq are not absolutely necessary but are just abstraction
1085 // Calculate Kp = E(S + a_pi) (+) E(S - r_pi - b_pi) 1085 // Calculate Kp = E(S + a_pi) (+) E(S - r_pi - b_pi)
1086 for (i = 0; i < count; i++) 1086 for (i = 0; i < count; i++)
@@ -1109,7 +1109,7 @@ compute_service_response (struct ServiceSession * request,
1109 } 1109 }
1110 GNUNET_free (a_pi_prime); 1110 GNUNET_free (a_pi_prime);
1111 GNUNET_free (rand_pi_prime); 1111 GNUNET_free (rand_pi_prime);
1112 1112
1113 request->r = r; 1113 request->r = r;
1114 request->r_prime = r_prime; 1114 request->r_prime = r_prime;
1115 1115
@@ -1157,7 +1157,7 @@ except:
1157 1157
1158/** 1158/**
1159 * Executed by Alice, fills in a service-request message and sends it to the given peer 1159 * Executed by Alice, fills in a service-request message and sends it to the given peer
1160 * 1160 *
1161 * @param session the session associated with this request, then also holds the CORE-handle 1161 * @param session the session associated with this request, then also holds the CORE-handle
1162 * @return #GNUNET_SYSERR if we could not send the message 1162 * @return #GNUNET_SYSERR if we could not send the message
1163 * #GNUNET_NO if the message was too large 1163 * #GNUNET_NO if the message was too large
@@ -1226,7 +1226,7 @@ prepare_service_request (void *cls,
1226 { 1226 {
1227 if (session->transferred_element_count <= j) 1227 if (session->transferred_element_count <= j)
1228 break; //reached end of this message, can't include more 1228 break; //reached end of this message, can't include more
1229 1229
1230 memset(element_exported, 0, PAILLIER_ELEMENT_LENGTH); 1230 memset(element_exported, 0, PAILLIER_ELEMENT_LENGTH);
1231 value = session->vector[i] >= 0 ? session->vector[i] : -session->vector[i]; 1231 value = session->vector[i] >= 0 ? session->vector[i] : -session->vector[i];
1232 1232
@@ -1287,10 +1287,10 @@ prepare_service_request (void *cls,
1287 1287
1288 1288
1289/** 1289/**
1290 * Handler for a client request message. 1290 * Handler for a client request message.
1291 * Can either be type A or B 1291 * Can either be type A or B
1292 * A: request-initiation to compute a scalar product with a peer 1292 * A: request-initiation to compute a scalar product with a peer
1293 * B: response role, keep the values + session and wait for a matching session or process a waiting request 1293 * B: response role, keep the values + session and wait for a matching session or process a waiting request
1294 * 1294 *
1295 * @param cls closure 1295 * @param cls closure
1296 * @param client identification of the client 1296 * @param client identification of the client
@@ -1454,7 +1454,7 @@ handle_client_request (void *cls,
1454 GNUNET_SERVER_client_set_user_context (client, session); 1454 GNUNET_SERVER_client_set_user_context (client, session);
1455 GNUNET_CONTAINER_DLL_insert (from_client_head, from_client_tail, session); 1455 GNUNET_CONTAINER_DLL_insert (from_client_head, from_client_tail, session);
1456 1456
1457 //check if service queue contains a matching request 1457 //check if service queue contains a matching request
1458 requesting_session = find_matching_session (from_service_tail, 1458 requesting_session = find_matching_session (from_service_tail,
1459 &session->key, 1459 &session->key,
1460 session->element_count, 1460 session->element_count,
@@ -1480,7 +1480,7 @@ handle_client_request (void *cls,
1480 1480
1481 1481
1482/** 1482/**
1483 * Function called for inbound tunnels. 1483 * Function called for inbound tunnels.
1484 * 1484 *
1485 * @param cls closure 1485 * @param cls closure
1486 * @param tunnel new handle to the tunnel 1486 * @param tunnel new handle to the tunnel
@@ -1507,8 +1507,8 @@ tunnel_incoming_handler (void *cls,
1507 1507
1508/** 1508/**
1509 * Function called whenever a tunnel is destroyed. Should clean up 1509 * Function called whenever a tunnel is destroyed. Should clean up
1510 * any associated state. 1510 * any associated state.
1511 * 1511 *
1512 * It must NOT call GNUNET_MESH_tunnel_destroy on the tunnel. 1512 * It must NOT call GNUNET_MESH_tunnel_destroy on the tunnel.
1513 * 1513 *
1514 * @param cls closure (set from GNUNET_MESH_connect) 1514 * @param cls closure (set from GNUNET_MESH_connect)
@@ -1561,7 +1561,7 @@ tunnel_destruction_handler (void *cls,
1561 NULL, NULL); 1561 NULL, NULL);
1562 free_session (session); 1562 free_session (session);
1563 1563
1564 // the client has to check if it was waiting for a result 1564 // the client has to check if it was waiting for a result
1565 // or if it was a responder, no point in adding more statefulness 1565 // or if it was a responder, no point in adding more statefulness
1566 if (client_session && (!do_shutdown)) 1566 if (client_session && (!do_shutdown))
1567 { 1567 {
@@ -1576,15 +1576,15 @@ tunnel_destruction_handler (void *cls,
1576 1576
1577/** 1577/**
1578 * Compute our scalar product, done by Alice 1578 * Compute our scalar product, done by Alice
1579 * 1579 *
1580 * @param session - the session associated with this computation 1580 * @param session - the session associated with this computation
1581 * @param kp - (1) from the protocol definition: 1581 * @param kp - (1) from the protocol definition:
1582 * $E_A(a_{\pi(i)}) \otimes E_A(- r_{\pi(i)} - b_{\pi(i)}) &= E_A(a_{\pi(i)} - r_{\pi(i)} - b_{\pi(i)})$ 1582 * $E_A(a_{\pi(i)}) \otimes E_A(- r_{\pi(i)} - b_{\pi(i)}) &= E_A(a_{\pi(i)} - r_{\pi(i)} - b_{\pi(i)})$
1583 * @param kq - (2) from the protocol definition: 1583 * @param kq - (2) from the protocol definition:
1584 * $E_A(a_{\pi'(i)}) \otimes E_A(- r_{\pi'(i)}) &= E_A(a_{\pi'(i)} - r_{\pi'(i)})$ 1584 * $E_A(a_{\pi'(i)}) \otimes E_A(- r_{\pi'(i)}) &= E_A(a_{\pi'(i)} - r_{\pi'(i)})$
1585 * @param s - S from the protocol definition: 1585 * @param s - S from the protocol definition:
1586 * $S := E_A(\sum (r_i + b_i)^2)$ 1586 * $S := E_A(\sum (r_i + b_i)^2)$
1587 * @param stick - S' from the protocol definition: 1587 * @param stick - S' from the protocol definition:
1588 * $S' := E_A(\sum r_i^2)$ 1588 * $S' := E_A(\sum r_i^2)$
1589 * @return product as MPI, never NULL 1589 * @return product as MPI, never NULL
1590 */ 1590 */
@@ -1667,8 +1667,8 @@ compute_scalar_product (struct ServiceSession * session,
1667 1667
1668/** 1668/**
1669 * prepare the response we will send to alice or bobs' clients. 1669 * prepare the response we will send to alice or bobs' clients.
1670 * in Bobs case the product will be NULL. 1670 * in Bobs case the product will be NULL.
1671 * 1671 *
1672 * @param session the session associated with our client. 1672 * @param session the session associated with our client.
1673 */ 1673 */
1674static void 1674static void
@@ -1873,7 +1873,7 @@ handle_service_request (void *cls,
1873 1873
1874 current += pk_length; 1874 current += pk_length;
1875 1875
1876 //check if service queue contains a matching request 1876 //check if service queue contains a matching request
1877 needed_state = CLIENT_RESPONSE_RECEIVED; 1877 needed_state = CLIENT_RESPONSE_RECEIVED;
1878 responder_session = find_matching_session (from_client_tail, 1878 responder_session = find_matching_session (from_client_tail,
1879 &session->key, 1879 &session->key,
diff --git a/src/scalarproduct/scalarproduct.h b/src/scalarproduct/scalarproduct.h
index af2e251e1..18e782ac0 100644
--- a/src/scalarproduct/scalarproduct.h
+++ b/src/scalarproduct/scalarproduct.h
@@ -42,7 +42,7 @@ extern "C"
42#define KEYBITS 2048 42#define KEYBITS 2048
43 43
44/** 44/**
45 * When performing our crypto, we may add two encrypted values with each 45 * When performing our crypto, we may add two encrypted values with each
46 * a maximal length of GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH. 46 * a maximal length of GNUNET_CRYPTO_RSA_DATA_ENCODING_LENGTH.
47 * thus we can receive a slightly longer element (+1 byte) 47 * thus we can receive a slightly longer element (+1 byte)
48 */ 48 */
@@ -60,7 +60,7 @@ extern "C"
60/////////////////////////////////////////////////////////////////////////////// 60///////////////////////////////////////////////////////////////////////////////
61 61
62/** 62/**
63 * Message type passed from client to service 63 * Message type passed from client to service
64 * to initiate a request or responder role 64 * to initiate a request or responder role
65 */ 65 */
66struct GNUNET_SCALARPRODUCT_client_request 66struct GNUNET_SCALARPRODUCT_client_request
@@ -94,7 +94,7 @@ struct GNUNET_SCALARPRODUCT_client_request
94 * followed by long vector[element_count] | [unsigned char mask[mask_bytes]] 94 * followed by long vector[element_count] | [unsigned char mask[mask_bytes]]
95 */ 95 */
96}; 96};
97 97
98/** 98/**
99 * Message type passed from requesting service Alice to responding service Bob 99 * Message type passed from requesting service Alice to responding service Bob
100 * to initiate a request and make bob participate in our protocol 100 * to initiate a request and make bob participate in our protocol
@@ -109,12 +109,12 @@ struct GNUNET_SCALARPRODUCT_service_request {
109 * how many elements the total message including all multipart msgs contains 109 * how many elements the total message including all multipart msgs contains
110 */ 110 */
111 uint32_t total_element_count GNUNET_PACKED; 111 uint32_t total_element_count GNUNET_PACKED;
112 112
113 /** 113 /**
114 * how many elements are actually included after the mask was applied. 114 * how many elements are actually included after the mask was applied.
115 */ 115 */
116 uint32_t contained_element_count GNUNET_PACKED; 116 uint32_t contained_element_count GNUNET_PACKED;
117 117
118 /** 118 /**
119 * how many bytes the mask has 119 * how many bytes the mask has
120 */ 120 */
@@ -153,7 +153,7 @@ struct GNUNET_SCALARPRODUCT_multipart_message {
153 * how many elements we supply within this message 153 * how many elements we supply within this message
154 */ 154 */
155 uint32_t multipart_element_count GNUNET_PACKED; 155 uint32_t multipart_element_count GNUNET_PACKED;
156 156
157 // followed by vector[multipart_element_count] or k[i][perm] 157 // followed by vector[multipart_element_count] or k[i][perm]
158}; 158};
159 159
@@ -171,12 +171,12 @@ struct GNUNET_SCALARPRODUCT_service_response {
171 * how many elements the session input had 171 * how many elements the session input had
172 */ 172 */
173 uint32_t total_element_count GNUNET_PACKED; 173 uint32_t total_element_count GNUNET_PACKED;
174 174
175 /** 175 /**
176 * how many elements were included after the mask was applied including all multipart msgs. 176 * how many elements were included after the mask was applied including all multipart msgs.
177 */ 177 */
178 uint32_t used_element_count GNUNET_PACKED; 178 uint32_t used_element_count GNUNET_PACKED;
179 179
180 /** 180 /**
181 * how many elements this individual message delivers 181 * how many elements this individual message delivers
182 */ 182 */
@@ -227,7 +227,7 @@ struct GNUNET_SCALARPRODUCT_client_response
227 * followed by product of length product_length (or nothing) 227 * followed by product of length product_length (or nothing)
228 */ 228 */
229}; 229};
230 230
231#ifdef __cplusplus 231#ifdef __cplusplus
232} 232}
233#endif 233#endif
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c
index a6d32f9ab..0f8a409cc 100644
--- a/src/scalarproduct/scalarproduct_api.c
+++ b/src/scalarproduct/scalarproduct_api.c
@@ -23,7 +23,7 @@
23 * @brief API for the scalarproduct 23 * @brief API for the scalarproduct
24 * @author Christian Fuchs 24 * @author Christian Fuchs
25 * @author Gaurav Kukreja 25 * @author Gaurav Kukreja
26 * 26 *
27 */ 27 */
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
@@ -145,9 +145,9 @@ GNUNET_SCALARPRODUCT_cancel (struct GNUNET_SCALARPRODUCT_ComputationHandle * h);
145 145
146 146
147/** 147/**
148 * Handles the RESULT received in reply of prepare_response from the 148 * Handles the RESULT received in reply of prepare_response from the
149 * service 149 * service
150 * 150 *
151 * @param cls Handle to the Master Context 151 * @param cls Handle to the Master Context
152 * @param msg Pointer to the response received 152 * @param msg Pointer to the response received
153 */ 153 */
@@ -163,9 +163,9 @@ process_status_message (void *cls,
163 163
164 164
165/** 165/**
166 * Handles the RESULT received in reply of prepare_response from the 166 * Handles the RESULT received in reply of prepare_response from the
167 * service 167 * service
168 * 168 *
169 * @param cls Handle to the Master Context 169 * @param cls Handle to the Master Context
170 * @param msg Pointer to the response received 170 * @param msg Pointer to the response received
171 */ 171 */
@@ -215,7 +215,7 @@ process_result_message (void *cls,
215 * Called when a response is received from the service. After basic check 215 * Called when a response is received from the service. After basic check
216 * handler in qe->response_proc is called. This functions handles the response 216 * handler in qe->response_proc is called. This functions handles the response
217 * to the client which used the API. 217 * to the client which used the API.
218 * 218 *
219 * @param cls Pointer to the Master Context 219 * @param cls Pointer to the Master Context
220 * @param msg Pointer to the data received in response 220 * @param msg Pointer to the data received in response
221 */ 221 */
@@ -245,7 +245,7 @@ receive_cb (void *cls, const struct GNUNET_MessageHeader *msg)
245 245
246 status = GNUNET_SCALARPRODUCT_Status_Success; 246 status = GNUNET_SCALARPRODUCT_Status_Success;
247 } 247 }
248 248
249 if (qe->cont_datum != NULL) 249 if (qe->cont_datum != NULL)
250 qe->response_proc (qe, msg, status); 250 qe->response_proc (qe, msg, status);
251 251
@@ -256,11 +256,11 @@ receive_cb (void *cls, const struct GNUNET_MessageHeader *msg)
256 256
257/** 257/**
258 * Transmits the request to the VectorProduct Sevice 258 * Transmits the request to the VectorProduct Sevice
259 * 259 *
260 * @param cls Closure 260 * @param cls Closure
261 * @param size Size of the buffer 261 * @param size Size of the buffer
262 * @param buf Pointer to the buffer 262 * @param buf Pointer to the buffer
263 * 263 *
264 * @return Size of the message sent 264 * @return Size of the message sent
265 */ 265 */
266static size_t 266static size_t
@@ -279,7 +279,7 @@ transmit_request (void *cls, size_t size,
279 // notify caller about the error, done here. 279 // notify caller about the error, done here.
280 if (qe->cont_datum != NULL) 280 if (qe->cont_datum != NULL)
281 qe->response_proc (qe, NULL, GNUNET_SCALARPRODUCT_Status_Failure); 281 qe->response_proc (qe, NULL, GNUNET_SCALARPRODUCT_Status_Failure);
282 282
283 GNUNET_SCALARPRODUCT_cancel (cls); 283 GNUNET_SCALARPRODUCT_cancel (cls);
284 return 0; 284 return 0;
285 } 285 }
@@ -307,8 +307,8 @@ transmit_request (void *cls, size_t size,
307 307
308 308
309/** 309/**
310 * Used by Bob's client to cooperate with Alice, 310 * Used by Bob's client to cooperate with Alice,
311 * 311 *
312 * @param h handle to the master context 312 * @param h handle to the master context
313 * @param key Session key - unique to the requesting client 313 * @param key Session key - unique to the requesting client
314 * @param elements Array of elements of the vector 314 * @param elements Array of elements of the vector
@@ -358,7 +358,7 @@ GNUNET_SCALARPRODUCT_response (const struct GNUNET_CONFIGURATION_Handle *cfg,
358 h->response_proc = &process_status_message; 358 h->response_proc = &process_status_message;
359 h->cfg = cfg; 359 h->cfg = cfg;
360 memcpy (&h->key, key, sizeof (struct GNUNET_HashCode)); 360 memcpy (&h->key, key, sizeof (struct GNUNET_HashCode));
361 361
362 msg = (struct GNUNET_SCALARPRODUCT_client_request*) GNUNET_malloc (size); 362 msg = (struct GNUNET_SCALARPRODUCT_client_request*) GNUNET_malloc (size);
363 h->msg = msg; 363 h->msg = msg;
364 msg->header.size = htons (size); 364 msg->header.size = htons (size);
@@ -393,7 +393,7 @@ GNUNET_SCALARPRODUCT_response (const struct GNUNET_CONFIGURATION_Handle *cfg,
393 393
394/** 394/**
395 * Request by Alice's client for computing a scalar product 395 * Request by Alice's client for computing a scalar product
396 * 396 *
397 * @param h handle to the master context 397 * @param h handle to the master context
398 * @param key Session key - unique to the requesting client 398 * @param key Session key - unique to the requesting client
399 * @param peer PeerID of the other peer 399 * @param peer PeerID of the other peer
@@ -451,7 +451,7 @@ GNUNET_SCALARPRODUCT_request (const struct GNUNET_CONFIGURATION_Handle *cfg,
451 h->response_proc = &process_result_message; 451 h->response_proc = &process_result_message;
452 h->cfg = cfg; 452 h->cfg = cfg;
453 memcpy (&h->key, key, sizeof (struct GNUNET_HashCode)); 453 memcpy (&h->key, key, sizeof (struct GNUNET_HashCode));
454 454
455 msg = (struct GNUNET_SCALARPRODUCT_client_request*) GNUNET_malloc (size); 455 msg = (struct GNUNET_SCALARPRODUCT_client_request*) GNUNET_malloc (size);
456 h->msg = msg; 456 h->msg = msg;
457 msg->header.size = htons (size); 457 msg->header.size = htons (size);
@@ -463,7 +463,7 @@ GNUNET_SCALARPRODUCT_request (const struct GNUNET_CONFIGURATION_Handle *cfg,
463 // copy each element over to the message 463 // copy each element over to the message
464 for (i = 0; i < element_count; i++) 464 for (i = 0; i < element_count; i++)
465 vector[i] = htonl (elements[i]); 465 vector[i] = htonl (elements[i]);
466 466
467 memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); 467 memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
468 memcpy (&msg->key, key, sizeof (struct GNUNET_HashCode)); 468 memcpy (&msg->key, key, sizeof (struct GNUNET_HashCode));
469 memcpy (&vector[element_count], mask, mask_bytes); 469 memcpy (&vector[element_count], mask, mask_bytes);
@@ -489,7 +489,7 @@ GNUNET_SCALARPRODUCT_request (const struct GNUNET_CONFIGURATION_Handle *cfg,
489 489
490/** 490/**
491 * Disconnect from the scalarproduct service. 491 * Disconnect from the scalarproduct service.
492 * 492 *
493 * @param h a computation handle to cancel 493 * @param h a computation handle to cancel
494 */ 494 */
495void 495void
diff --git a/src/scalarproduct/scalarproduct_testing.h b/src/scalarproduct/scalarproduct_testing.h
index a386fb0c7..5e7baa235 100644
--- a/src/scalarproduct/scalarproduct_testing.h
+++ b/src/scalarproduct/scalarproduct_testing.h
@@ -17,7 +17,7 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 */ 19 */
20/** 20/**
21 * @file scalarproduct/scalarproduct_testing.h 21 * @file scalarproduct/scalarproduct_testing.h
22 * @brief VectorProduct testcase common declarations 22 * @brief VectorProduct testcase common declarations
23 * @author Gaurav Kukreja 23 * @author Gaurav Kukreja
@@ -32,14 +32,14 @@
32#ifdef __cplusplus 32#ifdef __cplusplus
33extern "C" { 33extern "C" {
34#endif 34#endif
35 35
36struct GNUNET_SCALARPRODUCT_TESTING_handle 36struct GNUNET_SCALARPRODUCT_TESTING_handle
37{ 37{
38 /** 38 /**
39 * Testing library system handle 39 * Testing library system handle
40 */ 40 */
41 struct GNUNET_TESTING_System *tl_system; 41 struct GNUNET_TESTING_System *tl_system;
42 42
43 /** 43 /**
44 * head DLL of peers 44 * head DLL of peers
45 */ 45 */
@@ -51,7 +51,7 @@ struct GNUNET_SCALARPRODUCT_TESTING_handle
51 struct PeerContext *p_tail; 51 struct PeerContext *p_tail;
52}; 52};
53 53
54struct PeerContext 54struct PeerContext
55{ 55{
56 /** 56 /**
57 * Next element in the DLL 57 * Next element in the DLL
@@ -72,17 +72,17 @@ struct PeerContext
72 * Peer identity 72 * Peer identity
73 */ 73 */
74 struct GNUNET_PeerIdentity id; 74 struct GNUNET_PeerIdentity id;
75 75
76 /** 76 /**
77 * Handle for the peer's ARM process 77 * Handle for the peer's ARM process
78 */ 78 */
79 struct GNUNET_OS_Process *arm_proc; 79 struct GNUNET_OS_Process *arm_proc;
80 80
81 /** 81 /**
82 * Pointer to Vector Product Handle 82 * Pointer to Vector Product Handle
83 */ 83 */
84 struct GNUNET_SCALARPRODUCT_Handle *vh; 84 struct GNUNET_SCALARPRODUCT_Handle *vh;
85 85
86 /** 86 /**
87 * Closure for the callbacks 87 * Closure for the callbacks
88 */ 88 */
@@ -92,23 +92,23 @@ struct PeerContext
92 * An unique number to identify the peer 92 * An unique number to identify the peer
93 */ 93 */
94 unsigned int no; 94 unsigned int no;
95 95
96 /** 96 /**
97 * Peer's configuration 97 * Peer's configuration
98 */ 98 */
99 struct GNUNET_CONFIGURATION_Handle *cfg; 99 struct GNUNET_CONFIGURATION_Handle *cfg;
100 100
101 /** 101 /**
102 * Pointer to the master testing handle 102 * Pointer to the master testing handle
103 */ 103 */
104 struct GNUNET_SCALARPRODUCT_TESTING_handle * vth; 104 struct GNUNET_SCALARPRODUCT_TESTING_handle * vth;
105 105
106 /** 106 /**
107 * Callback when two peers are connected and both have called the connect callback 107 * Callback when two peers are connected and both have called the connect callback
108 * to notify clients about a new peer 108 * to notify clients about a new peer
109 */ 109 */
110 void (*start_cb) (struct PeerContext * p, void *cls); 110 void (*start_cb) (struct PeerContext * p, void *cls);
111 111
112// /** 112// /**
113// * Pointer to function where the test occurs 113// * Pointer to function where the test occurs
114// */ 114// */
diff --git a/src/scalarproduct/test_scalarproduct_api.c b/src/scalarproduct/test_scalarproduct_api.c
index e28074fd4..082723278 100644
--- a/src/scalarproduct/test_scalarproduct_api.c
+++ b/src/scalarproduct/test_scalarproduct_api.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21/** 21/**
22 * Aim of test_scalarproduct_api : This test creates two peers. Peer1 is the 22 * Aim of test_scalarproduct_api : This test creates two peers. Peer1 is the
23 * responder peer, Bob and Peer2 is the initiator peer, Alice. Both peers 23 * responder peer, Bob and Peer2 is the initiator peer, Alice. Both peers
24 * connect to VectorProduct Service, and use the API to issue requests to 24 * connect to VectorProduct Service, and use the API to issue requests to
25 * service. Test passes, when the expected scalar product is received from the 25 * service. Test passes, when the expected scalar product is received from the
@@ -219,7 +219,7 @@ do_close (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
219 219
220/** 220/**
221 * Shutdown a peer 221 * Shutdown a peer
222 * 222 *
223 * @param cls pointer to "struct PeerData" of the peer to be disconnected 223 * @param cls pointer to "struct PeerData" of the peer to be disconnected
224 * @param tc Task Context 224 * @param tc Task Context
225 */ 225 */
@@ -272,7 +272,7 @@ controller_event_cb (void *cls,
272 const struct GNUNET_TESTBED_EventInformation *event) 272 const struct GNUNET_TESTBED_EventInformation *event)
273{ 273{
274 GNUNET_assert (event->type == GNUNET_TESTBED_ET_OPERATION_FINISHED); 274 GNUNET_assert (event->type == GNUNET_TESTBED_ET_OPERATION_FINISHED);
275 275
276 switch (setup_state) 276 switch (setup_state)
277 { 277 {
278 case PEER1_SCALARPRODUCT_CONNECT: 278 case PEER1_SCALARPRODUCT_CONNECT:
@@ -366,7 +366,7 @@ requester_callback (void *cls,
366 { 366 {
367 LOG (GNUNET_ERROR_TYPE_INFO, "Requester Client expected response received!\n"); 367 LOG (GNUNET_ERROR_TYPE_INFO, "Requester Client expected response received!\n");
368 product_len = ntohl(msg->product_length); 368 product_len = ntohl(msg->product_length);
369 369
370 if (0 < product_len) 370 if (0 < product_len)
371 { 371 {
372 gcry_mpi_t result; 372 gcry_mpi_t result;
@@ -383,7 +383,7 @@ requester_callback (void *cls,
383 { 383 {
384 uint16_t i = 0; 384 uint16_t i = 0;
385 385
386 // calculate expected product 386 // calculate expected product
387 gcry_mpi_t expected_result; 387 gcry_mpi_t expected_result;
388 gcry_mpi_t v1; 388 gcry_mpi_t v1;
389 gcry_mpi_t v2; 389 gcry_mpi_t v2;
@@ -424,7 +424,7 @@ requester_callback (void *cls,
424 gcry_mpi_release (v1_v2_prod); 424 gcry_mpi_release (v1_v2_prod);
425 425
426 } 426 }
427 427
428 // compare the result 428 // compare the result
429 if (!gcry_mpi_cmp (expected_result, result)) 429 if (!gcry_mpi_cmp (expected_result, result))
430 { 430 {
@@ -453,7 +453,7 @@ requester_callback (void *cls,
453} 453}
454 454
455/** 455/**
456 * Prepare the message to be sent by peer2 to its scalarproduct service, to 456 * Prepare the message to be sent by peer2 to its scalarproduct service, to
457 * initiate a request to peer1. 457 * initiate a request to peer1.
458 */ 458 */
459static struct GNUNET_SCALARPRODUCT_QueueEntry * 459static struct GNUNET_SCALARPRODUCT_QueueEntry *
@@ -467,9 +467,9 @@ requester_request ()
467 int32_t element; 467 int32_t element;
468 struct GNUNET_SCALARPRODUCT_QueueEntry *qe; 468 struct GNUNET_SCALARPRODUCT_QueueEntry *qe;
469 struct GNUNET_HashCode key; 469 struct GNUNET_HashCode key;
470 470
471 GNUNET_assert (peer2.vh != NULL); 471 GNUNET_assert (peer2.vh != NULL);
472 472
473 GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key); 473 GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key);
474 474
475 /* Read input_elements_peer2, and put in elements_peer2 array */ 475 /* Read input_elements_peer2, and put in elements_peer2 array */
@@ -501,7 +501,7 @@ requester_request ()
501 while (!exit_loop && element_count_peer2 < max_mids); 501 while (!exit_loop && element_count_peer2 < max_mids);
502 GNUNET_assert (elements_peer2 != NULL); 502 GNUNET_assert (elements_peer2 != NULL);
503 GNUNET_assert (element_count_peer2 >= 1); 503 GNUNET_assert (element_count_peer2 >= 1);
504 504
505 /* Read input_mask_peer2 and read in mask_peer2 array */ 505 /* Read input_mask_peer2 and read in mask_peer2 array */
506 mask_length = element_count_peer2 / 8 + (element_count_peer2 % 8 ? 1 : 0); 506 mask_length = element_count_peer2 / 8 + (element_count_peer2 % 8 ? 1 : 0);
507 mask_peer2 = GNUNET_malloc ((element_count_peer2 / 8) + 2); 507 mask_peer2 = GNUNET_malloc ((element_count_peer2 / 8) + 2);
@@ -584,7 +584,7 @@ responder_prepare_response ()
584 int32_t element; 584 int32_t element;
585 struct GNUNET_SCALARPRODUCT_QueueEntry *qe; 585 struct GNUNET_SCALARPRODUCT_QueueEntry *qe;
586 struct GNUNET_HashCode key; 586 struct GNUNET_HashCode key;
587 587
588 GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key); 588 GNUNET_CRYPTO_hash (input_key, strlen (input_key), &key);
589 589
590 /* Read input_elements_peer1, and put in elements_peer1 array */ 590 /* Read input_elements_peer1, and put in elements_peer1 array */
@@ -638,7 +638,7 @@ responder_prepare_response ()
638 638
639/** 639/**
640 * Scheduler task to initiate requester client 640 * Scheduler task to initiate requester client
641 * 641 *
642 * @param cls void* to struct PeerData 642 * @param cls void* to struct PeerData
643 * @param tc Task Context 643 * @param tc Task Context
644 */ 644 */
@@ -653,7 +653,7 @@ request_task(void *cls,
653 653
654/** 654/**
655 * Scheduler task to initiate responder client 655 * Scheduler task to initiate responder client
656 * 656 *
657 * @param cls void* to struct PeerData 657 * @param cls void* to struct PeerData
658 * @param tc Task Context 658 * @param tc Task Context
659 */ 659 */
@@ -661,7 +661,7 @@ static void
661prepare_response_task(void *cls, 661prepare_response_task(void *cls,
662 const struct GNUNET_SCHEDULER_TaskContext 662 const struct GNUNET_SCHEDULER_TaskContext
663 * tc) 663 * tc)
664{ 664{
665 responder_prepare_response(); 665 responder_prepare_response();
666 return; 666 return;
667} 667}
@@ -672,7 +672,7 @@ prepare_response_task(void *cls,
672 * a service. This function is called when GNUNET_TESTBED_operation_done is 672 * a service. This function is called when GNUNET_TESTBED_operation_done is
673 * called for peer->op, which holds the handle for GNUNET_TESTBED_service_connect 673 * called for peer->op, which holds the handle for GNUNET_TESTBED_service_connect
674 * operation. 674 * operation.
675 * 675 *
676 * @param cls closure 676 * @param cls closure
677 * @param op_result service handle returned from the connect adapter 677 * @param op_result service handle returned from the connect adapter
678 */ 678 */
@@ -689,7 +689,7 @@ scalarproduct_da (void *cls, void *op_result)
689/** 689/**
690 * Adapter function called to establish a connection to 690 * Adapter function called to establish a connection to
691 * a service. This function is called to by GNUNET_TESTBED_service_connect. 691 * a service. This function is called to by GNUNET_TESTBED_service_connect.
692 * 692 *
693 * @param cls closure 693 * @param cls closure
694 * @param cfg configuration of the peer to connect to; will be available until 694 * @param cfg configuration of the peer to connect to; will be available until
695 * GNUNET_TESTBED_operation_done() is called on the operation returned 695 * GNUNET_TESTBED_operation_done() is called on the operation returned
@@ -729,7 +729,7 @@ scalarproduct_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
729 GNUNET_SCHEDULER_add_now(&prepare_response_task, &peer1); 729 GNUNET_SCHEDULER_add_now(&prepare_response_task, &peer1);
730 GNUNET_SCHEDULER_add_now(&request_task, &peer2); 730 GNUNET_SCHEDULER_add_now(&request_task, &peer2);
731 } 731 }
732 732
733 return peer2.vh; 733 return peer2.vh;
734 default: 734 default:
735 GNUNET_assert (0); 735 GNUNET_assert (0);
@@ -814,7 +814,7 @@ test_master (void *cls, unsigned int num_peers,
814 GNUNET_TESTBED_PIT_IDENTITY, 814 GNUNET_TESTBED_PIT_IDENTITY,
815 &peerinfo_cb, NULL); 815 &peerinfo_cb, NULL);
816 setup_state = PEER1_GET_IDENTITY; 816 setup_state = PEER1_GET_IDENTITY;
817 817
818 /* Abort task for stopping test on timeout */ 818 /* Abort task for stopping test on timeout */
819 abort_task = 819 abort_task =
820 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 820 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
@@ -842,7 +842,7 @@ main (int argc, char **argv)
842 NUM_PEERS, event_mask, &controller_event_cb, 842 NUM_PEERS, event_mask, &controller_event_cb,
843 NULL, 843 NULL,
844 &test_master, NULL); 844 &test_master, NULL);
845 845
846 if (GNUNET_SYSERR == ok) 846 if (GNUNET_SYSERR == ok)
847 { 847 {
848 LOG (GNUNET_ERROR_TYPE_ERROR, "Test failing due to some error before calling API for request or prepare_response\n"); 848 LOG (GNUNET_ERROR_TYPE_ERROR, "Test failing due to some error before calling API for request or prepare_response\n");