|
|
@ -1,5 +1,6 @@ |
|
|
|
// Copyright (c) 2016 Jack Grigg
|
|
|
|
// Copyright (c) 2016 The Zcash developers
|
|
|
|
// Copyright (c) 2017-2018 The LitecoinZ developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
@ -20,7 +21,6 @@ |
|
|
|
|
|
|
|
#include <boost/static_assert.hpp> |
|
|
|
|
|
|
|
|
|
|
|
typedef crypto_generichash_blake2b_state eh_HashState; |
|
|
|
typedef uint32_t eh_index; |
|
|
|
typedef uint8_t eh_trunc; |
|
|
@ -200,6 +200,8 @@ static Equihash<96,3> Eh96_3; |
|
|
|
static Equihash<200,9> Eh200_9; |
|
|
|
static Equihash<96,5> Eh96_5; |
|
|
|
static Equihash<48,5> Eh48_5; |
|
|
|
static Equihash<144,5> Eh144_5; |
|
|
|
static Equihash<192,7> Eh192_7; |
|
|
|
|
|
|
|
#define EhInitialiseState(n, k, base_state) \ |
|
|
|
if (n == 96 && k == 3) { \ |
|
|
@ -210,6 +212,10 @@ static Equihash<48,5> Eh48_5; |
|
|
|
Eh96_5.InitialiseState(base_state); \ |
|
|
|
} else if (n == 48 && k == 5) { \ |
|
|
|
Eh48_5.InitialiseState(base_state); \ |
|
|
|
} else if (n == 144 && k == 5) { \ |
|
|
|
Eh144_5.InitialiseState(base_state); \ |
|
|
|
} else if (n == 192 && k == 7) { \ |
|
|
|
Eh192_7.InitialiseState(base_state); \ |
|
|
|
} else { \ |
|
|
|
throw std::invalid_argument("Unsupported Equihash parameters"); \ |
|
|
|
} |
|
|
@ -227,6 +233,10 @@ inline bool EhBasicSolve(unsigned int n, unsigned int k, const eh_HashState& bas |
|
|
|
return Eh96_5.BasicSolve(base_state, validBlock, cancelled); |
|
|
|
} else if (n == 48 && k == 5) { |
|
|
|
return Eh48_5.BasicSolve(base_state, validBlock, cancelled); |
|
|
|
} else if (n == 144 && k == 5) { |
|
|
|
return Eh144_5.BasicSolve(base_state, validBlock, cancelled); |
|
|
|
} else if (n == 192 && k == 7) { |
|
|
|
return Eh192_7.BasicSolve(base_state, validBlock, cancelled); |
|
|
|
} else { |
|
|
|
throw std::invalid_argument("Unsupported Equihash parameters"); |
|
|
|
} |
|
|
@ -251,6 +261,10 @@ inline bool EhOptimisedSolve(unsigned int n, unsigned int k, const eh_HashState& |
|
|
|
return Eh96_5.OptimisedSolve(base_state, validBlock, cancelled); |
|
|
|
} else if (n == 48 && k == 5) { |
|
|
|
return Eh48_5.OptimisedSolve(base_state, validBlock, cancelled); |
|
|
|
} else if (n == 144 && k == 5) { |
|
|
|
return Eh144_5.OptimisedSolve(base_state, validBlock, cancelled); |
|
|
|
} else if (n == 192 && k == 7) { |
|
|
|
return Eh192_7.OptimisedSolve(base_state, validBlock, cancelled); |
|
|
|
} else { |
|
|
|
throw std::invalid_argument("Unsupported Equihash parameters"); |
|
|
|
} |
|
|
@ -273,8 +287,33 @@ inline bool EhOptimisedSolveUncancellable(unsigned int n, unsigned int k, const |
|
|
|
ret = Eh96_5.IsValidSolution(base_state, soln); \ |
|
|
|
} else if (n == 48 && k == 5) { \ |
|
|
|
ret = Eh48_5.IsValidSolution(base_state, soln); \ |
|
|
|
} else if (n == 144 && k == 5) { \ |
|
|
|
ret = Eh144_5.IsValidSolution(base_state, soln); \ |
|
|
|
} else if (n == 192 && k == 7) { \ |
|
|
|
ret = Eh192_7.IsValidSolution(base_state, soln); \ |
|
|
|
} else { \ |
|
|
|
throw std::invalid_argument("Unsupported Equihash parameters"); \ |
|
|
|
} |
|
|
|
|
|
|
|
inline unsigned int EhSolutionWidth(int n, int k) |
|
|
|
{ |
|
|
|
unsigned int ret; |
|
|
|
if (n == 96 && k == 3) { |
|
|
|
ret = Eh96_3.SolutionWidth; |
|
|
|
} else if (n == 200 && k == 9) { |
|
|
|
ret = Eh200_9.SolutionWidth; |
|
|
|
} else if (n == 144 && k == 5) { |
|
|
|
ret = Eh144_5.SolutionWidth; |
|
|
|
} else if (n == 192 && k == 7) { |
|
|
|
ret = Eh192_7.SolutionWidth; |
|
|
|
} else if (n == 96 && k == 5) { |
|
|
|
ret = Eh96_5.SolutionWidth; |
|
|
|
} else if (n == 48 && k == 5) { |
|
|
|
ret = Eh48_5.SolutionWidth; |
|
|
|
} else { |
|
|
|
throw std::invalid_argument("Unsupported Equihash parameters"); |
|
|
|
} |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
#endif // BITCOIN_EQUIHASH_H
|
|
|
|