/ledger-panacea

Primary LanguageCApache License 2.0Apache-2.0

Ledger MediBloc app

License GithubActions


zondax

Please visit our website at zondax.ch


This project contains the MediBloc app for Ledger Nano S and X.

  • Ledger Nano S/X MediBloc app
  • Specs / Documentation
  • C++ unit tests
  • Zemu tests

ATTENTION

Please:

  • Do not use in production
  • Do not use a Ledger device with funds for development purposes.
  • Have a separate and marked device that is used ONLY for development and testing

Tip:

  • In releases, you will find a precompiled test app. If you are just curious, you can run zxtool.sh and avoid building.

Download and install a prerelease

Once the app is approved by Ledger, it will be available in their app store (Ledger Live). You can get builds generated by CircleCI from the release tab. THESE ARE UNVETTED DEVELOPMENT RELEASES

Download a release from here (https://github.com/Zondax/ledger-cosmos/releases). You only need zxtool.sh

If the file is not executable, run

chmod +x ./zxtool.sh

then run:

./installer_s.sh load

Development

Preconditions

  • Be sure you checkout submodules too:

    git submodule update --init --recursive
    
  • Install Docker CE

  • We only officially support Ubuntu. Install the following packages:

    sudo apt update && sudo apt -y install build-essential git wget cmake \
    libssl-dev libgmp-dev autoconf libtool
    
  • Install node > v13.0. We typically recommend using n

  • You will need python 3 and then run

    • make deps
  • This project requires Ledger firmware 2.0

    • The current repository keeps track of Ledger's SDK but it is possible to override it by changing the git submodule.

Warning: Some IDEs may not use the same python interpreter or virtual enviroment as the one you used when running pip. If you see conan is not found, check that you installed the package in the same interpreter as the one that launches cmake.

How to build ?

We like clion or vscode but let's have some reproducible command line steps

  • Building the app itself

    If you installed the what is described above, just run:

    make

Running tests

  • Running rust tests (x64)

    If you installed the what is described above, just run:

    make rust_test
  • Running C/C++ tests (x64)

    If you installed the what is described above, just run:

    make cpp_test
  • Running device emulation+integration tests!!

     Use Zemu! Explained below!

How to test with Zemu?

What is Zemu?? Great you asked!! As part of this project, we are making public a beta version of our internal testing+emulation framework for Ledger apps.

Npm Package here: https://www.npmjs.com/package/@zondax/zemu

Repo here: https://github.com/Zondax/zemu

Let's go! First install everything:

At this moment, if you change the app you will need to run make before running the test again.

make zemu_install

Then you can run JS tests:

make zemu_test

To run a single specific test:

At the moment, the recommendation is to run from the IDE. Remember to run make if you change the app.

Using a real device

How to prepare your DEVELOPMENT! device:

You can use an emulated device for development. This is only required if you are using a physical device

Please do not use a Ledger device with funds for development purposes.

Have a separate and marked device that is used ONLY for development and testing

In Linux hosts it might be necessary to adjust udev rules, etc. Refer to Ledger documentation: https://support.ledger.com/hc/en-us/articles/115005165269-Fix-connection-issues

Loading into your development device

The Makefile will build the firmware in a docker container and leave the binary in the correct directory.

  • Build

    make                # Builds the app
  • Upload to a device The following command will upload the application to the ledger. Please note that the Nano X doesn't support side loading, therefore you must use the device emulator Speculos for loading to work.

    make load          # Builds and loads the app to the Nano S device
    make delete        # Delete the app from the Nano S device
    
    make loadS2        # Builds and loads the app to the Nano S+ device
    make deleteS2      # Delete the app from the Nano S+ device

APDU Specifications