Skip to content

Commit

Permalink
ProgPoW spec v0.9.1
Browse files Browse the repository at this point in the history
 * and support progpow_light_compute()
 * remove duplication codes.
 * fixed misc bugs.
 * See also:
   - chfast/ethash#108
   - ethereum/go-ethereum#17731
   - https://github.com/ifdefelse/cpp-ethereum/tree/a998c9e9335f4f8bfc89a4f9598d1cce8fad3330
  • Loading branch information
hackmod committed Nov 30, 2018
1 parent 939dd17 commit cddae4a
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 543 deletions.
23 changes: 22 additions & 1 deletion src/libethash/ethash.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
extern "C" {
#endif

typedef struct
{
uint32_t uint32s[32 / sizeof(uint32_t)];
} hash32_t;

/// Type of a seedhash/blockhash e.t.c.
typedef struct ethash_h256 { uint8_t b[32]; } ethash_h256_t;

Expand Down Expand Up @@ -132,7 +137,23 @@ ethash_return_value_t ethash_full_compute(
);

/**
* Calculate the full client data
* Calculate the light client data of the ProgPow
*
* @param light The light client handler
* @param header_hash The header hash to pack into the mix
* @param nonce The nonce to pack into the mix
* @param block_number The block_number
* @return an object of ethash_return_value_t holding the return values
*/
ethash_return_value_t progpow_light_compute(
ethash_light_t light,
ethash_h256_t const header_hash,
uint64_t nonce,
uint64_t block_number
);

/**
* Calculate the full client data of the ProgPoW
*
* @param full The full client handler
* @param header_hash The header hash to pack into the mix
Expand Down
24 changes: 24 additions & 0 deletions src/libethash/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ ethash_light_t ethash_light_new_internal(uint64_t cache_size, ethash_h256_t cons
* @param full_size The size of the full data in bytes.
* @param header_hash The header hash to pack into the mix
* @param nonce The nonce to pack into the mix
* @param block_number The block_number
* @return The resulting hash.
*/
ethash_return_value_t ethash_light_compute_internal(
Expand All @@ -115,6 +116,29 @@ ethash_return_value_t ethash_light_compute_internal(
uint64_t nonce
);

void keccak_f800_round(uint32_t st[25], const int r);
uint64_t keccak_f800(hash32_t header, uint64_t seed, uint32_t *result);
uint32_t progpowMath(uint32_t a, uint32_t b, uint32_t r);
void merge(uint32_t *a, uint32_t b, uint32_t r);

/**
* Calculate the light client data of the ProgPow. Internal version.
*
* @param light The light client handler
* @param full_size The size of the full data in bytes.
* @param header_hash The header hash to pack into the mix
* @param nonce The nonce to pack into the mix
* @param block_number The block_number
* @return The resulting hash.
*/
ethash_return_value_t progpow_light_compute_internal(
ethash_light_t light,
uint64_t full_size,
ethash_h256_t const header_hash,
uint64_t nonce,
uint64_t block_number
);

struct ethash_full {
FILE* file;
uint64_t file_size;
Expand Down
Loading

0 comments on commit cddae4a

Please sign in to comment.