Make difficulty 128 bit instead of 64 bit

Based on Boolberry work by:
  jahrsg <jahr@jahr.me>
  cr.zoidberg <crypto.zoidberg@gmail.com>
This commit is contained in:
moneromooo-monero 2019-01-31 10:44:08 +00:00
parent e4b049da05
commit 91f4c7f45f
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
30 changed files with 787 additions and 62 deletions

View file

@ -40,7 +40,7 @@ using cryptonote::check_hash;
int main(int argc, char *argv[]) {
crypto::hash h;
for (uint64_t diff = 1;; diff += 1 + (diff >> 8)) {
for (cryptonote::difficulty_type diff = 1;; diff += 1 + (diff >> 8)) {
for (uint16_t b = 0; b < 256; b++) {
memset(&h, b, sizeof(crypto::hash));
if (check_hash(h, diff) != (b == 0 || diff <= 255 / b)) {
@ -50,7 +50,7 @@ int main(int argc, char *argv[]) {
memset(&h, 0, sizeof(crypto::hash));
((char *) &h)[31] = b;
if (check_hash(h, diff) != (diff <= 255 / b)) {
return 1;
return 2;
}
}
}
@ -58,11 +58,11 @@ int main(int argc, char *argv[]) {
uint64_t val = 0;
for (int i = 31; i >= 0; i--) {
val = val * 256 + 255;
((char *) &h)[i] = static_cast<char>(val / diff);
val %= diff;
((char *) &h)[i] = static_cast<char>(static_cast<uint64_t>(val / diff));
val %= diff.convert_to<uint64_t>();
}
if (check_hash(h, diff) != true) {
return 1;
return 3;
}
if (diff > 1) {
for (int i = 0;; i++) {
@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
}
}
if (check_hash(h, diff) != false) {
return 1;
return 4;
}
}
}