You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ledgerblue Python modules has issues when icons are passed in
I could not get anything in this repo to build and install using the instructions in the Ledger SDK Documentation.
As warned in the docs, this Makefile does not acknowledge BOLOS_ENV and BOLOS_SDK... instead, you have to specify GCCPATH and CLANGPATH manually.
If I run COIN=bitcoin_testnet make, I get a couple of these errors:
find: ‘/home/brandon/repos/dev-ledger-sdk/qrcode’: No such file or directory
but these appear to be harmless and it does appear to compile.
Now if I run COIN=bitcoin_testnet make load, it errors out due to a TypeError:
TARGET_NAME=TARGET_NANOS TARGET_ID=0x31100002
find: ‘/home/brandon/repos/dev-ledger-sdk/qrcode’: No such file or directory
find: ‘/home/brandon/repos/dev-ledger-sdk/qrcode’: No such file or directory
python -m ledgerblue.loadApp --appFlags 0x50 --curve secp256k1 --targetId 0x31100002 --fileName bin/app.hex --appName "Bitcoin Test" `ICONHEX=\`python /home/brandon/repos/dev-ledger-sdk/icon.py nanos_app_bitcoin_testnet.gif hexbitmaponly 2>/dev/null\` ; [ ! -z "$ICONHEX" ] && echo "--icon $ICONHEX"` --path ""
Generated random root public key : 04a51c...
Using test master key 04a51c...
Using ephemeral key 049f372...
Broken certificate chain - loading from user key
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/brandon/.virtualenvs/dev-ledger-btc-DoSE2Zou/lib/python2.7/site-packages/ledgerblue/loadApp.py", line 174, in <module>
loader.createApp(args.appFlags, appLength, args.appName, icon, path, None, None, args.appVersion)
File "/home/brandon/.virtualenvs/dev-ledger-btc-DoSE2Zou/local/lib/python2.7/site-packages/ledgerblue/hexLoader.py", line 163, in createApp
data = self.encryptAES(data)
File "/home/brandon/.virtualenvs/dev-ledger-btc-DoSE2Zou/local/lib/python2.7/site-packages/ledgerblue/hexLoader.py", line 95, in encryptAES
encryptedData = cipher.encrypt(paddedData)
File "/home/brandon/.virtualenvs/dev-ledger-btc-DoSE2Zou/local/lib/python2.7/site-packages/Crypto/Cipher/blockalgo.py", line 244, in encrypt
return self._cipher.encrypt(plaintext)
TypeError: argument must be string or read-only buffer, not bytearray
Makefile:189: recipe for target 'load' failed
make: *** [load] Error 1
Now, if I try again but I pull out the Python one-liner that the Makefile runs, minus the icon part, this loads the app onto the Ledger just fine:
So it's definitely something about how loader.createApp handles that icon hex.
If I screw up the icon hex on purpose by adding a 0x prefix:
$ python -m ledgerblue.loadApp --appFlags 0x50 --curve secp256k1 --targetId 0x31100002 --fileName bin/app.hex --appName "Bitcoin Test" --icon "0x0100000000ffffff00ffffffffffffbffe0ffc9ff99ff91ff89ff19ff39ff10ff8bffeffffffffffff" --path ""
Generated random root public key : 04d4d313382cce448d43e54e085a9732b6935134f6fbc1a5b7c240d2e6cf2bbf473b46f47fbcf0735a94490aa34d680301508156f1bfd62e9d67f2d28443aba450
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/brandon/.virtualenvs/dev-ledger-btc-DoSE2Zou/lib/python2.7/site-packages/ledgerblue/loadApp.py", line 134, in <module>
icon = bytearray.fromhex(args.icon)
ValueError: non-hexadecimal number found in fromhex() arg at position 0
Now that's interesting, because above it says argument must be string or read-only buffer, not bytearray.
In loader.createApp, the loader part is an instead of HexLoader that comes in via from .hexLoader import HexLoader.
To summarize, there are two issues here:
BOLOS_ENV
andBOLOS_SDK
ledgerblue
Python modules has issues when icons are passed inI could not get anything in this repo to build and install using the instructions in the Ledger SDK Documentation.
As warned in the docs, this Makefile does not acknowledge
BOLOS_ENV
andBOLOS_SDK
... instead, you have to specifyGCCPATH
andCLANGPATH
manually.If I run
COIN=bitcoin_testnet make
, I get a couple of these errors:but these appear to be harmless and it does appear to compile.
Now if I run
COIN=bitcoin_testnet make load
, it errors out due to a TypeError:Now, if I try again but I pull out the Python one-liner that the Makefile runs, minus the icon part, this loads the app onto the Ledger just fine:
This suggests that the problem is in here somewhere, but this also returns properly:
This fails:
So it's definitely something about how
loader.createApp
handles that icon hex.If I screw up the icon hex on purpose by adding a 0x prefix:
Now that's interesting, because above it says
argument must be string or read-only buffer, not bytearray
.In
loader.createApp
, theloader
part is an instead ofHexLoader
that comes in viafrom .hexLoader import HexLoader
.Taking a peek inside
ledgerblue/hexLoader.py
:Ah! Changed it to
encryptedData = cipher.encrypt(buffer(paddedData))
and nowmake load
works great.So, it would appear this is actually a problem in the
ledgerblue
Python module.The text was updated successfully, but these errors were encountered: