-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyespower.c
More file actions
182 lines (168 loc) · 5.05 KB
/
yespower.c
File metadata and controls
182 lines (168 loc) · 5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*-
* Copyright 2013-2018 Alexander Peslyak
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "cpuminer-config.h"
#include "miner.h"
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "yespower.h"
int verstring;
int scanhash_yespower(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done, int perslen, int verstring)
{
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
uint32_t hash64[8] __attribute__((aligned(32)));
uint32_t endiandata[32];
if (verstring==1)
{
//puts("1111111");
static const yespower_params_t params = {
.version = YESPOWER_1_0,
.N = 2048,
.r = 32,
.pers = NULL,
.perslen = 0
};
}
if (verstring==2)
{
//puts("22222222");
static const yespower_params_t params = {
.version = YESPOWER_1_0,
.N = 4096,
.r = 16,
.pers = NULL,
.perslen = 0
};
}
if (verstring==3)
{
static const yespower_params_t params = {
.version = YESPOWER_1_0,
.N = 2048,
.r = 32,
.pers = (const uint8_t *)"UraniumX",
.perslen = 8
};
}
if (verstring==4)
{
static const yespower_params_t params = {
.version = YESPOWER_1_0,
.N = 2048,
.r = 32,
.pers = "CPUpower: The number of CPU working or available for proof-of-work mining",
.perslen = 73
};
}
if (verstring==5)
{
static const yespower_params_t params = {
.version = YESPOWER_1_0,
.N = 4096,
.r = 32,
.pers = NULL,
.perslen = 0
};
}
if (verstring==6)
{
yespower_params_t params = {
.version = YESPOWER_0_5,
.N = 2048,
.r = 8,
.pers = (const uint8_t *)endiandata,
.perslen = perslen
};
}
/*
static const yespower_params_t v2 = {YESPOWER_1_0, 4096, 16, NULL, 0};
yespower_params_t params = v2;
*/
/*
yespower_params_t params = {
.version = YESPOWER_1_0,
.N = 4096,
.r = 16,
.pers = NULL,
.perslen = 0
};
*/
//we need bigendian data...
int kk=0;
for (; kk < 32; kk++)
{
be32enc(&endiandata[kk], ((uint32_t*)pdata)[kk]);
};
do {
pdata[19] = ++n;
be32enc(&endiandata[19], n);
if (verstring==1) {
static const yespower_params_t v1 = {YESPOWER_1_0, 2048, 32, NULL, 0};
if (yespower_tls((unsigned char *)endiandata, perslen, &v1, (yespower_binary_t *)hash64)) {
puts("FAILED");
return -1;
}
}
if (verstring==2) {
static const yespower_params_t v2 = {YESPOWER_1_0, 4096, 16, NULL, 0};
if (yespower_tls((unsigned char *)endiandata, perslen, &v2, (yespower_binary_t *)hash64)) {
puts("FAILED");
return -1;
}
}
if (verstring==3) {
static const yespower_params_t v3 = {YESPOWER_1_0, 2048, 32, (const uint8_t *)"UraniumX", 8};
if (yespower_tls((unsigned char *)endiandata, perslen, &v3, (yespower_binary_t *)hash64)) {
puts("FAILED");
return -1;
}
}
if (verstring==4) {
static const yespower_params_t v4 = {YESPOWER_1_0, 2048, 32, "CPUpower: The number of CPU working or available for proof-of-work mining", 73};
if (yespower_tls((unsigned char *)endiandata, perslen, &v4, (yespower_binary_t *)hash64)) {
puts("FAILED");
return -1;
}
}
if (verstring==5) {
static const yespower_params_t v5 = {YESPOWER_1_0, 4096, 32, NULL, 0};
if (yespower_tls((unsigned char *)endiandata, perslen, &v5, (yespower_binary_t *)hash64)) {
puts("FAILED");
return -1;
}
}
if (verstring==6) {
yespower_params_t v6 = {YESPOWER_0_5, 2048, 8, (const uint8_t *)endiandata, perslen};
if (yespower_tls((unsigned char *)endiandata, perslen, &v6, (yespower_binary_t *)hash64)) {
puts("FAILED");
return -1;
}
}
if ((hash64[7] < ptarget[7]) || ((hash64[7] == ptarget[7]) && (hash64[6] < ptarget[6])) && fulltest(hash64, ptarget)) {
*hashes_done = n - first_nonce + 1;
return true;
}
} while (n < max_nonce && !work_restart[thr_id].restart);
*hashes_done = n - first_nonce + 1;
pdata[19] = n;
return 0;
}