Fabcoin Core  0.16.2
P2P Digital Currency
Classes | Macros | Typedefs | Enumerations | Functions
equihash.h File Reference
#include "compat/endian.h"
#include "crypto/sha256.h"
#include "utilstrencodings.h"
#include "sodium.h"
#include <cstring>
#include <exception>
#include <functional>
#include <memory>
#include <set>
#include <vector>
#include <boost/static_assert.hpp>
#include "equihash.tcc"
Include dependency graph for equihash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  StepRow< WIDTH >
 
class  CompareSR
 
class  FullStepRow< WIDTH >
 
class  TruncatedStepRow< WIDTH >
 
class  EhSolverCancelledException
 
class  Equihash< N, K >
 

Macros

#define EhInitialiseState(n, k, base_state)
 
#define EhIsValidSolution(n, k, base_state, soln, ret)
 

Typedefs

typedef crypto_generichash_blake2b_state eh_HashState
 
typedef uint32_t eh_index
 
typedef uint8_t eh_trunc
 

Enumerations

enum  EhSolverCancelCheck {
  ListGeneration, ListSorting, ListColliding, RoundEnd,
  FinalSorting, FinalColliding, PartialGeneration, PartialSorting,
  PartialSubtreeEnd, PartialIndexEnd, PartialEnd
}
 

Functions

void ExpandArray (const unsigned char *in, size_t in_len, unsigned char *out, size_t out_len, size_t bit_len, size_t byte_pad=0)
 
void CompressArray (const unsigned char *in, size_t in_len, unsigned char *out, size_t out_len, size_t bit_len, size_t byte_pad=0)
 
eh_index ArrayToEhIndex (const unsigned char *array)
 
eh_trunc TruncateIndex (const eh_index i, const unsigned int ilen)
 
std::vector< eh_indexGetIndicesFromMinimal (std::vector< unsigned char > minimal, size_t cBitLen)
 
std::vector< unsigned char > GetMinimalFromIndices (std::vector< eh_index > indices, size_t cBitLen)
 
template<size_t WIDTH>
bool HasCollision (StepRow< WIDTH > &a, StepRow< WIDTH > &b, size_t l)
 
constexpr size_t max (const size_t A, const size_t B)
 
constexpr size_t equihash_solution_size (unsigned int N, unsigned int K)
 
bool EhBasicSolve (unsigned int n, unsigned int k, const eh_HashState &base_state, const std::function< bool(std::vector< unsigned char >)> validBlock, const std::function< bool(EhSolverCancelCheck)> cancelled)
 
bool EhBasicSolveUncancellable (unsigned int n, unsigned int k, const eh_HashState &base_state, const std::function< bool(std::vector< unsigned char >)> validBlock)
 
bool EhOptimisedSolve (unsigned int n, unsigned int k, const eh_HashState &base_state, const std::function< bool(std::vector< unsigned char >)> validBlock, const std::function< bool(EhSolverCancelCheck)> cancelled)
 
bool EhOptimisedSolveUncancellable (unsigned int n, unsigned int k, const eh_HashState &base_state, const std::function< bool(std::vector< unsigned char >)> validBlock)
 

Macro Definition Documentation

#define EhInitialiseState (   n,
  k,
  base_state 
)
Value:
if (n == 96 && k == 3) { \
Eh96_3.InitialiseState(base_state); \
} else if (n == 200 && k == 9) { \
Eh200_9.InitialiseState(base_state); \
} else if (n == 96 && k == 5) { \
Eh96_5.InitialiseState(base_state); \
} else if (n == 48 && k == 5) { \
Eh48_5.InitialiseState(base_state); \
} else if (n == 184 && k == 7) { \
Eh184_7.InitialiseState(base_state); \
} else { \
throw std::invalid_argument("Unsupported Equihash parameters"); \
}

Definition at line 204 of file equihash.h.

