diff options
Diffstat (limited to 'src/scalarproduct/gnunet-service-scalarproduct_alice.c')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct_alice.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c index b5ab8a88f..e75915f9a 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c +++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c | |||
@@ -148,18 +148,21 @@ struct AliceServiceSession | |||
148 | gcry_mpi_t product; | 148 | gcry_mpi_t product; |
149 | 149 | ||
150 | /** | 150 | /** |
151 | * how many elements we were supplied with from the client | 151 | * How many elements we were supplied with from the client (total |
152 | * count before intersection). | ||
152 | */ | 153 | */ |
153 | uint32_t total; | 154 | uint32_t total; |
154 | 155 | ||
155 | /** | 156 | /** |
156 | * how many elements actually are used for the scalar product. | 157 | * How many elements actually are used for the scalar product. |
157 | * Size of the arrays in @e r and @e r_prime. | 158 | * Size of the arrays in @e r and @e r_prime. Sometimes also |
159 | * reset to 0 and used as a counter! | ||
158 | */ | 160 | */ |
159 | uint32_t used_element_count; | 161 | uint32_t used_element_count; |
160 | 162 | ||
161 | /** | 163 | /** |
162 | * already transferred elements (sent/received) for multipart messages, less or equal than @e used_element_count for | 164 | * Already transferred elements from client to us. |
165 | * Less or equal than @e total. | ||
163 | */ | 166 | */ |
164 | uint32_t transferred_element_count; | 167 | uint32_t transferred_element_count; |
165 | 168 | ||
@@ -665,6 +668,11 @@ handle_bobs_cryptodata_multipart (void *cls, | |||
665 | GNUNET_break (0); | 668 | GNUNET_break (0); |
666 | return GNUNET_SYSERR; | 669 | return GNUNET_SYSERR; |
667 | } | 670 | } |
671 | |||
672 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
673 | "Received %u additional crypto values from Bob\n", | ||
674 | (unsigned int) contained); | ||
675 | |||
668 | payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; | 676 | payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; |
669 | /* Convert each k[][perm] to its MPI_value */ | 677 | /* Convert each k[][perm] to its MPI_value */ |
670 | for (i = 0; i < contained; i++) | 678 | for (i = 0; i < contained; i++) |
@@ -741,6 +749,11 @@ handle_bobs_cryptodata_message (void *cls, | |||
741 | GNUNET_break_op (0); | 749 | GNUNET_break_op (0); |
742 | return GNUNET_SYSERR; | 750 | return GNUNET_SYSERR; |
743 | } | 751 | } |
752 | |||
753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
754 | "Received %u crypto values from Bob\n", | ||
755 | (unsigned int) contained); | ||
756 | |||
744 | payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; | 757 | payload = (const struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; |
745 | memcpy (&s->s, | 758 | memcpy (&s->s, |
746 | &payload[0], | 759 | &payload[0], |
@@ -847,6 +860,7 @@ send_alices_cryptodata_message (struct AliceServiceSession *s) | |||
847 | unsigned int i; | 860 | unsigned int i; |
848 | uint32_t todo_count; | 861 | uint32_t todo_count; |
849 | gcry_mpi_t a; | 862 | gcry_mpi_t a; |
863 | uint32_t off; | ||
850 | 864 | ||
851 | s->sorted_elements | 865 | s->sorted_elements |
852 | = GNUNET_malloc (GNUNET_CONTAINER_multihashmap_size (s->intersected_elements) * | 866 | = GNUNET_malloc (GNUNET_CONTAINER_multihashmap_size (s->intersected_elements) * |
@@ -862,12 +876,15 @@ send_alices_cryptodata_message (struct AliceServiceSession *s) | |||
862 | s->used_element_count, | 876 | s->used_element_count, |
863 | sizeof (struct MpiElement), | 877 | sizeof (struct MpiElement), |
864 | &element_cmp); | 878 | &element_cmp); |
865 | 879 | off = 0; | |
866 | while (s->transferred_element_count < s->used_element_count) | 880 | while (off < s->used_element_count) |
867 | { | 881 | { |
868 | todo_count = s->used_element_count - s->transferred_element_count; | 882 | todo_count = s->used_element_count - off; |
869 | if (todo_count > ELEMENT_CAPACITY) | 883 | if (todo_count > ELEMENT_CAPACITY) |
870 | todo_count = ELEMENT_CAPACITY; | 884 | todo_count = ELEMENT_CAPACITY; |
885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
886 | "Sending %u crypto values to Bob\n", | ||
887 | (unsigned int) todo_count); | ||
871 | 888 | ||
872 | e = GNUNET_MQ_msg_extra (msg, | 889 | e = GNUNET_MQ_msg_extra (msg, |
873 | todo_count * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext), | 890 | todo_count * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext), |
@@ -875,7 +892,7 @@ send_alices_cryptodata_message (struct AliceServiceSession *s) | |||
875 | msg->contained_element_count = htonl (todo_count); | 892 | msg->contained_element_count = htonl (todo_count); |
876 | payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; | 893 | payload = (struct GNUNET_CRYPTO_PaillierCiphertext *) &msg[1]; |
877 | a = gcry_mpi_new (0); | 894 | a = gcry_mpi_new (0); |
878 | for (i = s->transferred_element_count; i < todo_count; i++) | 895 | for (i = off; i < todo_count; i++) |
879 | { | 896 | { |
880 | gcry_mpi_add (a, | 897 | gcry_mpi_add (a, |
881 | s->sorted_elements[i].value, | 898 | s->sorted_elements[i].value, |
@@ -883,10 +900,10 @@ send_alices_cryptodata_message (struct AliceServiceSession *s) | |||
883 | GNUNET_CRYPTO_paillier_encrypt (&my_pubkey, | 900 | GNUNET_CRYPTO_paillier_encrypt (&my_pubkey, |
884 | a, | 901 | a, |
885 | 3, | 902 | 3, |
886 | &payload[i - s->transferred_element_count]); | 903 | &payload[i - off]); |
887 | } | 904 | } |
888 | gcry_mpi_release (a); | 905 | gcry_mpi_release (a); |
889 | s->transferred_element_count += todo_count; | 906 | off += todo_count; |
890 | GNUNET_MQ_send (s->cadet_mq, | 907 | GNUNET_MQ_send (s->cadet_mq, |
891 | e); | 908 | e); |
892 | } | 909 | } |