GNUnet  0.16.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.

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 }
static int result
Global testing status.
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calcualations.
static char buf[2048]
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
A 512-bit hashcode.

References buf, GNUNET_break, result, and salt.

Referenced by find_proof().

Here is the caller graph for this function: