Revert "reverted ticket_mask. tried testing nonces nerdminer style"

This reverts commit eee399324d8e6caa1a7e51da3336dc84069c75c7.
This commit is contained in:
johnny9 2023-05-27 08:24:46 -04:00
parent b7a18871a7
commit 20ed65279b
2 changed files with 11 additions and 34 deletions

View File

@ -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;
}

View File

@ -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