Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: Multihd on August 26, 2020, 01:17:49 PM



Title: How to overcome 'salt must be a byte string error'?
Post by: Multihd on August 26, 2020, 01:17:49 PM
I'm trying to recover my Multibit HD seed words using decrypt_bitcoinj_seed.py I don't know if anyone has used decrypt_bitcoinj_seed.py or not but I'm getting an error after it runs another python script in its arsenal called common.py with an error: raise TypeError('salt must be a byte string')

There are many opportunities for errors to be thrown is this python script, so if this one is overcome there could be others to follow. (Please see code at the bottom.) The code below shows the salt error.

C:\Python38\decrypt_bitcoinj_seed-master>py decrypt_bitcoinj_seed.py
Traceback (most recent call last):
  File "decrypt_bitcoinj_seed.py", line 319, in <module>
    wallet = load_wallet(wallet_file, get_password)
  File "decrypt_bitcoinj_seed.py", line 132, in load_wallet
    key  = pylibscrypt.scrypt(password.encode('utf_16_be'), salt, olen=32)
  File "C:\Python38\lib\site-packages\pylibscrypt\hashlibscrypt.py", line 49, in scrypt
    check_args(password, salt, N, r, p, olen)
  File "C:\Python38\lib\site-packages\pylibscrypt\common.py", line 49, in check_args
    raise TypeError('salt must be a byte string')
TypeError: salt must be a byte string

Does anyone know how the salt would be edited so it becomes a byte string or is there a better alternative? Also, not that it matters since I have very little programming knowledge, why does the script need all the following to crack the seed words? - password, salt, N, r, p, olen The good news is the "check args" password script part passed. Here's the code I mentioned earlier about all the possibilities for errors to be thrown:

    if not isinstance(password, bytes):
        raise TypeError('password must be a byte string')
    if not isinstance(salt, bytes):
        raise TypeError('salt must be a byte string')
    if not isinstance(N, numbers.Integral):
        raise TypeError('N must be an integer')
    if not isinstance(r, numbers.Integral):
        raise TypeError('r must be an integer')
    if not isinstance(p, numbers.Integral):
        raise TypeError('p must be an integer')
    if not isinstance(olen, numbers.Integral):
        raise TypeError('length must be an integer')
    if N > 2**63:
        raise ValueError('N cannot be larger than 2**63')
    if (N & (N - 1)) or N < 2:
        raise ValueError('N must be a power of two larger than 1')
    if r <= 0:
        raise ValueError('r must be positive')
    if p <= 0:
        raise ValueError('p must be positive')
    if r * p >= 2**30:
        raise ValueError('r * p must be less than 2 ** 30')
    if olen <= 0:
        raise ValueError('length must be positive')

If other errors arise, I will post them here; but I'm hoping it will just work and return my seed words!


Title: Re: How to overcome 'salt must be a byte string error'?
Post by: bob123 on August 30, 2020, 10:22:08 AM
What argument are you calling it with?
Do you provide the salt? If yes, how do you do that?


Does anyone know how the salt would be edited so it becomes a byte string
Use:
Code:
b'ThisIsABinaryString'


Providing the source coude would make it easier for us tho.


Title: Re: How to overcome 'salt must be a byte string error'?
Post by: HCP on September 01, 2020, 01:13:01 AM
C:\Python38\decrypt_bitcoinj_seed-master>py decrypt_bitcoinj_seed.py
Don't use Python3... I believe that "decrypt_bitcoinj_seed" will only work with Python 2...

As per the install instructions on github (https://github.com/gurnec/decrypt_bitcoinj_seed#windows):
Python 2.7 – visit the download page here: https://www.python.org/downloads/windows/, and click the link for the latest Python 2 release

Unfortunately, there are quite a few differences between Python2.7 and Python3 that "broke" a LOT of things... so there are numerous old scripts that just don't play nicely with Python3. :-\