GNUnet  0.10.x
Functions | Variables
gnunet-secretsharing-profiler.c File Reference

profiling tool for distributed key generation and decryption More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_secretsharing_service.h"
#include "gnunet_testbed_service.h"
Include dependency graph for gnunet-secretsharing-profiler.c:

Go to the source code of this file.

Functions

static void controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
 Signature of the event handler function called by the respective event controller. More...
 
static void session_connect_complete (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
 Callback to be called when a service connect operation is completed. More...
 
static void decrypt_connect_complete (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
 Callback to be called when a service connect operation is completed. More...
 
static void decrypt_cb (void *cls, const struct GNUNET_SECRETSHARING_Plaintext *plaintext)
 Called when a decryption has succeeded. More...
 
static void * decrypt_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Adapter function called to establish a connection to a service. More...
 
static void decrypt_disconnect_adapter (void *cls, void *op_result)
 Adapter function called to destroy a connection to a service. More...
 
static void secret_ready_cb (void *cls, struct GNUNET_SECRETSHARING_Share *my_share, struct GNUNET_SECRETSHARING_PublicKey *public_key, unsigned int num_ready_peers, const struct GNUNET_PeerIdentity *ready_peers)
 
static void * session_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Adapter function called to establish a connection to a service. More...
 
static void session_disconnect_adapter (void *cls, void *op_result)
 Adapter function called to destroy a connection to a service. More...
 
static void peer_info_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
 Callback to be called when the requested peer information is available. More...
 
static void handle_shutdown (void *cls)
 Signature of the main function of a task. More...
 
static void test_master (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **started_peers, unsigned int links_succeeded, unsigned int links_failed)
 Signature of a main function for a testcase. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
int main (int argc, char **argv)
 

Variables

static unsigned int num_peers = 3
 How many peers should participate in the key generation? More...
 
static unsigned int threshold = 2
 What should the threshold for then key be? More...
 
static int decrypt = GNUNET_NO
 Should we try to decrypt a value after the key generation? More...
 
static struct GNUNET_TIME_Relative timeout
 When would we like to see the operation finished? More...
 
static struct GNUNET_TIME_Relative delay
 When should dkg communication start? More...
 
static struct GNUNET_SECRETSHARING_Session ** session_handles
 Handles for secretsharing sessions. More...
 
static struct GNUNET_SECRETSHARING_DecryptionHandle ** decrypt_handles
 
static struct GNUNET_SECRETSHARING_Share ** shares
 Shares we got from the distributed key generation. More...
 
static struct GNUNET_SECRETSHARING_PublicKey common_pubkey
 
static unsigned int num_connected_sessions
 
static unsigned int num_connected_decrypt
 
static struct GNUNET_TESTBED_Peer ** peers
 Handles to the running peers. More...
 
static struct GNUNET_PeerIdentitypeer_ids
 
static unsigned int num_retrieved_peer_ids
 
static unsigned int num_generated
 
static unsigned int num_decrypted
 
static struct GNUNET_HashCode session_id
 
static unsigned int verbose
 
static struct GNUNET_SECRETSHARING_Plaintext reference_plaintext
 
static struct GNUNET_SECRETSHARING_Ciphertext ciphertext
 
static struct GNUNET_TIME_Absolute dkg_start
 
static struct GNUNET_TIME_Absolute dkg_deadline
 
static struct GNUNET_TIME_Absolute decrypt_start
 
static struct GNUNET_TIME_Absolute decrypt_deadline
 
static struct GNUNET_TESTBED_Operation ** connect_ops
 Connect operations, one for every peer. More...
 
static int in_shutdown
 Are we performing a shutdown right now? More...
 

Detailed Description

profiling tool for distributed key generation and decryption

Author
Florian Dold

Definition in file gnunet-secretsharing-profiler.c.

Function Documentation

◆ controller_cb()

static void controller_cb ( void *  cls,
const struct GNUNET_TESTBED_EventInformation event 
)
static

Signature of the event handler function called by the respective event controller.

Parameters
clsclosure
eventinformation about the event

Definition at line 125 of file gnunet-secretsharing-profiler.c.

References GNUNET_assert.

Referenced by run().

127 {
128  GNUNET_assert (0);
129 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Here is the caller graph for this function:

◆ session_connect_complete()

static void session_connect_complete ( void *  cls,
struct GNUNET_TESTBED_Operation op,
void *  ca_result,
const char *  emsg 
)
static

Callback to be called when a service connect operation is completed.

Parameters
clsthe callback closure from functions generating an operation
opthe operation that has been finished
ca_resultthe service handle returned from GNUNET_TESTBED_ConnectAdapter()
emsgerror message in case the operation has failed; will be NULL if operation has executed successfully.

Definition at line 142 of file gnunet-secretsharing-profiler.c.

References GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, num_connected_sessions, and num_peers.

Referenced by peer_info_cb().

146 {
147 
148  if (NULL != emsg)
149  {
151  "testbed connect emsg: %s\n",
152  emsg);
153  GNUNET_assert (0);
154  }
155 
157 
159  "dkg: session connect complete\n");
160 
162  {
164  "dkg: all peers connected\n");
165  }
166 }
static unsigned int num_peers
How many peers should participate in the key generation?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static unsigned int num_connected_sessions
#define GNUNET_log(kind,...)
Here is the caller graph for this function:

◆ decrypt_connect_complete()

static void decrypt_connect_complete ( void *  cls,
struct GNUNET_TESTBED_Operation op,
void *  ca_result,
const char *  emsg 
)
static

Callback to be called when a service connect operation is completed.

Parameters
clsthe callback closure from functions generating an operation
opthe operation that has been finished
ca_resultthe service handle returned from GNUNET_TESTBED_ConnectAdapter()
emsgerror message in case the operation has failed; will be NULL if operation has executed successfully.

Definition at line 179 of file gnunet-secretsharing-profiler.c.

References GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, num_connected_decrypt, and num_peers.

Referenced by session_disconnect_adapter().

183 {
184 
185  if (NULL != emsg)
186  {
188  "testbed connect emsg: %s\n",
189  emsg);
190  GNUNET_assert (0);
191  }
192 
194 
196  "decrypt: session connect complete\n");
197 
199  {
201  "decrypt: all peers connected\n");
202  }
203 }
static unsigned int num_peers
How many peers should participate in the key generation?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static unsigned int num_connected_decrypt
#define GNUNET_log(kind,...)
Here is the caller graph for this function:

◆ decrypt_cb()

static void decrypt_cb ( void *  cls,
const struct GNUNET_SECRETSHARING_Plaintext plaintext 
)
static

Called when a decryption has succeeded.

Parameters
clsPlaintext
plaintextPlaintext

Definition at line 212 of file gnunet-secretsharing-profiler.c.

References decrypt_handles, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_memcmp, GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_operation_done(), num_decrypted, num_peers, and reference_plaintext.

Referenced by decrypt_connect_adapter(), and GNUNET_SECRETSHARING_decrypt().

214 {
215  struct GNUNET_SECRETSHARING_DecryptionHandle **dhp = cls;
216  unsigned int n = dhp - decrypt_handles;
217  num_decrypted++;
218 
219  *dhp = NULL;
220 
221  // we should still be connected if this is called
222  GNUNET_assert (NULL != connect_ops[n]);
223 
225 
226  if (NULL == plaintext)
227  {
228  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt failed for peer %u\n", n);
229  return;
230  }
231  else if (0 == GNUNET_memcmp (&reference_plaintext, plaintext))
232  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "decrypt got correct result for peer %u\n", n);
233  else
234  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt got wrong result for peer %u\n", n);
235 
236  if (num_decrypted == num_peers)
237  {
238  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "every peer decrypted\n");
240  }
241 
242  *dhp = NULL;
243 }
static struct GNUNET_SECRETSHARING_Plaintext reference_plaintext
static unsigned int num_peers
How many peers should participate in the key generation?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static unsigned int num_decrypted
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2046
Handle to cancel a cooperative decryption operation.
static struct GNUNET_TESTBED_Operation ** connect_ops
Connect operations, one for every peer.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_log(kind,...)
static struct GNUNET_SECRETSHARING_DecryptionHandle ** decrypt_handles
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrypt_connect_adapter()

static void* decrypt_connect_adapter ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Adapter function called to establish a connection to a service.

Parameters
clsclosure
cfgconfiguration of the peer to connect to; will be available until GNUNET_TESTBED_operation_done() is called on the operation returned from GNUNET_TESTBED_service_connect()
Returns
service handle to return in 'op_result', NULL on error

Definition at line 258 of file gnunet-secretsharing-profiler.c.

References ciphertext, decrypt_cb(), decrypt_deadline, decrypt_handles, decrypt_start, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SECRETSHARING_decrypt(), and num_peers.

Referenced by session_disconnect_adapter().

260 {
261  struct GNUNET_SECRETSHARING_DecryptionHandle **hp = cls;
262  unsigned int n = hp - decrypt_handles;
263 
265  "decrypt connect adapter, %d peers\n",
266  num_peers);
269  decrypt_cb,
270  hp);
271 
272  return *hp;
273 }
static unsigned int num_peers
How many peers should participate in the key generation?
struct GNUNET_SECRETSHARING_DecryptionHandle * GNUNET_SECRETSHARING_decrypt(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SECRETSHARING_Share *share, const struct GNUNET_SECRETSHARING_Ciphertext *ciphertext, struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute deadline, GNUNET_SECRETSHARING_DecryptCallback decrypt_cb, void *decrypt_cb_cls)
Publish the given ciphertext for decryption.
static struct GNUNET_TIME_Absolute decrypt_deadline
static struct GNUNET_SECRETSHARING_Share ** shares
Shares we got from the distributed key generation.
static struct GNUNET_SECRETSHARING_Ciphertext ciphertext
Handle to cancel a cooperative decryption operation.
#define GNUNET_log(kind,...)
static void decrypt_cb(void *cls, const struct GNUNET_SECRETSHARING_Plaintext *plaintext)
Called when a decryption has succeeded.
static struct GNUNET_SECRETSHARING_DecryptionHandle ** decrypt_handles
static struct GNUNET_TIME_Absolute decrypt_start
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrypt_disconnect_adapter()

static void decrypt_disconnect_adapter ( void *  cls,
void *  op_result 
)
static

Adapter function called to destroy a connection to a service.

Parameters
clsclosure
op_resultservice handle returned from the connect adapter

Definition at line 284 of file gnunet-secretsharing-profiler.c.

References decrypt_handles, GNUNET_assert, and GNUNET_SECRETSHARING_decrypt_cancel().

Referenced by session_disconnect_adapter().

285 {
286  struct GNUNET_SECRETSHARING_DecryptionHandle **dh = cls;
287  unsigned int n = dh - decrypt_handles;
288 
289  GNUNET_assert (*dh == decrypt_handles[n]);
290 
291  if (NULL != *dh)
292  {
294  *dh = NULL;
295  }
296 
297  GNUNET_assert (NULL != connect_ops[n]);
298  connect_ops[n] = NULL;
299 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_SECRETSHARING_decrypt_cancel(struct GNUNET_SECRETSHARING_DecryptionHandle *dh)
Cancel a decryption.
Handle to cancel a cooperative decryption operation.
static struct GNUNET_TESTBED_Operation ** connect_ops
Connect operations, one for every peer.
static struct GNUNET_SECRETSHARING_DecryptionHandle ** decrypt_handles
Here is the call graph for this function:
Here is the caller graph for this function:

◆ secret_ready_cb()

static void secret_ready_cb ( void *  cls,
struct GNUNET_SECRETSHARING_Share my_share,
struct GNUNET_SECRETSHARING_PublicKey public_key,
unsigned int  num_ready_peers,
const struct GNUNET_PeerIdentity ready_peers 
)
static

Definition at line 303 of file gnunet-secretsharing-profiler.c.

References common_pubkey, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_memcmp, GNUNET_SCHEDULER_shutdown(), GNUNET_STRINGS_data_to_string(), GNUNET_TESTBED_operation_done(), num_generated, ret, and session_handles.

Referenced by session_connect_adapter().

308 {
309  struct GNUNET_SECRETSHARING_Session **sp = cls;
310  unsigned int n = sp - session_handles;
311  char pubkey_str[1024];
312  char *ret;
313 
314  num_generated++;
315  *sp = NULL;
316  shares[n] = my_share;
317  if (NULL == my_share)
318  {
319  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "key generation failed for peer #%u\n", n);
320  }
321  else
322  {
323  ret = GNUNET_STRINGS_data_to_string (public_key, sizeof *public_key, pubkey_str, 1024);
324  GNUNET_assert (NULL != ret);
325  *ret = '\0';
326  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "key generation successful for peer #%u, pubkey %s\n", n,
327  pubkey_str);
328 
329  /* we're the first to get the key -> store it */
330  if (num_generated == 1)
331  {
332  common_pubkey = *public_key;
333  }
334  else if (0 != GNUNET_memcmp (public_key, &common_pubkey))
335  {
336  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "generated public keys do not match\n");
338  return;
339  }
340  }
341 
342  // we should still be connected
343  GNUNET_assert (NULL != connect_ops[n]);
344 
345  // disconnect from the service, will call the disconnect callback
347 
348 }
static struct GNUNET_SECRETSHARING_Session ** session_handles
Handles for secretsharing sessions.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static int ret
Final status code.
Definition: gnunet-arm.c:89
static unsigned int num_generated
static struct GNUNET_SECRETSHARING_Share ** shares
Shares we got from the distributed key generation.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2046
Session that will eventually establish a shared secred between the involved peers and allow encryptio...
static struct GNUNET_TESTBED_Operation ** connect_ops
Connect operations, one for every peer.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_log(kind,...)
static struct GNUNET_SECRETSHARING_PublicKey common_pubkey
char * GNUNET_STRINGS_data_to_string(const void *data, size_t size, char *out, size_t out_size)
Convert binary data to ASCII encoding using CrockfordBase32.
Definition: strings.c:924
Here is the call graph for this function:
Here is the caller graph for this function:

