aboutsummaryrefslogtreecommitdiff
path: root/src/util/gnunet-scrypt.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-02 13:10:25 +0100
committerChristian Grothoff <christian@grothoff.org>2022-01-02 13:10:25 +0100
commitbb686c48354853aa725e493e85edce0602ed85e2 (patch)
tree6b0aeea58a7aebe0e3108da5302eaeae2c996ceb /src/util/gnunet-scrypt.c
parent2cbb614f694701c4afdab88f58ef7626629e1bc3 (diff)
downloadgnunet-bb686c48354853aa725e493e85edce0602ed85e2.tar.gz
gnunet-bb686c48354853aa725e493e85edce0602ed85e2.zip
revise DHT hashing functions, add test logic
Diffstat (limited to 'src/util/gnunet-scrypt.c')
-rw-r--r--src/util/gnunet-scrypt.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/util/gnunet-scrypt.c b/src/util/gnunet-scrypt.c
index fe8b6769f..ad46e3f39 100644
--- a/src/util/gnunet-scrypt.c
+++ b/src/util/gnunet-scrypt.c
@@ -78,24 +78,6 @@ shutdown_task (void *cls)
78 78
79 79
80/** 80/**
81 * Count the leading zeroes in hash.
82 *
83 * @param hash to count leading zeros in
84 * @return the number of leading zero bits.
85 */
86static unsigned int
87count_leading_zeroes (const struct GNUNET_HashCode *hash)
88{
89 unsigned int hash_count;
90
91 hash_count = 0;
92 while (0 == GNUNET_CRYPTO_hash_get_bit_ltr (hash, hash_count))
93 hash_count++;
94 return hash_count;
95}
96
97
98/**
99 * Find our proof of work. 81 * Find our proof of work.
100 * 82 *
101 * @param cls closure (unused) 83 * @param cls closure (unused)
@@ -131,7 +113,8 @@ find_proof (void *cls)
131 buf, 113 buf,
132 sizeof(buf), 114 sizeof(buf),
133 &result); 115 &result);
134 if (nse_work_required <= count_leading_zeroes (&result)) 116 if (nse_work_required <=
117 GNUNET_CRYPTO_hash_count_leading_zeros (&result))
135 { 118 {
136 proof = counter; 119 proof = counter;
137 fprintf (stdout, 120 fprintf (stdout,