Developing Ledger application (part 1: setting up development environment)

Ahmad Ali Abdilah
4 min readSep 29, 2020

--

*These articles are my personal development logs, if I have wrong comprehension on some stuffs, feel free to let me know

part 2: Creating menu screens manually
part 3: Communicating with Ledger
part 4: Generating Public Key and signing data

Ledger Nano S boot display

I am quite sure, Bitcoin and Ethereum are not foreign anymore to many of us. While being just one of use case of blockchain, the blockchain technology itself has been around for quite sometime now, and it starts to be used widely. Many people use it as a transaction method, trading, and even as a basis of automation as the blockchain capability widen. Not only by experts, non-tech people even starts to interact with blockchain technology in regular basis. But unfortunately, interacting with blockchain application slightly differs with interacting with common client-server application. One of the pain point of blockchain application users is: keeping their private key safe.

Private key acts like password in blockchain application. But unlike common application, the private key of a blockchain application is usually of a specific length and may not be easy to remember by users. Private key also can not be changed, it has direct relationship with your account. Thus, if your private key is compromised, your account (and your funds of course), are taken over. It has been then known as one of the usability problem of blockchain applications. Hardware wallet devices comes trying to solve this problem.

For some of you who have been in the blockchain space for sometimes, you might have heard about “hardware wallet”: a device to keep your blockchain private key save. This device starts being popular nowadays as it provides a portable, secure and easy to use device to use blockchain.

The device performs secure operations within the device itself, like signing the message, so it can ensure that your private never leave the device. Therefore, it is more secure than storing the private key in the browser or local application storage.

Zoobc

So currently my company is developing a blockchain technology called Zoobc, and I received an honor to develop hardware wallet application to support signing Zoobc transaction. After a few researches, we put our initial hardware wallet support choice on a popular hardware wallet: Ledger Nano S.

Developing application of Ledger Nano S has been not an easy task for me, as it has really minimal documentation and close to none tutorial regarding developing application for it. The SDK and other applications available has been my only guidance for developing the application. The community around this is also very limited (I only know the Slack), and asking questions regarding development will not give you instant feedback and guarantee you may find your solution quickly. Thus, I feel like I have to start putting to writing stuffs that I already gained during development of the application. I hope other developers who want to get on board developing application for Ledger will be helped by my experience, and will go through less resistance in doing it.

Before going to the development, here are some facts you need to know about developing Ledger:

Setting up environment

The best environment to develop ledger application is actually Linux as most of the tools we are using is supported better in Linux (as the the warning stated in the ledger documentation). But fortunately there are some workaround if you are using non-Linux (MacOS in my case). If you are using windows or MacOS, it’s better to use Linux VM or Docker to avoid facing some problems during the development, then follow the same procedures and connect the main OS to the Linux VM or Docker.
Once you have a Linux environment, you can follow these steps to setup your environment https://ledger.readthedocs.io/en/latest/userspace/getting_started.html#setting-up-the-toolchain
Also, you need to download SDK for Ledger Nano S https://github.com/LedgerHQ/nanos-secure-sdk

Sample application

To test the environment you have set up, try to compile this sample application and run it in your Ledger Nano S https://github.com/LedgerHQ/ledger-sample-apps/tree/master/blue-app-helloworld using command make clean && make load

Hello World application in Ledger Nano S

If you find your application, open it in you Ledger Nano S, and it shows like in the above picture, congratulations you successfully setup your environment for developing Ledger Nano S application. 🎉🎉

Get to know more about the blockchain technology we are developing: Zoobc in https://zoobc.com/

--

--