Sep 19

Splitting your Ethers securely on your Nano S

We covered in the past an example of how dynamic applications supported by Ledger Nano S and Blue were quite useful to secure interactions with smart contracts for TheDAO tokens — we’ll now cover a similar use case for splitting Ethers, along with an example for power users before offering a simple User Interface around it. This article is less developer oriented than the previous one.

ETH, ETC and the splitting problem

Let’s see why splitting is necessary in the first place.

When the Ethereum fork happened, all existing coins were duplicated on both branches on the fork (the original chain, Ethereum Classic — ETC and the forked chain, Ethereum — ETH). For the clients and the nodes, both chains are indistinguishable, which means that if the right conditions are met for an account on both sides of the fork (if both have the same number of transactions and acceptable balances), transactions sent on one chain will be duplicated on the other one automatically while the nodes broadcast it. This creates very confusing scenarios, and can be solved by splitting.

Splitting is achieved by sending a transaction to a smart contract existing on both chains and having a different behavior on each one — it will redirect the funds to a different account on each side.

You can find preexisting splitting contracts to run into your favorite Ethereum client, and several third parties such as Shapeshift or MyEtherWallet are offering a splitting contract as a service. Both are quite useful but create security risk that dynamic hardware wallet applications can solve.

Splitting security issues

Some third party services can require your private key associated to the account to split, which is of course a large security risk if malwares are listening or if the user is tricked into an hostile service impersonating the real one (this unfortunately already happened for MyEtherWallet)

All splitting contracts share the same security risk — the contract parameters include the destination addresses on both sides of the fork, and the contract has no way to verify that these addresses belong to the user.

To solve those issues, a hardware wallet dynamic application aware of the contract can enforce that the address is derived from the Hierarchical Deterministic wallet and of course never expose the private key associated to the account.

Performing a split

To use our splitting sample, proceed as follows :

  • Make sure that your Ledger ETH balance is made of pre-forked only ETH assets (if your ETH balance is empty, send your ETH from a wallet containing a pre-fork balance)
  • Install the Python environment with pip install ledgerblue or clone it from https://github.com/ledgerhq/blue-loader-python
  • Clone or download the project repository at https://github.com/btchip/ethsplit-demo
  • Connect your Nano S and load the application with load_10.sh (if you installed the latest development environment on a Nano S, use load_11.sh instead) — on Windows, you’ll need to run the loading command manually, replacing the path with the version you wish to load
python.exe -m ledgerblue.loadApp --targetId 0x31100002 --fileName bin/1.0/token-chainsplit.hex --appName "ETC/ETH Split" --icon 0100ffffff0000000000000000000080008000c000c000e000c0002000c000c0008000000000000000 --appFlags 0x40 --path "44'/60'" --path "44'/61'" --curve secp256k1 --signature 30450221009cef8dfecf1ec5dad3556a1b59464e514083be1e2820f2534d876323b818c07a02205d72b514142ae85be723c4fee64e305a57b8296cd79704b06cfdfa80870b7b3e
  • Run pip install requests rlp pycryptodome
  • Run the ETH/ETC Spilt application on the Nano S
  • To test a full split from ETH to ETC on the default Nano S account, just run python splitEther.py — if you need more flexibility, you can customize the parameters
  • When verifying that everything is correct, you can perform it live with
python splitEther.py --broadcast
  • You’ll then have safe balances on your device’s ETH and ETC addresses

Developers, join our Slack!

The ability to provide clear information to the user on what a smart contract is doing is a key functionality of the dynamic applications provided by Nano S and Ledger Blue — expect more for popular contracts such as the Token standard (ERC 20) and join our developer slack at http://slack.ledger.co/ to discuss your use cases and integration.

The code of this sample is available on https://github.com/ledgerhq/blue-app-eth in the src_chainsplit directory — for more details regarding the modifications allowing to parse the smart contract data, you can refer to our previous Medium post on that topic.

BOLOS series

<< Dynamic secure applications with BOLOS and Ledger Blue