#define EhIsValidSolution (   n,
  k,
  base_state,
  soln,
  ret 
)
Value:
if (n == 96 && k == 3) { \
ret = Eh96_3.IsValidSolution(base_state, soln); \
} else if (n == 200 && k == 9) { \
ret = Eh200_9.IsValidSolution(base_state, soln); \
} else if (n == 96 && k == 5) { \
ret = Eh96_5.IsValidSolution(base_state, soln); \
} else if (n == 48 && k == 5) { \
ret = Eh48_5.IsValidSolution(base_state, soln); \
} else if (n == 184 && k == 7) { \
ret = Eh184_7.IsValidSolution(base_state, soln); \
} else { \
throw std::invalid_argument("Unsupported Equihash parameters"); \
}

Definition at line 271 of file equihash.h.

Typedef Documentation

typedef crypto_generichash_blake2b_state eh_HashState

Definition at line 24 of file equihash.h.

typedef uint32_t eh_index

Definition at line 25 of file equihash.h.

typedef uint8_t eh_trunc

Definition at line 26 of file equihash.h.

Enumeration Type Documentation

Enumerator
ListGeneration 
ListSorting 
ListColliding 
RoundEnd 
FinalSorting 
FinalColliding 
PartialGeneration 
PartialSorting 
PartialSubtreeEnd 
PartialIndexEnd 
PartialEnd 

Definition at line 135 of file equihash.h.

Function Documentation

eh_index ArrayToEhIndex ( const unsigned char *  array)

Definition at line 158 of file equihash.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CompressArray ( const unsigned char *  in,
size_t  in_len,
unsigned char *  out,
size_t  out_len,
size_t  bit_len,
size_t  byte_pad = 0 
)

Definition at line 108 of file equihash.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool EhBasicSolve ( unsigned int  n,
unsigned int  k,
const eh_HashState base_state,
const std::function< bool(std::vector< unsigned char >)>  validBlock,
const std::function< bool(EhSolverCancelCheck)>  cancelled 
)
inline

Definition at line 219 of file equihash.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool EhBasicSolveUncancellable ( unsigned int  n,
unsigned int  k,
const eh_HashState base_state,
const std::function< bool(std::vector< unsigned char >)>  validBlock 
)
inline

Definition at line 238 of file equihash.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool EhOptimisedSolve ( unsigned int  n,
unsigned int  k,
const eh_HashState base_state,
const std::function< bool(std::vector< unsigned char >)>  validBlock,
const std::function< bool(EhSolverCancelCheck)>  cancelled 
)
inline

Definition at line 245 of file equihash.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool EhOptimisedSolveUncancellable ( unsigned int  n,
unsigned int  k,
const eh_HashState base_state,
const std::function< bool(std::vector< unsigned char >)>  validBlock 
)
inline

Definition at line 264 of file equihash.h.

Here is the call graph for this function:

constexpr size_t equihash_solution_size ( unsigned int  N,
unsigned int  K 
)
inline

Definition at line 159 of file equihash.h.

Here is the caller graph for this function:

void ExpandArray ( const unsigned char *  in,
size_t  in_len,
unsigned char *  out,
size_t  out_len,
size_t  bit_len,
size_t  byte_pad = 0 
)

Definition at line 64 of file equihash.cpp.

Here is the caller graph for this function:

std::vector<eh_index> GetIndicesFromMinimal ( std::vector< unsigned char >  minimal,
size_t  cBitLen 
)

Definition at line 179 of file equihash.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector<unsigned char> GetMinimalFromIndices ( std::vector< eh_index indices,
size_t  cBitLen 
)

Definition at line 195 of file equihash.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<size_t WIDTH>
bool HasCollision ( StepRow< WIDTH > &  a,
StepRow< WIDTH > &  b,
size_t  l 
)

Definition at line 283 of file equihash.cpp.

constexpr size_t max ( const size_t  A,
const size_t  B 
)
inline

Definition at line 157 of file equihash.h.

eh_trunc TruncateIndex ( const eh_index  i,
const unsigned int  ilen 
)

Definition at line 166 of file equihash.cpp.

Here is the caller graph for this function: