| 1282 | } |
| 1283 | |
| 1284 | void VanitySearch::FindKeyCPU(TH_PARAM *ph) { |
| 1285 | |
| 1286 | // Global init |
| 1287 | int thId = ph->threadId; |
| 1288 | counters[thId] = 0; |
| 1289 | |
| 1290 | // CPU Thread |
| 1291 | IntGroup *grp = new IntGroup(CPU_GRP_SIZE/2+1); |
| 1292 | |
| 1293 | // Group Init |
| 1294 | Int key; |
| 1295 | Point startP; |
| 1296 | getCPUStartingKey(thId,key,startP); |
| 1297 | |
| 1298 | Int dx[CPU_GRP_SIZE/2+1]; |
| 1299 | Point pts[CPU_GRP_SIZE]; |
| 1300 | |
| 1301 | Int dy; |
| 1302 | Int dyn; |
| 1303 | Int _s; |
| 1304 | Int _p; |
| 1305 | Point pp; |
| 1306 | Point pn; |
| 1307 | grp->Set(dx); |
| 1308 | |
| 1309 | ph->hasStarted = true; |
| 1310 | ph->rekeyRequest = false; |
| 1311 | |
| 1312 | while (!endOfSearch) { |
| 1313 | |
| 1314 | if (ph->rekeyRequest) { |
| 1315 | getCPUStartingKey(thId, key, startP); |
| 1316 | ph->rekeyRequest = false; |
| 1317 | } |
| 1318 | |
| 1319 | // Fill group |
| 1320 | int i; |
| 1321 | int hLength = (CPU_GRP_SIZE / 2 - 1); |
| 1322 | |
| 1323 | for (i = 0; i < hLength; i++) { |
| 1324 | dx[i].ModSub(&Gn[i].x, &startP.x); |
| 1325 | } |
| 1326 | dx[i].ModSub(&Gn[i].x, &startP.x); // For the first point |
| 1327 | dx[i+1].ModSub(&_2Gn.x, &startP.x); // For the next center point |
| 1328 | |
| 1329 | // Grouped ModInv |
| 1330 | grp->ModInv(); |
| 1331 | |
| 1332 | // We use the fact that P + i*G and P - i*G has the same deltax, so the same inverse |
| 1333 | // We compute key in the positive and negative way from the center of the group |
| 1334 | |
| 1335 | // center point |
| 1336 | pts[CPU_GRP_SIZE/2] = startP; |
| 1337 | |
| 1338 | for (i = 0; i<hLength && !endOfSearch; i++) { |
| 1339 | |
| 1340 | pp = startP; |
| 1341 | pn = startP; |