aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/gnunet-revocation-tvg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/revocation/gnunet-revocation-tvg.c')
-rw-r--r--src/revocation/gnunet-revocation-tvg.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/src/revocation/gnunet-revocation-tvg.c b/src/revocation/gnunet-revocation-tvg.c
index 23a4bf020..b8f462b28 100644
--- a/src/revocation/gnunet-revocation-tvg.c
+++ b/src/revocation/gnunet-revocation-tvg.c
@@ -34,6 +34,22 @@
34#define TEST_EPOCHS 2 34#define TEST_EPOCHS 2
35#define TEST_DIFFICULTY 5 35#define TEST_DIFFICULTY 5
36 36
37static void
38print_bytes (void *buf,
39 size_t buf_len,
40 int fold)
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}
52
37/** 53/**
38 * Main function that will be run. 54 * Main function that will be run.
39 * 55 *
@@ -52,22 +68,18 @@ run (void *cls,
52 struct GNUNET_CRYPTO_EcdsaPublicKey id_pub; 68 struct GNUNET_CRYPTO_EcdsaPublicKey id_pub;
53 struct GNUNET_REVOCATION_PowP pow; 69 struct GNUNET_REVOCATION_PowP pow;
54 struct GNUNET_REVOCATION_PowCalculationHandle *ph; 70 struct GNUNET_REVOCATION_PowCalculationHandle *ph;
55 char* data_enc; 71 struct GNUNET_TIME_Relative exp;
56 72
57 GNUNET_CRYPTO_ecdsa_key_create (&id_priv); 73 GNUNET_CRYPTO_ecdsa_key_create (&id_priv);
58 GNUNET_CRYPTO_ecdsa_key_get_public (&id_priv, 74 GNUNET_CRYPTO_ecdsa_key_get_public (&id_priv,
59 &id_pub); 75 &id_pub);
60 GNUNET_STRINGS_base64_encode (&id_priv, 76 fprintf(stdout, "Zone private key (d, little-endian scalar):\n");
61 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), 77 print_bytes (&id_priv, sizeof(id_priv), 0);
62 &data_enc); 78 fprintf(stdout, "\n");
63 fprintf(stdout, "Zone private key (d):\n%s\n\n", data_enc); 79 fprintf(stdout, "Zone public key (zk):\n");
64 GNUNET_free (data_enc); 80 print_bytes (&id_pub, sizeof(id_pub), 0);
65 GNUNET_STRINGS_base64_encode (&id_pub, 81 fprintf(stdout, "\n");
66 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), 82 memset (&pow, 0, sizeof (pow));
67 &data_enc);
68 fprintf(stdout, "Zone public key (zk):\n%s\n\n", data_enc);
69 GNUNET_free (data_enc);
70
71 GNUNET_REVOCATION_pow_init (&id_priv, 83 GNUNET_REVOCATION_pow_init (&id_priv,
72 &pow); 84 &pow);
73 ph = GNUNET_REVOCATION_pow_start (&pow, 85 ph = GNUNET_REVOCATION_pow_start (&pow,
@@ -82,11 +94,15 @@ run (void *cls,
82 { 94 {
83 pow_passes++; 95 pow_passes++;
84 } 96 }
85 GNUNET_STRINGS_base64_encode (&pow, 97 exp = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
86 sizeof (struct GNUNET_REVOCATION_PowP), 98 TEST_EPOCHS);
87 &data_enc); 99 GNUNET_assert (GNUNET_OK == GNUNET_REVOCATION_check_pow (&pow,
88 fprintf(stdout, "Proof:\n%s\n", data_enc); 100 TEST_DIFFICULTY,
89 GNUNET_free (data_enc); 101 exp));
102 fprintf(stdout, "Proof:\n");
103 print_bytes (&pow,
104 sizeof (pow),
105 8);
90} 106}
91 107
92 108