◆ session_connect_adapter()

static void* session_connect_adapter ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Adapter function called to establish a connection to a service.

Parameters
clsclosure
cfgconfiguration of the peer to connect to; will be available until GNUNET_TESTBED_operation_done() is called on the operation returned from GNUNET_TESTBED_service_connect()
Returns
service handle to return in 'op_result', NULL on error

Definition at line 362 of file gnunet-secretsharing-profiler.c.

References dkg_deadline, dkg_start, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SECRETSHARING_create_session(), num_peers, secret_ready_cb(), session_id, and threshold.

Referenced by peer_info_cb().

364 {
365  struct GNUNET_SECRETSHARING_Session **sp = cls;
366 
368  "connect adapter, %d peers\n",
369  num_peers);
371  num_peers,
372  peer_ids,
373  &session_id,
374  dkg_start,
375  dkg_deadline,
376  threshold,
377  &secret_ready_cb, sp);
378  return *sp;
379 }
static unsigned int threshold
What should the threshold for then key be?
static unsigned int num_peers
How many peers should participate in the key generation?
static struct GNUNET_TIME_Absolute dkg_start
static struct GNUNET_PeerIdentity * peer_ids
struct GNUNET_SECRETSHARING_Session * GNUNET_SECRETSHARING_create_session(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int num_peers, const struct GNUNET_PeerIdentity *peers, const struct GNUNET_HashCode *session_id, struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute deadline, unsigned int threshold, GNUNET_SECRETSHARING_SecretReadyCallback cb, void *cls)
Create a session that will eventually establish a shared secret with the other peers.
Session that will eventually establish a shared secred between the involved peers and allow encryptio...
static void secret_ready_cb(void *cls, struct GNUNET_SECRETSHARING_Share *my_share, struct GNUNET_SECRETSHARING_PublicKey *public_key, unsigned int num_ready_peers, const struct GNUNET_PeerIdentity *ready_peers)
#define GNUNET_log(kind,...)
static struct GNUNET_HashCode session_id
static struct GNUNET_TIME_Absolute dkg_deadline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ session_disconnect_adapter()

static void session_disconnect_adapter ( void *  cls,
void *  op_result 
)
static

Adapter function called to destroy a connection to a service.

Parameters
clsclosure
op_resultservice handle returned from the connect adapter

Definition at line 391 of file gnunet-secretsharing-profiler.c.

