Skip to content

Commit

Permalink
Tweaks after review
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Jun 13, 2016
1 parent f3aee6b commit 09e9a32
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/crypto/equihash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,30 @@
template<unsigned int N, unsigned int K>
int Equihash<N,K>::InitialiseState(eh_HashState& base_state)
{
uint32_t n = htole32(N);
uint32_t k = htole32(K);
uint32_t le_N = htole32(N);
uint32_t le_K = htole32(K);
unsigned char personalization[crypto_generichash_blake2b_PERSONALBYTES] = {};
memcpy(personalization, "ZcashPoW", 8);
memcpy(personalization+8, &n, 4);
memcpy(personalization+12, &k, 4);
memcpy(personalization+8, &le_N, 4);
memcpy(personalization+12, &le_K, 4);
return crypto_generichash_blake2b_init_salt_personal(&base_state,
NULL, 0, // No key.
N/8,
NULL, // No salt.
personalization);
}

// Big-endian so that array comparison is equivalent to integer comparison
// Big-endian so that lexicographic array comparison is equivalent to integer
// comparison
void EhIndexToArray(const eh_index i, unsigned char* array)
{
assert(sizeof(eh_index) == 4);
eh_index bei = htobe32(i);
memcpy(array, &bei, sizeof(eh_index));
}

// Big-endian so that array comparison is equivalent to integer comparison
// Big-endian so that lexicographic array comparison is equivalent to integer
// comparison
eh_index ArrayToEhIndex(const unsigned char* array)
{
assert(sizeof(eh_index) == 4);
Expand Down

0 comments on commit 09e9a32

Please sign in to comment.