Giter VIP home page Giter VIP logo

ledger-zcash's Introduction

Ledger Zcash app

stability-wip License GithubActions


zondax_light zondax_dark

Please visit our website at zondax.ch


This app is still work in progress!

Description of the Project

Welcome to the Ledger Zcash app repository developed by Zondax. This project contains the Zcash application for Ledger Nano S+ and X, providing users with the ability to securely manage their ZEC assets. This application supports sapling, enabling transfers between shielded and non shielded addresses.

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

This repository contains

  • Ledger BOLOS app
  • Specs / Documentation
  • C++ unit tests
  • Rust unit tests
  • Zemu tests

Tip:

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

Download and install

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

With our Zondax Hub you can install asset apps to your Ledger device and test them. This can be done with both released and unreleased versions developed by the zondax team. To install the Ledger Zcash App on your Ledger device, you can simply:

  1. Go to http://hub.zondax.ch/
  2. Connect your wallet
  3. Install the app

Another way to install the app is by downloading the installer script from the release page (https://github.com/Zondax/ledger-zcash/releases) and follow these commands. You only need zxtool.sh

If the file is not executable, run

chmod +x ./installer_s.sh

then run:

./installer_s.sh load

Troubleshooting

If you encounter any issues while using the Ledger Zcash App, please create and issue in this repository and the team will review it. You can also send an email to [email protected]

Contact Information/Support

For support, feedback, or inquiries, please reach out to us at: [email protected]

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 && apt-get -y install build-essential git wget cmake \
    libssl-dev libgmp-dev autoconf libtool
    
  • Install node > v16.0. We typically recommend using n

  • You will need python 3 and then run

    • make deps
  • This project requires Ledger firmware 1.6

    • 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 environment 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

There are a few additional steps that increase reproducibility and simplify development:

1 - Ensure your device works in your OS

2 - Set a test mnemonic

Many of our integration tests expect the device to be configured with a known test mnemonic.

  • Plug your device while pressing the right button

  • Your device will show "Recovery" in the screen

  • Double click

  • Run make dev_init. This will take about 2 minutes. The device will be initialized to:

    PIN: 5555
    Mnemonic: equip will roof matter pink blind book anxiety banner elbow sun young
    

3. Add a development certificate

  • Plug your device while pressing the right button

  • Your device will show "Recovery" in the screen

  • Click both buttons at the same time

  • Enter your pin if necessary

  • Run make dev_ca. The device will receive a development certificate to avoid constant manual confirmations.

Building the Ledger App

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:

    Warning: The application will be deleted before uploading.

    make load          # Builds and loads the app to the device
    

APDU Specifications

  • APDU Protocol
    make load          # Builds and loads the app to the device
    

ledger-zcash's People

Contributors

ainhoa-a avatar carlosala avatar dependabot[bot] avatar emmanuelm41 avatar ftheirs avatar idatucker avatar jleni avatar karrq avatar leongb avatar neithanmo avatar rex4539 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ledger-zcash's Issues

Add support for ZIP 313

ZIP 313 changes the default/conventional fee for shielded transactions from 10,000 zats to 1,000 zats
zcash/zips#408

To implement this change, clients are recommended to change the default fee from 10,000 to 1,000 zats for shielded transactions.

Activation:

  • The new default fee of 0.00001 or 1000 zats must start activation at block 1,080,000
  • With a grace period of ~4 weeks (block 1,120,000) to upgrade to the reduced default transaction fee for zcashd and core clients used by exchanges & service providers.

The implementation to activate the new fee can start anytime from the start to the end of the 4 week transition period outside which the shielded transaction fees will stand out from the updated light client fees of 1000 zats.

Possible bug in ZIP 32 Derivation

In derive_zip32_child_fromseedandpath_ida, the exk updated by update_exk_zip32 uses a dummy ask and nsk.
If I replace them with the real ask, nsk, I get child keys that match librustzcash implementation:

    let master = ExtendedSpendingKey::master(&seed);
    let path = [
        ChildIndex::Hardened(32),
        ChildIndex::Hardened(133),
        ChildIndex::Hardened(1000),
    ];
    let sk = ExtendedSpendingKey::from_path(&master, &path);
    let (_, pa) = sk.default_address();
    let address = encode_payment_address(MainNetwork.hrp_sapling_payment_address(), &pa);

FYI
image

Support for PIRATE (ARRR)

Hello @jleni

This is a great work you done supporting shielded address of Zcash. I was wondering how much additional work it would be to support PIRATE (ARRR) in Ledger devices?

PirateChain is a Komodo fork which is a ZCash fork and has sapling activated. Repo: https://github.com/PirateNetwork/pirate

Please feel free to ask any questions if you have about the PirateChain (ARRR).

Best regards,

SHossain

API Request: Get FVK or at least NSK

Rationale:

With IVK, wallet apps can detect incoming coins but they cannot detect spends without deriving the note NF. Currently, the zcash-ledger APIexposes NSK during signing as part of the proving key (nsk, ak) but not as an independent call.

I request the API standardizes IVK/OVK and NSK but offering a get FVK or get extended full viewing key API.

I don't see any significant change in secrecy or privacy and it would enable the host to provide a consistent UX with cold wallets.

๐Ÿ”— zboto Link

Timeline/requirements for Ledger integration

Hi, are we still waiting on Ledger to integrate this? Is there a way to speed up the process such as if a desktop wallet supported the app?
Would much work be required to support Orchard/Unified addresses? I would say a grant from ZF or ZOMG would be easily supported once Sapling's running on Ledger.
Cheers

๐Ÿ”— zboto Link

Update documentation

While checking the documentation for the app and the surrounding JS library it seems that the documentation is outdated, or the code isn't respecting the documentation.

For example, for INS_GET_ADDR_SECP256K1 the APDUSPEC.md says that the returned public key is 65 bytes, whilst the JS library only attempts to read 33 bytes from the returned buffer...

I didn't check further for now, but we may want to consider updating this while we are refreshing the app

๐Ÿ”— zboto Link

App hangs / cannot be loaded

On the nano s, latest firmware, the app:

  • v3. cannot be loaded -> ledgerblue.commException.CommException: Exception : Invalid status 5103
  • v2. can be loaded but hangs when opened

Previous firmware could run v2. Unfortunately, I cannot downgrade and I'm stuck now with no working version.

App works fine in zemu

๐Ÿ”— zboto Link

Unable to build the app

I'm trying to build the app but it fails on my end after running a few steps on docker image for some reason. Any clues?

TARGET_NAME=TARGET_NANOS TARGET_ID=0x31100004 TARGET_VERSION=1.6.1
BOLOS_ENV=/opt/bolos
BOLOS_ENV is /opt/bolos
cd rust && CARGO_HOME="/project/app/rust/.cargo" cargo fmt
/bin/bash: cargo: command not found
make[1]: *** [Makefile:156: rust] Error 127
make[1]: Leaving directory '/project/app'
make: *** [Makefile:28: default] Error 2
make: Leaving directory '/project'
make: *** [build] Error 2

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.