References ciphertext, common_pubkey, decrypt, decrypt_connect_adapter(), decrypt_connect_complete(), decrypt_deadline, decrypt_disconnect_adapter(), decrypt_start, delay, GNUNET_assert, GNUNET_NO, GNUNET_SCHEDULER_shutdown(), GNUNET_SECRETSHARING_encrypt(), GNUNET_SECRETSHARING_plaintext_generate_i(), GNUNET_SECRETSHARING_session_destroy(), GNUNET_TESTBED_service_connect(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_YES, in_shutdown, num_generated, num_peers, reference_plaintext, session_handles, and timeout.

Referenced by peer_info_cb().

392 {
393  struct GNUNET_SECRETSHARING_Session **sp = cls;
394  unsigned int n = (sp - session_handles);
395 
396  GNUNET_assert (*sp == session_handles[n]);
397 
398  if (NULL != *sp)
399  {
401  *sp = NULL;
402  }
403 
404  GNUNET_assert (NULL != connect_ops[n]);
405  connect_ops[n] = NULL;
406 
407  if (GNUNET_YES == in_shutdown)
408  return;
409 
410  // all peers received their secret
411  if (num_generated == num_peers)
412  {
413  int i;
414 
415  // only do decryption if requested by the user
416  if (GNUNET_NO == decrypt)
417  {
419  return;
420  }
421 
424 
425  // compute g^42 as the plaintext which we will decrypt and then
426  // cooperatively decrypt
429 
430  for (i = 0; i < num_peers; i++)
431  connect_ops[i] =
432  GNUNET_TESTBED_service_connect (NULL, peers[i], "secretsharing", &decrypt_connect_complete, NULL,
434  }
435 }
static struct GNUNET_SECRETSHARING_Plaintext reference_plaintext
static int decrypt
Should we try to decrypt a value after the key generation?
static unsigned int num_peers
How many peers should participate in the key generation?
static struct GNUNET_SECRETSHARING_Session ** session_handles
Handles for secretsharing sessions.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:393
static void decrypt_connect_complete(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Callback to be called when a service connect operation is completed.
static void decrypt_disconnect_adapter(void *cls, void *op_result)
Adapter function called to destroy a connection to a service.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
void GNUNET_SECRETSHARING_session_destroy(struct GNUNET_SECRETSHARING_Session *s)
Destroy a secret sharing session.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
Connect to a service offered by the given peer.
int GNUNET_SECRETSHARING_plaintext_generate_i(struct GNUNET_SECRETSHARING_Plaintext *plaintext, int64_t exponent)
static struct GNUNET_TESTBED_Peer ** peers
Handles to the running peers.
static struct GNUNET_TIME_Absolute decrypt_deadline
static struct GNUNET_TIME_Relative timeout
When would we like to see the operation finished?
static unsigned int num_generated
static struct GNUNET_SECRETSHARING_Ciphertext ciphertext
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Session that will eventually establish a shared secred between the involved peers and allow encryptio...
int GNUNET_SECRETSHARING_encrypt(const struct GNUNET_SECRETSHARING_PublicKey *public_key, const struct GNUNET_SECRETSHARING_Plaintext *plaintext, struct GNUNET_SECRETSHARING_Ciphertext *result_ciphertext)
Encrypt a value.
static struct GNUNET_TESTBED_Operation ** connect_ops
Connect operations, one for every peer.
static int in_shutdown
Are we performing a shutdown right now?
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
static struct GNUNET_SECRETSHARING_PublicKey common_pubkey
#define GNUNET_YES
Definition: gnunet_common.h:80
static void * decrypt_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Adapter function called to establish a connection to a service.
static struct GNUNET_SECRETSHARING_DecryptionHandle ** decrypt_handles
static struct GNUNET_TIME_Absolute decrypt_start
Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_info_cb()

static void peer_info_cb ( void *  cb_cls,
struct GNUNET_TESTBED_Operation op,
const struct GNUNET_TESTBED_PeerInformation pinfo,
const char *  emsg 
)
static

Callback to be called when the requested peer information is available.

Parameters
cb_clsthe closure from GNUNET_TETSBED_peer_get_information()
opthe operation this callback corresponds to
pinfothe result; will be NULL if the operation has failed
emsgerror message if the operation has failed; will be NULL if the operation is successfull

Definition at line 448 of file gnunet-secretsharing-profiler.c.

References GNUNET_assert, GNUNET_TESTBED_operation_done(), GNUNET_TESTBED_PIT_IDENTITY, GNUNET_TESTBED_service_connect(), GNUNET_TESTBED_PeerInformation::id, num_peers, num_retrieved_peer_ids, p, GNUNET_TESTBED_PeerInformation::pit, GNUNET_TESTBED_PeerInformation::result, session_connect_adapter(), session_connect_complete(), and session_disconnect_adapter().

Referenced by test_master().

452 {
453  struct GNUNET_PeerIdentity *p;
454  int i;
455 
456  GNUNET_assert (NULL == emsg);
457 
458  p = (struct GNUNET_PeerIdentity *) cb_cls;
459 
460  if (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY)
461  {
462  *p = *pinfo->result.id;
465  for (i = 0; i < num_peers; i++)
466  connect_ops[i] =
467  GNUNET_TESTBED_service_connect (NULL, peers[i], "secretsharing", session_connect_complete, NULL,
469  }
470  else
471  {
472  GNUNET_assert (0);
473  }
474 
476 }
static unsigned int num_peers
How many peers should participate in the key generation?
static void * session_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Adapter function called to establish a connection to a service.
union GNUNET_TESTBED_PeerInformation::@64 result
The result of the get information operation; Choose according to the pit.
static struct GNUNET_SECRETSHARING_Session ** session_handles
Handles for secretsharing sessions.
enum GNUNET_TESTBED_PeerInformationType pit
Peer information type; captures which of the types in the &#39;op_result&#39; is actually in use...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void session_disconnect_adapter(void *cls, void *op_result)
Adapter function called to destroy a connection to a service.
struct GNUNET_PeerIdentity * id
The identity of the peer.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
Connect to a service offered by the given peer.
static struct GNUNET_TESTBED_Peer ** peers
Handles to the running peers.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static unsigned int num_retrieved_peer_ids
static void session_connect_complete(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Callback to be called when a service connect operation is completed.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2046
static struct GNUNET_TESTBED_Operation ** connect_ops
Connect operations, one for every peer.
The identity of the host (wraps the signing key of the peer).
What is the identity of the peer? Returns a &#39;const struct GNUNET_PeerIdentity *&#39;. ...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_shutdown()

static void handle_shutdown ( void *  cls)
static

Signature of the main function of a task.

Parameters
clsclosure

Definition at line 485 of file gnunet-secretsharing-profiler.c.

References GNUNET_free, GNUNET_TESTBED_operation_done(), GNUNET_YES, in_shutdown, and num_peers.

Referenced by test_master().

486 {
488 
489  if (NULL != connect_ops)
490  {
491  unsigned int i;
492  for (i = 0; i < num_peers; i++)
493  if (NULL != connect_ops[i])
494  {
495  // the disconnect callback will set the op to NULL
497  }
499  }
500 
501  // killing the testbed operation will take care of remaining
502  // service handles in the disconnect callback
503 }
static unsigned int num_peers
How many peers should participate in the key generation?
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2046
static struct GNUNET_TESTBED_Operation ** connect_ops
Connect operations, one for every peer.
static int in_shutdown
Are we performing a shutdown right now?
#define GNUNET_YES
Definition: gnunet_common.h:80
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_master()

static void test_master ( void *  cls,
struct GNUNET_TESTBED_RunHandle h,
unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  started_peers,
unsigned int  links_succeeded,
unsigned int  links_failed 
)
static

Signature of a main function for a testcase.

Parameters
clsclosure
hthe run handle
num_peersnumber of peers in 'peers'
started_peershandle to peers run in the testbed. NULL upon timeout (see GNUNET_TESTBED_test_run()).
links_succeededthe number of overlay link connection attempts that succeeded
links_failedthe number of overlay link connection attempts that failed

Definition at line 520 of file gnunet-secretsharing-profiler.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_log_setup(), GNUNET_malloc, GNUNET_new_array, GNUNET_SCHEDULER_add_shutdown(), GNUNET_TESTBED_peer_get_information(), GNUNET_TESTBED_PIT_IDENTITY, handle_shutdown(), num_peers, and peer_info_cb().

Referenced by run().

526 {
527  int i;
528 
529  GNUNET_log_setup ("gnunet-secretsharing-profiler", "INFO", NULL);
530 
531  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "test master\n");
532 
534 
535  peers = started_peers;
536 
537  peer_ids = GNUNET_malloc (num_peers * sizeof (struct GNUNET_PeerIdentity));
538 
543 
544  for (i = 0; i < num_peers; i++)
545  {
546  // we do not store the returned operation, as peer_info_cb
547  // will receive it as a parameter and call GNUNET_TESTBED_operation_done.
550  peer_info_cb,
551  &peer_ids[i]);
552  }
553 }
static void peer_info_cb(void *cb_cls, struct GNUNET_TESTBED_Operation *op, const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
Callback to be called when the requested peer information is available.
static unsigned int num_peers
How many peers should participate in the key generation?
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
static struct GNUNET_SECRETSHARING_Session ** session_handles
Handles for secretsharing sessions.
A share, with all values in in host byte order.
Opaque handle to an abstract operation to be executed by the testing framework.
static struct GNUNET_TESTBED_Peer ** peers
Handles to the running peers.
static struct GNUNET_PeerIdentity * peer_ids
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
static void handle_shutdown(void *cls)
Signature of the main function of a task.
static struct GNUNET_SECRETSHARING_Share ** shares
Shares we got from the distributed key generation.
Session that will eventually establish a shared secred between the involved peers and allow encryptio...
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_peer_get_information(struct GNUNET_TESTBED_Peer *peer, enum GNUNET_TESTBED_PeerInformationType pit, GNUNET_TESTBED_PeerInfoCallback cb, void *cb_cls)
Request information about a peer.
Handle to cancel a cooperative decryption operation.
static struct GNUNET_TESTBED_Operation ** connect_ops
Connect operations, one for every peer.
The identity of the host (wraps the signing key of the peer).
What is the identity of the peer? Returns a &#39;const struct GNUNET_PeerIdentity *&#39;. ...
#define GNUNET_log(kind,...)
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
static struct GNUNET_SECRETSHARING_DecryptionHandle ** decrypt_handles
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 557 of file gnunet-secretsharing-profiler.c.

References controller_cb(), delay, dkg_deadline, dkg_start, GNUNET_CONFIGURATION_get_value_string(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_TESTBED_test_run(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), num_peers, session_id, test_master(), timeout, and topology.

Referenced by main().

559 {
560  static char *session_str = "gnunet-secretsharing/test";
561  char *topology;
562  int topology_cmp_result;
563 
566 
567  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed", "OVERLAY_TOPOLOGY", &topology))
568  {
569  fprintf (stderr,
570  "'OVERLAY_TOPOLOGY' not found in 'testbed' config section, "
571  "seems like you passed the wrong configuration file\n");
572  return;
573  }
574 
575  topology_cmp_result = strcasecmp (topology, "NONE");
576  GNUNET_free (topology);
577 
578  if (0 == topology_cmp_result)
579  {
580  fprintf (stderr,
581  "'OVERLAY_TOPOLOGY' set to 'NONE', "
582  "seems like you passed the wrong configuration file\n");
583  return;
584  }
585 
587  "running gnunet-secretsharing-profiler\n");
588 
589  GNUNET_CRYPTO_hash (session_str, strlen (session_str), &session_id);
590 
591  (void) GNUNET_TESTBED_test_run ("gnunet-secretsharing-profiler",
592  cfgfile,
593  num_peers,
594  0,
596  NULL,
597  test_master,
598  NULL);
599 }
static unsigned int num_peers
How many peers should participate in the key generation?
int GNUNET_TESTBED_test_run(const char *testname, const char *cfg_filename, unsigned int num_peers, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, GNUNET_TESTBED_TestMaster test_master, void *test_master_cls)
Convenience method for running a "simple" test on the local system with a single call from &#39;main&#39;...
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:393
static struct GNUNET_TIME_Absolute dkg_start
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
static struct GNUNET_TIME_Relative timeout
When would we like to see the operation finished?
static void controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Signature of the event handler function called by the respective event controller.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
#define GNUNET_log(kind,...)
static struct GNUNET_HashCode session_id
static struct GNUNET_TIME_Absolute dkg_deadline
static void test_master(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **started_peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 603 of file gnunet-secretsharing-profiler.c.

References decrypt, delay, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_relative_time(), GNUNET_GETOPT_option_uint(), GNUNET_GETOPT_option_verbose(), GNUNET_PROGRAM_run2(), GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_ZERO, GNUNET_YES, num_peers, run(), threshold, timeout, and verbose.

604 {
606 
608  "num-peers",
609  NULL,
610  gettext_noop ("number of peers in consensus"),
611  &num_peers),
612 
614  "delay",
615  NULL,
616  gettext_noop ("dkg start delay"),
617  &delay),
618 
620  "timeout",
621  NULL,
622  gettext_noop ("dkg timeout"),
623  &timeout),
624 
626  "threshold",
627  NULL,
628  gettext_noop ("threshold"),
629  &threshold),
630 
632  "descrypt",
633  gettext_noop ("also profile decryption"),
634  &decrypt),
635 
636 
638 
640  };
643  GNUNET_PROGRAM_run2 (argc, argv, "gnunet-secretsharing-profiler",
644  "help",
645  options, &run, NULL, GNUNET_YES);
646  return 0;
647 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time)...
static int decrypt
Should we try to decrypt a value after the key generation?
static unsigned int threshold
What should the threshold for then key be?
static unsigned int verbose
static unsigned int num_peers
How many peers should participate in the key generation?
int GNUNET_PROGRAM_run2(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls, int run_without_scheduler)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:141
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the &#39;-V&#39; verbosity option.
Definition of a command line option.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static struct GNUNET_TIME_Relative timeout
When would we like to see the operation finished?
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ num_peers

