aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/revocation_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-30 23:08:49 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-30 23:08:49 +0100
commit7cde88367991dcd1deca2485970c353fec5aff3e (patch)
treec2db008b530ac935a3375d562f80e67e85ba32b0 /src/revocation/revocation_api.c
parentf536489f831c5fd243c22545be12a2cd0f88a84d (diff)
downloadgnunet-7cde88367991dcd1deca2485970c353fec5aff3e.tar.gz
gnunet-7cde88367991dcd1deca2485970c353fec5aff3e.zip
use new POW function consistently, also in revocation
Diffstat (limited to 'src/revocation/revocation_api.c')
-rw-r--r--src/revocation/revocation_api.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c
index fd25050e2..ea8db835f 100644
--- a/src/revocation/revocation_api.c
+++ b/src/revocation/revocation_api.c
@@ -324,29 +324,6 @@ GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h)
324 324
325 325
326/** 326/**
327 * Calculate the 'proof-of-work' hash (an expensive hash).
328 *
329 * @param buf data to hash
330 * @param buf_len number of bytes in @a buf
331 * @param result where to write the resulting hash
332 */
333static void
334pow_hash (const void *buf,
335 size_t buf_len,
336 struct GNUNET_HashCode *result)
337{
338 GNUNET_break (0 ==
339 gcry_kdf_derive (buf, buf_len,
340 GCRY_KDF_SCRYPT,
341 1 /* subalgo */,
342 "gnunet-revocation-proof-of-work",
343 strlen ("gnunet-revocation-proof-of-work"),
344 2 /* iterations; keep cost of individual op small */,
345 sizeof(struct GNUNET_HashCode), result));
346}
347
348
349/**
350 * Count the leading zeroes in hash. 327 * Count the leading zeroes in hash.
351 * 328 *
352 * @param hash to count leading zeros in 329 * @param hash to count leading zeros in
@@ -385,7 +362,10 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_CRYPTO_EcdsaPublicKey *key,
385 GNUNET_memcpy (buf, &pow, sizeof(pow)); 362 GNUNET_memcpy (buf, &pow, sizeof(pow));
386 GNUNET_memcpy (&buf[sizeof(pow)], key, 363 GNUNET_memcpy (&buf[sizeof(pow)], key,
387 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)); 364 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey));
388 pow_hash (buf, sizeof(buf), &result); 365 GNUNET_CRYPTO_pow_hash ("gnunet-revocation-proof-of-work",
366 buf,
367 sizeof(buf),
368 &result);
389 return (count_leading_zeroes (&result) >= 369 return (count_leading_zeroes (&result) >=
390 matching_bits) ? GNUNET_YES : GNUNET_NO; 370 matching_bits) ? GNUNET_YES : GNUNET_NO;
391} 371}