aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-10-04 14:20:04 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-10-04 14:20:04 +0000
commitc53de7e597b8f10efe19b0e44e879a4c7a431580 (patch)
treeea8075bc4d6fd6343b3a90cec3e578d2a9df0a91 /src/scalarproduct
parentc7d80251ce87a5015409446d9ac93658ad5ca5d7 (diff)
downloadgnunet-c53de7e597b8f10efe19b0e44e879a4c7a431580.tar.gz
gnunet-c53de7e597b8f10efe19b0e44e879a4c7a431580.zip
added first part of multipart-message support to SP
extended and renamed properties in existing structs and message formats for multipart support fixed a memory leak
Diffstat (limited to 'src/scalarproduct')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.c150
-rw-r--r--src/scalarproduct/scalarproduct.h43
2 files changed, 128 insertions, 65 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c
index ec3dbe893..f4586235e 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct.c
@@ -48,6 +48,7 @@ enum SessionState
48 WAITING_FOR_BOBS_CONNECT, 48 WAITING_FOR_BOBS_CONNECT,
49 CLIENT_RESPONSE_RECEIVED, 49 CLIENT_RESPONSE_RECEIVED,
50 WAITING_FOR_SERVICE_REQUEST, 50 WAITING_FOR_SERVICE_REQUEST,
51 WAITING_FOR_MULTIPART_TRANSMISSION,
51 WAITING_FOR_SERVICE_RESPONSE, 52 WAITING_FOR_SERVICE_RESPONSE,
52 SERVICE_REQUEST_RECEIVED, 53 SERVICE_REQUEST_RECEIVED,
53 SERVICE_RESPONSE_RECEIVED, 54 SERVICE_RESPONSE_RECEIVED,
@@ -123,6 +124,11 @@ struct ServiceSession
123 uint32_t used_element_count; 124 uint32_t used_element_count;
124 125
125 /** 126 /**
127 * already transferred elements (sent/received) for multipart messages, less or equal than used_element_count for
128 */
129 uint32_t transferred_element_count;
130
131 /**
126 * how many bytes the mask is long. 132 * how many bytes the mask is long.
127 * 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
128 */ 134 */
@@ -511,6 +517,22 @@ do_send_message (void *cls, size_t size, void *buf)
511 session->state = FINALIZED; 517 session->state = FINALIZED;
512 session->client_transmit_handle = NULL; 518 session->client_transmit_handle = NULL;
513 break; 519 break;
520 case GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB:
521 case GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB_MULTIPART:
522 //else
523 session->service_transmit_handle = NULL;
524 // reset flags for sending
525 if ((session->state != WAITING_FOR_MULTIPART_TRANSMISSION) && (session->used_element_count != session->transferred_element_count))
526 prepare_service_request_multipart(session);
527 //TODO we have sent a message and now need to trigger trigger the next multipart message sending
528 break;
529 case GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE:
530 case GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE_MULTIPART:
531 //else
532 session->service_transmit_handle = NULL;
533 if ((session->state != WAITING_FOR_MULTIPART_TRANSMISSION) && (session->used_element_count != session->transferred_element_count))
534 prepare_service_response_multipart(session);
535 break;
514 default: 536 default:
515 session->service_transmit_handle = NULL; 537 session->service_transmit_handle = NULL;
516 } 538 }
@@ -808,101 +830,106 @@ prepare_service_response (gcry_mpi_t * r,
808 int i; 830 int i;
809 831
810 msg_length = sizeof (struct GNUNET_SCALARPRODUCT_service_response) 832 msg_length = sizeof (struct GNUNET_SCALARPRODUCT_service_response)
811 + 2 * request->used_element_count * PAILLIER_ELEMENT_LENGTH // kp, kq
812 + 2 * PAILLIER_ELEMENT_LENGTH; // s, stick 833 + 2 * PAILLIER_ELEMENT_LENGTH; // s, stick
813 834
835 if (GNUNET_SERVER_MAX_MESSAGE_SIZE > msg_length + 2 * request->used_element_count * PAILLIER_ELEMENT_LENGTH){ //kp, kq
836 msg_length += + 2 * request->used_element_count * PAILLIER_ELEMENT_LENGTH;
837 request->transferred_element_count = request->used_element_count;
838 }
839 else {
840 request->transferred_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - msg_length) / (PAILLIER_ELEMENT_LENGTH * 2);
841 }
842
814 msg = GNUNET_malloc (msg_length); 843 msg = GNUNET_malloc (msg_length);
815 844
816 msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE); 845 msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE);
817 msg->header.size = htons (msg_length); 846 msg->header.size = htons (msg_length);
818 msg->element_count = htonl (request->element_count); 847 msg->total_element_count = htonl (request->element_count);
819 msg->used_element_count = htonl (request->used_element_count); 848 msg->contained_element_count = htonl (request->used_element_count);
849 msg->contained_element_count = htonl (request->transferred_element_count);
820 memcpy (&msg->key, &request->key, sizeof (struct GNUNET_HashCode)); 850 memcpy (&msg->key, &request->key, sizeof (struct GNUNET_HashCode));
821 current = (unsigned char *) &msg[1]; 851 current = (unsigned char *) &msg[1];
822 852
853 element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH);
823 // 4 times the same logics with slight variations. 854 // 4 times the same logics with slight variations.
824 // doesn't really justify having 2 functions for that 855 // doesn't really justify having 2 functions for that
825 // so i put it into blocks to enhance readability 856 // so i put it into blocks to enhance readability
826 // convert s 857 // convert s
827 { 858 {
828 element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH); 859 memset(element_exported, 0, PAILLIER_ELEMENT_LENGTH);
829 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, 860 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG,
830 element_exported, PAILLIER_ELEMENT_LENGTH, 861 element_exported, PAILLIER_ELEMENT_LENGTH,
831 &element_length, 862 &element_length,
832 s)); 863 s));
833 adjust (element_exported, element_length, PAILLIER_ELEMENT_LENGTH); 864 adjust (element_exported, element_length, PAILLIER_ELEMENT_LENGTH);
834 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH); 865 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH);
835 GNUNET_free (element_exported);
836 current += PAILLIER_ELEMENT_LENGTH; 866 current += PAILLIER_ELEMENT_LENGTH;
837 } 867 }
838
839 // convert stick 868 // convert stick
840 { 869 {
841 element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH); 870 memset(element_exported, 0, PAILLIER_ELEMENT_LENGTH);
842 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, 871 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG,
843 element_exported, PAILLIER_ELEMENT_LENGTH, 872 element_exported, PAILLIER_ELEMENT_LENGTH,
844 &element_length, 873 &element_length,
845 s_prime)); 874 s_prime));
846 adjust (element_exported, element_length, PAILLIER_ELEMENT_LENGTH); 875 adjust (element_exported, element_length, PAILLIER_ELEMENT_LENGTH);
847 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH); 876 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH);
848 GNUNET_free (element_exported); 877
849 current += PAILLIER_ELEMENT_LENGTH; 878 current += PAILLIER_ELEMENT_LENGTH;
850 } 879 }
851 880 // convert k[][]
852 // convert kp[]
853 for (i = 0; i < request->used_element_count; i++) 881 for (i = 0; i < request->used_element_count; i++)
854 { 882 {
855 element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH); 883 if (request->transferred_element_count <= i)
884 break; //reached end of this message, can't include more
885
886 //k[i][p]
887 memset(element_exported, 0, PAILLIER_ELEMENT_LENGTH);
856 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, 888 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG,
857 element_exported, PAILLIER_ELEMENT_LENGTH, 889 element_exported, PAILLIER_ELEMENT_LENGTH,
858 &element_length, 890 &element_length,
859 r[i])); 891 r[i]));
860 adjust (element_exported, element_length, PAILLIER_ELEMENT_LENGTH); 892 adjust (element_exported, element_length, PAILLIER_ELEMENT_LENGTH);
861 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH); 893 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH);
862 GNUNET_free (element_exported);
863 current += PAILLIER_ELEMENT_LENGTH; 894 current += PAILLIER_ELEMENT_LENGTH;
864 } 895 //k[i][q]
865 896 memset(element_exported, 0, PAILLIER_ELEMENT_LENGTH);
866
867 // convert kq[]
868 for (i = 0; i < request->used_element_count; i++)
869 {
870 element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH);
871 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, 897 GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG,
872 element_exported, PAILLIER_ELEMENT_LENGTH, 898 element_exported, PAILLIER_ELEMENT_LENGTH,
873 &element_length, 899 &element_length,
874 r_prime[i])); 900 r_prime[i]));
875 adjust (element_exported, element_length, PAILLIER_ELEMENT_LENGTH); 901 adjust (element_exported, element_length, PAILLIER_ELEMENT_LENGTH);
876 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH); 902 memcpy (current, element_exported, PAILLIER_ELEMENT_LENGTH);
877 GNUNET_free (element_exported); 903 current += PAILLIER_ELEMENT_LENGTH;
878 current += PAILLIER_ELEMENT_LENGTH; 904 }
879 } 905 GNUNET_free (element_exported);
880 906
881 if (GNUNET_SERVER_MAX_MESSAGE_SIZE >= msg_length) 907 request->msg = (struct GNUNET_MessageHeader *) msg;
882 { 908 request->service_transmit_handle =
883 request->msg = (struct GNUNET_MessageHeader *) msg; 909 GNUNET_MESH_notify_transmit_ready (request->tunnel,
884 request->service_transmit_handle = 910 GNUNET_YES,
885 GNUNET_MESH_notify_transmit_ready (request->tunnel, 911 GNUNET_TIME_UNIT_FOREVER_REL,
886 GNUNET_YES, 912 msg_length,
887 GNUNET_TIME_UNIT_FOREVER_REL, 913 &do_send_message,
888 msg_length, 914 request);
889 &do_send_message,
890 request);
891 request->state = FINALIZED;
892 }
893 else
894 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Message too large, fragmentation is currently not supported!)\n"));
895
896 //disconnect our client 915 //disconnect our client
897 if (NULL == request->service_transmit_handle) 916 if (NULL == request->service_transmit_handle)
898 { 917 {
899 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-response message via mesh!)\n")); 918 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-response message via mesh!)\n"));
919 request->state = FINALIZED;
900 920
901 response->client_notification_task = 921 response->client_notification_task =
902 GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, 922 GNUNET_SCHEDULER_add_now (&prepare_client_end_notification,
903 response); 923 response);
904 return GNUNET_NO; 924 return GNUNET_NO;
905 } 925 }
926 if (request->transferred_element_count != request->used_element_count)
927 // multipart
928 request->state = WAITING_FOR_MULTIPART_TRANSMISSION;
929 else
930 //singlepart
931 request->state = FINALIZED;
932
906 return GNUNET_OK; 933 return GNUNET_OK;
907} 934}
908 935
@@ -1135,6 +1162,7 @@ prepare_service_request (void *cls,
1135{ 1162{
1136 struct ServiceSession * session = cls; 1163 struct ServiceSession * session = cls;
1137 unsigned char * current; 1164 unsigned char * current;
1165 unsigned char * element_exported;
1138 struct GNUNET_SCALARPRODUCT_service_request * msg; 1166 struct GNUNET_SCALARPRODUCT_service_request * msg;
1139 unsigned int i; 1167 unsigned int i;
1140 unsigned int j; 1168 unsigned int j;
@@ -1148,28 +1176,25 @@ prepare_service_request (void *cls,
1148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Successfully created new tunnel to peer (%s)!\n"), GNUNET_i2s (&session->peer)); 1176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Successfully created new tunnel to peer (%s)!\n"), GNUNET_i2s (&session->peer));
1149 1177
1150 msg_length = sizeof (struct GNUNET_SCALARPRODUCT_service_request) 1178 msg_length = sizeof (struct GNUNET_SCALARPRODUCT_service_request)
1151 +session->used_element_count * PAILLIER_ELEMENT_LENGTH
1152 + session->mask_length 1179 + session->mask_length
1153 + my_pubkey_external_length; 1180 + my_pubkey_external_length;
1154 1181
1155 if (GNUNET_SERVER_MAX_MESSAGE_SIZE < sizeof (struct GNUNET_SCALARPRODUCT_service_request) 1182 if (GNUNET_SERVER_MAX_MESSAGE_SIZE > msg_length + session->used_element_count * PAILLIER_ELEMENT_LENGTH){
1156 +session->used_element_count * PAILLIER_ELEMENT_LENGTH 1183 msg_length += session->used_element_count * PAILLIER_ELEMENT_LENGTH;
1157 + session->mask_length 1184 session->transferred_element_count = session->used_element_count;
1158 + my_pubkey_external_length) 1185 }
1159 { 1186 else {
1160 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Message too large, fragmentation is currently not supported!\n")); 1187 //create a multipart msg, first we calculate a new msg size for the head msg
1161 session->client_notification_task = 1188 session->transferred_element_count = (GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - msg_length) / PAILLIER_ELEMENT_LENGTH;
1162 GNUNET_SCHEDULER_add_now (&prepare_client_end_notification,
1163 session);
1164 return;
1165 } 1189 }
1166 1190
1167 msg = GNUNET_malloc (msg_length); 1191 msg = GNUNET_malloc (msg_length);
1168 msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB); 1192 msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB);
1193 msg->total_element_count = htonl(session->used_element_count);
1194 msg->contained_element_count = htonl (session->transferred_element_count);
1169 memcpy (&msg->key, &session->key, sizeof (struct GNUNET_HashCode)); 1195 memcpy (&msg->key, &session->key, sizeof (struct GNUNET_HashCode));
1170 msg->mask_length = htonl (session->mask_length); 1196 msg->mask_length = htonl (session->mask_length);
1171 msg->pk_length = htonl (my_pubkey_external_length); 1197 msg->pk_length = htonl (my_pubkey_external_length);
1172 msg->used_element_count = htonl (session->used_element_count);
1173 msg->element_count = htonl (session->element_count); 1198 msg->element_count = htonl (session->element_count);
1174 msg->header.size = htons (msg_length); 1199 msg->header.size = htons (msg_length);
1175 1200
@@ -1183,6 +1208,7 @@ prepare_service_request (void *cls,
1183 current += my_pubkey_external_length; 1208 current += my_pubkey_external_length;
1184 1209
1185 // now copy over the element vector 1210 // now copy over the element vector
1211 element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH);
1186 session->a = GNUNET_malloc (sizeof (gcry_mpi_t) * session->used_element_count); 1212 session->a = GNUNET_malloc (sizeof (gcry_mpi_t) * session->used_element_count);
1187 a = gcry_mpi_new (KEYBITS * 2); 1213 a = gcry_mpi_new (KEYBITS * 2);
1188 // encrypt our vector and generate string representations 1214 // encrypt our vector and generate string representations
@@ -1191,7 +1217,10 @@ prepare_service_request (void *cls,
1191 // if this is a used element... 1217 // if this is a used element...
1192 if (session->mask[i / 8] & 1 << (i % 8)) 1218 if (session->mask[i / 8] & 1 << (i % 8))
1193 { 1219 {
1194 unsigned char * element_exported = GNUNET_malloc (PAILLIER_ELEMENT_LENGTH); 1220 if (session->transferred_element_count <= j)
1221 break; //reached end of this message, can't include more
1222
1223 memset(element_exported, 0, PAILLIER_ELEMENT_LENGTH);
1195 value = session->vector[i] >= 0 ? session->vector[i] : -session->vector[i]; 1224 value = session->vector[i] >= 0 ? session->vector[i] : -session->vector[i];
1196 1225
1197 a = gcry_mpi_set_ui (a, 0); 1226 a = gcry_mpi_set_ui (a, 0);
@@ -1221,6 +1250,7 @@ prepare_service_request (void *cls,
1221 } 1250 }
1222 } 1251 }
1223 gcry_mpi_release (a); 1252 gcry_mpi_release (a);
1253 GNUNET_free(element_exported);
1224 1254
1225 session->msg = (struct GNUNET_MessageHeader *) msg; 1255 session->msg = (struct GNUNET_MessageHeader *) msg;
1226 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Transmitting service request.\n")); 1256 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Transmitting service request.\n"));
@@ -1241,7 +1271,11 @@ prepare_service_request (void *cls,
1241 session); 1271 session);
1242 return; 1272 return;
1243 } 1273 }
1244 session->state = WAITING_FOR_SERVICE_RESPONSE; 1274 if (session->transferred_element_count != session->used_element_count)
1275 session->state = WAITING_FOR_MULTIPART_TRANSMISSION;
1276 else
1277 //singlepart message
1278 session->state = WAITING_FOR_SERVICE_RESPONSE;
1245} 1279}
1246 1280
1247 1281
@@ -1781,7 +1815,7 @@ handle_service_request (void *cls,
1781 } 1815 }
1782 mask_length = ntohl (msg->mask_length); 1816 mask_length = ntohl (msg->mask_length);
1783 pk_length = ntohl (msg->pk_length); 1817 pk_length = ntohl (msg->pk_length);
1784 used_elements = ntohl (msg->used_element_count); 1818 used_elements = ntohl (msg->contained_element_count);
1785 element_count = ntohl (msg->element_count); 1819 element_count = ntohl (msg->element_count);
1786 msg_length = sizeof (struct GNUNET_SCALARPRODUCT_service_request) 1820 msg_length = sizeof (struct GNUNET_SCALARPRODUCT_service_request)
1787 +mask_length + pk_length + used_elements * PAILLIER_ELEMENT_LENGTH; 1821 +mask_length + pk_length + used_elements * PAILLIER_ELEMENT_LENGTH;
@@ -1932,7 +1966,7 @@ handle_service_response (void *cls,
1932 gcry_mpi_t s_prime = NULL; 1966 gcry_mpi_t s_prime = NULL;
1933 size_t read; 1967 size_t read;
1934 size_t i; 1968 size_t i;
1935 uint32_t used_element_count; 1969 uint32_t contained_element_count;
1936 size_t msg_size; 1970 size_t msg_size;
1937 gcry_mpi_t * r = NULL; 1971 gcry_mpi_t * r = NULL;
1938 gcry_mpi_t * r_prime = NULL; 1972 gcry_mpi_t * r_prime = NULL;
@@ -1956,12 +1990,12 @@ handle_service_response (void *cls,
1956 GNUNET_break_op (0); 1990 GNUNET_break_op (0);
1957 goto invalid_msg; 1991 goto invalid_msg;
1958 } 1992 }
1959 used_element_count = ntohl (msg->used_element_count); 1993 contained_element_count = ntohl (msg->contained_element_count);
1960 msg_size = sizeof (struct GNUNET_SCALARPRODUCT_service_response) 1994 msg_size = sizeof (struct GNUNET_SCALARPRODUCT_service_response)
1961 + 2 * used_element_count * PAILLIER_ELEMENT_LENGTH 1995 + 2 * contained_element_count * PAILLIER_ELEMENT_LENGTH
1962 + 2 * PAILLIER_ELEMENT_LENGTH; 1996 + 2 * PAILLIER_ELEMENT_LENGTH;
1963 //sanity check: is the message as long as the message_count fields suggests? 1997 //sanity check: is the message as long as the message_count fields suggests?
1964 if ((ntohs (msg->header.size) != msg_size) || (count != used_element_count)) 1998 if ((ntohs (msg->header.size) != msg_size) || (count != contained_element_count))
1965 { 1999 {
1966 GNUNET_break_op (0); 2000 GNUNET_break_op (0);
1967 goto invalid_msg; 2001 goto invalid_msg;
@@ -2112,7 +2146,9 @@ run (void *cls,
2112 }; 2146 };
2113 static const struct GNUNET_MESH_MessageHandler mesh_handlers[] = { 2147 static const struct GNUNET_MESH_MessageHandler mesh_handlers[] = {
2114 { &handle_service_request, GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB, 0}, 2148 { &handle_service_request, GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB, 0},
2149 { &handle_service_request_multipart, GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ALICE_TO_BOB_MULTIPART, 0},
2115 { &handle_service_response, GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE, 0}, 2150 { &handle_service_response, GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE, 0},
2151 { &handle_service_response_multipart, GNUNET_MESSAGE_TYPE_SCALARPRODUCT_BOB_TO_ALICE_MULTIPART, 0},
2116 {NULL, 0, 0} 2152 {NULL, 0, 0}
2117 }; 2153 };
2118 static const uint32_t ports[] = { 2154 static const uint32_t ports[] = {
diff --git a/src/scalarproduct/scalarproduct.h b/src/scalarproduct/scalarproduct.h
index 02c6d8b21..af2e251e1 100644
--- a/src/scalarproduct/scalarproduct.h
+++ b/src/scalarproduct/scalarproduct.h
@@ -106,6 +106,16 @@ struct GNUNET_SCALARPRODUCT_service_request {
106 struct GNUNET_MessageHeader header; 106 struct GNUNET_MessageHeader header;
107 107
108 /** 108 /**
109 * how many elements the total message including all multipart msgs contains
110 */
111 uint32_t total_element_count GNUNET_PACKED;
112
113 /**
114 * how many elements are actually included after the mask was applied.
115 */
116 uint32_t contained_element_count GNUNET_PACKED;
117
118 /**
109 * how many bytes the mask has 119 * how many bytes the mask has
110 */ 120 */
111 uint32_t mask_length GNUNET_PACKED; 121 uint32_t mask_length GNUNET_PACKED;
@@ -126,13 +136,25 @@ struct GNUNET_SCALARPRODUCT_service_request {
126 uint32_t element_count GNUNET_PACKED; 136 uint32_t element_count GNUNET_PACKED;
127 137
128 /** 138 /**
129 * how many elements are actually included after the mask was applied. 139 * followed by mask | public_key | vector[used_element_count]
130 */ 140 */
131 uint32_t used_element_count GNUNET_PACKED; 141};
132 142
143/**
144 * Multipart Message type passed between to supply additional elements for the peer
145 */
146struct GNUNET_SCALARPRODUCT_multipart_message {
133 /** 147 /**
134 * followed by mask | public_key | vector[used_element_count] 148 * GNUNET message header
135 */ 149 */
150 struct GNUNET_MessageHeader header;
151
152 /**
153 * how many elements we supply within this message
154 */
155 uint32_t multipart_element_count GNUNET_PACKED;
156
157 // followed by vector[multipart_element_count] or k[i][perm]
136}; 158};
137 159
138/** 160/**
@@ -146,14 +168,19 @@ struct GNUNET_SCALARPRODUCT_service_response {
146 struct GNUNET_MessageHeader header; 168 struct GNUNET_MessageHeader header;
147 169
148 /** 170 /**
149 * how many elements the vector in payload contains 171 * how many elements the session input had
150 */ 172 */
151 uint32_t element_count GNUNET_PACKED; 173 uint32_t total_element_count GNUNET_PACKED;
152 174
153 /** 175 /**
154 * how many elements are actually included after the mask was applied. 176 * how many elements were included after the mask was applied including all multipart msgs.
155 */ 177 */
156 uint32_t used_element_count GNUNET_PACKED; 178 uint32_t used_element_count GNUNET_PACKED;
179
180 /**
181 * how many elements this individual message delivers
182 */
183 uint32_t contained_element_count GNUNET_PACKED;
157 184
158 /** 185 /**
159 * the transaction/session key used to identify a session 186 * the transaction/session key used to identify a session
@@ -161,7 +188,7 @@ struct GNUNET_SCALARPRODUCT_service_response {
161 struct GNUNET_HashCode key; 188 struct GNUNET_HashCode key;
162 189
163 /** 190 /**
164 * followed by s | s' | kp[] | kq[] 191 * followed by s | s' | k[i][perm]
165 */ 192 */
166}; 193};
167 194