unsigned int num_peers = 3
static

◆ threshold

unsigned int threshold = 2
static

What should the threshold for then key be?

Definition at line 39 of file gnunet-secretsharing-profiler.c.

Referenced by GNUNET_TIME_randomized_backoff(), keygen_reveal_get_exp_coeff(), main(), and session_connect_adapter().

◆ decrypt

int decrypt = GNUNET_NO
static

Should we try to decrypt a value after the key generation?

Definition at line 44 of file gnunet-secretsharing-profiler.c.

Referenced by main(), and session_disconnect_adapter().

◆ timeout

struct GNUNET_TIME_Relative timeout
static

When would we like to see the operation finished?

Definition at line 49 of file gnunet-secretsharing-profiler.c.

Referenced by main(), run(), and session_disconnect_adapter().

◆ delay

struct GNUNET_TIME_Relative delay
static

◆ session_handles

struct GNUNET_SECRETSHARING_Session** session_handles
static

Handles for secretsharing sessions.

Definition at line 59 of file gnunet-secretsharing-profiler.c.

Referenced by secret_ready_cb(), and session_disconnect_adapter().

◆ decrypt_handles

struct GNUNET_SECRETSHARING_DecryptionHandle** decrypt_handles
static

◆ shares

struct GNUNET_SECRETSHARING_Share** shares
static

