diff options
author | Florian Dold <florian.dold@gmail.com> | 2014-01-07 11:29:24 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2014-01-07 11:29:24 +0000 |
commit | 4a353b58aec4670b2ac4477571ce9e28d5e8ea9a (patch) | |
tree | 5fd186c762b5fa8af00f9a8201ae117f81b205d4 /src/secretsharing | |
parent | 9b4bee4d09a77662448a9416f4deaf6994b2eb07 (diff) | |
download | gnunet-4a353b58aec4670b2ac4477571ce9e28d5e8ea9a.tar.gz gnunet-4a353b58aec4670b2ac4477571ce9e28d5e8ea9a.zip |
doxygen
Diffstat (limited to 'src/secretsharing')
-rw-r--r-- | src/secretsharing/gnunet-service-secretsharing.c | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/src/secretsharing/gnunet-service-secretsharing.c b/src/secretsharing/gnunet-service-secretsharing.c index fe02f55bc..38dabc3a8 100644 --- a/src/secretsharing/gnunet-service-secretsharing.c +++ b/src/secretsharing/gnunet-service-secretsharing.c | |||
@@ -54,7 +54,7 @@ struct KeygenPeerInfo | |||
54 | gcry_mpi_t presecret_commitment; | 54 | gcry_mpi_t presecret_commitment; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * The peer's preshare that we could decrypt | 57 | * The peer's preshare that we decrypted |
58 | * with out private key. | 58 | * with out private key. |
59 | */ | 59 | */ |
60 | gcry_mpi_t decrypted_preshare; | 60 | gcry_mpi_t decrypted_preshare; |
@@ -71,13 +71,16 @@ struct KeygenPeerInfo | |||
71 | int round1_valid; | 71 | int round1_valid; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Did we successfully receive the round1 element | 74 | * Did we successfully receive the round2 element |
75 | * of the peer? | 75 | * of the peer? |
76 | */ | 76 | */ |
77 | int round2_valid; | 77 | int round2_valid; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | 80 | ||
81 | /** | ||
82 | * Information about a peer in a decrypt session. | ||
83 | */ | ||
81 | struct DecryptPeerInfo | 84 | struct DecryptPeerInfo |
82 | { | 85 | { |
83 | /** | 86 | /** |
@@ -177,12 +180,12 @@ struct KeygenSession | |||
177 | struct GNUNET_HashCode session_id; | 180 | struct GNUNET_HashCode session_id; |
178 | 181 | ||
179 | /** | 182 | /** |
180 | * g-component of our peer's paillier private key. | 183 | * lambda-component of our peer's paillier private key. |
181 | */ | 184 | */ |
182 | gcry_mpi_t paillier_lambda; | 185 | gcry_mpi_t paillier_lambda; |
183 | 186 | ||
184 | /** | 187 | /** |
185 | * g-component of our peer's paillier private key. | 188 | * mu-component of our peer's paillier private key. |
186 | */ | 189 | */ |
187 | gcry_mpi_t paillier_mu; | 190 | gcry_mpi_t paillier_mu; |
188 | 191 | ||
@@ -205,6 +208,9 @@ struct KeygenSession | |||
205 | }; | 208 | }; |
206 | 209 | ||
207 | 210 | ||
211 | /** | ||
212 | * Session to cooperatively decrypt a value. | ||
213 | */ | ||
208 | struct DecryptSession | 214 | struct DecryptSession |
209 | { | 215 | { |
210 | /** | 216 | /** |
@@ -245,6 +251,8 @@ struct DecryptSession | |||
245 | 251 | ||
246 | /** | 252 | /** |
247 | * Share of the local peer. | 253 | * Share of the local peer. |
254 | * Containts other important information, such as | ||
255 | * the list of other peers. | ||
248 | */ | 256 | */ |
249 | struct GNUNET_SECRETSHARING_Share *share; | 257 | struct GNUNET_SECRETSHARING_Share *share; |
250 | 258 | ||
@@ -277,19 +285,19 @@ static struct KeygenSession *keygen_sessions_tail; | |||
277 | 285 | ||
278 | /** | 286 | /** |
279 | * The ElGamal prime field order as libgcrypt mpi. | 287 | * The ElGamal prime field order as libgcrypt mpi. |
280 | * Will be initialized to 'ELGAMAL_Q_DATA'. | 288 | * Initialized in #init_crypto_constants. |
281 | */ | 289 | */ |
282 | static gcry_mpi_t elgamal_q; | 290 | static gcry_mpi_t elgamal_q; |
283 | 291 | ||
284 | /** | 292 | /** |
285 | * Modulus of the prime field used for ElGamal. | 293 | * Modulus of the prime field used for ElGamal. |
286 | * Will be initialized to 'ELGAMAL_P_DATA'. | 294 | * Initialized in #init_crypto_constants. |
287 | */ | 295 | */ |
288 | static gcry_mpi_t elgamal_p; | 296 | static gcry_mpi_t elgamal_p; |
289 | 297 | ||
290 | /** | 298 | /** |
291 | * Generator for prime field of order 'elgamal_q'. | 299 | * Generator for prime field of order 'elgamal_q'. |
292 | * Will be initialized to 'ELGAMAL_G_DATA'. | 300 | * Initialized in #init_crypto_constants. |
293 | */ | 301 | */ |
294 | static gcry_mpi_t elgamal_g; | 302 | static gcry_mpi_t elgamal_g; |
295 | 303 | ||
@@ -341,8 +349,8 @@ adjust (unsigned char *buf, | |||
341 | * | 349 | * |
342 | * @param buf buffer to write to | 350 | * @param buf buffer to write to |
343 | * @param x mpi to be written in the buffer | 351 | * @param x mpi to be written in the buffer |
344 | * @param bytes how many bytes should the value use | 352 | * @param size how many bytes should the little endian binary |
345 | * @param | 353 | * representation of @a x use? |
346 | */ | 354 | */ |
347 | static void | 355 | static void |
348 | print_mpi_fixed (void *buf, gcry_mpi_t x, size_t size) | 356 | print_mpi_fixed (void *buf, gcry_mpi_t x, size_t size) |
@@ -355,6 +363,13 @@ print_mpi_fixed (void *buf, gcry_mpi_t x, size_t size) | |||
355 | } | 363 | } |
356 | 364 | ||
357 | 365 | ||
366 | /** | ||
367 | * Get the peer info belonging to a peer identity in a keygen session. | ||
368 | * | ||
369 | * @param ks the keygen session | ||
370 | * @param peer the peer identity | ||
371 | * @return the keygen peer info, or NULL if the peer could not be found | ||
372 | */ | ||
358 | static struct KeygenPeerInfo * | 373 | static struct KeygenPeerInfo * |
359 | get_keygen_peer_info (const struct KeygenSession *ks, | 374 | get_keygen_peer_info (const struct KeygenSession *ks, |
360 | const struct GNUNET_PeerIdentity *peer) | 375 | const struct GNUNET_PeerIdentity *peer) |
@@ -367,6 +382,13 @@ get_keygen_peer_info (const struct KeygenSession *ks, | |||
367 | } | 382 | } |
368 | 383 | ||
369 | 384 | ||
385 | /** | ||
386 | * Get the peer info belonging to a peer identity in a decrypt session. | ||
387 | * | ||
388 | * @param ks the decrypt session | ||
389 | * @param peer the peer identity | ||
390 | * @return the decrypt peer info, or NULL if the peer could not be found | ||
391 | */ | ||
370 | static struct DecryptPeerInfo * | 392 | static struct DecryptPeerInfo * |
371 | get_decrypt_peer_info (const struct DecryptSession *ds, | 393 | get_decrypt_peer_info (const struct DecryptSession *ds, |
372 | const struct GNUNET_PeerIdentity *peer) | 394 | const struct GNUNET_PeerIdentity *peer) |
@@ -379,6 +401,14 @@ get_decrypt_peer_info (const struct DecryptSession *ds, | |||
379 | } | 401 | } |
380 | 402 | ||
381 | 403 | ||
404 | /** | ||
405 | * Interpolate between two points in time. | ||
406 | * | ||
407 | * @param start start time | ||
408 | * @param end end time | ||
409 | * @param num numerator of the scale factor | ||
410 | * @param denum denumerator of the scale factor | ||
411 | */ | ||
382 | static struct GNUNET_TIME_Absolute | 412 | static struct GNUNET_TIME_Absolute |
383 | time_between (struct GNUNET_TIME_Absolute start, | 413 | time_between (struct GNUNET_TIME_Absolute start, |
384 | struct GNUNET_TIME_Absolute end, | 414 | struct GNUNET_TIME_Absolute end, |
@@ -409,7 +439,16 @@ peer_id_cmp (const void *p1, const void *p2) | |||
409 | } | 439 | } |
410 | 440 | ||
411 | 441 | ||
412 | int | 442 | /** |
443 | * Get the index of a peer in an array of peers | ||
444 | * | ||
445 | * @param haystack array of peers | ||
446 | * @param n size of @a haystack | ||
447 | * @param needle peer to find | ||
448 | * @return index of @a needle in @a haystack, or -1 if peer | ||
449 | * is not in the list. | ||
450 | */ | ||
451 | static int | ||
413 | peer_find (const struct GNUNET_PeerIdentity *haystack, unsigned int n, | 452 | peer_find (const struct GNUNET_PeerIdentity *haystack, unsigned int n, |
414 | const struct GNUNET_PeerIdentity *needle) | 453 | const struct GNUNET_PeerIdentity *needle) |
415 | { | 454 | { |
@@ -637,6 +676,11 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
637 | } | 676 | } |
638 | 677 | ||
639 | 678 | ||
679 | /** | ||
680 | * Generate the random coefficients of our pre-secret polynomial | ||
681 | * | ||
682 | * @param ks the session | ||
683 | */ | ||
640 | static void | 684 | static void |
641 | generate_presecret_polynomial (struct KeygenSession *ks) | 685 | generate_presecret_polynomial (struct KeygenSession *ks) |
642 | { | 686 | { |