diff --git a/cpu-miner.c b/cpu-miner.c index 1652a281f..70aa50d0d 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -197,7 +197,7 @@ struct option { static char const usage[] = "\ -Usage: " PROGRAM_NAME " [OPTIONS]\n\ +Usage example: " PROGRAM_NAME " [OPTIONS]\n\ Options:\n\ -a, --algo=ALGO specify the algorithm to use\n\ scrypt scrypt(1024, 1, 1) (default)\n\ diff --git a/cryptonight.c b/cryptonight.c index 43bcef7df..b994214b0 100644 --- a/cryptonight.c +++ b/cryptonight.c @@ -4,6 +4,7 @@ // Modified for CPUminer by Lucas Jones +#include #include "cpuminer-config.h" #include "miner.h" #include "crypto/oaes_lib.h" @@ -112,6 +113,7 @@ struct cryptonight_ctx { oaes_ctx* aes_ctx; }; +// https://cryptonote.org/cns/cns008.txt ? void cryptonight_hash_ctx(void* output, const void* input, size_t len, struct cryptonight_ctx* ctx) { hash_process(&ctx->state.hs, (const uint8_t*) input, len); ctx->aes_ctx = (oaes_ctx*) oaes_alloc(); @@ -134,7 +136,9 @@ void cryptonight_hash_ctx(void* output, const void* input, size_t len, struct cr xor_blocks_dst(&ctx->state.k[0], &ctx->state.k[32], ctx->a); xor_blocks_dst(&ctx->state.k[16], &ctx->state.k[48], ctx->b); - for (i = 0; likely(i < ITER / 4); ++i) { + printf("Before ITER\n"); + + for (i = 0; likely(i < ITER / 8); ++i) { /* Dependency chain: address -> read value ------+ * written value <-+ hard function (AES or MUL) <+ * next address <-+ @@ -151,8 +155,28 @@ void cryptonight_hash_ctx(void* output, const void* input, size_t len, struct cr xor_blocks_dst(ctx->b, ctx->c, &ctx->long_state[j]); /* Iteration 4 */ mul_sum_xor_dst(ctx->b, ctx->a, &ctx->long_state[e2i(ctx->b)]); + + /* Dependency chain: address -> read value ------+ + * written value <-+ hard function (AES or MUL) <+ + * next address <-+ + */ + /* Iteration 1 */ + j = e2i(ctx->a); + aesb_single_round(&ctx->long_state[j], ctx->c, ctx->a); + xor_blocks_dst(ctx->c, ctx->b, &ctx->long_state[j]); + /* Iteration 2 */ + mul_sum_xor_dst(ctx->c, ctx->a, &ctx->long_state[e2i(ctx->c)]); + /* Iteration 3 */ + j = e2i(ctx->a); + aesb_single_round(&ctx->long_state[j], ctx->b, ctx->a); + xor_blocks_dst(ctx->b, ctx->c, &ctx->long_state[j]); + /* Iteration 4 */ + mul_sum_xor_dst(ctx->b, ctx->a, &ctx->long_state[e2i(ctx->b)]); + } + printf("After ITER\n"); + memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE); oaes_key_import_data(ctx->aes_ctx, &ctx->state.hs.b[32], AES_KEY_SIZE); for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE) {