Shares we got from the distributed key generation.

Definition at line 66 of file gnunet-secretsharing-profiler.c.

◆ common_pubkey

struct GNUNET_SECRETSHARING_PublicKey common_pubkey
static

Definition at line 68 of file gnunet-secretsharing-profiler.c.

Referenced by secret_ready_cb(), and session_disconnect_adapter().

◆ num_connected_sessions

unsigned int num_connected_sessions
static

Definition at line 71 of file gnunet-secretsharing-profiler.c.

Referenced by session_connect_complete().

◆ num_connected_decrypt

unsigned int num_connected_decrypt
static

Definition at line 73 of file gnunet-secretsharing-profiler.c.

Referenced by decrypt_connect_complete().

◆ peers

struct GNUNET_TESTBED_Peer** peers
static

Handles to the running peers.

When peers[i] is NULL, the i-th peer has stopped.

Definition at line 79 of file gnunet-secretsharing-profiler.c.

◆ peer_ids

struct GNUNET_PeerIdentity* peer_ids
static

Definition at line 81 of file gnunet-secretsharing-profiler.c.

◆ num_retrieved_peer_ids

unsigned int num_retrieved_peer_ids
static

Definition at line 83 of file gnunet-secretsharing-profiler.c.

Referenced by peer_info_cb().

