From 20ed65279b751dd477d2559da24ac104d541fa1a Mon Sep 17 00:00:00 2001 From: johnny9 <985648+johnny9@users.noreply.github.com> Date: Sat, 27 May 2023 08:24:46 -0400 Subject: [PATCH] Revert "reverted ticket_mask. tried testing nonces nerdminer style" This reverts commit eee399324d8e6caa1a7e51da3336dc84069c75c7. --- components/stratum/mining.c | 43 +++++++++---------------------------- main/bm1397.c | 2 +- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/components/stratum/mining.c b/components/stratum/mining.c index 720cd401..3e068024 100644 --- a/components/stratum/mining.c +++ b/components/stratum/mining.c @@ -117,43 +117,23 @@ double test_nonce_value(bm_job * job, uint32_t nonce) { memcpy(header + 72, &job->target, 4); memcpy(header + 76, &nonce, 4); - // unsigned char swapped_header[80]; - // unsigned char hash_buffer[32]; + unsigned char swapped_header[80]; + unsigned char hash_buffer[32]; unsigned char hash_result[32]; - // printf("data32: "); - // prettyHex(header, 80); - // printf("\n"); + printf("data32: "); + prettyHex(header, 80); - // //endian flip the first 80 bytes. - // //version (4 bytes), prevhash (32 bytes), merkle (32 bytes), time (4 bytes), bits (4 bytes), nonce (4 bytes) = 80 bytes - // flip80bytes((uint32_t *)swapped_header, header); + //endian flip the first 80 bytes. + //version (4 bytes), prevhash (32 bytes), merkle (32 bytes), time (4 bytes), bits (4 bytes), nonce (4 bytes) = 80 bytes + flip80bytes((uint32_t *)swapped_header, header); - // //double hash the header - // mbedtls_sha256(swapped_header, 80, hash_buffer, 0); - // mbedtls_sha256(hash_buffer, 32, hash_result, 0); - - mbedtls_sha256_context midstate, ctx; - - //Calcular midstate - mbedtls_sha256_init(&midstate); - mbedtls_sha256_starts_ret(&midstate, 0); - mbedtls_sha256_update_ret(&midstate, header, 64); - - unsigned char *header64 = header + 64; - - mbedtls_sha256_clone(&ctx, &midstate); //Clonamos el contexto anterior para continuar el SHA desde allĂ­ - mbedtls_sha256_update_ret(&ctx, header64, 16); - mbedtls_sha256_finish_ret(&ctx, hash_result); - - // Segundo SHA-256 - mbedtls_sha256_starts_ret(&ctx, 0); - mbedtls_sha256_update_ret(&ctx, hash_result, 32); - mbedtls_sha256_finish_ret(&ctx, hash_result); + //double hash the header + mbedtls_sha256(swapped_header, 80, hash_buffer, 0); + mbedtls_sha256(hash_buffer, 32, hash_result, 0); printf("hash: "); prettyHex(hash_result, 32); - printf("\n"); // //check that the last 4 bytes are 0 // if (*hash_32 != 0) { // return 0.0; @@ -163,8 +143,5 @@ double test_nonce_value(bm_job * job, uint32_t nonce) { s64 = le256todouble(hash_result); ds = d64 / s64; - mbedtls_sha256_free(&ctx); - mbedtls_sha256_free(&midstate); - return ds; } \ No newline at end of file diff --git a/main/bm1397.c b/main/bm1397.c index c5edd191..d743ec81 100644 --- a/main/bm1397.c +++ b/main/bm1397.c @@ -181,7 +181,7 @@ void send_init(void) { unsigned char init4[9] = {0x00, 0x3C, 0x80, 0x00, 0x80, 0x74}; //init4 - init_4_? send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init4, 6, false); - unsigned char set_ticket[9] = {0x00, 0x14, 0x00, 0x00, 0x00, 0x00}; //set_ticket - ticket_mask + unsigned char set_ticket[9] = {0x00, 0x14, 0x00, 0x00, 0x80, 0xff}; //set_ticket - ticket_mask send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), set_ticket, 6, false); unsigned char init5[9] = {0x00, 0x68, 0xC0, 0x70, 0x01, 0x11}; //init5 - pll3_parameter