Skip to content

Commit

Permalink
Merge pull request #4 from muXxer/master
Browse files Browse the repository at this point in the history
Added Ledger Blue
  • Loading branch information
muXxer committed Dec 20, 2018
2 parents a9ff496 + 16a3101 commit e0d0d79
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 8 deletions.
11 changes: 6 additions & 5 deletions README.md
@@ -1,6 +1,6 @@
# Intro

You're about to install the IOTA beta app on the Ledger Nano S using our beta installer.
You're about to install the IOTA beta app on the Ledger Nano S / Ledger Blue using our beta installer.

See [blue-app-iota GitHub repository](https://github.com/IOTA-Ledger/blue-app-iota) for the original source code.

Expand All @@ -15,6 +15,7 @@ Before getting started, please be sure you've [read the warnings](https://github
## Requirements

Make sure that your Ledger Nano S is running firmware 1.4.2.<br>
Make sure that your Ledger Blue is running firmware 2.1.1.<br>
For update instructions see: [How to update my Ledger Nano S with the firmware 1.4](https://support.ledgerwallet.com/hc/en-us/articles/360001340473-How-to-update-my-Ledger-Nano-S-with-the-firmware-1-4)

## Installation of VirtualBox
Expand All @@ -32,13 +33,13 @@ You can download the latest version of the IOTA VM Installer Image here: [Releas

- Open VirtualBox
- In VirtualBox, click "File" > "Import Appliance"
- Browse to IOTA-Ledger-App-Loader.ova
- Browse to "IOTA-Ledger-Nano-App-Loader.ova" or "IOTA-Ledger-Blue-App-Loader.ova"
- Click "Next"
- Click "Import"

## Installation on the Ledger Nano S
## Installation on the Ledger

- Plug in your Ledger Nano S and enter your pin (you can leave it at the dashboard)
- Plug in your Ledger device and enter your pin (you can leave it at the dashboard)
- Open VirtualBox
- Now select the new VM in the list on the left
- Click "Start"
Expand All @@ -55,7 +56,7 @@ After the installation is done, you should see your IOTA app on the dashboard!

If it worked! Otherwise, feel free to head to issues and ask for help.

You can now continue to use the Ledger Nano S with a supported wallet app.
You can now continue to use the Ledger Nano S / Ledger Blue with a supported wallet app.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions download_app.py
Expand Up @@ -5,10 +5,10 @@
min_version_os = 0x01040200 # e.g. 1.4.2 => 1.4.2.0 => 0x01040200
min_version_mcu = 0x01050000 # e.g. 1.5 => 1.5.0.0 => 0x01050000
file_name = "/root/iota-ledger/download/app.hex"
data_size = 0x00000040 # `cat debug/app.map |grep _nvram_data_size | tr -s ' ' | cut -f2 -d' '`
data_size = 0x00000000 # `cat debug/app.map |grep _nvram_data_size | tr -s ' ' | cut -f2 -d' '`
icon_hex = "0100000000ffffff00ffffffffffffffe7ffe75ffffff7e7ffe7fb7ffffffffff2fff3ffffffffffff" # python $(BOLOS_SDK)/icon.py $(ICONNAME) hexbitmaponly
cmd_check_version = "-m get_ledger_version --targetId 0x%08X --minVersionOS 0x%08X --minVersionMCU 0x%08X" % (target_id, min_version_os, min_version_mcu)
cmd_load_app = "-m ledgerblue.loadApp --path \"44'/4218'\" --path \"44'/01'\" --appFlags 0x00 --tlv --targetId 0x%08X --delete --fileName %s --appName \"IOTA\" --appVersion 0.0.1 --dataSize 0x%08X --icon %s" % (target_id, file_name, data_size, icon_hex)
cmd_load_app = "-m ledgerblue.loadApp --path \"44'/4218'\" --path \"44'/01'\" --appFlags 0x40 --tlv --targetId 0x%08X --delete --fileName %s --appName \"IOTA\" --appVersion 0.0.1 --dataSize 0x%08X --icon %s" % (target_id, file_name, data_size, icon_hex)

exit_code = 1
try:
Expand Down
17 changes: 17 additions & 0 deletions download_app_blue.py
@@ -0,0 +1,17 @@
import os, sys

python_cmd = "python3"
target_id = 0x31010004
file_name = "/root/iota-ledger/download/app.hex"
data_size = 0x00000000 # `cat debug/app.map |grep _nvram_data_size | tr -s ' ' | cut -f2 -d' '`
icon_hex = "0456572200585e34005e623f00636748006a6e510074775e007f806c008a8c79009a9a8b00a9a89e00b4b3aa00c1c0b800d0d1ce00e2e4e200edf0ee00f9f9f900ffffffffffdf8b0400000000000000000070cafdffffffffffffffffffad050000000000000000000000000060eaffffffffffffff8d0000000000000000000000000000000000e9ffffffffffbf00000000000000000000000000000000000000fcffffffff0a00000000000000000000000000000000000000b0ffffffcf000000000000000000000000000000000000000000fcffff0d000000000000000000000000000000000000000000e0ffff090000000000000000000000000000c91a0000000000a0ffdf000000000000000000000000000090ffbf000000000000feaf0000000000000000000000000000c0ffdf000000000000fc5f000000000000000011000000000090ffbf000000000000f70d000000000030ab51ee668c00000000c91a000000000000e00b0000000000b0ff89ffb9cfc60700000000000000000000c0080000000000b0ff19bb527cfa8a0500a26b001100000000b005000000000040ab0120010081e50c00fbdf71dd080000008000000000000000b608e80cb80480c804fcffc2ff1e0000000000000000000010fd5efb2efd891bc503e7bfc0ff1d000000000000000070dd18fe5fc509c8c56f1700200450cc070000000000000000d0ff0db70800000050978f00a5070000000000000000000000c0ff0d000000a50632302910fd5ea09d00000000000000000060cc0710ec0bfc2ded360410fe5fe5ff63490000000000000000208861ff3efb2cedd71e00c709d2dfe5df0100000000000000c0ff2afd1c610254c11c6018005059f7ef0200000000000000e0ff0d51000000000000e59f10bb02b18d0000000000007028c0ff0a0000a107000000e59f80ff095600000000000000fbdf1378000014f70c000040661840dd86ef06000000000020feff09009057ae91060000d08f00982290ff07000000000020feff0800c01a6b808d0000c17e40fe07328900000000000000e8cf0100a5338cc0cf00c02d0256cb42ee040000000000000020020000f978cf505a00c11d20de0050ee05000000000000000000000071015700c25d10328cab30bc55000000000000000000000000f909ea08f7af00309d1068ce00000000000000000000000000d808fc0bc25d0000208baf2500000000000000000000000000601883120080cd03506d380000000000000000000000000000d09f40dd06c0ff090001000000000000000008000000000000c07e80ff09b0ef16570000000000000000600a000000000000008118bb220157c0ff0800000000000000800c00000000000000f96f00fa4d00f5ff0c60170000000000b00e00000000000000f85e00fd8f00d1ff09fbcf0100000000d07f0000000000000070567aea4d94478950ffff0700000000f5bf0000000000000000d1ef3421fd8f0040feff0700000000faef0000000000000000e2ff0560ffbf0000eabf0000000000fdff0900000000000000809c0010fd8f000030040000000090ffff0e000000000000000000000082060000000000000000e0ffffcf000000000000000000000000000000000000000000fcffffff0b00000000000000000000000000000000000000b0ffffffffcf00000000000000000000000000000000000000fcffffffffff8e0000000000000000000000000000000000d8ffffffffffffffad040000000000000000000000000040daffffffffffffffffffdf8b0400000000000000000050b8fdffffffffff" # python $(BOLOS_SDK)/icon.py $(ICONNAME) hexbitmaponly
cmd_load_app = "-m ledgerblue.loadApp --path \"44'/4218'\" --path \"44'/01'\" --appFlags 0x40 --tlv --targetId 0x%08X --delete --fileName %s --appName \"IOTA\" --appVersion 0.5.0 --dataSize 0x%08X --icon %s" % (target_id, file_name, data_size, icon_hex)

exit_code = 1
try:
exit_code = os.system("%s %s" % (python_cmd, cmd_load_app))
if exit_code != 0: # muXxer: Otherwise it returned 256, which was recognized as 0 in the shell
exit_code = 3
except:
pass
sys.exit(exit_code)
15 changes: 15 additions & 0 deletions install_alpine_environment_blue.sh
@@ -0,0 +1,15 @@
#!/bin/sh
apk update
apk add --no-cache ncurses gnupg curl python3 python3-dev gcc git autoconf pkgconf musl-dev libffi-dev automake libtool libusb-dev eudev-dev linux-headers zlib-dev jpeg-dev
gpg --import public.asc
python3 -m ensurepip
pip3 install --upgrade pip setuptools wheel
pip3 install git+https://github.com/LedgerHQ/blue-loader-python.git
cp iota_loader_blue /etc/init.d/
rc-update add iota_loader_blue
pip3 uninstall pillow
apk del --purge python3-dev gcc git autoconf pkgconf musl-dev libffi-dev automake libtool eudev-dev linux-headers zlib-dev jpeg-dev
rm -r /root/.cache
rm -r /tmp/*
dd if=/dev/zero of=/var/tmp/bigemptyfile bs=4096k ; rm /var/tmp/bigemptyfile
history -c
2 changes: 1 addition & 1 deletion iota_loader
Expand Up @@ -31,7 +31,7 @@ start()

mkdir -p /root/iota-ledger/download/
cd /root/iota-ledger/download/
latest_file=`curl -s https://api.github.com/repos/IOTA-Ledger/blue-app-iota/releases | grep browser_download_url | grep app | grep .zip | head -n 1 | cut -d '"' -f 4`
latest_file=`curl -s https://api.github.com/repos/IOTA-Ledger/blue-app-iota/releases | grep browser_download_url | grep nanos-app | grep .zip | head -n 1 | cut -d '"' -f 4`
retVal=$?
if [ $retVal -ne 0 ]; then
echo ""
Expand Down
127 changes: 127 additions & 0 deletions iota_loader_blue
@@ -0,0 +1,127 @@
#!/sbin/openrc-run
# Copyright (c) 2018 muXxer

## Functions
_bold=$(tput bold)
_reset=$(tput sgr0)

_red=$(tput setaf 1)
_green=$(tput setaf 2)
_yellow=$(tput setaf 3)

function print_ok { printf "${_bold}${_green}%s${_reset}\n" "$@"; }
function print_err { printf "${_bold}${_red}%s${_reset}\n" "$@"; }
function print_warn { printf "${_bold}${_yellow}%s${_reset}\n" "$@"; }

depend()
{
after networking sshd
}

start()
{
ebegin "Downloading IOTA-Ledger App..."

echo ""
print_warn "Please read our documentation carefully at https://github.com/IOTA-Ledger/blue-app-iota/"

echo ""
print_ok "Downloading latest compiled binary from https://github.com/IOTA-Ledger/blue-app-iota/releases..."
echo ""

mkdir -p /root/iota-ledger/download/
cd /root/iota-ledger/download/
latest_file=`curl -s https://api.github.com/repos/IOTA-Ledger/blue-app-iota/releases | grep browser_download_url | grep blue-app | grep .zip | head -n 1 | cut -d '"' -f 4`
retVal=$?
if [ $retVal -ne 0 ]; then
echo ""
print_err "No compiled binary found in the GitHub repository! Do you have a working internet connection? Rebooting..."
rm -R /root/iota-ledger/download/
sleep 10
reboot
eend $retVal
fi

curl -L $latest_file -O
retVal=$?
if [ $retVal -ne 0 ]; then
echo ""
print_err "Downloading the latest compiled binary from GitHub failed! Do you have a working internet connection? Rebooting..."
rm -R /root/iota-ledger/download/
sleep 10
reboot
eend $retVal
fi

file_name=`echo $latest_file | rev | cut -d '/' -f 1 | rev`
echo ""
print_ok "Downloaded:"
print_ok ' File name = "'${file_name}'"'

echo ""
#echo "Unzipping the file and comparing the checksum..."
print_ok "Unzipping the file and verifying the digital signature..."
echo ""
unzip ${file_name}
echo ""
#sha256sum -c app.hex.sha256
gpg --verify app.hex.asc
retVal=$?
if [ $retVal -ne 0 ]; then
echo ""
#echo "Checksum missmatch! Something went wrong! Please try again! Rebooting..."
print_err "Digital signature not valid! Something went wrong! Please try again! Rebooting..."
rm -R /root/iota-ledger/download/
sleep 10
reboot
eend $retVal
fi
echo ""
print_ok "File unzipped and digital signature valid!"

echo ""
print_warn "Plugin your Ledger Blue now and forward it in VirtualBox! You have 5 minutes to do this."
print_warn "Searching for Ledger Blue..."
echo ""

time_ms=0
while [ $time_ms -le 300000 ]
do
if [ -e /dev/hidraw1 ]; then
break
fi

usleep 500000
time_ms=$(( $time_ms + 500 ))
done

cd /root/iota-ledger/
python3 download_app_blue.py
retVal=$?
rm -R /root/iota-ledger/download/
if [ $retVal -ne 0 ]; then
echo ""
if [ $retVal -eq 2 ]; then
print_err "Ledger Blue Firmware is too old! Please update your Ledger Blue Firmware and try again! Shutting down VM..."
sleep 5
poweroff
else
print_err "Something went wrong! Please try again! Rebooting..."
sleep 5
reboot
fi
else
echo ""
print_ok "IOTA App installed successfully! Shutting down VM..."
sleep 3
poweroff
fi
eend 0
}

stop()
{
ebegin ""
eend 0
}

0 comments on commit e0d0d79

Please sign in to comment.