aboutsummaryrefslogtreecommitdiff
path: root/src/revocation
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-05-26 10:50:23 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-05-26 10:50:23 +0200
commit870c6d65864ff8265c5e4863529df4a44f99e1b1 (patch)
tree969a842d7ebe1369e2accbbee31fb970bb705241 /src/revocation
parent7b48b9e292ce90d1d663ca9ce7b2ccc95f0fd00e (diff)
downloadgnunet-870c6d65864ff8265c5e4863529df4a44f99e1b1.tar.gz
gnunet-870c6d65864ff8265c5e4863529df4a44f99e1b1.zip
test vectors in binary
Diffstat (limited to 'src/revocation')
-rw-r--r--src/revocation/gnunet-revocation-tvg.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/revocation/gnunet-revocation-tvg.c b/src/revocation/gnunet-revocation-tvg.c
index 2b850e436..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 *
@@ -53,21 +69,16 @@ run (void *cls,
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 struct GNUNET_TIME_Relative exp; 71 struct GNUNET_TIME_Relative exp;
56 char* data_enc;
57 72
58 GNUNET_CRYPTO_ecdsa_key_create (&id_priv); 73 GNUNET_CRYPTO_ecdsa_key_create (&id_priv);
59 GNUNET_CRYPTO_ecdsa_key_get_public (&id_priv, 74 GNUNET_CRYPTO_ecdsa_key_get_public (&id_priv,
60 &id_pub); 75 &id_pub);
61 GNUNET_STRINGS_base64_encode (&id_priv, 76 fprintf(stdout, "Zone private key (d, little-endian scalar):\n");
62 sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey), 77 print_bytes (&id_priv, sizeof(id_priv), 0);
63 &data_enc); 78 fprintf(stdout, "\n");
64 fprintf(stdout, "Zone private key (d):\n%s\n\n", data_enc); 79 fprintf(stdout, "Zone public key (zk):\n");
65 GNUNET_free (data_enc); 80 print_bytes (&id_pub, sizeof(id_pub), 0);
66 GNUNET_STRINGS_base64_encode (&id_pub, 81 fprintf(stdout, "\n");
67 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
68 &data_enc);
69 fprintf(stdout, "Zone public key (zk):\n%s\n\n", data_enc);
70 GNUNET_free (data_enc);
71 memset (&pow, 0, sizeof (pow)); 82 memset (&pow, 0, sizeof (pow));
72 GNUNET_REVOCATION_pow_init (&id_priv, 83 GNUNET_REVOCATION_pow_init (&id_priv,
73 &pow); 84 &pow);
@@ -88,11 +99,10 @@ run (void *cls,
88 GNUNET_assert (GNUNET_OK == GNUNET_REVOCATION_check_pow (&pow, 99 GNUNET_assert (GNUNET_OK == GNUNET_REVOCATION_check_pow (&pow,
89 TEST_DIFFICULTY, 100 TEST_DIFFICULTY,
90 exp)); 101 exp));
91 GNUNET_STRINGS_base64_encode (&pow, 102 fprintf(stdout, "Proof:\n");
92 sizeof (struct GNUNET_REVOCATION_PowP), 103 print_bytes (&pow,
93 &data_enc); 104 sizeof (pow),
94 fprintf(stdout, "Proof:\n%s\n", data_enc); 105 8);
95 GNUNET_free (data_enc);
96} 106}
97 107
98 108