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.


#define TEST_EPOCHS   2


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


#define TEST_EPOCHS   2

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



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

Function Documentation

◆ print_bytes()

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

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

41 {
42  int i;
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]

References buf.

Referenced by run().

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 

Main function that will be run.

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

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

67 {
68  struct GNUNET_IDENTITY_PrivateKey id_priv;
69  struct GNUNET_IDENTITY_PublicKey id_pub;
72  struct GNUNET_TIME_Relative exp;
73  char ztld[128];
75  id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
76  GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key);
78  &id_pub);
81  ztld,
82  sizeof (ztld));
83  fprintf (stdout, "Zone private key (d, little-endian scalar, with ztype prepended):\n");
84  print_bytes (&id_priv, sizeof(id_priv), 8);
85  fprintf (stdout, "\n");
86  fprintf (stdout, "Zone identifier (zid):\n");
87  print_bytes (&id_pub, GNUNET_IDENTITY_key_get_length (&id_pub), 8);
88  fprintf (stdout, "\n");
89  fprintf (stdout, "Encoded zone identifier (zkl = zTLD):\n");
90  fprintf (stdout, "%s\n", ztld);
91  fprintf (stdout, "\n");
94  pow);
98  fprintf (stdout, "Difficulty (%d base difficulty + %d epochs): %d\n\n",
102  uint64_t pow_passes = 0;
104  {
105  pow_passes++;
106  }
111  exp));
112  fprintf (stdout, "Proof:\n");
113  print_bytes (pow,
115  8);
116 }
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
static void print_bytes(void *buf, size_t buf_len, int fold)
static unsigned int pow_passes
Pow passes.
Definition: gnunet_common.h:95
Definition: gnunet_common.h:97
void GNUNET_CRYPTO_ecdsa_key_create(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:446
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:175
ssize_t GNUNET_IDENTITY_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:976
The identity type.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_malloc(size)
Wrapper around malloc.
size_t GNUNET_REVOCATION_proof_get_size(const struct GNUNET_REVOCATION_PowP *pow)
void GNUNET_REVOCATION_pow_init(const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_REVOCATION_PowP *pow)
Initializes a fresh PoW computation.
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_pow_round(struct GNUNET_REVOCATION_PowCalculationHandle *pc)
Calculate a single round in the key revocation PoW.
Maximum length of a revocation.
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.
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.
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:695
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:311
One year (365 days).
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
The handle to a PoW calculation.
Struct for a proof of work as part of the revocation.
Time for relative time used by GNUnet, in microseconds.

References GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_assert, GNUNET_CRYPTO_ecdsa_key_create(), GNUNET_IDENTITY_key_get_length(), GNUNET_IDENTITY_key_get_public(), GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_malloc, GNUNET_OK, GNUNET_REVOCATION_check_pow(), GNUNET_REVOCATION_MAX_PROOF_SIZE, GNUNET_REVOCATION_pow_init(), GNUNET_REVOCATION_pow_round(), GNUNET_REVOCATION_pow_start(), GNUNET_REVOCATION_proof_get_size(), GNUNET_STRINGS_data_to_string(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_YEARS, GNUNET_YES, ph, GNUNET_REVOCATION_PowP::pow, pow_passes, print_bytes(), TEST_DIFFICULTY, TEST_EPOCHS, and GNUNET_IDENTITY_PrivateKey::type.

Referenced by main().

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.

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

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

129 {
130  const struct GNUNET_GETOPT_CommandLineOption options[] = {
132  };
135  GNUNET_log_setup ("gnunet-revocation-tvg",
136  "INFO",
137  NULL));
138  if (GNUNET_OK !=
139  GNUNET_PROGRAM_run (argc, argv,
140  "gnunet-revocation-tvg",
141  "Generate test vectors for revocation",
142  options,
143  &run, NULL))
144  return 1;
145  return 0;
146 }
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
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_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
enum GNUNET_GenericReturnValue 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,...
Definition: program.c:364
Definition of a command line option.

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

Here is the call graph for this function: