elrond-sdk-erdpy
elrond-sdk-erdpy copied to clipboard
Trying to create a new wallet or deriving an existing one give "bad key length"
On macOS 12.1, M1 Macbook Air...
erdpy -v
erdpy 1.0.24
If I do either:
erdpy wallet new --pem
Or:
erdpy --verbose wallet derive ./walletKey.pem --mnemonic
I get the following error:
Traceback (most recent call last):
File "/Users/jamie/elrondsdk/erdpy-venv/bin/erdpy", line 8, in <module>
sys.exit(main())
File "/Users/jamie/elrondsdk/erdpy-venv/lib/python3.8/site-packages/erdpy/cli.py", line 32, in main
_do_main()
File "/Users/jamie/elrondsdk/erdpy-venv/lib/python3.8/site-packages/erdpy/cli.py", line 58, in _do_main
args.func(args)
File "/Users/jamie/elrondsdk/erdpy-venv/lib/python3.8/site-packages/erdpy/cli_wallet.py", line 93, in new_wallet
secret_key, pubkey = wallet.derive_keys(mnemonic)
File "/Users/jamie/elrondsdk/erdpy-venv/lib/python3.8/site-packages/erdpy/wallet/core.py", line 26, in derive_keys
bip39seed = mnemonic_to_bip39seed(mnemonic)
File "/Users/jamie/elrondsdk/erdpy-venv/lib/python3.8/site-packages/erdpy/wallet/core.py", line 39, in mnemonic_to_bip39seed
stretched = hashlib.pbkdf2_hmac("sha512", mnemonic, passphrase, BIP39_PBKDF2_ROUNDS)
ValueError: [digital envelope routines: CRYPTO_internal] bad key length
OK, I've done a little investigation on this, and it seems that the password argument to pbkdf2_hmac
is limited to 128 bytes.
My guess is this is a limitation imposed by the underlying openssl implementation.
Hey,
I have the same error on macOS 12.2.1, M1 Pro.
Do you have a workaround or something?
@jamiebullock, @IonutSKL, thank you for reporting the issue :pray:
Until we come back with an investigation and a fix, do you think you can use the following CLI to create wallets (or the web wallet, for that matter):
https://github.com/ElrondNetwork/erdwalletjs-cli
Further reference:
- https://docs.elrond.com/developers/creating-wallets
and still, how to derive the pem file from mnemonic? because with the erdwalletjs is not possible
and still, how to derive the pem file from mnemonic? because with the erdwalletjs is not possible
@pislaru, erdpy
commands support json
wallet files as well - see the parameters --keyfile
, --passfile
:pray:
@jamiebullock Is this reproducible on M1 with erdpy 1.1.0
?
Hey @ccorcoveanu,
I've tried again after erdpy update.. so, my version is now:
erdpy --version
erdpy 1.2.1
but, same error:
ib/python/site-packages/erdpy/wallet/core.py", line 39, in mnemonic_to_bip39seed
stretched = hashlib.pbkdf2_hmac("sha512", mnemonic, passphrase, BIP39_PBKDF2_ROUNDS)
ValueError: [digital envelope routines: CRYPTO_internal] bad key length
hello there,
up on this ? same error...
Same man, I was following this tutorial: https://docs.elrond.com/developers/tutorials/your-first-dapp/#create-an-owner-wallet and encounter the same error when trying to derive the pem file from mnemonic. Any fix yet guys?
Hello,
We are now at mxpy v7.1.0
and as far as we've tested this, the issue does not persist anymore.
The following command should work fine: mxpy wallet new --format=pem --outfile=test.pem