ryancdotorg / brainflayer

A proof-of-concept cracker for cryptocurrency brainwallets and other low entropy key algorithms.
https://rya.nc/brainflayer
909 stars 459 forks source link

bigger bloom file #188

Open Alf71 opened 1 year ago

Alf71 commented 1 year ago

Hello Ryan,

Would it be feasible to increase

define BLOOM_SIZE (51210241024)

to

define BLOOM_SIZE (102410241024)

in order to get a bigger bloom file?

ryancdotorg commented 1 year ago

Not usefully. The bloom filter implementation has a "hash function" that can't address more than 32 bits. It takes advantage of the fact that the input value is already hashed, and just combines various chunks of it rather than hashing again. This works as long as the filter size is a power of two and the inputs are both big enough and have an approximately uniform distribution.

I had planned to replace it with bloomslice which generalizes the technique, but I have been working on other things.

I don't really understand why anyone is still interested in brainflayer - there are people who have written their own GPU-based tools to steal everything that can be stolen, and there doesn't seem to be any further academic work going on.

Alf71 commented 1 year ago

Lovely and patient conversatiioon partner, as always... And we are not speaking of stealing, as far as all the 160 BTC puzzles were not resolved. I just can't afford to pay my electricity bill, the reason why I am using only 1 - 2 threads... ; ) I got some C application to generate pur random, around 150K to 220 k per second and thread. By increasing the number of rmd160 in bloomfile, I would have a bigger chance.

Alf71 commented 1 year ago

// gcc -o random130_5_2_TEST random130_5_2_TEST.c -lgmp

include

include

include

include

include

define KEY_SIZE 64 // The desired key size

define LEADING_ZEROS 31

int main(void) { mpz_t lower_bound, upper_bound, range, num; gmp_randstate_t state;

mpz_init(lower_bound);
mpz_init(upper_bound);
mpz_init(range);
mpz_init(num);

mpz_set_str(lower_bound, "200000fffffffffffffffffffffffffff", 16);
mpz_set_str(upper_bound, "2fffff000000000000000000000000000", 16);
mpz_sub(range, upper_bound, lower_bound);

gmp_randinit_default(state);

// Use a more random seed, and do it only once outside the loop
gmp_randseed_ui(state, time(NULL));

char str[KEY_SIZE + 1];  // Use the defined key size

while (1) {
    mpz_urandomm(num, state, range);
    mpz_add(num, num, lower_bound);

    // Convert the mpz_t to a string directly with the desired size
    mpz_get_str(str, 16, num);

    // Ensure a minimum of 31 leading zeros
    int str_len = strlen(str);
    if (str_len < KEY_SIZE) {
        int zeros_to_add = KEY_SIZE - str_len;
        memmove(str + zeros_to_add, str, str_len + 1); // Shift the string to make space for leading zeros
        memset(str, '0', zeros_to_add); // Add leading zeros
    }

    // Print the resulting string
    printf("%s\n", str);
}

mpz_clear(lower_bound);
mpz_clear(upper_bound);
mpz_clear(range);
mpz_clear(num);
gmp_randclear(state);

return EXIT_SUCCESS;

} `

ryancdotorg commented 1 year ago

I don't really appreciate the apparent (apologies if I've misread) sarcasm.

For the puzzle coins, there is Pollard's kangaroo algorithm, which is faster than brute force.

If you want to try random keys in the hopes of being lucky to find things before someone doing a faster search, you would be better off doubling the keys repeatedly from a random start point and clamping them when they get too big.

I pushed all my unreleased work on it to a develop branch if you want to play with it. The doubling search algorithm is in there, as is an option to stop after checking a certain number of keys. You'll have to hack it to limit leading zeros.

Alf71 commented 1 year ago

No, that was not sarcasm... : ) And thanks for the new develop branch

ryancdotorg commented 1 year ago

Have you actually tried estimating the expected value of what you're doing? I'm really curious.

Alf71 commented 1 year ago

Not sure what you mean. Puzzle 66 = 6, 6 BTC Puzzle 130 = 13 BTC Puzzle 160 = 16 BTC Some of the pubkeys are known, some not.

At the time there are several apps to try this. Keyhunt, Kangaroo, Brainflayer, Keysubtracter, Python scripts.

I belong to Iceland's and Alberto's school. I have learned a lot from them. I can't C programming, I mainly work with my own Python scripts, and they are of course slow.

Now sports:

I tried to MAKE your dev branch, but got an error message after

git clone --single-branch --branch develop https://github.com/ryancdotorg/brainflayer.git
cd brainflayer make all

ryancdotorg commented 1 year ago

"it works on my machine" - I have Ubuntu 20.04. Don't have time to try to troubleshoot it for you.

Alf71 commented 1 year ago

No problem. You've done already enough. In case someone knows the solution for WSL in Windows 10

$ make all

git submodule init git submodule update gcc -O3 -flto -funsigned-char -falign-functions=16 -falign-loops=16 -falign-jumps=16 -Wall -Wextra -Wno-pointer-sign -Wno-sign-compare -pedantic -std=gnu99 -ggdb brainflayer.o hex.o bloom.o mmapf.o hsearchf.o ec_pubkey_fast.o dldummy.o b58/b58.o scrypt-jane/scrypt-jane.o algo/brainv2.o algo/brainwalletio.o algo/electrum1x.o algo/keccak.o algo/quorum.o algo/sha3.o algo/warpwallet.o sha256/sha256.o sha256/sha256-nayuki64-asm.o sha256/sha256-ssse3-asm.o sha256/sha256-avx-asm.o sha256/sha256-avx2-asm.o sha256/sha256-ni-asm.o secp256k1/.libs/libsecp256k1.a -lrt -lcrypto -lz -lgmp -lpthread -o brainflayer /usr/bin/ld: b58/b58.o (symbol from plugin): in functionb58_csum': (.text+0x0): multiple definition of ripemd160_xform_func'; brainflayer.o (symbol from plugin):(.text+0x0): first defined here /usr/bin/ld: b58/b58.o (symbol from plugin): in functionb58_csum': (.text+0x0): multiple definition of SHA2_256_Transform'; brainflayer.o (symbol from plugin):(.text+0x0): first defined here /usr/bin/ld: sha256/sha256.o (symbol from plugin): in functionripemd160_fast': (.text+0x0): multiple definition of ripemd160_xform_func'; brainflayer.o (symbol from plugin):(.text+0x0): first defined here /usr/bin/ld: sha256/sha256.o (symbol from plugin): in functionripemd160_fast': (.text+0x0): multiple definition of SHA2_256_Transform'; brainflayer.o (symbol from plugin):(.text+0x0): first defined here collect2: error: ld returned 1 exit status make: *** [Makefile:109: brainflayer] Error 1