From 19cd0e6d0eca5192a9c8f4f005abd85d531949f1 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Mon, 25 May 2020 11:22:07 +0200 Subject: [PATCH] add some more debug output --- src/revocation/gnunet-revocation-tvg.c | 8 +++++++- src/revocation/revocation_api.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/revocation/gnunet-revocation-tvg.c b/src/revocation/gnunet-revocation-tvg.c index 805b7c39c..2b850e436 100644 --- a/src/revocation/gnunet-revocation-tvg.c +++ b/src/revocation/gnunet-revocation-tvg.c @@ -52,6 +52,7 @@ run (void *cls, struct GNUNET_CRYPTO_EcdsaPublicKey id_pub; struct GNUNET_REVOCATION_PowP pow; struct GNUNET_REVOCATION_PowCalculationHandle *ph; + struct GNUNET_TIME_Relative exp; char* data_enc; GNUNET_CRYPTO_ecdsa_key_create (&id_priv); @@ -67,7 +68,7 @@ run (void *cls, &data_enc); fprintf(stdout, "Zone public key (zk):\n%s\n\n", data_enc); GNUNET_free (data_enc); - + memset (&pow, 0, sizeof (pow)); GNUNET_REVOCATION_pow_init (&id_priv, &pow); ph = GNUNET_REVOCATION_pow_start (&pow, @@ -82,6 +83,11 @@ run (void *cls, { pow_passes++; } + exp = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, + TEST_EPOCHS); + GNUNET_assert (GNUNET_OK == GNUNET_REVOCATION_check_pow (&pow, + TEST_DIFFICULTY, + exp)); GNUNET_STRINGS_base64_encode (&pow, sizeof (struct GNUNET_REVOCATION_PowP), &data_enc); diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index 39fdb8b6f..3789e6799 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c @@ -394,7 +394,6 @@ static unsigned int count_leading_zeroes (const struct GNUNET_HashCode *hash) { unsigned int hash_count; - hash_count = 0; while ((0 == GNUNET_CRYPTO_hash_get_bit (hash, hash_count))) hash_count++; @@ -436,6 +435,7 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow, + sizeof (struct GNUNET_TIME_AbsoluteNBO) + sizeof (uint64_t)] GNUNET_ALIGN; struct GNUNET_REVOCATION_SignaturePurposePS spurp; + struct GNUNET_CRYPTO_HashAsciiEncoded h_str; struct GNUNET_HashCode result; struct GNUNET_TIME_Absolute ts; struct GNUNET_TIME_Absolute exp; @@ -492,6 +492,12 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Score %u with %" PRIu64 " (#%u)\n", tmp_score, pow_val, i); + + GNUNET_CRYPTO_hash_to_enc (&result, + &h_str); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Hash: %s\n", (char*)&h_str); + score += tmp_score; } -- 2.25.1