GNUnet  0.11.x
Macros | Functions
gnunet-revocation-tvg.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_signatures.h"
#include "gnunet_revocation_service.h"
#include "gnunet_dnsparser_lib.h"
#include "gnunet_testing_lib.h"
#include <inttypes.h>
Include dependency graph for gnunet-revocation-tvg.c:

Go to the source code of this file.

Macros

#define TEST_EPOCHS   2
 
#define TEST_DIFFICULTY   5
 

Functions

static void print_bytes (void *buf, size_t buf_len, int fold)
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be run. More...
 
int main (int argc, char *const *argv)
 The main function of the test vector generation tool. More...
 

Macro Definition Documentation

◆ TEST_EPOCHS

#define TEST_EPOCHS   2

Definition at line 34 of file gnunet-revocation-tvg.c.

Referenced by run().

◆ TEST_DIFFICULTY

#define TEST_DIFFICULTY   5

Definition at line 35 of file gnunet-revocation-tvg.c.

Referenced by run().

Function Documentation

◆ print_bytes()

static void print_bytes ( void *  buf,
size_t  buf_len,
int  fold 
)
static

Definition at line 38 of file gnunet-revocation-tvg.c.

Referenced by run().

41 {
42  int i;
43 
44  for (i = 0; i < buf_len; i++)
45  {
46  if ((0 != i) && (0 != fold) && (i % fold == 0))
47  printf ("\n");
48  printf ("%02x", ((unsigned char*) buf)[i]);
49  }
50  printf ("\n");
51 }
static char buf[2048]
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

Main function that will be run.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 63 of file gnunet-revocation-tvg.c.

References GNUNET_assert, GNUNET_CRYPTO_ecdsa_key_create(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_OK, GNUNET_REVOCATION_check_pow(), GNUNET_REVOCATION_pow_init(), GNUNET_REVOCATION_pow_round(), GNUNET_REVOCATION_pow_start(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_YEARS, GNUNET_YES, ph, pow_passes, print_bytes(), TEST_DIFFICULTY, and TEST_EPOCHS.

Referenced by main().

67 {
68  struct GNUNET_CRYPTO_EcdsaPrivateKey id_priv;
69  struct GNUNET_CRYPTO_EcdsaPublicKey id_pub;
72  struct GNUNET_TIME_Relative exp;
73 
76  &id_pub);
77  fprintf (stdout, "Zone private key (d, little-endian scalar):\n");
78  print_bytes (&id_priv, sizeof(id_priv), 0);
79  fprintf (stdout, "\n");
80  fprintf (stdout, "Zone public key (zk):\n");
81  print_bytes (&id_pub, sizeof(id_pub), 0);
82  fprintf (stdout, "\n");
83  memset (&pow, 0, sizeof (pow));
85  &pow);
86  ph = GNUNET_REVOCATION_pow_start (&pow,
89  fprintf (stdout, "Difficulty (%d base difficulty + %d epochs): %d\n\n",
93  uint64_t pow_passes = 0;
95  {
96  pow_passes++;
97  }
99  TEST_EPOCHS);
102  exp));
103  fprintf (stdout, "Proof:\n");
104  print_bytes (&pow,
105  sizeof (pow),
106  8);
107 }
void GNUNET_REVOCATION_pow_init(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_REVOCATION_PowP *pow)
Initializes a fresh PoW computation.
static void print_bytes(void *buf, size_t buf_len, int fold)
#define TEST_EPOCHS
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_pow_round(struct GNUNET_REVOCATION_PowCalculationHandle *pc)
Calculate a single round in the key revocation PoW.
Struct for a proof of work as part of the revocation.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
Private ECC key encoded for transmission.
#define TEST_DIFFICULTY
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:442
uint64_t pow[32]
The PoWs.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:176
static unsigned int pow_passes
Pow passes.
struct GNUNET_REVOCATION_PowCalculationHandle * GNUNET_REVOCATION_pow_start(struct GNUNET_REVOCATION_PowP *pow, int epochs, unsigned int difficulty)
Starts a proof-of-work calculation given the pow object as well as target epochs and difficulty...
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:524
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_TIME_UNIT_YEARS
One year (365 days).
The handle to a PoW calculation.
Time for relative time used by GNUnet, in microseconds.
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_check_pow(const struct GNUNET_REVOCATION_PowP *pow, unsigned int matching_bits, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function of the test vector generation tool.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 118 of file gnunet-revocation-tvg.c.

References GNUNET_assert, GNUNET_GETOPT_OPTION_END, GNUNET_log_setup(), GNUNET_OK, GNUNET_PROGRAM_run(), and run().

120 {
121  const struct GNUNET_GETOPT_CommandLineOption options[] = {
123  };
124 
126  GNUNET_log_setup ("gnunet-revocation-tvg",
127  "INFO",
128  NULL));
129  if (GNUNET_OK !=
130  GNUNET_PROGRAM_run (argc, argv,
131  "gnunet-revocation-tvg",
132  "Generate test vectors for revocation",
133  options,
134  &run, NULL))
135  return 1;
136  return 0;
137 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Definition of a command line option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
Here is the call graph for this function: