3rdIteration / btcrecover

BTCRecover is an open source wallet password and seed recovery tool. For seed based recovery, this is primarily useful in situations where you have lost/forgotten parts of your mnemonic, or have made an error transcribing it. (So you are either seeing an empty wallet or gettign an error that your seed is invalid) For wallet password or passphrase recovery, it is primarily useful if you have a reasonable idea about what your password might be.
https://btcrecover.readthedocs.io/
GNU General Public License v2.0
552 stars 178 forks source link

GPU search does not work #39

Closed Mathematician09183 closed 4 years ago

Mathematician09183 commented 4 years ago

Using GPU shows wrong number of operations and does not find password: `$ python3 btcrecover.py --wallet=wallet.dat --tokenlist=test.txt --dsw --no-eta --enable-gpu

Starting btcrecover 1.2.0-Cryptoguide on Python 3.6.9 64-bit, 21-bit unicodes, 64-bit ints btcrecover.py: warning: --no-eta without --no-dupchecks can cause out-of-memory failures while searching Wallet difficulty: 277,932 SHA-512 iterations 2020-06-14 16:28:47 : Using 2 OpenCL devices: ALL | GPU GeForce GTX 1070 Ti ALL | GPU GeForce GTX 1070 Ti | 275222 elapsed: 0:00:03 rate: 69.59 kP/s Password search exhausted

$ python3 btcrecover.py --wallet=wallet.dat --tokenlist=test.txt --dsw --no-eta

Starting btcrecover 1.2.0-Cryptoguide on Python 3.6.9 64-bit, 21-bit unicodes, 64-bit ints btcrecover.py: warning: --no-eta without --no-dupchecks can cause out-of-memory failures while searching Wallet difficulty: 277,932 SHA-512 iterations 2020-06-14 16:28:57 : Using 12 worker threads

If this tool helped you to recover funds, please consider donating 1% of what you recovered, in your crypto of choice to: BTC: 37N7B7sdHahCXTcMJgEnHz7YmiR4bEqCrS BCH: qpvjee5vwwsv78xc28kwgd3m9mnn5adargxd94kmrt LTC: M966MQte7agAzdCZe5ssHo7g9VriwXgyqM ETH: 0x72343f2806428dbbc2C11a83A1844912184b4243

Find me on Reddit @ https://www.reddit.com/user/Crypto-Guide

You may also consider donating to Gurnec, who created and maintained this tool until late 2017 @ 3Au8ZodNHPei7MQiSVAWb7NB2yqsb48GW4

Password found: '111'`

for tokenlist: `

password hash: YmM6Z3JBH5FuxI4myS9+eI0KM66zfPX3ibGodvQQRzr41W+bpAISYTR5okw4BAAyym07

3rdIteration commented 4 years ago

Interesting find, especially given the unit-testing all passes. That makes it pretty easy to locate, should be trivial to fix, will have a look. :)

GPU acceleration for Bitcoin Core wallets is available in the OpenCL-WIP branch as well, though using a different OpenCL kernel. https://github.com/3rdIteration/btcrecover/tree/OpenCL-WIP

It is far more user friendly, basically you can just have the same arguments as with CPU processing and just add --enable-opencl the defaults should give you about a 12x speed performance improvement and not really need much in the way of tweaking or tuning. (About to move on to the documentation for the OpenCL branch, as there are already people using it for blockchain.com wallets quite a bit...)

3rdIteration commented 4 years ago

Fixed in OpenCL-WIP branch. https://github.com/3rdIteration/btcrecover/commit/f2c5ad5bbd6a7680faf4edc64a1a6b4b7790f6ec

Also worth noting that this performs about 5x faster than the kernel from the opencl_brute module, so it's worth using. --enable-gpu over --enable-opencl

This won't be merged into the master branch until the docco for the other OpenCL stuff is fixed, but this branch is reasonably stable now, so should be fine.

Mathematician09183 commented 4 years ago

What is missing?

$ python3 btcrecover.py --data-extract --tokenlist=test.txt --dsw --no-eta --enable-opencl

Starting btcrecover 1.2.0-Cryptoguide on Python 3.6.9 64-bit, 21-bit unicodes, 64-bit ints

OpenCL: Available Platforms Platform 0 - Name NVIDIA CUDA, Vendor NVIDIA Corporation

Error: NoneType does not support GPU acceleration

3rdIteration commented 4 years ago

You haven't specified a wallet type, will just make that message a bit more informative.

Mathematician09183 commented 4 years ago

$ python3 btcrecover.py --data-extract --tokenlist=test.txt --dsw --no-eta --enable-gpu

Starting btcrecover 1.2.0-Cryptoguide on Python 3.6.9 64-bit, 21-bit unicodes, 64-bit ints Please enter the data from the extract script

YmM6Z3JBH5FuxI4myS9+eI0KM66zfPX3ibGodvQQRzr41W+bpAISYTR5okw4BAAyym07 Warning: --threads ignored for GPU based Bitcoin Core recovery Traceback (most recent call last): File "btcrecover.py", line 38, in btcrpass.parse_arguments(sys.argv[1:]) File "/root/btcrecover/btcrecover/btcrpass.py", line 3484, in parse_arguments loaded_wallet.init_opencl_kernel(devices, args.global_ws, args.local_ws, args.int_rate, *extra_opencl_args) File "/root/btcrecover/btcrecover/btcrpass.py", line 497, in init_opencl_kernel os.path.join(os.path.dirname(os.path.realpath(file)), "opencl\sha512-bc-kernel.cl")) FileNotFoundError: [Errno 2] No such file or directory: '/root/btcrecover/btcrecover/opencl\sha512-bc-kernel.cl'

I am on Linux. If in the file btcrpass.py I change backslash to slash it works

Mathematician09183 commented 4 years ago

Overall the performance is much weaker than original opencl from gurnec. On this same card (1x1080Ti), this same hash, this same settings ( --global-ws 20480 --local-ws 256) it is 3.13 kP/s vs 6.60kP/s (in peaks 7kP/s)

3rdIteration commented 4 years ago

Fixed up the platform dependent CPU loading, will work cross platform now. (As of https://github.com/3rdIteration/btcrecover/commit/dee8f4049466c3edc2c1db889e7a2e369fa6d51f)

In terms of performance, the kernel from gurnec is one from the johntheripper password cracker whereas the opencl ones use a more generic library opencl_brute. (This is also why adding the OpenCL acceleration to blockchain wallets, Electrum wallets, BIP39 wallet, etc, can all happen at the same time) On the python side, gurnec also made use of numpy data structures, as opposed to Python Lists, so that may also be a factor in terms of performance. The faster kernel won't be removed, so users have that option if they are prepared to "tune" the older one a bit to get a better result. (For Bitcoin Core)

Basically, the next step is to write up the documentation for the OpenCL stuff, rework the docco for the GPU acceleration for Bitcoin Core and then to merge it back in to master. (Including renting some server time and checking how it handles multi-GPU)

3rdIteration commented 4 years ago

Merged into master with https://github.com/3rdIteration/btcrecover/commit/743d9d5f55c46a6e0681dba2647892159d4a02b3