GNUnet  0.11.x
crypto_pow.c File Reference

proof-of-work hashing More...

#include "platform.h"
#include "gnunet_crypto_lib.h"
#include <sodium.h>
Include dependency graph for crypto_pow.c:

Go to the source code of this file.


void GNUNET_CRYPTO_pow_hash (const struct GNUNET_CRYPTO_PowSalt *salt, const void *buf, size_t buf_len, struct GNUNET_HashCode *result)
 Calculate the 'proof-of-work' hash (an expensive hash). More...

Detailed Description

proof-of-work hashing

Christian Grothoff
Bart Polot

Definition in file crypto_pow.c.

Function Documentation

◆ GNUNET_CRYPTO_pow_hash()

void GNUNET_CRYPTO_pow_hash ( const struct GNUNET_CRYPTO_PowSalt salt,
const void *  buf,
size_t  buf_len,
struct GNUNET_HashCode result 

Calculate the 'proof-of-work' hash (an expensive hash).

We're using a non-standard formula to avoid issues with ASICs appearing (see #3795).

saltsalt for the hash. Must be crypto_pwhash_argon2id_SALTBYTES long.
bufdata to hash
buf_lennumber of bytes in buf
resultwhere to write the resulting hash

Definition at line 41 of file crypto_pow.c.

References GNUNET_break.

Referenced by check_proof_of_work(), find_proof(), GNUNET_REVOCATION_check_pow(), and GNUNET_REVOCATION_pow_round().

45 {
46  /* Threads hardcoded at 1 in libsodium */
47  GNUNET_break (0 ==
48  crypto_pwhash_argon2id ((unsigned char *) result,
49  sizeof (struct GNUNET_HashCode),
50  buf,
51  buf_len,
52  (unsigned char*) salt,
53  3, /* iterations */
54  1024 * 1024, /* memory (1 MiB) */
55  crypto_pwhash_argon2id_ALG_ARGON2ID13));
56 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static char buf[2048]
A 512-bit hashcode.
Here is the caller graph for this function: