102 lines
2.7 KiB
Plaintext
102 lines
2.7 KiB
Plaintext
/*
|
|
* yespowerARM.c - Yespower Implementation for ARM Architecture
|
|
*
|
|
* Copyright 2025, Your Name or Company
|
|
*/
|
|
|
|
#include "cpuminer-config.h"
|
|
#include "version.h"
|
|
#include "miner.h"
|
|
|
|
#include "yespower-1.0.1/yespower.h"
|
|
#include "yespower-1.0.1/sysendian.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <inttypes.h>
|
|
|
|
|
|
// Yespower parameters for ARM-specific optimization
|
|
static const yespower_params_t yespower_params_arm = {
|
|
.version = YESPOWER_1_0,
|
|
.N = 2048, // Reduced for ARM performance
|
|
.r = 8,
|
|
.pers = (const uint8_t *)"ARMMining",
|
|
.perslen = 9 // Length of "ARMMining"
|
|
};
|
|
|
|
// Initialize local data structure for thread-local storage
|
|
int yespower_arm_init_local(yespower_local_t *local) {
|
|
return yespower_init_local(local);
|
|
}
|
|
|
|
// Free local thread storage
|
|
int yespower_arm_free_local(yespower_local_t *local) {
|
|
return yespower_free_local(local);
|
|
}
|
|
|
|
// Compute the Yespower hash for ARM
|
|
int yespower_arm_hash(const uint8_t *src, size_t srclen, uint8_t *dst) {
|
|
yespower_binary_t hash;
|
|
|
|
int ret = yespower_tls(src, srclen, &yespower_params_arm, &hash);
|
|
if (ret != 0) {
|
|
fprintf(stderr, "Error computing Yespower hash on ARM\n");
|
|
return ret;
|
|
}
|
|
|
|
// Copy the computed hash to the destination
|
|
memcpy(dst, hash.uc, 32);
|
|
return 0;
|
|
}
|
|
|
|
// Example usage for mining
|
|
int scanhash_arm_yespower(int thr_id, uint32_t *data, const uint32_t *target, uint32_t max_nonce, unsigned long *hashes_done) {
|
|
uint32_t nonce = data[19]; // Nonce is at index 19
|
|
uint8_t hash[32];
|
|
int result = 0;
|
|
|
|
*hashes_done = 0; // Initialize hash counter
|
|
|
|
for (; nonce < max_nonce; nonce++) {
|
|
data[19] = nonce; // Update the nonce
|
|
|
|
// Compute Yespower hash
|
|
if (yespower_arm_hash((const uint8_t *)data, 80, hash) != 0) {
|
|
fprintf(stderr, "Thread %d: Error in Yespower hash computation.\n", thr_id);
|
|
break;
|
|
}
|
|
|
|
// Check if the hash is below the target
|
|
if (memcmp(hash, target, 32) <= 0) {
|
|
printf("Thread %d: Valid hash found! Nonce: %u\n", thr_id, nonce);
|
|
result = 1;
|
|
break;
|
|
}
|
|
|
|
(*hashes_done)++;
|
|
}
|
|
|
|
data[19] = nonce; // Restore the final nonce value
|
|
return result;
|
|
}
|
|
|
|
// Test function for Yespower on ARM
|
|
void test_yespower_arm() {
|
|
uint8_t input[80] = {0};
|
|
uint8_t output[32] = {0};
|
|
|
|
// Example input data
|
|
memset(input, 0xAB, sizeof(input));
|
|
|
|
if (yespower_arm_hash(input, sizeof(input), output) == 0) {
|
|
printf("Yespower hash successfully computed on ARM:\n");
|
|
for (int i = 0; i < 32; i++) {
|
|
printf("%02x", output[i]);
|
|
}
|
|
printf("\n");
|
|
} else {
|
|
printf("Failed to compute Yespower hash on ARM\n");
|
|
}
|
|
}
|
|
|