Coder Social home page Coder Social logo

app-algorand's Introduction

Algorand App for Ledger Nano S

Run make load to build and load the application onto the device. After installing and running the application, you can run cli/sign.py. Running without any arguments should print the address corresponding to the key on the Ledger device. To sign a transaction, run cli/sign.py input.tx output.tx; this will ask the Ledger device to sign the transaction from input.tx, and put the resulting signed transaction into output.tx. You can use goal clerk send .. -o input.tx to construct an input.tx file, and then use goal clerk rawsend to broadcast the output.tx file to the Algorand network.

Development notes

Python environment

  • sudo apt install python-hid python-hidapi python3-hid python3-hidapi
  • sudo pip install ledgerblue
  • Set up /etc/udev/rules.d based on these notes

Firmware update

Setting up a custom CA for automating app loading

  • Documentation
  • python -m ledgerblue.genCAPair
  • python -m ledgerblue.setupCustomCA --targetId 0x31100004 --public 040db5032de3dc9ac155959bca5e163d1ab35789192495c99b39dceb82dafb5ffad14ce7fd32d739388b6017c606f26028fdfa3e7000fa8c9793740a7aff839587 --name dev
  • export SCP_PRIVKEY=7f189771ea6ee2808e4a66e6b74600b7eadb720a7ccf06bfe2ac0f67c7103250

PRINTF-style debugging

  • python -m ledgerblue.loadMCU --targetId 0x01000001 --fileName blup_0.9_misc_m1.hex --nocrc
  • python -m ledgerblue.loadMCU --targetId 0x01000001 --fileName mcu_1.7-printf_over_0.9.hex --reverse --nocrc
  • ./usbtool/usbtool -v 0x2c97 log
  • Edit Makefile to enable PRINTF (and edit it back for production to disable PRINTF)

To go back to release firmware:

  • Instructions
  • python -m ledgerblue.loadMCU --targetId 0x01000001 --fileName blup_0.9_misc_m1.hex --nocrc
  • python -m ledgerblue.loadMCU --targetId 0x01000001 --fileName mcu_1.7_over_0.9.hex --reverse --nocrc

Python HID debugging

  • Pass debug=True to getDongle() in cli/sign.py

Glyph/icon

  • convert -resize 12 -extent 16x16 -gravity center -colors 2 ...

Assorted complaints / tricks

  • Need volatile for N_ variables; not correctly done in default example
  • ed25519 public keys have an extra garbage byte upfront, then 64 bytes of uncompressed X and Y points, in reverse byte order
  • Have to pass full message to cx_eddsa_sign() despite it being the "hash"
  • bip32 keygen returns 64 bytes instead of 32 needed for Ed25519; not documented anywhere
  • BSS not actually zeroed out; have to explicitly initialize global variables
  • Can't call PRINTF after UX_DISPLAY
  • Converting (int)-2 to (char) and then back to (int) produces 254; the base32 library broke as a result
  • Weird memory behavior
  • The app gets 4KBytes of SRAM for writable memory and stack. Look at debug/app.map to make sure there's nothing too large in SRAM (look between the _bss and _estack symbols), and check for large stack use in functions (look for large sub sp statements in debug/app.asm).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.