GNUnet  0.11.x
Functions
crypto_pow.c File Reference

proof-of-work hashing More...

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

Go to the source code of this file.

Functions

void GNUNET_CRYPTO_pow_hash (const char *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

Author
Christian Grothoff
Bart Polot

Definition in file crypto_pow.c.

Function Documentation

◆ GNUNET_CRYPTO_pow_hash()

void GNUNET_CRYPTO_pow_hash ( const char *  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).

Parameters
saltsalt for the hash
bufdata to hash
buf_lennumber of bytes in buf
resultwhere to write the resulting hash

Definition at line 42 of file crypto_pow.c.

References GNUNET_break, GNUNET_CRYPTO_symmetric_derive_iv(), and GNUNET_CRYPTO_symmetric_encrypt().

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

46 {
49  char rbuf[buf_len];
50 
51  GNUNET_break (0 == gcry_kdf_derive (buf,
52  buf_len,
53  GCRY_KDF_SCRYPT,
54  1 /* subalgo */,
55  salt,
56  strlen (salt),
57  2 /* iterations; keep cost of individual op small */,
58  sizeof(skey),
59  &skey));
61  &skey,
62  "gnunet-proof-of-work-iv",
63  strlen ("gnunet-proof-of-work-iv"),
64  salt,
65  strlen (salt),
66  NULL, 0);
68  buf_len,
69  &skey,
70  &iv,
71  &rbuf);
72  GNUNET_break (0 == gcry_kdf_derive (rbuf,
73  buf_len,
74  GCRY_KDF_SCRYPT,
75  1 /* subalgo */,
76  salt,
77  strlen (salt),
78  2 /* iterations; keep cost of individual op small */,
79  sizeof(struct GNUNET_HashCode),
80  result));
81 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
ssize_t GNUNET_CRYPTO_symmetric_encrypt(const void *block, size_t size, const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, void *result)
Encrypt a block using a symmetric sessionkey.
void GNUNET_CRYPTO_symmetric_derive_iv(struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, const void *salt, size_t salt_len,...)
Derive an IV.
static char buf[2048]
A 512-bit hashcode.
Here is the call graph for this function:
Here is the caller graph for this function: