add some more debug output
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Mon, 25 May 2020 09:22:07 +0000 (11:22 +0200)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Mon, 25 May 2020 09:22:07 +0000 (11:22 +0200)
src/revocation/gnunet-revocation-tvg.c
src/revocation/revocation_api.c

index 805b7c39c2b5a02141743d80a6604b2b3ba1f149..2b850e43627905851f44763f984fb9a89f0d938d 100644 (file)
@@ -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);
index 39fdb8b6f32c93071da76ce78960d458b9532006..3789e67999a7a894134d937122599ceda7d17ca3 100644 (file)
@@ -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;
 
   }