◆ num_generated

unsigned int num_generated
static

Definition at line 85 of file gnunet-secretsharing-profiler.c.

Referenced by secret_ready_cb(), and session_disconnect_adapter().

◆ num_decrypted

unsigned int num_decrypted
static

Definition at line 87 of file gnunet-secretsharing-profiler.c.

Referenced by decrypt_cb().

◆ session_id

struct GNUNET_HashCode session_id
static

Definition at line 89 of file gnunet-secretsharing-profiler.c.

Referenced by run(), and session_connect_adapter().

◆ verbose

unsigned int verbose
static

Definition at line 91 of file gnunet-secretsharing-profiler.c.

Referenced by main().

◆ reference_plaintext

struct GNUNET_SECRETSHARING_Plaintext reference_plaintext
static

Definition at line 93 of file gnunet-secretsharing-profiler.c.

Referenced by decrypt_cb(), and session_disconnect_adapter().

◆ ciphertext

struct GNUNET_SECRETSHARING_Ciphertext ciphertext
static

◆ dkg_start

struct GNUNET_TIME_Absolute dkg_start
static

Definition at line 97 of file gnunet-secretsharing-profiler.c.

Referenced by run(), and session_connect_adapter().

◆ dkg_deadline

struct GNUNET_TIME_Absolute dkg_deadline
static

Definition at line 99 of file gnunet-secretsharing-profiler.c.

Referenced by run(), and session_connect_adapter().

◆ decrypt_start

struct GNUNET_TIME_Absolute decrypt_start
static

◆ decrypt_deadline

struct GNUNET_TIME_Absolute decrypt_deadline
static

◆ connect_ops

struct GNUNET_TESTBED_Operation** connect_ops
static

Connect operations, one for every peer.

Definition at line 109 of file gnunet-secretsharing-profiler.c.

◆ in_shutdown

int in_shutdown
static

Are we performing a shutdown right now?

Definition at line 114 of file gnunet-secretsharing-profiler.c.

Referenced by handle_shutdown(), and session_disconnect_adapter().