Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
26 changes: 25 additions & 1 deletion cryptonight.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// Modified for CPUminer by Lucas Jones

#include <stdio.h>
#include "cpuminer-config.h"
#include "miner.h"
#include "crypto/oaes_lib.h"
Expand Down Expand Up @@ -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();
Expand All @@ -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 <-+
Expand All @@ -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) {
Expand Down