diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-05-24 19:57:15 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-05-24 19:57:15 +0000 |
commit | 31536a9bb75502f4c090472f188e1eec138515f7 (patch) | |
tree | 2c75617baa1ca040ddfb6a59d90831624b3512b1 /src/scalarproduct/scalarproduct.h | |
parent | 152cd13768915399f9e5137d78a2f75296a1b93e (diff) | |
download | gnunet-31536a9bb75502f4c090472f188e1eec138515f7.tar.gz gnunet-31536a9bb75502f4c090472f188e1eec138515f7.zip |
cleaning up scalar product client API
Diffstat (limited to 'src/scalarproduct/scalarproduct.h')
-rw-r--r-- | src/scalarproduct/scalarproduct.h | 142 |
1 files changed, 18 insertions, 124 deletions
diff --git a/src/scalarproduct/scalarproduct.h b/src/scalarproduct/scalarproduct.h index 6837b3abc..4bafb18fb 100644 --- a/src/scalarproduct/scalarproduct.h +++ b/src/scalarproduct/scalarproduct.h | |||
@@ -33,14 +33,8 @@ | |||
33 | extern "C" | 33 | extern "C" |
34 | { | 34 | { |
35 | #endif | 35 | #endif |
36 | /////////////////////////////////////////////////////////////////////////////// | ||
37 | // Defines | ||
38 | /////////////////////////////////////////////////////////////////////////////// | ||
39 | 36 | ||
40 | /** | 37 | GNUNET_NETWORK_STRUCT_BEGIN |
41 | * Maximum count of elements we can put into a multipart message | ||
42 | */ | ||
43 | #define MULTIPART_ELEMENT_CAPACITY ((GNUNET_SERVER_MAX_MESSAGE_SIZE - 1 - sizeof (struct GNUNET_SCALARPRODUCT_multipart_message)) / sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)) | ||
44 | 38 | ||
45 | /** | 39 | /** |
46 | * Log an error message at log-level 'level' that indicates | 40 | * Log an error message at log-level 'level' that indicates |
@@ -49,15 +43,12 @@ extern "C" | |||
49 | */ | 43 | */ |
50 | #define LOG_GCRY(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0) | 44 | #define LOG_GCRY(level, cmd, rc) do { LOG(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0) |
51 | 45 | ||
52 | /////////////////////////////////////////////////////////////////////////////// | ||
53 | // Scalar Product Message Types | ||
54 | /////////////////////////////////////////////////////////////////////////////// | ||
55 | 46 | ||
56 | /** | 47 | /** |
57 | * Message type passed from client to service | 48 | * Message type passed from client to service |
58 | * to initiate a request or responder role | 49 | * to initiate a request or responder role |
59 | */ | 50 | */ |
60 | struct GNUNET_SCALARPRODUCT_computation_message | 51 | struct ComputationMessage |
61 | { | 52 | { |
62 | /** | 53 | /** |
63 | * GNUNET message header | 54 | * GNUNET message header |
@@ -68,13 +59,18 @@ struct GNUNET_SCALARPRODUCT_computation_message | |||
68 | * how many elements the vector in payload contains | 59 | * how many elements the vector in payload contains |
69 | */ | 60 | */ |
70 | uint32_t element_count_total GNUNET_PACKED; | 61 | uint32_t element_count_total GNUNET_PACKED; |
71 | 62 | ||
72 | /** | 63 | /** |
73 | * contained elements the vector in payload contains | 64 | * contained elements the vector in payload contains |
74 | */ | 65 | */ |
75 | uint32_t element_count_contained GNUNET_PACKED; | 66 | uint32_t element_count_contained GNUNET_PACKED; |
76 | 67 | ||
77 | /** | 68 | /** |
69 | * Always zero. | ||
70 | */ | ||
71 | uint32_t reserved GNUNET_PACKED; | ||
72 | |||
73 | /** | ||
78 | * the transaction/session key used to identify a session | 74 | * the transaction/session key used to identify a session |
79 | */ | 75 | */ |
80 | struct GNUNET_HashCode session_key; | 76 | struct GNUNET_HashCode session_key; |
@@ -89,16 +85,17 @@ struct GNUNET_SCALARPRODUCT_computation_message | |||
89 | */ | 85 | */ |
90 | }; | 86 | }; |
91 | 87 | ||
88 | |||
92 | /** | 89 | /** |
93 | * multipart messages following GNUNET_SCALARPRODUCT_client_request | 90 | * multipart messages following `struct ComputationMessage` |
94 | */ | 91 | */ |
95 | struct GNUNET_SCALARPRODUCT_computation_message_multipart | 92 | struct ComputationMultipartMessage |
96 | { | 93 | { |
97 | /** | 94 | /** |
98 | * GNUNET message header | 95 | * GNUNET message header |
99 | */ | 96 | */ |
100 | struct GNUNET_MessageHeader header; | 97 | struct GNUNET_MessageHeader header; |
101 | 98 | ||
102 | /** | 99 | /** |
103 | * contained elements the vector in payload contains | 100 | * contained elements the vector in payload contains |
104 | */ | 101 | */ |
@@ -111,105 +108,10 @@ struct GNUNET_SCALARPRODUCT_computation_message_multipart | |||
111 | 108 | ||
112 | 109 | ||
113 | /** | 110 | /** |
114 | * Message type passed from requesting service Alice to responding service Bob | ||
115 | * to initiate a request and make bob participate in our protocol | ||
116 | */ | ||
117 | struct GNUNET_SCALARPRODUCT_service_request { | ||
118 | /** | ||
119 | * GNUNET message header | ||
120 | */ | ||
121 | struct GNUNET_MessageHeader header; | ||
122 | |||
123 | /** | ||
124 | * the transaction/session key used to identify a session | ||
125 | */ | ||
126 | struct GNUNET_HashCode session_id; | ||
127 | |||
128 | /** | ||
129 | * Alice's public key | ||
130 | */ | ||
131 | struct GNUNET_CRYPTO_PaillierPublicKey public_key; | ||
132 | |||
133 | }; | ||
134 | |||
135 | |||
136 | /** | ||
137 | * Message type passed from requesting service Alice to responding service Bob | ||
138 | * to initiate a request and make bob participate in our protocol | ||
139 | */ | ||
140 | struct GNUNET_SCALARPRODUCT_alices_cryptodata_message { | ||
141 | /** | ||
142 | * GNUNET message header | ||
143 | */ | ||
144 | struct GNUNET_MessageHeader header; | ||
145 | |||
146 | /** | ||
147 | * how many elements we appended to this message | ||
148 | */ | ||
149 | uint32_t contained_element_count GNUNET_PACKED; | ||
150 | |||
151 | /** | ||
152 | * struct GNUNET_CRYPTO_PaillierCiphertext[contained_element_count] | ||
153 | */ | ||
154 | }; | ||
155 | |||
156 | /** | ||
157 | * Multipart Message type passed between to supply additional elements for the peer | ||
158 | */ | ||
159 | struct GNUNET_SCALARPRODUCT_multipart_message { | ||
160 | /** | ||
161 | * GNUNET message header | ||
162 | */ | ||
163 | struct GNUNET_MessageHeader header; | ||
164 | |||
165 | /** | ||
166 | * how many elements we supply within this message | ||
167 | */ | ||
168 | uint32_t contained_element_count GNUNET_PACKED; | ||
169 | |||
170 | // struct GNUNET_CRYPTO_PaillierCiphertext[multipart_element_count] | ||
171 | }; | ||
172 | |||
173 | /** | ||
174 | * Message type passed from responding service Bob to responding service Alice | ||
175 | * to complete a request and allow Alice to compute the result | ||
176 | */ | ||
177 | struct GNUNET_SCALARPRODUCT_service_response { | ||
178 | /** | ||
179 | * GNUNET message header | ||
180 | */ | ||
181 | struct GNUNET_MessageHeader header; | ||
182 | |||
183 | /** | ||
184 | * how many elements the session input had | ||
185 | */ | ||
186 | uint32_t total_element_count GNUNET_PACKED; | ||
187 | |||
188 | /** | ||
189 | * how many elements were included after the mask was applied including all multipart msgs. | ||
190 | */ | ||
191 | uint32_t used_element_count GNUNET_PACKED; | ||
192 | |||
193 | /** | ||
194 | * how many elements this individual message delivers | ||
195 | */ | ||
196 | uint32_t contained_element_count GNUNET_PACKED; | ||
197 | |||
198 | /** | ||
199 | * the transaction/session key used to identify a session | ||
200 | */ | ||
201 | struct GNUNET_HashCode key; | ||
202 | |||
203 | /** | ||
204 | * followed by s | s' | k[i][perm] | ||
205 | */ | ||
206 | }; | ||
207 | |||
208 | /** | ||
209 | * Message type passed from service client | 111 | * Message type passed from service client |
210 | * to finalize a session as requester or responder | 112 | * to finalize a session as requester or responder |
211 | */ | 113 | */ |
212 | struct GNUNET_SCALARPRODUCT_client_response | 114 | struct ClientResponseMessage |
213 | { | 115 | { |
214 | /** | 116 | /** |
215 | * GNUNET message header | 117 | * GNUNET message header |
@@ -222,30 +124,22 @@ struct GNUNET_SCALARPRODUCT_client_response | |||
222 | uint32_t product_length GNUNET_PACKED; | 124 | uint32_t product_length GNUNET_PACKED; |
223 | 125 | ||
224 | /** | 126 | /** |
225 | * the transaction/session key used to identify a session | ||
226 | */ | ||
227 | struct GNUNET_HashCode key; | ||
228 | |||
229 | /** | ||
230 | * the identity of a remote peer we want to communicate with | ||
231 | */ | ||
232 | struct GNUNET_PeerIdentity peer; | ||
233 | |||
234 | /** | ||
235 | * status information about the outcome of this session | 127 | * status information about the outcome of this session |
236 | */ | 128 | */ |
237 | int32_t status; | 129 | int32_t status GNUNET_PACKED; |
238 | 130 | ||
239 | /** | 131 | /** |
240 | * Workaround for libgcrypt: -1 if negative, 0 if zero, else 1 | 132 | * Workaround for libgcrypt: -1 if negative, 0 if zero, else 1 |
241 | */ | 133 | */ |
242 | int8_t range; | 134 | int32_t range GNUNET_PACKED; |
243 | 135 | ||
244 | /** | 136 | /** |
245 | * followed by product of length product_length (or nothing) | 137 | * followed by product of length product_length (or nothing) |
246 | */ | 138 | */ |
247 | }; | 139 | }; |
248 | 140 | ||
141 | GNUNET_NETWORK_STRUCT_END | ||
142 | |||
249 | #ifdef __cplusplus | 143 | #ifdef __cplusplus |
250 | } | 144 | } |
251 | #endif | 145 | #endif |